diff options
author | sky <sky@chromium.org> | 2015-04-23 09:20:09 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-04-23 16:20:15 +0000 |
commit | d866af3aee3eff86fcc93f24d77bef4425b80b5a (patch) | |
tree | a56f26a75a7809e7556e07b1a8cf09fd073bfe7d /third_party/mojo_services | |
parent | 29b6f6fa8785ed80c2fcf043bb0619f3f8b80065 (diff) | |
download | chromium_src-d866af3aee3eff86fcc93f24d77bef4425b80b5a.zip chromium_src-d866af3aee3eff86fcc93f24d77bef4425b80b5a.tar.gz chromium_src-d866af3aee3eff86fcc93f24d77bef4425b80b5a.tar.bz2 |
Moves services implementations out of third_party/mojo_services
Most go into components/, with the exception of events and
input_events. They are in ui/mojo now.
R=ben@chromium.org, jam@chromium.org, jochen@chromium.org
TBR=jochen@chromium.org
BUG=479353
Review URL: https://codereview.chromium.org/1085233004
Cr-Commit-Position: refs/heads/master@{#326535}
Diffstat (limited to 'third_party/mojo_services')
62 files changed, 4 insertions, 4877 deletions
diff --git a/third_party/mojo_services/src/accessibility/public/interfaces/BUILD.gn b/third_party/mojo_services/src/accessibility/public/interfaces/BUILD.gn index 2b29c1a..d3f7b78 100644 --- a/third_party/mojo_services/src/accessibility/public/interfaces/BUILD.gn +++ b/third_party/mojo_services/src/accessibility/public/interfaces/BUILD.gn @@ -3,7 +3,7 @@ # found in the LICENSE file. import("//build/module_args/mojo.gni") -import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni") +import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni") mojom("interfaces") { sources = [ @@ -13,6 +13,6 @@ mojom("interfaces") { import_dirs = [ get_path_info("../../../", "abspath") ] deps = [ - "../../../geometry/public/interfaces", + "//ui/mojo/geometry:interfaces", ] } diff --git a/third_party/mojo_services/src/accessibility/public/interfaces/accessibility.mojom b/third_party/mojo_services/src/accessibility/public/interfaces/accessibility.mojom index 3958388..048d639 100644 --- a/third_party/mojo_services/src/accessibility/public/interfaces/accessibility.mojom +++ b/third_party/mojo_services/src/accessibility/public/interfaces/accessibility.mojom @@ -4,7 +4,7 @@ module mojo; -import "geometry/public/interfaces/geometry.mojom"; +import "ui/mojo/geometry/geometry.mojom"; interface AxProvider { GetTree() => (array<AxNode> nodes); diff --git a/third_party/mojo_services/src/clipboard/public/interfaces/BUILD.gn b/third_party/mojo_services/src/clipboard/public/interfaces/BUILD.gn index 16fe33b..6ee9bb7 100644 --- a/third_party/mojo_services/src/clipboard/public/interfaces/BUILD.gn +++ b/third_party/mojo_services/src/clipboard/public/interfaces/BUILD.gn @@ -3,7 +3,7 @@ # found in the LICENSE file. import("//build/module_args/mojo.gni") -import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni") +import("//third_party/mojo/src/mojo/public/tools/bindings/mojom.gni") mojom("interfaces") { sources = [ diff --git a/third_party/mojo_services/src/geometry/public/cpp/BUILD.gn b/third_party/mojo_services/src/geometry/public/cpp/BUILD.gn deleted file mode 100644 index c527c93..0000000 --- a/third_party/mojo_services/src/geometry/public/cpp/BUILD.gn +++ /dev/null @@ -1,18 +0,0 @@ -# Copyright 2014 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. - -import("//build/module_args/mojo.gni") -import("$mojo_sdk_root/mojo/public/mojo_sdk.gni") - -mojo_sdk_source_set("cpp") { - restrict_external_deps = false - public_configs = [ "../../../public/build/config:mojo_services" ] - sources = [ - "geometry_util.h", - ] - - deps = [ - "../interfaces", - ] -} diff --git a/third_party/mojo_services/src/geometry/public/cpp/geometry_util.h b/third_party/mojo_services/src/geometry/public/cpp/geometry_util.h deleted file mode 100644 index f69fac3..0000000 --- a/third_party/mojo_services/src/geometry/public/cpp/geometry_util.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 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 MOJO_SERVICES_GEOMETRY_PUBLIC_CPP_GEOMETRY_UTIL_H_ -#define MOJO_SERVICES_GEOMETRY_PUBLIC_CPP_GEOMETRY_UTIL_H_ - -#include "geometry/public/interfaces/geometry.mojom.h" - -namespace mojo { - -inline bool operator==(const Rect& lhs, const Rect& rhs) { - return lhs.x == rhs.x && lhs.y == rhs.y && lhs.width == rhs.width && - lhs.height == lhs.height; -} - -inline bool operator!=(const Rect& lhs, const Rect& rhs) { - return !(lhs == rhs); -} - -inline bool operator==(const Size& lhs, const Size& rhs) { - return lhs.width == rhs.width && lhs.height == rhs.height; -} - -inline bool operator!=(const Size& lhs, const Size& rhs) { - return !(lhs == rhs); -} - -inline bool operator==(const Point& lhs, const Point& rhs) { - return lhs.x == rhs.x && lhs.y == rhs.y; -} - -inline bool operator!=(const Point& lhs, const Point& rhs) { - return !(lhs == rhs); -} - -} - -#endif // MOJO_SERVICES_GEOMETRY_PUBLIC_CPP_GEOMETRY_UTIL_H_ diff --git a/third_party/mojo_services/src/geometry/public/interfaces/BUILD.gn b/third_party/mojo_services/src/geometry/public/interfaces/BUILD.gn deleted file mode 100644 index 9047ee2..0000000 --- a/third_party/mojo_services/src/geometry/public/interfaces/BUILD.gn +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright 2014 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. - -import("//build/module_args/mojo.gni") -import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni") - -mojom("interfaces") { - sources = [ - "geometry.mojom", - ] -} diff --git a/third_party/mojo_services/src/geometry/public/interfaces/geometry.mojom b/third_party/mojo_services/src/geometry/public/interfaces/geometry.mojom deleted file mode 100644 index 62bc6c8..0000000 --- a/third_party/mojo_services/src/geometry/public/interfaces/geometry.mojom +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -struct Point { - int32 x; - int32 y; -}; - -struct PointF { - float x; - float y; -}; - -struct Size { - int32 width; - int32 height; -}; - -struct Rect { - int32 x; - int32 y; - int32 width; - int32 height; -}; - -struct RectF { - float x; - float y; - float width; - float height; -}; - -struct Transform { - // Row major order. - array<float, 16> matrix; -}; diff --git a/third_party/mojo_services/src/gpu/public/interfaces/BUILD.gn b/third_party/mojo_services/src/gpu/public/interfaces/BUILD.gn deleted file mode 100644 index ec061df..0000000 --- a/third_party/mojo_services/src/gpu/public/interfaces/BUILD.gn +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2014 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. - -import("//build/module_args/mojo.gni") -import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni") - -mojom("interfaces") { - sources = [ - "command_buffer.mojom", - "context_provider.mojom", - "gpu.mojom", - "gpu_capabilities.mojom", - "viewport_parameter_listener.mojom", - ] - - import_dirs = [ get_path_info("../../../", "abspath") ] - - deps = [ - "../../../geometry/public/interfaces", - ] -} diff --git a/third_party/mojo_services/src/gpu/public/interfaces/command_buffer.mojom b/third_party/mojo_services/src/gpu/public/interfaces/command_buffer.mojom deleted file mode 100644 index aa2c556..0000000 --- a/third_party/mojo_services/src/gpu/public/interfaces/command_buffer.mojom +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -import "gpu/public/interfaces/gpu_capabilities.mojom"; - -struct CommandBufferState { - int32 num_entries; - int32 get_offset; - int32 put_offset; - int32 token; - int32 error; // TODO(piman): enum - int32 context_lost_reason; // TODO(piman): enum - uint32 generation; -}; - -interface CommandBufferSyncClient { - DidInitialize(bool success, GpuCapabilities capabilities); - DidMakeProgress(CommandBufferState state); -}; - -interface CommandBufferSyncPointClient { - DidInsertSyncPoint(uint32 sync_point); -}; - -interface CommandBufferLostContextObserver { - DidLoseContext(int32 context_lost_reason); -}; - -interface CommandBuffer { - // Initialize attempts to initialize the command buffer. Success or failure - // will be communicated via the CommandBufferSyncClient DidInitialize() call. - // If the context is lost after creation the LostContext method on the - // CommandBufferLostContextObserver's will be called then this pipe will be - // closed. - Initialize(CommandBufferSyncClient sync_client, - CommandBufferSyncPointClient sync_point_client, - CommandBufferLostContextObserver lost_observer, - handle<shared_buffer> shared_state); - SetGetBuffer(int32 buffer); - Flush(int32 put_offset); - MakeProgress(int32 last_get_offset); - RegisterTransferBuffer( - int32 id, handle<shared_buffer> transfer_buffer, uint32 size); - DestroyTransferBuffer(int32 id); - - // InsertSyncPoint returns the sync point returned via DidInsertSyncPoint. - // If |retire| is true, the sync point is retired on insertion. Otherwise, - // explicitly call RetireSyncPoint to retire it. - InsertSyncPoint(bool retire); - RetireSyncPoint(uint32 sync_point); - Echo() => (); -}; diff --git a/third_party/mojo_services/src/gpu/public/interfaces/context_provider.mojom b/third_party/mojo_services/src/gpu/public/interfaces/context_provider.mojom deleted file mode 100644 index 59d3b7b..0000000 --- a/third_party/mojo_services/src/gpu/public/interfaces/context_provider.mojom +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2015 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. - -module mojo; - -import "gpu/public/interfaces/command_buffer.mojom"; -import "gpu/public/interfaces/viewport_parameter_listener.mojom"; - -// A ContextProvider can be used to provide new command buffers related to a -// particular context, for instance configured to draw to a particular display. -interface ContextProvider { - // This initializes a new command buffer for this provider when available, - // closing connections to the previously created command buffer (if any). - // - // This call may not return for an extended period of time if a command - // buffer cannot be produced immediately, for example if it is associated - // with a view that is offscreen. - // - // If a viewport_parameter_listener is provided it will notified be when - // vsync parameters change for this context. - // - // The returned handle will be null if no command buffer can be created for - // this request, for example if another request is made on the same provider - // before a previous call returns. - Create(ViewportParameterListener? viewport_parameter_listener) - => (CommandBuffer? gles2_client); -}; diff --git a/third_party/mojo_services/src/gpu/public/interfaces/gpu.mojom b/third_party/mojo_services/src/gpu/public/interfaces/gpu.mojom deleted file mode 100644 index d3deb46..0000000 --- a/third_party/mojo_services/src/gpu/public/interfaces/gpu.mojom +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -import "gpu/public/interfaces/command_buffer.mojom"; - -interface Gpu { - // Creates a new offscreen OpenGL ES 2.0 context. - CreateOffscreenGLES2Context(CommandBuffer& gles2_client); -}; diff --git a/third_party/mojo_services/src/gpu/public/interfaces/gpu_capabilities.mojom b/third_party/mojo_services/src/gpu/public/interfaces/gpu_capabilities.mojom deleted file mode 100644 index 2450139..0000000 --- a/third_party/mojo_services/src/gpu/public/interfaces/gpu_capabilities.mojom +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -struct GpuShaderPrecision { - int32 min_range; - int32 max_range; - int32 precision; -}; - -struct GpuPerStagePrecisions { - GpuShaderPrecision low_int; - GpuShaderPrecision medium_int; - GpuShaderPrecision high_int; - GpuShaderPrecision low_float; - GpuShaderPrecision medium_float; - GpuShaderPrecision high_float; -}; - -struct GpuCapabilities { - GpuPerStagePrecisions vertex_shader_precisions; - GpuPerStagePrecisions fragment_shader_precisions; - int32 max_combined_texture_image_units; - int32 max_cube_map_texture_size; - int32 max_fragment_uniform_vectors; - int32 max_renderbuffer_size; - int32 max_texture_image_units; - int32 max_texture_size; - int32 max_varying_vectors; - int32 max_vertex_attribs; - int32 max_vertex_texture_image_units; - int32 max_vertex_uniform_vectors; - int32 num_compressed_texture_formats; - int32 num_shader_binary_formats; - int32 bind_generates_resource_chromium; - - bool post_sub_buffer; - bool egl_image_external; - bool texture_format_bgra8888; - bool texture_format_etc1; - bool texture_format_etc1_npot; - bool texture_rectangle; - bool iosurface; - bool texture_usage; - bool texture_storage; - bool discard_framebuffer; - bool sync_query; - bool image; - bool future_sync_points; - bool blend_equation_advanced; - bool blend_equation_advanced_coherent; -}; diff --git a/third_party/mojo_services/src/gpu/public/interfaces/viewport_parameter_listener.mojom b/third_party/mojo_services/src/gpu/public/interfaces/viewport_parameter_listener.mojom deleted file mode 100644 index 5afa931..0000000 --- a/third_party/mojo_services/src/gpu/public/interfaces/viewport_parameter_listener.mojom +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -interface ViewportParameterListener { - // These parameters describe the refresh rate of the viewport. The viewport - // refreshes every |interval| time ticks. The phase of the refresh is - // indicated by |timebase|, which is synchronized with MojoGetTimeTicksNow. - OnVSyncParametersUpdated(int64 timebase, int64 interval); -}; diff --git a/third_party/mojo_services/src/input_events/public/interfaces/BUILD.gn b/third_party/mojo_services/src/input_events/public/interfaces/BUILD.gn deleted file mode 100644 index 5ef09eb..0000000 --- a/third_party/mojo_services/src/input_events/public/interfaces/BUILD.gn +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright 2014 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. - -import("//build/module_args/mojo.gni") -import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni") - -mojom("interfaces") { - sources = [ - "input_event_constants.mojom", - "input_events.mojom", - "input_key_codes.mojom", - ] - - import_dirs = [ get_path_info("../../../", "abspath") ] - - deps = [ - "../../../geometry/public/interfaces", - ] -} diff --git a/third_party/mojo_services/src/input_events/public/interfaces/input_event_constants.mojom b/third_party/mojo_services/src/input_events/public/interfaces/input_event_constants.mojom deleted file mode 100644 index b3e0ea1..0000000 --- a/third_party/mojo_services/src/input_events/public/interfaces/input_event_constants.mojom +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -enum EventType { - UNKNOWN, - KEY_PRESSED, - KEY_RELEASED, - POINTER_CANCEL, - POINTER_DOWN, - POINTER_MOVE, - POINTER_UP, -}; - -// This mirrors ui::EventFlags -// TODO(morrita): Use shift operator once it is available. -enum EventFlags { - NONE = 0, - CAPS_LOCK_DOWN = 1, - SHIFT_DOWN = 2, - CONTROL_DOWN = 4, - ALT_DOWN = 8, - LEFT_MOUSE_BUTTON = 16, - MIDDLE_MOUSE_BUTTON = 32, - RIGHT_MOUSE_BUTTON = 64, - COMMAND_DOWN = 128, - EXTENDED = 256, - IS_SYNTHESIZED = 512, - ALTGR_DOWN = 1024, - MOD3_DOWN = 2048 -}; - -enum MouseEventFlags { - IS_DOUBLE_CLICK = 65536, - IS_TRIPLE_CLICK = 131072, - IS_NON_CLIENT = 262144, - - // TODO(erg): Move accessibility flags and maybe synthetic touch events here. -}; - -enum PointerKind { - TOUCH, - MOUSE, -}; diff --git a/third_party/mojo_services/src/input_events/public/interfaces/input_events.mojom b/third_party/mojo_services/src/input_events/public/interfaces/input_events.mojom deleted file mode 100644 index 9fa36303..0000000 --- a/third_party/mojo_services/src/input_events/public/interfaces/input_events.mojom +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -import "geometry/public/interfaces/geometry.mojom"; -import "input_events/public/interfaces/input_event_constants.mojom"; -import "input_events/public/interfaces/input_key_codes.mojom"; - -struct KeyData { - // The chromium event key code; these values are from the ui/ KeyCode enum, - // which has the fun property of being neither consistently the Windows key - // code, nor the X11 keycodes. (This value is consistent across platforms - // for basic ASCII characters; it will differ for modifiers. We don't define - // this as a mojo enum because mojom doesn't appear to have a platform - // dependent preprocessor yet.) - // - // TODO(erg): Remove this, and declare Win32 keycodes correct by fiat. We can - // not do this until we remove ui::Event usage from within mojo. - int32 key_code; - - // Whether this is a character event, and the character value if it is. Note - // that this is different than |text|, which holds a value even when there - // isn't actually a character to insert. (For example, |text| will be set and - // have a value on backspace, and |character| won't.) - bool is_char; - uint16 character; - - // The Win32 key code. Because of the web, this is the closest thing that we - // have to a cross platform key state. - KeyboardCode windows_key_code; - - // The platform specific key code. - // - // TODO(erg): This exists only for NPAPI support, pepper USB keyboard support - // and IME on android support. Theoretically, we should be able to remove this - // in the medium to long term. - int32 native_key_code; - - // The text generated by this keystroke. Corresponds to - // blink::WebKeyboardEvent::text. - uint16 text; - - // Like |text|, but unmodified by concurrently held modifier keys (except - // shift). Corresponds to blink::WebKeyboardEvent::unmodifiedText. - uint16 unmodified_text; -}; - -struct PointerData { - int32 pointer_id; - PointerKind kind; - // |x| and |y| are in the coordinate system of the View. - float x; - float y; - // |screen_x| and |screen_y| are in screen coordinates. - float screen_x; - float screen_y; - float pressure; - float radius_major; - float radius_minor; - float orientation; - // Used for devices that support wheels. Ranges from -1 to 1. - float horizontal_wheel; - float vertical_wheel; -}; - -struct Event { - // TODO(sky): rename to type. - EventType action; - // TODO(sky): parts of this should move to PointerData. - EventFlags flags; - // Time the event was delivered. The time is in milliseconds and corresponds - // to the uptime of the machine. - int64 time_stamp; - KeyData? key_data; - PointerData? pointer_data; -}; diff --git a/third_party/mojo_services/src/input_events/public/interfaces/input_key_codes.mojom b/third_party/mojo_services/src/input_events/public/interfaces/input_key_codes.mojom deleted file mode 100644 index 695f5bd..0000000 --- a/third_party/mojo_services/src/input_events/public/interfaces/input_key_codes.mojom +++ /dev/null @@ -1,186 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -// Cross platform keyboard codes. -// -// Because the web has standardized on Win32 keyboard codes, so does mojo. -enum KeyboardCode { - BACK = 0x08, - TAB = 0x09, - CLEAR = 0x0C, - RETURN = 0x0D, - SHIFT = 0x10, - CONTROL = 0x11, - MENU = 0x12, // a.k.a. ALT - PAUSE = 0x13, - CAPITAL = 0x14, - KANA = 0x15, - HANGUL = 0x15, - JUNJA = 0x17, - FINAL = 0x18, - HANJA = 0x19, - KANJI = 0x19, - ESCAPE = 0x1B, - CONVERT = 0x1C, - NONCONVERT = 0x1D, - ACCEPT = 0x1E, - MODECHANGE = 0x1F, - SPACE = 0x20, - PRIOR = 0x21, - NEXT = 0x22, - END = 0x23, - HOME = 0x24, - LEFT = 0x25, - UP = 0x26, - RIGHT = 0x27, - DOWN = 0x28, - SELECT = 0x29, - PRINT = 0x2A, - EXECUTE = 0x2B, - SNAPSHOT = 0x2C, - INSERT = 0x2D, - DELETE = 0x2E, - HELP = 0x2F, - NUM_0 = 0x30, - NUM_1 = 0x31, - NUM_2 = 0x32, - NUM_3 = 0x33, - NUM_4 = 0x34, - NUM_5 = 0x35, - NUM_6 = 0x36, - NUM_7 = 0x37, - NUM_8 = 0x38, - NUM_9 = 0x39, - A = 0x41, - B = 0x42, - C = 0x43, - D = 0x44, - E = 0x45, - F = 0x46, - G = 0x47, - H = 0x48, - I = 0x49, - J = 0x4A, - K = 0x4B, - L = 0x4C, - M = 0x4D, - N = 0x4E, - O = 0x4F, - P = 0x50, - Q = 0x51, - R = 0x52, - S = 0x53, - T = 0x54, - U = 0x55, - V = 0x56, - W = 0x57, - X = 0x58, - Y = 0x59, - Z = 0x5A, - LWIN = 0x5B, - COMMAND = 0x5B, // Provide the Mac name for convenience. - RWIN = 0x5C, - APPS = 0x5D, - SLEEP = 0x5F, - NUMPAD0 = 0x60, - NUMPAD1 = 0x61, - NUMPAD2 = 0x62, - NUMPAD3 = 0x63, - NUMPAD4 = 0x64, - NUMPAD5 = 0x65, - NUMPAD6 = 0x66, - NUMPAD7 = 0x67, - NUMPAD8 = 0x68, - NUMPAD9 = 0x69, - MULTIPLY = 0x6A, - ADD = 0x6B, - SEPARATOR = 0x6C, - SUBTRACT = 0x6D, - DECIMAL = 0x6E, - DIVIDE = 0x6F, - F1 = 0x70, - F2 = 0x71, - F3 = 0x72, - F4 = 0x73, - F5 = 0x74, - F6 = 0x75, - F7 = 0x76, - F8 = 0x77, - F9 = 0x78, - F10 = 0x79, - F11 = 0x7A, - F12 = 0x7B, - F13 = 0x7C, - F14 = 0x7D, - F15 = 0x7E, - F16 = 0x7F, - F17 = 0x80, - F18 = 0x81, - F19 = 0x82, - F20 = 0x83, - F21 = 0x84, - F22 = 0x85, - F23 = 0x86, - F24 = 0x87, - NUMLOCK = 0x90, - SCROLL = 0x91, - LSHIFT = 0xA0, - RSHIFT = 0xA1, - LCONTROL = 0xA2, - RCONTROL = 0xA3, - LMENU = 0xA4, - RMENU = 0xA5, - BROWSER_BACK = 0xA6, - BROWSER_FORWARD = 0xA7, - BROWSER_REFRESH = 0xA8, - BROWSER_STOP = 0xA9, - BROWSER_SEARCH = 0xAA, - BROWSER_FAVORITES = 0xAB, - BROWSER_HOME = 0xAC, - VOLUME_MUTE = 0xAD, - VOLUME_DOWN = 0xAE, - VOLUME_UP = 0xAF, - MEDIA_NEXT_TRACK = 0xB0, - MEDIA_PREV_TRACK = 0xB1, - MEDIA_STOP = 0xB2, - MEDIA_PLAY_PAUSE = 0xB3, - MEDIA_LAUNCH_MAIL = 0xB4, - MEDIA_LAUNCH_MEDIA_SELECT = 0xB5, - MEDIA_LAUNCH_APP1 = 0xB6, - MEDIA_LAUNCH_APP2 = 0xB7, - - OEM_1 = 0xBA, - OEM_PLUS = 0xBB, - OEM_COMMA = 0xBC, - OEM_MINUS = 0xBD, - OEM_PERIOD = 0xBE, - OEM_2 = 0xBF, - OEM_3 = 0xC0, - OEM_4 = 0xDB, - OEM_5 = 0xDC, - OEM_6 = 0xDD, - OEM_7 = 0xDE, - OEM_8 = 0xDF, - OEM_102 = 0xE2, - PROCESSKEY = 0xE5, - PACKET = 0xE7, - DBE_SBCSCHAR = 0xF3, - DBE_DBCSCHAR = 0xF4, - ATTN = 0xF6, - CRSEL = 0xF7, - EXSEL = 0xF8, - EREOF = 0xF9, - PLAY = 0xFA, - ZOOM = 0xFB, - NONAME = 0xFC, - PA1 = 0xFD, - OEM_CLEAR = 0xFE, - UNKNOWN = 0, - - // Windows does not have a specific key code for AltGr. We use the unused - // VK_OEM_AX to represent AltGr, matching the behaviour of Firefox on Linux. - ALTGR = 0xE1, -}; diff --git a/third_party/mojo_services/src/native_viewport/public/cpp/BUILD.gn b/third_party/mojo_services/src/native_viewport/public/cpp/BUILD.gn deleted file mode 100644 index 855de71..0000000 --- a/third_party/mojo_services/src/native_viewport/public/cpp/BUILD.gn +++ /dev/null @@ -1,14 +0,0 @@ -# Copyright 2014 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. - -import("//build/module_args/mojo.gni") -import("$mojo_sdk_root/mojo/public/mojo_sdk.gni") - -mojo_sdk_source_set("args") { - public_configs = [ "../../../public/build/config:mojo_services" ] - sources = [ - "args.h", - "lib/args.cc", - ] -} diff --git a/third_party/mojo_services/src/native_viewport/public/cpp/args.h b/third_party/mojo_services/src/native_viewport/public/cpp/args.h deleted file mode 100644 index 2bad98d..0000000 --- a/third_party/mojo_services/src/native_viewport/public/cpp/args.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright 2014 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 MOJO_SERVICES_NATIVE_VIEWPORT_PUBLIC_CPP_ARGS_H_ -#define MOJO_SERVICES_NATIVE_VIEWPORT_PUBLIC_CPP_ARGS_H_ - -namespace mojo { - -// All args in alphabetical order. The switches should be documented -// alongside the definition of their values in the .cc file. -extern const char kUseHeadlessConfig[]; -extern const char kUseOSMesa[]; -extern const char kUseTestConfig[]; - -} // namespace mojo - -#endif // MOJO_SERVICES_NATIVE_VIEWPORT_PUBLIC_CPP_ARGS_H_ diff --git a/third_party/mojo_services/src/native_viewport/public/cpp/lib/args.cc b/third_party/mojo_services/src/native_viewport/public/cpp/lib/args.cc deleted file mode 100644 index 25ee1ae..0000000 --- a/third_party/mojo_services/src/native_viewport/public/cpp/lib/args.cc +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2014 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 "native_viewport/public/cpp/args.h" - -namespace mojo { - -// Instead of using the system GL implementation, use OSMesa. -const char kUseOSMesa[] = "--use-osmesa"; -// Loads an app from the specified directory and launches it. -// Force gl to be initialized in test mode. -const char kUseTestConfig[] = "--use-test-config"; -// Create native viewport in headless mode. -const char kUseHeadlessConfig[] = "--use-headless-config"; - -} // namespace mojo diff --git a/third_party/mojo_services/src/native_viewport/public/interfaces/BUILD.gn b/third_party/mojo_services/src/native_viewport/public/interfaces/BUILD.gn deleted file mode 100644 index 86ff870..0000000 --- a/third_party/mojo_services/src/native_viewport/public/interfaces/BUILD.gn +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright 2014 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. - -import("//build/module_args/mojo.gni") -import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni") - -mojom("interfaces") { - sources = [ - "native_viewport.mojom", - ] - - import_dirs = [ get_path_info("../../../", "abspath") ] - - public_deps = [ - "../../../geometry/public/interfaces", - "../../../gpu/public/interfaces", - "../../../input_events/public/interfaces", - "../../../surfaces/public/interfaces:surface_id", - ] -} diff --git a/third_party/mojo_services/src/native_viewport/public/interfaces/native_viewport.mojom b/third_party/mojo_services/src/native_viewport/public/interfaces/native_viewport.mojom deleted file mode 100644 index 21cace6..0000000 --- a/third_party/mojo_services/src/native_viewport/public/interfaces/native_viewport.mojom +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -import "geometry/public/interfaces/geometry.mojom"; -import "gpu/public/interfaces/context_provider.mojom"; -import "input_events/public/interfaces/input_events.mojom"; - -struct ViewportMetrics { - Size size; - float device_pixel_ratio = 1.0; -}; - -interface NativeViewport { - // TODO(sky): having a create function is awkward. Should there be a factory - // to create the NativeViewport that takes the size? - Create(Size size) => (ViewportMetrics metrics); - - Show(); - Hide(); - Close(); - SetSize(Size size); - SetEventDispatcher(NativeViewportEventDispatcher dispatcher); - - // Requests a ContextProvider capable of producing contexts that draw to - // this native viewport. - GetContextProvider(ContextProvider& provider); - - // The initial viewport metrics will be sent in the reply to the Create - // method. Call RequestMetrics() to receive updates when the viewport metrics - // change. The reply will be sent when the viewport metrics are different from - // the values last sent, so to receive continuous updates call this method - // again after receiving the callback. - RequestMetrics() => (ViewportMetrics metrics); -}; - -interface NativeViewportEventDispatcher { - OnEvent(Event event) => (); -}; diff --git a/third_party/mojo_services/src/surfaces/public/interfaces/BUILD.gn b/third_party/mojo_services/src/surfaces/public/interfaces/BUILD.gn deleted file mode 100644 index 7902a7a..0000000 --- a/third_party/mojo_services/src/surfaces/public/interfaces/BUILD.gn +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright 2014 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. - -import("//build/module_args/mojo.gni") -import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni") - -mojom("interfaces") { - sources = [ - "display.mojom", - "quads.mojom", - "surfaces.mojom", - ] - - import_dirs = [ get_path_info("../../../", "abspath") ] - - deps = [ - ":surface_id", - "../../../geometry/public/interfaces", - "../../../gpu/public/interfaces", - "../../../native_viewport/public/interfaces", - ] -} - -mojom("surface_id") { - sources = [ - "surface_id.mojom", - ] -} diff --git a/third_party/mojo_services/src/surfaces/public/interfaces/display.mojom b/third_party/mojo_services/src/surfaces/public/interfaces/display.mojom deleted file mode 100644 index cee3014..0000000 --- a/third_party/mojo_services/src/surfaces/public/interfaces/display.mojom +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2015 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. - -module mojo; - -import "gpu/public/interfaces/context_provider.mojom"; -import "gpu/public/interfaces/viewport_parameter_listener.mojom"; -import "surfaces/public/interfaces/surfaces.mojom"; - -interface Display { - // Submits a new frame to the display to be drawn when possible. The callback - // will be run after the frame has been issued to the display but possibly - // before the frame is actually visible. - // - // The Display will be resized to the size of the last entry in |frame|'s - // |passes| list (aka the root pass). - // - // Any resources submitted in the frame will be returned via the - // ResourceReturner associated with the Display at construction time. - SubmitFrame(Frame frame) => (); -}; - -// DisplayFactory creates new Display instances. -interface DisplayFactory { - // Create associates a Display that will draw to contexts produced by - // |context_provider|. Any resources submitted to the display will be - // returned via the |returner|, if supplied. - Create(ContextProvider context_provider, - ResourceReturner? returner, - Display& display_request); -}; - diff --git a/third_party/mojo_services/src/surfaces/public/interfaces/quads.mojom b/third_party/mojo_services/src/surfaces/public/interfaces/quads.mojom deleted file mode 100644 index 3022df0a..0000000 --- a/third_party/mojo_services/src/surfaces/public/interfaces/quads.mojom +++ /dev/null @@ -1,212 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -import "geometry/public/interfaces/geometry.mojom"; -import "surfaces/public/interfaces/surface_id.mojom"; - -struct Color { - uint32 rgba; -}; - -// TODO(jamesr): Populate subtype fields. -struct CheckerboardQuadState {}; - -struct DebugBorderQuadState {}; - -struct IoSurfaceContentQuadState {}; - -struct RenderPassId { - int32 layer_id; - int32 index; -}; - -struct RenderPassQuadState { - RenderPassId render_pass_id; - - // If nonzero, resource id of mask to use when drawing this pass. - uint32 mask_resource_id; - PointF mask_uv_scale; - Size mask_texture_size; - - // Post-processing filters, applied to the pixels in the render pass' texture. - // TODO(jamesr): Support - // FilterOperations filters; - - // The scale from layer space of the root layer of the render pass to - // the render pass physical pixels. This scale is applied to the filter - // parameters for pixel-moving filters. This scale should include - // content-to-target-space scale, and device pixel ratio. - PointF filters_scale; - - // Post-processing filters, applied to the pixels showing through the - // background of the render pass, from behind it. - // TODO(jamesr): Support - // FilterOperations background_filters; -}; - -struct SolidColorQuadState { - Color color; - bool force_anti_aliasing_off; -}; - -struct SurfaceQuadState { - SurfaceId surface; -}; - -struct TextureQuadState { - uint32 resource_id; - bool premultiplied_alpha; - PointF uv_top_left; - PointF uv_bottom_right; - Color background_color; - array<float, 4> vertex_opacity; - bool flipped; - bool nearest_neighbor; -}; - -struct TileQuadState { - RectF tex_coord_rect; - Size texture_size; - bool swizzle_contents; - uint32 resource_id; - bool nearest_neighbor; -}; - -struct StreamVideoQuadState {}; - -enum YUVColorSpace { - REC_601, // SDTV standard with restricted "studio swing" color range. - REC_709, // HDTV standard with restricted "studio swing" color range. - JPEG, // Full color range [0, 255] JPEG color space. -}; - -struct YUVVideoQuadState { - RectF tex_coord_rect; - uint32 y_plane_resource_id; - uint32 u_plane_resource_id; - uint32 v_plane_resource_id; - uint32 a_plane_resource_id; - YUVColorSpace color_space; -}; - -enum Material { - CHECKERBOARD = 1, - DEBUG_BORDER, - IO_SURFACE_CONTENT, - PICTURE_CONTENT, - RENDER_PASS, - SOLID_COLOR, - STREAM_VIDEO_CONTENT, - SURFACE_CONTENT, - TEXTURE_CONTENT, - TILED_CONTENT, - YUV_VIDEO_CONTENT, -}; - -struct Quad { - Material material; - - // This rect, after applying the quad_transform(), gives the geometry that - // this quad should draw to. This rect lives in content space. - Rect rect; - - // This specifies the region of the quad that is opaque. This rect lives in - // content space. - Rect opaque_rect; - - // Allows changing the rect that gets drawn to make it smaller. This value - // should be clipped to |rect|. This rect lives in content space. - Rect visible_rect; - - // Allows changing the rect that gets drawn to make it smaller. This value - // should be clipped to |rect|. This rect lives in content space. - bool needs_blending; - - // Index into the containing pass' shared quad state array which has state - // (transforms etc) shared by multiple quads. - uint32 shared_quad_state_index; - - // Only one of the following will be set, depending on the material. - CheckerboardQuadState? checkerboard_quad_state; - DebugBorderQuadState? debug_border_quad_state; - IoSurfaceContentQuadState? io_surface_quad_state; - RenderPassQuadState? render_pass_quad_state; - SolidColorQuadState? solid_color_quad_state; - SurfaceQuadState? surface_quad_state; - TextureQuadState? texture_quad_state; - TileQuadState? tile_quad_state; - StreamVideoQuadState? stream_video_quad_state; - YUVVideoQuadState? yuv_video_quad_state; -}; - -enum SkXfermode { - kClear_Mode = 0, //!< [0, 0] - kSrc_Mode, //!< [Sa, Sc] - kDst_Mode, //!< [Da, Dc] - kSrcOver_Mode, //!< [Sa + Da - Sa*Da, Rc = Sc + (1 - Sa)*Dc] - kDstOver_Mode, //!< [Sa + Da - Sa*Da, Rc = Dc + (1 - Da)*Sc] - kSrcIn_Mode, //!< [Sa * Da, Sc * Da] - kDstIn_Mode, //!< [Sa * Da, Sa * Dc] - kSrcOut_Mode, //!< [Sa * (1 - Da), Sc * (1 - Da)] - kDstOut_Mode, //!< [Da * (1 - Sa), Dc * (1 - Sa)] - kSrcATop_Mode, //!< [Da, Sc * Da + (1 - Sa) * Dc] - kDstATop_Mode, //!< [Sa, Sa * Dc + Sc * (1 - Da)] - kXor_Mode, //!< [Sa + Da - 2 * Sa * Da, Sc * (1 - Da) + (1 - Sa) * Dc] - kPlus_Mode, //!< [Sa + Da, Sc + Dc] - kModulate_Mode, // multiplies all components (= alpha and color) - - // Following blend modes are defined in the CSS Compositing standard: - // https://dvcs.w3.org/hg/FXTF/rawfile/tip/compositing/index.html#blending - kScreen_Mode, - kLastCoeffMode = kScreen_Mode, - - kOverlay_Mode, - kDarken_Mode, - kLighten_Mode, - kColorDodge_Mode, - kColorBurn_Mode, - kHardLight_Mode, - kSoftLight_Mode, - kDifference_Mode, - kExclusion_Mode, - kMultiply_Mode, - kLastSeparableMode = kMultiply_Mode, - - kHue_Mode, - kSaturation_Mode, - kColor_Mode, - kLuminosity_Mode, - kLastMode = kLuminosity_Mode -}; - -struct SharedQuadState { - // Transforms from quad's original content space to its target content space. - Transform content_to_target_transform; - - // This size lives in the content space for the quad's originating layer. - Size content_bounds; - - // This rect lives in the content space for the quad's originating layer. - Rect visible_content_rect; - - // This rect lives in the target content space. - Rect clip_rect; - - bool is_clipped; - float opacity; - SkXfermode blend_mode; - int32 sorting_context_id; -}; - -struct Pass { - RenderPassId id; - Rect output_rect; - Rect damage_rect; - Transform transform_to_root_target; - bool has_transparent_background; - array<Quad> quads; - array<SharedQuadState> shared_quad_states; -}; diff --git a/third_party/mojo_services/src/surfaces/public/interfaces/surface_id.mojom b/third_party/mojo_services/src/surfaces/public/interfaces/surface_id.mojom deleted file mode 100644 index 197e6f8b..0000000 --- a/third_party/mojo_services/src/surfaces/public/interfaces/surface_id.mojom +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -// A surface ID is composed of two parts, a local part and a namespace. The -// local part is allocated by the client using any scheme that avoids -// duplicates. The namespace is allocated by the service and will be different -// for each client (aka each connection to mojo.Surface). -// -// The special id_namespace value 0 is equivalent to the namespace of the -// client. This can be used to create, destroy and submit frames to -// surfaces before learning the namespace and to reference other surfaces -// owned by the same client. The actual id namespace must be used to pass -// surface ids to other clients for them to reference. -struct SurfaceId { - uint32 local; - uint32 id_namespace; -}; diff --git a/third_party/mojo_services/src/surfaces/public/interfaces/surfaces.mojom b/third_party/mojo_services/src/surfaces/public/interfaces/surfaces.mojom deleted file mode 100644 index 8248469..0000000 --- a/third_party/mojo_services/src/surfaces/public/interfaces/surfaces.mojom +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -import "geometry/public/interfaces/geometry.mojom"; -import "surfaces/public/interfaces/quads.mojom"; -import "surfaces/public/interfaces/surface_id.mojom"; - -enum ResourceFormat { - RGBA_8888, - RGBA_4444, - BGRA_8888, - ALPHA_8, - LUMINANCE_8, - RGB_565, - ETC1, -}; - -struct Mailbox { - array<int8, 64> name; -}; - -struct MailboxHolder { - Mailbox mailbox; - uint32 texture_target; - uint32 sync_point; -}; - -struct TransferableResource { - uint32 id; - ResourceFormat format; - uint32 filter; - Size size; - MailboxHolder mailbox_holder; - bool is_repeated; - bool is_software; -}; - -struct ReturnedResource { - uint32 id; - uint32 sync_point; - int32 count; - bool lost; -}; - -struct Frame { - array<TransferableResource> resources; - array<Pass> passes; -}; - -interface ResourceReturner { - ReturnResources(array<ReturnedResource> resources); -}; - -interface Surface { - // Request the id namespace for this connection. Fully qualified surface ids - // are the combination of the id_namespace for the connection that created the - // surface and the id_local component allocated by the caller. - GetIdNamespace() => (uint32 id_namespace); - - // Sets a ResourceReturner that will receive unused resources. - SetResourceReturner(ResourceReturner returner); - - // Creates a new surface with the given local identifier. Once a surface is - // created the caller may submit frames to it or destroy it using the local - // identifier. The caller can also produce a fully qualified surface id that - // can be embedded in frames produces by different connections. - CreateSurface(uint32 id_local); - - // After the submitted frame is drawn for the first time, the surface will - // respond to the SubmitFrame message. Clients should use this acknowledgement - // to ratelimit frame submissions. - SubmitFrame(uint32 id_local, Frame frame) => (); - DestroySurface(uint32 id_local); -}; diff --git a/third_party/mojo_services/src/view_manager/public/cpp/BUILD.gn b/third_party/mojo_services/src/view_manager/public/cpp/BUILD.gn deleted file mode 100644 index cbab611..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/BUILD.gn +++ /dev/null @@ -1,62 +0,0 @@ -# Copyright 2014 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. - -import("//build/module_args/mojo.gni") -import("$mojo_sdk_root/mojo/public/mojo_sdk.gni") - -mojo_sdk_source_set("cpp") { - restrict_external_deps = false - public_configs = [ "../../../public/build/config:mojo_services" ] - sources = [ - "lib/view.cc", - "lib/view_manager_client_factory.cc", - "lib/view_manager_client_impl.cc", - "lib/view_manager_client_impl.h", - "lib/view_manager_context.cc", - "lib/view_observer.cc", - "lib/view_private.cc", - "lib/view_private.h", - "view.h", - "view_manager.h", - "view_manager_client_factory.h", - "view_manager_context.h", - "view_manager_delegate.cc", - "view_manager_delegate.h", - "view_observer.h", - "view_property.h", - "view_tracker.cc", - "view_tracker.h", - ] - - public_deps = [ - ":common", - ] - - deps = [ - "../interfaces", - "../../../geometry/public/interfaces", - "../../../input_events/public/interfaces", - "../../../surfaces/public/interfaces:surface_id", - "../../../window_manager/public/interfaces", - "//base", - ] - - mojo_sdk_deps = [ - "mojo/public/c/gles2:headers", - "mojo/public/cpp/application", - "mojo/public/cpp/bindings:bindings", - "mojo/public/cpp/system", - "mojo/public/interfaces/application", - ] -} - -source_set("common") { - configs += [ "../../../public/build/config:mojo_services" ] - - sources = [ - "keys.cc", - "keys.h", - "types.h", - ] -} diff --git a/third_party/mojo_services/src/view_manager/public/cpp/keys.cc b/third_party/mojo_services/src/view_manager/public/cpp/keys.cc deleted file mode 100644 index 5ed54ef..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/keys.cc +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2015 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 "view_manager/public/cpp/keys.h" - -namespace mojo { - -extern const char kViewManagerKeyWantsTouchEvents[] = - "view-manager-key-wants-touch-events"; - -} // namespace mojo diff --git a/third_party/mojo_services/src/view_manager/public/cpp/keys.h b/third_party/mojo_services/src/view_manager/public/cpp/keys.h deleted file mode 100644 index 77ca346f..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/keys.h +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2015 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 MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_KEYS_H_ -#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_KEYS_H_ - -namespace mojo { - -extern const char kViewManagerKeyWantsTouchEvents[]; - -} // namespace mojo - -#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_KEYS_H_ diff --git a/third_party/mojo_services/src/view_manager/public/cpp/lib/view.cc b/third_party/mojo_services/src/view_manager/public/cpp/lib/view.cc deleted file mode 100644 index 9ed458c..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/lib/view.cc +++ /dev/null @@ -1,589 +0,0 @@ -// Copyright 2014 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 "view_manager/public/cpp/view.h" - -#include <set> -#include <string> - -#include "mojo/public/cpp/application/service_provider_impl.h" -#include "view_manager/public/cpp/lib/view_manager_client_impl.h" -#include "view_manager/public/cpp/lib/view_private.h" -#include "view_manager/public/cpp/view_observer.h" -#include "view_manager/public/cpp/view_tracker.h" - -namespace mojo { - -namespace { - -void NotifyViewTreeChangeAtReceiver( - View* receiver, - const ViewObserver::TreeChangeParams& params, - bool change_applied) { - ViewObserver::TreeChangeParams local_params = params; - local_params.receiver = receiver; - if (change_applied) { - FOR_EACH_OBSERVER(ViewObserver, - *ViewPrivate(receiver).observers(), - OnTreeChanged(local_params)); - } else { - FOR_EACH_OBSERVER(ViewObserver, - *ViewPrivate(receiver).observers(), - OnTreeChanging(local_params)); - } -} - -void NotifyViewTreeChangeUp( - View* start_at, - const ViewObserver::TreeChangeParams& params, - bool change_applied) { - for (View* current = start_at; current; current = current->parent()) - NotifyViewTreeChangeAtReceiver(current, params, change_applied); -} - -void NotifyViewTreeChangeDown( - View* start_at, - const ViewObserver::TreeChangeParams& params, - bool change_applied) { - NotifyViewTreeChangeAtReceiver(start_at, params, change_applied); - View::Children::const_iterator it = start_at->children().begin(); - for (; it != start_at->children().end(); ++it) - NotifyViewTreeChangeDown(*it, params, change_applied); -} - -void NotifyViewTreeChange( - const ViewObserver::TreeChangeParams& params, - bool change_applied) { - NotifyViewTreeChangeDown(params.target, params, change_applied); - if (params.old_parent) - NotifyViewTreeChangeUp(params.old_parent, params, change_applied); - if (params.new_parent) - NotifyViewTreeChangeUp(params.new_parent, params, change_applied); -} - -class ScopedTreeNotifier { - public: - ScopedTreeNotifier(View* target, View* old_parent, View* new_parent) { - params_.target = target; - params_.old_parent = old_parent; - params_.new_parent = new_parent; - NotifyViewTreeChange(params_, false); - } - ~ScopedTreeNotifier() { - NotifyViewTreeChange(params_, true); - } - - private: - ViewObserver::TreeChangeParams params_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedTreeNotifier); -}; - -void RemoveChildImpl(View* child, View::Children* children) { - View::Children::iterator it = - std::find(children->begin(), children->end(), child); - if (it != children->end()) { - children->erase(it); - ViewPrivate(child).ClearParent(); - } -} - -class ScopedOrderChangedNotifier { - public: - ScopedOrderChangedNotifier(View* view, - View* relative_view, - OrderDirection direction) - : view_(view), - relative_view_(relative_view), - direction_(direction) { - FOR_EACH_OBSERVER(ViewObserver, - *ViewPrivate(view_).observers(), - OnViewReordering(view_, relative_view_, direction_)); - } - ~ScopedOrderChangedNotifier() { - FOR_EACH_OBSERVER(ViewObserver, - *ViewPrivate(view_).observers(), - OnViewReordered(view_, relative_view_, direction_)); - } - - private: - View* view_; - View* relative_view_; - OrderDirection direction_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedOrderChangedNotifier); -}; - -// Returns true if the order actually changed. -bool ReorderImpl(View::Children* children, - View* view, - View* relative, - OrderDirection direction) { - DCHECK(relative); - DCHECK_NE(view, relative); - DCHECK_EQ(view->parent(), relative->parent()); - - const size_t child_i = - std::find(children->begin(), children->end(), view) - children->begin(); - const size_t target_i = - std::find(children->begin(), children->end(), relative) - - children->begin(); - if ((direction == ORDER_DIRECTION_ABOVE && child_i == target_i + 1) || - (direction == ORDER_DIRECTION_BELOW && child_i + 1 == target_i)) { - return false; - } - - ScopedOrderChangedNotifier notifier(view, relative, direction); - - const size_t dest_i = direction == ORDER_DIRECTION_ABOVE - ? (child_i < target_i ? target_i : target_i + 1) - : (child_i < target_i ? target_i - 1 : target_i); - children->erase(children->begin() + child_i); - children->insert(children->begin() + dest_i, view); - - return true; -} - -class ScopedSetBoundsNotifier { - public: - ScopedSetBoundsNotifier(View* view, - const Rect& old_bounds, - const Rect& new_bounds) - : view_(view), - old_bounds_(old_bounds), - new_bounds_(new_bounds) { - FOR_EACH_OBSERVER(ViewObserver, - *ViewPrivate(view_).observers(), - OnViewBoundsChanging(view_, old_bounds_, new_bounds_)); - } - ~ScopedSetBoundsNotifier() { - FOR_EACH_OBSERVER(ViewObserver, - *ViewPrivate(view_).observers(), - OnViewBoundsChanged(view_, old_bounds_, new_bounds_)); - } - - private: - View* view_; - const Rect old_bounds_; - const Rect new_bounds_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(ScopedSetBoundsNotifier); -}; - -// Some operations are only permitted in the connection that created the view. -bool OwnsView(ViewManager* manager, View* view) { - return !manager || - static_cast<ViewManagerClientImpl*>(manager)->OwnsView(view->id()); -} - -} // namespace - -//////////////////////////////////////////////////////////////////////////////// -// View, public: - -void View::Destroy() { - if (!OwnsView(manager_, this)) - return; - - if (manager_) - static_cast<ViewManagerClientImpl*>(manager_)->DestroyView(id_); - while (!children_.empty()) { - View* child = children_.front(); - if (!OwnsView(manager_, child)) { - ViewPrivate(child).ClearParent(); - children_.erase(children_.begin()); - } else { - child->Destroy(); - DCHECK(std::find(children_.begin(), children_.end(), child) == - children_.end()); - } - } - LocalDestroy(); -} - -void View::SetBounds(const Rect& bounds) { - if (!OwnsView(manager_, this)) - return; - - if (bounds_.Equals(bounds)) - return; - - if (manager_) - static_cast<ViewManagerClientImpl*>(manager_)->SetBounds(id_, bounds); - LocalSetBounds(bounds_, bounds); -} - -void View::SetVisible(bool value) { - if (visible_ == value) - return; - - if (manager_) - static_cast<ViewManagerClientImpl*>(manager_)->SetVisible(id_, value); - LocalSetVisible(value); -} - -void View::SetSharedProperty(const std::string& name, - const std::vector<uint8_t>* value) { - std::vector<uint8_t> old_value; - std::vector<uint8_t>* old_value_ptr = nullptr; - auto it = properties_.find(name); - if (it != properties_.end()) { - old_value = it->second; - old_value_ptr = &old_value; - - if (value && old_value == *value) - return; - } else if (!value) { - // This property isn't set in |properties_| and |value| is NULL, so there's - // no change. - return; - } - - if (value) { - properties_[name] = *value; - } else if (it != properties_.end()) { - properties_.erase(it); - } - - // TODO: add test coverage of this (450303). - if (manager_) { - Array<uint8_t> transport_value; - if (value) { - transport_value.resize(value->size()); - if (value->size()) - memcpy(&transport_value.front(), &(value->front()), value->size()); - } - static_cast<ViewManagerClientImpl*>(manager_)->SetProperty( - id_, name, transport_value.Pass()); - } - - FOR_EACH_OBSERVER( - ViewObserver, observers_, - OnViewSharedPropertyChanged(this, name, old_value_ptr, value)); -} - -bool View::IsDrawn() const { - if (!visible_) - return false; - return parent_ ? parent_->IsDrawn() : drawn_; -} - -void View::AddObserver(ViewObserver* observer) { - observers_.AddObserver(observer); -} - -void View::RemoveObserver(ViewObserver* observer) { - observers_.RemoveObserver(observer); -} - -const View* View::GetRoot() const { - const View* root = this; - for (const View* parent = this; parent; parent = parent->parent()) - root = parent; - return root; -} - -void View::AddChild(View* child) { - // TODO(beng): not necessarily valid to all connections, but possibly to the - // embeddee in an embedder-embeddee relationship. - if (manager_) - CHECK_EQ(child->view_manager(), manager_); - LocalAddChild(child); - if (manager_) - static_cast<ViewManagerClientImpl*>(manager_)->AddChild(child->id(), id_); -} - -void View::RemoveChild(View* child) { - // TODO(beng): not necessarily valid to all connections, but possibly to the - // embeddee in an embedder-embeddee relationship. - if (manager_) - CHECK_EQ(child->view_manager(), manager_); - LocalRemoveChild(child); - if (manager_) { - static_cast<ViewManagerClientImpl*>(manager_)->RemoveChild(child->id(), - id_); - } -} - -void View::MoveToFront() { - if (!parent_ || parent_->children_.back() == this) - return; - Reorder(parent_->children_.back(), ORDER_DIRECTION_ABOVE); -} - -void View::MoveToBack() { - if (!parent_ || parent_->children_.front() == this) - return; - Reorder(parent_->children_.front(), ORDER_DIRECTION_BELOW); -} - -void View::Reorder(View* relative, OrderDirection direction) { - if (!LocalReorder(relative, direction)) - return; - if (manager_) { - static_cast<ViewManagerClientImpl*>(manager_)->Reorder(id_, - relative->id(), - direction); - } -} - -bool View::Contains(View* child) const { - if (!child) - return false; - if (child == this) - return true; - if (manager_) - CHECK_EQ(child->view_manager(), manager_); - for (View* p = child->parent(); p; p = p->parent()) { - if (p == this) - return true; - } - return false; -} - -View* View::GetChildById(Id id) { - if (id == id_) - return this; - // TODO(beng): this could be improved depending on how we decide to own views. - Children::const_iterator it = children_.begin(); - for (; it != children_.end(); ++it) { - View* view = (*it)->GetChildById(id); - if (view) - return view; - } - return NULL; -} - -void View::SetSurfaceId(SurfaceIdPtr id) { - if (manager_) { - static_cast<ViewManagerClientImpl*>(manager_)->SetSurfaceId(id_, id.Pass()); - } -} - -void View::SetFocus() { - if (manager_) - static_cast<ViewManagerClientImpl*>(manager_)->SetFocus(id_); -} - -void View::Embed(const String& url) { - static_cast<ViewManagerClientImpl*>(manager_)->Embed(url, id_); -} - -void View::Embed(const String& url, - InterfaceRequest<ServiceProvider> services, - ServiceProviderPtr exposed_services) { - static_cast<ViewManagerClientImpl*>(manager_) - ->Embed(url, id_, services.Pass(), exposed_services.Pass()); -} - -void View::Embed(ViewManagerClientPtr client) { - static_cast<ViewManagerClientImpl*>(manager_)->Embed(id_, client.Pass()); -} - -//////////////////////////////////////////////////////////////////////////////// -// View, protected: - -namespace { - -ViewportMetricsPtr CreateEmptyViewportMetrics() { - ViewportMetricsPtr metrics = ViewportMetrics::New(); - metrics->size = Size::New(); - // TODO(vtl): The |.Pass()| below is only needed due to an MSVS bug; remove it - // once that's fixed. - return metrics.Pass(); -} - -} // namespace - -View::View() - : manager_(NULL), - id_(static_cast<Id>(-1)), - parent_(NULL), - viewport_metrics_(CreateEmptyViewportMetrics()), - visible_(true), - drawn_(false) { -} - -View::~View() { - FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDestroying(this)); - if (parent_) - parent_->LocalRemoveChild(this); - - // We may still have children. This can happen if the embedder destroys the - // root while we're still alive. - while (!children_.empty()) { - View* child = children_.front(); - LocalRemoveChild(child); - DCHECK(children_.empty() || children_.front() != child); - } - - // TODO(beng): It'd be better to do this via a destruction observer in the - // ViewManagerClientImpl. - if (manager_) - static_cast<ViewManagerClientImpl*>(manager_)->RemoveView(id_); - - // Clear properties. - for (auto& pair : prop_map_) { - if (pair.second.deallocator) - (*pair.second.deallocator)(pair.second.value); - } - prop_map_.clear(); - - FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDestroyed(this)); -} - -//////////////////////////////////////////////////////////////////////////////// -// View, private: - -View::View(ViewManager* manager, Id id) - : manager_(manager), - id_(id), - parent_(nullptr), - viewport_metrics_(CreateEmptyViewportMetrics()), - visible_(false), - drawn_(false) { -} - -int64 View::SetLocalPropertyInternal(const void* key, - const char* name, - PropertyDeallocator deallocator, - int64 value, - int64 default_value) { - int64 old = GetLocalPropertyInternal(key, default_value); - if (value == default_value) { - prop_map_.erase(key); - } else { - Value prop_value; - prop_value.name = name; - prop_value.value = value; - prop_value.deallocator = deallocator; - prop_map_[key] = prop_value; - } - FOR_EACH_OBSERVER(ViewObserver, observers_, - OnViewLocalPropertyChanged(this, key, old)); - return old; -} - -int64 View::GetLocalPropertyInternal(const void* key, - int64 default_value) const { - std::map<const void*, Value>::const_iterator iter = prop_map_.find(key); - if (iter == prop_map_.end()) - return default_value; - return iter->second.value; -} - -void View::LocalDestroy() { - delete this; -} - -void View::LocalAddChild(View* child) { - ScopedTreeNotifier notifier(child, child->parent(), this); - if (child->parent()) - RemoveChildImpl(child, &child->parent_->children_); - children_.push_back(child); - child->parent_ = this; -} - -void View::LocalRemoveChild(View* child) { - DCHECK_EQ(this, child->parent()); - ScopedTreeNotifier notifier(child, this, NULL); - RemoveChildImpl(child, &children_); -} - -bool View::LocalReorder(View* relative, OrderDirection direction) { - return ReorderImpl(&parent_->children_, this, relative, direction); -} - -void View::LocalSetBounds(const Rect& old_bounds, - const Rect& new_bounds) { - DCHECK(old_bounds.x == bounds_.x); - DCHECK(old_bounds.y == bounds_.y); - DCHECK(old_bounds.width == bounds_.width); - DCHECK(old_bounds.height == bounds_.height); - ScopedSetBoundsNotifier notifier(this, old_bounds, new_bounds); - bounds_ = new_bounds; -} - -void View::LocalSetViewportMetrics(const ViewportMetrics& old_metrics, - const ViewportMetrics& new_metrics) { - // TODO(eseidel): We could check old_metrics against viewport_metrics_. - viewport_metrics_ = new_metrics.Clone(); - FOR_EACH_OBSERVER( - ViewObserver, observers_, - OnViewViewportMetricsChanged(this, old_metrics, new_metrics)); -} - -void View::LocalSetDrawn(bool value) { - if (drawn_ == value) - return; - - // As IsDrawn() is derived from |visible_| and |drawn_|, only send drawn - // notification is the value of IsDrawn() is really changing. - if (IsDrawn() == value) { - drawn_ = value; - return; - } - FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanging(this)); - drawn_ = value; - FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewDrawnChanged(this)); -} - -void View::LocalSetVisible(bool visible) { - if (visible_ == visible) - return; - - FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewVisibilityChanging(this)); - visible_ = visible; - NotifyViewVisibilityChanged(this); -} - -void View::NotifyViewVisibilityChanged(View* target) { - if (!NotifyViewVisibilityChangedDown(target)) { - return; // |this| has been deleted. - } - NotifyViewVisibilityChangedUp(target); -} - -bool View::NotifyViewVisibilityChangedAtReceiver(View* target) { - // |this| may be deleted during a call to OnViewVisibilityChanged() on one - // of the observers. We create an local observer for that. In that case we - // exit without further access to any members. - ViewTracker tracker; - tracker.Add(this); - FOR_EACH_OBSERVER(ViewObserver, observers_, OnViewVisibilityChanged(target)); - return tracker.Contains(this); -} - -bool View::NotifyViewVisibilityChangedDown(View* target) { - if (!NotifyViewVisibilityChangedAtReceiver(target)) - return false; // |this| was deleted. - std::set<const View*> child_already_processed; - bool child_destroyed = false; - do { - child_destroyed = false; - for (View::Children::const_iterator it = children_.begin(); - it != children_.end(); ++it) { - if (!child_already_processed.insert(*it).second) - continue; - if (!(*it)->NotifyViewVisibilityChangedDown(target)) { - // |*it| was deleted, |it| is invalid and |children_| has changed. We - // exit the current for-loop and enter a new one. - child_destroyed = true; - break; - } - } - } while (child_destroyed); - return true; -} - -void View::NotifyViewVisibilityChangedUp(View* target) { - // Start with the parent as we already notified |this| - // in NotifyViewVisibilityChangedDown. - for (View* view = parent(); view; view = view->parent()) { - bool ret = view->NotifyViewVisibilityChangedAtReceiver(target); - DCHECK(ret); - } -} - -} // namespace mojo diff --git a/third_party/mojo_services/src/view_manager/public/cpp/lib/view_manager_client_factory.cc b/third_party/mojo_services/src/view_manager/public/cpp/lib/view_manager_client_factory.cc deleted file mode 100644 index bb39fc9..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/lib/view_manager_client_factory.cc +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 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 "view_manager/public/cpp/view_manager_client_factory.h" - -#include "mojo/public/interfaces/application/shell.mojom.h" -#include "view_manager/public/cpp/lib/view_manager_client_impl.h" - -namespace mojo { - -ViewManagerClientFactory::ViewManagerClientFactory( - Shell* shell, - ViewManagerDelegate* delegate) - : shell_(shell), delegate_(delegate) { -} - -ViewManagerClientFactory::~ViewManagerClientFactory() { -} - -// static -ViewManagerClient* ViewManagerClientFactory::WeakBindViewManagerToPipe( - InterfaceRequest<ViewManagerClient> request, - ViewManagerServicePtr view_manager_service, - Shell* shell, - ViewManagerDelegate* delegate) { - const bool delete_on_error = false; - auto client = new ViewManagerClientImpl(delegate, shell, request.Pass(), - delete_on_error); - client->SetViewManagerService(view_manager_service.Pass()); - return client; -} - -// InterfaceFactory<ViewManagerClient> implementation. -void ViewManagerClientFactory::Create( - ApplicationConnection* connection, - InterfaceRequest<ViewManagerClient> request) { - const bool delete_on_error = true; - new ViewManagerClientImpl(delegate_, shell_, request.Pass(), delete_on_error); -} - -} // namespace mojo diff --git a/third_party/mojo_services/src/view_manager/public/cpp/lib/view_manager_client_impl.cc b/third_party/mojo_services/src/view_manager/public/cpp/lib/view_manager_client_impl.cc deleted file mode 100644 index 77dc293..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/lib/view_manager_client_impl.cc +++ /dev/null @@ -1,511 +0,0 @@ -// Copyright 2014 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 "view_manager/public/cpp/lib/view_manager_client_impl.h" - -#include "mojo/public/cpp/application/application_impl.h" -#include "mojo/public/cpp/application/connect.h" -#include "mojo/public/cpp/application/service_provider_impl.h" -#include "mojo/public/interfaces/application/service_provider.mojom.h" -#include "mojo/public/interfaces/application/shell.mojom.h" -#include "view_manager/public/cpp/lib/view_private.h" -#include "view_manager/public/cpp/util.h" -#include "view_manager/public/cpp/view_manager_delegate.h" -#include "view_manager/public/cpp/view_observer.h" - -namespace mojo { - -Id MakeTransportId(ConnectionSpecificId connection_id, - ConnectionSpecificId local_id) { - return (connection_id << 16) | local_id; -} - -// Helper called to construct a local view object from transport data. -View* AddViewToViewManager(ViewManagerClientImpl* client, - View* parent, - const ViewDataPtr& view_data) { - // We don't use the ctor that takes a ViewManager here, since it will call - // back to the service and attempt to create a new view. - View* view = ViewPrivate::LocalCreate(); - ViewPrivate private_view(view); - private_view.set_view_manager(client); - private_view.set_id(view_data->view_id); - private_view.set_visible(view_data->visible); - private_view.set_drawn(view_data->drawn); - private_view.LocalSetViewportMetrics(ViewportMetrics(), - *view_data->viewport_metrics); - private_view.set_properties( - view_data->properties.To<std::map<std::string, std::vector<uint8_t>>>()); - client->AddView(view); - private_view.LocalSetBounds(Rect(), *view_data->bounds); - if (parent) - ViewPrivate(parent).LocalAddChild(view); - return view; -} - -View* BuildViewTree(ViewManagerClientImpl* client, - const Array<ViewDataPtr>& views, - View* initial_parent) { - std::vector<View*> parents; - View* root = NULL; - View* last_view = NULL; - if (initial_parent) - parents.push_back(initial_parent); - for (size_t i = 0; i < views.size(); ++i) { - if (last_view && views[i]->parent_id == last_view->id()) { - parents.push_back(last_view); - } else if (!parents.empty()) { - while (parents.back()->id() != views[i]->parent_id) - parents.pop_back(); - } - View* view = AddViewToViewManager( - client, !parents.empty() ? parents.back() : NULL, views[i]); - if (!last_view) - root = view; - last_view = view; - } - return root; -} - -// Responsible for removing a root from the ViewManager when that view is -// destroyed. -class RootObserver : public ViewObserver { - public: - explicit RootObserver(View* root) : root_(root) {} - ~RootObserver() override {} - - private: - // Overridden from ViewObserver: - void OnViewDestroyed(View* view) override { - DCHECK_EQ(view, root_); - static_cast<ViewManagerClientImpl*>(root_->view_manager()) - ->RootDestroyed(root_); - view->RemoveObserver(this); - delete this; - } - - View* root_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(RootObserver); -}; - -ViewManagerClientImpl::ViewManagerClientImpl( - ViewManagerDelegate* delegate, - Shell* shell, - InterfaceRequest<ViewManagerClient> request, - bool delete_on_error) - : connection_id_(0), - next_id_(1), - delegate_(delegate), - root_(nullptr), - capture_view_(nullptr), - focused_view_(nullptr), - activated_view_(nullptr), - wm_observer_binding_(this), - binding_(this, request.Pass()), - delete_on_error_(delete_on_error) { -} - -ViewManagerClientImpl::~ViewManagerClientImpl() { - std::vector<View*> non_owned; - while (!views_.empty()) { - IdToViewMap::iterator it = views_.begin(); - if (OwnsView(it->second->id())) { - it->second->Destroy(); - } else { - non_owned.push_back(it->second); - views_.erase(it); - } - } - // Delete the non-owned views last. In the typical case these are roots. The - // exception is the window manager, which may know aboutother random views - // that it doesn't own. - // NOTE: we manually delete as we're a friend. - for (size_t i = 0; i < non_owned.size(); ++i) - delete non_owned[i]; - - delegate_->OnViewManagerDisconnected(this); -} - -void ViewManagerClientImpl::DestroyView(Id view_id) { - DCHECK(service_); - service_->DeleteView(view_id, ActionCompletedCallback()); -} - -void ViewManagerClientImpl::AddChild(Id child_id, Id parent_id) { - DCHECK(service_); - service_->AddView(parent_id, child_id, ActionCompletedCallback()); -} - -void ViewManagerClientImpl::RemoveChild(Id child_id, Id parent_id) { - DCHECK(service_); - service_->RemoveViewFromParent(child_id, ActionCompletedCallback()); -} - -void ViewManagerClientImpl::Reorder( - Id view_id, - Id relative_view_id, - OrderDirection direction) { - DCHECK(service_); - service_->ReorderView(view_id, relative_view_id, direction, - ActionCompletedCallback()); -} - -bool ViewManagerClientImpl::OwnsView(Id id) const { - return HiWord(id) == connection_id_; -} - -void ViewManagerClientImpl::SetBounds(Id view_id, const Rect& bounds) { - DCHECK(service_); - service_->SetViewBounds(view_id, bounds.Clone(), ActionCompletedCallback()); -} - -void ViewManagerClientImpl::SetSurfaceId(Id view_id, SurfaceIdPtr surface_id) { - DCHECK(service_); - if (surface_id.is_null()) - return; - service_->SetViewSurfaceId( - view_id, surface_id.Pass(), ActionCompletedCallback()); -} - -void ViewManagerClientImpl::SetFocus(Id view_id) { - // In order for us to get here we had to have exposed a view, which implies we - // got a connection. - DCHECK(service_); - service_->PerformAction(view_id, "focus", ActionCompletedCallback()); -} - -void ViewManagerClientImpl::SetVisible(Id view_id, bool visible) { - DCHECK(service_); - service_->SetViewVisibility(view_id, visible, ActionCompletedCallback()); -} - -void ViewManagerClientImpl::SetProperty( - Id view_id, - const std::string& name, - const std::vector<uint8_t>& data) { - DCHECK(service_); - service_->SetViewProperty(view_id, - String(name), - Array<uint8_t>::From(data), - ActionCompletedCallback()); -} - -void ViewManagerClientImpl::Embed(const String& url, Id view_id) { - Embed(url, view_id, nullptr, nullptr); -} - -void ViewManagerClientImpl::Embed(const String& url, - Id view_id, - InterfaceRequest<ServiceProvider> services, - ServiceProviderPtr exposed_services) { - DCHECK(service_); - service_->EmbedUrl(url, view_id, services.Pass(), exposed_services.Pass(), - ActionCompletedCallback()); -} - -void ViewManagerClientImpl::Embed(Id view_id, ViewManagerClientPtr client) { - DCHECK(service_); - service_->Embed(view_id, client.Pass(), ActionCompletedCallback()); -} - -void ViewManagerClientImpl::AddView(View* view) { - DCHECK(views_.find(view->id()) == views_.end()); - views_[view->id()] = view; -} - -void ViewManagerClientImpl::RemoveView(Id view_id) { - if (focused_view_ && focused_view_->id() == view_id) - OnFocusChanged(0); - if (capture_view_ && capture_view_->id() == view_id) - OnCaptureChanged(0); - if (activated_view_ && activated_view_->id() == view_id) - OnActiveWindowChanged(0); - - IdToViewMap::iterator it = views_.find(view_id); - if (it != views_.end()) - views_.erase(it); -} - -void ViewManagerClientImpl::SetViewManagerService( - ViewManagerServicePtr service) { - DCHECK(!service_); - DCHECK(service); - service_ = service.Pass(); -} -//////////////////////////////////////////////////////////////////////////////// -// ViewManagerClientImpl, ViewManager implementation: - -Id ViewManagerClientImpl::CreateViewOnServer() { - DCHECK(service_); - const Id view_id = MakeTransportId(connection_id_, ++next_id_); - service_->CreateView(view_id, [this](ErrorCode code) { - OnActionCompleted(code == ERROR_CODE_NONE); - }); - return view_id; -} - -const std::string& ViewManagerClientImpl::GetEmbedderURL() const { - return creator_url_; -} - -View* ViewManagerClientImpl::GetRoot() { - return root_; -} - -View* ViewManagerClientImpl::GetViewById(Id id) { - IdToViewMap::const_iterator it = views_.find(id); - return it != views_.end() ? it->second : NULL; -} - -View* ViewManagerClientImpl::GetFocusedView() { - return focused_view_; -} - -View* ViewManagerClientImpl::CreateView() { - View* view = new View(this, CreateViewOnServer()); - AddView(view); - return view; -} - -//////////////////////////////////////////////////////////////////////////////// -// ViewManagerClientImpl, ViewManagerClient implementation: - -void ViewManagerClientImpl::OnEmbed( - ConnectionSpecificId connection_id, - const String& creator_url, - ViewDataPtr root_data, - ViewManagerServicePtr view_manager_service, - InterfaceRequest<ServiceProvider> services, - ServiceProviderPtr exposed_services, - ScopedMessagePipeHandle window_manager_pipe) { - if (view_manager_service) { - DCHECK(!service_); - service_ = view_manager_service.Pass(); - } - connection_id_ = connection_id; - creator_url_ = String::From(creator_url); - - DCHECK(!root_); - root_ = AddViewToViewManager(this, nullptr, root_data); - root_->AddObserver(new RootObserver(root_)); - - window_manager_.Bind(window_manager_pipe.Pass()); - WindowManagerObserverPtr observer; - wm_observer_binding_.Bind(GetProxy(&observer)); - // binding to |this| is safe here as |window_manager_| is bound to our - // lifetime. - window_manager_->GetFocusedAndActiveViews( - observer.Pass(), - [this](uint32_t capture_view_id, uint32_t focused_view_id, - uint32_t active_view_id) { - if (GetViewById(capture_view_id) != capture_view_) - OnCaptureChanged(capture_view_id); - if (GetViewById(focused_view_id) != focused_view_) - OnFocusChanged(focused_view_id); - if (GetViewById(active_view_id) != activated_view_) - OnActiveWindowChanged(active_view_id); - }); - - delegate_->OnEmbed(root_, services.Pass(), exposed_services.Pass()); -} - -void ViewManagerClientImpl::OnEmbeddedAppDisconnected(Id view_id) { - View* view = GetViewById(view_id); - if (view) { - FOR_EACH_OBSERVER(ViewObserver, *ViewPrivate(view).observers(), - OnViewEmbeddedAppDisconnected(view)); - } -} - -void ViewManagerClientImpl::OnViewBoundsChanged(Id view_id, - RectPtr old_bounds, - RectPtr new_bounds) { - View* view = GetViewById(view_id); - ViewPrivate(view).LocalSetBounds(*old_bounds, *new_bounds); -} - -namespace { - -void SetViewportMetricsOnDecendants(View* root, - const ViewportMetrics& old_metrics, - const ViewportMetrics& new_metrics) { - ViewPrivate(root).LocalSetViewportMetrics(old_metrics, new_metrics); - const View::Children& children = root->children(); - for (size_t i = 0; i < children.size(); ++i) - SetViewportMetricsOnDecendants(children[i], old_metrics, new_metrics); -} -} - -void ViewManagerClientImpl::OnViewViewportMetricsChanged( - ViewportMetricsPtr old_metrics, - ViewportMetricsPtr new_metrics) { - View* view = GetRoot(); - if (view) - SetViewportMetricsOnDecendants(view, *old_metrics, *new_metrics); -} - -void ViewManagerClientImpl::OnViewHierarchyChanged( - Id view_id, - Id new_parent_id, - Id old_parent_id, - mojo::Array<ViewDataPtr> views) { - View* initial_parent = views.size() ? - GetViewById(views[0]->parent_id) : NULL; - - BuildViewTree(this, views, initial_parent); - - View* new_parent = GetViewById(new_parent_id); - View* old_parent = GetViewById(old_parent_id); - View* view = GetViewById(view_id); - if (new_parent) - ViewPrivate(new_parent).LocalAddChild(view); - else - ViewPrivate(old_parent).LocalRemoveChild(view); -} - -void ViewManagerClientImpl::OnViewReordered(Id view_id, - Id relative_view_id, - OrderDirection direction) { - View* view = GetViewById(view_id); - View* relative_view = GetViewById(relative_view_id); - if (view && relative_view) - ViewPrivate(view).LocalReorder(relative_view, direction); -} - -void ViewManagerClientImpl::OnViewDeleted(Id view_id) { - View* view = GetViewById(view_id); - if (view) - ViewPrivate(view).LocalDestroy(); -} - -void ViewManagerClientImpl::OnViewVisibilityChanged(Id view_id, bool visible) { - // TODO(sky): there is a race condition here. If this client and another - // client change the visibility at the same time the wrong value may be set. - // Deal with this some how. - View* view = GetViewById(view_id); - if (view) - ViewPrivate(view).LocalSetVisible(visible); -} - -void ViewManagerClientImpl::OnViewDrawnStateChanged(Id view_id, bool drawn) { - View* view = GetViewById(view_id); - if (view) - ViewPrivate(view).LocalSetDrawn(drawn); -} - -void ViewManagerClientImpl::OnViewSharedPropertyChanged( - Id view_id, - const String& name, - Array<uint8_t> new_data) { - View* view = GetViewById(view_id); - if (view) { - std::vector<uint8_t> data; - std::vector<uint8_t>* data_ptr = NULL; - if (!new_data.is_null()) { - data = new_data.To<std::vector<uint8_t>>(); - data_ptr = &data; - } - - view->SetSharedProperty(name, data_ptr); - } -} - -void ViewManagerClientImpl::OnViewInputEvent( - Id view_id, - EventPtr event, - const Callback<void()>& ack_callback) { - View* view = GetViewById(view_id); - if (view) { - FOR_EACH_OBSERVER(ViewObserver, - *ViewPrivate(view).observers(), - OnViewInputEvent(view, event)); - } - ack_callback.Run(); -} - -void ViewManagerClientImpl::OnPerformAction( - Id view_id, - const String& name, - const Callback<void(bool)>& callback) { - View* view = GetViewById(view_id); - callback.Run(delegate_->OnPerformAction(view, name)); -} - -//////////////////////////////////////////////////////////////////////////////// -// ViewManagerClientImpl, WindowManagerObserver implementation: - -void ViewManagerClientImpl::OnCaptureChanged(Id capture_view_id) { - View* gained_capture = GetViewById(capture_view_id); - View* lost_capture = capture_view_; - if (lost_capture) { - FOR_EACH_OBSERVER(ViewObserver, - *ViewPrivate(lost_capture).observers(), - OnViewFocusChanged(gained_capture, lost_capture)); - } - capture_view_ = gained_capture; - if (gained_capture) { - FOR_EACH_OBSERVER(ViewObserver, - *ViewPrivate(gained_capture).observers(), - OnViewFocusChanged(gained_capture, lost_capture)); - } -} - -void ViewManagerClientImpl::OnFocusChanged(Id focused_view_id) { - View* focused = GetViewById(focused_view_id); - View* blurred = focused_view_; - if (blurred) { - FOR_EACH_OBSERVER(ViewObserver, - *ViewPrivate(blurred).observers(), - OnViewFocusChanged(focused, blurred)); - } - focused_view_ = focused; - if (focused) { - FOR_EACH_OBSERVER(ViewObserver, - *ViewPrivate(focused).observers(), - OnViewFocusChanged(focused, blurred)); - } -} - -void ViewManagerClientImpl::OnActiveWindowChanged(Id active_view_id) { - View* activated = GetViewById(active_view_id); - View* deactivated = activated_view_; - if (deactivated) { - FOR_EACH_OBSERVER(ViewObserver, - *ViewPrivate(deactivated).observers(), - OnViewActivationChanged(activated, deactivated)); - } - activated_view_ = activated; - if (activated) { - FOR_EACH_OBSERVER(ViewObserver, - *ViewPrivate(activated).observers(), - OnViewActivationChanged(activated, deactivated)); - } -} - -//////////////////////////////////////////////////////////////////////////////// -// OnConnectionError, private: -void ViewManagerClientImpl::OnConnectionError() { - if (delete_on_error_) - delete this; -} - -//////////////////////////////////////////////////////////////////////////////// -// ViewManagerClientImpl, private: - -void ViewManagerClientImpl::RootDestroyed(View* root) { - DCHECK_EQ(root, root_); - root_ = nullptr; -} - -void ViewManagerClientImpl::OnActionCompleted(bool success) { - if (!change_acked_callback_.is_null()) - change_acked_callback_.Run(); -} - -Callback<void(bool)> ViewManagerClientImpl::ActionCompletedCallback() { - return [this](bool success) { OnActionCompleted(success); }; -} - -} // namespace mojo diff --git a/third_party/mojo_services/src/view_manager/public/cpp/lib/view_manager_client_impl.h b/third_party/mojo_services/src/view_manager/public/cpp/lib/view_manager_client_impl.h deleted file mode 100644 index 3bdfd7f..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/lib/view_manager_client_impl.h +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright 2014 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 MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ -#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ - -#include "mojo/public/cpp/bindings/strong_binding.h" -#include "view_manager/public/cpp/types.h" -#include "view_manager/public/cpp/view.h" -#include "view_manager/public/cpp/view_manager.h" -#include "view_manager/public/interfaces/view_manager.mojom.h" -#include "window_manager/public/interfaces/window_manager.mojom.h" - -namespace mojo { -class Shell; -class ViewManager; -class ViewManagerDelegate; -class ViewManagerTransaction; - -// Manages the connection with the View Manager service. -class ViewManagerClientImpl : public ViewManager, - public ViewManagerClient, - public WindowManagerObserver, - public ErrorHandler { - public: - ViewManagerClientImpl(ViewManagerDelegate* delegate, - Shell* shell, - InterfaceRequest<ViewManagerClient> request, - bool delete_on_error); - ~ViewManagerClientImpl() override; - - bool connected() const { return service_; } - ConnectionSpecificId connection_id() const { return connection_id_; } - - // API exposed to the view implementations that pushes local changes to the - // service. - void DestroyView(Id view_id); - - // These methods take TransportIds. For views owned by the current connection, - // the connection id high word can be zero. In all cases, the TransportId 0x1 - // refers to the root view. - void AddChild(Id child_id, Id parent_id); - void RemoveChild(Id child_id, Id parent_id); - - void Reorder(Id view_id, Id relative_view_id, OrderDirection direction); - - // Returns true if the specified view was created by this connection. - bool OwnsView(Id id) const; - - void SetBounds(Id view_id, const Rect& bounds); - void SetSurfaceId(Id view_id, SurfaceIdPtr surface_id); - void SetFocus(Id view_id); - void SetVisible(Id view_id, bool visible); - void SetProperty(Id view_id, - const std::string& name, - const std::vector<uint8_t>& data); - - void Embed(const String& url, Id view_id); - void Embed(const String& url, - Id view_id, - InterfaceRequest<ServiceProvider> services, - ServiceProviderPtr exposed_services); - void Embed(Id view_id, ViewManagerClientPtr client); - - void set_change_acked_callback(const Callback<void(void)>& callback) { - change_acked_callback_ = callback; - } - void ClearChangeAckedCallback() { change_acked_callback_.reset(); } - - // Start/stop tracking views. While tracked, they can be retrieved via - // ViewManager::GetViewById. - void AddView(View* view); - void RemoveView(Id view_id); - - void SetViewManagerService(ViewManagerServicePtr service); - - private: - friend class RootObserver; - - typedef std::map<Id, View*> IdToViewMap; - - Id CreateViewOnServer(); - - // Overridden from ViewManager: - const std::string& GetEmbedderURL() const override; - View* GetRoot() override; - View* GetViewById(Id id) override; - View* GetFocusedView() override; - View* CreateView() override; - - // Overridden from ViewManagerClient: - void OnEmbed(ConnectionSpecificId connection_id, - const String& creator_url, - ViewDataPtr root, - ViewManagerServicePtr view_manager_service, - InterfaceRequest<ServiceProvider> services, - ServiceProviderPtr exposed_services, - ScopedMessagePipeHandle window_manager_pipe) override; - void OnEmbeddedAppDisconnected(Id view_id) override; - void OnViewBoundsChanged(Id view_id, - RectPtr old_bounds, - RectPtr new_bounds) override; - void OnViewViewportMetricsChanged(ViewportMetricsPtr old_metrics, - ViewportMetricsPtr new_metrics) override; - void OnViewHierarchyChanged(Id view_id, - Id new_parent_id, - Id old_parent_id, - Array<ViewDataPtr> views) override; - void OnViewReordered(Id view_id, - Id relative_view_id, - OrderDirection direction) override; - void OnViewDeleted(Id view_id) override; - void OnViewVisibilityChanged(Id view_id, bool visible) override; - void OnViewDrawnStateChanged(Id view_id, bool drawn) override; - void OnViewSharedPropertyChanged(Id view_id, - const String& name, - Array<uint8_t> new_data) override; - void OnViewInputEvent(Id view_id, - EventPtr event, - const Callback<void()>& callback) override; - void OnPerformAction(Id view_id, - const String& name, - const Callback<void(bool)>& callback) override; - - // Overridden from WindowManagerObserver: - void OnCaptureChanged(Id capture_view_id) override; - void OnFocusChanged(Id focused_view_id) override; - void OnActiveWindowChanged(Id focused_view_id) override; - - // ErrorHandler implementation. - void OnConnectionError() override; - - void RootDestroyed(View* root); - - void OnActionCompleted(bool success); - - Callback<void(bool)> ActionCompletedCallback(); - - ConnectionSpecificId connection_id_; - ConnectionSpecificId next_id_; - - std::string creator_url_; - - Callback<void(void)> change_acked_callback_; - - ViewManagerDelegate* delegate_; - - View* root_; - - IdToViewMap views_; - - View* capture_view_; - View* focused_view_; - View* activated_view_; - - WindowManagerPtr window_manager_; - Binding<WindowManagerObserver> wm_observer_binding_; - - Binding<ViewManagerClient> binding_; - ViewManagerServicePtr service_; - const bool delete_on_error_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerClientImpl); -}; - -} // namespace mojo - -#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_MANAGER_CLIENT_IMPL_H_ diff --git a/third_party/mojo_services/src/view_manager/public/cpp/lib/view_manager_context.cc b/third_party/mojo_services/src/view_manager/public/cpp/lib/view_manager_context.cc deleted file mode 100644 index d1c2fd0..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/lib/view_manager_context.cc +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright 2014 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 "view_manager/public/cpp/view_manager_context.h" - -#include "mojo/public/cpp/application/application_impl.h" -#include "mojo/public/cpp/bindings/interface_request.h" -#include "window_manager/public/interfaces/window_manager.mojom.h" - -namespace mojo { -class ApplicationImpl; - -class ViewManagerContext::InternalState { - public: - explicit InternalState(ApplicationImpl* application_impl) { - application_impl->ConnectToService("mojo:window_manager", &wm_); - } - ~InternalState() {} - - WindowManager* wm() { return wm_.get(); } - - private: - WindowManagerPtr wm_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(InternalState); -}; - -ViewManagerContext::ViewManagerContext(ApplicationImpl* application_impl) - : state_(new InternalState(application_impl)) {} -ViewManagerContext::~ViewManagerContext() { - delete state_; -} - -void ViewManagerContext::Embed(const String& url) { - Embed(url, nullptr, nullptr); -} - -void ViewManagerContext::Embed(const String& url, - InterfaceRequest<ServiceProvider> services, - ServiceProviderPtr exposed_services) { - state_->wm()->Embed(url, services.Pass(), exposed_services.Pass()); -} - -} // namespace mojo diff --git a/third_party/mojo_services/src/view_manager/public/cpp/lib/view_observer.cc b/third_party/mojo_services/src/view_manager/public/cpp/lib/view_observer.cc deleted file mode 100644 index 7e6acc0..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/lib/view_observer.cc +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2014 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 "view_manager/public/cpp/view_observer.h" - -namespace mojo { - -//////////////////////////////////////////////////////////////////////////////// -// ViewObserver, public: - -ViewObserver::TreeChangeParams::TreeChangeParams() - : target(nullptr), - old_parent(nullptr), - new_parent(nullptr), - receiver(nullptr) { -} - -} // namespace mojo diff --git a/third_party/mojo_services/src/view_manager/public/cpp/lib/view_private.cc b/third_party/mojo_services/src/view_manager/public/cpp/lib/view_private.cc deleted file mode 100644 index 20232e8..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/lib/view_private.cc +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2014 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 "view_manager/public/cpp/lib/view_private.h" - -namespace mojo { - -ViewPrivate::ViewPrivate(View* view) - : view_(view) { - CHECK(view); -} - -ViewPrivate::~ViewPrivate() { -} - -// static -View* ViewPrivate::LocalCreate() { - return new View; -} - -} // namespace mojo diff --git a/third_party/mojo_services/src/view_manager/public/cpp/lib/view_private.h b/third_party/mojo_services/src/view_manager/public/cpp/lib/view_private.h deleted file mode 100644 index 0b58280..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/lib/view_private.h +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright 2014 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 MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_PRIVATE_H_ -#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_PRIVATE_H_ - -#include "view_manager/public/cpp/view.h" - -namespace mojo { - -// This class is a friend of a View and contains functions to mutate internal -// state of View. -class ViewPrivate { - public: - explicit ViewPrivate(View* view); - ~ViewPrivate(); - - // Creates and returns a new View. Caller owns the return value. - static View* LocalCreate(); - - ObserverList<ViewObserver>* observers() { return &view_->observers_; } - - void ClearParent() { view_->parent_ = NULL; } - - void set_visible(bool visible) { view_->visible_ = visible; } - - void set_drawn(bool drawn) { view_->drawn_ = drawn; } - - void set_id(Id id) { view_->id_ = id; } - - void set_view_manager(ViewManager* manager) { - view_->manager_ = manager; - } - - void set_properties(const std::map<std::string, std::vector<uint8_t>>& data) { - view_->properties_ = data; - } - - void LocalSetViewportMetrics(const ViewportMetrics& old_metrics, - const ViewportMetrics& new_metrics) { - view_->LocalSetViewportMetrics(new_metrics, new_metrics); - } - - void LocalDestroy() { - view_->LocalDestroy(); - } - void LocalAddChild(View* child) { - view_->LocalAddChild(child); - } - void LocalRemoveChild(View* child) { - view_->LocalRemoveChild(child); - } - void LocalReorder(View* relative, OrderDirection direction) { - view_->LocalReorder(relative, direction); - } - void LocalSetBounds(const Rect& old_bounds, - const Rect& new_bounds) { - view_->LocalSetBounds(old_bounds, new_bounds); - } - void LocalSetDrawn(bool drawn) { view_->LocalSetDrawn(drawn); } - void LocalSetVisible(bool visible) { view_->LocalSetVisible(visible); } - - private: - View* view_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(ViewPrivate); -}; - -} // namespace mojo - -#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_LIB_VIEW_PRIVATE_H_ diff --git a/third_party/mojo_services/src/view_manager/public/cpp/tests/BUILD.gn b/third_party/mojo_services/src/view_manager/public/cpp/tests/BUILD.gn deleted file mode 100644 index f0d8071..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/tests/BUILD.gn +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright 2014 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. - -import("//build/config/ui.gni") -import("//testing/test.gni") - -test("mojo_view_manager_lib_unittests") { - sources = [ - "run_all_unittests.cc", - "view_manager_test_suite.cc", - "view_manager_test_suite.h", - "view_unittest.cc", - ] - - deps = [ - "//base", - "//base/test:test_support", - # TODO(vtl): These non-public deps are illegal here. This should be - # converted to an apptest. - "//mojo/application", - "//mojo/edk/system", - "//mojo/environment:chromium", - "//mojo/public/cpp/application", - "//mojo/public/cpp/system", - "//mojo/services/geometry/public/cpp", - "//mojo/services/geometry/public/interfaces", - "//mojo/services/view_manager/public/cpp", - "//testing/gtest", - ] - - if (use_x11) { - deps += [ "//ui/gfx/x" ] - } -} diff --git a/third_party/mojo_services/src/view_manager/public/cpp/tests/run_all_unittests.cc b/third_party/mojo_services/src/view_manager/public/cpp/tests/run_all_unittests.cc deleted file mode 100644 index 95a7b5c..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/tests/run_all_unittests.cc +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2014 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 "base/bind.h" -#include "base/test/launcher/unit_test_launcher.h" -#include "mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.h" - -int main(int argc, char** argv) { - mojo::ViewManagerTestSuite test_suite(argc, argv); - - return base::LaunchUnitTests( - argc, argv, base::Bind(&TestSuite::Run, base::Unretained(&test_suite))); -} diff --git a/third_party/mojo_services/src/view_manager/public/cpp/tests/view_manager_test_suite.cc b/third_party/mojo_services/src/view_manager/public/cpp/tests/view_manager_test_suite.cc deleted file mode 100644 index 2bfdd1e..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/tests/view_manager_test_suite.cc +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2014 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 "mojo/services/view_manager/public/cpp/tests/view_manager_test_suite.h" - -#include "base/i18n/icu_util.h" - -#if defined(USE_X11) -#include "ui/gfx/x/x11_connection.h" -#endif - -namespace mojo { - -ViewManagerTestSuite::ViewManagerTestSuite(int argc, char** argv) - : TestSuite(argc, argv) {} - -ViewManagerTestSuite::~ViewManagerTestSuite() { -} - -void ViewManagerTestSuite::Initialize() { -#if defined(USE_X11) - // Each test ends up creating a new thread for the native viewport service. - // In other words we'll use X on different threads, so tell it that. - gfx::InitializeThreadedX11(); -#endif - - base::TestSuite::Initialize(); - - // base::TestSuite and ViewsInit both try to load icu. That's ok for tests. - base::i18n::AllowMultipleInitializeCallsForTesting(); -} - -} // namespace mojo diff --git a/third_party/mojo_services/src/view_manager/public/cpp/tests/view_manager_test_suite.h b/third_party/mojo_services/src/view_manager/public/cpp/tests/view_manager_test_suite.h deleted file mode 100644 index 547efc2..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/tests/view_manager_test_suite.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2014 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 MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_SUITE_H_ -#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_SUITE_H_ - -#include "base/test/test_suite.h" -#include "mojo/public/cpp/system/macros.h" - -namespace mojo { - -class ViewManagerTestSuite : public base::TestSuite { - public: - ViewManagerTestSuite(int argc, char** argv); - ~ViewManagerTestSuite() override; - - protected: - void Initialize() override; - - private: - MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerTestSuite); -}; - -} // namespace mojo - -#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_TESTS_VIEW_MANAGER_TEST_SUITE_H_ diff --git a/third_party/mojo_services/src/view_manager/public/cpp/tests/view_unittest.cc b/third_party/mojo_services/src/view_manager/public/cpp/tests/view_unittest.cc deleted file mode 100644 index 09d1bde..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/tests/view_unittest.cc +++ /dev/null @@ -1,884 +0,0 @@ -// Copyright 2014 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 "mojo/services/view_manager/public/cpp/view.h" - -#include "base/logging.h" -#include "base/strings/stringprintf.h" -#include "mojo/services/view_manager/public/cpp/lib/view_private.h" -#include "mojo/services/view_manager/public/cpp/util.h" -#include "mojo/services/view_manager/public/cpp/view_observer.h" -#include "mojo/services/view_manager/public/cpp/view_property.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace mojo { - -// View ------------------------------------------------------------------------ - -typedef testing::Test ViewTest; - -// Subclass with public ctor/dtor. -class TestView : public View { - public: - TestView() { - ViewPrivate(this).set_id(1); - } - ~TestView() {} - - private: - MOJO_DISALLOW_COPY_AND_ASSIGN(TestView); -}; - -TEST_F(ViewTest, AddChild) { - TestView v1; - TestView v11; - v1.AddChild(&v11); - EXPECT_EQ(1U, v1.children().size()); -} - -TEST_F(ViewTest, RemoveChild) { - TestView v1; - TestView v11; - v1.AddChild(&v11); - EXPECT_EQ(1U, v1.children().size()); - v1.RemoveChild(&v11); - EXPECT_EQ(0U, v1.children().size()); -} - -TEST_F(ViewTest, Reparent) { - TestView v1; - TestView v2; - TestView v11; - v1.AddChild(&v11); - EXPECT_EQ(1U, v1.children().size()); - v2.AddChild(&v11); - EXPECT_EQ(1U, v2.children().size()); - EXPECT_EQ(0U, v1.children().size()); -} - -TEST_F(ViewTest, Contains) { - TestView v1; - - // Direct descendant. - TestView v11; - v1.AddChild(&v11); - EXPECT_TRUE(v1.Contains(&v11)); - - // Indirect descendant. - TestView v111; - v11.AddChild(&v111); - EXPECT_TRUE(v1.Contains(&v111)); -} - -TEST_F(ViewTest, GetChildById) { - TestView v1; - ViewPrivate(&v1).set_id(1); - TestView v11; - ViewPrivate(&v11).set_id(11); - v1.AddChild(&v11); - TestView v111; - ViewPrivate(&v111).set_id(111); - v11.AddChild(&v111); - - // Find direct & indirect descendents. - EXPECT_EQ(&v11, v1.GetChildById(v11.id())); - EXPECT_EQ(&v111, v1.GetChildById(v111.id())); -} - -TEST_F(ViewTest, DrawnAndVisible) { - TestView v1; - EXPECT_TRUE(v1.visible()); - EXPECT_FALSE(v1.IsDrawn()); - - ViewPrivate(&v1).set_drawn(true); - - TestView v11; - v1.AddChild(&v11); - EXPECT_TRUE(v11.visible()); - EXPECT_TRUE(v11.IsDrawn()); - - v1.RemoveChild(&v11); - EXPECT_TRUE(v11.visible()); - EXPECT_FALSE(v11.IsDrawn()); -} - -namespace { -DEFINE_VIEW_PROPERTY_KEY(int, kIntKey, -2); -DEFINE_VIEW_PROPERTY_KEY(const char*, kStringKey, "squeamish"); -} - -TEST_F(ViewTest, Property) { - TestView v; - - // Non-existent properties should return the default values. - EXPECT_EQ(-2, v.GetLocalProperty(kIntKey)); - EXPECT_EQ(std::string("squeamish"), v.GetLocalProperty(kStringKey)); - - // A set property value should be returned again (even if it's the default - // value). - v.SetLocalProperty(kIntKey, INT_MAX); - EXPECT_EQ(INT_MAX, v.GetLocalProperty(kIntKey)); - v.SetLocalProperty(kIntKey, -2); - EXPECT_EQ(-2, v.GetLocalProperty(kIntKey)); - v.SetLocalProperty(kIntKey, INT_MIN); - EXPECT_EQ(INT_MIN, v.GetLocalProperty(kIntKey)); - - v.SetLocalProperty(kStringKey, static_cast<const char*>(NULL)); - EXPECT_EQ(NULL, v.GetLocalProperty(kStringKey)); - v.SetLocalProperty(kStringKey, "squeamish"); - EXPECT_EQ(std::string("squeamish"), v.GetLocalProperty(kStringKey)); - v.SetLocalProperty(kStringKey, "ossifrage"); - EXPECT_EQ(std::string("ossifrage"), v.GetLocalProperty(kStringKey)); - - // ClearProperty should restore the default value. - v.ClearLocalProperty(kIntKey); - EXPECT_EQ(-2, v.GetLocalProperty(kIntKey)); - v.ClearLocalProperty(kStringKey); - EXPECT_EQ(std::string("squeamish"), v.GetLocalProperty(kStringKey)); -} - -namespace { - -class TestProperty { - public: - TestProperty() {} - virtual ~TestProperty() { last_deleted_ = this; } - static TestProperty* last_deleted() { return last_deleted_; } - - private: - static TestProperty* last_deleted_; - MOJO_DISALLOW_COPY_AND_ASSIGN(TestProperty); -}; - -TestProperty* TestProperty::last_deleted_ = NULL; - -DEFINE_OWNED_VIEW_PROPERTY_KEY(TestProperty, kOwnedKey, NULL); - -} // namespace - -TEST_F(ViewTest, OwnedProperty) { - TestProperty* p3 = NULL; - { - TestView v; - EXPECT_EQ(NULL, v.GetLocalProperty(kOwnedKey)); - TestProperty* p1 = new TestProperty(); - v.SetLocalProperty(kOwnedKey, p1); - EXPECT_EQ(p1, v.GetLocalProperty(kOwnedKey)); - EXPECT_EQ(NULL, TestProperty::last_deleted()); - - TestProperty* p2 = new TestProperty(); - v.SetLocalProperty(kOwnedKey, p2); - EXPECT_EQ(p2, v.GetLocalProperty(kOwnedKey)); - EXPECT_EQ(p1, TestProperty::last_deleted()); - - v.ClearLocalProperty(kOwnedKey); - EXPECT_EQ(NULL, v.GetLocalProperty(kOwnedKey)); - EXPECT_EQ(p2, TestProperty::last_deleted()); - - p3 = new TestProperty(); - v.SetLocalProperty(kOwnedKey, p3); - EXPECT_EQ(p3, v.GetLocalProperty(kOwnedKey)); - EXPECT_EQ(p2, TestProperty::last_deleted()); - } - - EXPECT_EQ(p3, TestProperty::last_deleted()); -} - -// ViewObserver -------------------------------------------------------- - -typedef testing::Test ViewObserverTest; - -bool TreeChangeParamsMatch(const ViewObserver::TreeChangeParams& lhs, - const ViewObserver::TreeChangeParams& rhs) { - return lhs.target == rhs.target && lhs.old_parent == rhs.old_parent && - lhs.new_parent == rhs.new_parent && lhs.receiver == rhs.receiver; -} - -class TreeChangeObserver : public ViewObserver { - public: - explicit TreeChangeObserver(View* observee) : observee_(observee) { - observee_->AddObserver(this); - } - ~TreeChangeObserver() override { observee_->RemoveObserver(this); } - - void Reset() { - received_params_.clear(); - } - - const std::vector<TreeChangeParams>& received_params() { - return received_params_; - } - - private: - // Overridden from ViewObserver: - void OnTreeChanging(const TreeChangeParams& params) override { - received_params_.push_back(params); - } - void OnTreeChanged(const TreeChangeParams& params) override { - received_params_.push_back(params); - } - - View* observee_; - std::vector<TreeChangeParams> received_params_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(TreeChangeObserver); -}; - -// Adds/Removes v11 to v1. -TEST_F(ViewObserverTest, TreeChange_SimpleAddRemove) { - TestView v1; - TreeChangeObserver o1(&v1); - EXPECT_TRUE(o1.received_params().empty()); - - TestView v11; - TreeChangeObserver o11(&v11); - EXPECT_TRUE(o11.received_params().empty()); - - // Add. - - v1.AddChild(&v11); - - EXPECT_EQ(2U, o1.received_params().size()); - ViewObserver::TreeChangeParams p1; - p1.target = &v11; - p1.receiver = &v1; - p1.old_parent = NULL; - p1.new_parent = &v1; - EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().back())); - - EXPECT_EQ(2U, o11.received_params().size()); - ViewObserver::TreeChangeParams p11 = p1; - p11.receiver = &v11; - EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front())); - EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().back())); - - o1.Reset(); - o11.Reset(); - EXPECT_TRUE(o1.received_params().empty()); - EXPECT_TRUE(o11.received_params().empty()); - - // Remove. - - v1.RemoveChild(&v11); - - EXPECT_EQ(2U, o1.received_params().size()); - p1.target = &v11; - p1.receiver = &v1; - p1.old_parent = &v1; - p1.new_parent = NULL; - EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().front())); - - EXPECT_EQ(2U, o11.received_params().size()); - p11 = p1; - p11.receiver = &v11; - EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front())); - EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().back())); -} - -// Creates these two trees: -// v1 -// +- v11 -// v111 -// +- v1111 -// +- v1112 -// Then adds/removes v111 from v11. -TEST_F(ViewObserverTest, TreeChange_NestedAddRemove) { - TestView v1, v11, v111, v1111, v1112; - - // Root tree. - v1.AddChild(&v11); - - // Tree to be attached. - v111.AddChild(&v1111); - v111.AddChild(&v1112); - - TreeChangeObserver o1(&v1), o11(&v11), o111(&v111), o1111(&v1111), - o1112(&v1112); - ViewObserver::TreeChangeParams p1, p11, p111, p1111, p1112; - - // Add. - - v11.AddChild(&v111); - - EXPECT_EQ(2U, o1.received_params().size()); - p1.target = &v111; - p1.receiver = &v1; - p1.old_parent = NULL; - p1.new_parent = &v11; - EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().back())); - - EXPECT_EQ(2U, o11.received_params().size()); - p11 = p1; - p11.receiver = &v11; - EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().back())); - - EXPECT_EQ(2U, o111.received_params().size()); - p111 = p11; - p111.receiver = &v111; - EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().front())); - EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().back())); - - EXPECT_EQ(2U, o1111.received_params().size()); - p1111 = p111; - p1111.receiver = &v1111; - EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().front())); - EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().back())); - - EXPECT_EQ(2U, o1112.received_params().size()); - p1112 = p111; - p1112.receiver = &v1112; - EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().front())); - EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().back())); - - // Remove. - o1.Reset(); - o11.Reset(); - o111.Reset(); - o1111.Reset(); - o1112.Reset(); - EXPECT_TRUE(o1.received_params().empty()); - EXPECT_TRUE(o11.received_params().empty()); - EXPECT_TRUE(o111.received_params().empty()); - EXPECT_TRUE(o1111.received_params().empty()); - EXPECT_TRUE(o1112.received_params().empty()); - - v11.RemoveChild(&v111); - - EXPECT_EQ(2U, o1.received_params().size()); - p1.target = &v111; - p1.receiver = &v1; - p1.old_parent = &v11; - p1.new_parent = NULL; - EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().front())); - - EXPECT_EQ(2U, o11.received_params().size()); - p11 = p1; - p11.receiver = &v11; - EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front())); - - EXPECT_EQ(2U, o111.received_params().size()); - p111 = p11; - p111.receiver = &v111; - EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().front())); - EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().back())); - - EXPECT_EQ(2U, o1111.received_params().size()); - p1111 = p111; - p1111.receiver = &v1111; - EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().front())); - EXPECT_TRUE(TreeChangeParamsMatch(p1111, o1111.received_params().back())); - - EXPECT_EQ(2U, o1112.received_params().size()); - p1112 = p111; - p1112.receiver = &v1112; - EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().front())); - EXPECT_TRUE(TreeChangeParamsMatch(p1112, o1112.received_params().back())); -} - -TEST_F(ViewObserverTest, TreeChange_Reparent) { - TestView v1, v11, v12, v111; - v1.AddChild(&v11); - v1.AddChild(&v12); - v11.AddChild(&v111); - - TreeChangeObserver o1(&v1), o11(&v11), o12(&v12), o111(&v111); - - // Reparent. - v12.AddChild(&v111); - - // v1 (root) should see both changing and changed notifications. - EXPECT_EQ(4U, o1.received_params().size()); - ViewObserver::TreeChangeParams p1; - p1.target = &v111; - p1.receiver = &v1; - p1.old_parent = &v11; - p1.new_parent = &v12; - EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().front())); - EXPECT_TRUE(TreeChangeParamsMatch(p1, o1.received_params().back())); - - // v11 should see changing notifications. - EXPECT_EQ(2U, o11.received_params().size()); - ViewObserver::TreeChangeParams p11; - p11 = p1; - p11.receiver = &v11; - EXPECT_TRUE(TreeChangeParamsMatch(p11, o11.received_params().front())); - - // v12 should see changed notifications. - EXPECT_EQ(2U, o12.received_params().size()); - ViewObserver::TreeChangeParams p12; - p12 = p1; - p12.receiver = &v12; - EXPECT_TRUE(TreeChangeParamsMatch(p12, o12.received_params().back())); - - // v111 should see both changing and changed notifications. - EXPECT_EQ(2U, o111.received_params().size()); - ViewObserver::TreeChangeParams p111; - p111 = p1; - p111.receiver = &v111; - EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().front())); - EXPECT_TRUE(TreeChangeParamsMatch(p111, o111.received_params().back())); -} - -namespace { - -class OrderChangeObserver : public ViewObserver { - public: - struct Change { - View* view; - View* relative_view; - OrderDirection direction; - }; - typedef std::vector<Change> Changes; - - explicit OrderChangeObserver(View* observee) : observee_(observee) { - observee_->AddObserver(this); - } - ~OrderChangeObserver() override { observee_->RemoveObserver(this); } - - Changes GetAndClearChanges() { - Changes changes; - changes_.swap(changes); - return changes; - } - - private: - // Overridden from ViewObserver: - void OnViewReordering(View* view, - View* relative_view, - OrderDirection direction) override { - OnViewReordered(view, relative_view, direction); - } - - void OnViewReordered(View* view, - View* relative_view, - OrderDirection direction) override { - Change change; - change.view = view; - change.relative_view = relative_view; - change.direction = direction; - changes_.push_back(change); - } - - View* observee_; - Changes changes_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(OrderChangeObserver); -}; - -} // namespace - -TEST_F(ViewObserverTest, Order) { - TestView v1, v11, v12, v13; - v1.AddChild(&v11); - v1.AddChild(&v12); - v1.AddChild(&v13); - - // Order: v11, v12, v13 - EXPECT_EQ(3U, v1.children().size()); - EXPECT_EQ(&v11, v1.children().front()); - EXPECT_EQ(&v13, v1.children().back()); - - { - OrderChangeObserver observer(&v11); - - // Move v11 to front. - // Resulting order: v12, v13, v11 - v11.MoveToFront(); - EXPECT_EQ(&v12, v1.children().front()); - EXPECT_EQ(&v11, v1.children().back()); - - OrderChangeObserver::Changes changes = observer.GetAndClearChanges(); - ASSERT_EQ(2U, changes.size()); - EXPECT_EQ(&v11, changes[0].view); - EXPECT_EQ(&v13, changes[0].relative_view); - EXPECT_EQ(ORDER_DIRECTION_ABOVE, changes[0].direction); - - EXPECT_EQ(&v11, changes[1].view); - EXPECT_EQ(&v13, changes[1].relative_view); - EXPECT_EQ(ORDER_DIRECTION_ABOVE, changes[1].direction); - } - - { - OrderChangeObserver observer(&v11); - - // Move v11 to back. - // Resulting order: v11, v12, v13 - v11.MoveToBack(); - EXPECT_EQ(&v11, v1.children().front()); - EXPECT_EQ(&v13, v1.children().back()); - - OrderChangeObserver::Changes changes = observer.GetAndClearChanges(); - ASSERT_EQ(2U, changes.size()); - EXPECT_EQ(&v11, changes[0].view); - EXPECT_EQ(&v12, changes[0].relative_view); - EXPECT_EQ(ORDER_DIRECTION_BELOW, changes[0].direction); - - EXPECT_EQ(&v11, changes[1].view); - EXPECT_EQ(&v12, changes[1].relative_view); - EXPECT_EQ(ORDER_DIRECTION_BELOW, changes[1].direction); - } - - { - OrderChangeObserver observer(&v11); - - // Move v11 above v12. - // Resulting order: v12. v11, v13 - v11.Reorder(&v12, ORDER_DIRECTION_ABOVE); - EXPECT_EQ(&v12, v1.children().front()); - EXPECT_EQ(&v13, v1.children().back()); - - OrderChangeObserver::Changes changes = observer.GetAndClearChanges(); - ASSERT_EQ(2U, changes.size()); - EXPECT_EQ(&v11, changes[0].view); - EXPECT_EQ(&v12, changes[0].relative_view); - EXPECT_EQ(ORDER_DIRECTION_ABOVE, changes[0].direction); - - EXPECT_EQ(&v11, changes[1].view); - EXPECT_EQ(&v12, changes[1].relative_view); - EXPECT_EQ(ORDER_DIRECTION_ABOVE, changes[1].direction); - } - - { - OrderChangeObserver observer(&v11); - - // Move v11 below v12. - // Resulting order: v11, v12, v13 - v11.Reorder(&v12, ORDER_DIRECTION_BELOW); - EXPECT_EQ(&v11, v1.children().front()); - EXPECT_EQ(&v13, v1.children().back()); - - OrderChangeObserver::Changes changes = observer.GetAndClearChanges(); - ASSERT_EQ(2U, changes.size()); - EXPECT_EQ(&v11, changes[0].view); - EXPECT_EQ(&v12, changes[0].relative_view); - EXPECT_EQ(ORDER_DIRECTION_BELOW, changes[0].direction); - - EXPECT_EQ(&v11, changes[1].view); - EXPECT_EQ(&v12, changes[1].relative_view); - EXPECT_EQ(ORDER_DIRECTION_BELOW, changes[1].direction); - } -} - -namespace { - -typedef std::vector<std::string> Changes; - -std::string ViewIdToString(Id id) { - return (id == 0) ? "null" : - base::StringPrintf("%d,%d", HiWord(id), LoWord(id)); -} - -std::string RectToString(const Rect& rect) { - return base::StringPrintf("%d,%d %dx%d", - rect.x, rect.y, rect.width, rect.height); -} - -class BoundsChangeObserver : public ViewObserver { - public: - explicit BoundsChangeObserver(View* view) : view_(view) { - view_->AddObserver(this); - } - ~BoundsChangeObserver() override { view_->RemoveObserver(this); } - - Changes GetAndClearChanges() { - Changes changes; - changes.swap(changes_); - return changes; - } - - private: - // Overridden from ViewObserver: - void OnViewBoundsChanging(View* view, - const Rect& old_bounds, - const Rect& new_bounds) override { - changes_.push_back( - base::StringPrintf( - "view=%s old_bounds=%s new_bounds=%s phase=changing", - ViewIdToString(view->id()).c_str(), - RectToString(old_bounds).c_str(), - RectToString(new_bounds).c_str())); - } - void OnViewBoundsChanged(View* view, - const Rect& old_bounds, - const Rect& new_bounds) override { - changes_.push_back( - base::StringPrintf( - "view=%s old_bounds=%s new_bounds=%s phase=changed", - ViewIdToString(view->id()).c_str(), - RectToString(old_bounds).c_str(), - RectToString(new_bounds).c_str())); - } - - View* view_; - Changes changes_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(BoundsChangeObserver); -}; - -} // namespace - -TEST_F(ViewObserverTest, SetBounds) { - TestView v1; - { - BoundsChangeObserver observer(&v1); - Rect rect; - rect.width = rect.height = 100; - v1.SetBounds(rect); - - Changes changes = observer.GetAndClearChanges(); - ASSERT_EQ(2U, changes.size()); - EXPECT_EQ( - "view=0,1 old_bounds=0,0 0x0 new_bounds=0,0 100x100 phase=changing", - changes[0]); - EXPECT_EQ( - "view=0,1 old_bounds=0,0 0x0 new_bounds=0,0 100x100 phase=changed", - changes[1]); - } -} - -namespace { - -class VisibilityChangeObserver : public ViewObserver { - public: - explicit VisibilityChangeObserver(View* view) : view_(view) { - view_->AddObserver(this); - } - ~VisibilityChangeObserver() override { view_->RemoveObserver(this); } - - Changes GetAndClearChanges() { - Changes changes; - changes.swap(changes_); - return changes; - } - - private: - // Overridden from ViewObserver: - void OnViewVisibilityChanging(View* view) override { - changes_.push_back( - base::StringPrintf("view=%s phase=changing visibility=%s", - ViewIdToString(view->id()).c_str(), - view->visible() ? "true" : "false")); - } - void OnViewVisibilityChanged(View* view) override { - changes_.push_back(base::StringPrintf("view=%s phase=changed visibility=%s", - ViewIdToString(view->id()).c_str(), - view->visible() ? "true" : "false")); - } - - View* view_; - Changes changes_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(VisibilityChangeObserver); -}; - -} // namespace - -TEST_F(ViewObserverTest, SetVisible) { - TestView v1; - EXPECT_TRUE(v1.visible()); - { - // Change visibility from true to false and make sure we get notifications. - VisibilityChangeObserver observer(&v1); - v1.SetVisible(false); - - Changes changes = observer.GetAndClearChanges(); - ASSERT_EQ(2U, changes.size()); - EXPECT_EQ("view=0,1 phase=changing visibility=true", changes[0]); - EXPECT_EQ("view=0,1 phase=changed visibility=false", changes[1]); - } - { - // Set visible to existing value and verify no notifications. - VisibilityChangeObserver observer(&v1); - v1.SetVisible(false); - EXPECT_TRUE(observer.GetAndClearChanges().empty()); - } -} - -TEST_F(ViewObserverTest, SetVisibleParent) { - TestView parent; - ViewPrivate(&parent).set_id(1); - TestView child; - ViewPrivate(&child).set_id(2); - parent.AddChild(&child); - EXPECT_TRUE(parent.visible()); - EXPECT_TRUE(child.visible()); - { - // Change visibility from true to false and make sure we get notifications - // on the parent. - VisibilityChangeObserver observer(&parent); - child.SetVisible(false); - - Changes changes = observer.GetAndClearChanges(); - ASSERT_EQ(1U, changes.size()); - EXPECT_EQ("view=0,2 phase=changed visibility=false", changes[0]); - } -} - -TEST_F(ViewObserverTest, SetVisibleChild) { - TestView parent; - ViewPrivate(&parent).set_id(1); - TestView child; - ViewPrivate(&child).set_id(2); - parent.AddChild(&child); - EXPECT_TRUE(parent.visible()); - EXPECT_TRUE(child.visible()); - { - // Change visibility from true to false and make sure we get notifications - // on the child. - VisibilityChangeObserver observer(&child); - parent.SetVisible(false); - - Changes changes = observer.GetAndClearChanges(); - ASSERT_EQ(1U, changes.size()); - EXPECT_EQ("view=0,1 phase=changed visibility=false", changes[0]); - } -} - -namespace { - -class SharedPropertyChangeObserver : public ViewObserver { - public: - explicit SharedPropertyChangeObserver(View* view) : view_(view) { - view_->AddObserver(this); - } - ~SharedPropertyChangeObserver() override { view_->RemoveObserver(this); } - - Changes GetAndClearChanges() { - Changes changes; - changes.swap(changes_); - return changes; - } - - private: - // Overridden from ViewObserver: - void OnViewSharedPropertyChanged( - View* view, - const std::string& name, - const std::vector<uint8_t>* old_data, - const std::vector<uint8_t>* new_data) override { - changes_.push_back(base::StringPrintf( - "view=%s shared property changed key=%s old_value=%s new_value=%s", - ViewIdToString(view->id()).c_str(), name.c_str(), - VectorToString(old_data).c_str(), VectorToString(new_data).c_str())); - } - - std::string VectorToString(const std::vector<uint8_t>* data) { - if (!data) - return "NULL"; - std::string s; - for (char c : *data) - s += c; - return s; - } - - View* view_; - Changes changes_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(SharedPropertyChangeObserver); -}; - -} // namespace - -TEST_F(ViewObserverTest, SetLocalProperty) { - TestView v1; - std::vector<uint8_t> one(1, '1'); - - { - // Change visibility from true to false and make sure we get notifications. - SharedPropertyChangeObserver observer(&v1); - v1.SetSharedProperty("one", &one); - Changes changes = observer.GetAndClearChanges(); - ASSERT_EQ(1U, changes.size()); - EXPECT_EQ( - "view=0,1 shared property changed key=one old_value=NULL new_value=1", - changes[0]); - EXPECT_EQ(1U, v1.shared_properties().size()); - } - { - // Set visible to existing value and verify no notifications. - SharedPropertyChangeObserver observer(&v1); - v1.SetSharedProperty("one", &one); - EXPECT_TRUE(observer.GetAndClearChanges().empty()); - EXPECT_EQ(1U, v1.shared_properties().size()); - } - { - // Set the value to NULL to delete it. - // Change visibility from true to false and make sure we get notifications. - SharedPropertyChangeObserver observer(&v1); - v1.SetSharedProperty("one", NULL); - Changes changes = observer.GetAndClearChanges(); - ASSERT_EQ(1U, changes.size()); - EXPECT_EQ( - "view=0,1 shared property changed key=one old_value=1 new_value=NULL", - changes[0]); - EXPECT_EQ(0U, v1.shared_properties().size()); - } - { - // Setting a null property to null shouldn't update us. - SharedPropertyChangeObserver observer(&v1); - v1.SetSharedProperty("one", NULL); - EXPECT_TRUE(observer.GetAndClearChanges().empty()); - EXPECT_EQ(0U, v1.shared_properties().size()); - } -} - -namespace { - -typedef std::pair<const void*, intptr_t> PropertyChangeInfo; - -class LocalPropertyChangeObserver : public ViewObserver { - public: - explicit LocalPropertyChangeObserver(View* view) - : view_(view), - property_key_(nullptr), - old_property_value_(-1) { - view_->AddObserver(this); - } - ~LocalPropertyChangeObserver() override { view_->RemoveObserver(this); } - - PropertyChangeInfo PropertyChangeInfoAndClear() { - PropertyChangeInfo result(property_key_, old_property_value_); - property_key_ = NULL; - old_property_value_ = -3; - return result; - } - - private: - void OnViewLocalPropertyChanged(View* window, - const void* key, - intptr_t old) override { - property_key_ = key; - old_property_value_ = old; - } - - View* view_; - const void* property_key_; - intptr_t old_property_value_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(LocalPropertyChangeObserver); -}; - -} // namespace - -TEST_F(ViewObserverTest, LocalPropertyChanged) { - TestView v1; - LocalPropertyChangeObserver o(&v1); - - static const ViewProperty<int> prop = {-2}; - - v1.SetLocalProperty(&prop, 1); - EXPECT_EQ(PropertyChangeInfo(&prop, -2), o.PropertyChangeInfoAndClear()); - v1.SetLocalProperty(&prop, -2); - EXPECT_EQ(PropertyChangeInfo(&prop, 1), o.PropertyChangeInfoAndClear()); - v1.SetLocalProperty(&prop, 3); - EXPECT_EQ(PropertyChangeInfo(&prop, -2), o.PropertyChangeInfoAndClear()); - v1.ClearLocalProperty(&prop); - EXPECT_EQ(PropertyChangeInfo(&prop, 3), o.PropertyChangeInfoAndClear()); - - // Sanity check to see if |PropertyChangeInfoAndClear| really clears. - EXPECT_EQ(PropertyChangeInfo( - reinterpret_cast<const void*>(NULL), -3), o.PropertyChangeInfoAndClear()); -} - -} // namespace mojo diff --git a/third_party/mojo_services/src/view_manager/public/cpp/types.h b/third_party/mojo_services/src/view_manager/public/cpp/types.h deleted file mode 100644 index 5652691..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/types.h +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2014 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 MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_TYPES_H_ -#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_TYPES_H_ - -#include <stdint.h> - -// Typedefs for the transport types. These typedefs match that of the mojom -// file, see it for specifics. - -namespace mojo { - -// Used to identify views and change ids. -typedef uint32_t Id; - -// Used to identify a connection as well as a connection specific view id. For -// example, the Id for a view consists of the ConnectionSpecificId of the -// connection and the ConnectionSpecificId of the view. -typedef uint16_t ConnectionSpecificId; - -} // namespace mojo - -#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_TYPES_H_ diff --git a/third_party/mojo_services/src/view_manager/public/cpp/util.h b/third_party/mojo_services/src/view_manager/public/cpp/util.h deleted file mode 100644 index 33e75dd..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/util.h +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright 2014 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 MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_UTIL_H_ -#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_UTIL_H_ - -#include "view_manager/public/cpp/types.h" - -// TODO(beng): #$*&@#(@ MacOSX SDK! -#if defined(HiWord) -#undef HiWord -#endif -#if defined(LoWord) -#undef LoWord -#endif - -namespace mojo { - -inline uint16_t HiWord(uint32_t id) { - return static_cast<uint16_t>((id >> 16) & 0xFFFF); -} - -inline uint16_t LoWord(uint32_t id) { - return static_cast<uint16_t>(id & 0xFFFF); -} - -} // namespace mojo - -#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_UTIL_H_ diff --git a/third_party/mojo_services/src/view_manager/public/cpp/view.h b/third_party/mojo_services/src/view_manager/public/cpp/view.h deleted file mode 100644 index fcb49bc..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/view.h +++ /dev/null @@ -1,210 +0,0 @@ -// Copyright 2014 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 MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_ -#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_ - -#include <stdint.h> -#include <vector> - -#include "base/observer_list.h" -#include "geometry/public/interfaces/geometry.mojom.h" -#include "mojo/public/cpp/bindings/array.h" -#include "mojo/public/cpp/system/macros.h" -#include "mojo/public/interfaces/application/service_provider.mojom.h" -#include "surfaces/public/interfaces/surface_id.mojom.h" -#include "view_manager/public/cpp/types.h" -#include "view_manager/public/interfaces/view_manager.mojom.h" -#include "view_manager/public/interfaces/view_manager_constants.mojom.h" - -namespace mojo { - -class ServiceProviderImpl; -class View; -class ViewManager; -class ViewObserver; - -// Defined in view_property.h (which we do not include) -template <typename T> -struct ViewProperty; - -// Views are owned by the ViewManager. -// TODO(beng): Right now, you'll have to implement a ViewObserver to track -// destruction and NULL any pointers you have. -// Investigate some kind of smart pointer or weak pointer for these. -class View { - public: - using Children = std::vector<View*>; - using SharedProperties = std::map<std::string, std::vector<uint8_t>>; - - // Destroys this view and all its children. - void Destroy(); - - ViewManager* view_manager() { return manager_; } - - // Configuration. - Id id() const { return id_; } - - // Geometric disposition. - const Rect& bounds() const { return bounds_; } - void SetBounds(const Rect& bounds); - - // Visibility (also see IsDrawn()). When created views are hidden. - bool visible() const { return visible_; } - void SetVisible(bool value); - - const ViewportMetrics& viewport_metrics() { return *viewport_metrics_; } - - // Returns the set of string to bag of byte properties. These properties are - // shared with the view manager. - const SharedProperties& shared_properties() const { return properties_; } - // Sets a property. If |data| is null, this property is deleted. - void SetSharedProperty(const std::string& name, - const std::vector<uint8_t>* data); - - // Sets the |value| of the given window |property|. Setting to the default - // value (e.g., NULL) removes the property. The caller is responsible for the - // lifetime of any object set as a property on the View. - // - // These properties are not visible to the view manager. - template <typename T> - void SetLocalProperty(const ViewProperty<T>* property, T value); - - // Returns the value of the given window |property|. Returns the - // property-specific default value if the property was not previously set. - // - // These properties are only visible in the current process and are not - // shared with other mojo services. - template <typename T> - T GetLocalProperty(const ViewProperty<T>* property) const; - - // Sets the |property| to its default value. Useful for avoiding a cast when - // setting to NULL. - // - // These properties are only visible in the current process and are not - // shared with other mojo services. - template <typename T> - void ClearLocalProperty(const ViewProperty<T>* property); - - // Type of a function to delete a property that this view owns. - typedef void (*PropertyDeallocator)(int64_t value); - - // A View is drawn if the View and all its ancestors are visible and the - // View is attached to the root. - bool IsDrawn() const; - - // Observation. - void AddObserver(ViewObserver* observer); - void RemoveObserver(ViewObserver* observer); - - // Tree. - View* parent() { return parent_; } - const View* parent() const { return parent_; } - const Children& children() const { return children_; } - View* GetRoot() { - return const_cast<View*>(const_cast<const View*>(this)->GetRoot()); - } - const View* GetRoot() const; - - void AddChild(View* child); - void RemoveChild(View* child); - - void Reorder(View* relative, OrderDirection direction); - void MoveToFront(); - void MoveToBack(); - - bool Contains(View* child) const; - - View* GetChildById(Id id); - - void SetSurfaceId(SurfaceIdPtr id); - - // Focus. - void SetFocus(); - - // Embedding. See view_manager.mojom for details. - void Embed(const String& url); - void Embed(const String& url, - InterfaceRequest<ServiceProvider> services, - ServiceProviderPtr exposed_services); - void Embed(ViewManagerClientPtr client); - - protected: - // This class is subclassed only by test classes that provide a public ctor. - View(); - ~View(); - - private: - friend class ViewPrivate; - friend class ViewManagerClientImpl; - - View(ViewManager* manager, Id id); - - // Called by the public {Set,Get,Clear}Property functions. - int64_t SetLocalPropertyInternal(const void* key, - const char* name, - PropertyDeallocator deallocator, - int64_t value, - int64_t default_value); - int64_t GetLocalPropertyInternal(const void* key, - int64_t default_value) const; - - void LocalDestroy(); - void LocalAddChild(View* child); - void LocalRemoveChild(View* child); - // Returns true if the order actually changed. - bool LocalReorder(View* relative, OrderDirection direction); - void LocalSetBounds(const Rect& old_bounds, const Rect& new_bounds); - void LocalSetViewportMetrics(const ViewportMetrics& old_metrics, - const ViewportMetrics& new_metrics); - void LocalSetDrawn(bool drawn); - void LocalSetVisible(bool visible); - - // Methods implementing visibility change notifications. See ViewObserver - // for more details. - void NotifyViewVisibilityChanged(View* target); - // Notifies this view's observers. Returns false if |this| was deleted during - // the call (by an observer), otherwise true. - bool NotifyViewVisibilityChangedAtReceiver(View* target); - // Notifies this view and its child hierarchy. Returns false if |this| was - // deleted during the call (by an observer), otherwise true. - bool NotifyViewVisibilityChangedDown(View* target); - // Notifies this view and its parent hierarchy. - void NotifyViewVisibilityChangedUp(View* target); - - ViewManager* manager_; - Id id_; - View* parent_; - Children children_; - - ObserverList<ViewObserver> observers_; - - Rect bounds_; - ViewportMetricsPtr viewport_metrics_; - - bool visible_; - - SharedProperties properties_; - - // Drawn state is derived from the visible state and the parent's visible - // state. This field is only used if the view has no parent (eg it's a root). - bool drawn_; - - // Value struct to keep the name and deallocator for this property. - // Key cannot be used for this purpose because it can be char* or - // WindowProperty<>. - struct Value { - const char* name; - int64_t value; - PropertyDeallocator deallocator; - }; - - std::map<const void*, Value> prop_map_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(View); -}; - -} // namespace mojo - -#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_H_ diff --git a/third_party/mojo_services/src/view_manager/public/cpp/view_manager.h b/third_party/mojo_services/src/view_manager/public/cpp/view_manager.h deleted file mode 100644 index 5852dd2..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/view_manager.h +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2014 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 MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_H_ -#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_H_ - -#include <string> - -#include "view_manager/public/cpp/types.h" - -namespace mojo { -class View; - -// Encapsulates a connection to the view manager service. A unique connection -// is made every time an app is embedded. -class ViewManager { - public: - // Returns the URL of the application that embedded this application. - virtual const std::string& GetEmbedderURL() const = 0; - - // Returns the root of this connection. - virtual View* GetRoot() = 0; - - // Returns a View known to this connection. - virtual View* GetViewById(Id id) = 0; - - // Returns the focused view; null if focus is not yet known or another app is - // focused. - virtual View* GetFocusedView() = 0; - - // Creates and returns a new View (which is owned by the ViewManager). Views - // are initially hidden, use SetVisible(true) to show. - virtual View* CreateView() = 0; - - protected: - virtual ~ViewManager() {} -}; - -} // namespace mojo - -#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_H_ diff --git a/third_party/mojo_services/src/view_manager/public/cpp/view_manager_client_factory.h b/third_party/mojo_services/src/view_manager/public/cpp/view_manager_client_factory.h deleted file mode 100644 index e47da3d..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/view_manager_client_factory.h +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2014 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 MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_CLIENT_FACTORY_H_ -#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_CLIENT_FACTORY_H_ - -#include "mojo/public/cpp/application/interface_factory.h" -#include "view_manager/public/interfaces/view_manager.mojom.h" - -namespace mojo { - -class ViewManagerDelegate; -class Shell; - -// Add an instance of this class to an incoming connection to allow it to -// instantiate ViewManagerClient implementations in response to -// ViewManagerClient requests. -class ViewManagerClientFactory : public InterfaceFactory<ViewManagerClient> { - public: - ViewManagerClientFactory(Shell* shell, ViewManagerDelegate* delegate); - ~ViewManagerClientFactory() override; - - // Creates a ViewManagerClient from the supplied arguments. Returns ownership - // to the caller. - static ViewManagerClient* WeakBindViewManagerToPipe( - InterfaceRequest<ViewManagerClient> request, - ViewManagerServicePtr view_manager_service, - Shell* shell, - ViewManagerDelegate* delegate); - - // InterfaceFactory<ViewManagerClient> implementation. - void Create(ApplicationConnection* connection, - InterfaceRequest<ViewManagerClient> request) override; - - private: - Shell* shell_; - ViewManagerDelegate* delegate_; -}; - -} // namespace mojo - -#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_CLIENT_FACTORY_H_ diff --git a/third_party/mojo_services/src/view_manager/public/cpp/view_manager_context.h b/third_party/mojo_services/src/view_manager/public/cpp/view_manager_context.h deleted file mode 100644 index de7b84b..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/view_manager_context.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2014 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 MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_CONTEXT_H_ -#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_CONTEXT_H_ - -#include <string> -#include <vector> - -#include "mojo/public/cpp/application/service_provider_impl.h" -#include "mojo/public/cpp/system/macros.h" - -namespace mojo { -class ApplicationImpl; - -class ViewManagerContext { - public: - explicit ViewManagerContext(ApplicationImpl* application_impl); - ~ViewManagerContext(); - - // Embed an application @ |url| at an appropriate View. - // The first time this method is called in the life time of the View Manager - // service the "appropriate View" is defined as being the service' root View. - // Subsequent times, the implementation of this method is delegated to the - // application embedded at the service root View. This application will have a - // specific definition of where within its View hierarchy to embed an - // un-parented URL. - // |services| encapsulates services offered by the embedder to the embedded - // app alongside this Embed() call. |exposed_services| provides a means for - // the embedder to connect to services exposed by the embedded app. - void Embed(const String& url); - void Embed(const String& url, - InterfaceRequest<ServiceProvider> services, - ServiceProviderPtr exposed_Services); - - private: - class InternalState; - InternalState* state_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(ViewManagerContext); -}; - -} // namespace mojo - -#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_CONTEXT_H_ diff --git a/third_party/mojo_services/src/view_manager/public/cpp/view_manager_delegate.cc b/third_party/mojo_services/src/view_manager/public/cpp/view_manager_delegate.cc deleted file mode 100644 index 4ae64a7..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/view_manager_delegate.cc +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2015 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 "view_manager/public/cpp/view_manager_delegate.h" - -namespace mojo { - -bool ViewManagerDelegate::OnPerformAction(View* view, - const std::string& action) { - return false; -} - -} // namespace mojo diff --git a/third_party/mojo_services/src/view_manager/public/cpp/view_manager_delegate.h b/third_party/mojo_services/src/view_manager/public/cpp/view_manager_delegate.h deleted file mode 100644 index 1590a591..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/view_manager_delegate.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2014 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 MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_DELEGATE_H_ -#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_DELEGATE_H_ - -#include <string> - -#include "mojo/public/interfaces/application/service_provider.mojom.h" - -namespace mojo { - -class View; -class ViewManager; - -// Interface implemented by an application using the view manager. -class ViewManagerDelegate { - public: - // Called when the application implementing this interface is embedded at - // |root|. Every embed results in a new ViewManager and root View being - // created. |root| and it's corresponding ViewManager are valid until - // OnViewManagerDisconnected() is called with the same object. - // - // |services| exposes the services offered by the embedder to the delegate. - // - // |exposed_services| is an object that the delegate can add services to - // expose to the embedder. - // - // Note that if a different application is subsequently embedded at |root|, - // the pipes connecting |services| and |exposed_services| to the embedder and - // any services obtained from them are not broken and will continue to be - // valid. - virtual void OnEmbed(View* root, - InterfaceRequest<ServiceProvider> services, - ServiceProviderPtr exposed_services) = 0; - - // Called when a connection to the view manager service is closed. - // |view_manager| is not valid after this function returns. - virtual void OnViewManagerDisconnected(ViewManager* view_manager) = 0; - - // Asks the delegate to perform the specified action. - // TODO(sky): nuke! See comments in view_manager.mojom for details. - virtual bool OnPerformAction(View* view, const std::string& action); - - protected: - virtual ~ViewManagerDelegate() {} -}; - -} // namespace mojo - -#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_MANAGER_DELEGATE_H_ diff --git a/third_party/mojo_services/src/view_manager/public/cpp/view_observer.h b/third_party/mojo_services/src/view_manager/public/cpp/view_observer.h deleted file mode 100644 index 341a4f0..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/view_observer.h +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright 2014 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 MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_OBSERVER_H_ -#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_OBSERVER_H_ - -#include <vector> - -#include "input_events/public/interfaces/input_events.mojom.h" -#include "view_manager/public/cpp/view.h" - -namespace mojo { - -class View; - -// A note on -ing and -ed suffixes: -// -// -ing methods are called before changes are applied to the local view model. -// -ed methods are called after changes are applied to the local view model. -// -// If the change originated from another connection to the view manager, it's -// possible that the change has already been applied to the service-side model -// prior to being called, so for example in the case of OnViewDestroying(), it's -// possible the view has already been destroyed on the service side. - -class ViewObserver { - public: - struct TreeChangeParams { - TreeChangeParams(); - View* target; - View* old_parent; - View* new_parent; - View* receiver; - }; - - virtual void OnTreeChanging(const TreeChangeParams& params) {} - virtual void OnTreeChanged(const TreeChangeParams& params) {} - - virtual void OnViewReordering(View* view, - View* relative_view, - OrderDirection direction) {} - virtual void OnViewReordered(View* view, - View* relative_view, - OrderDirection direction) {} - - virtual void OnViewDestroying(View* view) {} - virtual void OnViewDestroyed(View* view) {} - - virtual void OnViewBoundsChanging(View* view, - const Rect& old_bounds, - const Rect& new_bounds) {} - virtual void OnViewBoundsChanged(View* view, - const Rect& old_bounds, - const Rect& new_bounds) {} - - virtual void OnViewViewportMetricsChanged(View* view, - const ViewportMetrics& old_bounds, - const ViewportMetrics& new_bounds) { - } - - virtual void OnViewCaptureChanged(View* gained_capture, View* lost_capture) {} - virtual void OnViewFocusChanged(View* gained_focus, View* lost_focus) {} - virtual void OnViewActivationChanged(View* gained_active, View* lost_active) { - } - - virtual void OnViewInputEvent(View* view, const EventPtr& event) {} - - virtual void OnViewVisibilityChanging(View* view) {} - virtual void OnViewVisibilityChanged(View* view) {} - - // Invoked when this View's shared properties have changed. This can either - // be caused by SetSharedProperty() being called locally, or by us receiving - // a mojo message that this property has changed. If this property has been - // added, |old_data| is null. If this property was removed, |new_data| is - // null. - virtual void OnViewSharedPropertyChanged( - View* view, - const std::string& name, - const std::vector<uint8_t>* old_data, - const std::vector<uint8_t>* new_data) {} - - // Invoked when SetProperty() or ClearProperty() is called on the window. - // |key| is either a WindowProperty<T>* (SetProperty, ClearProperty). Either - // way, it can simply be compared for equality with the property - // constant. |old| is the old property value, which must be cast to the - // appropriate type before use. - virtual void OnViewLocalPropertyChanged( - View* view, - const void* key, - intptr_t old) {} - - virtual void OnViewEmbeddedAppDisconnected(View* view) {} - - // Sent when the drawn state changes. This is only sent for the root nodes - // when embedded. - virtual void OnViewDrawnChanging(View* view) {} - virtual void OnViewDrawnChanged(View* view) {} - - protected: - virtual ~ViewObserver() {} -}; - -} // namespace mojo - -#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_OBSERVER_H_ diff --git a/third_party/mojo_services/src/view_manager/public/cpp/view_property.h b/third_party/mojo_services/src/view_manager/public/cpp/view_property.h deleted file mode 100644 index 2dbd317..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/view_property.h +++ /dev/null @@ -1,140 +0,0 @@ -// Copyright 2014 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 MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_PROPERTY_H_ -#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_PROPERTY_H_ - -#include <stdint.h> - -// This header should be included by code that defines ViewProperties. It -// should not be included by code that only gets and sets ViewProperties. -// -// To define a new ViewProperty: -// -// #include "view_manager/public/cpp/view_property.h" -// -// DECLARE_EXPORTED_VIEW_PROPERTY_TYPE(FOO_EXPORT, MyType); -// namespace foo { -// // Use this to define an exported property that is premitive, -// // or a pointer you don't want automatically deleted. -// DEFINE_VIEW_PROPERTY_KEY(MyType, kMyKey, MyDefault); -// -// // Use this to define an exported property whose value is a heap -// // allocated object, and has to be owned and freed by the view. -// DEFINE_OWNED_VIEW_PROPERTY_KEY(gfx::Rect, kRestoreBoundsKey, nullptr); -// -// // Use this to define a non exported property that is primitive, -// // or a pointer you don't want to automatically deleted, and is used -// // only in a specific file. This will define the property in an unnamed -// // namespace which cannot be accessed from another file. -// DEFINE_LOCAL_VIEW_PROPERTY_KEY(MyType, kMyKey, MyDefault); -// -// } // foo namespace -// -// To define a new type used for ViewProperty. -// -// // outside all namespaces: -// DECLARE_EXPORTED_VIEW_PROPERTY_TYPE(FOO_EXPORT, MyType) -// -// If a property type is not exported, use DECLARE_VIEW_PROPERTY_TYPE(MyType) -// which is a shorthand for DECLARE_EXPORTED_VIEW_PROPERTY_TYPE(, MyType). - -namespace mojo { -namespace { - -// No single new-style cast works for every conversion to/from int64_t, so we -// need this helper class. A third specialization is needed for bool because -// MSVC warning C4800 (forcing value to bool) is not suppressed by an explicit -// cast (!). -template <typename T> -class ViewPropertyCaster { - public: - static int64_t ToInt64(T x) { return static_cast<int64_t>(x); } - static T FromInt64(int64_t x) { return static_cast<T>(x); } -}; -template <typename T> -class ViewPropertyCaster<T*> { - public: - static int64_t ToInt64(T* x) { return reinterpret_cast<int64_t>(x); } - static T* FromInt64(int64_t x) { return reinterpret_cast<T*>(x); } -}; -template <> -class ViewPropertyCaster<bool> { - public: - static int64_t ToInt64(bool x) { return static_cast<int64_t>(x); } - static bool FromInt64(int64_t x) { return x != 0; } -}; - -} // namespace - -template <typename T> -struct ViewProperty { - T default_value; - const char* name; - View::PropertyDeallocator deallocator; -}; - -template <typename T> -void View::SetLocalProperty(const ViewProperty<T>* property, T value) { - int64_t old = SetLocalPropertyInternal( - property, property->name, - value == property->default_value ? nullptr : property->deallocator, - ViewPropertyCaster<T>::ToInt64(value), - ViewPropertyCaster<T>::ToInt64(property->default_value)); - if (property->deallocator && - old != ViewPropertyCaster<T>::ToInt64(property->default_value)) { - (*property->deallocator)(old); - } -} - -template <typename T> -T View::GetLocalProperty(const ViewProperty<T>* property) const { - return ViewPropertyCaster<T>::FromInt64(GetLocalPropertyInternal( - property, ViewPropertyCaster<T>::ToInt64(property->default_value))); -} - -template <typename T> -void View::ClearLocalProperty(const ViewProperty<T>* property) { - SetLocalProperty(property, property->default_value); -} - -} // namespace mojo - -// Macros to instantiate the property getter/setter template functions. -#define DECLARE_EXPORTED_VIEW_PROPERTY_TYPE(EXPORT, T) \ - template EXPORT void mojo::View::SetLocalProperty( \ - const mojo::ViewProperty<T>*, T); \ - template EXPORT T mojo::View::GetLocalProperty(const mojo::ViewProperty<T>*) \ - const; \ - template EXPORT void mojo::View::ClearLocalProperty( \ - const mojo::ViewProperty<T>*); -#define DECLARE_VIEW_PROPERTY_TYPE(T) DECLARE_EXPORTED_VIEW_PROPERTY_TYPE(, T) - -#define DEFINE_VIEW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ - COMPILE_ASSERT(sizeof(TYPE) <= sizeof(int64_t), property_type_too_large); \ - namespace { \ - const mojo::ViewProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \ - } \ - const mojo::ViewProperty<TYPE>* const NAME = &NAME##_Value; - -#define DEFINE_LOCAL_VIEW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ - COMPILE_ASSERT(sizeof(TYPE) <= sizeof(int64_t), property_type_too_large); \ - namespace { \ - const mojo::ViewProperty<TYPE> NAME##_Value = {DEFAULT, #NAME, nullptr}; \ - const mojo::ViewProperty<TYPE>* const NAME = &NAME##_Value; \ - } - -#define DEFINE_OWNED_VIEW_PROPERTY_KEY(TYPE, NAME, DEFAULT) \ - namespace { \ - void Deallocator##NAME(int64_t p) { \ - enum { type_must_be_complete = sizeof(TYPE) }; \ - delete mojo::ViewPropertyCaster<TYPE*>::FromInt64(p); \ - } \ - const mojo::ViewProperty<TYPE*> NAME##_Value = {DEFAULT, \ - #NAME, \ - &Deallocator##NAME}; \ - } \ - const mojo::ViewProperty<TYPE*>* const NAME = &NAME##_Value; - -#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_PROPERTY_H_ diff --git a/third_party/mojo_services/src/view_manager/public/cpp/view_tracker.cc b/third_party/mojo_services/src/view_manager/public/cpp/view_tracker.cc deleted file mode 100644 index 317b97a..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/view_tracker.cc +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright 2014 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 "view_manager/public/cpp/view_tracker.h" - -namespace mojo { - -ViewTracker::ViewTracker() { -} - -ViewTracker::~ViewTracker() { - for (Views::iterator i = views_.begin(); i != views_.end(); ++i) - (*i)->RemoveObserver(this); -} - -void ViewTracker::Add(View* view) { - if (views_.count(view)) - return; - - view->AddObserver(this); - views_.insert(view); -} - -void ViewTracker::Remove(View* view) { - if (views_.count(view)) { - views_.erase(view); - view->RemoveObserver(this); - } -} - -bool ViewTracker::Contains(View* view) { - return views_.count(view) > 0; -} - -void ViewTracker::OnViewDestroying(View* view) { - DCHECK_GT(views_.count(view), 0u); - Remove(view); -} - -} // namespace mojo diff --git a/third_party/mojo_services/src/view_manager/public/cpp/view_tracker.h b/third_party/mojo_services/src/view_manager/public/cpp/view_tracker.h deleted file mode 100644 index cfc2b9d..0000000 --- a/third_party/mojo_services/src/view_manager/public/cpp/view_tracker.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright 2014 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 MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_TRACKER_H_ -#define MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_TRACKER_H_ - -#include <stdint.h> -#include <set> - -#include "mojo/public/cpp/system/macros.h" -#include "view_manager/public/cpp/view_observer.h" - -namespace mojo { - -class ViewTracker : public ViewObserver { - public: - using Views = std::set<View*>; - - ViewTracker(); - ~ViewTracker() override; - - // Returns the set of views being observed. - const std::set<View*>& views() const { return views_; } - - // Adds |view| to the set of Views being tracked. - void Add(View* view); - - // Removes |view| from the set of views being tracked. - void Remove(View* view); - - // Returns true if |view| was previously added and has not been removed or - // deleted. - bool Contains(View* view); - - // ViewObserver overrides: - void OnViewDestroying(View* view) override; - - private: - Views views_; - - MOJO_DISALLOW_COPY_AND_ASSIGN(ViewTracker); -}; - -} // namespace mojo - -#endif // MOJO_SERVICES_VIEW_MANAGER_PUBLIC_CPP_VIEW_TRACKER_H_ diff --git a/third_party/mojo_services/src/view_manager/public/interfaces/BUILD.gn b/third_party/mojo_services/src/view_manager/public/interfaces/BUILD.gn deleted file mode 100644 index 177066b..0000000 --- a/third_party/mojo_services/src/view_manager/public/interfaces/BUILD.gn +++ /dev/null @@ -1,25 +0,0 @@ -# Copyright 2014 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. - -import("//build/module_args/mojo.gni") -import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni") - -mojom("interfaces") { - sources = [ - "animations.mojom", - "view_manager.mojom", - "view_manager_constants.mojom", - ] - - import_dirs = [ get_path_info("../../../", "abspath") ] - - mojo_sdk_deps = [ "mojo/public/interfaces/application" ] - - deps = [ - "../../../geometry/public/interfaces", - "../../../input_events/public/interfaces", - "../../../native_viewport/public/interfaces", - "../../../surfaces/public/interfaces:surface_id", - ] -} diff --git a/third_party/mojo_services/src/view_manager/public/interfaces/animations.mojom b/third_party/mojo_services/src/view_manager/public/interfaces/animations.mojom deleted file mode 100644 index 59572c4..0000000 --- a/third_party/mojo_services/src/view_manager/public/interfaces/animations.mojom +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -import "geometry/public/interfaces/geometry.mojom"; - -enum AnimationTweenType { - LINEAR, - EASE_IN, - EASE_OUT, - EASE_IN_OUT, -}; - -enum AnimationProperty { - // Used for pausing. - NONE, - OPACITY, - TRANSFORM, -}; - -struct AnimationValue { - float float_value; - Transform transform; -}; - -// Identifies how a particular property should be animated between a start and -// target value. -struct AnimationElement { - AnimationProperty property; - - // Duration is in microseconds. - int64 duration; - - AnimationTweenType tween_type; - - // If not specified the start value is taken from either the current value - // (for the first element) or the target_value of the previous element. - AnimationValue? start_value; - - // target_value may be null when property is NONE. - AnimationValue? target_value; -}; - -// An AnimationSequence consists of a number of AnimationElements to animate. -// Each element is animated serially. -struct AnimationSequence { - // Number of times to run the sequence. Value of 0 means run until - // explicitly stopped. - uint32 cycle_count; - - array<AnimationElement> elements; -}; - -// AnimationGroup identifies a view and a set of AnimationSequences to apply -// to the view. Each sequence is run in parallel. -struct AnimationGroup { - uint32 view_id; - array<AnimationSequence> sequences; -}; diff --git a/third_party/mojo_services/src/view_manager/public/interfaces/view_manager.mojom b/third_party/mojo_services/src/view_manager/public/interfaces/view_manager.mojom deleted file mode 100644 index 0a2564e..0000000 --- a/third_party/mojo_services/src/view_manager/public/interfaces/view_manager.mojom +++ /dev/null @@ -1,230 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -import "geometry/public/interfaces/geometry.mojom"; -import "input_events/public/interfaces/input_events.mojom"; -import "mojo/public/interfaces/application/service_provider.mojom"; -import "native_viewport/public/interfaces/native_viewport.mojom"; -import "surfaces/public/interfaces/surface_id.mojom"; -import "view_manager/public/interfaces/view_manager_constants.mojom"; - -struct ViewData { - uint32 parent_id; - uint32 view_id; - mojo.Rect bounds; - map<string, array<uint8>> properties; - // True if this view is visible. The view may not be drawn on screen (see - // drawn for specifics). - bool visible; - // True if this view is drawn on screen. A view is drawn if attached to the - // root and all ancestors (including this view) are visible. - bool drawn; - ViewportMetrics viewport_metrics; -}; - -enum ErrorCode { - NONE, - VALUE_IN_USE, - ILLEGAL_ARGUMENT, -}; - -// Views are identified by a uint32. The upper 16 bits are the connection id, -// and the lower 16 the id assigned by the client. -// -// The root view is identified with a connection id of 0, and value of 1. -interface ViewManagerService { - // Creates a new view with the specified id. It is up to the client to ensure - // the id is unique to the connection (the id need not be globally unique). - // Additionally the connection id (embedded in |view_id|) must match that of - // the connection. - // Errors: - // ERROR_CODE_VALUE_IN_USE: a view already exists with the specified id. - // ERROR_CODE_ILLEGAL_ARGUMENT: The connection part of |view_id| does not - // match the connection id of the client. - // - // TODO(erg): Once we have default values in mojo, make this take a map of - // properties. - CreateView(uint32 view_id) => (ErrorCode error_code); - - // Deletes a view. This does not recurse. No hierarchy change notifications - // are sent as a result of this. Only the connection that created the view can - // delete it. - DeleteView(uint32 view_id) => (bool success); - - // Sets the specified bounds of the specified view. - SetViewBounds(uint32 view_id, mojo.Rect bounds) => (bool success); - - // Sets the visibility of the specified view to |visible|. Connections are - // allowed to change the visibility of any view they have created, as well as - // any of their roots. - SetViewVisibility(uint32 view_id, bool visible) => (bool success); - - // Sets an individual named property. Setting an individual property to null - // deletes the property. - SetViewProperty(uint32 view_id, - string name, - array<uint8>? value) => (bool success); - - // Reparents a view. - // This fails for any of the following reasons: - // . |parent| or |child| does not identify a valid view. - // . |child| is an ancestor of |parent|. - // . |child| is already a child of |parent|. - // - // This may result in a connection getting OnViewDeleted(). See - // RemoveViewFromParent for details. - AddView(uint32 parent, uint32 child) => (bool success); - - // Removes a view from its current parent. This fails if the view is not - // valid or the view already has no parent. - // - // Removing a view from a parent may result in OnViewDeleted() being sent to - // other connections. For example, connection A has views 1 and 2, with 2 a - // child of 1. Connection B has a root 1. If 2 is removed from 1 then B gets - // OnViewDeleted(). This is done as view 2 is effectively no longer visible to - // connection B. - RemoveViewFromParent(uint32 view_id) => (bool success); - - // Reorders a view in its parent, relative to |relative_view_id| according to - // |direction|. - // Only the connection that created the view's parent can reorder its - // children. - ReorderView(uint32 view_id, - uint32 relative_view_id, - OrderDirection direction) => (bool success); - - // Returns the views comprising the tree starting at |view_id|. |view_id| is - // the first result in the return value, unless |view_id| is invalid, in which - // case an empty vector is returned. The views are visited using a depth first - // search (pre-order). - GetViewTree(uint32 view_id) => (array<ViewData> views); - - // Shows the surface in the specified view. - SetViewSurfaceId(uint32 view_id, SurfaceId surface_id) => (bool success); - - // A connection may grant access to a view from another connection by way of - // the embed functions. There are two variants of this call: - // - // . EmbedUrl: the ViewManager connects to the app at the supplied url and - // asks it for a ViewManagerClient. - // . With the second variant a ViewManagerClient is directly supplied. - // - // In both cases the new ViewManagerClient is configured with a root of - // |view_id|. - // - // The caller must have created |view_id|. If not the request fails and the - // response is false. - // - // A view may only be a root of one connection at a time. Subsequent calls to - // Embed() for the same view result in the view being removed from the - // currently embedded app. The embedded app is told this by way of - // OnViewDeleted(). - // - // The embedder can detect when the embedded app disconnects by way of - // OnEmbeddedAppDisconnected(). - // - // When a connection embeds an app the connection no longer has priviledges - // to access or see any of the children of the view. If the view had existing - // children the children are removed. The one exception is the root - // connection. - // - // |services| encapsulates services offered by the embedder to the embedded - // app alongside this Embed() call. |exposed_services| provides a means for - // the embedder to connect to services exposed by the embedded app. Note that - // if a different app is subsequently embedded at |view_id| the - // ServiceProvider connections to its client in the embedded app and any - // services it provided are not broken and continue to be valid. - EmbedUrl(string url, - uint32 view_id, - ServiceProvider&? services, - ServiceProvider? exposed_services) => (bool success); - Embed(uint32 view_id, ViewManagerClient client) => (bool success); - - // Requests the WindowManager to perform an action on the specified view. - // It's up to the WindowManager to decide what |action| is. - // - // TODO(sky): nuke this. This is here to guarantee the state of the - // WindowManager matches that of the ViewManager at the time the client - // invokes the function. When we can enforce ordering this won't be necessary. - PerformAction(uint32 view_id, string action) => (bool success); -}; - -// Changes to views are not sent to the connection that originated the -// change. For example, if connection 1 changes the bounds of a view by calling -// SetBounds(), connection 1 does not receive OnViewBoundsChanged(). -interface ViewManagerClient { - // Invoked when the client application has been embedded at |root|. - // See Embed() on ViewManagerService for more details. |view_manager_service| - // will be a handle back to the view manager service, unless the connection is - // to the WindowManager in which case it will be null. - // |window_manager_pipe| is a pipe to the WindowManager. - OnEmbed(uint16 connection_id, - string embedder_url, - ViewData root, - ViewManagerService? view_manager_service, - ServiceProvider&? services, - ServiceProvider? exposed_services, - handle<message_pipe> window_manager_pipe); - - // Invoked when the application embedded at |view| is disconnected. - OnEmbeddedAppDisconnected(uint32 view); - - // Invoked when a view's bounds have changed. - OnViewBoundsChanged(uint32 view, - mojo.Rect old_bounds, - mojo.Rect new_bounds); - - // Invoked when the viewport metrics for the view have changed. - // Clients are expected to propagate this to the view tree. - OnViewViewportMetricsChanged(mojo.ViewportMetrics old_metrics, - mojo.ViewportMetrics new_metrics); - - // Invoked when a change is done to the hierarchy. A value of 0 is used to - // identify a null view. For example, if the old_parent is NULL, 0 is - // supplied. - // |views| contains any views that are that the client has not been told - // about. This is not sent for hierarchy changes of views not known to this - // client or not attached to the tree. - OnViewHierarchyChanged(uint32 view, - uint32 new_parent, - uint32 old_parent, - array<ViewData> views); - - // Invoked when the order of views within a parent changes. - OnViewReordered(uint32 view_id, - uint32 relative_view_id, - OrderDirection direction); - - // Invoked when a view is deleted. - OnViewDeleted(uint32 view); - - // Invoked when the visibility of the specified view changes. - OnViewVisibilityChanged(uint32 view, bool visible); - - // Invoked when a change to the visibility of |view| or one if it's ancestors - // is done such that the drawn state changes. This is only invoked for the - // top most view of a particular connection. For example, if you have the - // hierarchy: A -> B1 -> B2 (B2 is a child of B1 and B1 a child of A), B1/B2 - // are from connection 2 and A from connection 1 with all views visible and - // drawn and the visiblity of A changes to false, then connection 2 is told - // the drawn state of B1 has changed (to false), but is not told anything - // about B2 as it's drawn state can be calculated from that of B1. - // - // NOTE: This is not invoked if OnViewVisibilityChanged() is invoked. - OnViewDrawnStateChanged(uint32 view, bool drawn); - - // Invoked when a view property is changed. If this change is a removal, - // |new_data| is null. - OnViewSharedPropertyChanged(uint32 view, string name, array<uint8>? new_data); - - // Invoked when an event is targeted at the specified view. - OnViewInputEvent(uint32 view, mojo.Event event) => (); - - // Invoked solely on the WindowManager. See comments in PerformAction() above - // for details. - // TODO(sky): nuke this. - OnPerformAction(uint32 view_id, string action) => (bool success); -}; diff --git a/third_party/mojo_services/src/view_manager/public/interfaces/view_manager_constants.mojom b/third_party/mojo_services/src/view_manager/public/interfaces/view_manager_constants.mojom deleted file mode 100644 index 14bd363..0000000 --- a/third_party/mojo_services/src/view_manager/public/interfaces/view_manager_constants.mojom +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -enum OrderDirection { - ABOVE = 1, - BELOW, -}; diff --git a/third_party/mojo_services/src/window_manager/public/interfaces/BUILD.gn b/third_party/mojo_services/src/window_manager/public/interfaces/BUILD.gn deleted file mode 100644 index b97f069..0000000 --- a/third_party/mojo_services/src/window_manager/public/interfaces/BUILD.gn +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright 2014 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. - -import("//build/module_args/mojo.gni") -import("$mojo_sdk_root/mojo/public/tools/bindings/mojom.gni") - -mojom("interfaces") { - sources = [ - "window_manager.mojom", - "window_manager_internal.mojom", - ] - - import_dirs = [ get_path_info("../../../", "abspath") ] - - mojo_sdk_deps = [ "mojo/public/interfaces/application" ] - - deps = [ - "../../../geometry/public/interfaces", - "../../../input_events/public/interfaces", - ] -} diff --git a/third_party/mojo_services/src/window_manager/public/interfaces/window_manager.mojom b/third_party/mojo_services/src/window_manager/public/interfaces/window_manager.mojom deleted file mode 100644 index ee1b02e..0000000 --- a/third_party/mojo_services/src/window_manager/public/interfaces/window_manager.mojom +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -import "input_events/public/interfaces/input_events.mojom"; -import "mojo/public/interfaces/application/service_provider.mojom"; - -interface WindowManager { - // Requests the WindowManager to embed the app for |url| at an appropriate - // View. See ViewMangerService::Embed() for details on |services| and - // |exposed_services|. - Embed(string url, - ServiceProvider&? services, - ServiceProvider? exposed_services); - - SetCapture(uint32 view_id) => (bool success); - FocusWindow(uint32 view_id) => (bool success); - ActivateWindow(uint32 view_id) => (bool success); - - // Requests the current focus and activation state and an interface to observe - // future changes. - // If |observer| is not null capture, focus and activation updates will be - // sent to it. - GetFocusedAndActiveViews(WindowManagerObserver? observer) - => (uint32 capture_view_id, - uint32 focused_view_id, - uint32 active_view_id); -}; - -interface WindowManagerObserver { - OnCaptureChanged(uint32 capture_view_id); - OnFocusChanged(uint32 focused_view_id); - OnActiveWindowChanged(uint32 focused_view_id); -}; diff --git a/third_party/mojo_services/src/window_manager/public/interfaces/window_manager_internal.mojom b/third_party/mojo_services/src/window_manager/public/interfaces/window_manager_internal.mojom deleted file mode 100644 index bdb655d..0000000 --- a/third_party/mojo_services/src/window_manager/public/interfaces/window_manager_internal.mojom +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright 2014 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. - -module mojo; - -import "geometry/public/interfaces/geometry.mojom"; -import "input_events/public/interfaces/input_events.mojom"; - -// WindowManagerInternal is an interface provided by the WindowManager -// exclusively to the ViewManager. -interface WindowManagerInternal { - // Creates a connection to the WindowManager specifically for a connection to - // the ViewManager. |connection_id| is the id of the connection to the - // ViewManager. See view_manager.mojom for details on the id. - CreateWindowManagerForViewManagerClient( - uint16 connection_id, - handle<message_pipe> window_manager_pipe); - - SetViewManagerClient(handle<message_pipe> view_manager_client_request); -}; - -// WindowManagerInternalClient is an interface provide by the ViewManager -// exclusively to the WindowManager. It provides functionality only available -// to the WindowManager. -interface WindowManagerInternalClient { - // Dispatches the specified input event to the specified view. - DispatchInputEventToView(uint32 view_id, mojo.Event event); - - // Sets the native viewport size. - SetViewportSize(mojo.Size size); - - // Clones the tree rooted at |view_id|. When the animation completes the clone - // is destroyed. - // TODO(sky): add actual animation. - // TODO(sky): I think this only makes sense when destroying (view is - // already visible), should it be named to indicate this? - CloneAndAnimate(uint32 view_id); -}; |