summaryrefslogtreecommitdiff
path: root/chromium/ui
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-06 12:48:11 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:33:43 +0000
commit7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (patch)
treefa14ba0ca8d2683ba2efdabd246dc9b18a1229c6 /chromium/ui
parent79b4f909db1049fca459c07cca55af56a9b54fe3 (diff)
downloadqtwebengine-chromium-7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3.tar.gz
BASELINE: Update Chromium to 84.0.4147.141
Change-Id: Ib85eb4cfa1cbe2b2b81e5022c8cad5c493969535 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/ui')
-rw-r--r--chromium/ui/PRESUBMIT.py47
-rw-r--r--chromium/ui/accessibility/BUILD.gn154
-rw-r--r--chromium/ui/accessibility/PRESUBMIT.py6
-rw-r--r--chromium/ui/accessibility/accessibility_switches.cc16
-rw-r--r--chromium/ui/accessibility/accessibility_switches.h5
-rw-r--r--chromium/ui/accessibility/aura/aura_window_properties.cc (renamed from chromium/ui/accessibility/platform/aura_window_properties.cc)2
-rw-r--r--chromium/ui/accessibility/aura/aura_window_properties.h (renamed from chromium/ui/accessibility/platform/aura_window_properties.h)6
-rw-r--r--chromium/ui/accessibility/ax_base_export.h2
-rw-r--r--chromium/ui/accessibility/ax_enum_util.cc180
-rw-r--r--chromium/ui/accessibility/ax_enum_util.h20
-rw-r--r--chromium/ui/accessibility/ax_enum_util_unittest.cc11
-rw-r--r--chromium/ui/accessibility/ax_enums.mojom25
-rw-r--r--chromium/ui/accessibility/ax_event.cc29
-rw-r--r--chromium/ui/accessibility/ax_event.h35
-rw-r--r--chromium/ui/accessibility/ax_event_generator.cc36
-rw-r--r--chromium/ui/accessibility/ax_event_intent.cc40
-rw-r--r--chromium/ui/accessibility/ax_event_intent.h44
-rw-r--r--chromium/ui/accessibility/ax_generated_tree_unittest.cc251
-rw-r--r--chromium/ui/accessibility/ax_node.cc271
-rw-r--r--chromium/ui/accessibility/ax_node.h139
-rw-r--r--chromium/ui/accessibility/ax_node_data.cc87
-rw-r--r--chromium/ui/accessibility/ax_node_data.h46
-rw-r--r--chromium/ui/accessibility/ax_node_data_unittest.cc124
-rw-r--r--chromium/ui/accessibility/ax_node_position.cc34
-rw-r--r--chromium/ui/accessibility/ax_node_position_unittest.cc412
-rw-r--r--chromium/ui/accessibility/ax_param_traits_macros.h13
-rw-r--r--chromium/ui/accessibility/ax_position.h90
-rw-r--r--chromium/ui/accessibility/ax_role_properties.cc89
-rw-r--r--chromium/ui/accessibility/ax_role_properties.h43
-rw-r--r--chromium/ui/accessibility/ax_table_info.cc124
-rw-r--r--chromium/ui/accessibility/ax_table_info.h8
-rw-r--r--chromium/ui/accessibility/ax_table_info_unittest.cc98
-rw-r--r--chromium/ui/accessibility/ax_text_utils.cc64
-rw-r--r--chromium/ui/accessibility/ax_text_utils.h23
-rw-r--r--chromium/ui/accessibility/ax_tree.cc13
-rw-r--r--chromium/ui/accessibility/ax_tree.h9
-rw-r--r--chromium/ui/accessibility/ax_tree_id.cc3
-rw-r--r--chromium/ui/accessibility/ax_tree_serializer.h67
-rw-r--r--chromium/ui/accessibility/ax_tree_source.h7
-rw-r--r--chromium/ui/accessibility/ax_tree_unittest.cc580
-rw-r--r--chromium/ui/accessibility/extensions/chromevoxclassic/testing/chromevox_unittest_base.js7
-rw-r--r--chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_ar.xtb2
-rw-r--r--chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_eu.xtb10
-rw-r--r--chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_hi.xtb4
-rw-r--r--chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_id.xtb2
-rw-r--r--chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_km.xtb2
-rw-r--r--chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_my.xtb6
-rw-r--r--chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_ne.xtb2
-rw-r--r--chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_sw.xtb14
-rw-r--r--chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_vi.xtb4
-rw-r--r--chromium/ui/accessibility/mojom/BUILD.gn121
-rw-r--r--chromium/ui/accessibility/mojom/ax_action_data.typemap15
-rw-r--r--chromium/ui/accessibility/mojom/ax_assistant_structure.typemap23
-rw-r--r--chromium/ui/accessibility/mojom/ax_event.mojom2
-rw-r--r--chromium/ui/accessibility/mojom/ax_event.typemap15
-rw-r--r--chromium/ui/accessibility/mojom/ax_event_intent.mojom14
-rw-r--r--chromium/ui/accessibility/mojom/ax_event_intent_mojom_traits.cc19
-rw-r--r--chromium/ui/accessibility/mojom/ax_event_intent_mojom_traits.h29
-rw-r--r--chromium/ui/accessibility/mojom/ax_event_intent_mojom_traits_unittest.cc26
-rw-r--r--chromium/ui/accessibility/mojom/ax_event_mojom_traits.cc2
-rw-r--r--chromium/ui/accessibility/mojom/ax_event_mojom_traits.h10
-rw-r--r--chromium/ui/accessibility/mojom/ax_event_mojom_traits_unittest.cc18
-rw-r--r--chromium/ui/accessibility/mojom/ax_node_data.typemap15
-rw-r--r--chromium/ui/accessibility/mojom/ax_relative_bounds.typemap19
-rw-r--r--chromium/ui/accessibility/mojom/ax_tree_data.typemap15
-rw-r--r--chromium/ui/accessibility/mojom/ax_tree_id.typemap15
-rw-r--r--chromium/ui/accessibility/mojom/ax_tree_update.typemap15
-rw-r--r--chromium/ui/accessibility/mojom/typemaps.gni14
-rw-r--r--chromium/ui/accessibility/platform/atk_util_auralinux.h4
-rw-r--r--chromium/ui/accessibility/platform/ax_fragment_root_win.cc8
-rw-r--r--chromium/ui/accessibility/platform/ax_fragment_root_win_unittest.cc30
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_atk_hyperlink.cc17
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_auralinux.cc353
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_auralinux.h3
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_auralinux_unittest.cc10
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_base.cc151
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_base.h48
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_base_unittest.cc304
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_delegate_base.cc14
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_mac.h1
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_mac.mm7
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_textchildprovider_win_unittest.cc4
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.cc30
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_textrangeprovider_win_unittest.cc142
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_unittest.cc6
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_unittest.h9
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_win.cc167
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_win.h6
-rw-r--r--chromium/ui/accessibility/platform/ax_platform_node_win_unittest.cc549
-rw-r--r--chromium/ui/accessibility/platform/ax_system_caret_win.cc3
-rw-r--r--chromium/ui/accessibility/platform/ax_unique_id.cc1
-rw-r--r--chromium/ui/accessibility/tree_generator.cc69
-rw-r--r--chromium/ui/accessibility/tree_generator.h23
-rw-r--r--chromium/ui/android/BUILD.gn72
-rw-r--r--chromium/ui/android/delegated_frame_host_android.cc12
-rw-r--r--chromium/ui/android/dummy_screen_android.cc6
-rw-r--r--chromium/ui/android/edge_effect_base.cc2
-rw-r--r--chromium/ui/android/junit/src/org/chromium/ui/modelutil/ListModelBaseTest.java8
-rw-r--r--chromium/ui/android/junit/src/org/chromium/ui/modelutil/PropertyListModelTest.java2
-rw-r--r--chromium/ui/android/junit/src/org/chromium/ui/modelutil/SimpleRecyclerViewAdapterTest.java145
-rw-r--r--chromium/ui/android/junit/src/org/chromium/ui/resources/dynamics/ViewResourceAdapterTest.java8
-rw-r--r--chromium/ui/android/overscroll_refresh.cc3
-rw-r--r--chromium/ui/android/view_android.cc44
-rw-r--r--chromium/ui/android/view_android.h7
-rw-r--r--chromium/ui/android/window_android.cc21
-rw-r--r--chromium/ui/android/window_android.h10
-rw-r--r--chromium/ui/android/window_android_compositor.h18
-rw-r--r--chromium/ui/android/window_android_observer.h2
-rw-r--r--chromium/ui/aura/BUILD.gn4
-rw-r--r--chromium/ui/aura/demo/demo_main.cc10
-rw-r--r--chromium/ui/aura/env.cc1
-rw-r--r--chromium/ui/aura/gestures/gesture_recognizer_unittest.cc543
-rw-r--r--chromium/ui/aura/null_window_targeter.cc2
-rw-r--r--chromium/ui/aura/screen_ozone.cc32
-rw-r--r--chromium/ui/aura/screen_ozone.h7
-rw-r--r--chromium/ui/aura/test/ui_controls_factory_ozone.cc4
-rw-r--r--chromium/ui/aura/window_event_dispatcher.cc32
-rw-r--r--chromium/ui/aura/window_event_dispatcher_unittest.cc306
-rw-r--r--chromium/ui/aura/window_observer.cc2
-rw-r--r--chromium/ui/aura/window_occlusion_change_builder.cc2
-rw-r--r--chromium/ui/aura/window_tree_host.cc2
-rw-r--r--chromium/ui/aura/window_tree_host_platform.cc2
-rw-r--r--chromium/ui/aura/window_unittest.cc78
-rw-r--r--chromium/ui/base/BUILD.gn62
-rw-r--r--chromium/ui/base/accelerators/accelerator.cc3
-rw-r--r--chromium/ui/base/accelerators/accelerator_manager.cc3
-rw-r--r--chromium/ui/base/accelerators/mojom/BUILD.gn17
-rw-r--r--chromium/ui/base/accelerators/mojom/OWNERS4
-rw-r--r--chromium/ui/base/accelerators/mojom/accelerator.typemap14
-rw-r--r--chromium/ui/base/accelerators/mojom/typemaps.gni5
-rw-r--r--chromium/ui/base/accelerators/test_accelerator_target.h1
-rw-r--r--chromium/ui/base/clipboard/BUILD.gn1
-rw-r--r--chromium/ui/base/clipboard/clipboard.cc3
-rw-r--r--chromium/ui/base/clipboard/clipboard.h3
-rw-r--r--chromium/ui/base/clipboard/clipboard_android.cc41
-rw-r--r--chromium/ui/base/clipboard/clipboard_android.h3
-rw-r--r--chromium/ui/base/clipboard/clipboard_aura.cc15
-rw-r--r--chromium/ui/base/clipboard/clipboard_aura.h3
-rw-r--r--chromium/ui/base/clipboard/clipboard_format_type_win.cc2
-rw-r--r--chromium/ui/base/clipboard/clipboard_mac.h3
-rw-r--r--chromium/ui/base/clipboard/clipboard_mac.mm9
-rw-r--r--chromium/ui/base/clipboard/clipboard_ozone.cc7
-rw-r--r--chromium/ui/base/clipboard/clipboard_ozone.h3
-rw-r--r--chromium/ui/base/clipboard/clipboard_test_template.h3
-rw-r--r--chromium/ui/base/clipboard/clipboard_util_win.h1
-rw-r--r--chromium/ui/base/clipboard/clipboard_win.cc15
-rw-r--r--chromium/ui/base/clipboard/clipboard_win.h3
-rw-r--r--chromium/ui/base/clipboard/clipboard_x11.cc12
-rw-r--r--chromium/ui/base/clipboard/clipboard_x11.h3
-rw-r--r--chromium/ui/base/clipboard/scoped_clipboard_writer.cc8
-rw-r--r--chromium/ui/base/cocoa/command_dispatcher.mm70
-rw-r--r--chromium/ui/base/cocoa/defaults_utils.mm1
-rw-r--r--chromium/ui/base/cocoa/find_pasteboard.mm2
-rw-r--r--chromium/ui/base/cocoa/menu_controller.mm14
-rw-r--r--chromium/ui/base/cocoa/menu_controller_unittest.mm11
-rw-r--r--chromium/ui/base/cocoa/permissions_utils.h21
-rw-r--r--chromium/ui/base/cocoa/permissions_utils.mm52
-rw-r--r--chromium/ui/base/cocoa/secure_password_input.mm2
-rw-r--r--chromium/ui/base/cocoa/text_services_context_menu.cc89
-rw-r--r--chromium/ui/base/cocoa/tool_tip_base_view.mm3
-rw-r--r--chromium/ui/base/cocoa/tracking_area.h8
-rw-r--r--chromium/ui/base/cocoa/tracking_area.mm22
-rw-r--r--chromium/ui/base/cocoa/tracking_area_unittest.mm13
-rw-r--r--chromium/ui/base/cocoa/underlay_opengl_hosting_window.mm2
-rw-r--r--chromium/ui/base/cursor/BUILD.gn2
-rw-r--r--chromium/ui/base/cursor/cursor.cc2
-rw-r--r--chromium/ui/base/cursor/cursor.h2
-rw-r--r--chromium/ui/base/cursor/cursor_loader.h2
-rw-r--r--chromium/ui/base/cursor/cursor_loader_ozone.cc2
-rw-r--r--chromium/ui/base/cursor/cursor_loader_ozone.h2
-rw-r--r--chromium/ui/base/cursor/cursor_loader_win.cc38
-rw-r--r--chromium/ui/base/cursor/cursor_loader_x11.cc9
-rw-r--r--chromium/ui/base/cursor/cursor_loader_x11.h2
-rw-r--r--chromium/ui/base/cursor/cursor_lookup.cc2
-rw-r--r--chromium/ui/base/cursor/cursor_unittest.cc3
-rw-r--r--chromium/ui/base/cursor/cursor_util.cc3
-rw-r--r--chromium/ui/base/cursor/cursor_util_unittest.cc1
-rw-r--r--chromium/ui/base/cursor/cursors_aura.cc45
-rw-r--r--chromium/ui/base/cursor/cursors_aura.h2
-rw-r--r--chromium/ui/base/cursor/image_cursors.cc5
-rw-r--r--chromium/ui/base/cursor/mojom/BUILD.gn63
-rw-r--r--chromium/ui/base/cursor/mojom/DEPS3
-rw-r--r--chromium/ui/base/cursor/mojom/OWNERS4
-rw-r--r--chromium/ui/base/cursor/mojom/cursor.mojom (renamed from chromium/ui/base/mojom/cursor.mojom)3
-rw-r--r--chromium/ui/base/cursor/mojom/cursor_mojom_traits.cc (renamed from chromium/ui/base/mojom/cursor_mojom_traits.cc)16
-rw-r--r--chromium/ui/base/cursor/mojom/cursor_mojom_traits.h (renamed from chromium/ui/base/mojom/cursor_mojom_traits.h)20
-rw-r--r--chromium/ui/base/cursor/mojom/cursor_mojom_traits_unittest.cc (renamed from chromium/ui/base/mojom/cursor_mojom_traits_unittest.cc)6
-rw-r--r--chromium/ui/base/cursor/mojom/cursor_type.mojom (renamed from chromium/ui/base/mojom/cursor_type.mojom)0
-rw-r--r--chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc4
-rw-r--r--chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h2
-rw-r--r--chromium/ui/base/default_theme_provider.cc52
-rw-r--r--chromium/ui/base/default_theme_provider.h39
-rw-r--r--chromium/ui/base/dragdrop/DEPS1
-rw-r--r--chromium/ui/base/dragdrop/cocoa_dnd_util.mm2
-rw-r--r--chromium/ui/base/dragdrop/download_file_info.cc18
-rw-r--r--chromium/ui/base/dragdrop/download_file_info.h28
-rw-r--r--chromium/ui/base/dragdrop/download_file_interface.h7
-rw-r--r--chromium/ui/base/dragdrop/drag_drop_types_mac.mm5
-rw-r--r--chromium/ui/base/dragdrop/drag_drop_types_win.cc4
-rw-r--r--chromium/ui/base/dragdrop/drag_source_win.cc7
-rw-r--r--chromium/ui/base/dragdrop/drag_source_win.h2
-rw-r--r--chromium/ui/base/dragdrop/drop_target_win.cc2
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data.cc13
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data.h100
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider.h113
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_aura.cc24
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_aura.h12
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_aurax11.h47
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_builder_mac.h4
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_builder_mac.mm2
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_factory.cc23
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_factory.h4
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_factory_ozone.cc18
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_factory_ozone.h35
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_mac.h12
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_mac.mm39
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_win.cc36
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_win.h15
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_x11.cc (renamed from chromium/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc)25
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_x11.h45
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_provider_x11_unittest.cc (renamed from chromium/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc)48
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_unittest.cc46
-rw-r--r--chromium/ui/base/dragdrop/os_exchange_data_win_unittest.cc35
-rw-r--r--chromium/ui/base/emoji/emoji_panel_helper_chromeos.cc2
-rw-r--r--chromium/ui/base/idle/BUILD.gn5
-rw-r--r--chromium/ui/base/idle/idle_android.cc2
-rw-r--r--chromium/ui/base/idle/idle_fuchsia.cc2
-rw-r--r--chromium/ui/base/idle/scoped_set_idle_state.h1
-rw-r--r--chromium/ui/base/ime/BUILD.gn3
-rw-r--r--chromium/ui/base/ime/candidate_window.cc7
-rw-r--r--chromium/ui/base/ime/candidate_window.h10
-rw-r--r--chromium/ui/base/ime/candidate_window_unittest.cc1
-rw-r--r--chromium/ui/base/ime/character_composer.cc2
-rw-r--r--chromium/ui/base/ime/ime_assistive_window_handler_interface.h53
-rw-r--r--chromium/ui/base/ime/ime_bridge.cc13
-rw-r--r--chromium/ui/base/ime/ime_bridge.h12
-rw-r--r--chromium/ui/base/ime/ime_suggestion_window_handler_interface.h43
-rw-r--r--chromium/ui/base/ime/init/input_method_factory.h1
-rw-r--r--chromium/ui/base/ime/init/input_method_initializer.cc4
-rw-r--r--chromium/ui/base/ime/input_method_base.cc2
-rw-r--r--chromium/ui/base/ime/linux/composition_text_util_pango_unittest.cc2
-rw-r--r--chromium/ui/base/ime/linux/text_edit_command_auralinux.cc2
-rw-r--r--chromium/ui/base/ime/mock_ime_input_context_handler.cc1
-rw-r--r--chromium/ui/base/ime/mojom/BUILD.gn30
-rw-r--r--chromium/ui/base/ime/mojom/OWNERS4
-rw-r--r--chromium/ui/base/ime/mojom/ime_types.mojom3
-rw-r--r--chromium/ui/base/ime/mojom/ime_types.typemap26
-rw-r--r--chromium/ui/base/ime/mojom/ime_types_mojom_traits.cc7
-rw-r--r--chromium/ui/base/ime/mojom/typemaps.gni5
-rw-r--r--chromium/ui/base/ime/text_input_type.h14
-rw-r--r--chromium/ui/base/ime/virtual_keyboard_visibility_request.h21
-rw-r--r--chromium/ui/base/ime/win/BUILD.gn2
-rw-r--r--chromium/ui/base/ime/win/mock_tsf_bridge.cc2
-rw-r--r--chromium/ui/base/ime/win/on_screen_keyboard_display_manager_input_pane.cc66
-rw-r--r--chromium/ui/base/ime/win/on_screen_keyboard_display_manager_input_pane.h13
-rw-r--r--chromium/ui/base/ime/win/on_screen_keyboard_display_manager_unittest.cc41
-rw-r--r--chromium/ui/base/ime/win/tsf_input_scope.cc2
-rw-r--r--chromium/ui/base/ime/win/tsf_text_store.cc45
-rw-r--r--chromium/ui/base/ime/win/virtual_keyboard_debounce_timer.cc37
-rw-r--r--chromium/ui/base/ime/win/virtual_keyboard_debounce_timer.h54
-rw-r--r--chromium/ui/base/l10n/formatter.cc2
-rw-r--r--chromium/ui/base/l10n/l10n_font_util.cc2
-rw-r--r--chromium/ui/base/l10n/l10n_util.cc8
-rw-r--r--chromium/ui/base/l10n/l10n_util.h3
-rw-r--r--chromium/ui/base/l10n/l10n_util_android.cc2
-rw-r--r--chromium/ui/base/l10n/l10n_util_mac.mm2
-rw-r--r--chromium/ui/base/l10n/l10n_util_unittest.cc4
-rw-r--r--chromium/ui/base/l10n/time_format.cc3
-rw-r--r--chromium/ui/base/layout.cc2
-rw-r--r--chromium/ui/base/models/image_model.cc97
-rw-r--r--chromium/ui/base/models/image_model.h113
-rw-r--r--chromium/ui/base/models/image_model_unittest.cc95
-rw-r--r--chromium/ui/base/models/list_selection_model.cc2
-rw-r--r--chromium/ui/base/models/menu_model.cc10
-rw-r--r--chromium/ui/base/models/menu_model.h16
-rw-r--r--chromium/ui/base/models/simple_menu_model.cc123
-rw-r--r--chromium/ui/base/models/simple_menu_model.h58
-rw-r--r--chromium/ui/base/models/simple_menu_model_unittest.cc11
-rw-r--r--chromium/ui/base/models/table_model.cc3
-rw-r--r--chromium/ui/base/models/tree_model.cc2
-rw-r--r--chromium/ui/base/mojom/BUILD.gn53
-rw-r--r--chromium/ui/base/mojom/DEPS2
-rw-r--r--chromium/ui/base/mojom/OWNERS2
-rw-r--r--chromium/ui/base/mojom/clipboard_blink.typemap11
-rw-r--r--chromium/ui/base/mojom/cursor.typemap15
-rw-r--r--chromium/ui/base/mojom/typemaps.gni10
-rw-r--r--chromium/ui/base/mojom/ui_base_types.typemap15
-rw-r--r--chromium/ui/base/mojom/window_open_disposition.typemap12
-rw-r--r--chromium/ui/base/page_transition_types.cc5
-rw-r--r--chromium/ui/base/pointer/pointer_device_android.cc2
-rw-r--r--chromium/ui/base/pointer/pointer_device_linux.cc2
-rw-r--r--chromium/ui/base/pointer/pointer_device_win.cc2
-rw-r--r--chromium/ui/base/pointer/touch_editing_controller.h9
-rw-r--r--chromium/ui/base/pointer/touch_ui_controller.cc9
-rw-r--r--chromium/ui/base/resource/data_pack_unittest.cc26
-rw-r--r--chromium/ui/base/resource/resource_bundle.h14
-rw-r--r--chromium/ui/base/resource/resource_bundle_fuchsia.cc1
-rw-r--r--chromium/ui/base/resource/resource_bundle_unittest.cc60
-rw-r--r--chromium/ui/base/resource/resource_bundle_win.cc1
-rw-r--r--chromium/ui/base/resource/resource_data_dll_win.cc2
-rw-r--r--chromium/ui/base/template_expressions.cc27
-rw-r--r--chromium/ui/base/template_expressions.h3
-rw-r--r--chromium/ui/base/template_expressions_unittest.cc49
-rw-r--r--chromium/ui/base/text/bytes_formatting.cc3
-rw-r--r--chromium/ui/base/ui_base_features.cc20
-rw-r--r--chromium/ui/base/ui_base_features.h10
-rw-r--r--chromium/ui/base/ui_base_paths.cc1
-rw-r--r--chromium/ui/base/ui_features.gni2
-rw-r--r--chromium/ui/base/user_activity/user_activity_detector_unittest.cc2
-rw-r--r--chromium/ui/base/webui/i18n_source_stream.cc2
-rw-r--r--chromium/ui/base/webui/jstemplate_builder.cc3
-rw-r--r--chromium/ui/base/win/accessibility_misc_utils.cc2
-rw-r--r--chromium/ui/base/win/hwnd_subclass.cc2
-rw-r--r--chromium/ui/base/win/lock_state.cc1
-rw-r--r--chromium/ui/base/win/scoped_ole_initializer.cc2
-rw-r--r--chromium/ui/base/x/BUILD.gn43
-rw-r--r--chromium/ui/base/x/DEPS2
-rw-r--r--chromium/ui/base/x/OWNERS1
-rw-r--r--chromium/ui/base/x/selection_utils.cc2
-rw-r--r--chromium/ui/base/x/x11_desktop_window_move_client.cc43
-rw-r--r--chromium/ui/base/x/x11_desktop_window_move_client.h (renamed from chromium/ui/views/widget/desktop_aura/x11_desktop_window_move_client.h)37
-rw-r--r--chromium/ui/base/x/x11_drag_drop_client.cc48
-rw-r--r--chromium/ui/base/x/x11_drag_drop_client.h88
-rw-r--r--chromium/ui/base/x/x11_gl_egl_utility.cc47
-rw-r--r--chromium/ui/base/x/x11_gl_egl_utility.h24
-rw-r--r--chromium/ui/base/x/x11_move_loop.h (renamed from chromium/ui/views/widget/desktop_aura/x11_move_loop.h)17
-rw-r--r--chromium/ui/base/x/x11_move_loop_delegate.h (renamed from chromium/ui/views/widget/desktop_aura/x11_move_loop_delegate.h)12
-rw-r--r--chromium/ui/base/x/x11_os_exchange_data_provider.cc25
-rw-r--r--chromium/ui/base/x/x11_os_exchange_data_provider.h21
-rw-r--r--chromium/ui/base/x/x11_pointer_grab.cc2
-rw-r--r--chromium/ui/base/x/x11_util.cc487
-rw-r--r--chromium/ui/base/x/x11_util.h6
-rw-r--r--chromium/ui/base/x/x11_whole_screen_move_loop.cc (renamed from chromium/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc)59
-rw-r--r--chromium/ui/base/x/x11_whole_screen_move_loop.h (renamed from chromium/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h)38
-rw-r--r--chromium/ui/base/x/x11_window.cc21
-rw-r--r--chromium/ui/base/x/x11_window.h3
-rw-r--r--chromium/ui/base/x/x11_workspace_handler.cc46
-rw-r--r--chromium/ui/base/x/x11_workspace_handler.h7
-rw-r--r--chromium/ui/chromeos/BUILD.gn4
-rw-r--r--chromium/ui/color/BUILD.gn15
-rw-r--r--chromium/ui/color/DEPS1
-rw-r--r--chromium/ui/color/color_id.h16
-rw-r--r--chromium/ui/color/color_mixers.h26
-rw-r--r--chromium/ui/color/color_provider_manager.cc2
-rw-r--r--chromium/ui/color/core_default_color_mixer.cc2
-rw-r--r--chromium/ui/color/cros/native_color_mixer.cc15
-rw-r--r--chromium/ui/color/cros/native_color_mixers.cc (renamed from chromium/ui/color/fuchsia/native_color_mixer.cc)8
-rw-r--r--chromium/ui/color/fuchsia/native_color_mixers.cc19
-rw-r--r--chromium/ui/color/linux/native_color_mixer.cc15
-rw-r--r--chromium/ui/color/linux/native_color_mixers.cc19
-rw-r--r--chromium/ui/color/mac/native_color_mixer.cc15
-rw-r--r--chromium/ui/color/mac/native_color_mixers.mm66
-rw-r--r--chromium/ui/color/mac/scoped_current_nsappearance.h28
-rw-r--r--chromium/ui/color/mac/scoped_current_nsappearance.mm23
-rw-r--r--chromium/ui/color/run_all_unittests.cc3
-rw-r--r--chromium/ui/color/ui_color_mixer.cc5
-rw-r--r--chromium/ui/color/win/native_color_mixers.cc (renamed from chromium/ui/color/win/native_color_mixer.cc)11
-rw-r--r--chromium/ui/compositor/BUILD.gn4
-rw-r--r--chromium/ui/compositor/animation_metrics_recorder.cc2
-rw-r--r--chromium/ui/compositor/compositor.cc52
-rw-r--r--chromium/ui/compositor/compositor.h38
-rw-r--r--chromium/ui/compositor/compositor_unittest.cc114
-rw-r--r--chromium/ui/compositor/debug_utils.cc25
-rw-r--r--chromium/ui/compositor/debug_utils.h8
-rw-r--r--chromium/ui/compositor/layer.cc2
-rw-r--r--chromium/ui/compositor/layer_animator.cc2
-rw-r--r--chromium/ui/compositor/layer_type.cc2
-rw-r--r--chromium/ui/compositor/overscroll/DEPS1
-rw-r--r--chromium/ui/compositor/overscroll/scroll_input_handler.cc4
-rw-r--r--chromium/ui/compositor/test/test_compositor_host_ozone.cc2
-rw-r--r--chromium/ui/compositor/throughput_tracker.cc54
-rw-r--r--chromium/ui/compositor/throughput_tracker.h60
-rw-r--r--chromium/ui/compositor/throughput_tracker_host.h37
-rw-r--r--chromium/ui/content_accelerators/accelerator_util.cc2
-rw-r--r--chromium/ui/display/BUILD.gn6
-rw-r--r--chromium/ui/display/display_finder.cc2
-rw-r--r--chromium/ui/display/display_transform.cc1
-rw-r--r--chromium/ui/display/fake/fake_display_snapshot.cc1
-rw-r--r--chromium/ui/display/ios/screen_ios.mm3
-rw-r--r--chromium/ui/display/mac/screen_mac.mm185
-rw-r--r--chromium/ui/display/manager/content_protection_manager.cc2
-rw-r--r--chromium/ui/display/manager/display_change_observer.cc2
-rw-r--r--chromium/ui/display/manager/display_layout_store.cc3
-rw-r--r--chromium/ui/display/manager/display_manager.cc18
-rw-r--r--chromium/ui/display/manager/display_manager.h4
-rw-r--r--chromium/ui/display/manager/display_manager_utilities.cc2
-rw-r--r--chromium/ui/display/manager/display_util.cc3
-rw-r--r--chromium/ui/display/manager/json_converter_unittest.cc10
-rw-r--r--chromium/ui/display/manager/managed_display_info.cc21
-rw-r--r--chromium/ui/display/manager/managed_display_info.h4
-rw-r--r--chromium/ui/display/manager/touch_device_manager.cc46
-rw-r--r--chromium/ui/display/manager/touch_device_manager.h23
-rw-r--r--chromium/ui/display/manager/touch_device_manager_unittest.cc18
-rw-r--r--chromium/ui/display/manager/touch_transform_controller.cc24
-rw-r--r--chromium/ui/display/manager/touch_transform_controller.h3
-rw-r--r--chromium/ui/display/manager/touch_transform_controller_unittest.cc26
-rw-r--r--chromium/ui/display/mojom/BUILD.gn132
-rw-r--r--chromium/ui/display/mojom/OWNERS4
-rw-r--r--chromium/ui/display/mojom/display.typemap24
-rw-r--r--chromium/ui/display/mojom/display_constants.typemap18
-rw-r--r--chromium/ui/display/mojom/display_layout.typemap20
-rw-r--r--chromium/ui/display/mojom/display_mode.typemap17
-rw-r--r--chromium/ui/display/mojom/display_mojom_traits.h18
-rw-r--r--chromium/ui/display/mojom/display_mojom_traits_unittest.cc1
-rw-r--r--chromium/ui/display/mojom/display_rotation_for_blink.typemap12
-rw-r--r--chromium/ui/display/mojom/display_snapshot.typemap17
-rw-r--r--chromium/ui/display/mojom/gamma_ramp_rgb_entry.typemap15
-rw-r--r--chromium/ui/display/mojom/typemaps.gni12
-rw-r--r--chromium/ui/display/screen.cc15
-rw-r--r--chromium/ui/display/screen.h34
-rw-r--r--chromium/ui/display/screen_android.cc2
-rw-r--r--chromium/ui/display/screen_aura.cc2
-rw-r--r--chromium/ui/display/screen_base.cc7
-rw-r--r--chromium/ui/display/screen_base.h3
-rw-r--r--chromium/ui/display/types/display_snapshot.cc1
-rw-r--r--chromium/ui/display/util/display_util.cc43
-rw-r--r--chromium/ui/display/util/display_util_unittest.cc82
-rw-r--r--chromium/ui/display/util/edid_parser.cc55
-rw-r--r--chromium/ui/display/win/base_window_finder_win.cc30
-rw-r--r--chromium/ui/display/win/base_window_finder_win.h46
-rw-r--r--chromium/ui/display/win/color_profile_reader.cc2
-rw-r--r--chromium/ui/display/win/display_info.cc19
-rw-r--r--chromium/ui/display/win/display_info.h11
-rw-r--r--chromium/ui/display/win/local_process_window_finder_win.cc67
-rw-r--r--chromium/ui/display/win/local_process_window_finder_win.h55
-rw-r--r--chromium/ui/display/win/scaling_util.cc2
-rw-r--r--chromium/ui/display/win/scaling_util_unittest.cc2
-rw-r--r--chromium/ui/display/win/screen_win.cc71
-rw-r--r--chromium/ui/display/win/screen_win.h16
-rw-r--r--chromium/ui/display/win/screen_win_unittest.cc47
-rw-r--r--chromium/ui/display/win/topmost_window_finder_win.cc83
-rw-r--r--chromium/ui/display/win/topmost_window_finder_win.h51
-rw-r--r--chromium/ui/events/BUILD.gn24
-rw-r--r--chromium/ui/events/base_event_utils.cc2
-rw-r--r--chromium/ui/events/blink/BUILD.gn43
-rw-r--r--chromium/ui/events/blink/DEPS3
-rw-r--r--chromium/ui/events/blink/blink_event_util.cc818
-rw-r--r--chromium/ui/events/blink/blink_event_util.h40
-rw-r--r--chromium/ui/events/blink/blink_event_util_unittest.cc260
-rw-r--r--chromium/ui/events/blink/blink_features.cc28
-rw-r--r--chromium/ui/events/blink/blink_features.h49
-rw-r--r--chromium/ui/events/blink/compositor_thread_event_queue.cc108
-rw-r--r--chromium/ui/events/blink/compositor_thread_event_queue.h47
-rw-r--r--chromium/ui/events/blink/did_overscroll_params.cc13
-rw-r--r--chromium/ui/events/blink/did_overscroll_params.h2
-rw-r--r--chromium/ui/events/blink/event_with_callback.cc137
-rw-r--r--chromium/ui/events/blink/event_with_callback.h84
-rw-r--r--chromium/ui/events/blink/fling_booster.cc14
-rw-r--r--chromium/ui/events/blink/fling_booster_unittest.cc16
-rw-r--r--chromium/ui/events/blink/input_handler_proxy.cc1298
-rw-r--r--chromium/ui/events/blink/input_handler_proxy.h273
-rw-r--r--chromium/ui/events/blink/input_handler_proxy_client.h57
-rw-r--r--chromium/ui/events/blink/input_handler_proxy_unittest.cc3223
-rw-r--r--chromium/ui/events/blink/input_scroll_elasticity_controller.cc455
-rw-r--r--chromium/ui/events/blink/input_scroll_elasticity_controller.h164
-rw-r--r--chromium/ui/events/blink/input_scroll_elasticity_controller_unittest.cc500
-rw-r--r--chromium/ui/events/blink/momentum_scroll_jank_tracker.cc62
-rw-r--r--chromium/ui/events/blink/momentum_scroll_jank_tracker.h49
-rw-r--r--chromium/ui/events/blink/prediction/empty_filter.cc28
-rw-r--r--chromium/ui/events/blink/prediction/empty_filter.h38
-rw-r--r--chromium/ui/events/blink/prediction/empty_filter_unittests.cc47
-rw-r--r--chromium/ui/events/blink/prediction/empty_predictor.cc43
-rw-r--r--chromium/ui/events/blink/prediction/empty_predictor.h45
-rw-r--r--chromium/ui/events/blink/prediction/filter_factory.cc93
-rw-r--r--chromium/ui/events/blink/prediction/filter_factory.h99
-rw-r--r--chromium/ui/events/blink/prediction/filter_factory_unittests.cc138
-rw-r--r--chromium/ui/events/blink/prediction/input_filter.h36
-rw-r--r--chromium/ui/events/blink/prediction/input_filter_unittest_helpers.cc81
-rw-r--r--chromium/ui/events/blink/prediction/input_filter_unittest_helpers.h37
-rw-r--r--chromium/ui/events/blink/prediction/input_predictor.h84
-rw-r--r--chromium/ui/events/blink/prediction/input_predictor_unittest_helpers.cc67
-rw-r--r--chromium/ui/events/blink/prediction/input_predictor_unittest_helpers.h50
-rw-r--r--chromium/ui/events/blink/prediction/kalman_filter.cc122
-rw-r--r--chromium/ui/events/blink/prediction/kalman_filter.h84
-rw-r--r--chromium/ui/events/blink/prediction/kalman_predictor.cc139
-rw-r--r--chromium/ui/events/blink/prediction/kalman_predictor.h82
-rw-r--r--chromium/ui/events/blink/prediction/kalman_predictor_unittest.cc204
-rw-r--r--chromium/ui/events/blink/prediction/least_squares_predictor.cc112
-rw-r--r--chromium/ui/events/blink/prediction/least_squares_predictor.h57
-rw-r--r--chromium/ui/events/blink/prediction/least_squares_predictor_unittest.cc106
-rw-r--r--chromium/ui/events/blink/prediction/linear_predictor.cc127
-rw-r--r--chromium/ui/events/blink/prediction/linear_predictor.h78
-rw-r--r--chromium/ui/events/blink/prediction/linear_predictor_unittest.cc150
-rw-r--r--chromium/ui/events/blink/prediction/linear_resampling.cc100
-rw-r--r--chromium/ui/events/blink/prediction/linear_resampling.h58
-rw-r--r--chromium/ui/events/blink/prediction/linear_resampling_unittest.cc126
-rw-r--r--chromium/ui/events/blink/prediction/one_euro_filter.cc53
-rw-r--r--chromium/ui/events/blink/prediction/one_euro_filter.h50
-rw-r--r--chromium/ui/events/blink/prediction/one_euro_filter_unittests.cc46
-rw-r--r--chromium/ui/events/blink/prediction/prediction_metrics_handler.cc187
-rw-r--r--chromium/ui/events/blink/prediction/prediction_metrics_handler.h109
-rw-r--r--chromium/ui/events/blink/prediction/prediction_metrics_handler_unittest.cc231
-rw-r--r--chromium/ui/events/blink/prediction/predictor_factory.cc80
-rw-r--r--chromium/ui/events/blink/prediction/predictor_factory.h56
-rw-r--r--chromium/ui/events/blink/scroll_predictor.cc200
-rw-r--r--chromium/ui/events/blink/scroll_predictor.h90
-rw-r--r--chromium/ui/events/blink/scroll_predictor_unittest.cc510
-rw-r--r--chromium/ui/events/blink/synchronous_input_handler_proxy.h62
-rw-r--r--chromium/ui/events/blink/web_input_event.cc72
-rw-r--r--chromium/ui/events/blink/web_input_event_builders_win.cc28
-rw-r--r--chromium/ui/events/blink/web_input_event_traits.cc55
-rw-r--r--chromium/ui/events/blink/web_input_event_traits_unittest.cc13
-rw-r--r--chromium/ui/events/blink/web_input_event_unittest.cc38
-rw-r--r--chromium/ui/events/cocoa/events_mac.mm7
-rw-r--r--chromium/ui/events/devices/device_data_manager.cc2
-rw-r--r--chromium/ui/events/devices/x11/BUILD.gn2
-rw-r--r--chromium/ui/events/devices/x11/device_data_manager_x11.cc10
-rw-r--r--chromium/ui/events/devices/x11/touch_factory_x11.cc13
-rw-r--r--chromium/ui/events/devices/x11/touch_factory_x11.h2
-rw-r--r--chromium/ui/events/event.cc49
-rw-r--r--chromium/ui/events/event.h29
-rw-r--r--chromium/ui/events/event_constants.h11
-rw-r--r--chromium/ui/events/event_dispatcher_unittest.cc2
-rw-r--r--chromium/ui/events/event_rewriter.cc2
-rw-r--r--chromium/ui/events/event_rewriter_unittest.cc2
-rw-r--r--chromium/ui/events/event_source.cc1
-rw-r--r--chromium/ui/events/event_target.cc3
-rw-r--r--chromium/ui/events/event_unittest.cc43
-rw-r--r--chromium/ui/events/event_utils.cc3
-rw-r--r--chromium/ui/events/events_stub.cc6
-rw-r--r--chromium/ui/events/fuchsia/input_event_dispatcher.cc2
-rw-r--r--chromium/ui/events/gesture_detection/filtered_gesture_provider.cc3
-rw-r--r--chromium/ui/events/gesture_detection/gesture_event_data.cc15
-rw-r--r--chromium/ui/events/gesture_detection/gesture_event_data_packet.cc3
-rw-r--r--chromium/ui/events/gesture_detection/gesture_provider_unittest.cc2
-rw-r--r--chromium/ui/events/gesture_detection/gesture_touch_uma_histogram.cc1
-rw-r--r--chromium/ui/events/gesture_detection/motion_event.cc2
-rw-r--r--chromium/ui/events/gesture_detection/motion_event_buffer_unittest.cc1
-rw-r--r--chromium/ui/events/gesture_detection/motion_event_generic.cc2
-rw-r--r--chromium/ui/events/gesture_detection/scale_gesture_detector.cc2
-rw-r--r--chromium/ui/events/gesture_detection/touch_disposition_gesture_filter.cc3
-rw-r--r--chromium/ui/events/gesture_detection/velocity_tracker.cc3
-rw-r--r--chromium/ui/events/gesture_detection/velocity_tracker_state.cc2
-rw-r--r--chromium/ui/events/gesture_detection/velocity_tracker_unittest.cc2
-rw-r--r--chromium/ui/events/gesture_event_details.cc2
-rw-r--r--chromium/ui/events/gesture_event_details.h3
-rw-r--r--chromium/ui/events/gestures/blink/web_gesture_curve_impl.cc10
-rw-r--r--chromium/ui/events/gestures/blink/web_gesture_curve_impl.h9
-rw-r--r--chromium/ui/events/gestures/fling_curve.cc2
-rw-r--r--chromium/ui/events/gestures/gesture_provider_aura.cc4
-rw-r--r--chromium/ui/events/gestures/gesture_provider_aura_unittest.cc168
-rw-r--r--chromium/ui/events/gestures/gesture_recognizer_impl.cc4
-rw-r--r--chromium/ui/events/gestures/motion_event_aura.cc17
-rw-r--r--chromium/ui/events/gestures/motion_event_aura_unittest.cc27
-rw-r--r--chromium/ui/events/gestures/physics_based_fling_curve.cc26
-rw-r--r--chromium/ui/events/gestures/physics_based_fling_curve.h22
-rw-r--r--chromium/ui/events/gestures/physics_based_fling_curve_unittest.cc16
-rw-r--r--chromium/ui/events/ipc/BUILD.gn1
-rw-r--r--chromium/ui/events/ipc/ui_events_param_traits_macros.h2
-rw-r--r--chromium/ui/events/keycodes/BUILD.gn7
-rw-r--r--chromium/ui/events/keycodes/dom/dom_code_data.inc5
-rw-r--r--chromium/ui/events/keycodes/dom/dom_keyboard_layout.cc1
-rw-r--r--chromium/ui/events/keycodes/dom/dom_keyboard_layout_manager.cc1
-rw-r--r--chromium/ui/events/keycodes/dom/dom_keyboard_layout_map_base.cc2
-rw-r--r--chromium/ui/events/keycodes/dom/dom_keyboard_layout_map_ozone.cc1
-rw-r--r--chromium/ui/events/keycodes/dom/dom_keyboard_layout_map_unittest.cc2
-rw-r--r--chromium/ui/events/keycodes/dom/keycode_converter_unittest.cc8
-rw-r--r--chromium/ui/events/keycodes/dom_us_layout_data.h7
-rw-r--r--chromium/ui/events/keycodes/keyboard_code_conversion_mac.mm2
-rw-r--r--chromium/ui/events/keycodes/keyboard_code_conversion_x.cc4
-rw-r--r--chromium/ui/events/keycodes/platform_key_map_win.cc2
-rw-r--r--chromium/ui/events/keycodes/xkb_keysym.h2
-rw-r--r--chromium/ui/events/mobile_scroller.cc2
-rw-r--r--chromium/ui/events/mojom/BUILD.gn60
-rw-r--r--chromium/ui/events/mojom/OWNERS4
-rw-r--r--chromium/ui/events/mojom/blink_typemaps.gni5
-rw-r--r--chromium/ui/events/mojom/event.mojom2
-rw-r--r--chromium/ui/events/mojom/event.typemap29
-rw-r--r--chromium/ui/events/mojom/event_constants.mojom11
-rw-r--r--chromium/ui/events/mojom/event_mojom_traits.cc1
-rw-r--r--chromium/ui/events/mojom/event_mojom_traits.h45
-rw-r--r--chromium/ui/events/mojom/mojom_traits_unittest.cc31
-rw-r--r--chromium/ui/events/mojom/scroll_granularity.typemap9
-rw-r--r--chromium/ui/events/mojom/typemaps.gni8
-rw-r--r--chromium/ui/events/null_event_targeter.cc2
-rw-r--r--chromium/ui/events/ozone/evdev/device_event_dispatcher_evdev.cc2
-rw-r--r--chromium/ui/events/ozone/evdev/device_event_dispatcher_evdev.h2
-rw-r--r--chromium/ui/events/ozone/evdev/event_converter_evdev_impl.cc14
-rw-r--r--chromium/ui/events/ozone/evdev/event_converter_evdev_impl.h5
-rw-r--r--chromium/ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc16
-rw-r--r--chromium/ui/events/ozone/evdev/event_factory_evdev.cc17
-rw-r--r--chromium/ui/events/ozone/evdev/input_device_factory_evdev.cc8
-rw-r--r--chromium/ui/events/ozone/evdev/input_injector_evdev.cc12
-rw-r--r--chromium/ui/events/ozone/evdev/keyboard_evdev.cc9
-rw-r--r--chromium/ui/events/ozone/evdev/keyboard_evdev.h6
-rw-r--r--chromium/ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc9
-rw-r--r--chromium/ui/events/ozone/evdev/mouse_button_map_evdev.cc1
-rw-r--r--chromium/ui/events/ozone/evdev/stylus_button_event_converter_evdev.cc7
-rw-r--r--chromium/ui/events/ozone/evdev/tablet_event_converter_evdev.cc4
-rw-r--r--chromium/ui/events/ozone/evdev/tablet_event_converter_evdev_unittest.cc9
-rw-r--r--chromium/ui/events/ozone/evdev/touch_evdev_debug_buffer.cc1
-rw-r--r--chromium/ui/events/ozone/evdev/touch_evdev_types.h3
-rw-r--r--chromium/ui/events/ozone/evdev/touch_event_converter_evdev.cc15
-rw-r--r--chromium/ui/events/ozone/evdev/touch_event_converter_evdev.h4
-rw-r--r--chromium/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc58
-rw-r--r--chromium/ui/events/ozone/evdev/touch_filter/edge_touch_filter.cc1
-rw-r--r--chromium/ui/events/ozone/evdev/touch_filter/heuristic_stylus_palm_detection_filter.h1
-rw-r--r--chromium/ui/events/ozone/evdev/touch_filter/heuristic_stylus_palm_detection_filter_unittest.cc1
-rw-r--r--chromium/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.cc5
-rw-r--r--chromium/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_unittest.cc4
-rw-r--r--chromium/ui/events/ozone/evdev/touch_filter/open_palm_detection_filter.h1
-rw-r--r--chromium/ui/events/ozone/evdev/touch_filter/open_palm_detection_filter_unittest.cc1
-rw-r--r--chromium/ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory.cc24
-rw-r--r--chromium/ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory.h8
-rw-r--r--chromium/ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory_unittest.cc26
-rw-r--r--chromium/ui/events/ozone/evdev/touch_filter/palm_model/onedevice_train_palm_detection_filter_model.cc1
-rw-r--r--chromium/ui/events/ozone/evdev/touch_filter/palm_model/onedevice_train_palm_detection_filter_model.h1
-rw-r--r--chromium/ui/events/ozone/features.cc6
-rw-r--r--chromium/ui/events/ozone/features.h7
-rw-r--r--chromium/ui/events/ozone/keyboard/event_auto_repeat_handler.cc14
-rw-r--r--chromium/ui/events/ozone/keyboard/event_auto_repeat_handler.h5
-rw-r--r--chromium/ui/events/ozone/layout/keyboard_layout_engine_manager.cc2
-rw-r--r--chromium/ui/events/ozone/layout/scoped_keyboard_layout_engine.cc1
-rw-r--r--chromium/ui/events/platform/x11/BUILD.gn2
-rw-r--r--chromium/ui/events/platform/x11/x11_event_source.cc102
-rw-r--r--chromium/ui/events/platform/x11/x11_event_source.h23
-rw-r--r--chromium/ui/events/platform/x11/x11_hotplug_event_handler.cc2
-rw-r--r--chromium/ui/events/pointer_details.cc4
-rw-r--r--chromium/ui/events/pointer_details.h2
-rw-r--r--chromium/ui/events/types/BUILD.gn1
-rw-r--r--chromium/ui/events/types/scroll_input_type.h20
-rw-r--r--chromium/ui/events/win/events_win.cc3
-rw-r--r--chromium/ui/events/win/events_win_utils.cc9
-rw-r--r--chromium/ui/events/x/BUILD.gn2
-rw-r--r--chromium/ui/events/x/events_x_utils.cc12
-rw-r--r--chromium/ui/events/x/keyboard_hook_x11.cc2
-rw-r--r--chromium/ui/events/x/x11_event_translation.cc4
-rw-r--r--chromium/ui/events/x/x11_event_translation_unittest.cc54
-rw-r--r--chromium/ui/file_manager/file_manager/foreground/elements/BUILD.gn5
-rw-r--r--chromium/ui/file_manager/file_manager/foreground/js/BUILD.gn10
-rw-r--r--chromium/ui/file_manager/file_manager/foreground/js/ui/BUILD.gn11
-rw-r--r--chromium/ui/gfx/BUILD.gn3
-rw-r--r--chromium/ui/gfx/android/java_bitmap.cc18
-rw-r--r--chromium/ui/gfx/android/java_bitmap.h11
-rw-r--r--chromium/ui/gfx/animation/animation_settings_provider_linux.cc2
-rw-r--r--chromium/ui/gfx/animation/multi_animation.cc3
-rw-r--r--chromium/ui/gfx/animation/tween.cc3
-rw-r--r--chromium/ui/gfx/bidi_line_iterator.cc6
-rw-r--r--chromium/ui/gfx/blit.cc2
-rw-r--r--chromium/ui/gfx/buffer_format_util.cc3
-rw-r--r--chromium/ui/gfx/canvas.cc36
-rw-r--r--chromium/ui/gfx/canvas.h11
-rw-r--r--chromium/ui/gfx/codec/jpeg_codec.cc2
-rw-r--r--chromium/ui/gfx/color_analysis.cc3
-rw-r--r--chromium/ui/gfx/color_analysis.h1
-rw-r--r--chromium/ui/gfx/color_space.cc1
-rw-r--r--chromium/ui/gfx/color_space.h3
-rw-r--r--chromium/ui/gfx/color_space_unittest.cc1
-rw-r--r--chromium/ui/gfx/color_utils.cc3
-rw-r--r--chromium/ui/gfx/font_list_impl.cc2
-rw-r--r--chromium/ui/gfx/font_render_params.cc2
-rw-r--r--chromium/ui/gfx/font_render_params.h4
-rw-r--r--chromium/ui/gfx/font_render_params_linux_unittest.cc3
-rw-r--r--chromium/ui/gfx/font_render_params_mac.cc6
-rw-r--r--chromium/ui/gfx/font_render_params_skia.cc2
-rw-r--r--chromium/ui/gfx/gdi_util.cc1
-rw-r--r--chromium/ui/gfx/geometry/box_f.cc2
-rw-r--r--chromium/ui/gfx/geometry/cubic_bezier.cc2
-rw-r--r--chromium/ui/gfx/geometry/matrix3_f.cc2
-rw-r--r--chromium/ui/gfx/geometry/mojom/BUILD.gn68
-rw-r--r--chromium/ui/gfx/geometry/mojom/geometry.typemap40
-rw-r--r--chromium/ui/gfx/geometry/rect.cc2
-rw-r--r--chromium/ui/gfx/geometry/rect_conversions.cc2
-rw-r--r--chromium/ui/gfx/geometry/rect_f.cc2
-rw-r--r--chromium/ui/gfx/gpu_fence_handle.cc2
-rw-r--r--chromium/ui/gfx/harfbuzz_font_skia.cc2
-rw-r--r--chromium/ui/gfx/icc_profile.cc1
-rw-r--r--chromium/ui/gfx/icc_profile_unittest.cc1
-rw-r--r--chromium/ui/gfx/icon_util.cc14
-rw-r--r--chromium/ui/gfx/image/canvas_image_source.cc2
-rw-r--r--chromium/ui/gfx/image/image.cc3
-rw-r--r--chromium/ui/gfx/image/image_ios_unittest.mm1
-rw-r--r--chromium/ui/gfx/image/image_mac_unittest.mm1
-rw-r--r--chromium/ui/gfx/image/image_skia.cc2
-rw-r--r--chromium/ui/gfx/image/image_skia_operations.cc3
-rw-r--r--chromium/ui/gfx/image/image_skia_rep_default.cc6
-rw-r--r--chromium/ui/gfx/image/image_skia_rep_ios.cc4
-rw-r--r--chromium/ui/gfx/image/image_skia_unittest.cc2
-rw-r--r--chromium/ui/gfx/image/image_skia_util_ios.mm1
-rw-r--r--chromium/ui/gfx/image/image_util_ios.mm1
-rw-r--r--chromium/ui/gfx/image/mojom/BUILD.gn19
-rw-r--r--chromium/ui/gfx/image/mojom/image.typemap18
-rw-r--r--chromium/ui/gfx/image/mojom/image_skia_mojom_traits.cc2
-rw-r--r--chromium/ui/gfx/interpolated_transform.cc3
-rw-r--r--chromium/ui/gfx/ios/NSString+CrStringDrawing.mm4
-rw-r--r--chromium/ui/gfx/linux/BUILD.gn1
-rw-r--r--chromium/ui/gfx/linux/client_native_pixmap_dmabuf.cc12
-rw-r--r--chromium/ui/gfx/linux/drm_util_linux.cc2
-rw-r--r--chromium/ui/gfx/linux/drm_util_linux.h2
-rw-r--r--chromium/ui/gfx/linux/gbm_util.cc2
-rw-r--r--chromium/ui/gfx/linux/gbm_wrapper.cc1
-rw-r--r--chromium/ui/gfx/mojom/BUILD.gn214
-rw-r--r--chromium/ui/gfx/mojom/accelerated_widget.typemap11
-rw-r--r--chromium/ui/gfx/mojom/ca_layer_params.typemap17
-rw-r--r--chromium/ui/gfx/mojom/ca_layer_params_mojom_traits.cc2
-rw-r--r--chromium/ui/gfx/mojom/color_space.typemap9
-rw-r--r--chromium/ui/gfx/mojom/display_color_spaces.typemap10
-rw-r--r--chromium/ui/gfx/mojom/font_render_params.typemap14
-rw-r--r--chromium/ui/gfx/mojom/gpu_fence_handle.typemap14
-rw-r--r--chromium/ui/gfx/mojom/gpu_fence_handle_for_blink.typemap12
-rw-r--r--chromium/ui/gfx/mojom/gpu_fence_handle_mojom_traits.h9
-rw-r--r--chromium/ui/gfx/mojom/overlay_transform.typemap11
-rw-r--r--chromium/ui/gfx/mojom/presentation_feedback.typemap8
-rw-r--r--chromium/ui/gfx/mojom/rrect_f.typemap11
-rw-r--r--chromium/ui/gfx/mojom/selection_bound.typemap11
-rw-r--r--chromium/ui/gfx/mojom/swap_result.typemap8
-rw-r--r--chromium/ui/gfx/mojom/swap_timings.typemap8
-rw-r--r--chromium/ui/gfx/mojom/transform.typemap8
-rw-r--r--chromium/ui/gfx/native_pixmap_handle.cc1
-rw-r--r--chromium/ui/gfx/overlay_transform_utils.cc1
-rw-r--r--chromium/ui/gfx/paint_vector_icon.cc66
-rw-r--r--chromium/ui/gfx/path_win_unittest.cc1
-rw-r--r--chromium/ui/gfx/platform_font_skia_unittest.cc2
-rw-r--r--chromium/ui/gfx/range/mojom/BUILD.gn26
-rw-r--r--chromium/ui/gfx/range/mojom/range.typemap20
-rw-r--r--chromium/ui/gfx/range/range.cc1
-rw-r--r--chromium/ui/gfx/range/range_mac.mm2
-rw-r--r--chromium/ui/gfx/render_text.cc68
-rw-r--r--chromium/ui/gfx/render_text.h41
-rw-r--r--chromium/ui/gfx/render_text_harfbuzz.cc23
-rw-r--r--chromium/ui/gfx/render_text_harfbuzz.h5
-rw-r--r--chromium/ui/gfx/render_text_test_api.h3
-rw-r--r--chromium/ui/gfx/render_text_unittest.cc80
-rw-r--r--chromium/ui/gfx/rrect_f.cc1
-rw-r--r--chromium/ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm2
-rw-r--r--chromium/ui/gfx/scoped_ui_graphics_push_context_ios.mm2
-rw-r--r--chromium/ui/gfx/selection_model.cc40
-rw-r--r--chromium/ui/gfx/selection_model.h18
-rw-r--r--chromium/ui/gfx/selection_model_unittest.cc90
-rw-r--r--chromium/ui/gfx/sequential_id_generator.cc2
-rw-r--r--chromium/ui/gfx/sequential_id_generator_unittest.cc1
-rw-r--r--chromium/ui/gfx/skbitmap_operations.cc2
-rw-r--r--chromium/ui/gfx/skia_color_space_util.cc1
-rw-r--r--chromium/ui/gfx/text_elider.cc2
-rw-r--r--chromium/ui/gfx/text_utils.cc1
-rw-r--r--chromium/ui/gfx/text_utils_unittest.cc1
-rw-r--r--chromium/ui/gfx/transform.cc2
-rw-r--r--chromium/ui/gfx/transform_unittest.cc1
-rw-r--r--chromium/ui/gfx/transform_util.cc2
-rw-r--r--chromium/ui/gfx/typemaps.gni22
-rw-r--r--chromium/ui/gfx/utf16_indexing.cc2
-rw-r--r--chromium/ui/gfx/vector_icon_types.h5
-rw-r--r--chromium/ui/gfx/win/direct_write.cc4
-rw-r--r--chromium/ui/gfx/win/hwnd_util.cc1
-rw-r--r--chromium/ui/gfx/win/physical_size.cc2
-rw-r--r--chromium/ui/gfx/win/text_analysis_source.cc2
-rw-r--r--chromium/ui/gfx/win/window_impl.cc13
-rw-r--r--chromium/ui/gfx/x/.style.yapf2
-rw-r--r--chromium/ui/gfx/x/BUILD.gn105
-rw-r--r--chromium/ui/gfx/x/connection.cc32
-rw-r--r--chromium/ui/gfx/x/connection.h31
-rw-r--r--chromium/ui/gfx/x/gen_xproto.py1028
-rw-r--r--chromium/ui/gfx/x/request_queue.cc29
-rw-r--r--chromium/ui/gfx/x/request_queue.h51
-rw-r--r--chromium/ui/gfx/x/x11.h13
-rw-r--r--chromium/ui/gfx/x/x11_atom_cache.cc33
-rw-r--r--chromium/ui/gfx/x/x11_atom_cache.h6
-rw-r--r--chromium/ui/gfx/x/x11_connection.cc17
-rw-r--r--chromium/ui/gfx/x/x11_connection.h18
-rw-r--r--chromium/ui/gfx/x/x11_error_tracker.cc2
-rw-r--r--chromium/ui/gfx/x/x11_switches.cc3
-rw-r--r--chromium/ui/gfx/x/x11_switches.h9
-rw-r--r--chromium/ui/gfx/x/x11_types.cc24
-rw-r--r--chromium/ui/gfx/x/x11_types.h13
-rw-r--r--chromium/ui/gfx/x/xproto_internal.h161
-rw-r--r--chromium/ui/gfx/x/xproto_types.h209
-rw-r--r--chromium/ui/gfx/x/xproto_util.cc59
-rw-r--r--chromium/ui/gfx/x/xproto_util.h19
-rw-r--r--chromium/ui/gl/BUILD.gn30
-rw-r--r--chromium/ui/gl/android/android_surface_control_compat.cc36
-rw-r--r--chromium/ui/gl/android/android_surface_control_compat.h4
-rw-r--r--chromium/ui/gl/android/scoped_java_surface.cc2
-rw-r--r--chromium/ui/gl/android/surface_texture.cc2
-rw-r--r--chromium/ui/gl/direct_composition_child_surface_win.cc58
-rw-r--r--chromium/ui/gl/direct_composition_child_surface_win.h10
-rw-r--r--chromium/ui/gl/direct_composition_surface_win.cc83
-rw-r--r--chromium/ui/gl/direct_composition_surface_win.h18
-rw-r--r--chromium/ui/gl/direct_composition_surface_win_unittest.cc101
-rw-r--r--chromium/ui/gl/dual_gpu_state_mac.cc1
-rw-r--r--chromium/ui/gl/features.gni8
-rwxr-xr-xchromium/ui/gl/generate_bindings.py16
-rw-r--r--chromium/ui/gl/gl_bindings.cc4
-rw-r--r--chromium/ui/gl/gl_bindings_api_autogen_gl.h7
-rw-r--r--chromium/ui/gl/gl_bindings_autogen_gl.cc92
-rw-r--r--chromium/ui/gl/gl_bindings_autogen_gl.h28
-rw-r--r--chromium/ui/gl/gl_bindings_autogen_mock.cc23
-rw-r--r--chromium/ui/gl/gl_bindings_autogen_mock.h8
-rw-r--r--chromium/ui/gl/gl_context.cc1
-rw-r--r--chromium/ui/gl/gl_context.h4
-rw-r--r--chromium/ui/gl/gl_context_egl.cc31
-rw-r--r--chromium/ui/gl/gl_display_egl_util.cc52
-rw-r--r--chromium/ui/gl/gl_display_egl_util.h47
-rw-r--r--chromium/ui/gl/gl_helper.cc2
-rw-r--r--chromium/ui/gl/gl_image_ahardwarebuffer_unittest.cc2
-rw-r--r--chromium/ui/gl/gl_image_d3d_unittest.cc2
-rw-r--r--chromium/ui/gl/gl_image_dxgi_unittest.cc2
-rw-r--r--chromium/ui/gl/gl_image_io_surface_unittest.cc2
-rw-r--r--chromium/ui/gl/gl_image_memory.cc26
-rw-r--r--chromium/ui/gl/gl_image_memory.h6
-rw-r--r--chromium/ui/gl/gl_image_ref_counted_memory.cc2
-rw-r--r--chromium/ui/gl/gl_mock_autogen_gl.h5
-rw-r--r--chromium/ui/gl/gl_share_group.cc2
-rw-r--r--chromium/ui/gl/gl_stub_autogen_gl.h7
-rw-r--r--chromium/ui/gl/gl_surface.cc7
-rw-r--r--chromium/ui/gl/gl_surface.h6
-rw-r--r--chromium/ui/gl/gl_surface_egl.cc144
-rw-r--r--chromium/ui/gl/gl_surface_egl.h19
-rw-r--r--chromium/ui/gl/gl_surface_egl_surface_control.cc12
-rw-r--r--chromium/ui/gl/gl_surface_egl_surface_control.h5
-rw-r--r--chromium/ui/gl/gl_surface_egl_x11.cc126
-rw-r--r--chromium/ui/gl/gl_surface_egl_x11.h56
-rw-r--r--chromium/ui/gl/gl_surface_egl_x11_gles2.cc22
-rw-r--r--chromium/ui/gl/gl_surface_egl_x11_gles2.h8
-rw-r--r--chromium/ui/gl/gl_surface_format.cc2
-rw-r--r--chromium/ui/gl/gl_surface_glx.cc7
-rw-r--r--chromium/ui/gl/gl_switches.cc5
-rw-r--r--chromium/ui/gl/gl_switches.h1
-rw-r--r--chromium/ui/gl/gl_version_info.cc2
-rw-r--r--chromium/ui/gl/init/BUILD.gn10
-rw-r--r--chromium/ui/gl/init/create_gr_gl_interface.cc22
-rw-r--r--chromium/ui/gl/init/create_gr_gl_interface.h5
-rw-r--r--chromium/ui/gl/init/gl_display_egl_util_ozone.cc38
-rw-r--r--chromium/ui/gl/init/gl_display_egl_util_ozone.h39
-rw-r--r--chromium/ui/gl/init/gl_display_egl_util_x11.cc33
-rw-r--r--chromium/ui/gl/init/gl_display_egl_util_x11.h36
-rw-r--r--chromium/ui/gl/init/gl_factory_android.cc3
-rw-r--r--chromium/ui/gl/init/gl_factory_mac.cc3
-rw-r--r--chromium/ui/gl/init/gl_factory_ozone.cc3
-rw-r--r--chromium/ui/gl/init/gl_factory_win.cc3
-rw-r--r--chromium/ui/gl/init/gl_factory_x11.cc4
-rw-r--r--chromium/ui/gl/init/gl_initializer_ozone.cc9
-rw-r--r--chromium/ui/gl/init/gl_initializer_x11.cc3
-rw-r--r--chromium/ui/gl/mojom/BUILD.gn13
-rw-r--r--chromium/ui/gl/mojom/OWNERS2
-rw-r--r--chromium/ui/gl/mojom/gpu_preference.typemap12
-rw-r--r--chromium/ui/gl/scoped_cgl.cc2
-rw-r--r--chromium/ui/gl/scoped_make_current.cc2
-rw-r--r--chromium/ui/gl/shader_tracking.cc2
-rw-r--r--chromium/ui/gl/swap_chain_presenter.cc10
-rw-r--r--chromium/ui/gl/typemaps.gni5
-rw-r--r--chromium/ui/gl/vsync_provider_win.cc1
-rw-r--r--chromium/ui/gtk/BUILD.gn29
-rw-r--r--chromium/ui/gtk/gtk_ui.cc2
-rw-r--r--chromium/ui/gtk/native_theme_gtk.cc11
-rw-r--r--chromium/ui/gtk/print_dialog_gtk.cc15
-rw-r--r--chromium/ui/gtk/x/BUILD.gn27
-rw-r--r--chromium/ui/gtk/x/gtk_event_loop_x11.cc (renamed from chromium/ui/gtk/gtk_event_loop_x11.cc)2
-rw-r--r--chromium/ui/gtk/x/gtk_event_loop_x11.h (renamed from chromium/ui/gtk/gtk_event_loop_x11.h)6
-rw-r--r--chromium/ui/gtk/x/gtk_ui_delegate_x11.cc (renamed from chromium/ui/gtk/gtk_ui_delegate_x11.cc)6
-rw-r--r--chromium/ui/gtk/x/gtk_ui_delegate_x11.h (renamed from chromium/ui/gtk/gtk_ui_delegate_x11.h)6
-rw-r--r--chromium/ui/latency/latency_info.cc93
-rw-r--r--chromium/ui/latency/latency_info.h20
-rw-r--r--chromium/ui/latency/latency_tracker.h1
-rw-r--r--chromium/ui/latency/mojom/BUILD.gn19
-rw-r--r--chromium/ui/latency/mojom/OWNERS4
-rw-r--r--chromium/ui/latency/mojom/latency_info.mojom2
-rw-r--r--chromium/ui/latency/mojom/latency_info.typemap21
-rw-r--r--chromium/ui/latency/mojom/latency_info_mojom_traits.cc8
-rw-r--r--chromium/ui/latency/mojom/latency_info_mojom_traits.h1
-rw-r--r--chromium/ui/latency/mojom/typemaps.gni5
-rw-r--r--chromium/ui/login/display_manager.js12
-rw-r--r--chromium/ui/message_center/BUILD.gn1
-rw-r--r--chromium/ui/message_center/dummy_message_center.cc4
-rw-r--r--chromium/ui/message_center/message_center_observer.h1
-rw-r--r--chromium/ui/message_center/notification_list.cc2
-rw-r--r--chromium/ui/message_center/public/cpp/message_center_constants.h22
-rw-r--r--chromium/ui/message_center/public/cpp/notification.cc1
-rw-r--r--chromium/ui/message_center/public/cpp/notification_delegate.cc2
-rw-r--r--chromium/ui/message_center/public/cpp/notifier_id.cc2
-rw-r--r--chromium/ui/message_center/views/desktop_message_popup_collection.cc7
-rw-r--r--chromium/ui/message_center/views/desktop_message_popup_collection.h1
-rw-r--r--chromium/ui/message_center/views/message_popup_collection.cc53
-rw-r--r--chromium/ui/message_center/views/message_popup_collection.h19
-rw-r--r--chromium/ui/message_center/views/message_popup_collection_unittest.cc22
-rw-r--r--chromium/ui/message_center/views/message_view.cc21
-rw-r--r--chromium/ui/message_center/views/message_view.h17
-rw-r--r--chromium/ui/message_center/views/notification_control_buttons_unittest.cc81
-rw-r--r--chromium/ui/message_center/views/notification_control_buttons_view.cc71
-rw-r--r--chromium/ui/message_center/views/notification_control_buttons_view.h17
-rw-r--r--chromium/ui/message_center/views/notification_header_view.cc13
-rw-r--r--chromium/ui/message_center/views/notification_view_md.cc153
-rw-r--r--chromium/ui/message_center/views/notification_view_md.h5
-rw-r--r--chromium/ui/message_center/views/padded_button.cc8
-rw-r--r--chromium/ui/native_theme/BUILD.gn5
-rw-r--r--chromium/ui/native_theme/caption_style_win.cc2
-rw-r--r--chromium/ui/native_theme/common_theme.cc111
-rw-r--r--chromium/ui/native_theme/common_theme.h8
-rw-r--r--chromium/ui/native_theme/native_theme.cc233
-rw-r--r--chromium/ui/native_theme/native_theme.h12
-rw-r--r--chromium/ui/native_theme/native_theme_android.cc2
-rw-r--r--chromium/ui/native_theme/native_theme_aura.cc32
-rw-r--r--chromium/ui/native_theme/native_theme_base.cc5
-rw-r--r--chromium/ui/native_theme/native_theme_color_id.h41
-rw-r--r--chromium/ui/native_theme/native_theme_features.cc4
-rw-r--r--chromium/ui/native_theme/native_theme_mac.h11
-rw-r--r--chromium/ui/native_theme/native_theme_mac.mm111
-rw-r--r--chromium/ui/native_theme/native_theme_win.cc21
-rw-r--r--chromium/ui/native_theme/native_theme_win.h3
-rw-r--r--chromium/ui/native_theme/themed_vector_icon.cc41
-rw-r--r--chromium/ui/native_theme/themed_vector_icon.h15
-rw-r--r--chromium/ui/native_theme/themed_vector_icon_unittest.cc50
-rw-r--r--chromium/ui/ozone/BUILD.gn6
-rw-r--r--chromium/ui/ozone/DEPS2
-rw-r--r--chromium/ui/ozone/common/BUILD.gn5
-rw-r--r--chromium/ui/ozone/common/egl_util.cc19
-rw-r--r--chromium/ui/ozone/common/gl_surface_egl_readback.cc30
-rw-r--r--chromium/ui/ozone/common/gl_surface_egl_readback.h3
-rw-r--r--chromium/ui/ozone/common/gpu/OWNERS5
-rw-r--r--chromium/ui/ozone/common/gpu/ozone_gpu_message_generator.cc29
-rw-r--r--chromium/ui/ozone/common/gpu/ozone_gpu_message_generator.h7
-rw-r--r--chromium/ui/ozone/common/gpu/ozone_gpu_message_params.cc24
-rw-r--r--chromium/ui/ozone/common/gpu/ozone_gpu_message_params.h65
-rw-r--r--chromium/ui/ozone/common/gpu/ozone_gpu_messages.h190
-rw-r--r--chromium/ui/ozone/common/stub_client_native_pixmap_factory.cc1
-rw-r--r--chromium/ui/ozone/demo/gl_renderer.cc4
-rw-r--r--chromium/ui/ozone/demo/ozone_demo.cc12
-rw-r--r--chromium/ui/ozone/demo/simple_renderer_factory.h1
-rw-r--r--chromium/ui/ozone/demo/skia/skia_demo.cc12
-rw-r--r--chromium/ui/ozone/demo/skia/skia_gl_renderer.cc14
-rw-r--r--chromium/ui/ozone/demo/skia/skia_renderer_factory.h1
-rw-r--r--chromium/ui/ozone/demo/skia/skia_surfaceless_gl_renderer.cc4
-rw-r--r--chromium/ui/ozone/demo/window_manager.cc10
-rw-r--r--chromium/ui/ozone/gl/gl_image_ozone_native_pixmap_unittest.cc1
-rw-r--r--chromium/ui/ozone/ozone.gni13
-rw-r--r--chromium/ui/ozone/platform/cast/client_native_pixmap_factory_cast.cc2
-rw-r--r--chromium/ui/ozone/platform/drm/BUILD.gn9
-rw-r--r--chromium/ui/ozone/platform/drm/common/drm_util.cc91
-rw-r--r--chromium/ui/ozone/platform/drm/common/drm_util.h13
-rw-r--r--chromium/ui/ozone/platform/drm/common/drm_util_unittest.cc159
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/crtc_controller.cc7
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/crtc_controller.h3
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_display.h1
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h3
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_overlay_validator_unittest.cc1
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_thread.cc22
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_thread.h13
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_thread_message_proxy.cc286
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_thread_message_proxy.h100
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_thread_proxy.cc46
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_thread_unittest.cc98
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_window.cc1
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/drm_window_proxy.cc13
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/gbm_pixmap.cc2
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc2
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc3
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_controller.cc20
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc122
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h3
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.cc49
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h1
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc3
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h1
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc57
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/mock_drm_device.cc16
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/screen_manager_unittest.cc153
-rw-r--r--chromium/ui/ozone/platform/drm/gpu/vulkan_implementation_gbm.cc5
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_device_connector.cc13
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_device_connector.h6
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_display_host.cc4
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_display_host_manager.cc10
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_display_host_manager.h6
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc341
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h128
-rw-r--r--chromium/ui/ozone/platform/drm/host/drm_window_host_manager.cc3
-rw-r--r--chromium/ui/ozone/platform/drm/host/gpu_thread_adapter.h12
-rw-r--r--chromium/ui/ozone/platform/drm/host/host_cursor_proxy.cc1
-rw-r--r--chromium/ui/ozone/platform/drm/host/host_drm_device.cc14
-rw-r--r--chromium/ui/ozone/platform/drm/host/host_drm_device.h13
-rw-r--r--chromium/ui/ozone/platform/drm/ozone_platform_gbm.cc93
-rw-r--r--chromium/ui/ozone/platform/headless/headless_surface_factory.cc3
-rw-r--r--chromium/ui/ozone/platform/scenic/BUILD.gn1
-rw-r--r--chromium/ui/ozone/platform/scenic/DEPS1
-rw-r--r--chromium/ui/ozone/platform/scenic/ozone_platform_scenic.cc75
-rw-r--r--chromium/ui/ozone/platform/scenic/scenic_gpu_host.cc37
-rw-r--r--chromium/ui/ozone/platform/scenic/scenic_gpu_host.h15
-rw-r--r--chromium/ui/ozone/platform/scenic/scenic_surface_factory.cc154
-rw-r--r--chromium/ui/ozone/platform/scenic/scenic_surface_factory.h18
-rw-r--r--chromium/ui/ozone/platform/scenic/scenic_window_manager.cc10
-rw-r--r--chromium/ui/ozone/platform/scenic/scenic_window_manager.h3
-rw-r--r--chromium/ui/ozone/platform/scenic/sysmem_buffer_manager.cc17
-rw-r--r--chromium/ui/ozone/platform/scenic/sysmem_buffer_manager.h11
-rw-r--r--chromium/ui/ozone/platform/scenic/vulkan_implementation_scenic.cc2
-rw-r--r--chromium/ui/ozone/platform/wayland/BUILD.gn30
-rw-r--r--chromium/ui/ozone/platform/wayland/README.md45
-rw-r--r--chromium/ui/ozone/platform/wayland/gpu/gl_surface_egl_readback_wayland.cc10
-rw-r--r--chromium/ui/ozone/platform/wayland/gpu/gl_surface_egl_readback_wayland.h19
-rw-r--r--chromium/ui/ozone/platform/wayland/gpu/vulkan_implementation_wayland.cc151
-rw-r--r--chromium/ui/ozone/platform/wayland/gpu/vulkan_implementation_wayland.h59
-rw-r--r--chromium/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc30
-rw-r--r--chromium/ui/ozone/platform/wayland/gpu/wayland_canvas_surface.h24
-rw-r--r--chromium/ui/ozone/platform/wayland/gpu/wayland_surface_factory.cc13
-rw-r--r--chromium/ui/ozone/platform/wayland/gpu/wayland_surface_factory.h5
-rw-r--r--chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_device.cc2
-rw-r--r--chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_device.h4
-rw-r--r--chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_offer.cc2
-rw-r--r--chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_offer.h13
-rw-r--r--chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_source.cc2
-rw-r--r--chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_source.h4
-rw-r--r--chromium/ui/ozone/platform/wayland/host/shell_popup_wrapper.cc20
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_connector.cc85
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_connector.h16
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc5
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h4
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_clipboard.cc4
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_connection.cc199
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_connection.h76
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_connection_unittest.cc3
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_cursor.cc35
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_cursor.h13
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_data_device.cc8
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_data_device.h11
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_data_device_base.cc (renamed from chromium/ui/ozone/platform/wayland/host/internal/wayland_data_device_base.cc)6
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_data_device_base.h (renamed from chromium/ui/ozone/platform/wayland/host/internal/wayland_data_device_base.h)12
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_data_device_unittest.cc3
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_data_offer.cc6
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_data_offer.h7
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_data_offer_base.cc (renamed from chromium/ui/ozone/platform/wayland/host/internal/wayland_data_offer_base.cc)4
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_data_offer_base.h (renamed from chromium/ui/ozone/platform/wayland/host/internal/wayland_data_offer_base.h)8
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_data_source.cc5
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_data_source.h5
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_data_source_base.cc (renamed from chromium/ui/ozone/platform/wayland/host/internal/wayland_data_source_base.cc)4
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_data_source_base.h (renamed from chromium/ui/ozone/platform/wayland/host/internal/wayland_data_source_base.h)8
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_event_source.cc360
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_event_source.h153
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_event_source_unittest.cc118
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_event_watcher.cc107
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_event_watcher.h52
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_input_method_context.cc31
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_input_method_context.h20
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_input_method_context_factory.cc6
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_input_method_context_factory.h2
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_keyboard.cc95
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_keyboard.h46
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_pointer.cc154
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_pointer.h73
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_pointer_unittest.cc108
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_popup.cc38
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_popup.h1
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_screen.cc21
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_screen.h14
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc23
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_surface.cc6
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_touch.cc133
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_touch.h65
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_touch_unittest.cc74
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_window.cc133
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_window.h10
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_window_factory.cc5
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_window_manager.cc19
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_window_manager.h13
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_window_manager_unittests.cc5
-rw-r--r--chromium/ui/ozone/platform/wayland/host/wayland_window_unittest.cc716
-rw-r--r--chromium/ui/ozone/platform/wayland/host/xdg_popup_wrapper_impl.cc16
-rw-r--r--chromium/ui/ozone/platform/wayland/host/xdg_surface_wrapper_impl.h2
-rw-r--r--chromium/ui/ozone/platform/wayland/ozone_platform_wayland.cc15
-rw-r--r--chromium/ui/ozone/platform/wayland/test/mock_surface.h4
-rw-r--r--chromium/ui/ozone/platform/wayland/test/mock_xdg_shell.cc2
-rw-r--r--chromium/ui/ozone/platform/wayland/test/mock_xdg_surface.cc30
-rw-r--r--chromium/ui/ozone/platform/wayland/test/mock_xdg_surface.h8
-rw-r--r--chromium/ui/ozone/platform/wayland/test/test_compositor.cc1
-rw-r--r--chromium/ui/ozone/platform/wayland/test/test_data_device.cc2
-rw-r--r--chromium/ui/ozone/platform/wayland/test/test_data_device.h2
-rw-r--r--chromium/ui/ozone/platform/wayland/test/test_data_device_manager.h2
-rw-r--r--chromium/ui/ozone/platform/wayland/test/test_data_offer.h2
-rw-r--r--chromium/ui/ozone/platform/wayland/test/test_data_source.h2
-rw-r--r--chromium/ui/ozone/platform/wayland/test/test_output.cc2
-rw-r--r--chromium/ui/ozone/platform/wayland/test/test_region.h2
-rw-r--r--chromium/ui/ozone/platform/wayland/test/test_seat.h2
-rw-r--r--chromium/ui/ozone/platform/wayland/test/test_subcompositor.cc2
-rw-r--r--chromium/ui/ozone/platform/wayland/test/test_subsurface.h2
-rw-r--r--chromium/ui/ozone/platform/wayland/test/test_xdg_popup.cc (renamed from chromium/ui/ozone/platform/wayland/test/mock_xdg_popup.cc)8
-rw-r--r--chromium/ui/ozone/platform/wayland/test/test_xdg_popup.h (renamed from chromium/ui/ozone/platform/wayland/test/mock_xdg_popup.h)24
-rw-r--r--chromium/ui/ozone/platform/x11/BUILD.gn29
-rw-r--r--chromium/ui/ozone/platform/x11/DEPS2
-rw-r--r--chromium/ui/ozone/platform/x11/OWNERS3
-rw-r--r--chromium/ui/ozone/platform/x11/gl_egl_utility_x11.cc25
-rw-r--r--chromium/ui/ozone/platform/x11/gl_egl_utility_x11.h30
-rw-r--r--chromium/ui/ozone/platform/x11/gl_ozone_glx.cc4
-rw-r--r--chromium/ui/ozone/platform/x11/gl_surface_egl_ozone_x11.cc100
-rw-r--r--chromium/ui/ozone/platform/x11/gl_surface_egl_ozone_x11.h35
-rw-r--r--chromium/ui/ozone/platform/x11/gl_surface_glx_ozone.cc41
-rw-r--r--chromium/ui/ozone/platform/x11/gl_surface_glx_ozone.h37
-rw-r--r--chromium/ui/ozone/platform/x11/ozone_platform_x11.cc40
-rw-r--r--chromium/ui/ozone/platform/x11/x11_cursor_factory_ozone.cc2
-rw-r--r--chromium/ui/ozone/platform/x11/x11_cursor_factory_ozone.h2
-rw-r--r--chromium/ui/ozone/platform/x11/x11_cursor_ozone.cc37
-rw-r--r--chromium/ui/ozone/platform/x11/x11_os_exchange_data_provider_ozone.cc51
-rw-r--r--chromium/ui/ozone/platform/x11/x11_os_exchange_data_provider_ozone.h35
-rw-r--r--chromium/ui/ozone/platform/x11/x11_screen_ozone.cc72
-rw-r--r--chromium/ui/ozone/platform/x11/x11_screen_ozone.h3
-rw-r--r--chromium/ui/ozone/platform/x11/x11_surface_factory.cc4
-rw-r--r--chromium/ui/ozone/platform/x11/x11_window_ozone.cc138
-rw-r--r--chromium/ui/ozone/platform/x11/x11_window_ozone.h47
-rw-r--r--chromium/ui/ozone/platform/x11/x11_window_ozone_chromeos.cc28
-rw-r--r--chromium/ui/ozone/platform/x11/x11_window_ozone_chromeos.h33
-rw-r--r--chromium/ui/ozone/public/DEPS2
-rw-r--r--chromium/ui/ozone/public/cursor_factory_ozone.cc3
-rw-r--r--chromium/ui/ozone/public/cursor_factory_ozone.h2
-rw-r--r--chromium/ui/ozone/public/gpu_platform_support_host.cc8
-rw-r--r--chromium/ui/ozone/public/gpu_platform_support_host.h14
-rw-r--r--chromium/ui/ozone/public/ozone_gpu_test_helper.cc92
-rw-r--r--chromium/ui/ozone/public/ozone_gpu_test_helper.h12
-rw-r--r--chromium/ui/ozone/public/ozone_platform.cc8
-rw-r--r--chromium/ui/ozone/public/ozone_platform.h26
-rw-r--r--chromium/ui/ozone/public/platform_gl_egl_utility.h34
-rw-r--r--chromium/ui/ozone/public/platform_screen.cc9
-rw-r--r--chromium/ui/ozone/public/platform_screen.h11
-rw-r--r--chromium/ui/ozone/public/surface_ozone_canvas.cc2
-rw-r--r--chromium/ui/ozone/test/mock_platform_window_delegate.h1
-rw-r--r--chromium/ui/platform_window/extensions/x11_extension.h2
-rw-r--r--chromium/ui/platform_window/extensions/x11_extension_delegate.h7
-rw-r--r--chromium/ui/platform_window/platform_window_handler/BUILD.gn2
-rw-r--r--chromium/ui/platform_window/platform_window_handler/wm_move_loop_handler.cc25
-rw-r--r--chromium/ui/platform_window/platform_window_handler/wm_move_loop_handler.h39
-rw-r--r--chromium/ui/platform_window/x11/BUILD.gn4
-rw-r--r--chromium/ui/platform_window/x11/OWNERS3
-rw-r--r--chromium/ui/platform_window/x11/atk_event_conversion.cc2
-rw-r--r--chromium/ui/platform_window/x11/x11_topmost_window_finder.cc84
-rw-r--r--chromium/ui/platform_window/x11/x11_topmost_window_finder.h (renamed from chromium/ui/views/widget/desktop_aura/x11_topmost_window_finder.h)34
-rw-r--r--chromium/ui/platform_window/x11/x11_window.cc33
-rw-r--r--chromium/ui/platform_window/x11/x11_window.h23
-rw-r--r--chromium/ui/platform_window/x11/x11_window_manager.cc7
-rw-r--r--chromium/ui/platform_window/x11/x11_window_manager.h2
-rw-r--r--chromium/ui/resources/cursors/none.curbin78 -> 0 bytes
-rw-r--r--chromium/ui/resources/ui_unscaled_resources.grd1
-rw-r--r--chromium/ui/shell_dialogs/fake_select_file_dialog.cc1
-rw-r--r--chromium/ui/shell_dialogs/select_file_dialog.cc2
-rw-r--r--chromium/ui/shell_dialogs/select_file_dialog_android.cc3
-rw-r--r--chromium/ui/shell_dialogs/select_file_dialog_fuchsia.cc2
-rw-r--r--chromium/ui/shell_dialogs/select_file_dialog_mac.mm3
-rw-r--r--chromium/ui/shell_dialogs/select_file_dialog_win.cc3
-rw-r--r--chromium/ui/shell_dialogs/select_file_dialog_win_unittest.cc12
-rw-r--r--chromium/ui/shell_dialogs/shell_dialog_linux.cc1
-rw-r--r--chromium/ui/snapshot/snapshot_mac.mm2
-rw-r--r--chromium/ui/strings/app_locale_settings.grd1
-rw-r--r--chromium/ui/strings/translations/ui_strings_ar.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_as.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_bn.xtb4
-rw-r--r--chromium/ui/strings/translations/ui_strings_bs.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_da.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_de.xtb26
-rw-r--r--chromium/ui/strings/translations/ui_strings_es.xtb4
-rw-r--r--chromium/ui/strings/translations/ui_strings_et.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_fi.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_fr.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_gu.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_hi.xtb4
-rw-r--r--chromium/ui/strings/translations/ui_strings_hy.xtb4
-rw-r--r--chromium/ui/strings/translations/ui_strings_id.xtb4
-rw-r--r--chromium/ui/strings/translations/ui_strings_kk.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_kn.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_lv.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_ml.xtb4
-rw-r--r--chromium/ui/strings/translations/ui_strings_mr.xtb4
-rw-r--r--chromium/ui/strings/translations/ui_strings_my.xtb4
-rw-r--r--chromium/ui/strings/translations/ui_strings_nl.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_or.xtb4
-rw-r--r--chromium/ui/strings/translations/ui_strings_pl.xtb4
-rw-r--r--chromium/ui/strings/translations/ui_strings_ru.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_sk.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_sv.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_ta.xtb4
-rw-r--r--chromium/ui/strings/translations/ui_strings_te.xtb6
-rw-r--r--chromium/ui/strings/translations/ui_strings_tr.xtb2
-rw-r--r--chromium/ui/strings/translations/ui_strings_vi.xtb4
-rw-r--r--chromium/ui/strings/translations/ui_strings_zh-CN.xtb4
-rw-r--r--chromium/ui/strings/translations/ui_strings_zh-HK.xtb2
-rw-r--r--chromium/ui/strings/ui_strings.grd1
-rw-r--r--chromium/ui/touch_selection/touch_handle.cc2
-rw-r--r--chromium/ui/touch_selection/touch_selection_controller.cc3
-rw-r--r--chromium/ui/touch_selection/touch_selection_menu_runner.cc2
-rw-r--r--chromium/ui/views/BUILD.gn67
-rw-r--r--chromium/ui/views/accessibility/accessibility_alert_window.cc2
-rw-r--r--chromium/ui/views/accessibility/ax_aura_obj_cache.cc18
-rw-r--r--chromium/ui/views/accessibility/ax_aura_obj_cache_unittest.cc70
-rw-r--r--chromium/ui/views/accessibility/ax_aura_obj_wrapper.h1
-rw-r--r--chromium/ui/views/accessibility/ax_root_obj_wrapper.cc4
-rw-r--r--chromium/ui/views/accessibility/ax_root_obj_wrapper.h1
-rw-r--r--chromium/ui/views/accessibility/ax_system_caret_win_interactive_uitest.cc28
-rw-r--r--chromium/ui/views/accessibility/ax_tree_source_views.cc4
-rw-r--r--chromium/ui/views/accessibility/ax_tree_source_views.h1
-rw-r--r--chromium/ui/views/accessibility/ax_view_obj_wrapper.cc4
-rw-r--r--chromium/ui/views/accessibility/ax_view_obj_wrapper.h1
-rw-r--r--chromium/ui/views/accessibility/ax_virtual_view.cc69
-rw-r--r--chromium/ui/views/accessibility/ax_virtual_view.h2
-rw-r--r--chromium/ui/views/accessibility/ax_virtual_view_unittest.cc45
-rw-r--r--chromium/ui/views/accessibility/ax_virtual_view_wrapper.cc5
-rw-r--r--chromium/ui/views/accessibility/ax_virtual_view_wrapper.h1
-rw-r--r--chromium/ui/views/accessibility/ax_widget_obj_wrapper.cc4
-rw-r--r--chromium/ui/views/accessibility/ax_widget_obj_wrapper.h1
-rw-r--r--chromium/ui/views/accessibility/ax_window_obj_wrapper.cc18
-rw-r--r--chromium/ui/views/accessibility/ax_window_obj_wrapper.h1
-rw-r--r--chromium/ui/views/accessibility/test_list_grid_view.cc57
-rw-r--r--chromium/ui/views/accessibility/test_list_grid_view.h40
-rw-r--r--chromium/ui/views/accessibility/view_ax_platform_node_delegate_win_unittest.cc80
-rw-r--r--chromium/ui/views/accessibility/views_ax_tree_manager.cc3
-rw-r--r--chromium/ui/views/animation/bounds_animator.cc68
-rw-r--r--chromium/ui/views/animation/bounds_animator.h4
-rw-r--r--chromium/ui/views/animation/bounds_animator_unittest.cc111
-rw-r--r--chromium/ui/views/animation/ink_drop.h3
-rw-r--r--chromium/ui/views/animation/ink_drop_animation_ended_reason.cc4
-rw-r--r--chromium/ui/views/animation/ink_drop_host_view.cc21
-rw-r--r--chromium/ui/views/animation/ink_drop_host_view_unittest.cc4
-rw-r--r--chromium/ui/views/animation/ink_drop_impl.cc6
-rw-r--r--chromium/ui/views/animation/ink_drop_impl.h1
-rw-r--r--chromium/ui/views/animation/ink_drop_state.cc3
-rw-r--r--chromium/ui/views/animation/ink_drop_stub.cc2
-rw-r--r--chromium/ui/views/animation/ink_drop_stub.h1
-rw-r--r--chromium/ui/views/animation/ink_drop_util.cc2
-rw-r--r--chromium/ui/views/animation/installable_ink_drop.cc6
-rw-r--r--chromium/ui/views/animation/installable_ink_drop.h1
-rw-r--r--chromium/ui/views/animation/installable_ink_drop_animator.cc3
-rw-r--r--chromium/ui/views/animation/scroll_animator.cc2
-rw-r--r--chromium/ui/views/background.cc2
-rw-r--r--chromium/ui/views/border.cc2
-rw-r--r--chromium/ui/views/bubble/bubble_border.cc3
-rw-r--r--chromium/ui/views/bubble/bubble_dialog_delegate_view.cc87
-rw-r--r--chromium/ui/views/bubble/bubble_dialog_delegate_view.h4
-rw-r--r--chromium/ui/views/bubble/footnote_container_view.cc8
-rw-r--r--chromium/ui/views/color_chooser/color_chooser_view.cc6
-rw-r--r--chromium/ui/views/controls/button/button_controller.cc3
-rw-r--r--chromium/ui/views/controls/button/button_unittest.cc190
-rw-r--r--chromium/ui/views/controls/button/checkbox.cc2
-rw-r--r--chromium/ui/views/controls/button/image_button_factory.cc1
-rw-r--r--chromium/ui/views/controls/button/image_button_factory.h11
-rw-r--r--chromium/ui/views/controls/button/label_button_border.cc1
-rw-r--r--chromium/ui/views/controls/button/md_text_button.cc27
-rw-r--r--chromium/ui/views/controls/button/md_text_button.h12
-rw-r--r--chromium/ui/views/controls/button/radio_button.cc2
-rw-r--r--chromium/ui/views/controls/button/toggle_button.cc2
-rw-r--r--chromium/ui/views/controls/combobox/combobox.cc7
-rw-r--r--chromium/ui/views/controls/editable_combobox/editable_combobox.cc14
-rw-r--r--chromium/ui/views/controls/editable_combobox/editable_combobox.h2
-rw-r--r--chromium/ui/views/controls/highlight_path_generator.cc55
-rw-r--r--chromium/ui/views/controls/highlight_path_generator.h34
-rw-r--r--chromium/ui/views/controls/image_view.cc2
-rw-r--r--chromium/ui/views/controls/label.cc22
-rw-r--r--chromium/ui/views/controls/label.h9
-rw-r--r--chromium/ui/views/controls/label_unittest.cc40
-rw-r--r--chromium/ui/views/controls/link.cc54
-rw-r--r--chromium/ui/views/controls/link.h25
-rw-r--r--chromium/ui/views/controls/menu/menu_closure_animation_mac.mm3
-rw-r--r--chromium/ui/views/controls/menu/menu_config.h3
-rw-r--r--chromium/ui/views/controls/menu/menu_config_win.cc3
-rw-r--r--chromium/ui/views/controls/menu/menu_controller.cc35
-rw-r--r--chromium/ui/views/controls/menu/menu_controller_unittest.cc117
-rw-r--r--chromium/ui/views/controls/menu/menu_host.cc3
-rw-r--r--chromium/ui/views/controls/menu/menu_host_root_view.cc3
-rw-r--r--chromium/ui/views/controls/menu/menu_host_root_view.h2
-rw-r--r--chromium/ui/views/controls/menu/menu_item_view.cc2
-rw-r--r--chromium/ui/views/controls/menu/menu_model_adapter.cc17
-rw-r--r--chromium/ui/views/controls/menu/menu_model_adapter_unittest.cc4
-rw-r--r--chromium/ui/views/controls/menu/menu_runner_cocoa_unittest.mm3
-rw-r--r--chromium/ui/views/controls/menu/menu_scroll_view_container.cc12
-rw-r--r--chromium/ui/views/controls/menu/menu_scroll_view_container.h2
-rw-r--r--chromium/ui/views/controls/menu/native_menu_win.cc2
-rw-r--r--chromium/ui/views/controls/message_box_view.cc4
-rw-r--r--chromium/ui/views/controls/native/native_view_host.cc2
-rw-r--r--chromium/ui/views/controls/native/native_view_host_aura.cc2
-rw-r--r--chromium/ui/views/controls/native/native_view_host_aura_unittest.cc2
-rw-r--r--chromium/ui/views/controls/progress_bar.cc31
-rw-r--r--chromium/ui/views/controls/progress_bar.h9
-rw-r--r--chromium/ui/views/controls/progress_bar_unittest.cc112
-rw-r--r--chromium/ui/views/controls/resize_area.cc1
-rw-r--r--chromium/ui/views/controls/scroll_view.cc2
-rw-r--r--chromium/ui/views/controls/scroll_view_unittest.cc50
-rw-r--r--chromium/ui/views/controls/scrollbar/scroll_bar_views.cc3
-rw-r--r--chromium/ui/views/controls/slider.cc2
-rw-r--r--chromium/ui/views/controls/styled_label.cc3
-rw-r--r--chromium/ui/views/controls/tabbed_pane/tabbed_pane.cc2
-rw-r--r--chromium/ui/views/controls/tabbed_pane/tabbed_pane.h4
-rw-r--r--chromium/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc159
-rw-r--r--chromium/ui/views/controls/table/table_utils.cc2
-rw-r--r--chromium/ui/views/controls/table/table_view.cc24
-rw-r--r--chromium/ui/views/controls/table/table_view.h5
-rw-r--r--chromium/ui/views/controls/table/table_view_unittest.cc24
-rw-r--r--chromium/ui/views/controls/textfield/textfield.cc225
-rw-r--r--chromium/ui/views/controls/textfield/textfield.h32
-rw-r--r--chromium/ui/views/controls/textfield/textfield_model.cc354
-rw-r--r--chromium/ui/views/controls/textfield/textfield_model.h75
-rw-r--r--chromium/ui/views/controls/textfield/textfield_model_unittest.cc713
-rw-r--r--chromium/ui/views/controls/textfield/textfield_test_api.cc6
-rw-r--r--chromium/ui/views/controls/textfield/textfield_test_api.h8
-rw-r--r--chromium/ui/views/controls/textfield/textfield_unittest.cc193
-rw-r--r--chromium/ui/views/controls/tree/tree_view.cc11
-rw-r--r--chromium/ui/views/controls/tree/tree_view.h2
-rw-r--r--chromium/ui/views/controls/views_text_services_context_menu.cc2
-rw-r--r--chromium/ui/views/controls/webview/BUILD.gn2
-rw-r--r--chromium/ui/views/controls/webview/unhandled_keyboard_event_handler.cc4
-rw-r--r--chromium/ui/views/controls/webview/web_dialog_view.cc7
-rw-r--r--chromium/ui/views/controls/webview/web_dialog_view.h1
-rw-r--r--chromium/ui/views/controls/webview/web_dialog_view_unittest.cc2
-rw-r--r--chromium/ui/views/corewm/DEPS2
-rw-r--r--chromium/ui/views/corewm/desktop_capture_controller_unittest.cc9
-rw-r--r--chromium/ui/views/corewm/tooltip_aura.cc22
-rw-r--r--chromium/ui/views/corewm/tooltip_controller.cc7
-rw-r--r--chromium/ui/views/corewm/tooltip_controller_test_helper.cc5
-rw-r--r--chromium/ui/views/corewm/tooltip_controller_test_helper.h1
-rw-r--r--chromium/ui/views/corewm/tooltip_controller_unittest.cc30
-rw-r--r--chromium/ui/views/debug_utils.cc8
-rw-r--r--chromium/ui/views/debug_utils.h3
-rw-r--r--chromium/ui/views/event_monitor_aura.cc2
-rw-r--r--chromium/ui/views/event_monitor_mac.mm2
-rw-r--r--chromium/ui/views/examples/BUILD.gn125
-rw-r--r--chromium/ui/views/examples/DEPS2
-rw-r--r--chromium/ui/views/examples/box_layout_example.cc24
-rw-r--r--chromium/ui/views/examples/bubble_example.cc26
-rw-r--r--chromium/ui/views/examples/button_sticker_sheet.cc3
-rw-r--r--chromium/ui/views/examples/checkbox_example.cc4
-rw-r--r--chromium/ui/views/examples/colored_dialog_example.cc176
-rw-r--r--chromium/ui/views/examples/colored_dialog_example.h77
-rw-r--r--chromium/ui/views/examples/combobox_example.cc15
-rw-r--r--chromium/ui/views/examples/create_examples.cc80
-rw-r--r--chromium/ui/views/examples/create_examples.h24
-rw-r--r--chromium/ui/views/examples/dialog_example.cc14
-rw-r--r--chromium/ui/views/examples/example_base.h3
-rw-r--r--chromium/ui/views/examples/examples_exit_code.h25
-rw-r--r--chromium/ui/views/examples/examples_main.cc159
-rw-r--r--chromium/ui/views/examples/examples_main_proc.cc198
-rw-r--r--chromium/ui/views/examples/examples_main_proc.h18
-rw-r--r--chromium/ui/views/examples/examples_skia_gold_pixel_diff.cc60
-rw-r--r--chromium/ui/views/examples/examples_skia_gold_pixel_diff.h39
-rw-r--r--chromium/ui/views/examples/examples_unittest.cc26
-rw-r--r--chromium/ui/views/examples/examples_unittest_main.cc14
-rw-r--r--chromium/ui/views/examples/examples_window.cc126
-rw-r--r--chromium/ui/views/examples/examples_window.h10
-rw-r--r--chromium/ui/views/examples/examples_window_with_content.cc10
-rw-r--r--chromium/ui/views/examples/examples_window_with_content.h1
-rw-r--r--chromium/ui/views/examples/examples_with_content_main.cc (renamed from chromium/ui/views/examples/examples_with_content_main_exe.cc)35
-rw-r--r--chromium/ui/views/examples/flex_layout_example.cc18
-rw-r--r--chromium/ui/views/examples/label_example.cc12
-rw-r--r--chromium/ui/views/examples/layout_example_base.cc145
-rw-r--r--chromium/ui/views/examples/layout_example_base.h49
-rw-r--r--chromium/ui/views/examples/link_example.cc14
-rw-r--r--chromium/ui/views/examples/login_bubble_dialog.cc164
-rw-r--r--chromium/ui/views/examples/login_bubble_dialog.h71
-rw-r--r--chromium/ui/views/examples/menu_example.cc35
-rw-r--r--chromium/ui/views/examples/message_box_example.cc38
-rw-r--r--chromium/ui/views/examples/multiline_example.cc24
-rw-r--r--chromium/ui/views/examples/native_theme_example.cc11
-rw-r--r--chromium/ui/views/examples/progress_bar_example.cc20
-rw-r--r--chromium/ui/views/examples/radio_button_example.cc18
-rw-r--r--chromium/ui/views/examples/scroll_view_example.cc38
-rw-r--r--chromium/ui/views/examples/slider_example.cc11
-rw-r--r--chromium/ui/views/examples/tabbed_pane_example.cc37
-rw-r--r--chromium/ui/views/examples/tabbed_pane_example.h2
-rw-r--r--chromium/ui/views/examples/table_example.cc10
-rw-r--r--chromium/ui/views/examples/text_example.cc6
-rw-r--r--chromium/ui/views/examples/textfield_example.cc119
-rw-r--r--chromium/ui/views/examples/textfield_example.h2
-rw-r--r--chromium/ui/views/examples/throbber_example.cc12
-rw-r--r--chromium/ui/views/examples/toggle_button_example.cc9
-rw-r--r--chromium/ui/views/examples/tree_view_example.cc67
-rw-r--r--chromium/ui/views/examples/vector_example.cc26
-rw-r--r--chromium/ui/views/examples/views_examples_resources.grd411
-rw-r--r--chromium/ui/views/examples/webview_example.cc4
-rw-r--r--chromium/ui/views/examples/widget_example.cc37
-rw-r--r--chromium/ui/views/examples/widget_example.h2
-rw-r--r--chromium/ui/views/focus/external_focus_tracker.cc2
-rw-r--r--chromium/ui/views/focus/focus_manager.cc43
-rw-r--r--chromium/ui/views/focus/focus_manager.h20
-rw-r--r--chromium/ui/views/focus/focus_manager_unittest.cc197
-rw-r--r--chromium/ui/views/layout/animating_layout_manager.cc143
-rw-r--r--chromium/ui/views/layout/animating_layout_manager.h39
-rw-r--r--chromium/ui/views/layout/animating_layout_manager_unittest.cc603
-rw-r--r--chromium/ui/views/layout/box_layout.cc30
-rw-r--r--chromium/ui/views/layout/flex_layout.cc3
-rw-r--r--chromium/ui/views/layout/grid_layout.cc22
-rw-r--r--chromium/ui/views/layout/grid_layout.h20
-rw-r--r--chromium/ui/views/layout/grid_layout_unittest.cc179
-rw-r--r--chromium/ui/views/layout/layout_manager_base.cc2
-rw-r--r--chromium/ui/views/layout/layout_manager_base.h1
-rw-r--r--chromium/ui/views/layout/proposed_layout.cc1
-rw-r--r--chromium/ui/views/metadata/metadata_cache.cc2
-rw-r--r--chromium/ui/views/metadata/metadata_types.cc2
-rw-r--r--chromium/ui/views/metadata/type_conversion.cc2
-rw-r--r--chromium/ui/views/native_cursor_aura.cc2
-rw-r--r--chromium/ui/views/painter.cc2
-rw-r--r--chromium/ui/views/style/typography.cc2
-rw-r--r--chromium/ui/views/touchui/touch_selection_controller_impl.cc12
-rw-r--r--chromium/ui/views/touchui/touch_selection_controller_impl.h7
-rw-r--r--chromium/ui/views/touchui/touch_selection_menu_views.cc23
-rw-r--r--chromium/ui/views/vector_icons/linux_shutdown.icon16
-rw-r--r--chromium/ui/views/view.cc26
-rw-r--r--chromium/ui/views/view.h6
-rw-r--r--chromium/ui/views/view_model.cc2
-rw-r--r--chromium/ui/views/view_unittest.cc169
-rw-r--r--chromium/ui/views/views_features.cc6
-rw-r--r--chromium/ui/views/views_features.h1
-rw-r--r--chromium/ui/views/widget/any_widget_observer_unittest.cc2
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc28
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h14
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc40
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_ozone.cc3
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc6
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h2
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc6
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_screen_ozone.cc17
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_screen_ozone.h28
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_screen_win.cc20
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_screen_win.h11
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_screen_x11.cc27
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_screen_x11.h3
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_linux.cc42
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h14
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_linux_interactive_uitest.cc5
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.cc43
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h12
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc19
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h5
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc53
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h9
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc31
-rw-r--r--chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc6
-rw-r--r--chromium/ui/views/widget/desktop_aura/window_event_filter_linux.cc4
-rw-r--r--chromium/ui/views/widget/desktop_aura/window_move_client_platform.cc37
-rw-r--r--chromium/ui/views/widget/desktop_aura/window_move_client_platform.h37
-rw-r--r--chromium/ui/views/widget/desktop_aura/x11_desktop_window_move_client.cc56
-rw-r--r--chromium/ui/views/widget/desktop_aura/x11_topmost_window_finder.cc92
-rw-r--r--chromium/ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc77
-rw-r--r--chromium/ui/views/widget/desktop_widget_unittest.cc6
-rw-r--r--chromium/ui/views/widget/native_widget_aura.cc2
-rw-r--r--chromium/ui/views/widget/native_widget_aura_interactive_uitest.cc7
-rw-r--r--chromium/ui/views/widget/native_widget_aura_unittest.cc12
-rw-r--r--chromium/ui/views/widget/native_widget_mac_unittest.mm65
-rw-r--r--chromium/ui/views/widget/tooltip_manager_aura.cc1
-rw-r--r--chromium/ui/views/widget/widget.cc20
-rw-r--r--chromium/ui/views/widget/widget.h17
-rw-r--r--chromium/ui/views/widget/widget_aura_utils.cc2
-rw-r--r--chromium/ui/views/widget/widget_delegate.cc107
-rw-r--r--chromium/ui/views/widget/widget_delegate.h89
-rw-r--r--chromium/ui/views/widget/widget_interactive_uitest.cc823
-rw-r--r--chromium/ui/views/widget/widget_unittest.cc269
-rw-r--r--chromium/ui/views/win/fullscreen_handler.cc1
-rw-r--r--chromium/ui/views/win/hwnd_message_handler.cc61
-rw-r--r--chromium/ui/views/win/hwnd_message_handler.h9
-rw-r--r--chromium/ui/views/win/pen_event_processor.cc8
-rw-r--r--chromium/ui/views/win/pen_event_processor_unittest.cc4
-rw-r--r--chromium/ui/views/win/scoped_fullscreen_visibility.cc2
-rw-r--r--chromium/ui/views/window/caption_button_layout_constants.cc1
-rw-r--r--chromium/ui/views/window/client_view.cc2
-rw-r--r--chromium/ui/views/window/dialog_client_view.cc12
-rw-r--r--chromium/ui/views/window/dialog_client_view_unittest.cc110
-rw-r--r--chromium/ui/views/window/dialog_delegate.cc27
-rw-r--r--chromium/ui/views/window/dialog_delegate.h19
-rw-r--r--chromium/ui/views/window/dialog_delegate_unittest.cc11
-rw-r--r--chromium/ui/views/window/window_resize_utils.cc1
-rw-r--r--chromium/ui/views_content_client/BUILD.gn4
-rw-r--r--chromium/ui/views_content_client/views_content_client.cc5
-rw-r--r--chromium/ui/views_content_client/views_content_client.h8
-rw-r--r--chromium/ui/views_content_client/views_content_client_main_parts_desktop_aura.cc12
-rw-r--r--chromium/ui/views_content_client/views_content_main_delegate.cc3
-rw-r--r--chromium/ui/web_dialogs/web_dialog_web_contents_delegate.cc5
-rw-r--r--chromium/ui/web_dialogs/web_dialog_web_contents_delegate.h2
-rw-r--r--chromium/ui/webui/BUILD.gn5
-rw-r--r--chromium/ui/webui/DEPS1
-rw-r--r--chromium/ui/webui/PLATFORM_OWNERS1
-rw-r--r--chromium/ui/webui/resources/BUILD.gn18
-rw-r--r--chromium/ui/webui/resources/cr_components/BUILD.gn6
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/BUILD.gn343
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/ca_trust_edit_dialog.html16
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/ca_trust_edit_dialog.js19
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_delete_confirmation_dialog.html15
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_delete_confirmation_dialog.js18
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_entry.html16
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_entry.js14
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_list.html17
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_list.js18
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager.html27
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager.js28
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager_types.html1
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager_types.js28
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_decryption_dialog.html14
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_decryption_dialog.js17
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_encryption_dialog.html15
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_encryption_dialog.js18
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_browser_proxy.js74
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_details_dialog.html64
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_details_dialog.js65
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_entry.html25
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_entry.js65
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_list.html29
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_list.js124
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_shared_css.html5
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_shared_css.js10
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_subentry.html18
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificate_subentry.js21
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.html1
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.js53
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificates_error_dialog.html14
-rw-r--r--chromium/ui/webui/resources/cr_components/certificate_manager/certificates_error_dialog.js12
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/BUILD.gn8
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/cellular_setup/button_bar.html4
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/cellular_setup/cellular_setup.html5
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/multidevice_setup.html3
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/password_page.html2
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/setup_succeeded_page.html4
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/start_setup_page.html21
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/network/BUILD.gn404
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/network/mojo_interface_provider.js1
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/network/network_choose_mobile.html5
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/network/network_list_item.html3
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/network/network_property_list_mojo.html5
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/network/network_shared_css.html4
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/network/onc_mojo.js2
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/BUILD.gn62
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/lock_screen_constants.js46
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/pin_keyboard.html27
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/pin_keyboard_icon.html22
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/setup_pin_keyboard.html6
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/setup_pin_keyboard.js6
-rw-r--r--chromium/ui/webui/resources/cr_components/chromeos/smb_shares/BUILD.gn17
-rw-r--r--chromium/ui/webui/resources/cr_components/cr_components_resources.grdp100
-rw-r--r--chromium/ui/webui/resources/cr_components/cr_components_resources_v3.grdp73
-rw-r--r--chromium/ui/webui/resources/cr_components/omnibox/BUILD.gn11
-rw-r--r--chromium/ui/webui/resources/cr_elements/BUILD.gn5
-rw-r--r--chromium/ui/webui/resources/cr_elements/chromeos/BUILD.gn1
-rw-r--r--chromium/ui/webui/resources/cr_elements/chromeos/cr_lottie/BUILD.gn10
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_button/cr_button.js23
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_fingerprint/BUILD.gn13
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_fingerprint/cr_fingerprint_icon.html22
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_fingerprint/cr_fingerprint_progress_arc.html21
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_icon_button/cr_icon_button.js24
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_icons_css.html3
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_input/cr_input.js9
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_link_row/cr_link_row.html11
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_lottie/BUILD.gn42
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_lottie/cr_lottie.html (renamed from chromium/ui/webui/resources/cr_elements/chromeos/cr_lottie/cr_lottie.html)4
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_lottie/cr_lottie.js (renamed from chromium/ui/webui/resources/cr_elements/chromeos/cr_lottie/cr_lottie.js)3
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_searchable_drop_down/cr_searchable_drop_down.html6
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_slider/cr_slider.html7
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_toast/cr_toast.html1
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_toast/cr_toast.js28
-rw-r--r--chromium/ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.html24
-rw-r--r--chromium/ui/webui/resources/cr_elements/icons.html281
-rw-r--r--chromium/ui/webui/resources/cr_elements/policy/cr_tooltip_icon.html10
-rw-r--r--chromium/ui/webui/resources/cr_elements/shared_style_css.html46
-rw-r--r--chromium/ui/webui/resources/cr_elements/shared_vars_css.html32
-rw-r--r--chromium/ui/webui/resources/cr_elements_images.grdp2
-rw-r--r--chromium/ui/webui/resources/cr_elements_resources.grdp20
-rw-r--r--chromium/ui/webui/resources/cr_elements_resources_v3.grdp10
-rw-r--r--chromium/ui/webui/resources/css/cros_colors.json562
-rw-r--r--chromium/ui/webui/resources/js/cr/ui/tree.js21
-rw-r--r--chromium/ui/webui/resources/webui_resources.grd2
-rw-r--r--chromium/ui/webui/webui_allowlist.cc110
-rw-r--r--chromium/ui/webui/webui_allowlist.h52
-rw-r--r--chromium/ui/webui/webui_allowlist_provider.cc57
-rw-r--r--chromium/ui/webui/webui_allowlist_provider.h48
-rw-r--r--chromium/ui/wm/BUILD.gn9
-rw-r--r--chromium/ui/wm/core/capture_controller_unittest.cc1
-rw-r--r--chromium/ui/wm/core/compound_event_filter.cc19
-rw-r--r--chromium/ui/wm/core/compound_event_filter_unittest.cc20
-rw-r--r--chromium/ui/wm/core/cursor_manager.cc7
-rw-r--r--chromium/ui/wm/core/cursor_manager_unittest.cc2
-rw-r--r--chromium/ui/wm/core/shadow_controller.cc2
-rw-r--r--chromium/ui/wm/core/window_animations.cc3
1556 files changed, 27727 insertions, 26809 deletions
diff --git a/chromium/ui/PRESUBMIT.py b/chromium/ui/PRESUBMIT.py
deleted file mode 100644
index 810c0919e1f..00000000000
--- a/chromium/ui/PRESUBMIT.py
+++ /dev/null
@@ -1,47 +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.
-
-"""Presubmit script for ui.
-
-See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
-for more details about the presubmit API built into depot_tools.
-"""
-
-def CheckX11HeaderUsage(input_api, output_api):
- """X11 headers pollute the global namespace with macros for common
-names so instead code should include "ui/gfx/x/x11.h" which hide the
-dangerous macros inside the x11 namespace."""
-
- # Only check files in ui/gl and ui/gfx for now since that is the
- # only code converted.
-
- source_file_filter = lambda x: input_api.FilterSourceFile(
- x,
- white_list=tuple([r'.*ui[\\/].*\.(cc|h)$']))
- errors = []
- x11_include_pattern = input_api.re.compile(r'#include\s+<X11/.*\.h>')
- for f in input_api.AffectedSourceFiles(source_file_filter):
- if f.LocalPath().endswith(input_api.os_path.normpath("ui/gfx/x/x11.h")):
- # This is the only file that is allowed to include X11 headers.
- continue
- for line_number, line in f.ChangedContents():
- if input_api.re.search(x11_include_pattern, line):
- errors.append(output_api.PresubmitError(
- '%s:%d includes an X11 header. Include "ui/gfx/x/x11.h" instead.' %
- (f.LocalPath(), line_number)))
- return errors
-
-
-def CheckChange(input_api, output_api):
- results = []
- results += CheckX11HeaderUsage(input_api, output_api)
- return results
-
-
-def CheckChangeOnUpload(input_api, output_api):
- return CheckChange(input_api, output_api)
-
-
-def CheckChangeOnCommit(input_api, output_api):
- return CheckChange(input_api, output_api)
diff --git a/chromium/ui/accessibility/BUILD.gn b/chromium/ui/accessibility/BUILD.gn
index 97d2c4a62e1..fc74899db46 100644
--- a/chromium/ui/accessibility/BUILD.gn
+++ b/chromium/ui/accessibility/BUILD.gn
@@ -22,6 +22,10 @@ if (is_android) {
# TODO(crbug.com/1018739): remove this when migration is done.
set_sources_assignment_filter([])
+mojom("ax_constants_mojo") {
+ sources = [ "ax_constants.mojom" ]
+}
+
mojom_component("ax_enums_mojo") {
sources = [ "ax_enums.mojom" ]
@@ -29,19 +33,21 @@ mojom_component("ax_enums_mojo") {
output_prefix = "ui_accessibility_ax_mojom"
}
-mojom("ax_constants_mojo") {
- sources = [ "ax_constants.mojom" ]
-}
-
# A tiny subset of accessibility code that's allowed to be
# included by Blink. The rule of thumb (for now) is that it's
# anything platform-neutral (no platform/ directory) that
# relates to a single accessibility node (no trees, etc.).
jumbo_component("ax_base") {
+ defines = [ "AX_BASE_IMPLEMENTATION" ]
+
sources = [
"ax_base_export.h",
"ax_enum_util.cc",
"ax_enum_util.h",
+ "ax_event.cc",
+ "ax_event.h",
+ "ax_event_intent.cc",
+ "ax_event_intent.h",
"ax_node_data.cc",
"ax_node_data.h",
"ax_node_text_styles.cc",
@@ -50,8 +56,6 @@ jumbo_component("ax_base") {
"ax_relative_bounds.h",
"ax_role_properties.cc",
"ax_role_properties.h",
- "ax_text_utils.cc",
- "ax_text_utils.h",
]
public_deps = [
@@ -64,11 +68,11 @@ jumbo_component("ax_base") {
"//ui/gfx/geometry",
"//ui/strings",
]
-
- defines = [ "AX_BASE_IMPLEMENTATION" ]
}
jumbo_component("accessibility") {
+ defines = [ "AX_IMPLEMENTATION" ]
+
sources = [
"accessibility_features.cc",
"accessibility_features.h",
@@ -83,8 +87,6 @@ jumbo_component("accessibility") {
"ax_active_popup.h",
"ax_clipping_behavior.h",
"ax_coordinate_system.h",
- "ax_event.cc",
- "ax_event.h",
"ax_event_bundle_sink.h",
"ax_event_generator.cc",
"ax_event_generator.h",
@@ -105,6 +107,8 @@ jumbo_component("accessibility") {
"ax_serializable_tree.h",
"ax_table_info.cc",
"ax_table_info.h",
+ "ax_text_utils.cc",
+ "ax_text_utils.h",
"ax_tree.cc",
"ax_tree.h",
"ax_tree_combiner.cc",
@@ -128,8 +132,13 @@ jumbo_component("accessibility") {
"ax_tree_update_forward.h",
"null_ax_action_target.cc",
"null_ax_action_target.h",
+
+ # ax_android_constants* are used in ax_assistant_structure.cc.
"platform/ax_android_constants.cc",
"platform/ax_android_constants.h",
+
+ # ax_platform_node* are used for enable/disable accessibility and
+ # test_ax_node_wrapper.
"platform/ax_platform_node.cc",
"platform/ax_platform_node.h",
"platform/ax_platform_node_base.cc",
@@ -137,20 +146,29 @@ jumbo_component("accessibility") {
"platform/ax_platform_node_delegate.h",
"platform/ax_platform_node_delegate_base.cc",
"platform/ax_platform_node_delegate_base.h",
+
+ # ax_platform_node_test_helper.{cc,h} are used in
+ # browser_view_browsertest.cc
"platform/ax_platform_node_test_helper.cc",
"platform/ax_platform_node_test_helper.h",
+
+ # ax_unique_id.{cc,h} are used in browser_accessibility.cc and
+ # view_accessibility.cc
"platform/ax_unique_id.cc",
"platform/ax_unique_id.h",
+
+ # compute_attributes.{cc,h} are used in
+ # accessibility_tree_formatter_blink.cc
"platform/compute_attributes.cc",
"platform/compute_attributes.h",
]
- if (is_win) {
- sources += [
- "platform/ax_platform_node_delegate_utils_win.cc",
- "platform/ax_platform_node_delegate_utils_win.h",
- ]
- }
+ deps = [ "//third_party/cld_3/src/src:cld_3" ]
+
+ public_deps = [
+ ":ax_base",
+ "//ui/display",
+ ]
if (has_native_accessibility) {
sources += [
@@ -163,51 +181,36 @@ jumbo_component("accessibility") {
# config to ensure anything that includes this is able to find atk.h.
public_configs = [ "//build/config/linux/atk" ]
}
-
- if (is_mac) {
- sources += [
- "platform/ax_platform_node_mac.h",
- "platform/ax_platform_node_mac.mm",
- ]
- }
-
- if (is_win) {
- sources += [
- "platform/ax_fragment_root_delegate_win.h",
- "platform/ax_fragment_root_win.cc",
- "platform/ax_fragment_root_win.h",
- "platform/ax_platform_node_textchildprovider_win.cc",
- "platform/ax_platform_node_textchildprovider_win.h",
- "platform/ax_platform_node_textprovider_win.cc",
- "platform/ax_platform_node_textprovider_win.h",
- "platform/ax_platform_node_textrangeprovider_win.cc",
- "platform/ax_platform_node_textrangeprovider_win.h",
- "platform/ax_platform_node_win.cc",
- "platform/ax_platform_node_win.h",
- "platform/ax_platform_relation_win.cc",
- "platform/ax_platform_relation_win.h",
- "platform/ax_system_caret_win.cc",
- "platform/ax_system_caret_win.h",
- ]
- }
}
- defines = [ "AX_IMPLEMENTATION" ]
+ if (is_win) {
+ sources += [
+ "platform/ax_fragment_root_delegate_win.h",
+ "platform/ax_fragment_root_win.cc",
+ "platform/ax_fragment_root_win.h",
+ "platform/ax_platform_node_delegate_utils_win.cc",
+ "platform/ax_platform_node_delegate_utils_win.h",
+ "platform/ax_platform_node_textchildprovider_win.cc",
+ "platform/ax_platform_node_textchildprovider_win.h",
+ "platform/ax_platform_node_textprovider_win.cc",
+ "platform/ax_platform_node_textprovider_win.h",
+ "platform/ax_platform_node_textrangeprovider_win.cc",
+ "platform/ax_platform_node_textrangeprovider_win.h",
+ "platform/ax_platform_node_win.cc",
+ "platform/ax_platform_node_win.h",
+ "platform/ax_platform_relation_win.cc",
+ "platform/ax_platform_relation_win.h",
+ "platform/ax_system_caret_win.cc",
+ "platform/ax_system_caret_win.h",
+ ]
- deps = [ "//third_party/cld_3/src/src:cld_3" ]
+ public_deps += [ "//third_party/iaccessible2" ]
- public_deps = [
- ":ax_base",
- ":ax_constants_mojo",
- ":ax_enums_mojo",
- "//base",
- "//base:i18n",
- "//ui/base",
- "//ui/display",
- "//ui/gfx",
- "//ui/gfx/geometry",
- "//ui/strings",
- ]
+ libs = [
+ "oleacc.lib",
+ "uiautomationcore.lib",
+ ]
+ }
if (!is_ios) {
sources += [
@@ -222,15 +225,12 @@ jumbo_component("accessibility") {
]
}
- if (is_win) {
- public_deps += [ "//third_party/iaccessible2" ]
- libs = [
- "oleacc.lib",
- "uiautomationcore.lib",
+ if (is_mac) {
+ sources += [
+ "platform/ax_platform_node_mac.h",
+ "platform/ax_platform_node_mac.mm",
]
- }
- if (is_mac) {
libs = [
"AppKit.framework",
"Foundation.framework",
@@ -253,12 +253,16 @@ jumbo_component("accessibility") {
if (use_glib) {
configs += [ "//build/config/linux:glib" ]
}
+
+ if (use_x11) {
+ public_deps += [ "//ui/gfx/x" ]
+ }
}
if (use_aura) {
sources += [
- "platform/aura_window_properties.cc",
- "platform/aura_window_properties.h",
+ "aura/aura_window_properties.cc",
+ "aura/aura_window_properties.h",
]
public_deps += [ "//ui/aura" ]
@@ -270,12 +274,14 @@ source_set("ax_assistant") {
"ax_assistant_structure.cc",
"ax_assistant_structure.h",
]
+
deps = [ ":accessibility" ]
}
static_library("test_support") {
testonly = true
sources = [
+ # test_ax_node_wrapper.{cc,h} are used in ax_range_unittest.cc
"platform/test_ax_node_wrapper.cc",
"platform/test_ax_node_wrapper.h",
"test_ax_tree_manager.cc",
@@ -305,6 +311,7 @@ test("accessibility_unittests") {
"ax_tree_source_checker_unittest.cc",
"ax_tree_unittest.cc",
"mojom/ax_action_data_mojom_traits_unittest.cc",
+ "mojom/ax_event_intent_mojom_traits_unittest.cc",
"mojom/ax_event_mojom_traits_unittest.cc",
"mojom/ax_node_data_mojom_traits_unittest.cc",
"mojom/ax_relative_bounds_mojom_traits_unittest.cc",
@@ -329,18 +336,15 @@ test("accessibility_unittests") {
]
}
- if (!is_chromeos) {
- # NativeViewAccessible, on which this test heavily depends, is not
- # implemented on Chrome OS.
+ if (has_native_accessibility) {
+ # This test depends heavily on NativeViewAccessible, which is only
+ # implemented on these platforms.
sources += [ "platform/ax_platform_node_base_unittest.cc" ]
}
deps = [
":accessibility",
- ":ax_constants_mojo",
- ":ax_enums_mojo",
":test_support",
- "//base",
"//base/test:test_support",
"//ipc",
"//mojo/core/embedder",
@@ -350,24 +354,24 @@ test("accessibility_unittests") {
"//testing/gmock",
"//testing/gtest",
"//ui/accessibility/mojom",
- "//ui/base",
- "//ui/gfx",
"//ui/gfx:test_support",
- "//ui/gfx/geometry",
]
if (is_win) {
deps += [ "//third_party/iaccessible2" ]
+
libs = [
"oleacc.lib",
"uiautomationcore.lib",
]
}
+
if (use_atk) {
sources += [
"platform/atk_util_auralinux_unittest.cc",
"platform/ax_platform_node_auralinux_unittest.cc",
]
+
configs += [ "//build/config/linux/atk" ]
}
}
diff --git a/chromium/ui/accessibility/PRESUBMIT.py b/chromium/ui/accessibility/PRESUBMIT.py
index 15c4f2c3481..51a54692396 100644
--- a/chromium/ui/accessibility/PRESUBMIT.py
+++ b/chromium/ui/accessibility/PRESUBMIT.py
@@ -149,6 +149,12 @@ def CheckEnumsMatch(input_api, output_api):
'DefaultActionVerb', errs, output_api)
CheckMatchingEnum(ax_enums, 'MarkerType', automation_enums,
'MarkerType', errs, output_api)
+ CheckMatchingEnum(ax_enums, 'Command', automation_enums,
+ 'EventCommandType', errs, output_api)
+ CheckMatchingEnum(ax_enums, 'TextBoundary', automation_enums,
+ 'EventTextBoundaryType', errs, output_api)
+ CheckMatchingEnum(ax_enums, 'MoveDirection', automation_enums,
+ 'EventMoveDirectionType', errs, output_api)
return errs
# Given a full path to c++ header, return an array of the first static
diff --git a/chromium/ui/accessibility/accessibility_switches.cc b/chromium/ui/accessibility/accessibility_switches.cc
index 2a5d137877e..334319dac24 100644
--- a/chromium/ui/accessibility/accessibility_switches.cc
+++ b/chromium/ui/accessibility/accessibility_switches.cc
@@ -40,13 +40,17 @@ const char kEnableExperimentalAccessibilitySwitchAccessText[] =
const char kEnableExperimentalAccessibilityChromeVoxAnnotations[] =
"enable-experimental-accessibility-chromevox-annotations";
-// Enables language switching feature that hasn't launched yet.
-const char kEnableExperimentalAccessibilityChromeVoxLanguageSwitching[] =
- "enable-experimental-accessibility-chromevox-language-switching";
+// Disables ChromeVox language switching feature.
+const char kDisableExperimentalAccessibilityChromeVoxLanguageSwitching[] =
+ "disable-experimental-accessibility-chromevox-language-switching";
-// Enables search bar to search the ChromeVox menus.
-const char kEnableExperimentalAccessibilityChromeVoxSearchMenus[] =
- "enable-experimental-accessibility-chromevox-search-menus";
+// Disables ChromeVox search menus feature.
+const char kDisableExperimentalAccessibilityChromeVoxSearchMenus[] =
+ "disable-experimental-accessibility-chromevox-search-menus";
+
+// Enables interactive tutorial for ChromeVox.
+const char kEnableExperimentalAccessibilityChromeVoxTutorial[] =
+ "enable-experimental-accessibility-chromevox-tutorial";
bool IsExperimentalAccessibilityLanguageDetectionEnabled() {
return base::CommandLine::ForCurrentProcess()->HasSwitch(
diff --git a/chromium/ui/accessibility/accessibility_switches.h b/chromium/ui/accessibility/accessibility_switches.h
index 631f82a2601..3cc38c37f10 100644
--- a/chromium/ui/accessibility/accessibility_switches.h
+++ b/chromium/ui/accessibility/accessibility_switches.h
@@ -21,9 +21,10 @@ AX_EXPORT extern const char kEnableExperimentalAccessibilitySwitchAccessText[];
AX_EXPORT extern const char
kEnableExperimentalAccessibilityChromeVoxAnnotations[];
AX_EXPORT extern const char
- kEnableExperimentalAccessibilityChromeVoxLanguageSwitching[];
+ kDisableExperimentalAccessibilityChromeVoxLanguageSwitching[];
AX_EXPORT extern const char
- kEnableExperimentalAccessibilityChromeVoxSearchMenus[];
+ kDisableExperimentalAccessibilityChromeVoxSearchMenus[];
+AX_EXPORT extern const char kEnableExperimentalAccessibilityChromeVoxTutorial[];
// Returns true if experimental accessibility language detection is enabled.
AX_EXPORT bool IsExperimentalAccessibilityLanguageDetectionEnabled();
diff --git a/chromium/ui/accessibility/platform/aura_window_properties.cc b/chromium/ui/accessibility/aura/aura_window_properties.cc
index bbd55bf6080..a9473d84c79 100644
--- a/chromium/ui/accessibility/platform/aura_window_properties.cc
+++ b/chromium/ui/accessibility/aura/aura_window_properties.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/accessibility/platform/aura_window_properties.h"
+#include "ui/accessibility/aura/aura_window_properties.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_tree_id.h"
diff --git a/chromium/ui/accessibility/platform/aura_window_properties.h b/chromium/ui/accessibility/aura/aura_window_properties.h
index bee79a4f6b7..9fa2b82fa69 100644
--- a/chromium/ui/accessibility/platform/aura_window_properties.h
+++ b/chromium/ui/accessibility/aura/aura_window_properties.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_ACCESSIBILITY_PLATFORM_AURA_WINDOW_PROPERTIES_H_
-#define UI_ACCESSIBILITY_PLATFORM_AURA_WINDOW_PROPERTIES_H_
+#ifndef UI_ACCESSIBILITY_AURA_AURA_WINDOW_PROPERTIES_H_
+#define UI_ACCESSIBILITY_AURA_AURA_WINDOW_PROPERTIES_H_
#include <string>
@@ -24,4 +24,4 @@ AX_EXPORT extern const aura::WindowProperty<ax::mojom::Role>* const
} // namespace ui
-#endif // UI_ACCESSIBILITY_PLATFORM_AURA_WINDOW_PROPERTIES_H_
+#endif // UI_ACCESSIBILITY_AURA_AURA_WINDOW_PROPERTIES_H_
diff --git a/chromium/ui/accessibility/ax_base_export.h b/chromium/ui/accessibility/ax_base_export.h
index bab8cb59074..e2c7be31be5 100644
--- a/chromium/ui/accessibility/ax_base_export.h
+++ b/chromium/ui/accessibility/ax_base_export.h
@@ -1,4 +1,4 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
+// Copyright 2020 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.
diff --git a/chromium/ui/accessibility/ax_enum_util.cc b/chromium/ui/accessibility/ax_enum_util.cc
index d4a8d1a2fcd..35bbef5afc6 100644
--- a/chromium/ui/accessibility/ax_enum_util.cc
+++ b/chromium/ui/accessibility/ax_enum_util.cc
@@ -6,6 +6,9 @@
#include "ui/accessibility/ax_enums.mojom.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/strings/grit/ui_strings.h"
+
namespace ui {
const char* ToString(ax::mojom::Event event) {
@@ -471,6 +474,8 @@ const char* ToString(ax::mojom::Role role) {
return "imageMap";
case ax::mojom::Role::kImage:
return "image";
+ case ax::mojom::Role::kImeCandidate:
+ return "imeCandidate";
case ax::mojom::Role::kInlineTextBox:
return "inlineTextBox";
case ax::mojom::Role::kInputTime:
@@ -855,6 +860,8 @@ ax::mojom::Role ParseRole(const char* role) {
return ax::mojom::Role::kImageMap;
if (0 == strcmp(role, "image"))
return ax::mojom::Role::kImage;
+ if (0 == strcmp(role, "imeCandidate"))
+ return ax::mojom::Role::kImeCandidate;
if (0 == strcmp(role, "inlineTextBox"))
return ax::mojom::Role::kInlineTextBox;
if (0 == strcmp(role, "inputTime"))
@@ -1335,7 +1342,9 @@ const char* ToString(ax::mojom::DefaultActionVerb default_action_verb) {
case ax::mojom::DefaultActionVerb::kClick:
return "click";
case ax::mojom::DefaultActionVerb::kClickAncestor:
- return "clickAncestor";
+ // Some screen readers, such as Jaws, expect the following spelling of
+ // this verb.
+ return "click-ancestor";
case ax::mojom::DefaultActionVerb::kJump:
return "jump";
case ax::mojom::DefaultActionVerb::kOpen:
@@ -1351,6 +1360,33 @@ const char* ToString(ax::mojom::DefaultActionVerb default_action_verb) {
return "";
}
+std::string ToLocalizedString(ax::mojom::DefaultActionVerb action_verb) {
+ switch (action_verb) {
+ case ax::mojom::DefaultActionVerb::kNone:
+ return "";
+ case ax::mojom::DefaultActionVerb::kActivate:
+ return l10n_util::GetStringUTF8(IDS_AX_ACTIVATE_ACTION_VERB);
+ case ax::mojom::DefaultActionVerb::kCheck:
+ return l10n_util::GetStringUTF8(IDS_AX_CHECK_ACTION_VERB);
+ case ax::mojom::DefaultActionVerb::kClick:
+ return l10n_util::GetStringUTF8(IDS_AX_CLICK_ACTION_VERB);
+ case ax::mojom::DefaultActionVerb::kClickAncestor:
+ return l10n_util::GetStringUTF8(IDS_AX_CLICK_ANCESTOR_ACTION_VERB);
+ case ax::mojom::DefaultActionVerb::kJump:
+ return l10n_util::GetStringUTF8(IDS_AX_JUMP_ACTION_VERB);
+ case ax::mojom::DefaultActionVerb::kOpen:
+ return l10n_util::GetStringUTF8(IDS_AX_OPEN_ACTION_VERB);
+ case ax::mojom::DefaultActionVerb::kPress:
+ return l10n_util::GetStringUTF8(IDS_AX_PRESS_ACTION_VERB);
+ case ax::mojom::DefaultActionVerb::kSelect:
+ return l10n_util::GetStringUTF8(IDS_AX_SELECT_ACTION_VERB);
+ case ax::mojom::DefaultActionVerb::kUncheck:
+ return l10n_util::GetStringUTF8(IDS_AX_UNCHECK_ACTION_VERB);
+ }
+
+ return "";
+}
+
ax::mojom::DefaultActionVerb ParseDefaultActionVerb(
const char* default_action_verb) {
if (0 == strcmp(default_action_verb, "none"))
@@ -1361,7 +1397,9 @@ ax::mojom::DefaultActionVerb ParseDefaultActionVerb(
return ax::mojom::DefaultActionVerb::kCheck;
if (0 == strcmp(default_action_verb, "click"))
return ax::mojom::DefaultActionVerb::kClick;
- if (0 == strcmp(default_action_verb, "clickAncestor"))
+ // Some screen readers, such as Jaws, expect the following spelling of this
+ // verb.
+ if (0 == strcmp(default_action_verb, "click-ancestor"))
return ax::mojom::DefaultActionVerb::kClickAncestor;
if (0 == strcmp(default_action_verb, "jump"))
return ax::mojom::DefaultActionVerb::kJump;
@@ -2088,79 +2126,69 @@ ax::mojom::MoveDirection ParseMoveDirection(const char* move_direction) {
return ax::mojom::MoveDirection::kForward;
}
-const char* ToString(ax::mojom::EditCommand edit_command) {
- switch (edit_command) {
- case ax::mojom::EditCommand::kType:
- return "type";
- case ax::mojom::EditCommand::kCut:
+const char* ToString(ax::mojom::Command command) {
+ switch (command) {
+ case ax::mojom::Command::kClearSelection:
+ return "clearSelection";
+ case ax::mojom::Command::kCut:
return "cut";
- case ax::mojom::EditCommand::kDelete:
+ case ax::mojom::Command::kDelete:
return "delete";
- case ax::mojom::EditCommand::kDictate:
+ case ax::mojom::Command::kDictate:
return "dictate";
- case ax::mojom::EditCommand::kFormat:
+ case ax::mojom::Command::kExtendSelection:
+ return "extendSelection";
+ case ax::mojom::Command::kFormat:
return "format";
- case ax::mojom::EditCommand::kInsert:
+ case ax::mojom::Command::kInsert:
return "insert";
- case ax::mojom::EditCommand::kMarker:
+ case ax::mojom::Command::kMarker:
return "marker";
- case ax::mojom::EditCommand::kPaste:
+ case ax::mojom::Command::kMoveSelection:
+ return "moveSelection";
+ case ax::mojom::Command::kPaste:
return "paste";
- case ax::mojom::EditCommand::kReplace:
+ case ax::mojom::Command::kReplace:
return "replace";
+ case ax::mojom::Command::kSetSelection:
+ return "setSelection";
+ case ax::mojom::Command::kType:
+ return "type";
}
return "";
}
-ax::mojom::EditCommand ParseEditCommand(const char* edit_command) {
- if (0 == strcmp(edit_command, "type"))
- return ax::mojom::EditCommand::kType;
- if (0 == strcmp(edit_command, "cut"))
- return ax::mojom::EditCommand::kCut;
- if (0 == strcmp(edit_command, "delete"))
- return ax::mojom::EditCommand::kDelete;
- if (0 == strcmp(edit_command, "dictate"))
- return ax::mojom::EditCommand::kDictate;
- if (0 == strcmp(edit_command, "format"))
- return ax::mojom::EditCommand::kFormat;
- if (0 == strcmp(edit_command, "insert"))
- return ax::mojom::EditCommand::kInsert;
- if (0 == strcmp(edit_command, "marker"))
- return ax::mojom::EditCommand::kMarker;
- if (0 == strcmp(edit_command, "paste"))
- return ax::mojom::EditCommand::kPaste;
- if (0 == strcmp(edit_command, "replace"))
- return ax::mojom::EditCommand::kReplace;
- return ax::mojom::EditCommand::kType;
-}
-
-const char* ToString(ax::mojom::SelectionCommand selection_command) {
- switch (selection_command) {
- case ax::mojom::SelectionCommand::kSet:
- return "set";
- case ax::mojom::SelectionCommand::kClear:
- return "clear";
- case ax::mojom::SelectionCommand::kShrink:
- return "shrink";
- case ax::mojom::SelectionCommand::kExtend:
- return "extend";
- }
-
- return "";
-}
-
-ax::mojom::SelectionCommand ParseSelectionCommand(
- const char* selection_command) {
- if (0 == strcmp(selection_command, "set"))
- return ax::mojom::SelectionCommand::kSet;
- if (0 == strcmp(selection_command, "clear"))
- return ax::mojom::SelectionCommand::kClear;
- if (0 == strcmp(selection_command, "shrink"))
- return ax::mojom::SelectionCommand::kShrink;
- if (0 == strcmp(selection_command, "extend"))
- return ax::mojom::SelectionCommand::kExtend;
- return ax::mojom::SelectionCommand::kSet;
+ax::mojom::Command ParseCommand(const char* command) {
+ if (0 == strcmp(command, "clearSelection"))
+ return ax::mojom::Command::kClearSelection;
+ if (0 == strcmp(command, "cut"))
+ return ax::mojom::Command::kCut;
+ if (0 == strcmp(command, "delete"))
+ return ax::mojom::Command::kDelete;
+ if (0 == strcmp(command, "dictate"))
+ return ax::mojom::Command::kDictate;
+ if (0 == strcmp(command, "extendSelection"))
+ return ax::mojom::Command::kExtendSelection;
+ if (0 == strcmp(command, "format"))
+ return ax::mojom::Command::kFormat;
+ if (0 == strcmp(command, "insert"))
+ return ax::mojom::Command::kInsert;
+ if (0 == strcmp(command, "marker"))
+ return ax::mojom::Command::kMarker;
+ if (0 == strcmp(command, "moveSelection"))
+ return ax::mojom::Command::kMoveSelection;
+ if (0 == strcmp(command, "paste"))
+ return ax::mojom::Command::kPaste;
+ if (0 == strcmp(command, "replace"))
+ return ax::mojom::Command::kReplace;
+ if (0 == strcmp(command, "setSelection"))
+ return ax::mojom::Command::kSetSelection;
+ if (0 == strcmp(command, "type"))
+ return ax::mojom::Command::kType;
+
+ // Return the default command.
+ return ax::mojom::Command::kType;
}
const char* ToString(ax::mojom::TextBoundary text_boundary) {
@@ -2884,20 +2912,6 @@ ax::mojom::ImageAnnotationStatus ParseImageAnnotationStatus(
return ax::mojom::ImageAnnotationStatus::kNone;
}
-ax::mojom::Dropeffect ParseDropeffect(const char* dropeffect) {
- if (0 == strcmp(dropeffect, "copy"))
- return ax::mojom::Dropeffect::kCopy;
- if (0 == strcmp(dropeffect, "execute"))
- return ax::mojom::Dropeffect::kExecute;
- if (0 == strcmp(dropeffect, "link"))
- return ax::mojom::Dropeffect::kLink;
- if (0 == strcmp(dropeffect, "move"))
- return ax::mojom::Dropeffect::kMove;
- if (0 == strcmp(dropeffect, "popup"))
- return ax::mojom::Dropeffect::kPopup;
- return ax::mojom::Dropeffect::kNone;
-}
-
const char* ToString(ax::mojom::Dropeffect dropeffect) {
switch (dropeffect) {
case ax::mojom::Dropeffect::kCopy:
@@ -2917,4 +2931,18 @@ const char* ToString(ax::mojom::Dropeffect dropeffect) {
return "";
}
+ax::mojom::Dropeffect ParseDropeffect(const char* dropeffect) {
+ if (0 == strcmp(dropeffect, "copy"))
+ return ax::mojom::Dropeffect::kCopy;
+ if (0 == strcmp(dropeffect, "execute"))
+ return ax::mojom::Dropeffect::kExecute;
+ if (0 == strcmp(dropeffect, "link"))
+ return ax::mojom::Dropeffect::kLink;
+ if (0 == strcmp(dropeffect, "move"))
+ return ax::mojom::Dropeffect::kMove;
+ if (0 == strcmp(dropeffect, "popup"))
+ return ax::mojom::Dropeffect::kPopup;
+ return ax::mojom::Dropeffect::kNone;
+}
+
} // namespace ui
diff --git a/chromium/ui/accessibility/ax_enum_util.h b/chromium/ui/accessibility/ax_enum_util.h
index 89425cae6fa..d64fea15a8f 100644
--- a/chromium/ui/accessibility/ax_enum_util.h
+++ b/chromium/ui/accessibility/ax_enum_util.h
@@ -5,6 +5,8 @@
#ifndef UI_ACCESSIBILITY_AX_ENUM_UTIL_H_
#define UI_ACCESSIBILITY_AX_ENUM_UTIL_H_
+#include <string>
+
#include "ui/accessibility/ax_base_export.h"
#include "ui/accessibility/ax_enums.mojom-forward.h"
@@ -34,6 +36,11 @@ AX_BASE_EXPORT ax::mojom::ActionFlags ParseActionFlags(
// ax::mojom::DefaultActionVerb
AX_BASE_EXPORT const char* ToString(
ax::mojom::DefaultActionVerb default_action_verb);
+
+// Returns a localized string that corresponds to the name of the given action.
+AX_BASE_EXPORT std::string ToLocalizedString(
+ ax::mojom::DefaultActionVerb action_verb);
+
AX_BASE_EXPORT ax::mojom::DefaultActionVerb ParseDefaultActionVerb(
const char* default_action_verb);
@@ -87,16 +94,9 @@ AX_BASE_EXPORT const char* ToString(ax::mojom::MoveDirection move_direction);
AX_BASE_EXPORT ax::mojom::MoveDirection ParseMoveDirection(
const char* move_direction);
-// ax::mojom::EditCommand
-AX_BASE_EXPORT const char* ToString(ax::mojom::EditCommand edit_command);
-AX_BASE_EXPORT ax::mojom::EditCommand ParseEditCommand(
- const char* edit_command);
-
-// ax::mojom::SelectionCommand
-AX_BASE_EXPORT const char* ToString(
- ax::mojom::SelectionCommand selection_command);
-AX_BASE_EXPORT ax::mojom::SelectionCommand ParseSelectionCommand(
- const char* selection_command);
+// ax::mojom::Command
+AX_BASE_EXPORT const char* ToString(ax::mojom::Command command);
+AX_BASE_EXPORT ax::mojom::Command ParseCommand(const char* command);
// ax::mojom::TextBoundary
AX_BASE_EXPORT const char* ToString(ax::mojom::TextBoundary text_boundary);
diff --git a/chromium/ui/accessibility/ax_enum_util_unittest.cc b/chromium/ui/accessibility/ax_enum_util_unittest.cc
index 88f039de731..fd09b715113 100644
--- a/chromium/ui/accessibility/ax_enum_util_unittest.cc
+++ b/chromium/ui/accessibility/ax_enum_util_unittest.cc
@@ -4,6 +4,9 @@
#include "ui/accessibility/ax_enum_util.h"
+#include <string>
+#include <vector>
+
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
@@ -157,12 +160,8 @@ TEST(AXEnumUtilTest, MoveDirection) {
TestEnumStringConversion<ax::mojom::MoveDirection>(ParseMoveDirection);
}
-TEST(AXEnumUtilTest, EditCommand) {
- TestEnumStringConversion<ax::mojom::EditCommand>(ParseEditCommand);
-}
-
-TEST(AXEnumUtilTest, SelectionCommand) {
- TestEnumStringConversion<ax::mojom::SelectionCommand>(ParseSelectionCommand);
+TEST(AXEnumUtilTest, Command) {
+ TestEnumStringConversion<ax::mojom::Command>(ParseCommand);
}
TEST(AXEnumUtilTest, TextBoundary) {
diff --git a/chromium/ui/accessibility/ax_enums.mojom b/chromium/ui/accessibility/ax_enums.mojom
index 877976f0e72..a5c0fc5884f 100644
--- a/chromium/ui/accessibility/ax_enums.mojom
+++ b/chromium/ui/accessibility/ax_enums.mojom
@@ -216,6 +216,7 @@ enum Role {
kIgnored,
kImage,
kImageMap,
+ kImeCandidate,
kInlineTextBox,
kInputTime,
kKeyboard,
@@ -242,7 +243,7 @@ enum Role {
kMath,
kMenu,
kMenuBar,
- kMenuButton,
+ kMenuButton, // TODO: kMenuButton is not used anywhere, consider removal.
kMenuItem,
kMenuItemCheckBox,
kMenuItemRadio,
@@ -838,29 +839,25 @@ enum MoveDirection {
kNone = kForward
};
-// Describes the edit command that resulted in a text changed event.
-enum EditCommand {
+// Describes the edit or selection command that resulted in a selection or a
+// text changed event.
+enum Command {
+ kClearSelection,
kCut,
kDelete,
kDictate,
- kFormat, // Only the text attributes, such as font size, have changed.
+ kExtendSelection, // The existing selection has been extended or shrunk.
+ kFormat, // The text attributes, such as font size, have changed.
kInsert,
- kMarker, // Only a document marker has been added or removed.
+ kMarker, // A document marker has been added or removed.
+ kMoveSelection, // The selection has been moved by a specific granularity.
kPaste,
kReplace,
+ kSetSelection, // A completely new selection has been set.
kType,
kNone = kType
};
-// Describes the selection command that resulted in a selection changed event.
-enum SelectionCommand {
- kClear,
- kShrink,
- kExtend,
- kSet, // Sets a completely new selection.
- kNone = kSet
-};
-
// Defines a set of text boundaries in the accessibility tree.
//
// Most boundaries come in three flavors: A "WordStartOrEnd" boundary for
diff --git a/chromium/ui/accessibility/ax_event.cc b/chromium/ui/accessibility/ax_event.cc
index 45400e461ec..34327f466f1 100644
--- a/chromium/ui/accessibility/ax_event.cc
+++ b/chromium/ui/accessibility/ax_event.cc
@@ -6,18 +6,28 @@
#include "base/strings/string_number_conversions.h"
#include "ui/accessibility/ax_enum_util.h"
-#include "ui/accessibility/ax_enums.mojom.h"
namespace ui {
-// Mojo enums are initialized here so the header can include the much smaller
-// mojom-forward.h header.
-AXEvent::AXEvent()
- : event_type(ax::mojom::Event::kNone),
- event_from(ax::mojom::EventFrom::kNone) {}
+AXEvent::AXEvent() = default;
+
+AXEvent::AXEvent(AXNodeData::AXID id,
+ ax::mojom::Event event_type,
+ ax::mojom::EventFrom event_from,
+ const std::vector<AXEventIntent>& event_intents,
+ int action_request_id)
+ : id(id),
+ event_type(event_type),
+ event_from(event_from),
+ event_intents(event_intents),
+ action_request_id(action_request_id) {}
AXEvent::~AXEvent() = default;
+AXEvent::AXEvent(const AXEvent& event) = default;
+
+AXEvent& AXEvent::operator=(const AXEvent& event) = default;
+
std::string AXEvent::ToString() const {
std::string result = "AXEvent";
@@ -25,6 +35,13 @@ std::string AXEvent::ToString() const {
result += " on node id=" + base::NumberToString(id);
if (event_from != ax::mojom::EventFrom::kNone)
result += std::string(" from ") + ui::ToString(event_from);
+ if (!event_intents.empty()) {
+ result += " caused by [ ";
+ for (const AXEventIntent& intent : event_intents) {
+ result += intent.ToString() + ' ';
+ }
+ result += ']';
+ }
if (action_request_id)
result += " action_request_id=" + base::NumberToString(action_request_id);
return result;
diff --git a/chromium/ui/accessibility/ax_event.h b/chromium/ui/accessibility/ax_event.h
index c16e347e51d..86869b617ca 100644
--- a/chromium/ui/accessibility/ax_event.h
+++ b/chromium/ui/accessibility/ax_event.h
@@ -6,30 +6,47 @@
#define UI_ACCESSIBILITY_AX_EVENT_H_
#include <string>
+#include <vector>
-#include "ui/accessibility/ax_enums.mojom-forward.h"
-#include "ui/accessibility/ax_export.h"
+#include "ui/accessibility/ax_base_export.h"
+#include "ui/accessibility/ax_enums.mojom.h"
+#include "ui/accessibility/ax_event_intent.h"
+#include "ui/accessibility/ax_node_data.h"
namespace ui {
-struct AX_EXPORT AXEvent {
+struct AX_BASE_EXPORT AXEvent final {
AXEvent();
+ AXEvent(AXNodeData::AXID id,
+ ax::mojom::Event event_type,
+ ax::mojom::EventFrom event_from = ax::mojom::EventFrom::kNone,
+ const std::vector<AXEventIntent>& event_intents = {},
+ int action_request_id = -1);
virtual ~AXEvent();
-
- // The type of event.
- ax::mojom::Event event_type;
+ AXEvent(const AXEvent& event);
+ AXEvent& operator=(const AXEvent& event);
// The id of the node in the AXTree that the event should be fired on.
- int id = -1;
+ AXNodeData::AXID id = AXNodeData::kInvalidAXID;
+
+ // The type of event.
+ ax::mojom::Event event_type = ax::mojom::Event::kNone;
// The source of the event.
- ax::mojom::EventFrom event_from;
+ ax::mojom::EventFrom event_from = ax::mojom::EventFrom::kNone;
+
+ // Describes what caused an accessibility event to be raised. For example, in
+ // the case of a selection changed event, the selection could have been
+ // extended to the beginning of the previous word, or it could have been moved
+ // to the end of the next line. Note that there could be multiple causes that
+ // resulted in an event.
+ std::vector<AXEventIntent> event_intents;
// The action request ID that was passed in if this event was fired in
// direct response to a ax::mojom::Action.
int action_request_id = -1;
- // Return a string representation of this data, for debugging.
+ // Returns a string representation of this data, for debugging.
std::string ToString() const;
};
diff --git a/chromium/ui/accessibility/ax_event_generator.cc b/chromium/ui/accessibility/ax_event_generator.cc
index 8d395511bed..472dd5b1579 100644
--- a/chromium/ui/accessibility/ax_event_generator.cc
+++ b/chromium/ui/accessibility/ax_event_generator.cc
@@ -47,17 +47,6 @@ void RemoveEvent(std::set<AXEventGenerator::EventParams>* node_events,
}
}
-bool HasOtherLiveRegionEvent(
- const std::set<AXEventGenerator::EventParams>& events) {
- auto is_live_region_event = [](const AXEventGenerator::EventParams& params) {
- return params.event == AXEventGenerator::Event::ALERT ||
- params.event == AXEventGenerator::Event::LIVE_REGION_CREATED;
- };
-
- return std::find_if(events.begin(), events.end(), is_live_region_event) !=
- events.end();
-}
-
} // namespace
AXEventGenerator::EventParams::EventParams(Event event,
@@ -149,31 +138,6 @@ void AXEventGenerator::AddEvent(AXNode* node, AXEventGenerator::Event event) {
return;
std::set<EventParams>& node_events = tree_events_[node];
-
- // A newly created live region or alert should not *also* fire a
- // live region changed event.
- if (event == Event::LIVE_REGION_CHANGED &&
- HasOtherLiveRegionEvent(node_events)) {
- return;
- }
-
- // We shouldn't fire children changed events on nodes that become
- // ignored or unignored.
- if (event == Event::IGNORED_CHANGED) {
- for (auto& iter : node_events) {
- if (iter.event == Event::CHILDREN_CHANGED) {
- node_events.erase(iter);
- break;
- }
- }
- }
- if (event == Event::CHILDREN_CHANGED) {
- for (auto& iter : node_events) {
- if (iter.event == Event::IGNORED_CHANGED)
- return;
- }
- }
-
node_events.emplace(event, ax::mojom::EventFrom::kNone);
}
diff --git a/chromium/ui/accessibility/ax_event_intent.cc b/chromium/ui/accessibility/ax_event_intent.cc
new file mode 100644
index 00000000000..cb167a5142d
--- /dev/null
+++ b/chromium/ui/accessibility/ax_event_intent.cc
@@ -0,0 +1,40 @@
+// Copyright 2020 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 "ui/accessibility/ax_event_intent.h"
+
+#include "ui/accessibility/ax_enum_util.h"
+
+namespace ui {
+
+AXEventIntent::AXEventIntent() = default;
+
+AXEventIntent::AXEventIntent(ax::mojom::Command command,
+ ax::mojom::TextBoundary text_boundary,
+ ax::mojom::MoveDirection move_direction)
+ : command(command),
+ text_boundary(text_boundary),
+ move_direction(move_direction) {}
+
+AXEventIntent::~AXEventIntent() = default;
+
+AXEventIntent::AXEventIntent(const AXEventIntent& intent) = default;
+
+AXEventIntent& AXEventIntent::operator=(const AXEventIntent& intent) = default;
+
+bool operator==(const AXEventIntent& a, const AXEventIntent& b) {
+ return a.command == b.command && a.text_boundary == b.text_boundary &&
+ a.move_direction == b.move_direction;
+}
+
+bool operator!=(const AXEventIntent& a, const AXEventIntent& b) {
+ return !(a == b);
+}
+
+std::string AXEventIntent::ToString() const {
+ return std::string("AXEventIntent(") + ui::ToString(command) + ',' +
+ ui::ToString(text_boundary) + ',' + ui::ToString(move_direction) + ')';
+}
+
+} // namespace ui
diff --git a/chromium/ui/accessibility/ax_event_intent.h b/chromium/ui/accessibility/ax_event_intent.h
new file mode 100644
index 00000000000..6734c7e4736
--- /dev/null
+++ b/chromium/ui/accessibility/ax_event_intent.h
@@ -0,0 +1,44 @@
+// Copyright 2020 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 UI_ACCESSIBILITY_AX_EVENT_INTENT_H_
+#define UI_ACCESSIBILITY_AX_EVENT_INTENT_H_
+
+#include <string>
+
+#include "ui/accessibility/ax_base_export.h"
+#include "ui/accessibility/ax_enums.mojom.h"
+
+namespace ui {
+
+// Describes what caused an accessibility event to be raised. For example, a
+// character could have been typed, a word replaced, or a line deleted. Or, the
+// selection could have been extended to the beginning of the previous word, or
+// it could have been moved to the end of the next line.
+struct AX_BASE_EXPORT AXEventIntent final {
+ AXEventIntent();
+ AXEventIntent(ax::mojom::Command command,
+ ax::mojom::TextBoundary text_boundary,
+ ax::mojom::MoveDirection move_direction);
+ virtual ~AXEventIntent();
+ AXEventIntent(const AXEventIntent& intent);
+ AXEventIntent& operator=(const AXEventIntent& intent);
+
+ friend AX_BASE_EXPORT bool operator==(const AXEventIntent& a,
+ const AXEventIntent& b);
+ friend AX_BASE_EXPORT bool operator!=(const AXEventIntent& a,
+ const AXEventIntent& b);
+
+ ax::mojom::Command command = ax::mojom::Command::kType;
+ // TODO(nektar): Split TextBoundary into TextUnit and TextBoundary.
+ ax::mojom::TextBoundary text_boundary = ax::mojom::TextBoundary::kCharacter;
+ ax::mojom::MoveDirection move_direction = ax::mojom::MoveDirection::kForward;
+
+ // Returns a string representation of this data, for debugging.
+ std::string ToString() const;
+};
+
+} // namespace ui
+
+#endif // UI_ACCESSIBILITY_AX_EVENT_INTENT_H_
diff --git a/chromium/ui/accessibility/ax_generated_tree_unittest.cc b/chromium/ui/accessibility/ax_generated_tree_unittest.cc
index 3d0f49575b6..3c180fa061d 100644
--- a/chromium/ui/accessibility/ax_generated_tree_unittest.cc
+++ b/chromium/ui/accessibility/ax_generated_tree_unittest.cc
@@ -8,6 +8,7 @@
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/accessibility/ax_event_generator.h"
#include "ui/accessibility/ax_node.h"
#include "ui/accessibility/ax_serializable_tree.h"
#include "ui/accessibility/ax_tree.h"
@@ -29,8 +30,11 @@ namespace {
// (1) is a tree with a single node with id 1.
// (1 (2 3)) is a tree with 1 as the root, and 2 and 3 as its children.
// (1 (2 (3))) has 1 as the root, 2 as its child, and then 3 as the child of 2.
+// (1 (2 (3x))) is the same with node 3 ignored.
std::string TreeToStringHelper(const AXNode* node) {
std::string result = base::NumberToString(node->id());
+ if (node->IsIgnored())
+ result += "x";
if (node->children().empty())
return result;
const auto add_children = [](const std::string& str, const auto* node) {
@@ -47,6 +51,53 @@ std::string TreeToString(const AXTree& tree) {
return "(" + TreeToStringHelper(tree.root()) + ")";
}
+AXTreeUpdate SerializeEntireTree(AXSerializableTree& tree) {
+ std::unique_ptr<AXTreeSource<const AXNode*, AXNodeData, AXTreeData>>
+ tree_source(tree.CreateTreeSource());
+ AXTreeSerializer<const AXNode*, AXNodeData, AXTreeData> serializer(
+ tree_source.get());
+ AXTreeUpdate update;
+ CHECK(serializer.SerializeChanges(tree.root(), &update));
+ return update;
+}
+
+// Create an AXTreeUpdate consisting of only those nodes from
+// |tree0| that changed their ignored status in |tree1|.
+AXTreeUpdate MakeTreeUpdateFromIgnoredChanges(AXSerializableTree& tree0,
+ AXSerializableTree& tree1) {
+ AXTreeUpdate update = SerializeEntireTree(tree1);
+ AXTreeUpdate result;
+ for (size_t i = 0; i < update.nodes.size(); i++) {
+ AXNode* tree0_node = tree0.GetFromId(update.nodes[i].id);
+ AXNode* tree1_node = tree1.GetFromId(update.nodes[i].id);
+ if (tree0_node->IsIgnored() != tree1_node->IsIgnored())
+ result.nodes.push_back(update.nodes[i]);
+ }
+ return result;
+}
+
+void SerializeUnignoredNodes(AXNode* node, AXTreeUpdate* update) {
+ AXNodeData data = node->data();
+ data.child_ids.clear();
+ for (size_t i = 0; i < node->GetUnignoredChildCount(); i++) {
+ AXNode* child = node->GetUnignoredChildAtIndex(i);
+ data.child_ids.push_back(child->id());
+ }
+ update->nodes.push_back(data);
+ for (size_t i = 0; i < node->GetUnignoredChildCount(); i++) {
+ AXNode* child = node->GetUnignoredChildAtIndex(i);
+ SerializeUnignoredNodes(child, update);
+ }
+}
+
+void MakeTreeOfUnignoredNodesOnly(AXSerializableTree& src,
+ AXSerializableTree* dst) {
+ AXTreeUpdate update;
+ update.root_id = src.root()->id();
+ SerializeUnignoredNodes(src.root(), &update);
+ CHECK(dst->Unserialize(update));
+}
+
} // anonymous namespace
// Test the TreeGenerator class by building all possible trees with
@@ -54,12 +105,14 @@ std::string TreeToString(const AXTree& tree) {
TEST(AXGeneratedTreeTest, TestTreeGeneratorNoPermutations) {
int tree_size = 3;
TreeGenerator generator(tree_size, false);
+ // clang-format off
const char* EXPECTED_TREES[] = {
"(1)",
"(1 (2))",
"(1 (2 3))",
"(1 (2 (3)))",
};
+ // clang-format on
int n = generator.UniqueTreeCount();
ASSERT_EQ(static_cast<int>(base::size(EXPECTED_TREES)), n);
@@ -72,11 +125,47 @@ TEST(AXGeneratedTreeTest, TestTreeGeneratorNoPermutations) {
}
}
+// Test generating trees with permutations of ignored nodes.
+TEST(AXGeneratedTreeTest, TestGeneratingTreesWithIgnoredNodes) {
+ int tree_size = 3;
+ TreeGenerator generator(tree_size, false);
+ // clang-format off
+ const char* EXPECTED_TREES[] = {
+ "(1)",
+ "(1 (2))",
+ "(1 (2x))",
+ "(1 (2 3))",
+ "(1 (2x 3))",
+ "(1 (2 3x))",
+ "(1 (2x 3x))",
+ "(1 (2 (3)))",
+ "(1 (2x (3)))",
+ "(1 (2 (3x)))",
+ "(1 (2x (3x)))",
+ };
+ // clang-format on
+
+ int n = generator.UniqueTreeCount();
+ int expected_index = 0;
+ for (int i = 0; i < n; ++i) {
+ int ignored_permutation_count =
+ generator.IgnoredPermutationCountPerUniqueTree(i);
+ for (int j = 0; j < ignored_permutation_count; j++) {
+ AXTree tree;
+ generator.BuildUniqueTreeWithIgnoredNodes(i, j, &tree);
+ std::string str = TreeToString(tree);
+ EXPECT_EQ(EXPECTED_TREES[expected_index++], str);
+ }
+ }
+ EXPECT_EQ(11, expected_index);
+}
+
// Test the TreeGenerator class by building all possible trees with
// 3 nodes and the ids [1...3] permuted in any order.
TEST(AXGeneratedTreeTest, TestTreeGeneratorWithPermutations) {
int tree_size = 3;
TreeGenerator generator(tree_size, true);
+ // clang-format off
const char* EXPECTED_TREES[] = {
"(1)",
"(1 (2))",
@@ -94,6 +183,7 @@ TEST(AXGeneratedTreeTest, TestTreeGeneratorWithPermutations) {
"(2 (3 (1)))",
"(3 (2 (1)))",
};
+ // clang-format on
int n = generator.UniqueTreeCount();
ASSERT_EQ(static_cast<int>(base::size(EXPECTED_TREES)), n);
@@ -197,4 +287,165 @@ TEST(AXGeneratedTreeTest, SerializeGeneratedTrees) {
}
}
+TEST(AXGeneratedTreeTest, GeneratedTreesWithIgnoredNodes) {
+ int max_tree_size = 5;
+
+ TreeGenerator generator(max_tree_size, false);
+ int unique_tree_count = generator.UniqueTreeCount();
+
+ // Loop over every possible tree up to a certain size.
+ for (int tree_index = 0; tree_index < unique_tree_count; tree_index++) {
+ // Try each permutation of nodes other than the root being ignored.
+ // We'll call this tree the "fat" tree because it has redundant
+ // ignored nodes.
+ int ignored_permutation_count =
+ generator.IgnoredPermutationCountPerUniqueTree(tree_index);
+ for (int perm_index0 = 0; perm_index0 < ignored_permutation_count;
+ perm_index0++) {
+ AXSerializableTree fat_tree;
+ generator.BuildUniqueTreeWithIgnoredNodes(tree_index, perm_index0,
+ &fat_tree);
+ SCOPED_TRACE("fat_tree is " + TreeToString(fat_tree));
+
+ // Create a second tree, also with each permutations of nodes
+ // other than the root being ignored.
+ for (int perm_index1 = 1; perm_index1 < ignored_permutation_count;
+ perm_index1++) {
+ AXSerializableTree fat_tree1;
+ generator.BuildUniqueTreeWithIgnoredNodes(tree_index, perm_index1,
+ &fat_tree1);
+ SCOPED_TRACE("fat_tree1 is " + TreeToString(fat_tree1));
+
+ // Make a source and destination tree using only the unignored nodes.
+ // We call this one the "skinny" tree.
+ AXSerializableTree skinny_tree;
+ MakeTreeOfUnignoredNodesOnly(fat_tree, &skinny_tree);
+ AXSerializableTree skinny_tree1;
+ MakeTreeOfUnignoredNodesOnly(fat_tree1, &skinny_tree1);
+
+ // Now, turn fat_tree into fat_tree1, and record the generated events.
+ AXEventGenerator event_generator(&fat_tree);
+ AXTreeUpdate update =
+ MakeTreeUpdateFromIgnoredChanges(fat_tree, fat_tree1);
+ ASSERT_TRUE(fat_tree.Unserialize(update));
+ EXPECT_EQ(TreeToString(fat_tree), TreeToString(fat_tree1));
+
+ // Capture the events generated.
+ std::map<AXNode::AXID, std::set<AXEventGenerator::Event>> actual_events;
+ for (const AXEventGenerator::TargetedEvent& event : event_generator) {
+ if (event.node->IsIgnored() ||
+ event.event_params.event ==
+ AXEventGenerator::Event::IGNORED_CHANGED) {
+ continue;
+ }
+
+ actual_events[event.node->id()].insert(event.event_params.event);
+ }
+
+ // Now, turn skinny_tree into skinny_tree1 and compare
+ // the generated events.
+ AXEventGenerator skinny_event_generator(&skinny_tree);
+ AXTreeUpdate skinny_update = SerializeEntireTree(skinny_tree1);
+ ASSERT_TRUE(skinny_tree.Unserialize(skinny_update));
+ EXPECT_EQ(TreeToString(skinny_tree), TreeToString(skinny_tree1));
+
+ std::map<AXNode::AXID, std::set<AXEventGenerator::Event>>
+ expected_events;
+ for (const AXEventGenerator::TargetedEvent& event :
+ skinny_event_generator)
+ expected_events[event.node->id()].insert(event.event_params.event);
+
+ for (auto& entry : expected_events) {
+ AXNode::AXID node_id = entry.first;
+ for (auto& event_type : entry.second) {
+ EXPECT_TRUE(actual_events[node_id].find(event_type) !=
+ actual_events[node_id].end())
+ << "Expected " << event_type << " on node " << node_id;
+ }
+ }
+
+ for (auto& entry : actual_events) {
+ AXNode::AXID node_id = entry.first;
+ for (auto& event_type : entry.second) {
+ EXPECT_TRUE(expected_events[node_id].find(event_type) !=
+ expected_events[node_id].end())
+ << "Unexpected " << event_type << " on node " << node_id;
+ }
+ }
+
+ // For each node in skinny_tree (the tree with only the unignored
+ // nodes), check the node in fat_tree (the tree with ignored nodes).
+ // Make sure that the parents, children, and siblings are all computed
+ // correctly.
+ AXTreeUpdate skinny_tree_serialized = SerializeEntireTree(skinny_tree);
+ for (size_t i = 0; i < skinny_tree_serialized.nodes.size(); i++) {
+ AXNode::AXID id = skinny_tree_serialized.nodes[i].id;
+
+ AXNode* skinny_tree_node = skinny_tree.GetFromId(id);
+ AXNode* fat_tree_node = fat_tree.GetFromId(id);
+
+ SCOPED_TRACE("Testing node ID " + base::NumberToString(id));
+
+ // Check children.
+ EXPECT_EQ(skinny_tree_node->children().size(),
+ fat_tree_node->GetUnignoredChildCount());
+
+ // Check child IDs.
+ for (size_t j = 0; j < skinny_tree_node->children().size(); j++) {
+ AXNode* skinny_tree_child = skinny_tree_node->children()[j];
+ AXNode* fat_tree_child = fat_tree_node->GetUnignoredChildAtIndex(j);
+ EXPECT_TRUE(skinny_tree_child);
+ EXPECT_TRUE(fat_tree_child);
+ if (fat_tree_child)
+ EXPECT_EQ(skinny_tree_child->id(), fat_tree_child->id());
+ }
+
+ // Check parent.
+ if (skinny_tree_node->parent()) {
+ EXPECT_EQ(skinny_tree_node->parent()->id(),
+ fat_tree_node->GetUnignoredParent()->id());
+ } else {
+ EXPECT_FALSE(fat_tree_node->GetUnignoredParent());
+ }
+
+ // Check index in parent.
+ EXPECT_EQ(skinny_tree_node->index_in_parent(),
+ fat_tree_node->GetUnignoredIndexInParent());
+
+ // Unignored previous sibling.
+ size_t index_in_parent = skinny_tree_node->index_in_parent();
+ size_t num_siblings =
+ skinny_tree_node->parent()
+ ? skinny_tree_node->parent()->children().size()
+ : 1;
+ if (index_in_parent > 0) {
+ AXNode* skinny_tree_previous_sibling =
+ skinny_tree_node->parent()->children()[index_in_parent - 1];
+ AXNode* fat_tree_previous_sibling =
+ fat_tree_node->GetPreviousUnignoredSibling();
+ EXPECT_TRUE(fat_tree_previous_sibling);
+ if (fat_tree_previous_sibling) {
+ EXPECT_EQ(skinny_tree_previous_sibling->id(),
+ fat_tree_previous_sibling->id());
+ }
+ }
+
+ // Unignored next sibling.
+ if (index_in_parent < num_siblings - 1) {
+ AXNode* skinny_tree_next_sibling =
+ skinny_tree_node->parent()->children()[index_in_parent + 1];
+ AXNode* fat_tree_next_sibling =
+ fat_tree_node->GetNextUnignoredSibling();
+ EXPECT_TRUE(fat_tree_next_sibling);
+ if (fat_tree_next_sibling) {
+ EXPECT_EQ(skinny_tree_next_sibling->id(),
+ fat_tree_next_sibling->id());
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
} // namespace ui
diff --git a/chromium/ui/accessibility/ax_node.cc b/chromium/ui/accessibility/ax_node.cc
index b2012c7ac21..b81f1491c31 100644
--- a/chromium/ui/accessibility/ax_node.cc
+++ b/chromium/ui/accessibility/ax_node.cc
@@ -107,67 +107,177 @@ AXNode* AXNode::GetDeepestLastUnignoredChild() const {
return deepest_child;
}
+// Search for the next sibling of this node, skipping over any ignored nodes
+// encountered.
+//
+// In our search:
+// If we find an ignored sibling, we consider its children as our siblings.
+// If we run out of siblings, we consider an ignored parent's siblings as our
+// own siblings.
+//
+// Note: this behaviour of 'skipping over' an ignored node makes this subtly
+// different to finding the next (direct) sibling which is unignored.
+//
+// Consider a tree, where (i) marks a node as ignored:
+//
+// 1
+// ├── 2
+// ├── 3(i)
+// │ └── 5
+// └── 4
+//
+// The next sibling of node 2 is node 3, which is ignored.
+// The next unignored sibling of node 2 could be either:
+// 1) node 4 - next unignored sibling in the literal tree, or
+// 2) node 5 - next unignored sibling in the logical document.
+//
+// There is no next sibling of node 5.
+// The next unignored sibling of node 5 could be either:
+// 1) null - no next sibling in the literal tree, or
+// 2) node 4 - next unignored sibling in the logical document.
+//
+// In both cases, this method implements approach (2).
+//
+// TODO(chrishall): Can we remove this non-reflexive case by forbidding
+// GetNextUnignoredSibling calls on an ignored started node?
+// Note: this means that Next/Previous-UnignoredSibling are not reflexive if
+// either of the nodes in question are ignored. From above we get an example:
+// NextUnignoredSibling(3) is 4, but
+// PreviousUnignoredSibling(4) is 5.
+//
+// The view of unignored siblings for node 3 includes both node 2 and node 4:
+// 2 <-- [3(i)] --> 4
+//
+// Whereas nodes 2, 5, and 4 do not consider node 3 to be an unignored sibling:
+// null <-- [2] --> 5
+// 2 <-- [5] --> 4
+// 5 <-- [4] --> null
AXNode* AXNode::GetNextUnignoredSibling() const {
DCHECK(!tree_->GetTreeUpdateInProgressState());
- AXNode* parent_node = parent();
- size_t index = index_in_parent() + 1;
- while (parent_node) {
- if (index < parent_node->children().size()) {
- AXNode* child = parent_node->children()[index];
- if (!child->IsIgnored())
- return child; // valid position (unignored child)
-
- // If the node is ignored, drill down to the ignored node's first child.
- parent_node = child;
- index = 0;
+ const AXNode* current = this;
+
+ // If there are children of the |current| node still to consider.
+ bool considerChildren = false;
+
+ while (current) {
+ // A |candidate| sibling to consider.
+ // If it is unignored then we have found our result.
+ // Otherwise promote it to |current| and consider its children.
+ AXNode* candidate;
+
+ if (considerChildren && (candidate = current->GetFirstChild())) {
+ if (!candidate->IsIgnored())
+ return candidate;
+ current = candidate;
+
+ } else if ((candidate = current->GetNextSibling())) {
+ if (!candidate->IsIgnored())
+ return candidate;
+ current = candidate;
+ // Look through the ignored candidate node to consider their children as
+ // though they were siblings.
+ considerChildren = true;
+
} else {
- // If the parent is not ignored and we are past all of its children, there
- // is no next sibling.
- if (!parent_node->IsIgnored())
+ // Continue our search through a parent iff they are ignored.
+ //
+ // If |current| has an ignored parent, then we consider the parent's
+ // siblings as though they were siblings of |current|.
+ //
+ // Given a tree:
+ // 1
+ // ├── 2(?)
+ // │ └── [4]
+ // └── 3
+ //
+ // Node 4's view of siblings:
+ // literal tree: null <-- [4] --> null
+ //
+ // If node 2 is not ignored, then node 4's view doesn't change, and we
+ // have no more nodes to consider:
+ // unignored tree: null <-- [4] --> null
+ //
+ // If instead node 2 is ignored, then node 4's view of siblings grows to
+ // include node 3, and we have more nodes to consider:
+ // unignored tree: null <-- [4] --> 3
+ current = current->parent();
+ if (!current || !current->IsIgnored())
return nullptr;
- // If the parent is ignored and we are past all of its children, continue
- // on to the parent's next sibling.
- index = parent_node->index_in_parent() + 1;
- parent_node = parent_node->parent();
+ // We have already considered all relevant descendants of |current|.
+ considerChildren = false;
}
}
+
return nullptr;
}
+// Search for the previous sibling of this node, skipping over any ignored nodes
+// encountered.
+//
+// In our search for a sibling:
+// If we find an ignored sibling, we may consider its children as siblings.
+// If we run out of siblings, we may consider an ignored parent's siblings as
+// our own.
+//
+// See the documentation for |GetNextUnignoredSibling| for more details.
AXNode* AXNode::GetPreviousUnignoredSibling() const {
DCHECK(!tree_->GetTreeUpdateInProgressState());
- AXNode* parent_node = parent();
- base::Optional<size_t> index;
- if (index_in_parent() > 0)
- index = index_in_parent() - 1;
- while (parent_node) {
- if (index.has_value()) {
- AXNode* child = parent_node->children()[index.value()];
- if (!child->IsIgnored())
- return child; // valid position (unignored child)
-
- // If the node is ignored, drill down to the ignored node's last child.
- parent_node = child;
- if (parent_node->children().empty())
- index = base::nullopt;
- else
- index = parent_node->children().size() - 1;
+ const AXNode* current = this;
+
+ // If there are children of the |current| node still to consider.
+ bool considerChildren = false;
+
+ while (current) {
+ // A |candidate| sibling to consider.
+ // If it is unignored then we have found our result.
+ // Otherwise promote it to |current| and consider its children.
+ AXNode* candidate;
+
+ if (considerChildren && (candidate = current->GetLastChild())) {
+ if (!candidate->IsIgnored())
+ return candidate;
+ current = candidate;
+
+ } else if ((candidate = current->GetPreviousSibling())) {
+ if (!candidate->IsIgnored())
+ return candidate;
+ current = candidate;
+ // Look through the ignored candidate node to consider their children as
+ // though they were siblings.
+ considerChildren = true;
+
} else {
- // If the parent is not ignored and we are past all of its children, there
- // is no next sibling.
- if (!parent_node->IsIgnored())
+ // Continue our search through a parent iff they are ignored.
+ //
+ // If |current| has an ignored parent, then we consider the parent's
+ // siblings as though they were siblings of |current|.
+ //
+ // Given a tree:
+ // 1
+ // ├── 2
+ // └── 3(?)
+ // └── [4]
+ //
+ // Node 4's view of siblings:
+ // literal tree: null <-- [4] --> null
+ //
+ // If node 3 is not ignored, then node 4's view doesn't change, and we
+ // have no more nodes to consider:
+ // unignored tree: null <-- [4] --> null
+ //
+ // If instead node 3 is ignored, then node 4's view of siblings grows to
+ // include node 2, and we have more nodes to consider:
+ // unignored tree: 2 <-- [4] --> null
+ current = current->parent();
+ if (!current || !current->IsIgnored())
return nullptr;
- // If the parent is ignored and we are past all of its children, continue
- // on to the parent's previous sibling.
- if (parent_node->index_in_parent() == 0)
- index = base::nullopt;
- else
- index = parent_node->index_in_parent() - 1;
- parent_node = parent_node->parent();
+ // We have already considered all relevant descendants of |current|.
+ considerChildren = false;
}
}
+
return nullptr;
}
@@ -208,6 +318,41 @@ AXNode::UnignoredChildIterator AXNode::UnignoredChildrenEnd() const {
return UnignoredChildIterator(this, nullptr);
}
+// The first (direct) child, ignored or unignored.
+AXNode* AXNode::GetFirstChild() const {
+ if (children().size() == 0)
+ return nullptr;
+ return children()[0];
+}
+
+// The last (direct) child, ignored or unignored.
+AXNode* AXNode::GetLastChild() const {
+ size_t n = children().size();
+ if (n == 0)
+ return nullptr;
+ return children()[n - 1];
+}
+
+// The previous (direct) sibling, ignored or unignored.
+AXNode* AXNode::GetPreviousSibling() const {
+ // Root nodes lack a parent, their index_in_parent should be 0.
+ DCHECK(!parent() ? index_in_parent() == 0 : true);
+ size_t index = index_in_parent();
+ if (index == 0)
+ return nullptr;
+ return parent()->children()[index - 1];
+}
+
+// The next (direct) sibling, ignored or unignored.
+AXNode* AXNode::GetNextSibling() const {
+ if (!parent())
+ return nullptr;
+ size_t nextIndex = index_in_parent() + 1;
+ if (nextIndex >= parent()->children().size())
+ return nullptr;
+ return parent()->children()[nextIndex];
+}
+
bool AXNode::IsText() const {
return data().role == ax::mojom::Role::kStaticText ||
data().role == ax::mojom::Role::kLineBreak ||
@@ -377,14 +522,14 @@ base::Optional<int> AXNode::GetTableAriaColCount() const {
const AXTableInfo* table_info = GetAncestorTableInfo();
if (!table_info)
return base::nullopt;
- return table_info->aria_col_count;
+ return base::make_optional(table_info->aria_col_count);
}
base::Optional<int> AXNode::GetTableAriaRowCount() const {
const AXTableInfo* table_info = GetAncestorTableInfo();
if (!table_info)
return base::nullopt;
- return table_info->aria_row_count;
+ return base::make_optional(table_info->aria_row_count);
}
base::Optional<int> AXNode::GetTableCellCount() const {
@@ -819,6 +964,7 @@ bool AXNode::SetRoleMatchesItemRole(const AXNode* ordered_set) const {
item_role == ax::mojom::Role::kListItem ||
item_role == ax::mojom::Role::kMenuItem ||
item_role == ax::mojom::Role::kMenuItemRadio ||
+ item_role == ax::mojom::Role::kListBoxOption ||
item_role == ax::mojom::Role::kTreeItem;
case ax::mojom::Role::kMenu:
return item_role == ax::mojom::Role::kMenuItem ||
@@ -946,4 +1092,37 @@ bool AXNode::IsInListMarker() const {
grandparent_node->data().role == ax::mojom::Role::kListMarker;
}
+bool AXNode::IsCollapsedMenuListPopUpButton() const {
+ if (data().role != ax::mojom::Role::kPopUpButton ||
+ !data().HasState(ax::mojom::State::kCollapsed)) {
+ return false;
+ }
+
+ // When a popup button contains a menu list popup, its only child is unignored
+ // and is a menu list popup.
+ AXNode* node = GetFirstUnignoredChild();
+ if (!node)
+ return false;
+
+ return node->data().role == ax::mojom::Role::kMenuListPopup;
+}
+
+AXNode* AXNode::GetCollapsedMenuListPopUpButtonAncestor() const {
+ AXNode* node = GetOrderedSet();
+
+ if (!node)
+ return nullptr;
+
+ // The ordered set returned is either the popup element child of the popup
+ // button (e.g., the AXMenuListPopup) or the popup button itself. We need
+ // |node| to point to the popup button itself.
+ if (node->data().role != ax::mojom::Role::kPopUpButton) {
+ node = node->parent();
+ if (!node)
+ return nullptr;
+ }
+
+ return node->IsCollapsedMenuListPopUpButton() ? node : nullptr;
+}
+
} // namespace ui
diff --git a/chromium/ui/accessibility/ax_node.h b/chromium/ui/accessibility/ax_node.h
index 8e3f55fbce5..e19d1bc43b7 100644
--- a/chromium/ui/accessibility/ax_node.h
+++ b/chromium/ui/accessibility/ax_node.h
@@ -68,6 +68,7 @@ class AX_EXPORT AXNode final {
template <typename NodeType,
NodeType* (NodeType::*NextSibling)() const,
NodeType* (NodeType::*PreviousSibling)() const,
+ NodeType* (NodeType::*FirstChild)() const,
NodeType* (NodeType::*LastChild)() const>
class ChildIteratorBase {
public:
@@ -128,10 +129,18 @@ class AX_EXPORT AXNode final {
ChildIteratorBase<AXNode,
&AXNode::GetNextUnignoredSibling,
&AXNode::GetPreviousUnignoredSibling,
+ &AXNode::GetFirstUnignoredChild,
&AXNode::GetLastUnignoredChild>;
UnignoredChildIterator UnignoredChildrenBegin() const;
UnignoredChildIterator UnignoredChildrenEnd() const;
+ // Walking the tree including both ignored and unignored nodes.
+ // These methods consider only the direct children or siblings of a node.
+ AXNode* GetFirstChild() const;
+ AXNode* GetLastChild() const;
+ AXNode* GetPreviousSibling() const;
+ AXNode* GetNextSibling() const;
+
// Returns true if the node has any of the text related roles.
bool IsText() const;
@@ -388,6 +397,15 @@ class AX_EXPORT AXNode final {
// of a list marker node. Returns false otherwise.
bool IsInListMarker() const;
+ // Returns true if this node is a collapsed popup button that is parent to a
+ // menu list popup.
+ bool IsCollapsedMenuListPopUpButton() const;
+
+ // Returns the popup button ancestor of this current node if any. The popup
+ // button needs to be the parent of a menu list popup and needs to be
+ // collapsed.
+ AXNode* GetCollapsedMenuListPopUpButtonAncestor() const;
+
private:
// Computes the text offset where each line starts by traversing all child
// leaf nodes.
@@ -420,72 +438,125 @@ AX_EXPORT std::ostream& operator<<(std::ostream& stream, const AXNode& node);
template <typename NodeType,
NodeType* (NodeType::*NextSibling)() const,
NodeType* (NodeType::*PreviousSibling)() const,
+ NodeType* (NodeType::*FirstChild)() const,
NodeType* (NodeType::*LastChild)() const>
-AXNode::ChildIteratorBase<NodeType, NextSibling, PreviousSibling, LastChild>::
- ChildIteratorBase(const NodeType* parent, NodeType* child)
+AXNode::ChildIteratorBase<NodeType,
+ NextSibling,
+ PreviousSibling,
+ FirstChild,
+ LastChild>::ChildIteratorBase(const NodeType* parent,
+ NodeType* child)
: parent_(parent), child_(child) {}
template <typename NodeType,
NodeType* (NodeType::*NextSibling)() const,
NodeType* (NodeType::*PreviousSibling)() const,
+ NodeType* (NodeType::*FirstChild)() const,
NodeType* (NodeType::*LastChild)() const>
-AXNode::ChildIteratorBase<NodeType, NextSibling, PreviousSibling, LastChild>::
- ChildIteratorBase(const ChildIteratorBase& it)
+AXNode::ChildIteratorBase<NodeType,
+ NextSibling,
+ PreviousSibling,
+ FirstChild,
+ LastChild>::ChildIteratorBase(const ChildIteratorBase&
+ it)
: parent_(it.parent_), child_(it.child_) {}
template <typename NodeType,
NodeType* (NodeType::*NextSibling)() const,
NodeType* (NodeType::*PreviousSibling)() const,
+ NodeType* (NodeType::*FirstChild)() const,
NodeType* (NodeType::*LastChild)() const>
-bool AXNode::
- ChildIteratorBase<NodeType, NextSibling, PreviousSibling, LastChild>::
- operator==(const ChildIteratorBase& rhs) const {
+bool AXNode::ChildIteratorBase<NodeType,
+ NextSibling,
+ PreviousSibling,
+ FirstChild,
+ LastChild>::operator==(const ChildIteratorBase&
+ rhs) const {
return parent_ == rhs.parent_ && child_ == rhs.child_;
}
template <typename NodeType,
NodeType* (NodeType::*NextSibling)() const,
NodeType* (NodeType::*PreviousSibling)() const,
+ NodeType* (NodeType::*FirstChild)() const,
NodeType* (NodeType::*LastChild)() const>
-bool AXNode::
- ChildIteratorBase<NodeType, NextSibling, PreviousSibling, LastChild>::
- operator!=(const ChildIteratorBase& rhs) const {
+bool AXNode::ChildIteratorBase<NodeType,
+ NextSibling,
+ PreviousSibling,
+ FirstChild,
+ LastChild>::operator!=(const ChildIteratorBase&
+ rhs) const {
return parent_ != rhs.parent_ || child_ != rhs.child_;
}
template <typename NodeType,
NodeType* (NodeType::*NextSibling)() const,
NodeType* (NodeType::*PreviousSibling)() const,
+ NodeType* (NodeType::*FirstChild)() const,
NodeType* (NodeType::*LastChild)() const>
-AXNode::ChildIteratorBase<NodeType, NextSibling, PreviousSibling, LastChild>&
-AXNode::ChildIteratorBase<NodeType, NextSibling, PreviousSibling, LastChild>::
-operator++() {
- if (child_)
- child_ = (child_->*NextSibling)();
+AXNode::ChildIteratorBase<NodeType,
+ NextSibling,
+ PreviousSibling,
+ FirstChild,
+ LastChild>&
+AXNode::ChildIteratorBase<NodeType,
+ NextSibling,
+ PreviousSibling,
+ FirstChild,
+ LastChild>::operator++() {
+ // |child_ = nullptr| denotes the iterator's past-the-end condition. When we
+ // increment the iterator past the end, we remain at the past-the-end iterator
+ // condition.
+ if (child_ && parent_) {
+ if (child_ == (parent_->*LastChild)())
+ child_ = nullptr;
+ else
+ child_ = (child_->*NextSibling)();
+ }
+
return *this;
}
template <typename NodeType,
NodeType* (NodeType::*NextSibling)() const,
NodeType* (NodeType::*PreviousSibling)() const,
+ NodeType* (NodeType::*FirstChild)() const,
NodeType* (NodeType::*LastChild)() const>
-AXNode::ChildIteratorBase<NodeType, NextSibling, PreviousSibling, LastChild>&
-AXNode::ChildIteratorBase<NodeType, NextSibling, PreviousSibling, LastChild>::
-operator--() {
- if (child_)
- child_ = (child_->*PreviousSibling)();
- else
- child_ = (parent_->*LastChild)();
+AXNode::ChildIteratorBase<NodeType,
+ NextSibling,
+ PreviousSibling,
+ FirstChild,
+ LastChild>&
+AXNode::ChildIteratorBase<NodeType,
+ NextSibling,
+ PreviousSibling,
+ FirstChild,
+ LastChild>::operator--() {
+ if (parent_) {
+ // If the iterator is past the end, |child_=nullptr|, decrement the iterator
+ // gives us the last iterator element.
+ if (!child_)
+ child_ = (parent_->*LastChild)();
+ // Decrement the iterator gives us the previous element, except when the
+ // iterator is at the beginning; in which case, decrementing the iterator
+ // remains at the beginning.
+ else if (child_ != (parent_->*FirstChild)())
+ child_ = (child_->*PreviousSibling)();
+ }
+
return *this;
}
template <typename NodeType,
NodeType* (NodeType::*NextSibling)() const,
NodeType* (NodeType::*PreviousSibling)() const,
+ NodeType* (NodeType::*FirstChild)() const,
NodeType* (NodeType::*LastChild)() const>
-NodeType* AXNode::
- ChildIteratorBase<NodeType, NextSibling, PreviousSibling, LastChild>::get()
- const {
+NodeType* AXNode::ChildIteratorBase<NodeType,
+ NextSibling,
+ PreviousSibling,
+ FirstChild,
+ LastChild>::get() const {
DCHECK(child_);
return child_;
}
@@ -493,10 +564,13 @@ NodeType* AXNode::
template <typename NodeType,
NodeType* (NodeType::*NextSibling)() const,
NodeType* (NodeType::*PreviousSibling)() const,
+ NodeType* (NodeType::*FirstChild)() const,
NodeType* (NodeType::*LastChild)() const>
-NodeType& AXNode::
- ChildIteratorBase<NodeType, NextSibling, PreviousSibling, LastChild>::
- operator*() const {
+NodeType& AXNode::ChildIteratorBase<NodeType,
+ NextSibling,
+ PreviousSibling,
+ FirstChild,
+ LastChild>::operator*() const {
DCHECK(child_);
return *child_;
}
@@ -504,10 +578,13 @@ NodeType& AXNode::
template <typename NodeType,
NodeType* (NodeType::*NextSibling)() const,
NodeType* (NodeType::*PreviousSibling)() const,
+ NodeType* (NodeType::*FirstChild)() const,
NodeType* (NodeType::*LastChild)() const>
-NodeType* AXNode::
- ChildIteratorBase<NodeType, NextSibling, PreviousSibling, LastChild>::
- operator->() const {
+NodeType* AXNode::ChildIteratorBase<NodeType,
+ NextSibling,
+ PreviousSibling,
+ FirstChild,
+ LastChild>::operator->() const {
DCHECK(child_);
return child_;
}
diff --git a/chromium/ui/accessibility/ax_node_data.cc b/chromium/ui/accessibility/ax_node_data.cc
index 3ad412f2310..1780711a1ae 100644
--- a/chromium/ui/accessibility/ax_node_data.cc
+++ b/chromium/ui/accessibility/ax_node_data.cc
@@ -8,6 +8,7 @@
#include <algorithm>
#include <set>
+#include <utility>
#include "base/no_destructor.h"
#include "base/stl_util.h"
@@ -18,7 +19,6 @@
#include "ui/accessibility/ax_enum_util.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_role_properties.h"
-#include "ui/accessibility/ax_text_utils.h"
#include "ui/gfx/transform.h"
namespace ui {
@@ -880,6 +880,20 @@ void AXNodeData::SetTextDirection(ax::mojom::TextDirection text_direction) {
}
}
+bool AXNodeData::IsActivatable() const {
+ return IsTextField() || role == ax::mojom::Role::kListBox;
+}
+
+bool AXNodeData::IsButtonPressed() const {
+ // Currently there is no internal representation for |aria-pressed|, and
+ // we map |aria-pressed="true"| to ax::mojom::CheckedState::kTrue for a native
+ // button or role="button".
+ // https://www.w3.org/TR/wai-aria-1.1/#aria-pressed
+ if (IsButton(role) && GetCheckedState() == ax::mojom::CheckedState::kTrue)
+ return true;
+ return false;
+}
+
bool AXNodeData::IsClickable() const {
// If it has a custom default action verb except for
// ax::mojom::DefaultActionVerb::kClickAncestor, it's definitely clickable.
@@ -893,18 +907,45 @@ bool AXNodeData::IsClickable() const {
}
bool AXNodeData::IsIgnored() const {
- if (HasState(ax::mojom::State::kIgnored) || role == ax::mojom::Role::kIgnored)
- return true;
- return false;
+ return HasState(ax::mojom::State::kIgnored) ||
+ role == ax::mojom::Role::kIgnored;
+}
+
+bool AXNodeData::IsInvisibleOrIgnored() const {
+ return IsIgnored() || HasState(ax::mojom::State::kInvisible);
}
bool AXNodeData::IsInvocable() const {
// A control is "invocable" if it initiates an action when activated but
// does not maintain any state. A control that maintains state when activated
// would be considered a toggle or expand-collapse element - these elements
- // are "clickable" but not "invocable".
- return IsClickable() && !SupportsExpandCollapse() &&
- !ui::SupportsToggle(role);
+ // are "clickable" but not "invocable". Similarly, if the action only involves
+ // activating the control, such as when clicking a text field, the control is
+ // not considered "invocable".
+ return IsClickable() && !IsActivatable() && !SupportsExpandCollapse() &&
+ !SupportsToggle(role);
+}
+
+bool AXNodeData::IsMenuButton() const {
+ // According to the WAI-ARIA spec, a menu button is a native button or an ARIA
+ // role="button" that opens a menu. Although ARIA does not include a role
+ // specifically for menu buttons, screen readers identify buttons that have
+ // aria-haspopup="true" or aria-haspopup="menu" as menu buttons, and Blink
+ // maps both to HasPopup::kMenu.
+ // https://www.w3.org/TR/wai-aria-practices/#menubutton
+ // https://www.w3.org/TR/wai-aria-1.1/#aria-haspopup
+ if (IsButton(role) && GetHasPopup() == ax::mojom::HasPopup::kMenu)
+ return true;
+
+ return false;
+}
+
+bool AXNodeData::IsTextField() const {
+ return IsPlainTextField() || IsRichTextField();
+}
+
+bool AXNodeData::IsPasswordField() const {
+ return IsTextField() && HasState(ax::mojom::State::kProtected);
}
bool AXNodeData::IsPlainTextField() const {
@@ -918,6 +959,11 @@ bool AXNodeData::IsPlainTextField() const {
GetBoolAttribute(ax::mojom::BoolAttribute::kEditableRoot));
}
+bool AXNodeData::IsRichTextField() const {
+ return GetBoolAttribute(ax::mojom::BoolAttribute::kEditableRoot) &&
+ HasState(ax::mojom::State::kRichlyEditable);
+}
+
bool AXNodeData::IsReadOnlyOrDisabled() const {
switch (GetRestriction()) {
case ax::mojom::Restriction::kReadOnly:
@@ -938,23 +984,12 @@ bool AXNodeData::IsReadOnlyOrDisabled() const {
}
bool AXNodeData::IsRangeValueSupported() const {
- // https://www.w3.org/TR/wai-aria-1.1/#aria-valuenow
- // https://www.w3.org/TR/wai-aria-1.1/#aria-valuetext
- // Roles that support aria-valuetext / aria-valuenow
- switch (role) {
- case ax::mojom::Role::kMeter:
- case ax::mojom::Role::kProgressIndicator:
- case ax::mojom::Role::kScrollBar:
- case ax::mojom::Role::kSlider:
- case ax::mojom::Role::kSpinButton:
- return true;
- case ax::mojom::Role::kSplitter:
- // According to the ARIA spec, role="separator" acts as a splitter only
- // when focusable, and supports a range only in that case.
- return HasState(ax::mojom::State::kFocusable);
- default:
- return false;
+ if (role == ax::mojom::Role::kSplitter) {
+ // According to the ARIA spec, role="separator" acts as a splitter only
+ // when focusable, and supports a range only in that case.
+ return HasState(ax::mojom::State::kFocusable);
}
+ return ui::IsRangeValueSupported(role);
}
bool AXNodeData::SupportsExpandCollapse() const {
@@ -997,9 +1032,9 @@ std::string AXNodeData::ToString() const {
std::string value = base::NumberToString(int_attribute.second);
switch (int_attribute.first) {
case ax::mojom::IntAttribute::kDefaultActionVerb:
- result += " action=" + base::UTF16ToUTF8(ActionVerbToUnlocalizedString(
- static_cast<ax::mojom::DefaultActionVerb>(
- int_attribute.second)));
+ result += std::string(" action=") +
+ ui::ToString(static_cast<ax::mojom::DefaultActionVerb>(
+ int_attribute.second));
break;
case ax::mojom::IntAttribute::kScrollX:
result += " scroll_x=" + value;
diff --git a/chromium/ui/accessibility/ax_node_data.h b/chromium/ui/accessibility/ax_node_data.h
index 36dbf005964..e03e836b912 100644
--- a/chromium/ui/accessibility/ax_node_data.h
+++ b/chromium/ui/accessibility/ax_node_data.h
@@ -10,6 +10,7 @@
#include <map>
#include <memory>
#include <string>
+#include <utility>
#include <vector>
#include "base/strings/string16.h"
@@ -34,6 +35,13 @@ AX_BASE_EXPORT bool IsNodeIdIntListAttribute(ax::mojom::IntListAttribute attr);
// single accessible object, in a form that can be serialized and sent from
// one process to another.
struct AX_BASE_EXPORT AXNodeData {
+ // Defines the type used for AXNode IDs.
+ using AXID = int32_t;
+
+ // If a node is not yet or no longer valid, its ID should have a value of
+ // kInvalidAXID.
+ static constexpr AXID kInvalidAXID = 0;
+
AXNodeData();
virtual ~AXNodeData();
@@ -190,6 +198,14 @@ struct AX_BASE_EXPORT AXNodeData {
ax::mojom::ImageAnnotationStatus GetImageAnnotationStatus() const;
void SetImageAnnotationStatus(ax::mojom::ImageAnnotationStatus status);
+ // Helper to determine if the data belongs to a node that gains focus when
+ // clicked, such as a text field or a native HTML list box.
+ bool IsActivatable() const;
+
+ // Helper to determine if the data belongs to a node that is a native button
+ // or ARIA role="button" in a pressed state.
+ bool IsButtonPressed() const;
+
// Helper to determine if the data belongs to a node that can respond to
// clicks.
bool IsClickable() const;
@@ -197,13 +213,39 @@ struct AX_BASE_EXPORT AXNodeData {
// Helper to determine if the data has the ignored state or ignored role.
bool IsIgnored() const;
+ // Helper to determine if the data has the ignored state, the invisible state
+ // or the ignored role.
+ bool IsInvisibleOrIgnored() const;
+
// Helper to determine if the data belongs to a node that is invocable.
bool IsInvocable() const;
- // Helper to determine if the data belongs to a node that is a plain
- // textfield.
+ // Helper to determine if the data belongs to a node that is a menu button.
+ bool IsMenuButton() const;
+
+ // This data belongs to a text field. This is any widget in which the user
+ // should be able to enter and edit text.
+ //
+ // Examples include <input type="text">, <input type="password">, <textarea>,
+ // <div contenteditable="true">, <div role="textbox">, <div role="searchbox">
+ // and <div role="combobox">. Note that when an ARIA role that indicates that
+ // the widget is editable is used, such as "role=textbox", the element doesn't
+ // need to be contenteditable for this method to return true, as in theory
+ // JavaScript could be used to implement editing functionality. In practice,
+ // this situation should be rare.
+ bool IsTextField() const;
+
+ // This data belongs to a text field that is used for entering passwords.
+ bool IsPasswordField() const;
+
+ // This data belongs to a text field that doesn't accept rich text content,
+ // such as text with special formatting or styling.
bool IsPlainTextField() const;
+ // This data belongs to a text field that accepts rich text content, such as
+ // text with special formatting or styling.
+ bool IsRichTextField() const;
+
// Helper to determine if |GetRestriction| is either ReadOnly or Disabled.
// By default, all nodes that can't be edited are readonly.
bool IsReadOnlyOrDisabled() const;
diff --git a/chromium/ui/accessibility/ax_node_data_unittest.cc b/chromium/ui/accessibility/ax_node_data_unittest.cc
index 4ae414f2d87..492bf6a3857 100644
--- a/chromium/ui/accessibility/ax_node_data_unittest.cc
+++ b/chromium/ui/accessibility/ax_node_data_unittest.cc
@@ -4,6 +4,9 @@
#include "ui/accessibility/ax_node_data.h"
+#include <set>
+
+#include "base/stl_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/accessibility/ax_enum_util.h"
#include "ui/accessibility/ax_enums.mojom.h"
@@ -81,7 +84,51 @@ TEST(AXNodeDataTest, TextAttributes) {
EXPECT_TRUE(moved_styles == node_1.GetTextStyles());
}
-TEST(AXNodeDataTest, TestIsClickable) {
+TEST(AXNodeDataTest, IsButtonPressed) {
+ // A non-button element with CheckedState::kTrue should not return true for
+ // IsButtonPressed.
+ AXNodeData non_button_pressed;
+ non_button_pressed.role = ax::mojom::Role::kGenericContainer;
+ non_button_pressed.SetCheckedState(ax::mojom::CheckedState::kTrue);
+ EXPECT_FALSE(IsButton(non_button_pressed.role));
+ EXPECT_FALSE(non_button_pressed.IsButtonPressed());
+
+ // A button element with CheckedState::kTrue should return true for
+ // IsButtonPressed.
+ AXNodeData button_pressed;
+ button_pressed.role = ax::mojom::Role::kButton;
+ button_pressed.SetCheckedState(ax::mojom::CheckedState::kTrue);
+ EXPECT_TRUE(IsButton(button_pressed.role));
+ EXPECT_TRUE(button_pressed.IsButtonPressed());
+
+ button_pressed.role = ax::mojom::Role::kPopUpButton;
+ EXPECT_TRUE(IsButton(button_pressed.role));
+ EXPECT_TRUE(button_pressed.IsButtonPressed());
+
+ button_pressed.role = ax::mojom::Role::kToggleButton;
+ EXPECT_TRUE(IsButton(button_pressed.role));
+ EXPECT_TRUE(button_pressed.IsButtonPressed());
+
+ // A button element does not have CheckedState::kTrue should return false for
+ // IsButtonPressed.
+ AXNodeData button_not_pressed;
+ button_not_pressed.role = ax::mojom::Role::kButton;
+ button_not_pressed.SetCheckedState(ax::mojom::CheckedState::kNone);
+ EXPECT_TRUE(IsButton(button_not_pressed.role));
+ EXPECT_FALSE(button_not_pressed.IsButtonPressed());
+
+ button_not_pressed.role = ax::mojom::Role::kPopUpButton;
+ button_not_pressed.SetCheckedState(ax::mojom::CheckedState::kFalse);
+ EXPECT_TRUE(IsButton(button_not_pressed.role));
+ EXPECT_FALSE(button_not_pressed.IsButtonPressed());
+
+ button_not_pressed.role = ax::mojom::Role::kToggleButton;
+ button_not_pressed.SetCheckedState(ax::mojom::CheckedState::kMixed);
+ EXPECT_TRUE(IsButton(button_not_pressed.role));
+ EXPECT_FALSE(button_not_pressed.IsButtonPressed());
+}
+
+TEST(AXNodeDataTest, IsClickable) {
// Test for ax node data attribute with a custom default action verb.
AXNodeData data_default_action_verb;
@@ -110,28 +157,38 @@ TEST(AXNodeDataTest, TestIsClickable) {
}
// Test for iterating through all roles and validate if a role is clickable.
- std::unordered_set<ax::mojom::Role> roles_expected_is_clickable = {
+ std::set<ax::mojom::Role> roles_expected_is_clickable = {
ax::mojom::Role::kButton,
ax::mojom::Role::kCheckBox,
ax::mojom::Role::kColorWell,
+ ax::mojom::Role::kComboBoxMenuButton,
+ ax::mojom::Role::kDate,
+ ax::mojom::Role::kDateTime,
ax::mojom::Role::kDisclosureTriangle,
ax::mojom::Role::kDocBackLink,
ax::mojom::Role::kDocBiblioRef,
ax::mojom::Role::kDocGlossRef,
ax::mojom::Role::kDocNoteRef,
+ ax::mojom::Role::kImeCandidate,
+ ax::mojom::Role::kInputTime,
ax::mojom::Role::kLink,
+ ax::mojom::Role::kListBox,
ax::mojom::Role::kListBoxOption,
ax::mojom::Role::kMenuButton,
ax::mojom::Role::kMenuItem,
ax::mojom::Role::kMenuItemCheckBox,
ax::mojom::Role::kMenuItemRadio,
ax::mojom::Role::kMenuListOption,
- ax::mojom::Role::kMenuListPopup,
ax::mojom::Role::kPdfActionableHighlight,
ax::mojom::Role::kPopUpButton,
+ ax::mojom::Role::kPortal,
ax::mojom::Role::kRadioButton,
+ ax::mojom::Role::kSearchBox,
+ ax::mojom::Role::kSpinButton,
ax::mojom::Role::kSwitch,
ax::mojom::Role::kTab,
+ ax::mojom::Role::kTextField,
+ ax::mojom::Role::kTextFieldWithComboBox,
ax::mojom::Role::kToggleButton};
AXNodeData data;
@@ -146,15 +203,12 @@ TEST(AXNodeDataTest, TestIsClickable) {
<< ", Actual: isClickable=" << is_clickable
<< ", Expected: isClickable=" << !is_clickable);
- if (roles_expected_is_clickable.find(data.role) !=
- roles_expected_is_clickable.end())
- EXPECT_TRUE(is_clickable);
- else
- EXPECT_FALSE(is_clickable);
+ EXPECT_EQ(base::Contains(roles_expected_is_clickable, data.role),
+ is_clickable);
}
}
-TEST(AXNodeDataTest, TestIsInvocable) {
+TEST(AXNodeDataTest, IsInvocable) {
// Test for iterating through all roles and validate if a role is invocable.
// A role is invocable if it is clickable and supports neither expand collpase
// nor toggle.
@@ -162,27 +216,63 @@ TEST(AXNodeDataTest, TestIsInvocable) {
for (int role_idx = static_cast<int>(ax::mojom::Role::kMinValue);
role_idx <= static_cast<int>(ax::mojom::Role::kMaxValue); role_idx++) {
data.role = static_cast<ax::mojom::Role>(role_idx);
- bool supports_expand_collapse = data.SupportsExpandCollapse();
- bool supports_toggle = ui::SupportsToggle(data.role);
- bool is_clickable = data.IsClickable();
- bool is_invocable = data.IsInvocable();
+ bool is_activatable = data.IsActivatable();
+ const bool supports_expand_collapse = data.SupportsExpandCollapse();
+ const bool supports_toggle = ui::SupportsToggle(data.role);
+ const bool is_clickable = data.IsClickable();
+ const bool is_invocable = data.IsInvocable();
SCOPED_TRACE(testing::Message()
<< "ax::mojom::Role=" << ToString(data.role)
- << ", isClickable=" << is_clickable
- << ", supportsToggle=" << supports_toggle
+ << ", isClickable=" << is_clickable << ", isActivatable="
+ << is_activatable << ", supportsToggle=" << supports_toggle
<< ", supportsExpandCollapse=" << supports_expand_collapse
<< ", Actual: isInvocable=" << is_invocable
<< ", Expected: isInvocable=" << !is_invocable);
- if (is_clickable && !supports_toggle && !supports_expand_collapse)
+ if (is_clickable && !is_activatable && !supports_toggle &&
+ !supports_expand_collapse)
EXPECT_TRUE(is_invocable);
else
EXPECT_FALSE(is_invocable);
}
}
-TEST(AXNodeDataTest, TestSupportsExpandCollapse) {
+TEST(AXNodeDataTest, IsMenuButton) {
+ // A non button element should return false for IsMenuButton.
+ AXNodeData non_button;
+ non_button.role = ax::mojom::Role::kGenericContainer;
+ EXPECT_FALSE(IsButton(non_button.role));
+ EXPECT_FALSE(non_button.IsMenuButton());
+
+ // Only button element with HasPopup::kMenu should return true for
+ // IsMenuButton. All other ax::mojom::HasPopup types should return false.
+ AXNodeData button_with_popup;
+
+ button_with_popup.role = ax::mojom::Role::kButton;
+
+ for (int has_popup_idx = static_cast<int>(ax::mojom::HasPopup::kMinValue);
+ has_popup_idx <= static_cast<int>(ax::mojom::HasPopup::kMaxValue);
+ has_popup_idx++) {
+ button_with_popup.SetHasPopup(
+ static_cast<ax::mojom::HasPopup>(has_popup_idx));
+ bool is_menu_button = button_with_popup.IsMenuButton();
+
+ SCOPED_TRACE(testing::Message()
+ << "ax::mojom::Role=" << ToString(button_with_popup.role)
+ << ", hasPopup=" << button_with_popup.GetHasPopup()
+ << ", Actual: isMenuButton=" << is_menu_button
+ << ", Expected: isMenuButton=" << !is_menu_button);
+
+ if (IsButton(button_with_popup.role) &&
+ button_with_popup.GetHasPopup() == ax::mojom::HasPopup::kMenu)
+ EXPECT_TRUE(is_menu_button);
+ else
+ EXPECT_FALSE(is_menu_button);
+ }
+}
+
+TEST(AXNodeDataTest, SupportsExpandCollapse) {
// Test for iterating through all hasPopup attributes and validate if a
// hasPopup attribute supports expand collapse.
AXNodeData data_has_popup;
diff --git a/chromium/ui/accessibility/ax_node_position.cc b/chromium/ui/accessibility/ax_node_position.cc
index 1f1e121a719..ffce6af1700 100644
--- a/chromium/ui/accessibility/ax_node_position.cc
+++ b/chromium/ui/accessibility/ax_node_position.cc
@@ -299,23 +299,8 @@ std::vector<int32_t> AXNodePosition::GetWordStartOffsets() const {
if (IsEmptyObjectReplacedByCharacter())
return {0};
- std::vector<int32_t> offsets = GetAnchor()->data().GetIntListAttribute(
+ return GetAnchor()->data().GetIntListAttribute(
ax::mojom::IntListAttribute::kWordStarts);
- if (!offsets.empty() ||
- GetAnchor()
- ->data()
- .GetIntListAttribute(ax::mojom::IntListAttribute::kCharacterOffsets)
- .empty() ||
- IsInWhiteSpace()) {
- return offsets;
- }
-
- // When the position is on a node that has character offsets but has no word
- // boundary, treat the entire node content as a word. This can happen when
- // the node contains only "skippable words", like whitespaces, punctuation or
- // other special characters. E.g., "•" or any emoji.
- // TODO: This should not be needed once https://crbug.com/1028830 is fixed.
- return {0};
}
std::vector<int32_t> AXNodePosition::GetWordEndOffsets() const {
@@ -332,23 +317,8 @@ std::vector<int32_t> AXNodePosition::GetWordEndOffsets() const {
if (IsEmptyObjectReplacedByCharacter())
return {1};
- std::vector<int32_t> offsets = GetAnchor()->data().GetIntListAttribute(
+ return GetAnchor()->data().GetIntListAttribute(
ax::mojom::IntListAttribute::kWordEnds);
- if (!offsets.empty() ||
- GetAnchor()
- ->data()
- .GetIntListAttribute(ax::mojom::IntListAttribute::kCharacterOffsets)
- .empty() ||
- IsInWhiteSpace()) {
- return offsets;
- }
-
- // When the position is on a node that has character offsets but has no word
- // boundary, treat the entire node content as a word. This can happen when
- // the node contains only "skippable words", like whitespaces, punctuation or
- // other special characters. E.g., "•" or any emoji.
- // TODO: This should not be needed once https://crbug.com/1028830 is fixed.
- return {MaxTextOffset()};
}
AXNode::AXID AXNodePosition::GetNextOnLineID(AXNode::AXID node_id) const {
diff --git a/chromium/ui/accessibility/ax_node_position_unittest.cc b/chromium/ui/accessibility/ax_node_position_unittest.cc
index 59f8bade215..d7e7b25695e 100644
--- a/chromium/ui/accessibility/ax_node_position_unittest.cc
+++ b/chromium/ui/accessibility/ax_node_position_unittest.cc
@@ -6795,267 +6795,6 @@ TEST_F(AXPositionTest, CreateLinePositionsMultipleAnchorsInSingleLine) {
EXPECT_EQ(0, previous_line_end_position->text_offset());
}
-TEST_F(AXPositionTest,
- CreateNextAndPreviousWordStartAndEndPositionWithoutWordBoundaries) {
- // This test updates the tree structure to test a specific edge case -
- // text nodes sometimes have no word boundaries even though they are not
- // empty. This happens with emojis and special characters. We need to
- // "augment" the word boundaries of such nodes for them to be exposed to the
- // text pattern and allow word navigation.
-
- // ++1 kRootWebArea
- // ++++2 kStaticText
- // ++++++3 kInlineTextBox "3"
- // ++++4 kStaticText
- // ++++++5 kInlineTextBox "•"
- // ++++6 kStaticText
- // ++++++7 kInlineTextBox "14"
- // ++++8 kStaticText
- // ++++++9 kInlineTextBox "❤"
- // ++++10 kStaticText
- // ++++++11 kInlineTextBox " " (tab)
- // ++++12 kStaticText
- // ++++++13 kInlineTextBox "159265358979323846264"
- AXNodeData root_1;
- AXNodeData static_text_2;
- AXNodeData inline_box_3;
- AXNodeData static_text_4;
- AXNodeData inline_box_5;
- AXNodeData static_text_6;
- AXNodeData inline_box_7;
- AXNodeData static_text_8;
- AXNodeData inline_box_9;
- AXNodeData static_text_10;
- AXNodeData inline_box_11;
- AXNodeData static_text_12;
- AXNodeData inline_box_13;
-
- root_1.id = 1;
- static_text_2.id = 2;
- inline_box_3.id = 3;
- static_text_4.id = 4;
- inline_box_5.id = 5;
- static_text_6.id = 6;
- inline_box_7.id = 7;
- static_text_8.id = 8;
- inline_box_9.id = 9;
- static_text_10.id = 10;
- inline_box_11.id = 11;
- static_text_12.id = 12;
- inline_box_13.id = 13;
-
- root_1.role = ax::mojom::Role::kRootWebArea;
- root_1.child_ids = {static_text_2.id, static_text_4.id, static_text_6.id,
- static_text_8.id, static_text_10.id, static_text_12.id};
-
- static_text_2.role = ax::mojom::Role::kStaticText;
- static_text_2.SetName("3");
- static_text_2.child_ids = {inline_box_3.id};
-
- inline_box_3.role = ax::mojom::Role::kInlineTextBox;
- inline_box_3.SetName("3");
- inline_box_3.AddIntListAttribute(ax::mojom::IntListAttribute::kWordStarts,
- std::vector<int32_t>{0});
- inline_box_3.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds,
- std::vector<int32_t>{1});
-
- static_text_4.role = ax::mojom::Role::kStaticText;
- static_text_4.SetName("•");
- static_text_4.child_ids = {inline_box_5.id};
-
- inline_box_5.role = ax::mojom::Role::kInlineTextBox;
- inline_box_5.SetName("•");
- inline_box_5.AddIntListAttribute(
- ax::mojom::IntListAttribute::kCharacterOffsets, std::vector<int32_t>{0});
-
- static_text_6.role = ax::mojom::Role::kStaticText;
- static_text_6.SetName("14");
- static_text_6.child_ids = {inline_box_7.id};
-
- inline_box_7.role = ax::mojom::Role::kInlineTextBox;
- inline_box_7.SetName("14");
- inline_box_7.AddIntListAttribute(ax::mojom::IntListAttribute::kWordStarts,
- std::vector<int32_t>{0});
- inline_box_7.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds,
- std::vector<int32_t>{2});
-
- // Heart emoji.
- static_text_8.role = ax::mojom::Role::kStaticText;
- static_text_8.SetName("\u2764");
- static_text_8.child_ids = {inline_box_9.id};
-
- inline_box_9.role = ax::mojom::Role::kInlineTextBox;
- inline_box_9.SetName("\u2764");
- inline_box_9.AddIntListAttribute(
- ax::mojom::IntListAttribute::kCharacterOffsets, std::vector<int32_t>{0});
-
- // Tab character.
- static_text_10.role = ax::mojom::Role::kStaticText;
- static_text_10.SetName("\u0009");
- static_text_10.child_ids = {inline_box_11.id};
-
- inline_box_11.role = ax::mojom::Role::kInlineTextBox;
- inline_box_11.SetName("\u0009");
- inline_box_11.AddIntListAttribute(
- ax::mojom::IntListAttribute::kCharacterOffsets, std::vector<int32_t>{0});
-
- static_text_12.role = ax::mojom::Role::kStaticText;
- static_text_12.SetName("159265358979323846264");
- static_text_12.child_ids = {inline_box_13.id};
-
- inline_box_13.role = ax::mojom::Role::kInlineTextBox;
- inline_box_13.SetName("159265358979323846264");
- inline_box_13.AddIntListAttribute(
- ax::mojom::IntListAttribute::kCharacterOffsets, std::vector<int32_t>{0});
-
- SetTree(CreateAXTree({root_1, static_text_2, inline_box_3, static_text_4,
- inline_box_5, static_text_6, inline_box_7,
- static_text_8, inline_box_9, static_text_10,
- inline_box_11, static_text_12, inline_box_13}));
-
- // Test word start positions. Start at the first node.
- {
- TestPositionType text_position = AXNodePosition::CreateTextPosition(
- GetTreeID(), inline_box_3.id, 0 /* text_offset */,
- ax::mojom::TextAffinity::kDownstream);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_3.id, text_position->anchor_id());
- ASSERT_EQ(0, text_position->text_offset());
-
- // Move forwards from "<3>" to "<•>".
- text_position = text_position->CreateNextWordStartPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_5.id, text_position->anchor_id());
- ASSERT_EQ(0, text_position->text_offset());
-
- // Move forwards from "<•>" to "<1>4".
- text_position = text_position->CreateNextWordStartPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_7.id, text_position->anchor_id());
- ASSERT_EQ(0, text_position->text_offset());
-
- // Move forwards from "<1>4" to "<\u2764>".
- text_position = text_position->CreateNextWordStartPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_9.id, text_position->anchor_id());
- ASSERT_EQ(0, text_position->text_offset());
-
- // Move forwards from "<\u2764>" to "<1>59265358979323846264".
- text_position = text_position->CreateNextWordStartPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_13.id, text_position->anchor_id());
- ASSERT_EQ(0, text_position->text_offset());
-
- // Move backwards from "<1>59265358979323846264" to "<\u2764>".
- text_position = text_position->CreatePreviousWordStartPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_9.id, text_position->anchor_id());
- ASSERT_EQ(0, text_position->text_offset());
-
- // Move backwards from "<\u2764>" to "<1>4".
- text_position = text_position->CreatePreviousWordStartPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_7.id, text_position->anchor_id());
- ASSERT_EQ(0, text_position->text_offset());
-
- // Move backwards from "<1>4" to "<•>".
- text_position = text_position->CreatePreviousWordStartPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_5.id, text_position->anchor_id());
- ASSERT_EQ(0, text_position->text_offset());
- }
-
- // Test word end positions. Start at the last node.
- {
- TestPositionType text_position = AXNodePosition::CreateTextPosition(
- GetTreeID(), inline_box_13.id, 21 /* text_offset */,
- ax::mojom::TextAffinity::kDownstream);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_13.id, text_position->anchor_id());
- ASSERT_EQ(21, text_position->text_offset());
-
- // Move backwards from "159265358979323846264<>" to "\u2764<>"
- text_position = text_position->CreatePreviousWordEndPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_9.id, text_position->anchor_id());
- ASSERT_EQ(1, text_position->text_offset());
-
- // Move backwards from "\u2764<>" to "14<>"
- text_position = text_position->CreatePreviousWordEndPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_7.id, text_position->anchor_id());
- ASSERT_EQ(2, text_position->text_offset());
-
- // Move backwards from "14<>" to "•<>"
- text_position = text_position->CreatePreviousWordEndPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_5.id, text_position->anchor_id());
- ASSERT_EQ(1, text_position->text_offset());
-
- // Move backwards from "•<>" to "3<>"
- text_position = text_position->CreatePreviousWordEndPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_3.id, text_position->anchor_id());
- ASSERT_EQ(1, text_position->text_offset());
-
- // Move forwards from "3<>" to "•<>"
- text_position = text_position->CreateNextWordEndPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_5.id, text_position->anchor_id());
- ASSERT_EQ(1, text_position->text_offset());
-
- // Move forwards from "•<>" to "14<>"
- text_position = text_position->CreateNextWordEndPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_7.id, text_position->anchor_id());
- ASSERT_EQ(2, text_position->text_offset());
-
- // Move forwards from "14<>" to "\u2764<>"
- text_position = text_position->CreateNextWordEndPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_9.id, text_position->anchor_id());
- ASSERT_EQ(1, text_position->text_offset());
-
- // Move forwards from "\u2764<>" to "159265358979323846264<>"
- text_position = text_position->CreateNextWordEndPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- ASSERT_NE(nullptr, text_position);
- ASSERT_TRUE(text_position->IsTextPosition());
- ASSERT_EQ(inline_box_13.id, text_position->anchor_id());
- ASSERT_EQ(21, text_position->text_offset());
- }
-}
-
TEST_F(AXPositionTest, CreateNextWordPositionInList) {
// This test updates the tree structure to test a specific edge case -
// next word navigation inside a list with AXListMarkers nodes.
@@ -7515,7 +7254,7 @@ TEST_F(AXPositionTest, EmptyObjectReplacedByCharacterTextNavigation) {
generic_container_11, generic_container_12,
static_text_13, button_14, generic_container_15}));
- // CreateStartWordStartPosition tests.
+ // CreateNextWordStartPosition tests.
TestPositionType position = AXNodePosition::CreateTextPosition(
GetTreeID(), inline_box_3.id, 0 /* child_index_or_text_offset */,
ax::mojom::TextAffinity::kDownstream);
@@ -7687,6 +7426,155 @@ TEST_F(AXPositionTest, EmptyObjectReplacedByCharacterTextNavigation) {
EXPECT_EQ(1, text_position->text_offset());
}
+TEST_F(AXPositionTest, TextNavigationWithCollapsedCombobox) {
+ // On Windows, a <select> element is replaced by a combobox that contains
+ // an AXMenuListPopup parent of AXMenuListOptions. When the select dropdown is
+ // collapsed, the subtree of that combobox needs to be hidden and, when
+ // expanded, it must be accessible in the tree. This test ensures we can't
+ // navigate into the options of a collapsed menu list popup.
+ g_ax_embedded_object_behavior = AXEmbeddedObjectBehavior::kExposeCharacter;
+
+ // ++1 kRootWebArea
+ // ++++2 kStaticText "Hi"
+ // ++++++3 kInlineTextBox "Hi"
+ // ++++4 kPopUpButton
+ // ++++++5 kMenuListPopup
+ // ++++++++6 kMenuListOption "Option"
+ // ++++7 kStaticText "3.14"
+ // ++++++8 kInlineTextBox "3.14"
+ AXNodeData root_1;
+ AXNodeData static_text_2;
+ AXNodeData inline_box_3;
+ AXNodeData popup_button_4;
+ AXNodeData menu_list_popup_5;
+ AXNodeData menu_list_option_6;
+ AXNodeData static_text_7;
+ AXNodeData inline_box_8;
+
+ root_1.id = 1;
+ static_text_2.id = 2;
+ inline_box_3.id = 3;
+ popup_button_4.id = 4;
+ menu_list_popup_5.id = 5;
+ menu_list_option_6.id = 6;
+ static_text_7.id = 7;
+ inline_box_8.id = 8;
+
+ root_1.role = ax::mojom::Role::kRootWebArea;
+ root_1.child_ids = {static_text_2.id, popup_button_4.id, static_text_7.id};
+
+ static_text_2.role = ax::mojom::Role::kStaticText;
+ static_text_2.SetName("Hi");
+ static_text_2.child_ids = {inline_box_3.id};
+
+ inline_box_3.role = ax::mojom::Role::kInlineTextBox;
+ inline_box_3.SetName("Hi");
+ inline_box_3.AddIntListAttribute(ax::mojom::IntListAttribute::kWordStarts,
+ {0});
+ inline_box_3.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds, {2});
+
+ popup_button_4.role = ax::mojom::Role::kPopUpButton;
+ popup_button_4.child_ids = {menu_list_popup_5.id};
+ popup_button_4.AddState(ax::mojom::State::kCollapsed);
+
+ menu_list_popup_5.role = ax::mojom::Role::kMenuListPopup;
+ menu_list_popup_5.child_ids = {menu_list_option_6.id};
+
+ menu_list_option_6.role = ax::mojom::Role::kMenuListOption;
+ menu_list_option_6.SetName("Option");
+
+ static_text_7.role = ax::mojom::Role::kStaticText;
+ static_text_7.SetName("3.14");
+ static_text_7.child_ids = {inline_box_8.id};
+
+ inline_box_8.role = ax::mojom::Role::kInlineTextBox;
+ inline_box_8.SetName("3.14");
+ inline_box_8.AddIntListAttribute(ax::mojom::IntListAttribute::kWordStarts,
+ {0});
+ inline_box_8.AddIntListAttribute(ax::mojom::IntListAttribute::kWordEnds, {4});
+
+ SetTree(CreateAXTree({root_1, static_text_2, inline_box_3, popup_button_4,
+ menu_list_popup_5, menu_list_option_6, static_text_7,
+ inline_box_8}));
+
+ // Collapsed - Forward navigation.
+ TestPositionType position = AXNodePosition::CreateTextPosition(
+ GetTreeID(), inline_box_3.id, 0, ax::mojom::TextAffinity::kDownstream);
+ ASSERT_NE(nullptr, position);
+
+ position = position->CreateNextParagraphStartPosition(
+ AXBoundaryBehavior::StopAtLastAnchorBoundary);
+ ASSERT_NE(nullptr, position);
+ EXPECT_EQ(popup_button_4.id, position->anchor_id());
+ EXPECT_EQ(0, position->text_offset());
+
+ position = position->CreateNextParagraphStartPosition(
+ AXBoundaryBehavior::StopAtLastAnchorBoundary);
+ ASSERT_NE(nullptr, position);
+ EXPECT_EQ(inline_box_8.id, position->anchor_id());
+ EXPECT_EQ(0, position->text_offset());
+
+ // Collapsed - Backward navigation.
+ position = AXNodePosition::CreateTextPosition(
+ GetTreeID(), inline_box_8.id, 4, ax::mojom::TextAffinity::kDownstream);
+ ASSERT_NE(nullptr, position);
+
+ position = position->CreatePreviousParagraphEndPosition(
+ AXBoundaryBehavior::StopAtLastAnchorBoundary);
+ ASSERT_NE(nullptr, position);
+ EXPECT_EQ(popup_button_4.id, position->anchor_id());
+ // The content of this popup button should be replaced with the empty object
+ // character of length 1.
+ EXPECT_EQ(1, position->text_offset());
+
+ position = position->CreatePreviousParagraphEndPosition(
+ AXBoundaryBehavior::StopAtLastAnchorBoundary);
+ ASSERT_NE(nullptr, position);
+ EXPECT_EQ(inline_box_3.id, position->anchor_id());
+ EXPECT_EQ(2, position->text_offset());
+
+ // Expand the combobox for the rest of the test.
+ popup_button_4.RemoveState(ax::mojom::State::kCollapsed);
+ popup_button_4.AddState(ax::mojom::State::kExpanded);
+ AXTreeUpdate update;
+ update.nodes = {popup_button_4};
+ ASSERT_TRUE(GetTree()->Unserialize(update));
+
+ // Expanded - Forward navigation.
+ position = AXNodePosition::CreateTextPosition(
+ GetTreeID(), inline_box_3.id, 0, ax::mojom::TextAffinity::kDownstream);
+ ASSERT_NE(nullptr, position);
+
+ position = position->CreateNextParagraphStartPosition(
+ AXBoundaryBehavior::StopAtLastAnchorBoundary);
+ ASSERT_NE(nullptr, position);
+ EXPECT_EQ(menu_list_option_6.id, position->anchor_id());
+ EXPECT_EQ(0, position->text_offset());
+
+ position = position->CreateNextParagraphStartPosition(
+ AXBoundaryBehavior::StopAtLastAnchorBoundary);
+ ASSERT_NE(nullptr, position);
+ EXPECT_EQ(inline_box_8.id, position->anchor_id());
+ EXPECT_EQ(0, position->text_offset());
+
+ // Expanded- Backward navigation.
+ position = AXNodePosition::CreateTextPosition(
+ GetTreeID(), inline_box_8.id, 4, ax::mojom::TextAffinity::kDownstream);
+ ASSERT_NE(nullptr, position);
+
+ position = position->CreatePreviousParagraphEndPosition(
+ AXBoundaryBehavior::StopAtLastAnchorBoundary);
+ ASSERT_NE(nullptr, position);
+ EXPECT_EQ(menu_list_option_6.id, position->anchor_id());
+ EXPECT_EQ(1, position->text_offset());
+
+ position = position->CreatePreviousParagraphEndPosition(
+ AXBoundaryBehavior::StopAtLastAnchorBoundary);
+ ASSERT_NE(nullptr, position);
+ EXPECT_EQ(inline_box_3.id, position->anchor_id());
+ EXPECT_EQ(2, position->text_offset());
+}
+
//
// Parameterized tests.
//
diff --git a/chromium/ui/accessibility/ax_param_traits_macros.h b/chromium/ui/accessibility/ax_param_traits_macros.h
index 6c5315fabb8..d33912c774e 100644
--- a/chromium/ui/accessibility/ax_param_traits_macros.h
+++ b/chromium/ui/accessibility/ax_param_traits_macros.h
@@ -9,6 +9,7 @@
#include "ipc/ipc_message_macros.h"
#include "ui/accessibility/ax_enums.mojom-shared.h"
#include "ui/accessibility/ax_event.h"
+#include "ui/accessibility/ax_event_intent.h"
#include "ui/accessibility/ax_export.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/ax_tree_id.h"
@@ -36,6 +37,11 @@ IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::StringAttribute,
IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::TextAffinity,
ax::mojom::TextAffinity::kMaxValue)
IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::EventFrom, ax::mojom::EventFrom::kMaxValue)
+IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::Command, ax::mojom::Command::kMaxValue)
+IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::TextBoundary,
+ ax::mojom::TextBoundary::kMaxValue)
+IPC_ENUM_TRAITS_MAX_VALUE(ax::mojom::MoveDirection,
+ ax::mojom::MoveDirection::kMaxValue)
IPC_STRUCT_TRAITS_BEGIN(ui::AXRelativeBounds)
IPC_STRUCT_TRAITS_MEMBER(offset_container_id)
@@ -47,9 +53,16 @@ IPC_STRUCT_TRAITS_BEGIN(ui::AXEvent)
IPC_STRUCT_TRAITS_MEMBER(event_type)
IPC_STRUCT_TRAITS_MEMBER(id)
IPC_STRUCT_TRAITS_MEMBER(event_from)
+ IPC_STRUCT_TRAITS_MEMBER(event_intents)
IPC_STRUCT_TRAITS_MEMBER(action_request_id)
IPC_STRUCT_TRAITS_END()
+IPC_STRUCT_TRAITS_BEGIN(ui::AXEventIntent)
+ IPC_STRUCT_TRAITS_MEMBER(command)
+ IPC_STRUCT_TRAITS_MEMBER(text_boundary)
+ IPC_STRUCT_TRAITS_MEMBER(move_direction)
+IPC_STRUCT_TRAITS_END()
+
IPC_STRUCT_TRAITS_BEGIN(ui::AXNodeData)
IPC_STRUCT_TRAITS_MEMBER(id)
IPC_STRUCT_TRAITS_MEMBER(role)
diff --git a/chromium/ui/accessibility/ax_position.h b/chromium/ui/accessibility/ax_position.h
index a9cf694ed5d..70f9501c195 100644
--- a/chromium/ui/accessibility/ax_position.h
+++ b/chromium/ui/accessibility/ax_position.h
@@ -1012,19 +1012,16 @@ class AXPosition {
if (!position->GetAnchor())
return CreateNullPosition();
- if (GetAnchor()->IsIgnored()) {
- // In this class, we define the empty object as one whose all
- // descendants are ignored. Its content is replaced by the empty
- // object character (string of length 1). Its underlying content is
- // not exposed. A position on an ignored descendant of an empty object
- // is invalid. To make it valid we move the position from its ignored
- // descendant to the empty object node itself.
- AXNodeType* empty_object_node = GetEmptyObjectAncestorNode();
- if (empty_object_node) {
- return CreateTreePosition(
- position->tree_id(), GetAnchorID(empty_object_node),
- position->child_index() == BEFORE_TEXT ? BEFORE_TEXT : 0);
- }
+ if (AXNodeType* empty_object_node = GetEmptyObjectAncestorNode()) {
+ // In this class and on certain platforms, we define the empty object
+ // as one that doesn't expose its underlying content. Its content is
+ // replaced by the empty object character (string of length 1). A
+ // position on a descendant of an empty object is invalid. To make it
+ // valid we move the position from the descendant to the empty object
+ // node itself.
+ return CreateTreePosition(
+ position->tree_id(), GetAnchorID(empty_object_node),
+ position->child_index() == BEFORE_TEXT ? BEFORE_TEXT : 0);
}
if (position->child_index_ == BEFORE_TEXT)
@@ -1040,21 +1037,20 @@ class AXPosition {
if (!position->GetAnchor())
return CreateNullPosition();
- if (GetAnchor()->IsIgnored()) {
- // This is needed because an empty object as defined in this class can
- // have ignored descendants that should not be exposed. See comment
- // above in similar implementation for AXPositionKind::TREE_POSITION.
- AXNodeType* empty_object_node = GetEmptyObjectAncestorNode();
- if (empty_object_node) {
- // We set the |text_offset_| to either 0 or 1 here because the
- // MaxTextOffset of an empty object is 1 (the empty object
- // character, a string of length 1). If the invalid position was
- // already at the start of the node, we set it to 0.
- return CreateTextPosition(position->tree_id(),
- GetAnchorID(empty_object_node),
- position->text_offset() > 0 ? 1 : 0,
- ax::mojom::TextAffinity::kDownstream);
- }
+ if (AXNodeType* empty_object_node = GetEmptyObjectAncestorNode()) {
+ // This is needed because an empty object as defined in this class and
+ // on certain platforms can have descendants that should not be
+ // exposed. See comment above in similar implementation for
+ // AXPositionKind::TREE_POSITION.
+ //
+ // We set the |text_offset_| to either 0 or 1 here because the
+ // MaxTextOffset of an empty object is 1 (the empty object character,
+ // a string of length 1). If the invalid position was already at the
+ // start of the node, we set it to 0.
+ return CreateTextPosition(position->tree_id(),
+ GetAnchorID(empty_object_node),
+ position->text_offset() > 0 ? 1 : 0,
+ ax::mojom::TextAffinity::kDownstream);
}
if (position->text_offset_ <= 0) {
@@ -3020,15 +3016,26 @@ class AXPosition {
// Returns true if this position is on an empty object node that needs to
// be represented by an empty object replacement character. It does when the
- // node has no unignored child, is not a text object and we are on a platform
- // that enables this feature.
+ // node is a collapsed menu list popup button or has no unignored child and is
+ // not a text object. This feature is only enabled on some platforms.
bool IsEmptyObjectReplacedByCharacter() const {
if (g_ax_embedded_object_behavior ==
AXEmbeddedObjectBehavior::kSuppressCharacter ||
- IsNullPosition() || AnchorUnignoredChildCount()) {
+ IsNullPosition()) {
return false;
}
+ // A collapsed popup button that contains a menu list popup (i.e, the exact
+ // subtree representation we get from a collapsed <select> element on
+ // Windows) should not expose its children even though they are not ignored.
+ if (GetAnchor()->IsCollapsedMenuListPopUpButton())
+ return true;
+
+ // All other elements that have unignored descendants should not be treated
+ // as empty objects.
+ if (AnchorUnignoredChildCount())
+ return false;
+
// All unignored leaf nodes in the AXTree except the document and the text
// nodes should be replaced by the embedded object character. Also, nodes
// that only have ignored children (e.g., a button that contains only an
@@ -3049,12 +3056,10 @@ class AXPosition {
return false;
}
- // Empty objects can only have ignored descendants. If the node is not
- // ignored, it can't be a descendant of an empty object.
- if (!GetAnchor()->IsIgnored() || !GetEmptyObjectAncestorNode())
- return false;
-
- return true;
+ // Empty objects are only possible on a collapsed popup button parent of a
+ // menu list popup or a node that only has ignored descendants. If it has no
+ // empty object ancestor, it can't be inside of an empty object.
+ return GetEmptyObjectAncestorNode();
}
AXNodeType* GetEmptyObjectAncestorNode() const {
@@ -3064,6 +3069,17 @@ class AXPosition {
return nullptr;
}
+ if (!GetAnchor()->IsIgnored()) {
+ // The only case where a descendant of an empty object can be unignored is
+ // when we are inside of a collapsed popup button parent of a menu list
+ // popup.
+ if (AXNodeType* popup_button =
+ GetAnchor()->GetCollapsedMenuListPopUpButtonAncestor()) {
+ return popup_button;
+ }
+ return nullptr;
+ }
+
// The first unignored ancestor is necessarily the empty object if this node
// is the descendant of an empty object.
AXNodeType* ancestor_node = GetLowestUnignoredAncestor();
diff --git a/chromium/ui/accessibility/ax_role_properties.cc b/chromium/ui/accessibility/ax_role_properties.cc
index c72c580a8c3..587b4e81e19 100644
--- a/chromium/ui/accessibility/ax_role_properties.cc
+++ b/chromium/ui/accessibility/ax_role_properties.cc
@@ -52,29 +52,54 @@ bool IsAlert(const ax::mojom::Role role) {
}
}
+bool IsButton(const ax::mojom::Role role) {
+ // According to the WAI-ARIA spec, native button or role="button"
+ // supports |aria-expanded| and |aria-pressed|.
+ // If the button has |aria-expanded| set, then it takes on
+ // Role::kPopUpButton.
+ // If the button has |aria-pressed| set, then it takes on
+ // Role::kToggleButton.
+ // https://www.w3.org/TR/wai-aria-1.1/#button
+ return role == ax::mojom::Role::kButton ||
+ role == ax::mojom::Role::kPopUpButton ||
+ role == ax::mojom::Role::kToggleButton;
+}
+
bool IsClickable(const ax::mojom::Role role) {
switch (role) {
case ax::mojom::Role::kButton:
case ax::mojom::Role::kCheckBox:
case ax::mojom::Role::kColorWell:
+ case ax::mojom::Role::kComboBoxMenuButton:
+ case ax::mojom::Role::kDate:
+ case ax::mojom::Role::kDateTime:
case ax::mojom::Role::kDisclosureTriangle:
case ax::mojom::Role::kDocBackLink:
case ax::mojom::Role::kDocBiblioRef:
case ax::mojom::Role::kDocGlossRef:
case ax::mojom::Role::kDocNoteRef:
+ case ax::mojom::Role::kImeCandidate:
+ case ax::mojom::Role::kInputTime:
case ax::mojom::Role::kLink:
+ case ax::mojom::Role::kListBox:
case ax::mojom::Role::kListBoxOption:
case ax::mojom::Role::kMenuButton:
case ax::mojom::Role::kMenuItem:
case ax::mojom::Role::kMenuItemCheckBox:
case ax::mojom::Role::kMenuItemRadio:
case ax::mojom::Role::kMenuListOption:
- case ax::mojom::Role::kMenuListPopup:
case ax::mojom::Role::kPdfActionableHighlight:
case ax::mojom::Role::kPopUpButton:
+ case ax::mojom::Role::kPortal:
case ax::mojom::Role::kRadioButton:
+ case ax::mojom::Role::kSearchBox:
+ case ax::mojom::Role::kSpinButton:
case ax::mojom::Role::kSwitch:
case ax::mojom::Role::kTab:
+ case ax::mojom::Role::kTextField:
+ case ax::mojom::Role::kTextFieldWithComboBox:
+ // kTree and related roles are not included because they are not natively
+ // supported by HTML and so their "clickable" behavior is uncertain.
case ax::mojom::Role::kToggleButton:
return true;
default:
@@ -245,6 +270,10 @@ bool IsIframe(ax::mojom::Role role) {
}
}
+bool IsImageOrVideo(const ax::mojom::Role role) {
+ return IsImage(role) || role == ax::mojom::Role::kVideo;
+}
+
bool IsImage(const ax::mojom::Role role) {
switch (role) {
case ax::mojom::Role::kCanvas:
@@ -259,10 +288,6 @@ bool IsImage(const ax::mojom::Role role) {
}
}
-bool IsImageOrVideo(const ax::mojom::Role role) {
- return IsImage(role) || role == ax::mojom::Role::kVideo;
-}
-
bool IsItemLike(const ax::mojom::Role role) {
switch (role) {
case ax::mojom::Role::kArticle:
@@ -368,15 +393,47 @@ bool IsMenuRelated(const ax::mojom::Role role) {
}
}
+bool IsPresentational(const ax::mojom::Role role) {
+ switch (role) {
+ case ax::mojom::Role::kNone:
+ case ax::mojom::Role::kPresentational:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool IsRangeValueSupported(const ax::mojom::Role role) {
+ // https://www.w3.org/TR/wai-aria-1.1/#aria-valuenow
+ // https://www.w3.org/TR/wai-aria-1.1/#aria-valuetext
+ // Roles that support aria-valuetext / aria-valuenow
+ switch (role) {
+ case ax::mojom::Role::kMeter:
+ case ax::mojom::Role::kProgressIndicator:
+ case ax::mojom::Role::kScrollBar:
+ case ax::mojom::Role::kSlider:
+ case ax::mojom::Role::kSpinButton:
+ case ax::mojom::Role::kSplitter:
+ return true;
+ default:
+ return false;
+ }
+}
+
bool IsReadOnlySupported(const ax::mojom::Role role) {
// https://www.w3.org/TR/wai-aria-1.1/#aria-readonly
// Roles that support aria-readonly
switch (role) {
case ax::mojom::Role::kCheckBox:
+ case ax::mojom::Role::kColorWell:
case ax::mojom::Role::kComboBoxGrouping:
case ax::mojom::Role::kComboBoxMenuButton:
+ case ax::mojom::Role::kDate:
+ case ax::mojom::Role::kDateTime:
case ax::mojom::Role::kGrid:
+ case ax::mojom::Role::kInputTime:
case ax::mojom::Role::kListBox:
+ case ax::mojom::Role::kMenuButton:
case ax::mojom::Role::kMenuItemCheckBox:
case ax::mojom::Role::kMenuItemRadio:
case ax::mojom::Role::kMenuListPopup:
@@ -389,11 +446,12 @@ bool IsReadOnlySupported(const ax::mojom::Role role) {
case ax::mojom::Role::kSwitch:
case ax::mojom::Role::kTextField:
case ax::mojom::Role::kTextFieldWithComboBox:
+ case ax::mojom::Role::kToggleButton:
case ax::mojom::Role::kTreeGrid:
return true;
// https://www.w3.org/TR/wai-aria-1.1/#aria-readonly
- // ARIA-1.1+ 'gridcell', supports aria-readonly, but 'cell' does not
+ // ARIA-1.1+ 'gridcell', supports aria-readonly, but 'cell' does not.
//
// https://www.w3.org/TR/wai-aria-1.1/#columnheader
// https://www.w3.org/TR/wai-aria-1.1/#rowheader
@@ -407,9 +465,8 @@ bool IsReadOnlySupported(const ax::mojom::Role role) {
case ax::mojom::Role::kColumnHeader:
return false;
default:
- break;
+ return false;
}
- return false;
}
bool IsRowContainer(const ax::mojom::Role role) {
@@ -686,6 +743,22 @@ bool SupportsOrientation(const ax::mojom::Role role) {
}
}
+bool SupportsSelected(const ax::mojom::Role role) {
+ switch (role) {
+ case ax::mojom::Role::kCell:
+ case ax::mojom::Role::kColumnHeader:
+ case ax::mojom::Role::kListBoxOption:
+ case ax::mojom::Role::kMenuListOption:
+ case ax::mojom::Role::kRow:
+ case ax::mojom::Role::kRowHeader:
+ case ax::mojom::Role::kTab:
+ case ax::mojom::Role::kTreeItem:
+ return true;
+ default:
+ return false;
+ }
+}
+
bool SupportsToggle(const ax::mojom::Role role) {
switch (role) {
case ax::mojom::Role::kCheckBox:
diff --git a/chromium/ui/accessibility/ax_role_properties.h b/chromium/ui/accessibility/ax_role_properties.h
index d601cdc89a7..536d2758440 100644
--- a/chromium/ui/accessibility/ax_role_properties.h
+++ b/chromium/ui/accessibility/ax_role_properties.h
@@ -15,15 +15,31 @@ namespace ui {
//
// Please keep these functions in alphabetic order.
-// Returns true for objects which have the characteristic "Children
-// Presentational: True". This concept is defined in the ARIA specification. See
+// Returns true for object roles that have the attribute "Children
+// Presentational: True" as defined in the ARIA Specification.
// https://www.w3.org/TR/wai-aria-1.1/#childrenArePresentational.
AX_BASE_EXPORT bool HasPresentationalChildren(const ax::mojom::Role role);
-// Checks if the given role is an alert or alert-dialog type.
+// Returns true if the given role is an alert or alert-dialog type.
AX_BASE_EXPORT bool IsAlert(const ax::mojom::Role role);
-// Checks if the given role is a clickable type.
+// Returns true if the provided role belongs to a native or an ARIA button.
+AX_BASE_EXPORT bool IsButton(const ax::mojom::Role role);
+
+// Returns true if the provided role belongs to an object on which a click
+// handler is commonly attached, or to an object that carries out an action when
+// clicked, such as activating itself, opening a dialog or closing a menu.
+//
+// A button and a checkbox fall in the first category, whilst a color well and a
+// list menu option in the second. Note that a text field, or a similar element,
+// also carries out an action when clicked. It focuses itself, so the action
+// verb is "activate". Not all roles that inherently support a click handler or
+// that can potentially be focused are included, because in that case even a div
+// could be made clickable or focusable.
+//
+// The reason for the existence of this function is that certain screen readers,
+// such as Jaws, might need to report such objects as clickable to their users,
+// so that users will know that they could activate them if they so choose.
AX_BASE_EXPORT bool IsClickable(const ax::mojom::Role role);
// Returns true if the provided role belongs to a cell or a table header.
@@ -63,12 +79,12 @@ AX_BASE_EXPORT bool IsHeadingOrTableHeader(const ax::mojom::Role role);
// Returns true if the provided role belongs to an iframe.
AX_BASE_EXPORT bool IsIframe(const ax::mojom::Role role);
-// Returns true if the provided role is for any kind of image or video.
-AX_BASE_EXPORT bool IsImageOrVideo(const ax::mojom::Role role);
-
// Returns true if the provided role belongs to an image, graphic, canvas, etc.
AX_BASE_EXPORT bool IsImage(const ax::mojom::Role role);
+// Returns true if the provided role is for any kind of image or video.
+AX_BASE_EXPORT bool IsImageOrVideo(const ax::mojom::Role role);
+
// Returns true if the provided role is item-like, specifically if it can hold
// pos_in_set and set_size values.
AX_BASE_EXPORT bool IsItemLike(const ax::mojom::Role role);
@@ -92,7 +108,17 @@ AX_BASE_EXPORT bool IsMenuItem(ax::mojom::Role role);
// Returns true if the provided role belongs to a menu or related control.
AX_BASE_EXPORT bool IsMenuRelated(const ax::mojom::Role role);
+// Returns true if the provided role is presentational in nature, i.e. a node
+// whose implicit native role semantics will not be mapped to the accessibility
+// API.
+AX_BASE_EXPORT bool IsPresentational(const ax::mojom::Role role);
+
+// Returns true if the provided role supports a range-based value, such as a
+// slider.
+AX_BASE_EXPORT bool IsRangeValueSupported(const ax::mojom::Role role);
+
// Returns true if this object supports readonly.
+//
// Note: This returns false for table cells and headers, it is up to the
// caller to make sure that they are included IFF they are within an
// ARIA-1.1+ role='grid' or 'treegrid', and not role='table'.
@@ -152,6 +178,9 @@ AX_BASE_EXPORT bool SupportsHierarchicalLevel(const ax::mojom::Role role);
// Returns true if the provided role can have an orientation.
AX_BASE_EXPORT bool SupportsOrientation(const ax::mojom::Role role);
+// Returns true if the provided role supports aria-selected state.
+AX_BASE_EXPORT bool SupportsSelected(const ax::mojom::Role role);
+
// Returns true if the provided role supports toggle.
AX_BASE_EXPORT bool SupportsToggle(const ax::mojom::Role role);
diff --git a/chromium/ui/accessibility/ax_table_info.cc b/chromium/ui/accessibility/ax_table_info.cc
index e5711689cba..a861036d688 100644
--- a/chromium/ui/accessibility/ax_table_info.cc
+++ b/chromium/ui/accessibility/ax_table_info.cc
@@ -4,6 +4,7 @@
#include "ui/accessibility/ax_table_info.h"
+#include "base/strings/string_util.h"
#include "ui/accessibility/ax_constants.mojom.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node.h"
@@ -110,16 +111,12 @@ bool AXTableInfo::Update() {
row_count = GetSizeTAttribute(*table_node_, IntAttribute::kTableRowCount);
col_count = GetSizeTAttribute(*table_node_, IntAttribute::kTableColumnCount);
- int32_t aria_rows = table_node_->GetIntAttribute(IntAttribute::kAriaRowCount);
- aria_row_count = (aria_rows != ax::mojom::kUnknownAriaColumnOrRowCount)
- ? base::make_optional(int{aria_rows})
- : base::nullopt;
-
- int32_t aria_cols =
- table_node_->GetIntAttribute(IntAttribute::kAriaColumnCount);
- aria_col_count = (aria_cols != ax::mojom::kUnknownAriaColumnOrRowCount)
- ? base::make_optional(int{aria_cols})
- : base::nullopt;
+ // Note - GetIntAttribute returns 0 if no value has been specified for the
+ // attribute.
+ aria_row_count =
+ int{table_node_->GetIntAttribute(IntAttribute::kAriaRowCount)};
+ aria_col_count =
+ int{table_node_->GetIntAttribute(IntAttribute::kAriaColumnCount)};
// Iterate over the cells and build up an array of CellData
// entries, one for each cell. Compute the actual row and column
@@ -157,6 +154,9 @@ void AXTableInfo::ClearVectors() {
unique_cell_ids.clear();
cell_data_vector.clear();
row_nodes.clear();
+ cell_id_to_index.clear();
+ row_id_to_index.clear();
+ incremental_row_col_map_.clear();
}
void AXTableInfo::BuildCellDataVectorFromRowAndCellNodes(
@@ -178,12 +178,12 @@ void AXTableInfo::BuildCellDataVectorFromRowAndCellNodes(
size_t current_aria_col_index = 1;
// Make sure the row index is always at least as high as the one reported by
- // Blink.
+ // the source tree.
row_id_to_index[row_node->id()] =
std::max(next_row_index,
GetSizeTAttribute(*row_node, IntAttribute::kTableRowIndex));
size_t* current_row_index = &row_id_to_index[row_node->id()];
-
+ size_t spanned_col_index = 0;
for (AXNode* cell : cell_nodes_in_this_row) {
// Fill in basic info in CellData.
CellData cell_data;
@@ -213,6 +213,9 @@ void AXTableInfo::BuildCellDataVectorFromRowAndCellNodes(
// Ensure the column index must always be incrementing.
cell_data.col_index = std::max(cell_data.col_index, current_col_index);
+ // And update the spanned column index.
+ spanned_col_index = std::max(spanned_col_index, cell_data.col_index);
+
if (is_first_cell_in_row) {
is_first_cell_in_row = false;
@@ -245,6 +248,41 @@ void AXTableInfo::BuildCellDataVectorFromRowAndCellNodes(
cell_data.aria_row_index = current_aria_row_index;
}
+ // Adjust the spanned col index by looking at the incremental row col map.
+ // This map contains already filled in values, accounting for spans, of
+ // all row, col indices. The map should have filled in all values we need
+ // (upper left triangle of cells of the table).
+ while (true) {
+ const auto& row_it = incremental_row_col_map_.find(*current_row_index);
+ if (row_it == incremental_row_col_map_.end()) {
+ break;
+ } else {
+ const auto& col_it = row_it->second.find(spanned_col_index);
+ if (col_it == row_it->second.end()) {
+ break;
+ } else {
+ // A pre-existing cell resides in our desired position. Make a
+ // best-fit to the right of the existing span.
+ const CellData& spanned_cell_data = col_it->second;
+ spanned_col_index =
+ spanned_cell_data.col_index + spanned_cell_data.col_span;
+
+ // Adjust the actual col index to be the best fit with the existing
+ // spanned cell data.
+ cell_data.col_index = spanned_col_index;
+ }
+ }
+ }
+
+ // Memoize the cell data using our incremental row col map.
+ for (size_t r = cell_data.row_index;
+ r < (cell_data.row_index + cell_data.row_span); r++) {
+ for (size_t c = cell_data.col_index;
+ c < (cell_data.col_index + cell_data.col_span); c++) {
+ incremental_row_col_map_[r][c] = cell_data;
+ }
+ }
+
// Ensure the ARIA col index is incrementing.
cell_data.aria_col_index =
std::max(cell_data.aria_col_index, current_aria_col_index);
@@ -256,14 +294,14 @@ void AXTableInfo::BuildCellDataVectorFromRowAndCellNodes(
// whereas all other indices are zero-based.
row_count = std::max(row_count, cell_data.row_index + cell_data.row_span);
col_count = std::max(col_count, cell_data.col_index + cell_data.col_span);
- if (aria_row_count) {
+ if (aria_row_count != ax::mojom::kUnknownAriaColumnOrRowCount) {
aria_row_count =
- std::max((*aria_row_count),
+ std::max((aria_row_count),
int{current_aria_row_index + cell_data.row_span - 1});
}
- if (aria_col_count) {
+ if (aria_col_count != ax::mojom::kUnknownAriaColumnOrRowCount) {
aria_col_count =
- std::max((*aria_col_count),
+ std::max((aria_col_count),
int{current_aria_col_index + cell_data.col_span - 1});
}
// Update |current_col_index| to reflect the next available index after
@@ -271,6 +309,7 @@ void AXTableInfo::BuildCellDataVectorFromRowAndCellNodes(
// must be at least this large. Same for the current ARIA col index.
current_col_index = cell_data.col_index + cell_data.col_span;
current_aria_col_index = cell_data.aria_col_index + cell_data.col_span;
+ spanned_col_index = current_col_index;
// Add this cell to our vector.
cell_data_vector.push_back(cell_data);
@@ -289,10 +328,6 @@ void AXTableInfo::BuildCellAndHeaderVectorsFromCellData() {
// arrays of row headers and column headers.
row_headers.resize(row_count);
col_headers.resize(col_count);
- cell_ids.resize(row_count);
- for (auto& row : cell_ids)
- row.resize(col_count);
-
// Fill in the arrays.
//
// At this point we have computed valid row and column indices for
@@ -301,6 +336,25 @@ void AXTableInfo::BuildCellAndHeaderVectorsFromCellData() {
// fill in a 2-dimensional array that lets us look up an individual cell
// by its (row, column) coordinates, plus arrays to hold row and column
// headers.
+
+ // For cells.
+ cell_ids.resize(row_count);
+ for (size_t r = 0; r < row_count; r++) {
+ cell_ids[r].resize(col_count);
+ for (size_t c = 0; c < col_count; c++) {
+ const auto& row_it = incremental_row_col_map_.find(r);
+ if (row_it != incremental_row_col_map_.end()) {
+ const auto& col_it = row_it->second.find(c);
+ if (col_it != row_it->second.end())
+ cell_ids[r][c] = col_it->second.cell->id();
+ }
+ }
+ }
+
+ // No longer need this.
+ incremental_row_col_map_.clear();
+
+ // For relations.
for (auto& cell_data : cell_data_vector) {
for (size_t r = cell_data.row_index;
r < cell_data.row_index + cell_data.row_span; r++) {
@@ -309,8 +363,6 @@ void AXTableInfo::BuildCellAndHeaderVectorsFromCellData() {
c < cell_data.col_index + cell_data.col_span; c++) {
DCHECK_LT(c, col_count);
AXNode* cell = cell_data.cell;
- cell_ids[r][c] = cell->id();
-
if (cell->data().role == ax::mojom::Role::kColumnHeader) {
col_headers[c].push_back(cell->id());
all_headers.push_back(cell->id());
@@ -332,7 +384,7 @@ void AXTableInfo::UpdateExtraMacNodes() {
// node.
//
// The columns have id -1, -2, -3, ... - this won't conflict with ids from
- // Blink, which are all positive.
+ // the source tree, which are all positive.
//
// Each column has the kColumnIndex attribute set, and then each of the cells
// in that column gets added as an indirect ID. That exposes them as children
@@ -461,6 +513,32 @@ void AXTableInfo::ClearExtraMacNodes() {
extra_mac_nodes.clear();
}
+std::string AXTableInfo::ToString() const {
+ // First, scan through to get the length of the largest id.
+ int padding = 0;
+ for (size_t r = 0; r < row_count; r++) {
+ for (size_t c = 0; c < col_count; c++) {
+ // Extract the length of the id for padding purposes.
+ padding = std::max(padding, static_cast<int>(log10(cell_ids[r][c])));
+ }
+ }
+
+ std::string result;
+ for (size_t r = 0; r < row_count; r++) {
+ result += "|";
+ for (size_t c = 0; c < col_count; c++) {
+ int cell_id = cell_ids[r][c];
+ result += base::NumberToString(cell_id);
+ int cell_padding = padding;
+ if (cell_id != 0)
+ cell_padding = padding - static_cast<int>(log10(cell_id));
+ result += std::string(cell_padding, ' ') + '|';
+ }
+ result += "\n";
+ }
+ return result;
+}
+
AXTableInfo::AXTableInfo(AXTree* tree, AXNode* table_node)
: tree_(tree), table_node_(table_node) {}
diff --git a/chromium/ui/accessibility/ax_table_info.h b/chromium/ui/accessibility/ax_table_info.h
index 207a731be60..3bfb246263a 100644
--- a/chromium/ui/accessibility/ax_table_info.h
+++ b/chromium/ui/accessibility/ax_table_info.h
@@ -5,6 +5,7 @@
#ifndef UI_ACCESSIBILITY_AX_TABLE_INFO_H_
#define UI_ACCESSIBILITY_AX_TABLE_INFO_H_
+#include <map>
#include <set>
#include <unordered_map>
#include <vector>
@@ -94,8 +95,10 @@ class AX_EXPORT AXTableInfo {
// The ARIA row count and column count, if any ARIA table or grid
// attributes are used in the table at all.
- base::Optional<int> aria_row_count = 0;
- base::Optional<int> aria_col_count = 0;
+ int aria_row_count = 0;
+ int aria_col_count = 0;
+
+ std::string ToString() const;
private:
AXTableInfo(AXTree* tree, AXNode* table_node);
@@ -114,6 +117,7 @@ class AX_EXPORT AXTableInfo {
AXTree* tree_ = nullptr;
AXNode* table_node_ = nullptr;
bool valid_ = false;
+ std::map<int, std::map<int, CellData>> incremental_row_col_map_;
};
} // namespace ui
diff --git a/chromium/ui/accessibility/ax_table_info_unittest.cc b/chromium/ui/accessibility/ax_table_info_unittest.cc
index 3633abf0afc..a3631a6dc86 100644
--- a/chromium/ui/accessibility/ax_table_info_unittest.cc
+++ b/chromium/ui/accessibility/ax_table_info_unittest.cc
@@ -1078,4 +1078,102 @@ TEST_F(AXTableInfoTest, ExtraMacNodesChanges) {
}
}
+TEST_F(AXTableInfoTest, RowColumnSpanChanges) {
+ // Simple 2 col x 1 row table
+ AXTreeUpdate update;
+ update.root_id = 1;
+ update.nodes.resize(4);
+ MakeTable(&update.nodes[0], 1, 0, 0);
+ update.nodes[0].child_ids = {2};
+ MakeRow(&update.nodes[1], 2, 0);
+ update.nodes[1].child_ids = {3, 10};
+ MakeCell(&update.nodes[2], 3, 0, 0);
+ MakeCell(&update.nodes[3], 10, 0, 1);
+ AXTree tree(update);
+
+ AXTableInfo* table_info = GetTableInfo(&tree, tree.root());
+ ASSERT_TRUE(table_info);
+
+ EXPECT_EQ(1u, table_info->row_count);
+ EXPECT_EQ(2u, table_info->col_count);
+
+ EXPECT_EQ("|3 |10|\n", table_info->ToString());
+
+ // Add a row to the table.
+ update.nodes.resize(6);
+ update.nodes[0].child_ids = {2, 4};
+ MakeRow(&update.nodes[4], 4, 0);
+ update.nodes[4].child_ids = {5};
+ MakeCell(&update.nodes[5], 5, -1, -1);
+
+ tree.Unserialize(update);
+
+ table_info = GetTableInfo(&tree, tree.root());
+ ASSERT_TRUE(table_info);
+ EXPECT_EQ(2u, table_info->row_count);
+ EXPECT_EQ(2u, table_info->col_count);
+ EXPECT_EQ(
+ "|3 |10|\n"
+ "|5 |0 |\n",
+ table_info->ToString());
+
+ // Add a row to the middle of the table, with a span. Intentionally omit other
+ // rows from the update.
+ update.nodes.resize(3);
+ update.nodes[0].child_ids = {2, 6, 4};
+ MakeRow(&update.nodes[1], 6, 0);
+ update.nodes[1].child_ids = {7};
+ MakeCell(&update.nodes[2], 7, -1, -1, 1, 2);
+
+ tree.Unserialize(update);
+
+ table_info = GetTableInfo(&tree, tree.root());
+ ASSERT_TRUE(table_info);
+ EXPECT_EQ(3u, table_info->row_count);
+ EXPECT_EQ(2u, table_info->col_count);
+ EXPECT_EQ(
+ "|3 |10|\n"
+ "|7 |7 |\n"
+ "|5 |0 |\n",
+ table_info->ToString());
+
+ // Add a row to the end of the table, with a span. Intentionally omit other
+ // rows from the update.
+ update.nodes.resize(3);
+ update.nodes[0].child_ids = {2, 6, 4, 8};
+ MakeRow(&update.nodes[1], 8, 0);
+ update.nodes[1].child_ids = {9};
+ MakeCell(&update.nodes[2], 9, -1, -1, 2, 3);
+
+ tree.Unserialize(update);
+
+ table_info = GetTableInfo(&tree, tree.root());
+ ASSERT_TRUE(table_info);
+ EXPECT_EQ(5u, table_info->row_count);
+ EXPECT_EQ(3u, table_info->col_count);
+ EXPECT_EQ(
+ "|3 |10|0 |\n"
+ "|7 |7 |0 |\n"
+ "|5 |0 |0 |\n"
+ "|9 |9 |9 |\n"
+ "|9 |9 |9 |\n",
+ table_info->ToString());
+
+ // Finally, delete a few rows.
+ update.nodes.resize(1);
+ update.nodes[0].child_ids = {6, 8};
+
+ tree.Unserialize(update);
+
+ table_info = GetTableInfo(&tree, tree.root());
+ ASSERT_TRUE(table_info);
+ EXPECT_EQ(3u, table_info->row_count);
+ EXPECT_EQ(3u, table_info->col_count);
+ EXPECT_EQ(
+ "|7|7|0|\n"
+ "|9|9|9|\n"
+ "|9|9|9|\n",
+ table_info->ToString());
+}
+
} // namespace ui
diff --git a/chromium/ui/accessibility/ax_text_utils.cc b/chromium/ui/accessibility/ax_text_utils.cc
index 3f7a7a3b074..bda3a61c56c 100644
--- a/chromium/ui/accessibility/ax_text_utils.cc
+++ b/chromium/ui/accessibility/ax_text_utils.cc
@@ -6,15 +6,14 @@
#include <algorithm>
+#include "base/check_op.h"
#include "base/i18n/break_iterator.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/optional.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/accessibility/ax_enums.mojom.h"
-#include "ui/base/l10n/l10n_util.h"
-#include "ui/strings/grit/ui_strings.h"
namespace ui {
@@ -71,7 +70,7 @@ size_t FindAccessibleTextBoundary(const base::string16& text,
if (boundary == ax::mojom::TextBoundary::kLineStart) {
if (direction == ax::mojom::MoveDirection::kForward) {
for (int line_break : line_breaks) {
- size_t clamped_line_break = std::max(0, line_break);
+ size_t clamped_line_break = size_t{std::max(0, line_break)};
if ((affinity == ax::mojom::TextAffinity::kDownstream &&
clamped_line_break > start_offset) ||
(affinity == ax::mojom::TextAffinity::kUpstream &&
@@ -178,63 +177,6 @@ size_t FindAccessibleTextBoundary(const base::string16& text,
}
}
-base::string16 ActionVerbToLocalizedString(
- const ax::mojom::DefaultActionVerb action_verb) {
- switch (action_verb) {
- case ax::mojom::DefaultActionVerb::kNone:
- return base::string16();
- case ax::mojom::DefaultActionVerb::kActivate:
- return l10n_util::GetStringUTF16(IDS_AX_ACTIVATE_ACTION_VERB);
- case ax::mojom::DefaultActionVerb::kCheck:
- return l10n_util::GetStringUTF16(IDS_AX_CHECK_ACTION_VERB);
- case ax::mojom::DefaultActionVerb::kClick:
- return l10n_util::GetStringUTF16(IDS_AX_CLICK_ACTION_VERB);
- case ax::mojom::DefaultActionVerb::kClickAncestor:
- return l10n_util::GetStringUTF16(IDS_AX_CLICK_ANCESTOR_ACTION_VERB);
- case ax::mojom::DefaultActionVerb::kJump:
- return l10n_util::GetStringUTF16(IDS_AX_JUMP_ACTION_VERB);
- case ax::mojom::DefaultActionVerb::kOpen:
- return l10n_util::GetStringUTF16(IDS_AX_OPEN_ACTION_VERB);
- case ax::mojom::DefaultActionVerb::kPress:
- return l10n_util::GetStringUTF16(IDS_AX_PRESS_ACTION_VERB);
- case ax::mojom::DefaultActionVerb::kSelect:
- return l10n_util::GetStringUTF16(IDS_AX_SELECT_ACTION_VERB);
- case ax::mojom::DefaultActionVerb::kUncheck:
- return l10n_util::GetStringUTF16(IDS_AX_UNCHECK_ACTION_VERB);
- }
- NOTREACHED();
- return base::string16();
-}
-
-// Some APIs on Linux and Windows need to return non-localized action names.
-base::string16 ActionVerbToUnlocalizedString(
- const ax::mojom::DefaultActionVerb action_verb) {
- switch (action_verb) {
- case ax::mojom::DefaultActionVerb::kNone:
- return base::UTF8ToUTF16("none");
- case ax::mojom::DefaultActionVerb::kActivate:
- return base::UTF8ToUTF16("activate");
- case ax::mojom::DefaultActionVerb::kCheck:
- return base::UTF8ToUTF16("check");
- case ax::mojom::DefaultActionVerb::kClick:
- return base::UTF8ToUTF16("click");
- case ax::mojom::DefaultActionVerb::kClickAncestor:
- return base::UTF8ToUTF16("click-ancestor");
- case ax::mojom::DefaultActionVerb::kJump:
- return base::UTF8ToUTF16("jump");
- case ax::mojom::DefaultActionVerb::kOpen:
- return base::UTF8ToUTF16("open");
- case ax::mojom::DefaultActionVerb::kPress:
- return base::UTF8ToUTF16("press");
- case ax::mojom::DefaultActionVerb::kSelect:
- return base::UTF8ToUTF16("select");
- case ax::mojom::DefaultActionVerb::kUncheck:
- return base::UTF8ToUTF16("uncheck");
- }
- NOTREACHED();
- return base::string16();
-}
-
std::vector<int> GetWordStartOffsets(const base::string16& text) {
std::vector<int> word_starts;
base::i18n::BreakIterator iter(text, base::i18n::BreakIterator::BREAK_WORD);
diff --git a/chromium/ui/accessibility/ax_text_utils.h b/chromium/ui/accessibility/ax_text_utils.h
index 63563310868..7e4d0ea1a3e 100644
--- a/chromium/ui/accessibility/ax_text_utils.h
+++ b/chromium/ui/accessibility/ax_text_utils.h
@@ -10,8 +10,8 @@
#include <vector>
#include "base/strings/string16.h"
-#include "ui/accessibility/ax_base_export.h"
#include "ui/accessibility/ax_enums.mojom-forward.h"
+#include "ui/accessibility/ax_export.h"
namespace ui {
@@ -20,27 +20,26 @@ namespace ui {
// (depending on |direction|) from the given |start_offset| until the
// given boundary is found, and return the offset of that boundary,
// using the vector of line break character offsets in |line_breaks|.
-AX_BASE_EXPORT size_t
-FindAccessibleTextBoundary(const base::string16& text,
- const std::vector<int>& line_breaks,
- ax::mojom::TextBoundary boundary,
- size_t start_offset,
- ax::mojom::MoveDirection direction,
- ax::mojom::TextAffinity affinity);
+AX_EXPORT size_t FindAccessibleTextBoundary(const base::string16& text,
+ const std::vector<int>& line_breaks,
+ ax::mojom::TextBoundary boundary,
+ size_t start_offset,
+ ax::mojom::MoveDirection direction,
+ ax::mojom::TextAffinity affinity);
// Returns a string ID that corresponds to the name of the given action.
-AX_BASE_EXPORT base::string16 ActionVerbToLocalizedString(
+AX_EXPORT base::string16 ActionVerbToLocalizedString(
const ax::mojom::DefaultActionVerb action_verb);
// Returns the non-localized string representation of a supported action.
// Some APIs on Linux and Windows need to return non-localized action names.
-AX_BASE_EXPORT base::string16 ActionVerbToUnlocalizedString(
+AX_EXPORT base::string16 ActionVerbToUnlocalizedString(
const ax::mojom::DefaultActionVerb action_verb);
// Returns indices of all word starts in |text|.
-AX_BASE_EXPORT std::vector<int> GetWordStartOffsets(const base::string16& text);
+AX_EXPORT std::vector<int> GetWordStartOffsets(const base::string16& text);
// Returns indices of all word ends in |text|.
-AX_BASE_EXPORT std::vector<int> GetWordEndOffsets(const base::string16& text);
+AX_EXPORT std::vector<int> GetWordEndOffsets(const base::string16& text);
} // namespace ui
diff --git a/chromium/ui/accessibility/ax_tree.cc b/chromium/ui/accessibility/ax_tree.cc
index 7b8d9b1b161..5a2b447abbc 100644
--- a/chromium/ui/accessibility/ax_tree.cc
+++ b/chromium/ui/accessibility/ax_tree.cc
@@ -11,10 +11,11 @@
#include <utility>
#include "base/auto_reset.h"
+#include "base/check_op.h"
#include "base/command_line.h"
-#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/no_destructor.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "ui/accessibility/accessibility_switches.h"
@@ -567,14 +568,8 @@ struct AXTreeUpdateState {
const AXTree& tree;
};
-struct AXTree::NodeSetSizePosInSetInfo {
- NodeSetSizePosInSetInfo() = default;
- ~NodeSetSizePosInSetInfo() = default;
-
- int32_t pos_in_set = 0;
- int32_t set_size = 0;
- base::Optional<int> lowest_hierarchical_level;
-};
+AXTree::NodeSetSizePosInSetInfo::NodeSetSizePosInSetInfo() = default;
+AXTree::NodeSetSizePosInSetInfo::~NodeSetSizePosInSetInfo() = default;
struct AXTree::OrderedSetContent {
explicit OrderedSetContent(const AXNode* ordered_set = nullptr)
diff --git a/chromium/ui/accessibility/ax_tree.h b/chromium/ui/accessibility/ax_tree.h
index a51ca8de4c8..8c1c57517ac 100644
--- a/chromium/ui/accessibility/ax_tree.h
+++ b/chromium/ui/accessibility/ax_tree.h
@@ -328,7 +328,14 @@ class AX_EXPORT AXTree : public AXNode::OwnerTree {
bool enable_extra_mac_nodes_ = false;
// Contains pos_in_set and set_size data for an AXNode.
- struct NodeSetSizePosInSetInfo;
+ struct NodeSetSizePosInSetInfo {
+ NodeSetSizePosInSetInfo();
+ ~NodeSetSizePosInSetInfo();
+
+ int32_t pos_in_set = 0;
+ int32_t set_size = 0;
+ base::Optional<int> lowest_hierarchical_level;
+ };
// Represents the content of an ordered set which includes the ordered set
// items and the ordered set container if it exists.
diff --git a/chromium/ui/accessibility/ax_tree_id.cc b/chromium/ui/accessibility/ax_tree_id.cc
index a02967ab857..86347de4255 100644
--- a/chromium/ui/accessibility/ax_tree_id.cc
+++ b/chromium/ui/accessibility/ax_tree_id.cc
@@ -7,8 +7,9 @@
#include <algorithm>
#include <iostream>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/no_destructor.h"
+#include "base/notreached.h"
#include "base/value_conversions.h"
#include "base/values.h"
#include "ui/accessibility/ax_enums.mojom.h"
diff --git a/chromium/ui/accessibility/ax_tree_serializer.h b/chromium/ui/accessibility/ax_tree_serializer.h
index 18fe3aa1b5f..f4fb10a7c7b 100644
--- a/chromium/ui/accessibility/ax_tree_serializer.h
+++ b/chromium/ui/accessibility/ax_tree_serializer.h
@@ -173,13 +173,12 @@ class AXTreeSerializer {
AXSourceNode node,
AXTreeUpdateBase<AXNodeData, AXTreeData>* out_update);
- // Visit all of the descendants of |node| once.
- void WalkAllDescendants(AXSourceNode node);
-
// Delete the entire client subtree but don't set the did_reset_ flag
// like when Reset() is called.
void InternalReset();
+ ClientTreeNode* GetClientTreeNodeParent(ClientTreeNode* obj);
+
// The tree source.
AXTreeSource<AXSourceNode, AXNodeData, AXTreeData>* tree_;
@@ -269,7 +268,7 @@ AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>::LeastCommonAncestor(
std::vector<ClientTreeNode*> client_ancestors;
while (client_node) {
client_ancestors.push_back(client_node);
- client_node = client_node->parent;
+ client_node = GetClientTreeNodeParent(client_node);
}
// Start at the root. Keep going until the source ancestor chain and
@@ -304,9 +303,12 @@ AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>::LeastCommonAncestor(
// that we're inside of an invalid subtree that all needs to be
// re-serialized, so the LCA should be higher.
ClientTreeNode* client_node = ClientTreeNodeById(tree_->GetId(node));
- while (
- tree_->IsValid(node) &&
- (!client_node || (client_node->parent && client_node->parent->invalid))) {
+ while (tree_->IsValid(node)) {
+ if (client_node) {
+ ClientTreeNode* parent = GetClientTreeNodeParent(client_node);
+ if (!parent || !parent->invalid)
+ break;
+ }
node = tree_->GetParent(node);
if (tree_->IsValid(node))
client_node = ClientTreeNodeById(tree_->GetId(node));
@@ -326,12 +328,13 @@ bool AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>::
int child_id = tree_->GetId(child);
ClientTreeNode* client_child = ClientTreeNodeById(child_id);
if (client_child) {
- if (!client_child->parent) {
+ ClientTreeNode* parent = client_child->parent;
+ if (!parent) {
// If the client child has no parent, it must have been the
// previous root node, so there is no LCA and we can exit early.
*out_lca = tree_->GetNull();
return true;
- } else if (client_child->parent->id != id) {
+ } else if (parent->id != id) {
// If the client child's parent is not this node, update the LCA
// and return true (reparenting was found).
*out_lca = LeastCommonAncestor(*out_lca, client_child);
@@ -367,6 +370,19 @@ AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>::ClientTreeNodeById(
}
template <typename AXSourceNode, typename AXNodeData, typename AXTreeData>
+ClientTreeNode*
+AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>::GetClientTreeNodeParent(
+ ClientTreeNode* obj) {
+ ClientTreeNode* parent = obj->parent;
+#if DCHECK_IS_ON()
+ if (!parent)
+ return nullptr;
+ DCHECK(ClientTreeNodeById(parent->id)) << "Parent not in id map.";
+#endif // DCHECK_IS_ON()
+ return parent;
+}
+
+template <typename AXSourceNode, typename AXNodeData, typename AXTreeData>
bool AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>::SerializeChanges(
AXSourceNode node,
AXTreeUpdateBase<AXNodeData, AXTreeData>* out_update) {
@@ -422,12 +438,6 @@ bool AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>::SerializeChanges(
if (!tree_->IsValid(lca))
lca = tree_->GetRoot();
- // Work around flaky source trees where nodes don't figure out their
- // correct parent/child relationships until you walk the whole tree once.
- // Covered by this test in the content_browsertests suite:
- // DumpAccessibilityTreeTest.AccessibilityAriaOwns.
- WalkAllDescendants(lca);
-
if (!SerializeChangedNodes(lca, out_update))
return false;
@@ -549,12 +559,22 @@ bool AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>::
// above. If this happens, reset and return an error.
ClientTreeNode* client_child = ClientTreeNodeById(new_child_id);
- if (client_child && client_child->parent != client_node) {
+ if (client_child && GetClientTreeNodeParent(client_child) != client_node) {
DVLOG(1) << "Illegal reparenting detected";
#if defined(ADDRESS_SANITIZER)
// Wrapping this in ADDRESS_SANITIZER will cause it to run on
// clusterfuzz, which should help us narrow down the issue.
- NOTREACHED() << "Illegal reparenting detected";
+ // TODO(accessibility) Remove all cases where this occurs and re-add
+ // NOTREACHED(). This condition leads to performance problems. It will
+ // also reset virtual buffers, causing users to lose their place.
+ NOTREACHED() << "Illegal reparenting detected: "
+ << "\nPassed-in parent: "
+ << tree_->GetDebugString(tree_->GetFromId(client_node->id))
+ << "\nChild: " << tree_->GetDebugString(child)
+ << "\nChild's parent: "
+ << tree_->GetDebugString(
+ tree_->GetFromId(client_child->parent->id))
+ << "\n-----------------------------------------\n\n\n";
#endif
Reset();
return false;
@@ -634,6 +654,10 @@ bool AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>::
new_child->ignored = tree_->IsIgnored(child);
new_child->invalid = false;
client_node->children.push_back(new_child);
+ DCHECK(!ClientTreeNodeById(child_id))
+ << "Child id " << child_id << " already exists in map."
+ << "\nChild is " << tree_->GetDebugString(tree_->GetFromId(child_id))
+ << " of parent " << tree_->GetDebugString(node);
client_id_map_[child_id] = new_child;
if (!SerializeChangedNodes(child, out_update))
return false;
@@ -648,15 +672,6 @@ bool AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>::
return true;
}
-template <typename AXSourceNode, typename AXNodeData, typename AXTreeData>
-void AXTreeSerializer<AXSourceNode, AXNodeData, AXTreeData>::WalkAllDescendants(
- AXSourceNode node) {
- std::vector<AXSourceNode> children;
- tree_->GetChildren(node, &children);
- for (size_t i = 0; i < children.size(); ++i)
- WalkAllDescendants(children[i]);
-}
-
} // namespace ui
#endif // UI_ACCESSIBILITY_AX_TREE_SERIALIZER_H_
diff --git a/chromium/ui/accessibility/ax_tree_source.h b/chromium/ui/accessibility/ax_tree_source.h
index 7d93b346d28..160c416e32f 100644
--- a/chromium/ui/accessibility/ax_tree_source.h
+++ b/chromium/ui/accessibility/ax_tree_source.h
@@ -61,6 +61,13 @@ class AXTreeSource {
// Serialize one node in the tree.
virtual void SerializeNode(AXNodeSource node, AXNodeData* out_data) const = 0;
+ // Return a string useful for debugging a node.
+ virtual std::string GetDebugString(AXNodeSource node) const {
+ AXNodeData node_data;
+ SerializeNode(node, &node_data);
+ return node_data.ToString();
+ }
+
protected:
AXTreeSource() {}
};
diff --git a/chromium/ui/accessibility/ax_tree_unittest.cc b/chromium/ui/accessibility/ax_tree_unittest.cc
index c48318b7a8c..05c962720ea 100644
--- a/chromium/ui/accessibility/ax_tree_unittest.cc
+++ b/chromium/ui/accessibility/ax_tree_unittest.cc
@@ -2046,6 +2046,178 @@ TEST(AXTreeTest, NullUnignoredChildren) {
EXPECT_EQ(nullptr, root->GetUnignoredChildAtIndex(1));
}
+TEST(AXTreeTest, UnignoredChildIteratorIncrementDecrementPastEnd) {
+ AXTreeUpdate tree_update;
+
+ // RootWebArea #1
+ // ++StaticText "text1" #2
+
+ tree_update.root_id = 1;
+ tree_update.nodes.resize(2);
+
+ tree_update.nodes[0].id = 1;
+ tree_update.nodes[0].role = ax::mojom::Role::kWebArea;
+ tree_update.nodes[0].child_ids = {2};
+
+ tree_update.nodes[1].id = 2;
+ tree_update.nodes[1].role = ax::mojom::Role::kStaticText;
+ tree_update.nodes[1].SetName("text1");
+
+ AXTree tree(tree_update);
+ AXNode* root = tree.root();
+
+ {
+ {
+ AXNode::UnignoredChildIterator root_unignored_iter =
+ root->UnignoredChildrenBegin();
+ EXPECT_EQ(2, root_unignored_iter->id());
+ EXPECT_EQ("text1", root_unignored_iter->GetStringAttribute(
+ ax::mojom::StringAttribute::kName));
+
+ // Call unignored child iterator on root and increment, we should reach
+ // the end since there is only one iterator element.
+ EXPECT_EQ(root->UnignoredChildrenEnd(), ++root_unignored_iter);
+
+ // We increment past the end, and we should still stay at the end.
+ EXPECT_EQ(root->UnignoredChildrenEnd(), ++root_unignored_iter);
+
+ // When we decrement from the end, we should get the last iterator element
+ // "text1".
+ --root_unignored_iter;
+ EXPECT_EQ(2, root_unignored_iter->id());
+ EXPECT_EQ("text1", root_unignored_iter->GetStringAttribute(
+ ax::mojom::StringAttribute::kName));
+ }
+
+ {
+ AXNode::UnignoredChildIterator root_unignored_iter =
+ root->UnignoredChildrenBegin();
+ EXPECT_EQ(2, root_unignored_iter->id());
+ EXPECT_EQ("text1", root_unignored_iter->GetStringAttribute(
+ ax::mojom::StringAttribute::kName));
+
+ // Call unignored child iterator on root and decrement from the beginning,
+ // we should stay at the beginning.
+ --root_unignored_iter;
+ EXPECT_EQ(2, root_unignored_iter->id());
+ EXPECT_EQ("text1", root_unignored_iter->GetStringAttribute(
+ ax::mojom::StringAttribute::kName));
+
+ // When we decrement past the beginning, we should still stay at the
+ // beginning.
+ --root_unignored_iter;
+ EXPECT_EQ(2, root_unignored_iter->id());
+ EXPECT_EQ("text1", root_unignored_iter->GetStringAttribute(
+ ax::mojom::StringAttribute::kName));
+
+ // We increment past the end, and we should still reach the end.
+ EXPECT_EQ(root->UnignoredChildrenEnd(), ++root_unignored_iter);
+ }
+ }
+}
+
+TEST(AXTreeTest, UnignoredChildIteratorIgnoredContainerSiblings) {
+ AXTreeUpdate tree_update;
+
+ // RootWebArea #1
+ // ++genericContainer IGNORED #2
+ // ++++StaticText "text1" #3
+ // ++genericContainer IGNORED #4
+ // ++++StaticText "text2" #5
+ // ++genericContainer IGNORED #6
+ // ++++StaticText "text3" #7
+
+ tree_update.root_id = 1;
+ tree_update.nodes.resize(7);
+
+ tree_update.nodes[0].id = 1;
+ tree_update.nodes[0].role = ax::mojom::Role::kWebArea;
+ tree_update.nodes[0].child_ids = {2, 4, 6};
+
+ tree_update.nodes[1].id = 2;
+ tree_update.nodes[1].child_ids = {3};
+ tree_update.nodes[1].role = ax::mojom::Role::kGenericContainer;
+ tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
+
+ tree_update.nodes[2].id = 3;
+ tree_update.nodes[2].role = ax::mojom::Role::kStaticText;
+ tree_update.nodes[2].SetName("text1");
+
+ tree_update.nodes[3].id = 4;
+ tree_update.nodes[3].child_ids = {5};
+ tree_update.nodes[3].role = ax::mojom::Role::kGenericContainer;
+ tree_update.nodes[3].AddState(ax::mojom::State::kIgnored);
+
+ tree_update.nodes[4].id = 5;
+ tree_update.nodes[4].role = ax::mojom::Role::kStaticText;
+ tree_update.nodes[4].SetName("text2");
+
+ tree_update.nodes[5].id = 6;
+ tree_update.nodes[5].child_ids = {7};
+ tree_update.nodes[5].role = ax::mojom::Role::kGenericContainer;
+ tree_update.nodes[5].AddState(ax::mojom::State::kIgnored);
+
+ tree_update.nodes[6].id = 7;
+ tree_update.nodes[6].role = ax::mojom::Role::kStaticText;
+ tree_update.nodes[6].SetName("text3");
+
+ AXTree tree(tree_update);
+
+ {
+ // Call unignored child iterator on root and iterate till the end, we should
+ // get "text1", "text2", "text3" respectively because the sibling text nodes
+ // share the same parent (i.e. root) as |unignored_iter|.
+ AXNode* root = tree.root();
+ AXNode::UnignoredChildIterator root_unignored_iter =
+ root->UnignoredChildrenBegin();
+ EXPECT_EQ(3, root_unignored_iter->id());
+ EXPECT_EQ("text1", root_unignored_iter->GetStringAttribute(
+ ax::mojom::StringAttribute::kName));
+
+ EXPECT_EQ(5, (++root_unignored_iter)->id());
+ EXPECT_EQ("text2",
+ (*root_unignored_iter)
+ .GetStringAttribute(ax::mojom::StringAttribute::kName));
+
+ EXPECT_EQ(7, (++root_unignored_iter)->id());
+ EXPECT_EQ("text3", root_unignored_iter->GetStringAttribute(
+ ax::mojom::StringAttribute::kName));
+ EXPECT_EQ(root->UnignoredChildrenEnd(), ++root_unignored_iter);
+ }
+
+ {
+ // Call unignored child iterator on the ignored generic container of "text1"
+ // (id=2), When we iterate to the next of "text1", we should
+ // reach the end because the sibling text node "text2" does not share the
+ // same parent as |unignored_iter| of "text1".
+ AXNode* text1_ignored_container = tree.GetFromId(2);
+ AXNode::UnignoredChildIterator unignored_iter =
+ text1_ignored_container->UnignoredChildrenBegin();
+ EXPECT_EQ(3, unignored_iter->id());
+ EXPECT_EQ("text1", unignored_iter->GetStringAttribute(
+ ax::mojom::StringAttribute::kName));
+ // The next child of "text1" should be the end.
+ EXPECT_EQ(text1_ignored_container->UnignoredChildrenEnd(),
+ ++unignored_iter);
+
+ // Call unignored child iterator on the ignored generic container of "text2"
+ // (id=4), When we iterate to the previous of "text2", we should
+ // reach the end because the sibling text node "text1" does not share the
+ // same parent as |unignored_iter| of "text2".
+ AXNode* text2_ignored_container = tree.GetFromId(4);
+ unignored_iter = text2_ignored_container->UnignoredChildrenBegin();
+ EXPECT_EQ(5, unignored_iter->id());
+ EXPECT_EQ("text2", unignored_iter->GetStringAttribute(
+ ax::mojom::StringAttribute::kName));
+ // Decrement the iterator of "text2" should still remain on "text2" since
+ // the beginning of iterator is "text2."
+ --unignored_iter;
+ EXPECT_EQ(5, unignored_iter->id());
+ EXPECT_EQ("text2", unignored_iter->GetStringAttribute(
+ ax::mojom::StringAttribute::kName));
+ }
+}
+
TEST(AXTreeTest, UnignoredChildIterator) {
AXTreeUpdate tree_update;
// (i) => node is ignored
@@ -2113,27 +2285,27 @@ TEST(AXTreeTest, UnignoredChildIterator) {
// UnignoredChildren(root) = {5, 6, 14, 15, 12, 3, 4}
AXNode::UnignoredChildIterator unignored_iterator =
root->UnignoredChildrenBegin();
- EXPECT_EQ(5, (*unignored_iterator).id());
+ EXPECT_EQ(5, unignored_iterator->id());
- EXPECT_EQ(6, (*++unignored_iterator).id());
+ EXPECT_EQ(6, (++unignored_iterator)->id());
- EXPECT_EQ(14, (*++unignored_iterator).id());
+ EXPECT_EQ(14, (++unignored_iterator)->id());
- EXPECT_EQ(15, (*++unignored_iterator).id());
+ EXPECT_EQ(15, (++unignored_iterator)->id());
- EXPECT_EQ(14, (*--unignored_iterator).id());
+ EXPECT_EQ(14, (--unignored_iterator)->id());
- EXPECT_EQ(6, (*--unignored_iterator).id());
+ EXPECT_EQ(6, (--unignored_iterator)->id());
- EXPECT_EQ(14, (*++unignored_iterator).id());
+ EXPECT_EQ(14, (++unignored_iterator)->id());
- EXPECT_EQ(15, (*++unignored_iterator).id());
+ EXPECT_EQ(15, (++unignored_iterator)->id());
- EXPECT_EQ(12, (*++unignored_iterator).id());
+ EXPECT_EQ(12, (++unignored_iterator)->id());
- EXPECT_EQ(3, (*++unignored_iterator).id());
+ EXPECT_EQ(3, (++unignored_iterator)->id());
- EXPECT_EQ(4, (*++unignored_iterator).id());
+ EXPECT_EQ(4, (++unignored_iterator)->id());
EXPECT_EQ(root->UnignoredChildrenEnd(), ++unignored_iterator);
@@ -2153,7 +2325,7 @@ TEST(AXTreeTest, UnignoredChildIterator) {
// UnignoredChildren(11) = {}
AXNode* node11 = tree.GetFromId(11);
unignored_iterator = node11->UnignoredChildrenBegin();
- EXPECT_EQ(14, (*unignored_iterator).id());
+ EXPECT_EQ(14, unignored_iterator->id());
// Two UnignoredChildIterators from the same parent at the same position
// should be equivalent, even in end position.
@@ -2384,6 +2556,309 @@ TEST(AXTreeTest, UnignoredNextPreviousChild) {
EXPECT_EQ(nullptr, tree.GetFromId(16)->GetPreviousUnignoredSibling());
}
+TEST(AXTreeTest, GetSiblingsNoIgnored) {
+ // Since this tree contains no ignored nodes, PreviousSibling and NextSibling
+ // are equivalent to their unignored counterparts.
+ //
+ // 1
+ // ├── 2
+ // │ └── 4
+ // └── 3
+ AXTreeUpdate tree_update;
+ tree_update.root_id = 1;
+ tree_update.nodes.resize(4);
+ tree_update.nodes[0].id = 1;
+ tree_update.nodes[0].child_ids = {2, 3};
+ tree_update.nodes[1].id = 2;
+ tree_update.nodes[1].child_ids = {4};
+ tree_update.nodes[2].id = 3;
+ tree_update.nodes[3].id = 4;
+
+ AXTree tree(tree_update);
+
+ EXPECT_EQ(nullptr, tree.GetFromId(1)->GetPreviousSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(1)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(1)->GetNextSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(1)->GetNextUnignoredSibling());
+
+ EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextSibling());
+ EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextUnignoredSibling());
+
+ EXPECT_EQ(tree.GetFromId(2), tree.GetFromId(3)->GetPreviousSibling());
+ EXPECT_EQ(tree.GetFromId(2),
+ tree.GetFromId(3)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(3)->GetNextSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(3)->GetNextUnignoredSibling());
+
+ EXPECT_EQ(nullptr, tree.GetFromId(4)->GetPreviousSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(4)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(4)->GetNextSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(4)->GetNextUnignoredSibling());
+}
+
+TEST(AXTreeTest, GetUnignoredSiblingsChildrenPromoted) {
+ // An ignored node has its' children considered as though they were promoted
+ // to their parents place.
+ //
+ // (i) => node is ignored.
+ //
+ // 1
+ // ├── 2(i)
+ // │ ├── 4
+ // │ └── 5
+ // └── 3
+ AXTreeUpdate tree_update;
+ tree_update.root_id = 1;
+ tree_update.nodes.resize(5);
+ tree_update.nodes[0].id = 1;
+ tree_update.nodes[0].child_ids = {2, 3};
+ tree_update.nodes[1].id = 2;
+ tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
+ tree_update.nodes[1].child_ids = {4, 5};
+ tree_update.nodes[2].id = 3;
+ tree_update.nodes[3].id = 4;
+ tree_update.nodes[4].id = 5;
+
+ AXTree tree(tree_update);
+
+ // Root node has no siblings.
+ EXPECT_EQ(nullptr, tree.GetFromId(1)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousUnignoredSibling());
+
+ // Node 2's view of siblings:
+ // literal tree: null <-- [2(i)] --> 3
+ // unignored tree: null <-- [2(i)] --> 3
+ EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextSibling());
+ EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextUnignoredSibling());
+
+ // Node 3's view of siblings:
+ // literal tree: 2(i) <-- [3] --> null
+ // unignored tree: 5 <-- [4] --> null
+ EXPECT_EQ(tree.GetFromId(2), tree.GetFromId(3)->GetPreviousSibling());
+ EXPECT_EQ(tree.GetFromId(5),
+ tree.GetFromId(3)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(3)->GetNextSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(3)->GetNextUnignoredSibling());
+
+ // Node 4's view of siblings:
+ // literal tree: null <-- [4] --> 5
+ // unignored tree: null <-- [4] --> 5
+ EXPECT_EQ(nullptr, tree.GetFromId(4)->GetPreviousSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(4)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(tree.GetFromId(5), tree.GetFromId(4)->GetNextSibling());
+ EXPECT_EQ(tree.GetFromId(5), tree.GetFromId(4)->GetNextUnignoredSibling());
+
+ // Node 5's view of siblings:
+ // literal tree: 4 <-- [5] --> null
+ // unignored tree: 4 <-- [5] --> 3
+ EXPECT_EQ(tree.GetFromId(4), tree.GetFromId(5)->GetPreviousSibling());
+ EXPECT_EQ(tree.GetFromId(4),
+ tree.GetFromId(5)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(5)->GetNextSibling());
+ EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(5)->GetNextUnignoredSibling());
+}
+
+TEST(AXTreeTest, GetUnignoredSiblingsIgnoredChildSkipped) {
+ // Ignored children of ignored parents are skipped over.
+ //
+ // (i) => node is ignored.
+ //
+ // 1
+ // ├── 2(i)
+ // │ ├── 4
+ // │ └── 5(i)
+ // └── 3
+ AXTreeUpdate tree_update;
+ tree_update.root_id = 1;
+ tree_update.nodes.resize(5);
+ tree_update.nodes[0].id = 1;
+ tree_update.nodes[0].child_ids = {2, 3};
+ tree_update.nodes[1].id = 2;
+ tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
+ tree_update.nodes[1].child_ids = {4, 5};
+ tree_update.nodes[2].id = 3;
+ tree_update.nodes[3].id = 4;
+ tree_update.nodes[4].id = 5;
+ tree_update.nodes[4].AddState(ax::mojom::State::kIgnored);
+
+ AXTree tree(tree_update);
+
+ // Root node has no siblings.
+ EXPECT_EQ(nullptr, tree.GetFromId(1)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(1)->GetNextUnignoredSibling());
+
+ // Node 2's view of siblings:
+ // literal tree: null <-- [2(i)] --> 3
+ // unignored tree: null <-- [2(i)] --> 3
+ EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextSibling());
+ EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextUnignoredSibling());
+
+ // Node 3's view of siblings:
+ // literal tree: 2(i) <-- [3] --> null
+ // unignored tree: 4 <-- [3] --> null
+ EXPECT_EQ(tree.GetFromId(2), tree.GetFromId(3)->GetPreviousSibling());
+ EXPECT_EQ(tree.GetFromId(4),
+ tree.GetFromId(3)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(3)->GetNextSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(3)->GetNextUnignoredSibling());
+
+ // Node 4's view of siblings:
+ // literal tree: null <-- [4] --> 5(i)
+ // unignored tree: null <-- [4] --> 3
+ EXPECT_EQ(nullptr, tree.GetFromId(4)->GetPreviousSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(4)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(tree.GetFromId(5), tree.GetFromId(4)->GetNextSibling());
+ EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(4)->GetNextUnignoredSibling());
+
+ // Node 5's view of siblings:
+ // literal tree: 4 <-- [5(i)] --> null
+ // unignored tree: 4 <-- [5(i)] --> 3
+ EXPECT_EQ(tree.GetFromId(4), tree.GetFromId(5)->GetPreviousSibling());
+ EXPECT_EQ(tree.GetFromId(4),
+ tree.GetFromId(5)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(5)->GetNextSibling());
+ EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(5)->GetNextUnignoredSibling());
+}
+
+TEST(AXTreeTest, GetUnignoredSiblingIgnoredParentIrrelevant) {
+ // An ignored parent is not relevant unless the search would need to continue
+ // up through it.
+ //
+ // (i) => node is ignored.
+ //
+ // 1(i)
+ // ├── 2
+ // └── 3
+ AXTreeUpdate tree_update;
+ tree_update.root_id = 1;
+ tree_update.nodes.resize(3);
+ tree_update.nodes[0].id = 1;
+ tree_update.nodes[0].AddState(ax::mojom::State::kIgnored);
+ tree_update.nodes[0].child_ids = {2, 3};
+ tree_update.nodes[1].id = 2;
+ tree_update.nodes[2].id = 3;
+
+ AXTree tree(tree_update);
+
+ // Node 2 and 3 are each other's unignored siblings, the parent's ignored
+ // status is not relevant for this search.
+ EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextUnignoredSibling());
+ EXPECT_EQ(tree.GetFromId(2),
+ tree.GetFromId(3)->GetPreviousUnignoredSibling());
+}
+
+TEST(AXTreeTest, GetUnignoredSiblingsAllIgnored) {
+ // Test termination when all nodes, including the root node, are ignored.
+ //
+ // (i) => node is ignored.
+ //
+ // 1(i)
+ // └── 2(i)
+ AXTreeUpdate tree_update;
+ tree_update.root_id = 1;
+ tree_update.nodes.resize(2);
+ tree_update.nodes[0].id = 1;
+ tree_update.nodes[0].AddState(ax::mojom::State::kIgnored);
+ tree_update.nodes[0].child_ids = {2};
+ tree_update.nodes[1].id = 2;
+ tree_update.nodes[1].AddState(ax::mojom::State::kIgnored);
+
+ AXTree tree(tree_update);
+
+ EXPECT_EQ(nullptr, tree.GetFromId(1)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(1)->GetNextUnignoredSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousUnignoredSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(2)->GetNextUnignoredSibling());
+}
+
+TEST(AXTreeTest, GetUnignoredSiblingsNestedIgnored) {
+ // Test promotion of children through multiple layers of ignored parents.
+ // (i) => node is ignored.
+ //
+ // 1
+ // ├── 2
+ // ├── 3(i)
+ // │ └── 5(i)
+ // │ └── 6
+ // └── 4
+ AXTreeUpdate tree_update;
+ tree_update.root_id = 1;
+ tree_update.nodes.resize(6);
+ tree_update.nodes[0].id = 1;
+ tree_update.nodes[0].child_ids = {2, 3, 4};
+ tree_update.nodes[1].id = 2;
+ tree_update.nodes[2].id = 3;
+ tree_update.nodes[2].AddState(ax::mojom::State::kIgnored);
+ tree_update.nodes[2].child_ids = {5};
+ tree_update.nodes[3].id = 4;
+ tree_update.nodes[4].id = 5;
+ tree_update.nodes[4].AddState(ax::mojom::State::kIgnored);
+ tree_update.nodes[4].child_ids = {6};
+ tree_update.nodes[5].id = 6;
+
+ AXTree tree(tree_update);
+
+ EXPECT_EQ(nullptr, tree.GetFromId(1)->GetPreviousUnignoredSibling());
+
+ const AXNode* node2 = tree.GetFromId(2);
+ const AXNode* node3 = tree.GetFromId(3);
+ const AXNode* node4 = tree.GetFromId(4);
+ const AXNode* node5 = tree.GetFromId(5);
+ const AXNode* node6 = tree.GetFromId(6);
+
+ ASSERT_NE(nullptr, node2);
+ ASSERT_NE(nullptr, node3);
+ ASSERT_NE(nullptr, node4);
+ ASSERT_NE(nullptr, node5);
+ ASSERT_NE(nullptr, node6);
+
+ // Node 2's view of siblings:
+ // literal tree: null <-- [2] --> 3
+ // unignored tree: null <-- [2] --> 6
+ EXPECT_EQ(nullptr, node2->GetPreviousSibling());
+ EXPECT_EQ(nullptr, node2->GetPreviousUnignoredSibling());
+ EXPECT_EQ(node3, node2->GetNextSibling());
+ EXPECT_EQ(node6, node2->GetNextUnignoredSibling());
+
+ // Node 3's view of siblings:
+ // literal tree: 2 <-- [3(i)] --> 4
+ // unignored tree: 2 <-- [3(i)] --> 4
+ EXPECT_EQ(node2, node3->GetPreviousSibling());
+ EXPECT_EQ(node2, node3->GetPreviousUnignoredSibling());
+ EXPECT_EQ(node4, node3->GetNextSibling());
+ EXPECT_EQ(node4, node3->GetNextUnignoredSibling());
+
+ // Node 4's view of siblings:
+ // literal tree: 3 <-- [4] --> null
+ // unignored tree: 6 <-- [4] --> null
+ EXPECT_EQ(node3, node4->GetPreviousSibling());
+ EXPECT_EQ(node6, node4->GetPreviousUnignoredSibling());
+ EXPECT_EQ(nullptr, node4->GetNextSibling());
+ EXPECT_EQ(nullptr, node4->GetNextUnignoredSibling());
+
+ // Node 5's view of siblings:
+ // literal tree: null <-- [5(i)] --> null
+ // unignored tree: 2 <-- [5(i)] --> 4
+ EXPECT_EQ(nullptr, node5->GetPreviousSibling());
+ EXPECT_EQ(node2, node5->GetPreviousUnignoredSibling());
+ EXPECT_EQ(nullptr, node5->GetNextSibling());
+ EXPECT_EQ(node4, node5->GetNextUnignoredSibling());
+
+ // Node 6's view of siblings:
+ // literal tree: null <-- [6] --> null
+ // unignored tree: 2 <-- [6] --> 4
+ EXPECT_EQ(nullptr, node6->GetPreviousSibling());
+ EXPECT_EQ(node2, node6->GetPreviousUnignoredSibling());
+ EXPECT_EQ(nullptr, node6->GetNextSibling());
+ EXPECT_EQ(node4, node6->GetNextUnignoredSibling());
+}
+
TEST(AXTreeTest, UnignoredSelection) {
AXTreeUpdate tree_update;
// (i) => node is ignored
@@ -2566,6 +3041,50 @@ TEST(AXTreeTest, UnignoredSelection) {
TEST_SELECTION(tree_update, test_ax_tree_manager.GetTree(), input, expected);
}
+TEST(AXTreeTest, GetChildrenOrSiblings) {
+ // 1
+ // ├── 2
+ // │ └── 5
+ // ├── 3
+ // └── 4
+ AXTreeUpdate tree_update;
+ tree_update.root_id = 1;
+ tree_update.nodes.resize(5);
+ tree_update.nodes[0].id = 1;
+ tree_update.nodes[0].child_ids = {2, 3, 4};
+ tree_update.nodes[1].id = 2;
+ tree_update.nodes[1].child_ids = {5};
+ tree_update.nodes[2].id = 3;
+ tree_update.nodes[3].id = 4;
+ tree_update.nodes[4].id = 5;
+
+ AXTree tree(tree_update);
+
+ EXPECT_EQ(tree.GetFromId(2), tree.GetFromId(1)->GetFirstChild());
+ EXPECT_EQ(tree.GetFromId(5), tree.GetFromId(2)->GetFirstChild());
+ EXPECT_EQ(nullptr, tree.GetFromId(3)->GetFirstChild());
+ EXPECT_EQ(nullptr, tree.GetFromId(4)->GetFirstChild());
+ EXPECT_EQ(nullptr, tree.GetFromId(5)->GetFirstChild());
+
+ EXPECT_EQ(tree.GetFromId(4), tree.GetFromId(1)->GetLastChild());
+ EXPECT_EQ(tree.GetFromId(5), tree.GetFromId(2)->GetLastChild());
+ EXPECT_EQ(nullptr, tree.GetFromId(3)->GetLastChild());
+ EXPECT_EQ(nullptr, tree.GetFromId(4)->GetLastChild());
+ EXPECT_EQ(nullptr, tree.GetFromId(5)->GetLastChild());
+
+ EXPECT_EQ(nullptr, tree.GetFromId(1)->GetPreviousSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(2)->GetPreviousSibling());
+ EXPECT_EQ(tree.GetFromId(2), tree.GetFromId(3)->GetPreviousSibling());
+ EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(4)->GetPreviousSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(5)->GetPreviousSibling());
+
+ EXPECT_EQ(nullptr, tree.GetFromId(1)->GetNextSibling());
+ EXPECT_EQ(tree.GetFromId(3), tree.GetFromId(2)->GetNextSibling());
+ EXPECT_EQ(tree.GetFromId(4), tree.GetFromId(3)->GetNextSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(4)->GetNextSibling());
+ EXPECT_EQ(nullptr, tree.GetFromId(5)->GetNextSibling());
+}
+
TEST(AXTreeTest, ChildTreeIds) {
ui::AXTreeID tree_id_1 = ui::AXTreeID::CreateNewAXTreeID();
ui::AXTreeID tree_id_2 = ui::AXTreeID::CreateNewAXTreeID();
@@ -3647,6 +4166,43 @@ TEST(AXTreeTest, TestSetSizePosInSetMenuItemValidChildOfMenuListPopup) {
EXPECT_OPTIONAL_EQ(2, item2->GetSetSize());
}
+TEST(AXTreeTest, TestSetSizePostInSetListBoxOptionWithGroup) {
+ AXTreeUpdate initial_state;
+ initial_state.root_id = 1;
+ initial_state.nodes.resize(7);
+ initial_state.nodes[0].id = 1;
+ initial_state.nodes[0].child_ids = {2, 3};
+ initial_state.nodes[0].role = ax::mojom::Role::kListBox;
+ initial_state.nodes[1].id = 2;
+ initial_state.nodes[1].child_ids = {4, 5};
+ initial_state.nodes[1].role = ax::mojom::Role::kGroup;
+ initial_state.nodes[2].id = 3;
+ initial_state.nodes[2].child_ids = {6, 7};
+ initial_state.nodes[2].role = ax::mojom::Role::kGroup;
+ initial_state.nodes[3].id = 4;
+ initial_state.nodes[3].role = ax::mojom::Role::kListBoxOption;
+ initial_state.nodes[4].id = 5;
+ initial_state.nodes[4].role = ax::mojom::Role::kListBoxOption;
+ initial_state.nodes[5].id = 6;
+ initial_state.nodes[5].role = ax::mojom::Role::kListBoxOption;
+ initial_state.nodes[6].id = 7;
+ initial_state.nodes[6].role = ax::mojom::Role::kListBoxOption;
+ AXTree tree(initial_state);
+
+ AXNode* listbox_option1 = tree.GetFromId(4);
+ EXPECT_OPTIONAL_EQ(1, listbox_option1->GetPosInSet());
+ EXPECT_OPTIONAL_EQ(2, listbox_option1->GetSetSize());
+ AXNode* listbox_option2 = tree.GetFromId(5);
+ EXPECT_OPTIONAL_EQ(2, listbox_option2->GetPosInSet());
+ EXPECT_OPTIONAL_EQ(2, listbox_option2->GetSetSize());
+ AXNode* listbox_option3 = tree.GetFromId(6);
+ EXPECT_OPTIONAL_EQ(1, listbox_option3->GetPosInSet());
+ EXPECT_OPTIONAL_EQ(2, listbox_option3->GetSetSize());
+ AXNode* listbox_option4 = tree.GetFromId(7);
+ EXPECT_OPTIONAL_EQ(2, listbox_option4->GetPosInSet());
+ EXPECT_OPTIONAL_EQ(2, listbox_option4->GetSetSize());
+}
+
TEST(AXTreeTest, OnNodeWillBeDeletedHasValidUnignoredParent) {
AXTreeUpdate initial_state;
initial_state.root_id = 1;
diff --git a/chromium/ui/accessibility/extensions/chromevoxclassic/testing/chromevox_unittest_base.js b/chromium/ui/accessibility/extensions/chromevoxclassic/testing/chromevox_unittest_base.js
index 60d6ce32b92..29e01eb3824 100644
--- a/chromium/ui/accessibility/extensions/chromevoxclassic/testing/chromevox_unittest_base.js
+++ b/chromium/ui/accessibility/extensions/chromevoxclassic/testing/chromevox_unittest_base.js
@@ -30,6 +30,13 @@ ChromeVoxUnitTestBase.prototype = {
__proto__: testing.Test.prototype,
/** @override */
+ testGenCppIncludes: function() {
+ GEN(`
+ #include "content/public/test/browser_test.h"
+ `);
+ },
+
+ /** @override */
closureModuleDeps: [
'cvox.ChromeVoxTester',
'cvox.ChromeVoxUserCommands',
diff --git a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_ar.xtb b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_ar.xtb
index 19856e0275f..04701ee1faa 100644
--- a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_ar.xtb
+++ b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_ar.xtb
@@ -20,7 +20,7 @@
<translation id="2808027189040546825">الخطوة الأولى: تحدد الصف مع النجوم الأضعف:</translation>
<translation id="2965611304828530558">‏&lt;p&gt;عندما تصل إلى رابط أو عنصر تحكم فإنه يتم التركيز عليه تلقائيًا. انقر على &lt;span class='key'&gt;Enter&lt;/span&gt; للنقر على رابط أو زر. &lt;/ P&gt; &lt;p&gt; عندما يقوم عنصر تحكم مُركز عليه بالتقاط مفاتيح الأسهم (مثل مربع نص أو مربع قائمة)، اضغط على &lt;span class='key'&gt;Esc&lt;/span&gt; SPAN&gt; تليها السهم الأيمن أو الأيسر لمواصلة التصفح النصي بالمؤشر &lt;/ P&gt; &lt;P&gt; وبدلاً من ذلك، اضغط &lt;span class='key'&gt;Tab&lt;/span&gt; للانتقال إلى عنصر التحكم التالي القابل للتركيز عليه &lt;/ P&gt;</translation>
<translation id="3252573918265662711">الإعداد</translation>
-<translation id="3410969471888629217">نسيان تخصيصات موقع الويب</translation>
+<translation id="3410969471888629217">نسيان تخصيصات الموقع الإلكتروني</translation>
<translation id="3435896845095436175">تفعيل الإضافات</translation>
<translation id="3622586652998721735">تعيين كمخطط تلقائي</translation>
<translation id="3812541808639806898">‏عارض النص "Alt" للصورة</translation>
diff --git a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_eu.xtb b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_eu.xtb
index 3963c022258..c288793020f 100644
--- a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_eu.xtb
+++ b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_eu.xtb
@@ -7,7 +7,7 @@
<translation id="1555130319947370107">Urdina</translation>
<translation id="1588438908519853928">Arrunta</translation>
<translation id="1591070050619849194">Desgaitu animazio guztiak.</translation>
-<translation id="1703735871906654364">Tartekatze-ikurrak arakatzeko aplikazioa</translation>
+<translation id="1703735871906654364">Tartekatze-ikurraren bidez arakatzeko aplikazioa</translation>
<translation id="1791496371305830581">Onartu animazio guztiak.</translation>
<translation id="1996252509865389616">Gaitu nahi duzu?</translation>
<translation id="2079545284768500474">Desegin</translation>
@@ -18,7 +18,7 @@
<translation id="2648340354586434750">Eduki sakatuta &lt;span class='key'&gt;Aukera&lt;/span&gt; hitz batetik bestera mugitzeko.</translation>
<translation id="2795227192542594043">Luzapenak kurtsore mugikorra jartzen du webgunean testua teklatuarekin hautatu ahal izateko.</translation>
<translation id="2808027189040546825">1. urratsa: hautatu izar lausoenak dituen errenkada:</translation>
-<translation id="2965611304828530558">&lt;p&gt;Estekara edo kontrolera iristean, automatikoki fokuratzen da. Sakatu &lt;span class='key'&gt;Sartu&lt;/span&gt; estekan edo botoian klik egitean. &lt;/p&gt; &lt;p&gt;Fokuratutako kontrolak (adibidez, testu-koadroak edo zerrenda-koadroak) gezien teklak hartzen dituenean, sakatu &lt;span class='key'&gt;Esc&lt;/span&gt; eta, ondoren, Ezkerrera edo Eskuinera gezia, tartekatze-ikurrak arakatzen jarraitzeko. &lt;/p&gt; &lt;p&gt;Horren ordez, sakatu &lt;span class='key'&gt;Fitxa&lt;/span&gt; fokura daitekeen hurrengo kontrolera joateko. &lt;/p&gt;</translation>
+<translation id="2965611304828530558">&lt;p&gt;Estekara edo kontrolera iristean, automatikoki fokuratzen da. Sakatu &lt;span class='key'&gt;Sartu&lt;/span&gt; estekan edo botoian klik egitean. &lt;/p&gt; &lt;p&gt;Fokuratutako kontrolak (adibidez, testu-koadroak edo zerrenda-koadroak) gezi-teklak hartzen dituenean, sakatu &lt;span class='key'&gt;Esc&lt;/span&gt; eta, ondoren, Ezkerrera edo Eskuinera gezia, tartekatze-ikurraren bidez arakatzen jarraitzeko. &lt;/p&gt; &lt;p&gt;Horren ordez, sakatu &lt;span class='key'&gt;Fitxa&lt;/span&gt; fokura daitekeen hurrengo kontrolera joateko. &lt;/p&gt;</translation>
<translation id="3252573918265662711">Konfigurazioa</translation>
<translation id="3410969471888629217">Ahaztu webgunearen pertsonalizazioak</translation>
<translation id="3435896845095436175">Gaitu</translation>
@@ -32,7 +32,7 @@
<translation id="4896660567607030658">Ez bistaratu azalpenik; besterik gabe, erakutsi kurtsorea.</translation>
<translation id="4937901943818762779">Gaitu animazioak, baina behin soilik.</translation>
<translation id="4949131196216960195">Sakatu &lt;span class='key'&gt;Bilatu&lt;/span&gt; + &lt;img src='increase_brightness.png'&gt; (distira handiagotzeko tekla edo F7) teklatu bidezko arakatzea aktibatzeko. Saka ezazu berriro desaktibatzeko.</translation>
-<translation id="4954450790315188152">Tartekatze-ikurrak arakatzeko aukera aktibatuta dagoenean:</translation>
+<translation id="4954450790315188152">Tartekatze-ikurraren bidez arakatzeko aukera aktibatuta dagoenean:</translation>
<translation id="5041932793799765940">Kolore doikuntza</translation>
<translation id="5094574508723441140">Kontraste handitua</translation>
<translation id="5173942593318174089">Nabarmendu kurtsorearen posizioa animazioarekin.</translation>
@@ -60,9 +60,9 @@
<translation id="7658239707568436148">Utzi</translation>
<translation id="786423340267544509">Gehitu ertza aria-describedat edo longdesc atributuak dituen elementuan.</translation>
<translation id="7942349550061667556">Gorria</translation>
-<translation id="8260673944985561857">Tartekatze-ikurrak arakatzeko aukerak</translation>
+<translation id="8260673944985561857">Tartekatze-ikurraren bidez arakatzeko aukerak</translation>
<translation id="8321034316479930120">Animazioen gidalerroak</translation>
<translation id="8480209185614411573">Kontraste handia</translation>
-<translation id="8609925175482059018">Sakatu &lt;span class='key'&gt;F7&lt;/span&gt; tartekatze-ikurrak arakatzeko aukera aktibatzeko. Saka ezazu berriro desaktibatzeko.</translation>
+<translation id="8609925175482059018">Sakatu &lt;span class='key'&gt;F7&lt;/span&gt; tartekatze-ikurraren bidez arakatzeko aukera aktibatzeko. Saka ezazu berriro desaktibatzeko.</translation>
<translation id="894241283505723656">Laster-menuko azalpen luzeak</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_hi.xtb b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_hi.xtb
index 6ee3067ed22..6bff44a3f67 100644
--- a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_hi.xtb
+++ b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_hi.xtb
@@ -10,7 +10,7 @@
<translation id="1703735871906654364">कैरेट ब्राउज़िंग</translation>
<translation id="1791496371305830581">सभी ऐनिमेट किए गए चित्रों को अनुमति दें.</translation>
<translation id="1996252509865389616">चालू करें?</translation>
-<translation id="2079545284768500474">वापस लाएं</translation>
+<translation id="2079545284768500474">पहले जैसा करें</translation>
<translation id="2179565792157161713">लंबे वर्णन को नए टैब में खोलें</translation>
<translation id="2223143012868735942">रंग की समझ को बेहतर बनाने के लिए वेबपृष्‍ठों में एक कस्‍टमाइज़ करने योग्‍य रंग फ़िल्‍टर लागू किया गया है.</translation>
<translation id="2394933097471027016">इसे अभी आज़माएं - कैरेट ब्राउज़िंग इस पृष्‍ठ पर हमेशा सक्षम रहती है!</translation>
@@ -30,7 +30,7 @@
<translation id="4394049700291259645">बंद करें</translation>
<translation id="4769065380738716500">चित्रों को उनके वैकल्‍पिक लेख से बदल दिया गया है.</translation>
<translation id="4896660567607030658">कोई फ़ीडबैक नहीं, बस कर्सर दिखाएं.</translation>
-<translation id="4937901943818762779">ऐनिमेट किए गए चित्रों को अनुमति दें, लेकिन केवल एक बार.</translation>
+<translation id="4937901943818762779">ऐनिमेट किए गए चित्रों को अनुमति दें, लेकिन सिर्फ़ एक बार.</translation>
<translation id="4949131196216960195">कैरेट ब्राउज़िंग चालू करने के लिए &lt;span class='key'&gt;Search&lt;/span&gt; + &lt;img src='increase_brightness.png'&gt; (स्क्रीन की चमक बढाने वाली कुंजी या F7) दबाएं. इसे बंद करने के लिए, दोबारा दबाएं.</translation>
<translation id="4954450790315188152">जब कैरेट ब्राउज़िंग सक्षम हो:</translation>
<translation id="5041932793799765940">रंग समायोजन</translation>
diff --git a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_id.xtb b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_id.xtb
index 026e399d69b..8574d4ecc7a 100644
--- a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_id.xtb
+++ b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_id.xtb
@@ -44,7 +44,7 @@
<translation id="5631241868147802353">Skema warna default:</translation>
<translation id="5650358096585648000">Masukan Visual</translation>
<translation id="5710185147685935461">Mengubah atau membalikkan skema warna untuk membuat halaman web lebih mudah dibaca.</translation>
-<translation id="5939518447894949180">Setel ulang</translation>
+<translation id="5939518447894949180">Reset</translation>
<translation id="595639123821853262">Abu-Abu Terbalik</translation>
<translation id="6017514345406065928">Hijau</translation>
<translation id="6050189528197190982">Abu-Abu</translation>
diff --git a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_km.xtb b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_km.xtb
index 72e18b7a6bc..57487c3ce31 100644
--- a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_km.xtb
+++ b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_km.xtb
@@ -10,7 +10,7 @@
<translation id="1703735871906654364">ការរុករកការ៉ាត់</translation>
<translation id="1791496371305830581">អនុញ្ញាតរូបភាពមានចលនាទាំងអស់។</translation>
<translation id="1996252509865389616">បើកដំណើរការ?</translation>
-<translation id="2079545284768500474">បកក្រោយ</translation>
+<translation id="2079545284768500474">ត្រឡប់វិញ</translation>
<translation id="2179565792157161713">បើកការពិពណ៌វែងនៅក្នុងផ្ទាំងថ្មី</translation>
<translation id="2223143012868735942">តម្រងពណ៌ដែលអាចកែសម្រួលបានអនុវត្តចំពោះគេហទំព័រដើម្បីធ្វើឲ្យការយល់ឃើញពីពណ៌បានប្រសើរជាងមុន។</translation>
<translation id="2394933097471027016">សាកល្បងវាឥឡូវនេះ ការរុករកការ៉ាត់បើកដំណើរការនៅលើទំព័រនេះជានិច្ច!</translation>
diff --git a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_my.xtb b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_my.xtb
index 9e22887d29a..f38aadf8f1b 100644
--- a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_my.xtb
+++ b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_my.xtb
@@ -10,15 +10,15 @@
<translation id="1703735871906654364">Caret ဖြင့် ရှာကြည့်မှု</translation>
<translation id="1791496371305830581">ရွှေ့လျားရုပ်ပုံများအားလုံး ခွင့်ပြုမည်။</translation>
<translation id="1996252509865389616">ဖွင့်မည်လား?</translation>
-<translation id="2079545284768500474">ပြန်ဖျက်ရန်</translation>
-<translation id="2179565792157161713">ရှည်လျားသည့် ဖေါ်ပြချက်ကို တဲဘ် အသစ်ထဲမှာ ဖွင့်ရန်</translation>
+<translation id="2079545284768500474">တစ်ဆင့်နောက်ပြန်ရန်</translation>
+<translation id="2179565792157161713">ရှည်လျားသည့် ဖေါ်ပြချက်ကို တဘ် အသစ်ထဲမှာ ဖွင့်ရန်</translation>
<translation id="2223143012868735942">ဝက်ဘ်စာမျက်နှာများတွင် အရောင် ပိုမိုကောင်းစွာမြင်ရရန် စိတ်ကြိုက်ပြုပြင်နိုင်သော အရောင်စိစစ်မှုအား သုံး၏။</translation>
<translation id="2394933097471027016">အဲဒါကို ယခုု စမ်းကြည့်ပါ - ဒီစာမျက်နှာမှာ Caret ဖြင့် ရှာကြည့်မှုကို အမြဲတမ်း ဖွင့်ထားသည်!</translation>
<translation id="2471847333270902538"><ph name="SITE" /> အတွက် အရောင် ဇယား:</translation>
<translation id="2648340354586434750">စာလုံးအလိုက် ရွေ့ရှားရန် &lt;span class='key'&gt;ရွေးစရာ&lt;/span&gt; ကို နှိပ်ကိုင်ထားပါ။</translation>
<translation id="2795227192542594043">ဒီတိုးချဲ့ချက်က သင့်အတွက် ဝဘ် စာမျက်နှာထဲမှာ လှုပ်ရှားနိုင်သည့် ညွှန်းမြားကို စီစဉ်ပေးကာ၊ စာသားကို ကီးဘုတ်ဖြင့် ရွေးခွင့်ပြုမည်။</translation>
<translation id="2808027189040546825">အဆင့် 1: အမှိန်ဆုံးကြယ်များဖြင့် အတန်းကိုရွေးရန်:</translation>
-<translation id="2965611304828530558">&lt;p&gt;သင်က လင့် သို့မဟုတ် ထိန်းချုပ်မှု တစ်ခုဆီကို ရောက်လျှင်၊ ၎င်းသည် အလိုအလျောက် ဆုံချက်ညှိယူသည်။ လင့် သို့မဟုတ် ခလုတ် တစ်ခုကို ကလစ်ရန် &lt;span class='key'&gt;အင်တာ&lt;/span&gt;ကို နှိပ်ပါ။ &lt;/p&gt; &lt;p&gt; ဆုံချက် ထိန်းချုပ်မှု တစ်ခုက (စာသား အကွက် သို့မဟုတ် စာရင်း အကွက်လို) မြားကီးများကို ဖမ်းမိထားလျှင်၊ &lt;span class='key'&gt;Esc&lt;/span&gt; ကို နှိပ်လိုက်ကာ၊ Caret ဖြင့် ရှာကြည့်မှုကို ဆက်သုံးရန် ဘယ် သို့မဟုတ် ညာ မြားကို နှိပ်ပါ။ &lt;/p&gt; &lt;p&gt; သို့မဟုတ်ပါက၊ &lt;span class='key'&gt;တဲဘ်&lt;/span&gt; ကို နှိပ်လိုက်ခြင်းဖြင့် နောက် ဆုံချက်ညှိရနိုင်သည့် ထိန်းချုပ်မှုဆီကို ရွေ့သွားမည်။&lt;/p&gt;</translation>
+<translation id="2965611304828530558">&lt;p&gt;သင်က လင့် သို့မဟုတ် ထိန်းချုပ်မှု တစ်ခုဆီကို ရောက်လျှင်၊ ၎င်းသည် အလိုအလျောက် ဆုံချက်ညှိယူသည်။ လင့် သို့မဟုတ် ခလုတ် တစ်ခုကို ကလစ်ရန် &lt;span class='key'&gt;အင်တာ&lt;/span&gt;ကို နှိပ်ပါ။ &lt;/p&gt; &lt;p&gt; ဆုံချက် ထိန်းချုပ်မှု တစ်ခုက (စာသား အကွက် သို့မဟုတ် စာရင်း အကွက်လို) မြားကီးများကို ဖမ်းမိထားလျှင်၊ &lt;span class='key'&gt;Esc&lt;/span&gt; ကို နှိပ်လိုက်ကာ၊ Caret ဖြင့် ရှာကြည့်မှုကို ဆက်သုံးရန် ဘယ် သို့မဟုတ် ညာ မြားကို နှိပ်ပါ။ &lt;/p&gt; &lt;p&gt; သို့မဟုတ်ပါက၊ &lt;span class='key'&gt;တဘ်&lt;/span&gt; ကို နှိပ်လိုက်ခြင်းဖြင့် နောက် ဆုံချက်ညှိရနိုင်သည့် ထိန်းချုပ်မှုဆီကို ရွေ့သွားမည်။&lt;/p&gt;</translation>
<translation id="3252573918265662711">တပ်ဆင်ရန်</translation>
<translation id="3410969471888629217">ဆိုက်ကို စိတ်ကြိုက်လုပ်ထားမှုကို မေ့ပစ်လိုက်ရန်</translation>
<translation id="3435896845095436175">ဖွင့်ပေးရန်</translation>
diff --git a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_ne.xtb b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_ne.xtb
index c624db01118..1625ac72dfa 100644
--- a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_ne.xtb
+++ b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_ne.xtb
@@ -4,7 +4,7 @@
<translation id="1287053896835709737">कालोमा पहेंलो</translation>
<translation id="1408730541890277710">वैकल्पिक पाठद्वारा छविहरूलाई बदल्नुहोस्।</translation>
<translation id="145360476452865422">एनिमेसन नीति:</translation>
-<translation id="1555130319947370107">नीलो</translation>
+<translation id="1555130319947370107">निलो</translation>
<translation id="1588438908519853928">सामान्य</translation>
<translation id="1591070050619849194">सबै छवि एनिमेसन असक्षम गर्नुहोस्।</translation>
<translation id="1703735871906654364">क्यारेट ब्राउजिङ</translation>
diff --git a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_sw.xtb b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_sw.xtb
index cb76eb4e796..027b1e2b05b 100644
--- a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_sw.xtb
+++ b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_sw.xtb
@@ -7,18 +7,18 @@
<translation id="1555130319947370107">Samawati</translation>
<translation id="1588438908519853928">Ya kawaida</translation>
<translation id="1591070050619849194">Zima uhuishaji wa picha zote.</translation>
-<translation id="1703735871906654364">Kuvinjari kwa Kareti</translation>
+<translation id="1703735871906654364">Kuvinjari kwa Kibodi</translation>
<translation id="1791496371305830581">Ruhusu picha zote zilizouhuishwa.</translation>
<translation id="1996252509865389616">Ungependa kuwasha?</translation>
<translation id="2079545284768500474">Tendua</translation>
<translation id="2179565792157161713">Fungua Maelezo Marefu Katika Kichupo Kipya</translation>
<translation id="2223143012868735942">Kichujio cha rangi kinachoweza kugeuzwa ili kifae kinachotumiwa kwenye kurasa za wavuti ili kuboresha mwonekano wa rangi.</translation>
-<translation id="2394933097471027016">Jaribu sasa - Kuvinjari kwa Kareti huwa kumewashwa kwenye ukurasa huu wakati wowote!</translation>
+<translation id="2394933097471027016">Jaribu sasa - Kuvinjari kwa Kibodi huwa kumewashwa kwenye ukurasa huu wakati wowote!</translation>
<translation id="2471847333270902538">Mpango wa rangi wa <ph name="SITE" />:</translation>
<translation id="2648340354586434750">Shikilia chini &lt;span class='key'&gt;Chaguo&lt;/span&gt; ili kusogea kwa maneno.</translation>
<translation id="2795227192542594043">Kiendelezi hiki kinakupa kielekezi cha kusogeza katika ukurasa wa wavuti, na kukuruhusu kuchagua maandishi kwa kibodi.</translation>
<translation id="2808027189040546825">Hatua ya 1: Chagua safu mlalo yenye nyota zilizofifia zaidi:</translation>
-<translation id="2965611304828530558">&lt;p&gt;Unapofikia kiungo au kidhibiti, kinaangaziwa kiotomatiki. Bonyeza &lt;span class='key'&gt;Enter&lt;/span&gt; ili kubofya kiungo au kitufe. &lt;/p&gt; &lt;p&gt; Kidhibiti kilichoangaziwa (kama vile kikasha cha maandishi au kikasha cha orodha) kinapopiga picha vitufe vya vishale, bonyeza &lt;span class='key'&gt;Esc&lt;/span&gt; ukifuatisha kishale cha kushoto au kulia ili kuendelea Kuvinjari kwa Kareti. &lt;/p&gt; &lt;p&gt; Njia nyingine, bonyeza &lt;span class='key'&gt;Kichupo&lt;/span&gt; ili kuhamisha kidhibiti kinachofuata kinachoweza kuangaziwa. &lt;/p&gt;</translation>
+<translation id="2965611304828530558">&lt;p&gt;Unapofikia kiungo au kidhibiti, kinaangaziwa kiotomatiki. Bonyeza &lt;span class='key'&gt;Enter&lt;/span&gt; ili ubofye kiungo au kitufe. &lt;/p&gt; &lt;p&gt;Kidhibiti kilichoangaziwa (kama vile kikasha cha maandishi au cha orodha) kinaponasa vitufe vya vishale, bonyeza &lt;span class='key'&gt;Esc&lt;/span&gt; ukifuatisha kishale cha kushoto au kulia ili kuendelea Kuvinjari kwa Kibodi. &lt;/p&gt; &lt;p&gt; Njia nyingine, bonyeza &lt;span class='key'&gt;Kichupo&lt;/span&gt; ili kuhamisha kidhibiti kinachofuata kinachoweza kuangaziwa. &lt;/p&gt;</translation>
<translation id="3252573918265662711">Usanidi</translation>
<translation id="3410969471888629217">Sahau ugeuzaji wa tovuti ili zikufae</translation>
<translation id="3435896845095436175">Washa</translation>
@@ -31,8 +31,8 @@
<translation id="4769065380738716500">Picha zimebadilishwa kwa maandishi yao ya alt.</translation>
<translation id="4896660567607030658">Hakuna maoni, onyesha tu kielekezi.</translation>
<translation id="4937901943818762779">Ruhusu picha zilizouhuishwa, lakini mara moja pekee.</translation>
-<translation id="4949131196216960195">Bonyeza &lt;span class='key'&gt;Tafuta&lt;/span&gt; + &lt;img src='increase_brightness.png'&gt; (kitufe cha 'Ongeza Mwangaza' au F7) ili uwashe 'Kuvinjari kwa Kareti'. Ibonyeze tena ili uizime.</translation>
-<translation id="4954450790315188152">Kuvinjari kwa Kareti kunapowashwa:</translation>
+<translation id="4949131196216960195">Bonyeza &lt;span class='key'&gt;Tafuta&lt;/span&gt; + &lt;img src='increase_brightness.png'&gt; (kitufe cha 'Ongeza Mwangaza' au F7) ili uwashe 'Kuvinjari kwa Kibodi'. Zibonyeze tena ili uzime.</translation>
+<translation id="4954450790315188152">Wakati kipengele cha Kuvinjari kwa Kibodi kimewashwa:</translation>
<translation id="5041932793799765940">Marekebisho ya rangi</translation>
<translation id="5094574508723441140">Utofautishaji ulioongezeka</translation>
<translation id="5173942593318174089">Angazia kilipo kielekezi kwa uhuishaji.</translation>
@@ -60,9 +60,9 @@
<translation id="7658239707568436148">Ghairi</translation>
<translation id="786423340267544509">Ongeza mpaka kwenye vipengee vilivyo na vipengele vya aria-describedat au longdesc.</translation>
<translation id="7942349550061667556">Nyekundu</translation>
-<translation id="8260673944985561857">Chaguo za Kuvinjari za Kareti</translation>
+<translation id="8260673944985561857">Chaguo za Kuvinjari kwa Kibodi</translation>
<translation id="8321034316479930120">Sera ya Uhuishaji</translation>
<translation id="8480209185614411573">Utofautishaji wa Juu</translation>
-<translation id="8609925175482059018">Bonyeza &lt;span class='key'&gt;F7&lt;/span&gt; ili kuwasha Kuvinjari kwa Kareti. Kibonyeze tena ili kuizima.</translation>
+<translation id="8609925175482059018">Bonyeza &lt;span class='key'&gt;F7&lt;/span&gt; ili uwashe Kuvinjari kwa Kibodi. Kibonyeze tena ili uzime.</translation>
<translation id="894241283505723656">Maelezo Marefu katika Menyu ya Muktadha</translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_vi.xtb b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_vi.xtb
index d1f294ea8d5..fe3f101fbae 100644
--- a/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_vi.xtb
+++ b/chromium/ui/accessibility/extensions/strings/accessibility_extensions_strings_vi.xtb
@@ -11,14 +11,14 @@
<translation id="1791496371305830581">Cho phép tất cả hình ảnh động.</translation>
<translation id="1996252509865389616">Bật?</translation>
<translation id="2079545284768500474">Hoàn tác</translation>
-<translation id="2179565792157161713">Mở mô tả dài trong tab mới</translation>
+<translation id="2179565792157161713">Mở mô tả dài trong thẻ mới</translation>
<translation id="2223143012868735942">Bộ lọc màu tùy chỉnh được áp dụng cho các trang web để tăng cường nhận biết màu.</translation>
<translation id="2394933097471027016">Hãy dùng thử ngay bây giờ - chế độ Duyệt với con nháy luôn được bật trên trang này!</translation>
<translation id="2471847333270902538">Lược đồ màu dành cho <ph name="SITE" />:</translation>
<translation id="2648340354586434750">Nhấn và giữ &lt;span class='key'&gt;Tùy chọn&lt;/span&gt; để di chuyển theo từ.</translation>
<translation id="2795227192542594043">Tiện ích này cung cấp cho bạn một con trỏ di động trong trang web, cho phép bạn chọn văn bản bằng bàn phím.</translation>
<translation id="2808027189040546825">Bước 1: Chọn hàng có các ngôi sao nhạt nhất:</translation>
-<translation id="2965611304828530558">&lt;p&gt;Khi bạn tới một liên kết hoặc nút điều khiển, liên kết hoặc nút điều khiển đó sẽ tự động được lấy làm tiêu điểm. Nhấn &lt;span class='key'&gt;Enter&lt;/span&gt; để nhấp vào liên kết hoặc nút. &lt;/p&gt; &lt;p&gt; Khi một nút điều khiển được lấy làm tiêu điểm (như hộp văn bản hoặc hộp danh sách) đang chụp các phím mũi tên, nhấn &lt;span class='key'&gt;Esc&lt;/span&gt; rồi đến mũi tên trái hoặc phải để tiếp tục chế độ Duyệt với con nháy. &lt;/p&gt; &lt;p&gt; Hoặc, nhấn vào &lt;span class='key'&gt;Tab&lt;/span&gt; để chuyển tới nút điều khiển có thể lấy làm tiêu điểm tiếp theo. &lt;/p&gt;</translation>
+<translation id="2965611304828530558">&lt;p&gt;Khi bạn tới một liên kết hoặc nút điều khiển, liên kết hoặc nút điều khiển đó sẽ tự động được lấy làm tiêu điểm. Nhấn &lt;span class='key'&gt;Enter&lt;/span&gt; để nhấp vào liên kết hoặc nút. &lt;/p&gt; &lt;p&gt; Khi một nút điều khiển được lấy làm tiêu điểm (như hộp văn bản hoặc hộp danh sách) đang chụp các phím mũi tên, nhấn &lt;span class='key'&gt;Esc&lt;/span&gt; rồi đến mũi tên trái hoặc phải để tiếp tục chế độ Duyệt với con nháy. &lt;/p&gt; &lt;p&gt; Hoặc, nhấn vào &lt;span class='key'&gt;Thẻ&lt;/span&gt; để chuyển tới nút điều khiển có thể lấy làm tiêu điểm tiếp theo. &lt;/p&gt;</translation>
<translation id="3252573918265662711">Thiết lập</translation>
<translation id="3410969471888629217">Bỏ qua các tùy chỉnh đối với trang web</translation>
<translation id="3435896845095436175">Bật</translation>
diff --git a/chromium/ui/accessibility/mojom/BUILD.gn b/chromium/ui/accessibility/mojom/BUILD.gn
index 877b3561e6d..654241c270b 100644
--- a/chromium/ui/accessibility/mojom/BUILD.gn
+++ b/chromium/ui/accessibility/mojom/BUILD.gn
@@ -9,6 +9,7 @@ mojom("mojom") {
"ax_action_data.mojom",
"ax_assistant_structure.mojom",
"ax_event.mojom",
+ "ax_event_intent.mojom",
"ax_node_data.mojom",
"ax_relative_bounds.mojom",
"ax_tree_data.mojom",
@@ -25,4 +26,124 @@ mojom("mojom") {
"//ui/gfx/range/mojom",
"//url/mojom:url_mojom_gurl",
]
+
+ cpp_typemaps = [
+ {
+ types = [
+ {
+ mojom = "ax.mojom.AXActionData"
+ cpp = "::ui::AXActionData"
+ },
+ ]
+ traits_sources = [ "ax_action_data_mojom_traits.cc" ]
+ traits_headers = [ "ax_action_data_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/accessibility" ]
+ },
+ {
+ types = [
+ {
+ mojom = "ax.mojom.AssistantTree"
+ cpp = "::std::unique_ptr<::ui::AssistantTree>"
+ move_only = true
+ nullable_is_same_type = true
+ },
+ {
+ mojom = "ax.mojom.AssistantNode"
+ cpp = "::std::unique_ptr<::ui::AssistantNode>"
+ move_only = true
+ },
+ ]
+ traits_sources = [ "ax_assistant_structure_mojom_traits.cc" ]
+ traits_headers = [ "ax_assistant_structure_mojom_traits.h" ]
+ traits_public_deps = [
+ "//ui/accessibility:ax_assistant",
+ "//ui/gfx",
+ "//ui/gfx/geometry/mojom",
+ "//ui/gfx/geometry/mojom:mojom_traits",
+ "//ui/gfx/range/mojom",
+ ]
+ },
+ {
+ types = [
+ {
+ mojom = "ax.mojom.AXEventIntent"
+ cpp = "::ui::AXEventIntent"
+ },
+ ]
+ traits_sources = [ "ax_event_intent_mojom_traits.cc" ]
+ traits_headers = [ "ax_event_intent_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/accessibility" ]
+ },
+ {
+ types = [
+ {
+ mojom = "ax.mojom.AXEvent"
+ cpp = "::ui::AXEvent"
+ },
+ ]
+ traits_sources = [ "ax_event_mojom_traits.cc" ]
+ traits_headers = [ "ax_event_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/accessibility" ]
+ },
+ {
+ types = [
+ {
+ mojom = "ax.mojom.AXNodeData"
+ cpp = "::ui::AXNodeData"
+ },
+ ]
+ traits_sources = [ "ax_node_data_mojom_traits.cc" ]
+ traits_headers = [ "ax_node_data_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/accessibility" ]
+ },
+ {
+ types = [
+ {
+ mojom = "ax.mojom.AXRelativeBounds"
+ cpp = "::ui::AXRelativeBounds"
+ },
+ ]
+ traits_sources = [ "ax_relative_bounds_mojom_traits.cc" ]
+ traits_headers = [ "ax_relative_bounds_mojom_traits.h" ]
+ traits_public_deps = [
+ "//ui/gfx",
+ "//ui/gfx/geometry/mojom",
+ "//ui/gfx/geometry/mojom:mojom_traits",
+ "//ui/gfx/mojom",
+ ]
+ },
+ {
+ types = [
+ {
+ mojom = "ax.mojom.AXTreeData"
+ cpp = "::ui::AXTreeData"
+ },
+ ]
+ traits_sources = [ "ax_tree_data_mojom_traits.cc" ]
+ traits_headers = [ "ax_tree_data_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/accessibility" ]
+ },
+ {
+ types = [
+ {
+ mojom = "ax.mojom.AXTreeID"
+ cpp = "::ui::AXTreeID"
+ },
+ ]
+ traits_sources = [ "ax_tree_id_mojom_traits.cc" ]
+ traits_headers = [ "ax_tree_id_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/accessibility" ]
+ },
+ {
+ types = [
+ {
+ mojom = "ax.mojom.AXTreeUpdate"
+ cpp = "::ui::AXTreeUpdate"
+ },
+ ]
+ traits_sources = [ "ax_tree_update_mojom_traits.cc" ]
+ traits_headers = [ "ax_tree_update_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/accessibility" ]
+ },
+ ]
}
diff --git a/chromium/ui/accessibility/mojom/ax_action_data.typemap b/chromium/ui/accessibility/mojom/ax_action_data.typemap
deleted file mode 100644
index 21b1d0ea869..00000000000
--- a/chromium/ui/accessibility/mojom/ax_action_data.typemap
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2018 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.
-
-mojom = "//ui/accessibility/mojom/ax_action_data.mojom"
-public_headers = [ "//ui/accessibility/ax_action_data.h" ]
-traits_headers = [ "//ui/accessibility/mojom/ax_action_data_mojom_traits.h" ]
-sources = [
- "ax_action_data_mojom_traits.cc",
- "ax_action_data_mojom_traits.h",
-]
-public_deps = [
- "//ui/accessibility",
-]
-type_mappings = [ "ax.mojom.AXActionData=::ui::AXActionData" ]
diff --git a/chromium/ui/accessibility/mojom/ax_assistant_structure.typemap b/chromium/ui/accessibility/mojom/ax_assistant_structure.typemap
deleted file mode 100644
index 4edf3b38796..00000000000
--- a/chromium/ui/accessibility/mojom/ax_assistant_structure.typemap
+++ /dev/null
@@ -1,23 +0,0 @@
-# Copyright 2018 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.
-
-mojom = "//ui/accessibility/mojom/ax_assistant_structure.mojom"
-public_headers = [ "//ui/accessibility/ax_assistant_structure.h" ]
-traits_headers =
- [ "//ui/accessibility/mojom/ax_assistant_structure_mojom_traits.h" ]
-sources = [
- "ax_assistant_structure_mojom_traits.cc",
- "ax_assistant_structure_mojom_traits.h",
-]
-public_deps = [
- "//ui/accessibility:ax_assistant",
- "//ui/gfx",
- "//ui/gfx/geometry/mojom",
- "//ui/gfx/geometry/mojom:mojom_traits",
- "//ui/gfx/range/mojom",
-]
-type_mappings = [
- "ax.mojom.AssistantTree=::std::unique_ptr<::ui::AssistantTree>[move_only,nullable_is_same_type]",
- "ax.mojom.AssistantNode=::std::unique_ptr<::ui::AssistantNode>[move_only]",
-]
diff --git a/chromium/ui/accessibility/mojom/ax_event.mojom b/chromium/ui/accessibility/mojom/ax_event.mojom
index 907f74a6bd5..857af93c03c 100644
--- a/chromium/ui/accessibility/mojom/ax_event.mojom
+++ b/chromium/ui/accessibility/mojom/ax_event.mojom
@@ -5,11 +5,13 @@
module ax.mojom;
import "ui/accessibility/ax_enums.mojom";
+import "ui/accessibility/mojom/ax_event_intent.mojom";
// See ui::AXEvent for documentation.
struct AXEvent {
Event event_type;
int32 id;
EventFrom event_from;
+ array<EventIntent> event_intents;
int32 action_request_id;
};
diff --git a/chromium/ui/accessibility/mojom/ax_event.typemap b/chromium/ui/accessibility/mojom/ax_event.typemap
deleted file mode 100644
index 538ac4468d4..00000000000
--- a/chromium/ui/accessibility/mojom/ax_event.typemap
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2018 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.
-
-mojom = "//ui/accessibility/mojom/ax_event.mojom"
-public_headers = [ "//ui/accessibility/ax_event.h" ]
-traits_headers = [ "//ui/accessibility/mojom/ax_event_mojom_traits.h" ]
-sources = [
- "ax_event_mojom_traits.cc",
- "ax_event_mojom_traits.h",
-]
-public_deps = [
- "//ui/accessibility",
-]
-type_mappings = [ "ax.mojom.AXEvent=::ui::AXEvent" ]
diff --git a/chromium/ui/accessibility/mojom/ax_event_intent.mojom b/chromium/ui/accessibility/mojom/ax_event_intent.mojom
new file mode 100644
index 00000000000..789c910182c
--- /dev/null
+++ b/chromium/ui/accessibility/mojom/ax_event_intent.mojom
@@ -0,0 +1,14 @@
+// Copyright 2020 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 ax.mojom;
+
+import "ui/accessibility/ax_enums.mojom";
+
+// See ui::AXEventIntent for documentation.
+struct EventIntent {
+ Command command;
+ TextBoundary text_boundary;
+ MoveDirection move_direction;
+};
diff --git a/chromium/ui/accessibility/mojom/ax_event_intent_mojom_traits.cc b/chromium/ui/accessibility/mojom/ax_event_intent_mojom_traits.cc
new file mode 100644
index 00000000000..9556a684d52
--- /dev/null
+++ b/chromium/ui/accessibility/mojom/ax_event_intent_mojom_traits.cc
@@ -0,0 +1,19 @@
+// Copyright 2020 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 "ui/accessibility/mojom/ax_event_intent_mojom_traits.h"
+
+namespace mojo {
+
+// static
+bool StructTraits<ax::mojom::EventIntentDataView, ui::AXEventIntent>::Read(
+ ax::mojom::EventIntentDataView data,
+ ui::AXEventIntent* out) {
+ out->command = data.command();
+ out->text_boundary = data.text_boundary();
+ out->move_direction = data.move_direction();
+ return true;
+}
+
+} // namespace mojo
diff --git a/chromium/ui/accessibility/mojom/ax_event_intent_mojom_traits.h b/chromium/ui/accessibility/mojom/ax_event_intent_mojom_traits.h
new file mode 100644
index 00000000000..614c044e1c1
--- /dev/null
+++ b/chromium/ui/accessibility/mojom/ax_event_intent_mojom_traits.h
@@ -0,0 +1,29 @@
+// Copyright 2020 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 UI_ACCESSIBILITY_MOJOM_AX_EVENT_INTENT_MOJOM_TRAITS_H_
+#define UI_ACCESSIBILITY_MOJOM_AX_EVENT_INTENT_MOJOM_TRAITS_H_
+
+#include "ui/accessibility/ax_event_intent.h"
+#include "ui/accessibility/mojom/ax_event_intent.mojom.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<ax::mojom::EventIntentDataView, ui::AXEventIntent> {
+ static ax::mojom::Command command(const ui::AXEventIntent& p) {
+ return p.command;
+ }
+ static ax::mojom::TextBoundary text_boundary(const ui::AXEventIntent& p) {
+ return p.text_boundary;
+ }
+ static ax::mojom::MoveDirection move_direction(const ui::AXEventIntent& p) {
+ return p.move_direction;
+ }
+ static bool Read(ax::mojom::EventIntentDataView data, ui::AXEventIntent* out);
+};
+
+} // namespace mojo
+
+#endif // UI_ACCESSIBILITY_MOJOM_AX_EVENT_INTENT_MOJOM_TRAITS_H_
diff --git a/chromium/ui/accessibility/mojom/ax_event_intent_mojom_traits_unittest.cc b/chromium/ui/accessibility/mojom/ax_event_intent_mojom_traits_unittest.cc
new file mode 100644
index 00000000000..6c8d62b349e
--- /dev/null
+++ b/chromium/ui/accessibility/mojom/ax_event_intent_mojom_traits_unittest.cc
@@ -0,0 +1,26 @@
+// Copyright 2020 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 "ui/accessibility/mojom/ax_event_intent_mojom_traits.h"
+
+#include "mojo/public/cpp/test_support/test_utils.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/accessibility/ax_enums.mojom.h"
+#include "ui/accessibility/ax_event_intent.h"
+#include "ui/accessibility/mojom/ax_event_intent.mojom.h"
+
+using mojo::test::SerializeAndDeserialize;
+
+TEST(AXEventIntentMojomTraitsTest, RoundTrip) {
+ ui::AXEventIntent input;
+ input.command = ax::mojom::Command::kCut;
+ input.text_boundary = ax::mojom::TextBoundary::kWordEnd;
+ input.move_direction = ax::mojom::MoveDirection::kForward;
+
+ ui::AXEventIntent output;
+ EXPECT_TRUE(SerializeAndDeserialize<ax::mojom::EventIntent>(&input, &output));
+ EXPECT_EQ(ax::mojom::Command::kCut, output.command);
+ EXPECT_EQ(ax::mojom::TextBoundary::kWordEnd, output.text_boundary);
+ EXPECT_EQ(ax::mojom::MoveDirection::kForward, output.move_direction);
+}
diff --git a/chromium/ui/accessibility/mojom/ax_event_mojom_traits.cc b/chromium/ui/accessibility/mojom/ax_event_mojom_traits.cc
index 8196678832f..1b927eab4a6 100644
--- a/chromium/ui/accessibility/mojom/ax_event_mojom_traits.cc
+++ b/chromium/ui/accessibility/mojom/ax_event_mojom_traits.cc
@@ -14,7 +14,7 @@ bool StructTraits<ax::mojom::AXEventDataView, ui::AXEvent>::Read(
out->id = data.id();
out->event_from = data.event_from();
out->action_request_id = data.action_request_id();
- return true;
+ return data.ReadEventIntents(&out->event_intents);
}
} // namespace mojo
diff --git a/chromium/ui/accessibility/mojom/ax_event_mojom_traits.h b/chromium/ui/accessibility/mojom/ax_event_mojom_traits.h
index 62150c391d6..c1922345251 100644
--- a/chromium/ui/accessibility/mojom/ax_event_mojom_traits.h
+++ b/chromium/ui/accessibility/mojom/ax_event_mojom_traits.h
@@ -5,8 +5,13 @@
#ifndef UI_ACCESSIBILITY_MOJOM_AX_EVENT_MOJOM_TRAITS_H_
#define UI_ACCESSIBILITY_MOJOM_AX_EVENT_MOJOM_TRAITS_H_
+#include <vector>
+
#include "ui/accessibility/ax_event.h"
-#include "ui/accessibility/mojom/ax_event.mojom-shared.h"
+#include "ui/accessibility/ax_event_intent.h"
+#include "ui/accessibility/mojom/ax_event.mojom.h"
+#include "ui/accessibility/mojom/ax_event_intent.mojom.h"
+#include "ui/accessibility/mojom/ax_event_intent_mojom_traits.h"
namespace mojo {
@@ -19,6 +24,9 @@ struct StructTraits<ax::mojom::AXEventDataView, ui::AXEvent> {
static ax::mojom::EventFrom event_from(const ui::AXEvent& p) {
return p.event_from;
}
+ static std::vector<ui::AXEventIntent> event_intents(const ui::AXEvent& p) {
+ return p.event_intents;
+ }
static int32_t action_request_id(const ui::AXEvent& p) {
return p.action_request_id;
}
diff --git a/chromium/ui/accessibility/mojom/ax_event_mojom_traits_unittest.cc b/chromium/ui/accessibility/mojom/ax_event_mojom_traits_unittest.cc
index ac2197b57a8..ba5657cc8d3 100644
--- a/chromium/ui/accessibility/mojom/ax_event_mojom_traits_unittest.cc
+++ b/chromium/ui/accessibility/mojom/ax_event_mojom_traits_unittest.cc
@@ -4,23 +4,37 @@
#include "ui/accessibility/mojom/ax_event_mojom_traits.h"
+#include <vector>
+
#include "mojo/public/cpp/test_support/test_utils.h"
+#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_event.h"
+#include "ui/accessibility/ax_event_intent.h"
#include "ui/accessibility/mojom/ax_event.mojom.h"
+#include "ui/accessibility/mojom/ax_event_intent.mojom.h"
using mojo::test::SerializeAndDeserialize;
TEST(AXEventMojomTraitsTest, RoundTrip) {
ui::AXEvent input;
- input.event_type = ax::mojom::Event::kFocus;
+ input.event_type = ax::mojom::Event::kTextChanged;
input.id = 111;
input.event_from = ax::mojom::EventFrom::kUser;
+ ui::AXEventIntent cut_intent;
+ cut_intent.command = ax::mojom::Command::kCut;
+ cut_intent.text_boundary = ax::mojom::TextBoundary::kWordEnd;
+ cut_intent.move_direction = ax::mojom::MoveDirection::kForward;
+ const std::vector<ui::AXEventIntent> event_intents{cut_intent};
+ input.event_intents = event_intents;
input.action_request_id = 222;
+
ui::AXEvent output;
EXPECT_TRUE(SerializeAndDeserialize<ax::mojom::AXEvent>(&input, &output));
- EXPECT_EQ(ax::mojom::Event::kFocus, output.event_type);
+ EXPECT_EQ(ax::mojom::Event::kTextChanged, output.event_type);
EXPECT_EQ(111, output.id);
EXPECT_EQ(ax::mojom::EventFrom::kUser, output.event_from);
+ EXPECT_THAT(output.event_intents, testing::ContainerEq(event_intents));
EXPECT_EQ(222, output.action_request_id);
}
diff --git a/chromium/ui/accessibility/mojom/ax_node_data.typemap b/chromium/ui/accessibility/mojom/ax_node_data.typemap
deleted file mode 100644
index bd80084fdcf..00000000000
--- a/chromium/ui/accessibility/mojom/ax_node_data.typemap
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2018 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.
-
-mojom = "//ui/accessibility/mojom/ax_node_data.mojom"
-public_headers = [ "//ui/accessibility/ax_node_data.h" ]
-traits_headers = [ "//ui/accessibility/mojom/ax_node_data_mojom_traits.h" ]
-sources = [
- "ax_node_data_mojom_traits.cc",
- "ax_node_data_mojom_traits.h",
-]
-public_deps = [
- "//ui/accessibility",
-]
-type_mappings = [ "ax.mojom.AXNodeData=::ui::AXNodeData" ]
diff --git a/chromium/ui/accessibility/mojom/ax_relative_bounds.typemap b/chromium/ui/accessibility/mojom/ax_relative_bounds.typemap
deleted file mode 100644
index 93f3206c515..00000000000
--- a/chromium/ui/accessibility/mojom/ax_relative_bounds.typemap
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2018 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.
-
-mojom = "//ui/accessibility/mojom/ax_relative_bounds.mojom"
-public_headers = [ "//ui/accessibility/ax_relative_bounds.h" ]
-traits_headers =
- [ "//ui/accessibility/mojom/ax_relative_bounds_mojom_traits.h" ]
-sources = [
- "ax_relative_bounds_mojom_traits.cc",
- "ax_relative_bounds_mojom_traits.h",
-]
-public_deps = [
- "//ui/gfx",
- "//ui/gfx/geometry/mojom",
- "//ui/gfx/geometry/mojom:mojom_traits",
- "//ui/gfx/mojom",
-]
-type_mappings = [ "ax.mojom.AXRelativeBounds=::ui::AXRelativeBounds" ]
diff --git a/chromium/ui/accessibility/mojom/ax_tree_data.typemap b/chromium/ui/accessibility/mojom/ax_tree_data.typemap
deleted file mode 100644
index 218530f8c3f..00000000000
--- a/chromium/ui/accessibility/mojom/ax_tree_data.typemap
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2018 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.
-
-mojom = "//ui/accessibility/mojom/ax_tree_data.mojom"
-public_headers = [ "//ui/accessibility/ax_tree_data.h" ]
-traits_headers = [ "//ui/accessibility/mojom/ax_tree_data_mojom_traits.h" ]
-sources = [
- "ax_tree_data_mojom_traits.cc",
- "ax_tree_data_mojom_traits.h",
-]
-public_deps = [
- "//ui/accessibility",
-]
-type_mappings = [ "ax.mojom.AXTreeData=::ui::AXTreeData" ]
diff --git a/chromium/ui/accessibility/mojom/ax_tree_id.typemap b/chromium/ui/accessibility/mojom/ax_tree_id.typemap
deleted file mode 100644
index b54728211d8..00000000000
--- a/chromium/ui/accessibility/mojom/ax_tree_id.typemap
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2018 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.
-
-mojom = "//ui/accessibility/mojom/ax_tree_id.mojom"
-public_headers = [ "//ui/accessibility/ax_tree_id.h" ]
-traits_headers = [ "//ui/accessibility/mojom/ax_tree_id_mojom_traits.h" ]
-sources = [
- "ax_tree_id_mojom_traits.cc",
- "ax_tree_id_mojom_traits.h",
-]
-public_deps = [
- "//ui/accessibility",
-]
-type_mappings = [ "ax.mojom.AXTreeID=::ui::AXTreeID" ]
diff --git a/chromium/ui/accessibility/mojom/ax_tree_update.typemap b/chromium/ui/accessibility/mojom/ax_tree_update.typemap
deleted file mode 100644
index 8423c2033c1..00000000000
--- a/chromium/ui/accessibility/mojom/ax_tree_update.typemap
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2018 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.
-
-mojom = "//ui/accessibility/mojom/ax_tree_update.mojom"
-public_headers = [ "//ui/accessibility/ax_tree_update.h" ]
-traits_headers = [ "//ui/accessibility/mojom/ax_tree_update_mojom_traits.h" ]
-sources = [
- "ax_tree_update_mojom_traits.cc",
- "ax_tree_update_mojom_traits.h",
-]
-public_deps = [
- "//ui/accessibility",
-]
-type_mappings = [ "ax.mojom.AXTreeUpdate=::ui::AXTreeUpdate" ]
diff --git a/chromium/ui/accessibility/mojom/typemaps.gni b/chromium/ui/accessibility/mojom/typemaps.gni
deleted file mode 100644
index 6095574abeb..00000000000
--- a/chromium/ui/accessibility/mojom/typemaps.gni
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2018 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.
-
-typemaps = [
- "//ui/accessibility/mojom/ax_action_data.typemap",
- "//ui/accessibility/mojom/ax_assistant_structure.typemap",
- "//ui/accessibility/mojom/ax_event.typemap",
- "//ui/accessibility/mojom/ax_node_data.typemap",
- "//ui/accessibility/mojom/ax_relative_bounds.typemap",
- "//ui/accessibility/mojom/ax_tree_data.typemap",
- "//ui/accessibility/mojom/ax_tree_id.typemap",
- "//ui/accessibility/mojom/ax_tree_update.typemap",
-]
diff --git a/chromium/ui/accessibility/platform/atk_util_auralinux.h b/chromium/ui/accessibility/platform/atk_util_auralinux.h
index c9db59d473a..c38fb53617e 100644
--- a/chromium/ui/accessibility/platform/atk_util_auralinux.h
+++ b/chromium/ui/accessibility/platform/atk_util_auralinux.h
@@ -11,10 +11,6 @@
#include "base/memory/singleton.h"
#include "ui/accessibility/ax_export.h"
-#if defined(USE_X11)
-#include "ui/gfx/x/x11.h"
-#endif
-
namespace ui {
// These values are duplicates of the GDK values that can be found in
diff --git a/chromium/ui/accessibility/platform/ax_fragment_root_win.cc b/chromium/ui/accessibility/platform/ax_fragment_root_win.cc
index c427658a023..f1925832840 100644
--- a/chromium/ui/accessibility/platform/ax_fragment_root_win.cc
+++ b/chromium/ui/accessibility/platform/ax_fragment_root_win.cc
@@ -204,8 +204,12 @@ class AXFragmentRootMapWin {
void RemoveFragmentRoot(gfx::AcceleratedWidget widget) { map_.erase(widget); }
- ui::AXFragmentRootWin* GetFragmentRoot(gfx::AcceleratedWidget widget) {
- return map_[widget];
+ ui::AXFragmentRootWin* GetFragmentRoot(gfx::AcceleratedWidget widget) const {
+ const auto& entry = map_.find(widget);
+ if (entry != map_.end())
+ return entry->second;
+
+ return nullptr;
}
ui::AXFragmentRootWin* GetFragmentRootParentOf(
diff --git a/chromium/ui/accessibility/platform/ax_fragment_root_win_unittest.cc b/chromium/ui/accessibility/platform/ax_fragment_root_win_unittest.cc
index 905fefaa2f5..7691d12cece 100644
--- a/chromium/ui/accessibility/platform/ax_fragment_root_win_unittest.cc
+++ b/chromium/ui/accessibility/platform/ax_fragment_root_win_unittest.cc
@@ -430,4 +430,34 @@ TEST_F(AXFragmentRootTest, TestUIAMultipleFragmentRoots) {
test_fragment.Get());
}
+TEST_F(AXFragmentRootTest, TestFragmentRootMap) {
+ AXNodeData root;
+ Init(root);
+
+ // There should be nothing in the map before we create a fragment root.
+ // Call GetForAcceleratedWidget() first to ensure that querying for a
+ // fragment root doesn't inadvertently create an empty entry in the map
+ // (https://crbug.com/1071185).
+ EXPECT_EQ(nullptr, AXFragmentRootWin::GetForAcceleratedWidget(
+ gfx::kMockAcceleratedWidget));
+ EXPECT_EQ(nullptr, AXFragmentRootWin::GetFragmentRootParentOf(
+ GetRootIAccessible().Get()));
+
+ // After initializing a fragment root, we should be able to retrieve it using
+ // its accelerated widget, or as the parent of its child.
+ InitFragmentRoot();
+ EXPECT_EQ(ax_fragment_root_.get(), AXFragmentRootWin::GetForAcceleratedWidget(
+ gfx::kMockAcceleratedWidget));
+ EXPECT_EQ(ax_fragment_root_.get(), AXFragmentRootWin::GetFragmentRootParentOf(
+ GetRootIAccessible().Get()));
+
+ // After deleting a fragment root, it should no longer be reachable from the
+ // map.
+ ax_fragment_root_.reset();
+ EXPECT_EQ(nullptr, AXFragmentRootWin::GetForAcceleratedWidget(
+ gfx::kMockAcceleratedWidget));
+ EXPECT_EQ(nullptr, AXFragmentRootWin::GetFragmentRootParentOf(
+ GetRootIAccessible().Get()));
+}
+
} // namespace ui
diff --git a/chromium/ui/accessibility/platform/ax_platform_atk_hyperlink.cc b/chromium/ui/accessibility/platform/ax_platform_atk_hyperlink.cc
index e59b7c3a2d7..be91def6b40 100644
--- a/chromium/ui/accessibility/platform/ax_platform_atk_hyperlink.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_atk_hyperlink.cc
@@ -4,7 +4,10 @@
#include "ui/accessibility/platform/ax_platform_atk_hyperlink.h"
-#include "ui/accessibility/ax_text_utils.h"
+#include <string>
+#include <utility>
+
+#include "ui/accessibility/ax_enum_util.h"
#include "ui/accessibility/platform/ax_platform_node_auralinux.h"
#include "ui/accessibility/platform/ax_platform_node_delegate.h"
@@ -192,9 +195,9 @@ static const gchar* ax_platform_atk_hyperlink_get_name(AtkAction* atk_action,
if (!obj->GetIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb,
&action))
return nullptr;
- base::string16 action_verb = ui::ActionVerbToUnlocalizedString(
- static_cast<ax::mojom::DefaultActionVerb>(action));
- ATK_AURALINUX_RETURN_STRING(base::UTF16ToUTF8(action_verb));
+ std::string action_verb =
+ ui::ToString(static_cast<ax::mojom::DefaultActionVerb>(action));
+ ATK_AURALINUX_RETURN_STRING(action_verb);
}
static const gchar* ax_platform_atk_hyperlink_get_localized_name(
@@ -212,9 +215,9 @@ static const gchar* ax_platform_atk_hyperlink_get_localized_name(
if (!obj->GetIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb,
&action))
return nullptr;
- base::string16 action_verb = ui::ActionVerbToLocalizedString(
- static_cast<ax::mojom::DefaultActionVerb>(action));
- ATK_AURALINUX_RETURN_STRING(base::UTF16ToUTF8(action_verb));
+ std::string action_verb =
+ ui::ToLocalizedString(static_cast<ax::mojom::DefaultActionVerb>(action));
+ ATK_AURALINUX_RETURN_STRING(action_verb);
}
static void atk_action_interface_init(AtkActionIface* iface) {
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_auralinux.cc b/chromium/ui/accessibility/platform/ax_platform_node_auralinux.cc
index 773ca872f48..89309020096 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_auralinux.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node_auralinux.cc
@@ -28,11 +28,11 @@
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "ui/accessibility/ax_action_data.h"
+#include "ui/accessibility/ax_enum_util.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_mode_observer.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/ax_role_properties.h"
-#include "ui/accessibility/ax_text_utils.h"
#include "ui/accessibility/ax_tree_data.h"
#include "ui/accessibility/platform/atk_util_auralinux.h"
#include "ui/accessibility/platform/ax_platform_atk_hyperlink.h"
@@ -177,20 +177,6 @@ static GetColumnHeaderCellsFunc g_atk_table_cell_get_column_header_cells;
static GetRowHeaderCellsFunc g_atk_table_cell_get_row_header_cells;
static GetRowColumnSpanFunc g_atk_table_cell_get_row_column_span;
-AXPlatformNodeAuraLinux* AtkObjectToAXPlatformNodeAuraLinux(
- AtkObject* atk_object) {
- if (!atk_object)
- return nullptr;
-
- if (IS_AX_PLATFORM_NODE_AURALINUX(atk_object)) {
- AXPlatformNodeAuraLinuxObject* platform_object =
- AX_PLATFORM_NODE_AURALINUX(atk_object);
- return platform_object->m_object;
- }
-
- return nullptr;
-}
-
// The ATK API often requires pointers to be used as out arguments, while
// allowing for those pointers to be null if the caller is not interested in
// the value. This function is a simpler helper to avoid continually checking
@@ -210,23 +196,23 @@ bool SupportsAtkTextScrollingInterface() {
AtkObject* FindAtkObjectParentFrame(AtkObject* atk_object) {
AXPlatformNodeAuraLinux* node =
- AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
while (node) {
if (node->GetAtkRole() == ATK_ROLE_FRAME)
return node->GetNativeViewAccessible();
- node = AtkObjectToAXPlatformNodeAuraLinux(node->GetParent());
+ node = AXPlatformNodeAuraLinux::FromAtkObject(node->GetParent());
}
return nullptr;
}
AtkObject* FindAtkObjectToplevelParentDocument(AtkObject* atk_object) {
AXPlatformNodeAuraLinux* node =
- AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
AtkObject* toplevel_document = nullptr;
while (node) {
if (node->GetAtkRole() == ATK_ROLE_DOCUMENT_WEB)
toplevel_document = node->GetNativeViewAccessible();
- node = AtkObjectToAXPlatformNodeAuraLinux(node->GetParent());
+ node = AXPlatformNodeAuraLinux::FromAtkObject(node->GetParent());
}
return toplevel_document;
}
@@ -237,7 +223,7 @@ bool IsFrameAncestorOfAtkObject(AtkObject* frame, AtkObject* atk_object) {
if (current_frame == frame)
return true;
AXPlatformNodeAuraLinux* frame_node =
- AtkObjectToAXPlatformNodeAuraLinux(current_frame);
+ AXPlatformNodeAuraLinux::FromAtkObject(current_frame);
current_frame = FindAtkObjectParentFrame(frame_node->GetParent());
}
return false;
@@ -345,7 +331,7 @@ gfx::Point FindAtkObjectParentCoords(AtkObject* atk_object) {
return gfx::Point(0, 0);
AXPlatformNodeAuraLinux* node =
- AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (node->GetAtkRole() == ATK_ROLE_FRAME) {
int x, y;
atk_component_get_extents(ATK_COMPONENT(atk_object), &x, &y, nullptr,
@@ -373,7 +359,7 @@ AtkObject* GetActiveDescendantOfCurrentFocused() {
if (!g_current_focused)
return nullptr;
- auto* node = AtkObjectToAXPlatformNodeAuraLinux(g_current_focused);
+ auto* node = AXPlatformNodeAuraLinux::FromAtkObject(g_current_focused);
if (!node)
return nullptr;
@@ -482,7 +468,8 @@ void GetExtents(AtkComponent* atk_component,
*height = 0;
AtkObject* atk_object = ATK_OBJECT(atk_component);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return;
@@ -501,7 +488,8 @@ void GetPosition(AtkComponent* atk_component,
*y = 0;
AtkObject* atk_object = ATK_OBJECT(atk_component);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return;
@@ -517,7 +505,8 @@ void GetSize(AtkComponent* atk_component, gint* width, gint* height) {
*height = 0;
AtkObject* atk_object = ATK_OBJECT(atk_component);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return;
@@ -530,7 +519,8 @@ AtkObject* RefAccesibleAtPoint(AtkComponent* atk_component,
AtkCoordType coord_type) {
g_return_val_if_fail(ATK_IS_COMPONENT(atk_component), nullptr);
AtkObject* atk_object = ATK_OBJECT(atk_component);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
@@ -543,7 +533,8 @@ AtkObject* RefAccesibleAtPoint(AtkComponent* atk_component,
gboolean GrabFocus(AtkComponent* atk_component) {
g_return_val_if_fail(ATK_IS_COMPONENT(atk_component), FALSE);
AtkObject* atk_object = ATK_OBJECT(atk_component);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return FALSE;
@@ -555,7 +546,7 @@ gboolean ScrollTo(AtkComponent* atk_component, AtkScrollType scroll_type) {
g_return_val_if_fail(ATK_IS_COMPONENT(atk_component), FALSE);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(atk_component));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_component));
if (!obj)
return FALSE;
@@ -570,7 +561,7 @@ gboolean ScrollToPoint(AtkComponent* atk_component,
g_return_val_if_fail(ATK_IS_COMPONENT(atk_component), FALSE);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(atk_component));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_component));
if (!obj)
return FALSE;
@@ -605,7 +596,8 @@ gboolean DoAction(AtkAction* atk_action, gint index) {
g_return_val_if_fail(!index, FALSE);
AtkObject* atk_object = ATK_OBJECT(atk_action);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return FALSE;
@@ -616,7 +608,8 @@ gint GetNActions(AtkAction* atk_action) {
g_return_val_if_fail(ATK_IS_ACTION(atk_action), 0);
AtkObject* atk_object = ATK_OBJECT(atk_action);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return 0;
@@ -634,7 +627,8 @@ const gchar* GetName(AtkAction* atk_action, gint index) {
g_return_val_if_fail(!index, nullptr);
AtkObject* atk_object = ATK_OBJECT(atk_action);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
@@ -646,7 +640,8 @@ const gchar* GetKeybinding(AtkAction* atk_action, gint index) {
g_return_val_if_fail(!index, nullptr);
AtkObject* atk_object = ATK_OBJECT(atk_action);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
@@ -674,7 +669,8 @@ const gchar* GetDocumentAttributeValue(AtkDocument* atk_doc,
g_return_val_if_fail(ATK_IS_DOCUMENT(atk_doc), nullptr);
AtkObject* atk_object = ATK_OBJECT(atk_doc);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
@@ -685,7 +681,8 @@ AtkAttributeSet* GetDocumentAttributes(AtkDocument* atk_doc) {
g_return_val_if_fail(ATK_IS_DOCUMENT(atk_doc), 0);
AtkObject* atk_object = ATK_OBJECT(atk_doc);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
@@ -711,7 +708,8 @@ void GetImagePosition(AtkImage* atk_img,
g_return_if_fail(ATK_IMAGE(atk_img));
AtkObject* atk_object = ATK_OBJECT(atk_img);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return;
@@ -722,7 +720,8 @@ const gchar* GetImageDescription(AtkImage* atk_img) {
g_return_val_if_fail(ATK_IMAGE(atk_img), nullptr);
AtkObject* atk_object = ATK_OBJECT(atk_img);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
@@ -734,7 +733,8 @@ void GetImageSize(AtkImage* atk_img, gint* width, gint* height) {
g_return_if_fail(ATK_IMAGE(atk_img));
AtkObject* atk_object = ATK_OBJECT(atk_img);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return;
@@ -758,7 +758,8 @@ void GetCurrentValue(AtkValue* atk_value, GValue* value) {
g_return_if_fail(ATK_IS_VALUE(atk_value));
AtkObject* atk_object = ATK_OBJECT(atk_value);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return;
@@ -770,7 +771,8 @@ void GetMinimumValue(AtkValue* atk_value, GValue* value) {
g_return_if_fail(ATK_IS_VALUE(atk_value));
AtkObject* atk_object = ATK_OBJECT(atk_value);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return;
@@ -782,7 +784,8 @@ void GetMaximumValue(AtkValue* atk_value, GValue* value) {
g_return_if_fail(ATK_IS_VALUE(atk_value));
AtkObject* atk_object = ATK_OBJECT(atk_value);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return;
@@ -794,7 +797,8 @@ void GetMinimumIncrement(AtkValue* atk_value, GValue* value) {
g_return_if_fail(ATK_IS_VALUE(atk_value));
AtkObject* atk_object = ATK_OBJECT(atk_value);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return;
@@ -806,7 +810,8 @@ gboolean SetCurrentValue(AtkValue* atk_value, const GValue* value) {
g_return_val_if_fail(ATK_IS_VALUE(atk_value), FALSE);
AtkObject* atk_object = ATK_OBJECT(atk_value);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return FALSE;
@@ -854,7 +859,8 @@ AtkHyperlink* GetHyperlink(AtkHyperlinkImpl* atk_hyperlink_impl) {
g_return_val_if_fail(ATK_HYPERLINK_IMPL(atk_hyperlink_impl), 0);
AtkObject* atk_object = ATK_OBJECT(atk_hyperlink_impl);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return 0;
@@ -877,7 +883,7 @@ namespace atk_hypertext {
AtkHyperlink* GetLink(AtkHypertext* hypertext, int index) {
g_return_val_if_fail(ATK_HYPERTEXT(hypertext), 0);
- auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(hypertext));
+ auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(hypertext));
if (!obj)
return nullptr;
@@ -897,14 +903,14 @@ AtkHyperlink* GetLink(AtkHypertext* hypertext, int index) {
int GetNLinks(AtkHypertext* hypertext) {
g_return_val_if_fail(ATK_HYPERTEXT(hypertext), 0);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(hypertext));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(hypertext));
return obj ? obj->GetAXHypertext().hyperlinks.size() : 0;
}
int GetLinkIndex(AtkHypertext* hypertext, int char_index) {
g_return_val_if_fail(ATK_HYPERTEXT(hypertext), 0);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(hypertext));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(hypertext));
if (!obj)
return -1;
@@ -931,7 +937,8 @@ gchar* GetText(AtkText* atk_text, gint start_offset, gint end_offset) {
g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
AtkObject* atk_object = ATK_OBJECT(atk_text);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
@@ -960,7 +967,8 @@ gint GetCharacterCount(AtkText* atk_text) {
g_return_val_if_fail(ATK_IS_TEXT(atk_text), 0);
AtkObject* atk_object = ATK_OBJECT(atk_text);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return 0;
@@ -971,7 +979,8 @@ gunichar GetCharacterAtOffset(AtkText* atk_text, int offset) {
g_return_val_if_fail(ATK_IS_TEXT(atk_text), 0);
AtkObject* atk_object = ATK_OBJECT(atk_text);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return 0;
@@ -999,7 +1008,8 @@ char* GetCharacter(AtkText* atk_text,
*end_offset = -1;
AtkObject* atk_object = ATK_OBJECT(atk_text);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
@@ -1023,7 +1033,8 @@ char* GetTextWithBoundaryType(AtkText* atk_text,
g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
AtkObject* atk_object = ATK_OBJECT(atk_text);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
@@ -1116,7 +1127,7 @@ gint GetCaretOffset(AtkText* atk_text) {
g_return_val_if_fail(ATK_IS_TEXT(atk_text), -1);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(atk_text));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
if (!obj)
return -1;
return obj->GetCaretOffset();
@@ -1126,7 +1137,7 @@ gboolean SetCaretOffset(AtkText* atk_text, gint offset) {
g_return_val_if_fail(ATK_IS_TEXT(atk_text), FALSE);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(atk_text));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
if (!obj)
return FALSE;
if (!obj->SetCaretOffset(offset))
@@ -1145,7 +1156,7 @@ int GetNSelections(AtkText* atk_text) {
g_return_val_if_fail(ATK_IS_TEXT(atk_text), 0);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(atk_text));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
if (!obj)
return 0;
@@ -1167,7 +1178,7 @@ gchar* GetSelection(AtkText* atk_text,
g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(atk_text));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
if (!obj)
return nullptr;
if (selection_num != 0)
@@ -1183,7 +1194,7 @@ gboolean RemoveSelection(AtkText* atk_text, int selection_num) {
return FALSE;
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(atk_text));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
if (!obj)
return FALSE;
@@ -1204,7 +1215,7 @@ gboolean SetSelection(AtkText* atk_text,
return FALSE;
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(atk_text));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
if (!obj)
return FALSE;
@@ -1270,7 +1281,7 @@ void GetCharacterExtents(AtkText* atk_text,
gfx::Rect rect;
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(atk_text));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
if (obj) {
switch (coordinate_type) {
#if defined(ATK_230)
@@ -1311,7 +1322,7 @@ void GetRangeExtents(AtkText* atk_text,
gfx::Rect rect;
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(atk_text));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
if (obj) {
switch (coordinate_type) {
#if defined(ATK_230)
@@ -1349,7 +1360,8 @@ AtkAttributeSet* GetRunAttributes(AtkText* atk_text,
return nullptr;
AtkObject* atk_object = ATK_OBJECT(atk_text);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
@@ -1361,7 +1373,8 @@ AtkAttributeSet* GetDefaultAttributes(AtkText* atk_text) {
g_return_val_if_fail(ATK_IS_TEXT(atk_text), nullptr);
AtkObject* atk_object = ATK_OBJECT(atk_text);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
return ToAtkAttributeSet(obj->GetDefaultTextAttributes());
@@ -1375,7 +1388,7 @@ gboolean ScrollSubstringTo(AtkText* atk_text,
g_return_val_if_fail(ATK_IS_TEXT(atk_text), FALSE);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(atk_text));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
if (!obj)
return FALSE;
@@ -1391,7 +1404,7 @@ gboolean ScrollSubstringToPoint(AtkText* atk_text,
g_return_val_if_fail(ATK_IS_TEXT(atk_text), FALSE);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(atk_text));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(atk_text));
if (!obj)
return FALSE;
@@ -1449,14 +1462,14 @@ gboolean AddSelection(AtkSelection* selection, gint index) {
g_return_val_if_fail(ATK_IS_SELECTION(selection), FALSE);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(selection));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
if (!obj)
return FALSE;
if (index < 0 || index >= obj->GetChildCount())
return FALSE;
AXPlatformNodeAuraLinux* child =
- AtkObjectToAXPlatformNodeAuraLinux(obj->ChildAtIndex(index));
+ AXPlatformNodeAuraLinux::FromAtkObject(obj->ChildAtIndex(index));
if (!child)
return FALSE;
@@ -1476,7 +1489,7 @@ gboolean ClearSelection(AtkSelection* selection) {
g_return_val_if_fail(ATK_IS_SELECTION(selection), FALSE);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(selection));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
if (!obj)
return FALSE;
@@ -1484,7 +1497,7 @@ gboolean ClearSelection(AtkSelection* selection) {
bool success = true;
for (int i = 0; i < child_count; ++i) {
AXPlatformNodeAuraLinux* child =
- AtkObjectToAXPlatformNodeAuraLinux(obj->ChildAtIndex(i));
+ AXPlatformNodeAuraLinux::FromAtkObject(obj->ChildAtIndex(i));
if (!child)
continue;
@@ -1508,23 +1521,14 @@ AtkObject* RefSelection(AtkSelection* selection, gint requested_child_index) {
g_return_val_if_fail(ATK_IS_SELECTION(selection), nullptr);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(selection));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
if (!obj)
return nullptr;
- int child_count = obj->GetChildCount();
- gint selected_count = 0;
- for (int i = 0; i < child_count; ++i) {
- AtkObject* child = obj->ChildAtIndex(i);
- AXPlatformNodeAuraLinux* child_ax_node =
- AtkObjectToAXPlatformNodeAuraLinux(child);
- if (!child_ax_node)
- continue;
-
- if (child_ax_node->GetBoolAttribute(ax::mojom::BoolAttribute::kSelected)) {
- if (selected_count == requested_child_index)
- return static_cast<AtkObject*>(g_object_ref(child));
- ++selected_count;
+ if (auto* selected_child = obj->GetSelectedItem(requested_child_index)) {
+ if (AtkObject* atk_object = selected_child->GetNativeViewAccessible()) {
+ g_object_ref(atk_object);
+ return atk_object;
}
}
@@ -1535,37 +1539,25 @@ gint GetSelectionCount(AtkSelection* selection) {
g_return_val_if_fail(ATK_IS_SELECTION(selection), 0);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(selection));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
if (!obj)
return 0;
- int child_count = obj->GetChildCount();
- gint selected_count = 0;
- for (int i = 0; i < child_count; ++i) {
- AXPlatformNodeAuraLinux* child =
- AtkObjectToAXPlatformNodeAuraLinux(obj->ChildAtIndex(i));
- if (!child)
- continue;
-
- if (child->GetBoolAttribute(ax::mojom::BoolAttribute::kSelected))
- ++selected_count;
- }
-
- return selected_count;
+ return obj->GetSelectionCount();
}
gboolean IsChildSelected(AtkSelection* selection, gint index) {
g_return_val_if_fail(ATK_IS_SELECTION(selection), FALSE);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(selection));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
if (!obj)
return FALSE;
if (index < 0 || index >= obj->GetChildCount())
return FALSE;
AXPlatformNodeAuraLinux* child =
- AtkObjectToAXPlatformNodeAuraLinux(obj->ChildAtIndex(index));
+ AXPlatformNodeAuraLinux::FromAtkObject(obj->ChildAtIndex(index));
return child && child->GetBoolAttribute(ax::mojom::BoolAttribute::kSelected);
}
@@ -1574,14 +1566,14 @@ gboolean RemoveSelection(AtkSelection* selection,
g_return_val_if_fail(ATK_IS_SELECTION(selection), FALSE);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(selection));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
if (!obj)
return FALSE;
int child_count = obj->GetChildCount();
for (int i = 0; i < child_count; ++i) {
AXPlatformNodeAuraLinux* child =
- AtkObjectToAXPlatformNodeAuraLinux(obj->ChildAtIndex(i));
+ AXPlatformNodeAuraLinux::FromAtkObject(obj->ChildAtIndex(i));
if (!child)
continue;
@@ -1606,7 +1598,7 @@ gboolean SelectAllSelection(AtkSelection* selection) {
g_return_val_if_fail(ATK_IS_SELECTION(selection), FALSE);
AXPlatformNodeAuraLinux* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(selection));
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(selection));
if (!obj)
return FALSE;
@@ -1614,7 +1606,7 @@ gboolean SelectAllSelection(AtkSelection* selection) {
bool success = true;
for (int i = 0; i < child_count; ++i) {
AXPlatformNodeAuraLinux* child =
- AtkObjectToAXPlatformNodeAuraLinux(obj->ChildAtIndex(i));
+ AXPlatformNodeAuraLinux::FromAtkObject(obj->ChildAtIndex(i));
if (!child)
continue;
@@ -1654,7 +1646,7 @@ namespace atk_table {
AtkObject* RefAt(AtkTable* table, gint row, gint column) {
g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
- if (auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(table))) {
+ if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
if (AXPlatformNodeBase* cell = obj->GetTableCell(row, column)) {
if (AtkObject* atk_cell = cell->GetNativeViewAccessible()) {
g_object_ref(atk_cell);
@@ -1669,7 +1661,7 @@ AtkObject* RefAt(AtkTable* table, gint row, gint column) {
gint GetIndexAt(AtkTable* table, gint row, gint column) {
g_return_val_if_fail(ATK_IS_TABLE(table), -1);
- if (auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(table))) {
+ if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
if (const AXPlatformNodeBase* cell = obj->GetTableCell(row, column)) {
DCHECK(cell->GetTableCellIndex().has_value());
return cell->GetTableCellIndex().value();
@@ -1682,7 +1674,7 @@ gint GetIndexAt(AtkTable* table, gint row, gint column) {
gint GetColumnAtIndex(AtkTable* table, gint index) {
g_return_val_if_fail(ATK_IS_TABLE(table), -1);
- if (auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(table))) {
+ if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
if (const AXPlatformNodeBase* cell = obj->GetTableCell(index)) {
DCHECK(cell->GetTableColumn().has_value());
return cell->GetTableColumn().value();
@@ -1695,7 +1687,7 @@ gint GetColumnAtIndex(AtkTable* table, gint index) {
gint GetRowAtIndex(AtkTable* table, gint index) {
g_return_val_if_fail(ATK_IS_TABLE(table), -1);
- if (auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(table))) {
+ if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
if (const AXPlatformNodeBase* cell = obj->GetTableCell(index)) {
DCHECK(cell->GetTableRow().has_value());
return cell->GetTableRow().value();
@@ -1708,7 +1700,7 @@ gint GetRowAtIndex(AtkTable* table, gint index) {
gint GetNColumns(AtkTable* table) {
g_return_val_if_fail(ATK_IS_TABLE(table), 0);
- if (auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(table))) {
+ if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
// If the object is not a table, we return 0.
return obj->GetTableColumnCount().value_or(0);
}
@@ -1719,7 +1711,7 @@ gint GetNColumns(AtkTable* table) {
gint GetNRows(AtkTable* table) {
g_return_val_if_fail(ATK_IS_TABLE(table), 0);
- if (auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(table))) {
+ if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
// If the object is not a table, we return 0.
return obj->GetTableRowCount().value_or(0);
}
@@ -1730,7 +1722,7 @@ gint GetNRows(AtkTable* table) {
gint GetColumnExtentAt(AtkTable* table, gint row, gint column) {
g_return_val_if_fail(ATK_IS_TABLE(table), 0);
- if (auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(table))) {
+ if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
if (const AXPlatformNodeBase* cell = obj->GetTableCell(row, column)) {
DCHECK(cell->GetTableColumnSpan().has_value());
return cell->GetTableColumnSpan().value();
@@ -1743,7 +1735,7 @@ gint GetColumnExtentAt(AtkTable* table, gint row, gint column) {
gint GetRowExtentAt(AtkTable* table, gint row, gint column) {
g_return_val_if_fail(ATK_IS_TABLE(table), 0);
- if (auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(table))) {
+ if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
if (const AXPlatformNodeBase* cell = obj->GetTableCell(row, column)) {
DCHECK(cell->GetTableRowSpan().has_value());
return cell->GetTableRowSpan().value();
@@ -1756,7 +1748,7 @@ gint GetRowExtentAt(AtkTable* table, gint row, gint column) {
AtkObject* GetColumnHeader(AtkTable* table, gint column) {
g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
- auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(table));
+ auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table));
if (!obj)
return nullptr;
@@ -1779,7 +1771,7 @@ AtkObject* GetColumnHeader(AtkTable* table, gint column) {
AtkObject* GetRowHeader(AtkTable* table, gint row) {
g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
- auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(table));
+ auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table));
if (!obj)
return nullptr;
@@ -1802,7 +1794,7 @@ AtkObject* GetRowHeader(AtkTable* table, gint row) {
AtkObject* GetCaption(AtkTable* table) {
g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
- if (auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(table))) {
+ if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table))) {
if (auto* caption = obj->GetTableCaption())
return caption->GetNativeViewAccessible();
}
@@ -1813,7 +1805,7 @@ AtkObject* GetCaption(AtkTable* table) {
const gchar* GetColumnDescription(AtkTable* table, gint column) {
g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
- auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(table));
+ auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table));
if (!obj)
return nullptr;
@@ -1824,7 +1816,7 @@ const gchar* GetColumnDescription(AtkTable* table, gint column) {
const gchar* GetRowDescription(AtkTable* table, gint row) {
g_return_val_if_fail(ATK_IS_TABLE(table), nullptr);
- auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(table));
+ auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(table));
if (!obj)
return nullptr;
@@ -1864,7 +1856,7 @@ gint GetColumnSpan(AtkTableCell* cell) {
G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()), 0);
if (const AXPlatformNodeBase* obj =
- AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(cell))) {
+ AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell))) {
// If the object is not a cell, we return 0.
return obj->GetTableColumnSpan().value_or(0);
}
@@ -1880,7 +1872,7 @@ GPtrArray* GetColumnHeaderCells(AtkTableCell* cell) {
GPtrArray* array = g_ptr_array_new_with_free_func(g_object_unref);
- auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(cell));
+ auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell));
if (!obj)
return array;
@@ -1915,7 +1907,7 @@ gboolean GetCellPosition(AtkTableCell* cell, gint* row, gint* column) {
G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()),
FALSE);
- if (auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(cell))) {
+ if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell))) {
base::Optional<int> row_index = obj->GetTableRow();
base::Optional<int> col_index = obj->GetTableColumn();
if (!row_index || !col_index)
@@ -1934,7 +1926,7 @@ gint GetRowSpan(AtkTableCell* cell) {
g_return_val_if_fail(
G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()), 0);
- if (auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(cell))) {
+ if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell))) {
// If the object is not a cell, we return 0.
return obj->GetTableRowSpan().value_or(0);
}
@@ -1950,7 +1942,7 @@ GPtrArray* GetRowHeaderCells(AtkTableCell* cell) {
GPtrArray* array = g_ptr_array_new_with_free_func(g_object_unref);
- auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(cell));
+ auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell));
if (!obj)
return array;
@@ -1985,7 +1977,7 @@ AtkObject* GetTable(AtkTableCell* cell) {
G_TYPE_CHECK_INSTANCE_TYPE((cell), AtkTableCellInterface::GetType()),
nullptr);
- if (auto* obj = AtkObjectToAXPlatformNodeAuraLinux(ATK_OBJECT(cell))) {
+ if (auto* obj = AXPlatformNodeAuraLinux::FromAtkObject(ATK_OBJECT(cell))) {
if (auto* table = obj->GetTable())
return table->GetNativeViewAccessible();
}
@@ -2018,7 +2010,8 @@ gpointer kAXPlatformNodeAuraLinuxParentClass = nullptr;
const gchar* GetName(AtkObject* atk_object) {
g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
@@ -2042,7 +2035,8 @@ const gchar* AtkGetName(AtkObject* atk_object) {
const gchar* GetDescription(AtkObject* atk_object) {
g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
@@ -2058,7 +2052,8 @@ const gchar* AtkGetDescription(AtkObject* atk_object) {
gint GetNChildren(AtkObject* atk_object) {
g_return_val_if_fail(ATK_IS_OBJECT(atk_object), 0);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return 0;
@@ -2073,7 +2068,8 @@ gint AtkGetNChildren(AtkObject* atk_object) {
AtkObject* RefChild(AtkObject* atk_object, gint index) {
g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
@@ -2094,11 +2090,12 @@ AtkObject* AtkRefChild(AtkObject* atk_object, gint index) {
gint GetIndexInParent(AtkObject* atk_object) {
g_return_val_if_fail(ATK_IS_OBJECT(atk_object), -1);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return -1;
- return obj->GetIndexInParent();
+ return obj->GetIndexInParent().value_or(-1);
}
gint AtkGetIndexInParent(AtkObject* atk_object) {
@@ -2109,7 +2106,8 @@ gint AtkGetIndexInParent(AtkObject* atk_object) {
AtkObject* GetParent(AtkObject* atk_object) {
g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
@@ -2124,7 +2122,8 @@ AtkObject* AtkGetParent(AtkObject* atk_object) {
AtkRelationSet* RefRelationSet(AtkObject* atk_object) {
g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return atk_relation_set_new();
return obj->GetAtkRelations();
@@ -2138,7 +2137,8 @@ AtkRelationSet* AtkRefRelationSet(AtkObject* atk_object) {
AtkAttributeSet* GetAttributes(AtkObject* atk_object) {
g_return_val_if_fail(ATK_IS_OBJECT(atk_object), nullptr);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return nullptr;
@@ -2153,7 +2153,8 @@ AtkAttributeSet* AtkGetAttributes(AtkObject* atk_object) {
AtkRole GetRole(AtkObject* atk_object) {
g_return_val_if_fail(ATK_IS_OBJECT(atk_object), ATK_ROLE_INVALID);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj)
return ATK_ROLE_INVALID;
return obj->GetAtkRole();
@@ -2171,7 +2172,8 @@ AtkStateSet* RefStateSet(AtkObject* atk_object) {
ATK_OBJECT_CLASS(kAXPlatformNodeAuraLinuxParentClass)
->ref_state_set(atk_object);
- AXPlatformNodeAuraLinux* obj = AtkObjectToAXPlatformNodeAuraLinux(atk_object);
+ AXPlatformNodeAuraLinux* obj =
+ AXPlatformNodeAuraLinux::FromAtkObject(atk_object);
if (!obj) {
atk_state_set_add_state(atk_state_set, ATK_STATE_DEFUNCT);
} else {
@@ -2429,14 +2431,14 @@ void AXPlatformNodeAuraLinux::SetDocumentParentOnFrameIfNecessary() {
AtkObject* parent_atk_object = GetParent();
AXPlatformNodeAuraLinux* parent =
- AtkObjectToAXPlatformNodeAuraLinux(parent_atk_object);
+ AXPlatformNodeAuraLinux::FromAtkObject(parent_atk_object);
if (!parent)
return;
if (parent->GetDelegate()->IsWebContent())
return;
- AXPlatformNodeAuraLinux* frame = AtkObjectToAXPlatformNodeAuraLinux(
+ AXPlatformNodeAuraLinux* frame = AXPlatformNodeAuraLinux::FromAtkObject(
FindAtkObjectParentFrame(parent_atk_object));
if (!frame)
return;
@@ -2449,7 +2451,7 @@ AtkObject* AXPlatformNodeAuraLinux::FindFirstWebContentDocument() {
*child_iterator_ptr != *GetDelegate()->ChildrenEnd();
++(*child_iterator_ptr)) {
AtkObject* child = child_iterator_ptr->GetNativeViewAccessible();
- auto* child_node = AtkObjectToAXPlatformNodeAuraLinux(child);
+ auto* child_node = AXPlatformNodeAuraLinux::FromAtkObject(child);
if (!child_node)
continue;
if (!child_node->GetDelegate()->IsWebContent())
@@ -2510,7 +2512,7 @@ AXPlatformNode* AXPlatformNode::Create(AXPlatformNodeDelegate* delegate) {
// static
AXPlatformNode* AXPlatformNode::FromNativeViewAccessible(
gfx::NativeViewAccessible accessible) {
- return AtkObjectToAXPlatformNodeAuraLinux(accessible);
+ return AXPlatformNodeAuraLinux::FromAtkObject(accessible);
}
//
@@ -2518,6 +2520,21 @@ AXPlatformNode* AXPlatformNode::FromNativeViewAccessible(
//
// static
+AXPlatformNodeAuraLinux* AXPlatformNodeAuraLinux::FromAtkObject(
+ const AtkObject* atk_object) {
+ if (!atk_object)
+ return nullptr;
+
+ if (IS_AX_PLATFORM_NODE_AURALINUX(atk_object)) {
+ AXPlatformNodeAuraLinuxObject* platform_object =
+ AX_PLATFORM_NODE_AURALINUX(atk_object);
+ return platform_object->m_object;
+ }
+
+ return nullptr;
+}
+
+// static
void AXPlatformNodeAuraLinux::SetApplication(AXPlatformNode* application) {
g_root_application = application;
}
@@ -2543,9 +2560,9 @@ void AXPlatformNodeAuraLinux::EnableAXMode() {
AtkRole AXPlatformNodeAuraLinux::GetAtkRole() const {
switch (GetData().role) {
case ax::mojom::Role::kAlert:
- return ATK_ROLE_ALERT;
+ return ATK_ROLE_NOTIFICATION;
case ax::mojom::Role::kAlertDialog:
- return ATK_ROLE_DIALOG;
+ return ATK_ROLE_ALERT;
case ax::mojom::Role::kAnchor:
return ATK_ROLE_LINK;
case ax::mojom::Role::kComment:
@@ -2922,6 +2939,7 @@ AtkRole AXPlatformNodeAuraLinux::GetAtkRole() const {
// When we are not in web content, assume that a node with an unknown
// role is a view (which often have the unknown role).
return !GetDelegate()->IsWebContent() ? ATK_ROLE_PANEL : ATK_ROLE_UNKNOWN;
+ case ax::mojom::Role::kImeCandidate:
case ax::mojom::Role::kKeyboard:
case ax::mojom::Role::kNone:
case ax::mojom::Role::kPresentational:
@@ -3124,8 +3142,7 @@ AtkRelationSet* AXPlatformNodeAuraLinux::GetAtkRelations() {
}
}
- if (auto* document_parent =
- AtkObjectToAXPlatformNodeAuraLinux(document_parent_)) {
+ if (auto* document_parent = FromAtkObject(document_parent_)) {
AtkObject* document = document_parent->FindFirstWebContentDocument();
if (document) {
atk_relation_set_add_relation_by_type(relation_set, ATK_RELATION_EMBEDS,
@@ -3244,7 +3261,7 @@ void AXPlatformNodeAuraLinux::OnActiveDescendantChanged() {
// as a result of selection, a focus event will be emitted. We don't want to
// emit duplicate notifications.
{
- auto* node = AtkObjectToAXPlatformNodeAuraLinux(descendant);
+ auto* node = FromAtkObject(descendant);
if (node && node->SelectionAndFocusAreTheSame())
return;
}
@@ -3369,7 +3386,7 @@ void AXPlatformNodeAuraLinux::OnMenuPopupHide() {
}
void AXPlatformNodeAuraLinux::ResendFocusSignalsForCurrentlyFocusedNode() {
- auto* frame = AtkObjectToAXPlatformNodeAuraLinux(g_active_top_level_frame);
+ auto* frame = FromAtkObject(g_active_top_level_frame);
if (!frame)
return;
@@ -3558,8 +3575,7 @@ bool AXPlatformNodeAuraLinux::SelectionAndFocusAreTheSame() {
//
// If the selection is changing on a collapsed select element, focus remains
// on the select element and not the newly-selected descendant.
- if (AXPlatformNodeBase* parent =
- AtkObjectToAXPlatformNodeAuraLinux(GetParent())) {
+ if (AXPlatformNodeBase* parent = FromAtkObject(GetParent())) {
if (parent->GetData().role == ax::mojom::Role::kMenuListPopup)
return !parent->GetData().HasState(ax::mojom::State::kInvisible);
}
@@ -3610,7 +3626,7 @@ AXPlatformNodeAuraLinux& AXPlatformNodeAuraLinux::FindEditableRootOrDocument() {
return *this;
if (GetData().GetBoolAttribute(ax::mojom::BoolAttribute::kEditableRoot))
return *this;
- if (auto* parent = AtkObjectToAXPlatformNodeAuraLinux(GetParent()))
+ if (auto* parent = FromAtkObject(GetParent()))
return parent->FindEditableRootOrDocument();
return *this;
}
@@ -3619,7 +3635,7 @@ AXPlatformNodeAuraLinux* AXPlatformNodeAuraLinux::FindCommonAncestor(
AXPlatformNodeAuraLinux* other) {
if (this == other || other->IsDescendantOf(this))
return this;
- if (auto* parent = AtkObjectToAXPlatformNodeAuraLinux(GetParent()))
+ if (auto* parent = FromAtkObject(GetParent()))
return parent->FindCommonAncestor(other);
return nullptr;
}
@@ -3635,7 +3651,7 @@ void AXPlatformNodeAuraLinux::UpdateSelectionInformation(int32_t anchor_node_id,
void AXPlatformNodeAuraLinux::EmitSelectionChangedSignal(bool had_selection) {
if (!EmitsAtkTextEvents()) {
- if (auto* parent = AtkObjectToAXPlatformNodeAuraLinux(GetParent()))
+ if (auto* parent = FromAtkObject(GetParent()))
parent->EmitSelectionChangedSignal(had_selection);
return;
}
@@ -3654,7 +3670,7 @@ void AXPlatformNodeAuraLinux::EmitSelectionChangedSignal(bool had_selection) {
void AXPlatformNodeAuraLinux::EmitCaretChangedSignal() {
if (!EmitsAtkTextEvents()) {
- if (auto* parent = AtkObjectToAXPlatformNodeAuraLinux(GetParent()))
+ if (auto* parent = FromAtkObject(GetParent()))
parent->EmitCaretChangedSignal();
return;
}
@@ -3728,6 +3744,16 @@ void AXPlatformNodeAuraLinux::OnDescriptionChanged() {
g_value_unset(&property_values.new_value);
}
+void AXPlatformNodeAuraLinux::OnSortDirectionChanged() {
+ // TODO(crbug.com/1074380) fire correct event for aria-sort change.
+ // AtkObject* atk_object = GetOrCreateAtkObject();
+ // if (!atk_object)
+ // return;
+
+ // std::string sort;
+ // GetStringAttribute(ax::mojom::StringAttribute::kSortDirection, &sort);
+}
+
void AXPlatformNodeAuraLinux::OnValueChanged() {
// For the AtkText interface to work on non-web content nodes, we need to
// update the nodes' hypertext and trigger text change signals when the value
@@ -3778,8 +3804,7 @@ void AXPlatformNodeAuraLinux::OnDocumentTitleChanged() {
return;
// We always want to notify on the top frame.
- AXPlatformNodeAuraLinux* window =
- AtkObjectToAXPlatformNodeAuraLinux(g_active_top_level_frame);
+ AXPlatformNodeAuraLinux* window = FromAtkObject(g_active_top_level_frame);
if (window)
window->OnNameChanged();
}
@@ -3795,7 +3820,7 @@ void AXPlatformNodeAuraLinux::OnSubtreeCreated() {
return;
g_signal_emit_by_name(GetParent(), "children-changed::add",
- GetIndexInParent(), atk_object);
+ GetIndexInParent().value_or(-1), atk_object);
}
void AXPlatformNodeAuraLinux::OnSubtreeWillBeDeleted() {
@@ -3809,7 +3834,7 @@ void AXPlatformNodeAuraLinux::OnSubtreeWillBeDeleted() {
return;
g_signal_emit_by_name(GetParent(), "children-changed::remove",
- GetIndexInParent(), atk_object);
+ GetIndexInParent().value_or(-1), atk_object);
}
void AXPlatformNodeAuraLinux::OnParentChanged() {
@@ -3838,6 +3863,7 @@ void AXPlatformNodeAuraLinux::OnInvalidStatusChanged() {
}
void AXPlatformNodeAuraLinux::OnAlertShown() {
+ DCHECK(ui::IsAlert(GetData().role));
atk_object_notify_state_change(ATK_OBJECT(GetOrCreateAtkObject()),
ATK_STATE_SHOWING, TRUE);
}
@@ -3870,6 +3896,7 @@ void AXPlatformNodeAuraLinux::NotifyAccessibilityEvent(
OnCheckedStateChanged();
break;
case ax::mojom::Event::kExpandedChanged:
+ case ax::mojom::Event::kStateChanged:
OnExpandedStateChanged(GetData().HasState(ax::mojom::State::kExpanded));
break;
case ax::mojom::Event::kFocus:
@@ -3947,7 +3974,7 @@ AXPlatformNodeAuraLinux::GetEmbeddedObjectIndicesForId(int id) {
base::Optional<std::pair<int, int>>
AXPlatformNodeAuraLinux::GetEmbeddedObjectIndices() {
- auto* parent = AtkObjectToAXPlatformNodeAuraLinux(GetParent());
+ auto* parent = FromAtkObject(GetParent());
if (!parent)
return base::nullopt;
return parent->GetEmbeddedObjectIndicesForId(GetUniqueId());
@@ -4178,7 +4205,7 @@ bool AXPlatformNodeAuraLinux::FocusFirstFocusableAncestorInWebContent() {
return true;
}
- auto* parent = AtkObjectToAXPlatformNodeAuraLinux(GetParent());
+ auto* parent = FromAtkObject(GetParent());
if (!parent)
return false;
@@ -4188,8 +4215,7 @@ bool AXPlatformNodeAuraLinux::FocusFirstFocusableAncestorInWebContent() {
for (auto child_iterator_ptr = parent->GetDelegate()->ChildrenBegin();
*child_iterator_ptr != *parent->GetDelegate()->ChildrenEnd();
++(*child_iterator_ptr)) {
- auto* child = AtkObjectToAXPlatformNodeAuraLinux(
- child_iterator_ptr->GetNativeViewAccessible());
+ auto* child = FromAtkObject(child_iterator_ptr->GetNativeViewAccessible());
if (!child || child == this)
continue;
@@ -4231,8 +4257,7 @@ bool AXPlatformNodeAuraLinux::
// building the hypertext here.
int current_offset = 0;
for (int i = 0; i < child_count; ++i) {
- auto* child =
- AtkObjectToAXPlatformNodeAuraLinux(delegate_->ChildAtIndex(i));
+ auto* child = FromAtkObject(delegate_->ChildAtIndex(i));
if (!child)
continue;
@@ -4264,10 +4289,9 @@ const gchar* AXPlatformNodeAuraLinux::GetDefaultActionName() {
if (!GetIntAttribute(ax::mojom::IntAttribute::kDefaultActionVerb, &action))
return nullptr;
- base::string16 action_verb = ActionVerbToUnlocalizedString(
- static_cast<ax::mojom::DefaultActionVerb>(action));
-
- ATK_AURALINUX_RETURN_STRING(base::UTF16ToUTF8(action_verb));
+ std::string action_verb =
+ ui::ToString(static_cast<ax::mojom::DefaultActionVerb>(action));
+ ATK_AURALINUX_RETURN_STRING(action_verb);
}
AtkAttributeSet* AXPlatformNodeAuraLinux::GetAtkAttributes() {
@@ -4755,8 +4779,7 @@ AXPlatformNodeAuraLinux::GetHypertextExtentsOfChild(
for (auto child_iterator_ptr = GetDelegate()->ChildrenBegin();
*child_iterator_ptr != *GetDelegate()->ChildrenEnd();
++(*child_iterator_ptr)) {
- auto* child = AtkObjectToAXPlatformNodeAuraLinux(
- child_iterator_ptr->GetNativeViewAccessible());
+ auto* child = FromAtkObject(child_iterator_ptr->GetNativeViewAccessible());
if (!child)
continue;
@@ -4774,7 +4797,7 @@ AXPlatformNodeAuraLinux::GetHypertextExtentsOfChild(
void AXPlatformNodeAuraLinux::ActivateFindInPageInParent(int start_offset,
int end_offset) {
- auto* parent = AtkObjectToAXPlatformNodeAuraLinux(GetParent());
+ auto* parent = FromAtkObject(GetParent());
if (!parent)
return;
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_auralinux.h b/chromium/ui/accessibility/platform/ax_platform_node_auralinux.h
index a1d8c20c9d4..6fde338d9e1 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_auralinux.h
+++ b/chromium/ui/accessibility/platform/ax_platform_node_auralinux.h
@@ -121,6 +121,8 @@ class AX_EXPORT AXPlatformNodeAuraLinux : public AXPlatformNodeBase {
AXPlatformNodeAuraLinux();
~AXPlatformNodeAuraLinux() override;
+ static AXPlatformNodeAuraLinux* FromAtkObject(const AtkObject*);
+
// Set or get the root-level Application object that's the parent of all
// top-level windows.
static void SetApplication(AXPlatformNode* application);
@@ -212,6 +214,7 @@ class AX_EXPORT AXPlatformNodeAuraLinux : public AXPlatformNodeBase {
void OnValueChanged();
void OnNameChanged();
void OnDescriptionChanged();
+ void OnSortDirectionChanged();
void OnInvalidStatusChanged();
void OnDocumentTitleChanged();
void OnSubtreeCreated();
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_auralinux_unittest.cc b/chromium/ui/accessibility/platform/ax_platform_node_auralinux_unittest.cc
index fdae0972a01..b120f746734 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_auralinux_unittest.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node_auralinux_unittest.cc
@@ -284,6 +284,14 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkObjectRole) {
AtkObject* child_obj(AtkObjectFromNode(child_node));
ASSERT_TRUE(ATK_IS_OBJECT(child_obj));
g_object_ref(child_obj);
+ EXPECT_EQ(ATK_ROLE_NOTIFICATION, atk_object_get_role(child_obj));
+ g_object_unref(child_obj);
+
+ child.role = ax::mojom::Role::kAlertDialog;
+ child_node->SetData(child);
+ child_obj = AtkObjectFromNode(child_node);
+ ASSERT_TRUE(ATK_IS_OBJECT(child_obj));
+ g_object_ref(child_obj);
EXPECT_EQ(ATK_ROLE_ALERT, atk_object_get_role(child_obj));
g_object_unref(child_obj);
@@ -1859,6 +1867,8 @@ TEST_F(AXPlatformNodeAuraLinuxTest, TestAtkSelectionInterface) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kListBox;
+ root.AddState(ax::mojom::State::kFocusable);
+ root.AddState(ax::mojom::State::kMultiselectable);
root.child_ids.push_back(2);
root.child_ids.push_back(3);
root.child_ids.push_back(4);
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_base.cc b/chromium/ui/accessibility/platform/ax_platform_node_base.cc
index ebff0e2b264..99de6603989 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_base.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node_base.cc
@@ -130,7 +130,7 @@ int AXPlatformNodeBase::GetChildCount() const {
return 0;
}
-gfx::NativeViewAccessible AXPlatformNodeBase::ChildAtIndex(int index) {
+gfx::NativeViewAccessible AXPlatformNodeBase::ChildAtIndex(int index) const {
if (delegate_)
return delegate_->ChildAtIndex(index);
return nullptr;
@@ -149,15 +149,16 @@ base::string16 AXPlatformNodeBase::GetNameAsString16() const {
return base::UTF8ToUTF16(name);
}
-int AXPlatformNodeBase::GetIndexInParent() {
+base::Optional<int> AXPlatformNodeBase::GetIndexInParent() {
AXPlatformNodeBase* parent = FromNativeViewAccessible(GetParent());
if (!parent)
- return 0;
+ return base::nullopt;
int child_count = parent->GetChildCount();
if (child_count == 0) {
- // |child_count| could be 0 if the node is PlatformIsLeaf.
- return 0;
+ // |child_count| could be 0 if the parent is IsLeaf.
+ DCHECK(parent->IsLeaf());
+ return base::nullopt;
}
// Ask the delegate for the index in parent, and return it if it's plausible.
@@ -176,7 +177,9 @@ int AXPlatformNodeBase::GetIndexInParent() {
if (parent->ChildAtIndex(i) == current)
return i;
}
- return -1;
+ NOTREACHED()
+ << "Unable to find the child in the list of its parent's children.";
+ return base::nullopt;
}
// AXPlatformNode overrides.
@@ -228,27 +231,36 @@ bool AXPlatformNodeBase::IsDescendantOf(AXPlatformNode* ancestor) const {
return parent->IsDescendantOf(ancestor);
}
+AXPlatformNodeBase::AXPlatformNodeChildIterator
+AXPlatformNodeBase::AXPlatformNodeChildrenBegin() const {
+ return AXPlatformNodeChildIterator(this, GetFirstChild());
+}
+
+AXPlatformNodeBase::AXPlatformNodeChildIterator
+AXPlatformNodeBase::AXPlatformNodeChildrenEnd() const {
+ return AXPlatformNodeChildIterator(this, nullptr);
+}
// Helpers.
-AXPlatformNodeBase* AXPlatformNodeBase::GetPreviousSibling() {
+AXPlatformNodeBase* AXPlatformNodeBase::GetPreviousSibling() const {
if (!delegate_)
return nullptr;
return FromNativeViewAccessible(delegate_->GetPreviousSibling());
}
-AXPlatformNodeBase* AXPlatformNodeBase::GetNextSibling() {
+AXPlatformNodeBase* AXPlatformNodeBase::GetNextSibling() const {
if (!delegate_)
return nullptr;
return FromNativeViewAccessible(delegate_->GetNextSibling());
}
-AXPlatformNodeBase* AXPlatformNodeBase::GetFirstChild() {
+AXPlatformNodeBase* AXPlatformNodeBase::GetFirstChild() const {
if (!delegate_)
return nullptr;
return FromNativeViewAccessible(delegate_->GetFirstChild());
}
-AXPlatformNodeBase* AXPlatformNodeBase::GetLastChild() {
+AXPlatformNodeBase* AXPlatformNodeBase::GetLastChild() const {
if (!delegate_)
return nullptr;
return FromNativeViewAccessible(delegate_->GetLastChild());
@@ -539,11 +551,10 @@ base::string16 AXPlatformNodeBase::GetInnerText() const {
return GetNameAsString16();
base::string16 text;
- // TODO(Nektar): Remove const_cast by making all tree traversal methods const.
- AXPlatformNodeBase* child =
- const_cast<AXPlatformNodeBase*>(this)->GetFirstChild();
- for (; child; child = child->GetNextSibling())
- text += child->GetInnerText();
+ for (auto child_iter = AXPlatformNodeChildrenBegin();
+ child_iter != AXPlatformNodeChildrenEnd(); ++child_iter) {
+ text += child_iter->GetInnerText();
+ }
return text;
}
@@ -1155,7 +1166,8 @@ void AXPlatformNodeBase::ComputeAttributes(PlatformAttributeList* attributes) {
}
// Expose slider value.
- if (GetData().IsRangeValueSupported()) {
+ if (GetData().IsRangeValueSupported() ||
+ GetData().role == ax::mojom::Role::kComboBoxMenuButton) {
std::string value = base::UTF16ToUTF8(GetRangeValueText());
if (!value.empty())
AddAttributeToList("valuetext", value, attributes);
@@ -1282,18 +1294,16 @@ void AXPlatformNodeBase::UpdateComputedHypertext() const {
// the character index of each embedded object character to the id of the
// child object it points to.
base::string16 hypertext;
- // TODO(Nektar): Remove const_cast by making all tree traversal methods const.
- AXPlatformNodeBase* child =
- const_cast<AXPlatformNodeBase*>(this)->GetFirstChild();
- for (; child; child = child->GetNextSibling()) {
+ for (AXPlatformNodeChildIterator child_iter = AXPlatformNodeChildrenBegin();
+ child_iter != AXPlatformNodeChildrenEnd(); ++child_iter) {
// Similar to Firefox, we don't expose text-only objects in IA2 and ATK
// hypertext with the embedded object character. We copy all of their text
// instead.
- if (child->IsTextOnlyObject()) {
- hypertext_.hypertext += child->GetNameAsString16();
+ if (child_iter->IsTextOnlyObject()) {
+ hypertext_.hypertext += child_iter->GetNameAsString16();
} else {
int32_t char_offset = static_cast<int32_t>(hypertext_.hypertext.size());
- int32_t child_unique_id = child->GetUniqueId();
+ int32_t child_unique_id = child_iter->GetUniqueId();
int32_t index = static_cast<int32_t>(hypertext_.hyperlinks.size());
hypertext_.hyperlink_offset_to_index[char_offset] = index;
hypertext_.hyperlinks.push_back(child_unique_id);
@@ -1429,15 +1439,12 @@ int32_t AXPlatformNodeBase::GetHypertextOffsetFromChild(
// cross-tree traversal is necessary.
if (child->IsTextOnlyObject()) {
int32_t hypertext_offset = 0;
- int32_t index_in_parent = child->GetIndexInParent();
- DCHECK_GE(index_in_parent, 0);
- DCHECK_LT(index_in_parent, static_cast<int32_t>(GetChildCount()));
- for (uint32_t i = 0; i < static_cast<uint32_t>(index_in_parent); ++i) {
- auto* sibling = static_cast<AXPlatformNodeBase*>(
- FromNativeViewAccessible(ChildAtIndex(i)));
- DCHECK(sibling);
- if (sibling->IsTextOnlyObject()) {
- hypertext_offset += (int32_t)sibling->GetHypertext().size();
+ for (auto child_iter = AXPlatformNodeChildrenBegin();
+ child_iter != AXPlatformNodeChildrenEnd() && child_iter.get() != child;
+ ++child_iter) {
+ if (child_iter->IsTextOnlyObject()) {
+ hypertext_offset +=
+ static_cast<int32_t>(child_iter->GetHypertext().size());
} else {
++hypertext_offset;
}
@@ -1510,7 +1517,7 @@ int AXPlatformNodeBase::GetHypertextOffsetFromEndpoint(
}
AXPlatformNodeBase* common_parent = this;
- int32_t index_in_common_parent = GetIndexInParent();
+ base::Optional<int> index_in_common_parent = GetIndexInParent();
while (common_parent && !endpoint_object->IsDescendantOf(common_parent)) {
index_in_common_parent = common_parent->GetIndexInParent();
common_parent = static_cast<AXPlatformNodeBase*>(
@@ -1519,7 +1526,6 @@ int AXPlatformNodeBase::GetHypertextOffsetFromEndpoint(
if (!common_parent)
return -1;
- DCHECK_GE(index_in_common_parent, 0);
DCHECK(!(common_parent->IsTextOnlyObject()));
// Case 2. Is the selection endpoint inside a descendant of this object?
@@ -1547,17 +1553,14 @@ int AXPlatformNodeBase::GetHypertextOffsetFromEndpoint(
//
// We can safely assume that the endpoint is in another part of the tree or
// at common parent, and that this object is a descendant of common parent.
- int32_t endpoint_index_in_common_parent = -1;
- for (int i = 0; i < common_parent->GetDelegate()->GetChildCount(); ++i) {
- auto* child = static_cast<AXPlatformNodeBase*>(FromNativeViewAccessible(
- common_parent->GetDelegate()->ChildAtIndex(i)));
- DCHECK(child);
- if (endpoint_object->IsDescendantOf(child)) {
- endpoint_index_in_common_parent = child->GetIndexInParent();
+ base::Optional<int> endpoint_index_in_common_parent;
+ for (auto child_iter = common_parent->AXPlatformNodeChildrenBegin();
+ child_iter != common_parent->AXPlatformNodeChildrenEnd(); ++child_iter) {
+ if (endpoint_object->IsDescendantOf(child_iter.get())) {
+ endpoint_index_in_common_parent = child_iter->GetIndexInParent();
break;
}
}
- DCHECK_GE(endpoint_index_in_common_parent, 0);
if (endpoint_index_in_common_parent < index_in_common_parent)
return 0;
@@ -2058,6 +2061,54 @@ ui::TextAttributeList AXPlatformNodeBase::ComputeTextAttributes() const {
return attributes;
}
+int AXPlatformNodeBase::GetSelectionCount() const {
+ int max_items = GetMaxSelectableItems();
+ if (!max_items)
+ return 0;
+ return GetSelectedItems(max_items);
+}
+
+AXPlatformNodeBase* AXPlatformNodeBase::GetSelectedItem(
+ int selected_index) const {
+ DCHECK_GE(selected_index, 0);
+ int max_items = GetMaxSelectableItems();
+ if (max_items == 0)
+ return nullptr;
+ if (selected_index >= max_items)
+ return nullptr;
+
+ std::vector<AXPlatformNodeBase*> selected_children;
+ int requested_count = selected_index + 1;
+ int returned_count = GetSelectedItems(requested_count, &selected_children);
+
+ if (returned_count <= selected_index)
+ return nullptr;
+
+ DCHECK(!selected_children.empty());
+ DCHECK_LT(selected_index, static_cast<int>(selected_children.size()));
+ return selected_children[selected_index];
+}
+
+int AXPlatformNodeBase::GetSelectedItems(
+ int max_items,
+ std::vector<AXPlatformNodeBase*>* out_selected_items) const {
+ int selected_count = 0;
+ for (auto child_iter = AXPlatformNodeChildrenBegin();
+ child_iter != AXPlatformNodeChildrenEnd() && selected_count < max_items;
+ ++child_iter) {
+ if (!IsItemLike(child_iter->GetData().role)) {
+ selected_count += child_iter->GetSelectedItems(max_items - selected_count,
+ out_selected_items);
+ } else if (child_iter->GetBoolAttribute(
+ ax::mojom::BoolAttribute::kSelected)) {
+ selected_count++;
+ if (out_selected_items)
+ out_selected_items->emplace_back(child_iter.get());
+ }
+ }
+ return selected_count;
+}
+
void AXPlatformNodeBase::SanitizeTextAttributeValue(const std::string& input,
std::string* output) const {
DCHECK(output);
@@ -2116,4 +2167,20 @@ std::string AXPlatformNodeBase::ComputeDetailsRoles() const {
return base::JoinString(details_roles_vector, " ");
}
+int AXPlatformNodeBase::GetMaxSelectableItems() const {
+ if (!GetData().HasState(ax::mojom::State::kFocusable))
+ return 0;
+
+ if (IsLeaf())
+ return 0;
+
+ if (!IsContainerWithSelectableChildren(GetData().role))
+ return 0;
+
+ int max_items = 1;
+ if (GetData().HasState(ax::mojom::State::kMultiselectable))
+ max_items = std::numeric_limits<int>::max();
+ return max_items;
+}
+
} // namespace ui
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_base.h b/chromium/ui/accessibility/platform/ax_platform_node_base.h
index b46cf48d223..90fca62bb3f 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_base.h
+++ b/chromium/ui/accessibility/platform/ax_platform_node_base.h
@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "build/build_config.h"
#include "ui/accessibility/ax_enums.mojom-forward.h"
+#include "ui/accessibility/ax_node.h"
#include "ui/accessibility/platform/ax_platform_node.h"
#include "ui/accessibility/platform/ax_platform_node_delegate.h"
#include "ui/accessibility/platform/ax_platform_text_boundary.h"
@@ -64,13 +65,14 @@ class AX_EXPORT AXPlatformNodeBase : public AXPlatformNode {
gfx::NativeViewAccessible GetFocus();
gfx::NativeViewAccessible GetParent() const;
int GetChildCount() const;
- gfx::NativeViewAccessible ChildAtIndex(int index);
+ gfx::NativeViewAccessible ChildAtIndex(int index) const;
std::string GetName() const;
base::string16 GetNameAsString16() const;
- // This returns 0 if there's no parent.
- virtual int GetIndexInParent();
+ // This returns nullopt if there's no parent, it's unable to find the child in
+ // the list of its parent's children, or its parent doesn't have children.
+ virtual base::Optional<int> GetIndexInParent();
// AXPlatformNode.
void Destroy() override;
@@ -85,12 +87,21 @@ class AX_EXPORT AXPlatformNodeBase : public AXPlatformNode {
bool IsDescendantOf(AXPlatformNode* ancestor) const override;
// Helpers.
- AXPlatformNodeBase* GetPreviousSibling();
- AXPlatformNodeBase* GetNextSibling();
- AXPlatformNodeBase* GetFirstChild();
- AXPlatformNodeBase* GetLastChild();
+ AXPlatformNodeBase* GetPreviousSibling() const;
+ AXPlatformNodeBase* GetNextSibling() const;
+ AXPlatformNodeBase* GetFirstChild() const;
+ AXPlatformNodeBase* GetLastChild() const;
bool IsDescendant(AXPlatformNodeBase* descendant);
+ using AXPlatformNodeChildIterator =
+ ui::AXNode::ChildIteratorBase<AXPlatformNodeBase,
+ &AXPlatformNodeBase::GetNextSibling,
+ &AXPlatformNodeBase::GetPreviousSibling,
+ &AXPlatformNodeBase::GetFirstChild,
+ &AXPlatformNodeBase::GetLastChild>;
+ AXPlatformNodeChildIterator AXPlatformNodeChildrenBegin() const;
+ AXPlatformNodeChildIterator AXPlatformNodeChildrenEnd() const;
+
bool HasBoolAttribute(ax::mojom::BoolAttribute attr) const;
bool GetBoolAttribute(ax::mojom::BoolAttribute attr) const;
bool GetBoolAttribute(ax::mojom::BoolAttribute attr, bool* value) const;
@@ -312,6 +323,24 @@ class AX_EXPORT AXPlatformNodeBase : public AXPlatformNode {
ui::TextAttributeList ComputeTextAttributes() const;
+ // Get the number of items selected. It checks kMultiselectable and
+ // kFocusable. and uses GetSelectedItems to get the selected number.
+ int GetSelectionCount() const;
+
+ // If this object is a container that supports selectable children, returns
+ // the selected item at the provided index.
+ AXPlatformNodeBase* GetSelectedItem(int selected_index) const;
+
+ // If this object is a container that supports selectable children,
+ // returns the number of selected items in this container.
+ // |out_selected_items| could be set to nullptr if the caller just
+ // needs to know the number of items selected.
+ // |max_items| represents the number that the caller expects as a
+ // maximum. For a single selection list box, it will be 1.
+ int GetSelectedItems(
+ int max_items,
+ std::vector<AXPlatformNodeBase*>* out_selected_items = nullptr) const;
+
//
// Delegate. This is a weak reference which owns |this|.
//
@@ -454,6 +483,11 @@ class AX_EXPORT AXPlatformNodeBase : public AXPlatformNode {
std::string GetInvalidValue() const;
+ // Based on the characteristics of this object, such as its role and the
+ // presence of a multiselectable attribute, returns the maximum number of
+ // selectable children that this object could potentially contain.
+ int GetMaxSelectableItems() const;
+
mutable AXHypertext hypertext_;
private:
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_base_unittest.cc b/chromium/ui/accessibility/platform/ax_platform_node_base_unittest.cc
index d0bc34a70e5..8df32b83c91 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_base_unittest.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node_base_unittest.cc
@@ -43,6 +43,114 @@ void SetRole(AXTree* tree, int id, ax::mojom::Role role) {
} // namespace
+TEST(AXPlatformNodeBaseTest, GetHypertext) {
+ AXTreeUpdate update;
+
+ // RootWebArea #1
+ // ++++StaticText "text1" #2
+ // ++++StaticText "text2" #3
+ // ++++StaticText "text3" #4
+
+ update.root_id = 1;
+ update.nodes.resize(4);
+
+ update.nodes[0].id = 1;
+ update.nodes[0].role = ax::mojom::Role::kWebArea;
+ update.nodes[0].child_ids = {2, 3, 4};
+
+ MakeStaticText(&update.nodes[1], 2, "text1");
+ MakeStaticText(&update.nodes[2], 3, "text2");
+ MakeStaticText(&update.nodes[3], 4, "text3");
+
+ AXTree tree(update);
+
+ // Set an AXMode on the AXPlatformNode as some platforms (auralinux) use it to
+ // determine if it should enable accessibility.
+ AXPlatformNodeBase::NotifyAddAXModeFlags(kAXModeComplete);
+
+ AXPlatformNodeBase* root = static_cast<AXPlatformNodeBase*>(
+ TestAXNodeWrapper::GetOrCreate(&tree, tree.root())->ax_platform_node());
+
+ EXPECT_EQ(root->GetHypertext(), base::UTF8ToUTF16("text1text2text3"));
+
+ AXPlatformNodeBase* text1 = static_cast<AXPlatformNodeBase*>(
+ AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(0)));
+ EXPECT_EQ(text1->GetHypertext(), base::UTF8ToUTF16("text1"));
+
+ AXPlatformNodeBase* text2 = static_cast<AXPlatformNodeBase*>(
+ AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(1)));
+ EXPECT_EQ(text2->GetHypertext(), base::UTF8ToUTF16("text2"));
+
+ AXPlatformNodeBase* text3 = static_cast<AXPlatformNodeBase*>(
+ AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(2)));
+ EXPECT_EQ(text3->GetHypertext(), base::UTF8ToUTF16("text3"));
+}
+
+TEST(AXPlatformNodeBaseTest, GetHypertextIgnoredContainerSiblings) {
+ AXTreeUpdate update;
+
+ // RootWebArea #1
+ // ++genericContainer IGNORED #2
+ // ++++StaticText "text1" #3
+ // ++genericContainer IGNORED #4
+ // ++++StaticText "text2" #5
+ // ++genericContainer IGNORED #6
+ // ++++StaticText "text3" #7
+
+ update.root_id = 1;
+ update.nodes.resize(7);
+
+ update.nodes[0].id = 1;
+ update.nodes[0].role = ax::mojom::Role::kWebArea;
+ update.nodes[0].child_ids = {2, 4, 6};
+
+ update.nodes[1].id = 2;
+ update.nodes[1].child_ids = {3};
+ update.nodes[1].role = ax::mojom::Role::kGenericContainer;
+ update.nodes[1].AddState(ax::mojom::State::kIgnored);
+ MakeStaticText(&update.nodes[2], 3, "text1");
+
+ update.nodes[3].id = 4;
+ update.nodes[3].child_ids = {5};
+ update.nodes[3].role = ax::mojom::Role::kGenericContainer;
+ update.nodes[3].AddState(ax::mojom::State::kIgnored);
+ MakeStaticText(&update.nodes[4], 5, "text2");
+
+ update.nodes[5].id = 6;
+ update.nodes[5].child_ids = {7};
+ update.nodes[5].role = ax::mojom::Role::kGenericContainer;
+ update.nodes[5].AddState(ax::mojom::State::kIgnored);
+ MakeStaticText(&update.nodes[6], 7, "text3");
+
+ AXTree tree(update);
+ // Set an AXMode on the AXPlatformNode as some platforms (auralinux) use it to
+ // determine if it should enable accessibility.
+ AXPlatformNodeBase::NotifyAddAXModeFlags(kAXModeComplete);
+
+ AXPlatformNodeBase* root = static_cast<AXPlatformNodeBase*>(
+ TestAXNodeWrapper::GetOrCreate(&tree, tree.root())->ax_platform_node());
+
+ EXPECT_EQ(root->GetHypertext(), base::UTF8ToUTF16("text1text2text3"));
+
+ AXPlatformNodeBase* text1_ignored_container =
+ static_cast<AXPlatformNodeBase*>(
+ AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(0)));
+ EXPECT_EQ(text1_ignored_container->GetHypertext(),
+ base::UTF8ToUTF16("text1"));
+
+ AXPlatformNodeBase* text2_ignored_container =
+ static_cast<AXPlatformNodeBase*>(
+ AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(1)));
+ EXPECT_EQ(text2_ignored_container->GetHypertext(),
+ base::UTF8ToUTF16("text2"));
+
+ AXPlatformNodeBase* text3_ignored_container =
+ static_cast<AXPlatformNodeBase*>(
+ AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(2)));
+ EXPECT_EQ(text3_ignored_container->GetHypertext(),
+ base::UTF8ToUTF16("text3"));
+}
+
TEST(AXPlatformNodeBaseTest, InnerTextIgnoresInvisibleAndIgnored) {
AXTreeUpdate update;
@@ -96,4 +204,200 @@ TEST(AXPlatformNodeBaseTest, InnerTextIgnoresInvisibleAndIgnored) {
}
}
+TEST(AXPlatformNodeBaseTest, TestSelectedChildren) {
+ AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
+
+ AXNodeData root_data;
+ root_data.id = 1;
+ root_data.role = ax::mojom::Role::kListBox;
+ root_data.AddState(ax::mojom::State::kFocusable);
+ root_data.child_ids = {2, 3};
+
+ AXNodeData item_1_data;
+ item_1_data.id = 2;
+ item_1_data.role = ax::mojom::Role::kListBoxOption;
+ item_1_data.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
+
+ AXNodeData item_2_data;
+ item_2_data.id = 3;
+ item_2_data.role = ax::mojom::Role::kListBoxOption;
+
+ AXTreeUpdate update;
+ update.root_id = 1;
+ update.nodes = {root_data, item_1_data, item_2_data};
+ AXTree tree(update);
+
+ auto* root = static_cast<AXPlatformNodeBase*>(
+ TestAXNodeWrapper::GetOrCreate(&tree, tree.root())->ax_platform_node());
+
+ int num = root->GetSelectionCount();
+ EXPECT_EQ(num, 1);
+
+ gfx::NativeViewAccessible first_child = root->ChildAtIndex(0);
+ AXPlatformNodeBase* first_selected_node = root->GetSelectedItem(0);
+ EXPECT_EQ(first_child, first_selected_node->GetNativeViewAccessible());
+ EXPECT_EQ(nullptr, root->GetSelectedItem(1));
+}
+
+TEST(AXPlatformNodeBaseTest, TestSelectedChildrenWithGroup) {
+ AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
+
+ AXNodeData root_data;
+ root_data.id = 1;
+ root_data.role = ax::mojom::Role::kListBox;
+ root_data.AddState(ax::mojom::State::kFocusable);
+ root_data.AddState(ax::mojom::State::kMultiselectable);
+ root_data.child_ids = {2, 3};
+
+ AXNodeData group_1_data;
+ group_1_data.id = 2;
+ group_1_data.role = ax::mojom::Role::kGroup;
+ group_1_data.child_ids = {4, 5};
+
+ AXNodeData group_2_data;
+ group_2_data.id = 3;
+ group_2_data.role = ax::mojom::Role::kGroup;
+ group_2_data.child_ids = {6, 7};
+
+ AXNodeData item_1_data;
+ item_1_data.id = 4;
+ item_1_data.role = ax::mojom::Role::kListBoxOption;
+ item_1_data.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
+
+ AXNodeData item_2_data;
+ item_2_data.id = 5;
+ item_2_data.role = ax::mojom::Role::kListBoxOption;
+
+ AXNodeData item_3_data;
+ item_3_data.id = 6;
+ item_3_data.role = ax::mojom::Role::kListBoxOption;
+
+ AXNodeData item_4_data;
+ item_4_data.id = 7;
+ item_4_data.role = ax::mojom::Role::kListBoxOption;
+ item_4_data.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
+
+ AXTreeUpdate update;
+ update.root_id = 1;
+ update.nodes = {root_data, group_1_data, group_2_data, item_1_data,
+ item_2_data, item_3_data, item_4_data};
+ AXTree tree(update);
+
+ auto* root = static_cast<AXPlatformNodeBase*>(
+ TestAXNodeWrapper::GetOrCreate(&tree, tree.root())->ax_platform_node());
+
+ int num = root->GetSelectionCount();
+ EXPECT_EQ(num, 2);
+
+ gfx::NativeViewAccessible first_group_child =
+ static_cast<AXPlatformNodeBase*>(
+ AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(0)))
+ ->ChildAtIndex(0);
+ AXPlatformNodeBase* first_selected_node = root->GetSelectedItem(0);
+ EXPECT_EQ(first_group_child, first_selected_node->GetNativeViewAccessible());
+
+ gfx::NativeViewAccessible second_group_child =
+ static_cast<AXPlatformNodeBase*>(
+ AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(1)))
+ ->ChildAtIndex(1);
+ AXPlatformNodeBase* second_selected_node = root->GetSelectedItem(1);
+ EXPECT_EQ(second_group_child,
+ second_selected_node->GetNativeViewAccessible());
+}
+
+TEST(AXPlatformNodeBaseTest, TestSelectedChildrenMixed) {
+ AXPlatformNode::NotifyAddAXModeFlags(kAXModeComplete);
+
+ // Build the below tree which is mixed with listBoxOption and group.
+ // id=1 listBox FOCUSABLE MULTISELECTABLE (0, 0)-(0, 0) child_ids=2,3,4,9
+ // ++id=2 listBoxOption (0, 0)-(0, 0) selected=true
+ // ++id=3 group (0, 0)-(0, 0) child_ids=5,6
+ // ++++id=5 listBoxOption (0, 0)-(0, 0) selected=true
+ // ++++id=6 listBoxOption (0, 0)-(0, 0)
+ // ++id=4 group (0, 0)-(0, 0) child_ids=7,8
+ // ++++id=7 listBoxOption (0, 0)-(0, 0)
+ // ++++id=8 listBoxOption (0, 0)-(0, 0) selected=true
+ // ++id=9 listBoxOption (0, 0)-(0, 0) selected=true
+
+ AXNodeData root_data;
+ root_data.id = 1;
+ root_data.role = ax::mojom::Role::kListBox;
+ root_data.AddState(ax::mojom::State::kFocusable);
+ root_data.AddState(ax::mojom::State::kMultiselectable);
+ root_data.child_ids = {2, 3, 4, 9};
+
+ AXNodeData item_1_data;
+ item_1_data.id = 2;
+ item_1_data.role = ax::mojom::Role::kListBoxOption;
+ item_1_data.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
+
+ AXNodeData group_1_data;
+ group_1_data.id = 3;
+ group_1_data.role = ax::mojom::Role::kGroup;
+ group_1_data.child_ids = {5, 6};
+
+ AXNodeData item_2_data;
+ item_2_data.id = 5;
+ item_2_data.role = ax::mojom::Role::kListBoxOption;
+ item_2_data.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
+
+ AXNodeData item_3_data;
+ item_3_data.id = 6;
+ item_3_data.role = ax::mojom::Role::kListBoxOption;
+
+ AXNodeData group_2_data;
+ group_2_data.id = 4;
+ group_2_data.role = ax::mojom::Role::kGroup;
+ group_2_data.child_ids = {7, 8};
+
+ AXNodeData item_4_data;
+ item_4_data.id = 7;
+ item_4_data.role = ax::mojom::Role::kListBoxOption;
+
+ AXNodeData item_5_data;
+ item_5_data.id = 8;
+ item_5_data.role = ax::mojom::Role::kListBoxOption;
+ item_5_data.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
+
+ AXNodeData item_6_data;
+ item_6_data.id = 9;
+ item_6_data.role = ax::mojom::Role::kListBoxOption;
+ item_6_data.AddBoolAttribute(ax::mojom::BoolAttribute::kSelected, true);
+
+ AXTreeUpdate update;
+ update.root_id = 1;
+ update.nodes = {root_data, item_1_data, group_1_data,
+ item_2_data, item_3_data, group_2_data,
+ item_4_data, item_5_data, item_6_data};
+ AXTree tree(update);
+
+ auto* root = static_cast<AXPlatformNodeBase*>(
+ TestAXNodeWrapper::GetOrCreate(&tree, tree.root())->ax_platform_node());
+
+ int num = root->GetSelectionCount();
+ EXPECT_EQ(num, 4);
+
+ gfx::NativeViewAccessible first_child = root->ChildAtIndex(0);
+ AXPlatformNodeBase* first_selected_node = root->GetSelectedItem(0);
+ EXPECT_EQ(first_child, first_selected_node->GetNativeViewAccessible());
+
+ gfx::NativeViewAccessible first_group_child =
+ static_cast<AXPlatformNodeBase*>(
+ AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(1)))
+ ->ChildAtIndex(0);
+ AXPlatformNodeBase* second_selected_node = root->GetSelectedItem(1);
+ EXPECT_EQ(first_group_child, second_selected_node->GetNativeViewAccessible());
+
+ gfx::NativeViewAccessible second_group_child =
+ static_cast<AXPlatformNodeBase*>(
+ AXPlatformNode::FromNativeViewAccessible(root->ChildAtIndex(2)))
+ ->ChildAtIndex(1);
+ AXPlatformNodeBase* third_selected_node = root->GetSelectedItem(2);
+ EXPECT_EQ(second_group_child, third_selected_node->GetNativeViewAccessible());
+
+ gfx::NativeViewAccessible fourth_child = root->ChildAtIndex(3);
+ AXPlatformNodeBase* fourth_selected_node = root->GetSelectedItem(3);
+ EXPECT_EQ(fourth_child, fourth_selected_node->GetNativeViewAccessible());
+}
+
} // namespace ui
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_delegate_base.cc b/chromium/ui/accessibility/platform/ax_platform_node_delegate_base.cc
index f352bf6e0bf..8abc5a9300e 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_delegate_base.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node_delegate_base.cc
@@ -293,18 +293,20 @@ base::Optional<int> AXPlatformNodeDelegateBase::GetTableColCount() const {
}
base::Optional<int> AXPlatformNodeDelegateBase::GetTableAriaColCount() const {
- int aria_column_count =
- GetData().GetIntAttribute(ax::mojom::IntAttribute::kAriaColumnCount);
- if (aria_column_count == ax::mojom::kUnknownAriaColumnOrRowCount)
+ int aria_column_count;
+ if (!GetData().GetIntAttribute(ax::mojom::IntAttribute::kAriaColumnCount,
+ &aria_column_count)) {
return base::nullopt;
+ }
return aria_column_count;
}
base::Optional<int> AXPlatformNodeDelegateBase::GetTableAriaRowCount() const {
- int aria_row_count =
- GetData().GetIntAttribute(ax::mojom::IntAttribute::kAriaRowCount);
- if (aria_row_count == ax::mojom::kUnknownAriaColumnOrRowCount)
+ int aria_row_count;
+ if (!GetData().GetIntAttribute(ax::mojom::IntAttribute::kAriaRowCount,
+ &aria_row_count)) {
return base::nullopt;
+ }
return aria_row_count;
}
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_mac.h b/chromium/ui/accessibility/platform/ax_platform_node_mac.h
index a5624cb789a..920f0a05363 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_mac.h
+++ b/chromium/ui/accessibility/platform/ax_platform_node_mac.h
@@ -27,7 +27,6 @@ class AXPlatformNodeMac : public AXPlatformNodeBase {
// AXPlatformNodeBase.
void Destroy() override;
- int GetIndexInParent() override;
protected:
void AddAttributeToList(const char* name,
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_mac.mm b/chromium/ui/accessibility/platform/ax_platform_node_mac.mm
index 0454164364c..9a8f6f6d60a 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_mac.mm
+++ b/chromium/ui/accessibility/platform/ax_platform_node_mac.mm
@@ -56,7 +56,7 @@ RoleMap BuildRoleMap() {
{ax::mojom::Role::kColumn, NSAccessibilityColumnRole},
{ax::mojom::Role::kColumnHeader, @"AXCell"},
{ax::mojom::Role::kComboBoxGrouping, NSAccessibilityGroupRole},
- {ax::mojom::Role::kComboBoxMenuButton, NSAccessibilityButtonRole},
+ {ax::mojom::Role::kComboBoxMenuButton, NSAccessibilityPopUpButtonRole},
{ax::mojom::Role::kComment, NSAccessibilityGroupRole},
{ax::mojom::Role::kComplementary, NSAccessibilityGroupRole},
{ax::mojom::Role::kContentDeletion, NSAccessibilityGroupRole},
@@ -1257,11 +1257,6 @@ void AXPlatformNodeMac::AnnounceText(const base::string16& text) {
[native_node_ AXWindow], false);
}
-int AXPlatformNodeMac::GetIndexInParent() {
- // TODO(dmazzoni): implement this. http://crbug.com/396137
- return -1;
-}
-
bool IsNameExposedInAXValueForRole(ax::mojom::Role role) {
switch (role) {
case ax::mojom::Role::kListBoxOption:
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_textchildprovider_win_unittest.cc b/chromium/ui/accessibility/platform/ax_platform_node_textchildprovider_win_unittest.cc
index 5ce6a7914e9..167e1af7f8e 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_textchildprovider_win_unittest.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node_textchildprovider_win_unittest.cc
@@ -296,7 +296,7 @@ TEST_F(AXPlatformNodeTextChildProviderTest,
ComPtr<IRawElementProviderSimple> enclosing_element;
text_range_provider->GetEnclosingElement(&enclosing_element);
- EXPECT_EQ(text_child_of_text_text_provider_raw_.Get(),
+ EXPECT_EQ(text_child_of_root_text_provider_raw_.Get(),
enclosing_element.Get());
}
@@ -353,7 +353,7 @@ TEST_F(AXPlatformNodeTextChildProviderTest,
ComPtr<IRawElementProviderSimple> enclosing_element;
text_range_provider->GetEnclosingElement(&enclosing_element);
- EXPECT_EQ(text_child_of_text_text_provider_raw_.Get(),
+ EXPECT_EQ(text_child_of_root_text_provider_raw_.Get(),
enclosing_element.Get());
}
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.cc b/chromium/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.cc
index 36eb2cba477..ee4026570b1 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node_textrangeprovider_win.cc
@@ -213,20 +213,27 @@ HRESULT AXPlatformNodeTextRangeProviderWin::ExpandToEnclosingUnit(
end_ = start_->CreateNextFormatEndPosition(
AXBoundaryBehavior::StopIfAlreadyAtBoundary);
break;
- case TextUnit_Word:
+ case TextUnit_Word: {
+ AXPositionInstance start_backup = start_->Clone();
start_ = start_->CreatePreviousWordStartPosition(
AXBoundaryBehavior::StopIfAlreadyAtBoundary);
+ // Since we use AXBoundaryBehavior::StopIfAlreadyAtBoundary, the only case
+ // possible where CreatePreviousWordStartPosition can return a
+ // NullPosition is when it's called on a node before the first word
+ // boundary. This can happen when the document starts with nodes that have
+ // no word boundaries, like whitespaces and punctuation. When it happens,
+ // move the position back to the start of the document.
+ if (start_->IsNullPosition())
+ start_ = start_backup->CreatePositionAtStartOfDocument();
+
// Since start_ is already located at a word boundary, we need to cross it
- // in order to move to the next one (stopping at the last anchor's end).
+ // in order to move to the next one. Because Windows ATs behave
+ // undesirably when the start and end endpoints are not in the same anchor
+ // (for character and word navigation), stop at anchor boundary.
end_ = start_->CreateNextWordStartPosition(
- AXBoundaryBehavior::StopAtLastAnchorBoundary);
- // Because Windows ATs behave undesirably when the start and end endpoints
- // are not in the same anchor (for character and word navigation), make
- // sure to bring back the end endpoint to the end of the start's anchor.
- if (start_->anchor_id() != end_->anchor_id()) {
- end_ = start_->CreatePositionAtEndOfAnchor();
- }
+ AXBoundaryBehavior::StopAtAnchorBoundary);
break;
+ }
case TextUnit_Line:
start_ = start_->CreateBoundaryStartPosition(
AXBoundaryBehavior::StopIfAlreadyAtBoundary,
@@ -265,6 +272,8 @@ HRESULT AXPlatformNodeTextRangeProviderWin::ExpandToEnclosingUnit(
default:
return UIA_E_NOTSUPPORTED;
}
+ DCHECK(!start_->IsNullPosition());
+ DCHECK(!end_->IsNullPosition());
return S_OK;
}
@@ -562,7 +571,8 @@ HRESULT AXPlatformNodeTextRangeProviderWin::GetEnclosingElement(
return UIA_E_ELEMENTNOTAVAILABLE;
while (enclosing_node->GetData().IsIgnored() ||
- enclosing_node->GetData().role == ax::mojom::Role::kInlineTextBox) {
+ enclosing_node->GetData().role == ax::mojom::Role::kInlineTextBox ||
+ enclosing_node->IsChildOfLeaf()) {
AXPlatformNodeWin* parent = static_cast<AXPlatformNodeWin*>(
AXPlatformNode::FromNativeViewAccessible(enclosing_node->GetParent()));
DCHECK(parent);
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_textrangeprovider_win_unittest.cc b/chromium/ui/accessibility/platform/ax_platform_node_textrangeprovider_win_unittest.cc
index 5d29c09fa9b..13617fa8a8c 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_textrangeprovider_win_unittest.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node_textrangeprovider_win_unittest.cc
@@ -2971,13 +2971,17 @@ TEST_F(AXPlatformNodeTextRangeProviderTest,
//
// root
// |
- // paragraph_______
- // | |
- // static_text link
- // | |
- // text_node static_text
- // |
- // text_node
+ // paragraph______________________________________________
+ // | | | | |
+ // static_text link link search input pdf_highlight
+ // | | | | |
+ // text_node static_text ul text_node static_text
+ // | | |
+ // text_node li text_node
+ // |
+ // static_text
+ // |
+ // text_node
ui::AXNodeData root_data;
root_data.id = 1;
@@ -3013,6 +3017,57 @@ TEST_F(AXPlatformNodeTextRangeProviderTest,
inline_text_data2.role = ax::mojom::Role::kInlineTextBox;
static_text_data2.child_ids.push_back(inline_text_data2.id);
+ ui::AXNodeData link_data2;
+ link_data2.id = 8;
+ link_data2.role = ax::mojom::Role::kLink;
+ paragraph_data.child_ids.push_back(link_data2.id);
+
+ ui::AXNodeData list_data;
+ list_data.id = 9;
+ list_data.role = ax::mojom::Role::kList;
+ link_data2.child_ids.push_back(list_data.id);
+
+ ui::AXNodeData list_item_data;
+ list_item_data.id = 10;
+ list_item_data.role = ax::mojom::Role::kListItem;
+ list_data.child_ids.push_back(list_item_data.id);
+
+ ui::AXNodeData static_text_data3;
+ static_text_data3.id = 11;
+ static_text_data3.role = ax::mojom::Role::kStaticText;
+ list_item_data.child_ids.push_back(static_text_data3.id);
+
+ ui::AXNodeData inline_text_data3;
+ inline_text_data3.id = 12;
+ inline_text_data3.role = ax::mojom::Role::kInlineTextBox;
+ static_text_data3.child_ids.push_back(inline_text_data3.id);
+
+ ui::AXNodeData search_box;
+ search_box.id = 13;
+ search_box.role = ax::mojom::Role::kSearchBox;
+ paragraph_data.child_ids.push_back(search_box.id);
+
+ ui::AXNodeData search_text;
+ search_text.id = 14;
+ search_text.role = ax::mojom::Role::kStaticText;
+ search_text.SetName("placeholder");
+ search_box.child_ids.push_back(search_text.id);
+
+ ui::AXNodeData pdf_highlight_data;
+ pdf_highlight_data.id = 15;
+ pdf_highlight_data.role = ax::mojom::Role::kPdfActionableHighlight;
+ paragraph_data.child_ids.push_back(pdf_highlight_data.id);
+
+ ui::AXNodeData static_text_data4;
+ static_text_data4.id = 16;
+ static_text_data4.role = ax::mojom::Role::kStaticText;
+ pdf_highlight_data.child_ids.push_back(static_text_data4.id);
+
+ ui::AXNodeData inline_text_data4;
+ inline_text_data4.id = 17;
+ inline_text_data4.role = ax::mojom::Role::kInlineTextBox;
+ static_text_data4.child_ids.push_back(inline_text_data4.id);
+
ui::AXTreeUpdate update;
ui::AXTreeData tree_data;
tree_data.tree_id = ui::AXTreeID::CreateNewAXTreeID();
@@ -3026,6 +3081,16 @@ TEST_F(AXPlatformNodeTextRangeProviderTest,
update.nodes.push_back(link_data);
update.nodes.push_back(static_text_data2);
update.nodes.push_back(inline_text_data2);
+ update.nodes.push_back(link_data2);
+ update.nodes.push_back(list_data);
+ update.nodes.push_back(list_item_data);
+ update.nodes.push_back(static_text_data3);
+ update.nodes.push_back(inline_text_data3);
+ update.nodes.push_back(search_box);
+ update.nodes.push_back(search_text);
+ update.nodes.push_back(pdf_highlight_data);
+ update.nodes.push_back(static_text_data4);
+ update.nodes.push_back(inline_text_data4);
Init(update);
@@ -3036,20 +3101,46 @@ TEST_F(AXPlatformNodeTextRangeProviderTest,
AXNode* inline_text_node1 = static_text_node1->children()[0];
AXNode* static_text_node2 = link_node->children()[0];
AXNode* inline_text_node2 = static_text_node2->children()[0];
+ AXNode* link_node2 = paragraph_node->children()[2];
+ AXNode* list_node = link_node2->children()[0];
+ AXNode* list_item_node = list_node->children()[0];
+ AXNode* static_text_node3 = list_item_node->children()[0];
+ AXNode* inline_text_node3 = static_text_node3->children()[0];
+ AXNode* search_box_node = paragraph_node->children()[3];
+ AXNode* search_text_node = search_box_node->children()[0];
+ AXNode* pdf_highlight_node = paragraph_node->children()[4];
+ AXNode* static_text_node4 = pdf_highlight_node->children()[0];
+ AXNode* inline_text_node4 = static_text_node4->children()[0];
ComPtr<IRawElementProviderSimple> link_node_raw =
QueryInterfaceFromNode<IRawElementProviderSimple>(link_node);
ComPtr<IRawElementProviderSimple> static_text_node_raw1 =
QueryInterfaceFromNode<IRawElementProviderSimple>(static_text_node1);
+ ComPtr<IRawElementProviderSimple> static_text_node_raw2 =
+ QueryInterfaceFromNode<IRawElementProviderSimple>(static_text_node2);
+ ComPtr<IRawElementProviderSimple> static_text_node_raw3 =
+ QueryInterfaceFromNode<IRawElementProviderSimple>(static_text_node3);
ComPtr<IRawElementProviderSimple> inline_text_node_raw1 =
QueryInterfaceFromNode<IRawElementProviderSimple>(inline_text_node1);
ComPtr<IRawElementProviderSimple> inline_text_node_raw2 =
QueryInterfaceFromNode<IRawElementProviderSimple>(inline_text_node2);
+ ComPtr<IRawElementProviderSimple> inline_text_node_raw3 =
+ QueryInterfaceFromNode<IRawElementProviderSimple>(inline_text_node3);
+ ComPtr<IRawElementProviderSimple> search_box_node_raw =
+ QueryInterfaceFromNode<IRawElementProviderSimple>(search_box_node);
+ ComPtr<IRawElementProviderSimple> search_text_node_raw =
+ QueryInterfaceFromNode<IRawElementProviderSimple>(search_text_node);
+ ComPtr<IRawElementProviderSimple> pdf_highlight_node_raw =
+ QueryInterfaceFromNode<IRawElementProviderSimple>(pdf_highlight_node);
+ ComPtr<IRawElementProviderSimple> inline_text_node_raw4 =
+ QueryInterfaceFromNode<IRawElementProviderSimple>(inline_text_node4);
// Test GetEnclosingElement for the two leaves text nodes. The enclosing
// element of the first one should be its static text parent (because inline
// text boxes shouldn't be exposed) and the enclosing element for the text
// node that is grandchild of the link node should return the link node.
+ // The text node in the link node with a complex subtree should behave
+ // normally and return the static text parent.
ComPtr<ITextProvider> text_provider;
EXPECT_HRESULT_SUCCEEDED(inline_text_node_raw1->GetPatternProvider(
UIA_TextPatternId, &text_provider));
@@ -3072,6 +3163,43 @@ TEST_F(AXPlatformNodeTextRangeProviderTest,
EXPECT_HRESULT_SUCCEEDED(
text_range_provider->GetEnclosingElement(&enclosing_element));
EXPECT_EQ(link_node_raw.Get(), enclosing_element.Get());
+
+ EXPECT_HRESULT_SUCCEEDED(inline_text_node_raw3->GetPatternProvider(
+ UIA_TextPatternId, &text_provider));
+
+ EXPECT_HRESULT_SUCCEEDED(
+ text_provider->get_DocumentRange(&text_range_provider));
+
+ EXPECT_HRESULT_SUCCEEDED(
+ text_range_provider->GetEnclosingElement(&enclosing_element));
+ EXPECT_EQ(static_text_node_raw3.Get(), enclosing_element.Get());
+
+ // The enclosing element of a text range in the search text should give the
+ // search box
+ EXPECT_HRESULT_SUCCEEDED(search_text_node_raw->GetPatternProvider(
+ UIA_TextPatternId, &text_provider));
+
+ EXPECT_HRESULT_SUCCEEDED(
+ text_provider->get_DocumentRange(&text_range_provider));
+
+ EXPECT_HRESULT_SUCCEEDED(
+ text_range_provider->ExpandToEnclosingUnit(TextUnit_Character));
+
+ EXPECT_HRESULT_SUCCEEDED(
+ text_range_provider->GetEnclosingElement(&enclosing_element));
+ EXPECT_EQ(search_box_node_raw.Get(), enclosing_element.Get());
+
+ // The enclosing element for the text node that is grandchild of the
+ // pdf_highlight node should return the pdf_highlight node.
+ EXPECT_HRESULT_SUCCEEDED(inline_text_node_raw4->GetPatternProvider(
+ UIA_TextPatternId, &text_provider));
+
+ EXPECT_HRESULT_SUCCEEDED(
+ text_provider->get_DocumentRange(&text_range_provider));
+
+ EXPECT_HRESULT_SUCCEEDED(
+ text_range_provider->GetEnclosingElement(&enclosing_element));
+ EXPECT_EQ(pdf_highlight_node_raw.Get(), enclosing_element.Get());
}
TEST_F(AXPlatformNodeTextRangeProviderTest,
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_unittest.cc b/chromium/ui/accessibility/platform/ax_platform_node_unittest.cc
index c652b37ec7f..480a7233253 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_unittest.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node_unittest.cc
@@ -356,13 +356,13 @@ AXTreeUpdate AXPlatformNodeTest::BuildListBox(
bool option_1_is_selected,
bool option_2_is_selected,
bool option_3_is_selected,
- ax::mojom::State additional_state /* ax::mojom::State::kNone */) {
+ const std::vector<ax::mojom::State>& additional_state) {
AXNodeData listbox;
listbox.id = 1;
listbox.SetName("ListBox");
listbox.role = ax::mojom::Role::kListBox;
- if (additional_state != ax::mojom::State::kNone)
- listbox.AddState(additional_state);
+ for (auto state : additional_state)
+ listbox.AddState(state);
AXNodeData option_1;
option_1.id = 2;
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_unittest.h b/chromium/ui/accessibility/platform/ax_platform_node_unittest.h
index 3207332eb83..d004a0585eb 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_unittest.h
+++ b/chromium/ui/accessibility/platform/ax_platform_node_unittest.h
@@ -48,10 +48,11 @@ class AXPlatformNodeTest : public testing::Test, public TestAXTreeManager {
AXTreeUpdate Build3X3Table();
AXTreeUpdate BuildAriaColumnAndRowCountGrids();
- AXTreeUpdate BuildListBox(bool option_1_is_selected,
- bool option_2_is_selected,
- bool option_3_is_selected,
- ax::mojom::State additional_state);
+ AXTreeUpdate BuildListBox(
+ bool option_1_is_selected,
+ bool option_2_is_selected,
+ bool option_3_is_selected,
+ const std::vector<ax::mojom::State>& additional_state);
};
} // namespace ui
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_win.cc b/chromium/ui/accessibility/platform/ax_platform_node_win.cc
index eadcb741d94..b9fbc55ae57 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_win.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node_win.cc
@@ -30,11 +30,12 @@
#include "ui/accessibility/accessibility_switches.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_active_popup.h"
+#include "ui/accessibility/ax_constants.mojom.h"
+#include "ui/accessibility/ax_enum_util.h"
#include "ui/accessibility/ax_mode_observer.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/ax_node_position.h"
#include "ui/accessibility/ax_role_properties.h"
-#include "ui/accessibility/ax_text_utils.h"
#include "ui/accessibility/ax_tree_data.h"
#include "ui/accessibility/platform/ax_fragment_root_win.h"
#include "ui/accessibility/platform/ax_platform_node_delegate.h"
@@ -710,7 +711,7 @@ void AXPlatformNodeWin::FireUiaTextEditTextChangedEvent(
return;
}
- long index = 0;
+ LONG index = 0;
HRESULT hr =
SafeArrayPutElement(changed_data.Get(), &index, composition_text.Get());
@@ -997,8 +998,8 @@ IFACEMETHODIMP AXPlatformNodeWin::get_accDefaultAction(VARIANT var_id,
return S_FALSE;
}
- base::string16 action_verb = ActionVerbToLocalizedString(
- static_cast<ax::mojom::DefaultActionVerb>(action));
+ base::string16 action_verb = base::UTF8ToUTF16(
+ ui::ToLocalizedString(static_cast<ax::mojom::DefaultActionVerb>(action)));
if (action_verb.empty()) {
*def_action = nullptr;
return S_FALSE;
@@ -1370,10 +1371,11 @@ IFACEMETHODIMP AXPlatformNodeWin::get_attributes(BSTR* attributes) {
IFACEMETHODIMP AXPlatformNodeWin::get_indexInParent(LONG* index_in_parent) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_INDEX_IN_PARENT);
COM_OBJECT_VALIDATE_1_ARG(index_in_parent);
- *index_in_parent = GetIndexInParent();
- if (*index_in_parent < 0)
+ base::Optional<int> index = GetIndexInParent();
+ if (!index.has_value())
return E_FAIL;
+ *index_in_parent = index.value();
return S_OK;
}
@@ -1763,18 +1765,20 @@ IFACEMETHODIMP AXPlatformNodeWin::Expand() {
ExpandCollapseState AXPlatformNodeWin::ComputeExpandCollapseState() const {
const AXNodeData& data = GetData();
- const bool is_menu_button = data.GetHasPopup() == ax::mojom::HasPopup::kMenu;
- const bool is_expanded_menu_button =
- is_menu_button &&
- data.GetCheckedState() == ax::mojom::CheckedState::kTrue;
- const bool is_collapsed_menu_button =
- is_menu_button &&
- data.GetCheckedState() != ax::mojom::CheckedState::kTrue;
-
- if (data.HasState(ax::mojom::State::kExpanded) || is_expanded_menu_button) {
+
+ // Since a menu button implies there is a popup and it is either expanded or
+ // collapsed, and it should not support ExpandCollapseState_LeafNode.
+ // According to the UIA spec, ExpandCollapseState_LeafNode indicates that the
+ // element neither expands nor collapses.
+ if (data.IsMenuButton()) {
+ if (data.IsButtonPressed())
+ return ExpandCollapseState_Expanded;
+ return ExpandCollapseState_Collapsed;
+ }
+
+ if (data.HasState(ax::mojom::State::kExpanded)) {
return ExpandCollapseState_Expanded;
- } else if (data.HasState(ax::mojom::State::kCollapsed) ||
- is_collapsed_menu_button) {
+ } else if (data.HasState(ax::mojom::State::kCollapsed)) {
return ExpandCollapseState_Collapsed;
} else {
return ExpandCollapseState_LeafNode;
@@ -1877,6 +1881,9 @@ IFACEMETHODIMP AXPlatformNodeWin::get_RowCount(int* result) {
base::Optional<int> row_count = GetTableAriaRowCount();
if (!row_count)
+ row_count = GetTableRowCount();
+
+ if (!row_count || *row_count == ax::mojom::kUnknownAriaColumnOrRowCount)
return E_UNEXPECTED;
*result = *row_count;
return S_OK;
@@ -1888,7 +1895,12 @@ IFACEMETHODIMP AXPlatformNodeWin::get_ColumnCount(int* result) {
base::Optional<int> column_count = GetTableAriaColumnCount();
if (!column_count)
+ column_count = GetTableColumnCount();
+
+ if (!column_count ||
+ *column_count == ax::mojom::kUnknownAriaColumnOrRowCount) {
return E_UNEXPECTED;
+ }
*result = *column_count;
return S_OK;
}
@@ -2131,15 +2143,10 @@ IFACEMETHODIMP AXPlatformNodeWin::GetSelection(SAFEARRAY** result) {
WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_SELECTION_GETSELECTION);
UIA_VALIDATE_CALL_1_ARG(result);
- std::vector<AXPlatformNodeWin*> selected_children;
- LONG child_count = GetDelegate()->GetChildCount();
- for (LONG i = 0; i < child_count; ++i) {
- auto* child = static_cast<AXPlatformNodeWin*>(
- FromNativeViewAccessible(GetDelegate()->ChildAtIndex(i)));
- DCHECK(child);
- if (child->GetData().GetBoolAttribute(ax::mojom::BoolAttribute::kSelected))
- selected_children.push_back(child);
- }
+ std::vector<AXPlatformNodeBase*> selected_children;
+ int max_items = GetMaxSelectableItems();
+ if (max_items)
+ GetSelectedItems(max_items, &selected_children);
LONG selected_children_count = selected_children.size();
*result = SafeArrayCreateVector(VT_UNKNOWN, 0, selected_children_count);
@@ -2147,9 +2154,10 @@ IFACEMETHODIMP AXPlatformNodeWin::GetSelection(SAFEARRAY** result) {
return E_OUTOFMEMORY;
for (LONG i = 0; i < selected_children_count; ++i) {
+ AXPlatformNodeWin* children =
+ static_cast<AXPlatformNodeWin*>(selected_children[i]);
HRESULT hr = SafeArrayPutElement(
- *result, &i,
- static_cast<IRawElementProviderSimple*>(selected_children[i]));
+ *result, &i, static_cast<IRawElementProviderSimple*>(children));
if (FAILED(hr)) {
SafeArrayDestroy(*result);
*result = nullptr;
@@ -4166,15 +4174,10 @@ IFACEMETHODIMP AXPlatformNodeWin::GetPropertyValue(PROPERTYID property_id,
}
case UIA_LabeledByPropertyId:
- for (int32_t id : data.GetIntListAttribute(
- ax::mojom::IntListAttribute::kLabelledbyIds)) {
- auto* node_win = GetDelegate()->GetFromNodeID(id);
- if (IsValidUiaRelationTarget(node_win)) {
- result->vt = VT_UNKNOWN;
- result->punkVal = node_win->GetNativeViewAccessible();
- result->punkVal->AddRef();
- break;
- }
+ if (AXPlatformNodeWin* node = ComputeUIALabeledBy()) {
+ result->vt = VT_UNKNOWN;
+ result->punkVal = node->GetNativeViewAccessible();
+ result->punkVal->AddRef();
}
break;
@@ -4473,9 +4476,6 @@ STDMETHODIMP AXPlatformNodeWin::InternalQueryInterface(
HRESULT AXPlatformNodeWin::GetTextAttributeValue(TEXTATTRIBUTEID attribute_id,
VARIANT* result) {
- // This should only be called on nodes actually in the tree
- DCHECK(!GetDelegate()->IsChildOfLeaf());
-
switch (attribute_id) {
case UIA_BackgroundColorAttributeId:
V_VT(result) = VT_I4;
@@ -4735,9 +4735,11 @@ int AXPlatformNodeWin::MSAARole() {
switch (GetData().role) {
case ax::mojom::Role::kAlert:
- case ax::mojom::Role::kAlertDialog:
return ROLE_SYSTEM_ALERT;
+ case ax::mojom::Role::kAlertDialog:
+ return ROLE_SYSTEM_DIALOG;
+
case ax::mojom::Role::kAnchor:
return ROLE_SYSTEM_LINK;
@@ -5222,6 +5224,7 @@ int AXPlatformNodeWin::MSAARole() {
// hierarchy, matching the HWND.
return ROLE_SYSTEM_PANE;
+ case ax::mojom::Role::kImeCandidate:
case ax::mojom::Role::kIgnored:
case ax::mojom::Role::kKeyboard:
case ax::mojom::Role::kNone:
@@ -5778,6 +5781,10 @@ base::string16 AXPlatformNodeWin::UIAAriaRole() {
case ax::mojom::Role::kImageMap:
return L"document";
+ case ax::mojom::Role::kImeCandidate:
+ // Internal role, not used on Windows.
+ return L"group";
+
case ax::mojom::Role::kInputTime:
return L"group";
@@ -6705,6 +6712,7 @@ LONG AXPlatformNodeWin::ComputeUIAControlType() { // NOLINT(runtime/int)
case ax::mojom::Role::kPane:
case ax::mojom::Role::kWindow:
case ax::mojom::Role::kIgnored:
+ case ax::mojom::Role::kImeCandidate:
case ax::mojom::Role::kKeyboard:
case ax::mojom::Role::kNone:
case ax::mojom::Role::kPresentational:
@@ -6716,6 +6724,68 @@ LONG AXPlatformNodeWin::ComputeUIAControlType() { // NOLINT(runtime/int)
return UIA_DocumentControlTypeId;
}
+AXPlatformNodeWin* AXPlatformNodeWin::ComputeUIALabeledBy() {
+ // Not all control types expect a value for this property.
+ if (!CanHaveUIALabeledBy())
+ return nullptr;
+
+ // This property only accepts static text elements to be returned. Find the
+ // first static text used to label this node.
+ for (int32_t id : GetData().GetIntListAttribute(
+ ax::mojom::IntListAttribute::kLabelledbyIds)) {
+ auto* node_win =
+ static_cast<AXPlatformNodeWin*>(GetDelegate()->GetFromNodeID(id));
+ if (!node_win)
+ continue;
+
+ // If this node is a static text, then simply return the node itself.
+ if (IsValidUiaRelationTarget(node_win) &&
+ node_win->GetData().role == ax::mojom::Role::kStaticText) {
+ return node_win;
+ }
+
+ // Otherwise, find the first static text node in its descendants.
+ for (auto iter = node_win->GetDelegate()->ChildrenBegin();
+ *iter != *node_win->GetDelegate()->ChildrenEnd(); ++(*iter)) {
+ AXPlatformNodeWin* child = static_cast<AXPlatformNodeWin*>(
+ AXPlatformNode::FromNativeViewAccessible(
+ iter->GetNativeViewAccessible()));
+ if (IsValidUiaRelationTarget(child) &&
+ child->GetData().role == ax::mojom::Role::kStaticText) {
+ return child;
+ }
+ }
+ }
+
+ return nullptr;
+}
+
+bool AXPlatformNodeWin::CanHaveUIALabeledBy() {
+ // Not all control types expect a value for this property. See
+ // https://docs.microsoft.com/en-us/windows/win32/winauto/uiauto-supportinguiautocontroltypes
+ // for a complete list of control types. Each one of them has specific
+ // expectations regarding the UIA_LabeledByPropertyId.
+ switch (ComputeUIAControlType()) {
+ case UIA_ButtonControlTypeId:
+ case UIA_CheckBoxControlTypeId:
+ case UIA_DataItemControlTypeId:
+ case UIA_MenuControlTypeId:
+ case UIA_MenuBarControlTypeId:
+ case UIA_RadioButtonControlTypeId:
+ case UIA_ScrollBarControlTypeId:
+ case UIA_SeparatorControlTypeId:
+ case UIA_StatusBarControlTypeId:
+ case UIA_TabItemControlTypeId:
+ case UIA_TextControlTypeId:
+ case UIA_ToolBarControlTypeId:
+ case UIA_ToolTipControlTypeId:
+ case UIA_TreeItemControlTypeId:
+ return false;
+ default:
+ return true;
+ }
+}
+
bool AXPlatformNodeWin::IsNameExposed() const {
const AXNodeData& data = GetData();
switch (data.role) {
@@ -6901,8 +6971,19 @@ bool AXPlatformNodeWin::ShouldHideChildrenForUIA() const {
// TODO(bebeaudr): We might be able to remove ax::mojom::Role::kLink once
// http://crbug.com/1054514 is fixed. Links should not have to hide their
// children.
+ // TODO(virens): |kPdfActionableHighlight| needs to follow a fix similar to
+ // links. At present Pdf highlghts have text nodes as children. But, we may
+ // enable pdf highlights to have complex children like links based on user
+ // feedback.
case ax::mojom::Role::kLink:
+ // Links with a single text-only child should hide their subtree.
+ if (GetChildCount() == 1) {
+ AXPlatformNodeBase* only_child = GetFirstChild();
+ return only_child && only_child->IsTextOnlyObject();
+ }
+ return false;
case ax::mojom::Role::kTextField:
+ case ax::mojom::Role::kPdfActionableHighlight:
return true;
default:
return false;
@@ -7133,6 +7214,7 @@ base::Optional<DWORD> AXPlatformNodeWin::MojoEventToMSAAEvent(
return EVENT_SYSTEM_ALERT;
case ax::mojom::Event::kCheckedStateChanged:
case ax::mojom::Event::kExpandedChanged:
+ case ax::mojom::Event::kStateChanged:
return EVENT_OBJECT_STATECHANGE;
case ax::mojom::Event::kFocus:
case ax::mojom::Event::kFocusContext:
@@ -7209,6 +7291,9 @@ base::Optional<PROPERTYID> AXPlatformNodeWin::MojoEventToUIAProperty(
return UIA_ControllerForPropertyId;
case ax::mojom::Event::kCheckedStateChanged:
return UIA_ToggleToggleStatePropertyId;
+ case ax::mojom::Event::kRowCollapsed:
+ case ax::mojom::Event::kRowExpanded:
+ return UIA_ExpandCollapseExpandCollapseStatePropertyId;
default:
return base::nullopt;
}
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_win.h b/chromium/ui/accessibility/platform/ax_platform_node_win.h
index 2f8238802c6..1055422d59c 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_win.h
+++ b/chromium/ui/accessibility/platform/ax_platform_node_win.h
@@ -1100,6 +1100,10 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
LONG ComputeUIAControlType();
+ AXPlatformNodeWin* ComputeUIALabeledBy();
+
+ bool CanHaveUIALabeledBy();
+
bool IsNameExposed() const;
bool IsUIAControl() const;
@@ -1154,7 +1158,7 @@ class AX_EXPORT __declspec(uuid("26f5641a-246d-457b-a96d-07f3fae6acf2"))
static void SanitizeStringAttributeForIA2(const std::string& input,
std::string* output);
FRIEND_TEST_ALL_PREFIXES(AXPlatformNodeWinTest,
- TestSanitizeStringAttributeForIA2);
+ SanitizeStringAttributeForIA2);
private:
bool IsWebAreaForPresentationalIframe();
diff --git a/chromium/ui/accessibility/platform/ax_platform_node_win_unittest.cc b/chromium/ui/accessibility/platform/ax_platform_node_win_unittest.cc
index 4a1df770606..50b78af9642 100644
--- a/chromium/ui/accessibility/platform/ax_platform_node_win_unittest.cc
+++ b/chromium/ui/accessibility/platform/ax_platform_node_win_unittest.cc
@@ -448,7 +448,7 @@ bool TestFragmentRootDelegate::IsAXFragmentRootAControlElement() {
return is_control_element_;
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleDetachedObject) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleDetachedObject) {
AXNodeData root;
root.id = 1;
root.SetName("Name");
@@ -465,7 +465,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleDetachedObject) {
EXPECT_EQ(E_FAIL, root_obj->get_accName(SELF, name2.Receive()));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleHitTest) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleHitTest) {
AXNodeData root;
root.id = 1;
root.relative_bounds.bounds = gfx::RectF(0, 0, 40, 40);
@@ -505,7 +505,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleHitTest) {
CheckVariantHasName(obj_2, L"Name2");
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleHitTestDoesNotLoopForever) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleHitTestDoesNotLoopForever) {
AXNodeData root;
root.id = 1;
root.relative_bounds.bounds = gfx::RectF(0, 0, 40, 40);
@@ -532,7 +532,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleHitTestDoesNotLoopForever) {
CheckVariantHasName(obj_1, L"Name1");
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleName) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleName) {
AXNodeData root;
root.id = 1;
root.SetName("Name");
@@ -549,7 +549,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleName) {
EXPECT_EQ(E_INVALIDARG, root_obj->get_accName(bad_id, name2.Receive()));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleDescription) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleDescription) {
AXNodeData root;
root.id = 1;
root.AddStringAttribute(ax::mojom::StringAttribute::kDescription,
@@ -567,7 +567,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleDescription) {
EXPECT_EQ(E_INVALIDARG, root_obj->get_accDescription(bad_id, d2.Receive()));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleAccValue) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleAccValue) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kTextField;
@@ -585,7 +585,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleAccValue) {
EXPECT_EQ(E_INVALIDARG, root_obj->get_accValue(bad_id, v2.Receive()));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleShortcut) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleShortcut) {
AXNodeData root;
root.id = 1;
root.AddStringAttribute(ax::mojom::StringAttribute::kKeyShortcuts,
@@ -605,7 +605,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleShortcut) {
}
TEST_F(AXPlatformNodeWinTest,
- TestIAccessibleSelectionListBoxOptionNothingSelected) {
+ IAccessibleSelectionListBoxOptionNothingSelected) {
AXNodeData list;
list.id = 1;
list.role = ax::mojom::Role::kListBox;
@@ -633,8 +633,7 @@ TEST_F(AXPlatformNodeWinTest,
EXPECT_EQ(VT_EMPTY, selection.type());
}
-TEST_F(AXPlatformNodeWinTest,
- TestIAccessibleSelectionListBoxOptionOneSelected) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleSelectionListBoxOptionOneSelected) {
AXNodeData list;
list.id = 1;
list.role = ax::mojom::Role::kListBox;
@@ -666,7 +665,7 @@ TEST_F(AXPlatformNodeWinTest,
}
TEST_F(AXPlatformNodeWinTest,
- TestIAccessibleSelectionListBoxOptionMultipleSelected) {
+ IAccessibleSelectionListBoxOptionMultipleSelected) {
AXNodeData list;
list.id = 1;
list.role = ax::mojom::Role::kListBox;
@@ -747,7 +746,7 @@ TEST_F(AXPlatformNodeWinTest,
}
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleSelectionTableNothingSelected) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleSelectionTableNothingSelected) {
Init(Build3X3Table());
ComPtr<IAccessible> root_obj(GetRootIAccessible());
@@ -758,7 +757,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleSelectionTableNothingSelected) {
EXPECT_EQ(VT_EMPTY, selection.type());
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleSelectionTableRowOneSelected) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleSelectionTableRowOneSelected) {
AXTreeUpdate update = Build3X3Table();
// 5 == table_row_1
@@ -784,8 +783,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleSelectionTableRowOneSelected) {
EXPECT_EQ(ROLE_SYSTEM_ROW, V_I4(role.ptr()));
}
-TEST_F(AXPlatformNodeWinTest,
- TestIAccessibleSelectionTableRowMultipleSelected) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleSelectionTableRowMultipleSelected) {
AXTreeUpdate update = Build3X3Table();
// 5 == table_row_1
@@ -848,7 +846,7 @@ TEST_F(AXPlatformNodeWinTest,
}
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleSelectionTableCellOneSelected) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleSelectionTableCellOneSelected) {
AXTreeUpdate update = Build3X3Table();
// 7 == table_cell_1
@@ -884,8 +882,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleSelectionTableCellOneSelected) {
EXPECT_STREQ(L"1", name.Get());
}
-TEST_F(AXPlatformNodeWinTest,
- TestIAccessibleSelectionTableCellMultipleSelected) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleSelectionTableCellMultipleSelected) {
AXTreeUpdate update = Build3X3Table();
// 11 == table_cell_3
@@ -954,7 +951,7 @@ TEST_F(AXPlatformNodeWinTest,
}
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleRole) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleRole) {
AXNodeData root;
root.id = 1;
root.child_ids.push_back(2);
@@ -989,7 +986,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleRole) {
child_iaccessible->get_accRole(bad_id, role.Receive()));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleLocation) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleLocation) {
AXNodeData root;
root.id = 1;
root.relative_bounds.bounds = gfx::RectF(10, 40, 800, 600);
@@ -1021,7 +1018,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleLocation) {
TestAXNodeWrapper::SetGlobalCoordinateOffset(gfx::Vector2d(0, 0));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleChildAndParent) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleChildAndParent) {
AXNodeData root;
root.id = 1;
root.child_ids.push_back(2);
@@ -1126,7 +1123,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleChildAndParent) {
}
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessible2IndexInParent) {
+TEST_F(AXPlatformNodeWinTest, IAccessible2IndexInParent) {
AXNodeData root;
root.id = 1;
root.child_ids.push_back(2);
@@ -1149,8 +1146,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2IndexInParent) {
ComPtr<IAccessible2> right_iaccessible2 = ToIAccessible2(right_iaccessible);
LONG index;
- EXPECT_EQ(S_OK, root_iaccessible2->get_indexInParent(&index));
- EXPECT_EQ(0, index);
+ EXPECT_EQ(E_FAIL, root_iaccessible2->get_indexInParent(&index));
EXPECT_EQ(S_OK, left_iaccessible2->get_indexInParent(&index));
EXPECT_EQ(0, index);
@@ -1159,7 +1155,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2IndexInParent) {
EXPECT_EQ(1, index);
}
-TEST_F(AXPlatformNodeWinTest, TestAccNavigate) {
+TEST_F(AXPlatformNodeWinTest, AccNavigate) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -1261,7 +1257,7 @@ TEST_F(AXPlatformNodeWinTest, TestAccNavigate) {
EXPECT_EQ(VT_EMPTY, end.type());
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessible2TextFieldSetSelection) {
+TEST_F(AXPlatformNodeWinTest, IAccessible2TextFieldSetSelection) {
Init(BuildTextField());
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
@@ -1283,7 +1279,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2TextFieldSetSelection) {
// to AXPlatformNodeWin because |hypertext_| is only initialized
// on the BrowserAccessibility side.
TEST_F(AXPlatformNodeWinTest,
- DISABLED_TestIAccessible2ContentEditableSetSelection) {
+ DISABLED_IAccessible2ContentEditableSetSelection) {
Init(BuildContentEditable());
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
@@ -1301,7 +1297,7 @@ TEST_F(AXPlatformNodeWinTest,
EXPECT_HRESULT_FAILED(content_editable->setSelection(0, 0, 50));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetAccessibilityAt) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetAccessibilityAt) {
Init(Build3X3Table());
ComPtr<IAccessible> root_obj(GetRootIAccessible());
@@ -1327,8 +1323,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetAccessibilityAt) {
CheckIUnknownHasName(cell_4, L"4");
}
-TEST_F(AXPlatformNodeWinTest,
- TestIAccessibleTableGetAccessibilityAtOutOfBounds) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetAccessibilityAtOutOfBounds) {
Init(Build3X3Table());
ComPtr<IAccessible> root_obj(GetRootIAccessible());
@@ -1362,7 +1357,7 @@ TEST_F(AXPlatformNodeWinTest,
}
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableQueryInterfaceOnNonTable) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableQueryInterfaceOnNonTable) {
ComPtr<IAccessibleTable> table;
ComPtr<IAccessibleTable2> table2;
@@ -1385,7 +1380,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableQueryInterfaceOnNonTable) {
EXPECT_EQ(E_NOINTERFACE, cell->QueryInterface(IID_PPV_ARGS(&table2)));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellQueryInterfaceOnNonCell) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableCellQueryInterfaceOnNonCell) {
Init(Build3X3Table());
ComPtr<IAccessible> root_obj = GetRootIAccessible();
@@ -1393,7 +1388,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellQueryInterfaceOnNonCell) {
EXPECT_EQ(E_NOINTERFACE, root_obj->QueryInterface(IID_PPV_ARGS(&cell)));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessible2ScrollToPoint) {
+TEST_F(AXPlatformNodeWinTest, IAccessible2ScrollToPoint) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -1445,7 +1440,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2ScrollToPoint) {
EXPECT_EQ(10, height);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessible2ScrollTo) {
+TEST_F(AXPlatformNodeWinTest, IAccessible2ScrollTo) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -1486,7 +1481,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2ScrollTo) {
EXPECT_EQ(10, height);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetChildIndex) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetChildIndex) {
Init(Build3X3Table());
ComPtr<IAccessible> root_obj(GetRootIAccessible());
@@ -1514,7 +1509,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetChildIndex) {
EXPECT_EQ(E_INVALIDARG, result->get_childIndex(5, 5, &id));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetColumnDescription) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetColumnDescription) {
Init(Build3X3Table());
ComPtr<IAccessible> root_obj(GetRootIAccessible());
@@ -1540,7 +1535,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetColumnDescription) {
}
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetColumnExtentAt) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetColumnExtentAt) {
// TODO(dougt) This table doesn't have any spanning cells. This test
// tests get_columnExtentAt for (1) and an invalid input.
Init(Build3X3Table());
@@ -1558,7 +1553,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetColumnExtentAt) {
EXPECT_EQ(E_INVALIDARG, result->get_columnExtentAt(-1, -1, &columns_spanned));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetColumnIndex) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetColumnIndex) {
Init(Build3X3Table());
ComPtr<IAccessible> root_obj(GetRootIAccessible());
@@ -1576,7 +1571,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetColumnIndex) {
EXPECT_EQ(E_INVALIDARG, result->get_columnIndex(-1, &index));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNColumns) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetNColumns) {
Init(Build3X3Table());
ComPtr<IAccessible> root_obj(GetRootIAccessible());
@@ -1590,7 +1585,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNColumns) {
EXPECT_EQ(count, 3);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNRows) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetNRows) {
Init(Build3X3Table());
ComPtr<IAccessible> root_obj(GetRootIAccessible());
@@ -1604,7 +1599,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNRows) {
EXPECT_EQ(count, 3);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowDescription) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetRowDescription) {
Init(Build3X3Table());
ComPtr<IAccessible> root_obj(GetRootIAccessible());
@@ -1631,7 +1626,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowDescription) {
}
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowExtentAt) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetRowExtentAt) {
// TODO(dougt) This table doesn't have any spanning cells. This test
// tests get_rowExtentAt for (1) and an invalid input.
Init(Build3X3Table());
@@ -1649,7 +1644,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowExtentAt) {
EXPECT_EQ(E_INVALIDARG, result->get_columnExtentAt(-1, -1, &rows_spanned));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowIndex) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetRowIndex) {
Init(Build3X3Table());
ComPtr<IAccessible> root_obj(GetRootIAccessible());
@@ -1667,7 +1662,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowIndex) {
EXPECT_EQ(E_INVALIDARG, result->get_rowIndex(-1, &index));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowColumnExtentsAtIndex) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetRowColumnExtentsAtIndex) {
Init(Build3X3Table());
ComPtr<IAccessible> root_obj(GetRootIAccessible());
@@ -1693,7 +1688,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetRowColumnExtentsAtIndex) {
&column_extents, &is_selected));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetCellAt) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetCellAt) {
Init(Build3X3Table());
ComPtr<IAccessible> root_obj(GetRootIAccessible());
@@ -1714,7 +1709,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetCellAt) {
}
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetColumnExtent) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableCellGetColumnExtent) {
Init(Build3X3Table());
ComPtr<IAccessibleTableCell> cell = GetCellInTable();
@@ -1725,7 +1720,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetColumnExtent) {
EXPECT_EQ(1, column_spanned);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetColumnHeaderCells) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableCellGetColumnHeaderCells) {
Init(Build3X3Table());
ComPtr<IAccessibleTableCell> cell = GetCellInTable();
@@ -1739,7 +1734,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetColumnHeaderCells) {
EXPECT_EQ(1, number_cells);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetColumnIndex) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableCellGetColumnIndex) {
Init(Build3X3Table());
ComPtr<IAccessibleTableCell> cell = GetCellInTable();
@@ -1750,7 +1745,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetColumnIndex) {
EXPECT_EQ(index, 1);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowExtent) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableCellGetRowExtent) {
Init(Build3X3Table());
ComPtr<IAccessibleTableCell> cell = GetCellInTable();
@@ -1761,7 +1756,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowExtent) {
EXPECT_EQ(rows_spanned, 1);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowHeaderCells) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableCellGetRowHeaderCells) {
Init(Build3X3Table());
ComPtr<IAccessibleTableCell> cell = GetCellInTable();
@@ -1774,7 +1769,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowHeaderCells) {
EXPECT_EQ(number_cells, 1);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowIndex) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableCellGetRowIndex) {
Init(Build3X3Table());
ComPtr<IAccessibleTableCell> cell = GetCellInTable();
@@ -1785,7 +1780,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowIndex) {
EXPECT_EQ(index, 1);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowColumnExtent) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableCellGetRowColumnExtent) {
Init(Build3X3Table());
ComPtr<IAccessibleTableCell> cell = GetCellInTable();
@@ -1802,7 +1797,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetRowColumnExtent) {
EXPECT_FALSE(is_selected);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetTable) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableCellGetTable) {
Init(Build3X3Table());
ComPtr<IAccessibleTableCell> cell = GetCellInTable();
@@ -1821,7 +1816,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableCellGetTable) {
CheckIUnknownHasName(cell_1, L"1");
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessible2GetNRelations) {
+TEST_F(AXPlatformNodeWinTest, IAccessible2GetNRelations) {
// This is is a duplicated of
// BrowserAccessibilityTest::TestIAccessible2Relations but without the
// specific COM/BrowserAccessibility knowledge.
@@ -2020,7 +2015,7 @@ TEST_F(AXPlatformNodeWinTest, DISABLED_TestRelationTargetsOfType) {
}
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedChildrenZero) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetNSelectedChildrenZero) {
Init(Build3X3Table());
ComPtr<IAccessibleTableCell> cell = GetCellInTable();
@@ -2038,7 +2033,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedChildrenZero) {
EXPECT_EQ(0, selectedChildren);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedChildrenOne) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetNSelectedChildrenOne) {
AXTreeUpdate update = Build3X3Table();
// 7 == table_cell_1
@@ -2060,7 +2055,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedChildrenOne) {
EXPECT_EQ(1, selectedChildren);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedChildrenMany) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetNSelectedChildrenMany) {
AXTreeUpdate update = Build3X3Table();
// 7 == table_cell_1
@@ -2089,7 +2084,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedChildrenMany) {
EXPECT_EQ(4, selectedChildren);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedColumnsZero) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetNSelectedColumnsZero) {
Init(Build3X3Table());
ComPtr<IAccessibleTableCell> cell = GetCellInTable();
@@ -2107,7 +2102,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedColumnsZero) {
EXPECT_EQ(0, selectedColumns);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedColumnsOne) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetNSelectedColumnsOne) {
AXTreeUpdate update = Build3X3Table();
// 3 == table_column_header_2
@@ -2134,7 +2129,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedColumnsOne) {
EXPECT_EQ(1, selectedColumns);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedColumnsMany) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetNSelectedColumnsMany) {
AXTreeUpdate update = Build3X3Table();
// 3 == table_column_header_2
@@ -2168,7 +2163,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedColumnsMany) {
EXPECT_EQ(2, selectedColumns);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedRowsZero) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetNSelectedRowsZero) {
Init(Build3X3Table());
ComPtr<IAccessibleTableCell> cell = GetCellInTable();
@@ -2186,7 +2181,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedRowsZero) {
EXPECT_EQ(0, selectedRows);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedRowsOne) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetNSelectedRowsOne) {
AXTreeUpdate update = Build3X3Table();
// 6 == table_row_header_1
@@ -2213,7 +2208,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedRowsOne) {
EXPECT_EQ(1, selectedRows);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedRowsMany) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetNSelectedRowsMany) {
AXTreeUpdate update = Build3X3Table();
// 6 == table_row_header_3
@@ -2247,7 +2242,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetNSelectedRowsMany) {
EXPECT_EQ(2, selectedRows);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedChildren) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetSelectedChildren) {
AXTreeUpdate update = Build3X3Table();
// 7 == table_cell_1
@@ -2276,7 +2271,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedChildren) {
EXPECT_EQ(8, indices[1]);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedChildrenZeroMax) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetSelectedChildrenZeroMax) {
AXTreeUpdate update = Build3X3Table();
// 7 == table_cell_1
@@ -2301,7 +2296,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedChildrenZeroMax) {
EXPECT_EQ(E_INVALIDARG, result->get_selectedChildren(0, &indices, &count));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedColumnsZero) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetSelectedColumnsZero) {
AXTreeUpdate update = Build3X3Table();
// 7 == table_cell_1
@@ -2329,7 +2324,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedColumnsZero) {
EXPECT_EQ(0, n_columns);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedColumnsOne) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetSelectedColumnsOne) {
AXTreeUpdate update = Build3X3Table();
// 3 == table_column_header_2
@@ -2360,7 +2355,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedColumnsOne) {
EXPECT_EQ(1, columns[0]);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedColumnsMany) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetSelectedColumnsMany) {
AXTreeUpdate update = Build3X3Table();
// 3 == table_column_header_2
@@ -2399,7 +2394,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedColumnsMany) {
EXPECT_EQ(2, columns[1]);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedRowsZero) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetSelectedRowsZero) {
Init(Build3X3Table());
ComPtr<IAccessibleTableCell> cell = GetCellInTable();
@@ -2419,7 +2414,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedRowsZero) {
EXPECT_EQ(0, n_rows);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedRowsOne) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetSelectedRowsOne) {
AXTreeUpdate update = Build3X3Table();
// 6 == table_row_header_1
@@ -2449,7 +2444,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedRowsOne) {
EXPECT_EQ(1, rows[0]);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedRowsMany) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableGetSelectedRowsMany) {
AXTreeUpdate update = Build3X3Table();
// 6 == table_row_header_3
@@ -2487,7 +2482,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableGetSelectedRowsMany) {
EXPECT_EQ(2, rows[1]);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableIsColumnSelected) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableIsColumnSelected) {
AXTreeUpdate update = Build3X3Table();
// 3 == table_column_header_2
@@ -2523,7 +2518,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableIsColumnSelected) {
EXPECT_EQ(E_INVALIDARG, result->get_isColumnSelected(-3, &selected));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableIsRowSelected) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableIsRowSelected) {
AXTreeUpdate update = Build3X3Table();
// 6 == table_row_header_3
@@ -2559,7 +2554,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableIsRowSelected) {
EXPECT_EQ(E_INVALIDARG, result->get_isRowSelected(-3, &selected));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableIsSelected) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTableIsSelected) {
AXTreeUpdate update = Build3X3Table();
// 6 == table_row_header_3
@@ -2605,7 +2600,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTableIsSelected) {
EXPECT_EQ(E_INVALIDARG, result->get_isSelected(1, 4, &selected));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTable2GetSelectedChildrenZero) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTable2GetSelectedChildrenZero) {
Init(Build3X3Table());
ComPtr<IAccessibleTableCell> cell = GetCellInTable();
@@ -2624,7 +2619,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTable2GetSelectedChildrenZero) {
EXPECT_EQ(0, count);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTable2GetSelectedChildren) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTable2GetSelectedChildren) {
AXTreeUpdate update = Build3X3Table();
// 7 == table_cell_1
@@ -2656,7 +2651,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTable2GetSelectedChildren) {
CheckIUnknownHasName(table_cell_4, L"4");
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessible2GetGroupPosition) {
+TEST_F(AXPlatformNodeWinTest, IAccessible2GetGroupPosition) {
AXNodeData root;
root.id = 1;
root.AddIntAttribute(ax::mojom::IntAttribute::kHierarchicalLevel, 1);
@@ -2676,7 +2671,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2GetGroupPosition) {
iaccessible2->get_groupPosition(nullptr, nullptr, nullptr));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessible2GetLocalizedExtendedRole) {
+TEST_F(AXPlatformNodeWinTest, IAccessible2GetLocalizedExtendedRole) {
AXNodeData root;
root.id = 1;
root.AddStringAttribute(ax::mojom::StringAttribute::kRoleDescription,
@@ -2690,7 +2685,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessible2GetLocalizedExtendedRole) {
EXPECT_STREQ(L"extended role", role.Get());
}
-TEST_F(AXPlatformNodeWinTest, TestUnlabeledImageRoleDescription) {
+TEST_F(AXPlatformNodeWinTest, UnlabeledImageRoleDescription) {
AXTreeUpdate tree;
tree.root_id = 1;
tree.nodes.resize(3);
@@ -2726,7 +2721,7 @@ TEST_F(AXPlatformNodeWinTest, TestUnlabeledImageRoleDescription) {
}
}
-TEST_F(AXPlatformNodeWinTest, TestUnlabeledImageAttributes) {
+TEST_F(AXPlatformNodeWinTest, UnlabeledImageAttributes) {
AXTreeUpdate tree;
tree.root_id = 1;
tree.nodes.resize(3);
@@ -2766,7 +2761,7 @@ TEST_F(AXPlatformNodeWinTest, TestUnlabeledImageAttributes) {
}
}
-TEST_F(AXPlatformNodeWinTest, TestAnnotatedImageName) {
+TEST_F(AXPlatformNodeWinTest, AnnotatedImageName) {
std::vector<const wchar_t*> expected_names;
AXTreeUpdate tree;
@@ -2907,7 +2902,7 @@ TEST_F(AXPlatformNodeWinTest, TestAnnotatedImageName) {
}
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTextGetNCharacters) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTextGetNCharacters) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -2933,7 +2928,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTextGetNCharacters) {
EXPECT_EQ(4, count);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTextGetOffsetAtPoint) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTextGetOffsetAtPoint) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kWebArea;
@@ -3081,7 +3076,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTextGetOffsetAtPoint) {
EXPECT_EQ(5, offset_result);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTextTextFieldRemoveSelection) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTextTextFieldRemoveSelection) {
Init(BuildTextFieldWithSelectionRange(1, 2));
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
@@ -3102,8 +3097,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTextTextFieldRemoveSelection) {
text_field->get_selection(0, &start_offset, &end_offset));
}
-TEST_F(AXPlatformNodeWinTest,
- TestIAccessibleTextContentEditableRemoveSelection) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTextContentEditableRemoveSelection) {
Init(BuildTextFieldWithSelectionRange(1, 2));
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
@@ -3124,7 +3118,7 @@ TEST_F(AXPlatformNodeWinTest,
text_field->get_selection(0, &start_offset, &end_offset));
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTextTextFieldGetSelected) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTextTextFieldGetSelected) {
Init(BuildTextFieldWithSelectionRange(1, 2));
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
@@ -3145,7 +3139,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTextTextFieldGetSelected) {
EXPECT_EQ(2, end_offset);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTextTextFieldGetSelectedBackward) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTextTextFieldGetSelectedBackward) {
Init(BuildTextFieldWithSelectionRange(1, 2));
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
@@ -3160,7 +3154,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTextTextFieldGetSelectedBackward) {
EXPECT_EQ(2, end_offset);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleContentEditabledGetSelected) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleContentEditabledGetSelected) {
Init(BuildContentEditableWithSelectionRange(1, 2));
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
@@ -3181,8 +3175,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleContentEditabledGetSelected) {
EXPECT_EQ(2, end_offset);
}
-TEST_F(AXPlatformNodeWinTest,
- TestIAccessibleContentEditabledGetSelectedBackward) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleContentEditabledGetSelectedBackward) {
Init(BuildContentEditableWithSelectionRange(1, 2));
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
@@ -3197,7 +3190,7 @@ TEST_F(AXPlatformNodeWinTest,
EXPECT_EQ(2, end_offset);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTextTextFieldAddSelection) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTextTextFieldAddSelection) {
Init(BuildTextField());
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
ComPtr<IAccessibleText> text_field;
@@ -3221,7 +3214,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTextTextFieldAddSelection) {
// to AXPlatformNodeWin because |hypertext_| is only initialized
// on the BrowserAccessibility side.
TEST_F(AXPlatformNodeWinTest,
- DISABLED_TestIAccessibleTextContentEditableAddSelection) {
+ DISABLED_IAccessibleTextContentEditableAddSelection) {
Init(BuildContentEditable());
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
@@ -3242,7 +3235,7 @@ TEST_F(AXPlatformNodeWinTest,
EXPECT_EQ(2, end_offset);
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleTextTextFieldGetNSelectionsZero) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTextTextFieldGetNSelectionsZero) {
Init(BuildTextField());
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
@@ -3256,7 +3249,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleTextTextFieldGetNSelectionsZero) {
}
TEST_F(AXPlatformNodeWinTest,
- TestIAccessibleTextContentEditableGetNSelectionsZero) {
+ IAccessibleTextContentEditableGetNSelectionsZero) {
Init(BuildContentEditable());
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
@@ -3269,8 +3262,7 @@ TEST_F(AXPlatformNodeWinTest,
EXPECT_EQ(0, selections);
}
-TEST_F(AXPlatformNodeWinTest,
- TestIAccessibleTextContentEditableGetNSelections) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTextContentEditableGetNSelections) {
Init(BuildContentEditableWithSelectionRange(1, 2));
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
ComPtr<IAccessibleText> text_field;
@@ -3282,8 +3274,7 @@ TEST_F(AXPlatformNodeWinTest,
EXPECT_EQ(1, selections);
}
-TEST_F(AXPlatformNodeWinTest,
- TestIAccessibleTextTextFieldGetCaretOffsetNoCaret) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTextTextFieldGetCaretOffsetNoCaret) {
Init(BuildTextField());
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
@@ -3296,8 +3287,7 @@ TEST_F(AXPlatformNodeWinTest,
EXPECT_EQ(0, offset);
}
-TEST_F(AXPlatformNodeWinTest,
- TestIAccessibleTextTextFieldGetCaretOffsetHasCaret) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleTextTextFieldGetCaretOffsetHasCaret) {
Init(BuildTextFieldWithSelectionRange(1, 2));
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
@@ -3311,7 +3301,7 @@ TEST_F(AXPlatformNodeWinTest,
}
TEST_F(AXPlatformNodeWinTest,
- TestIAccessibleTextContextEditableGetCaretOffsetNoCaret) {
+ IAccessibleTextContextEditableGetCaretOffsetNoCaret) {
Init(BuildContentEditable());
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
@@ -3325,7 +3315,7 @@ TEST_F(AXPlatformNodeWinTest,
}
TEST_F(AXPlatformNodeWinTest,
- TestIAccessibleTextContentEditableGetCaretOffsetHasCaret) {
+ IAccessibleTextContentEditableGetCaretOffsetHasCaret) {
Init(BuildContentEditableWithSelectionRange(1, 2));
ComPtr<IAccessible2> ia2_text_field = ToIAccessible2(GetRootIAccessible());
@@ -3338,7 +3328,7 @@ TEST_F(AXPlatformNodeWinTest,
EXPECT_EQ(2, offset);
}
-TEST_F(AXPlatformNodeWinTest, TestIGridProviderGetRowCount) {
+TEST_F(AXPlatformNodeWinTest, IGridProviderGetRowCount) {
Init(BuildAriaColumnAndRowCountGrids());
// Empty Grid
@@ -3371,7 +3361,7 @@ TEST_F(AXPlatformNodeWinTest, TestIGridProviderGetRowCount) {
EXPECT_EQ(E_UNEXPECTED, grid4_provider->get_RowCount(&row_count));
}
-TEST_F(AXPlatformNodeWinTest, TestIGridProviderGetColumnCount) {
+TEST_F(AXPlatformNodeWinTest, IGridProviderGetColumnCount) {
Init(BuildAriaColumnAndRowCountGrids());
// Empty Grid
@@ -3404,7 +3394,7 @@ TEST_F(AXPlatformNodeWinTest, TestIGridProviderGetColumnCount) {
EXPECT_EQ(E_UNEXPECTED, grid4_provider->get_ColumnCount(&column_count));
}
-TEST_F(AXPlatformNodeWinTest, TestIGridProviderGetItem) {
+TEST_F(AXPlatformNodeWinTest, IGridProviderGetItem) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kGrid;
@@ -3436,7 +3426,7 @@ TEST_F(AXPlatformNodeWinTest, TestIGridProviderGetItem) {
EXPECT_EQ(cell1_irawelementprovidersimple.Get(), grid_item);
}
-TEST_F(AXPlatformNodeWinTest, TestITableProviderGetColumnHeaders) {
+TEST_F(AXPlatformNodeWinTest, ITableProviderGetColumnHeaders) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kTable;
@@ -3484,7 +3474,7 @@ TEST_F(AXPlatformNodeWinTest, TestITableProviderGetColumnHeaders) {
EXPECT_EQ(nullptr, safearray.Get());
}
-TEST_F(AXPlatformNodeWinTest, TestITableProviderGetRowHeaders) {
+TEST_F(AXPlatformNodeWinTest, ITableProviderGetRowHeaders) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kTable;
@@ -3530,7 +3520,7 @@ TEST_F(AXPlatformNodeWinTest, TestITableProviderGetRowHeaders) {
EXPECT_EQ(nullptr, safearray.Get());
}
-TEST_F(AXPlatformNodeWinTest, TestITableProviderGetRowOrColumnMajor) {
+TEST_F(AXPlatformNodeWinTest, ITableProviderGetRowOrColumnMajor) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kTable;
@@ -3546,7 +3536,7 @@ TEST_F(AXPlatformNodeWinTest, TestITableProviderGetRowOrColumnMajor) {
EXPECT_EQ(row_or_column_major, RowOrColumnMajor_RowMajor);
}
-TEST_F(AXPlatformNodeWinTest, TestITableItemProviderGetColumnHeaderItems) {
+TEST_F(AXPlatformNodeWinTest, ITableItemProviderGetColumnHeaderItems) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kTable;
@@ -3609,7 +3599,7 @@ TEST_F(AXPlatformNodeWinTest, TestITableItemProviderGetColumnHeaderItems) {
EXPECT_EQ(nullptr, safearray.Get());
}
-TEST_F(AXPlatformNodeWinTest, TestITableItemProviderGetRowHeaderItems) {
+TEST_F(AXPlatformNodeWinTest, ITableItemProviderGetRowHeaderItems) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kTable;
@@ -3671,7 +3661,7 @@ TEST_F(AXPlatformNodeWinTest, TestITableItemProviderGetRowHeaderItems) {
EXPECT_EQ(nullptr, safearray.Get());
}
-TEST_F(AXPlatformNodeWinTest, TestIA2GetAttribute) {
+TEST_F(AXPlatformNodeWinTest, IA2GetAttribute) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kButton;
@@ -3698,7 +3688,7 @@ TEST_F(AXPlatformNodeWinTest, TestIA2GetAttribute) {
EXPECT_EQ(E_INVALIDARG, iaccessible2->get_attribute(nullptr, nullptr));
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetPropertySimple) {
+TEST_F(AXPlatformNodeWinTest, UIAGetPropertySimple) {
AXNodeData root;
root.SetName("fake name");
root.AddStringAttribute(ax::mojom::StringAttribute::kAccessKey, "Ctrl+Q");
@@ -3757,7 +3747,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAGetPropertySimple) {
EXPECT_UIA_INT_EQ(child_node1, UIA_PositionInSetPropertyId, 1);
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetPropertyValueClickablePoint) {
+TEST_F(AXPlatformNodeWinTest, UIAGetPropertyValueClickablePoint) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kButton;
@@ -3774,7 +3764,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAGetPropertyValueClickablePoint) {
UIA_ClickablePointPropertyId, expected_values);
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetPropertyValue_Histogram) {
+TEST_F(AXPlatformNodeWinTest, UIAGetPropertyValue_Histogram) {
AXNodeData root;
root.id = 1;
Init(root);
@@ -3824,7 +3814,7 @@ TEST_F(AXPlatformNodeWinTest, UIAGetPropertyValueIsDialog) {
UIA_IsDialogPropertyId, true);
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetControllerForPropertyId) {
+TEST_F(AXPlatformNodeWinTest, UIAGetControllerForPropertyId) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -3872,7 +3862,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAGetControllerForPropertyId) {
expected_names_2);
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetDescribedByPropertyId) {
+TEST_F(AXPlatformNodeWinTest, UIAGetDescribedByPropertyId) {
AXNodeData root;
std::vector<AXNode::AXID> describedby_ids = {2, 3, 4};
root.AddIntListAttribute(ax::mojom::IntListAttribute::kDescribedbyIds,
@@ -3905,7 +3895,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAGetDescribedByPropertyId) {
root_node, UIA_DescribedByPropertyId, UIA_NamePropertyId, expected_names);
}
-TEST_F(AXPlatformNodeWinTest, TestUIAItemStatusPropertyId) {
+TEST_F(AXPlatformNodeWinTest, UIAItemStatusPropertyId) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kTable;
@@ -3973,7 +3963,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAItemStatusPropertyId) {
UIA_ItemStatusPropertyId, ScopedVariant::kEmptyVariant);
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetFlowsToPropertyId) {
+TEST_F(AXPlatformNodeWinTest, UIAGetFlowsToPropertyId) {
AXNodeData root;
std::vector<AXNode::AXID> flowto_ids = {2, 3, 4};
root.AddIntListAttribute(ax::mojom::IntListAttribute::kFlowtoIds, flowto_ids);
@@ -4004,7 +3994,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAGetFlowsToPropertyId) {
UIA_NamePropertyId, expected_names);
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetPropertyValueFlowsFromNone) {
+TEST_F(AXPlatformNodeWinTest, UIAGetPropertyValueFlowsFromNone) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -4022,7 +4012,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAGetPropertyValueFlowsFromNone) {
EXPECT_EQ(nullptr, V_ARRAY(property_value.ptr()));
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetPropertyValueFlowsFromSingle) {
+TEST_F(AXPlatformNodeWinTest, UIAGetPropertyValueFlowsFromSingle) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -4047,7 +4037,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAGetPropertyValueFlowsFromSingle) {
child_node1, UIA_FlowsFromPropertyId, UIA_NamePropertyId, expected_names);
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetPropertyValueFlowsFromMultiple) {
+TEST_F(AXPlatformNodeWinTest, UIAGetPropertyValueFlowsFromMultiple) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -4091,7 +4081,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAGetPropertyValueFlowsFromMultiple) {
expected_names_2);
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetPropertyValueFrameworkId) {
+TEST_F(AXPlatformNodeWinTest, UIAGetPropertyValueFrameworkId) {
AXNodeData root_ax_node_data;
root_ax_node_data.id = 1;
root_ax_node_data.role = ax::mojom::Role::kRootWebArea;
@@ -4103,46 +4093,132 @@ TEST_F(AXPlatformNodeWinTest, TestUIAGetPropertyValueFrameworkId) {
UIA_FrameworkIdPropertyId, L"Chrome");
}
-TEST_F(AXPlatformNodeWinTest, TestGetPropertyValue_LabeledByTest) {
- AXNodeData root;
- root.role = ax::mojom::Role::kListItem;
- root.id = 1;
- std::vector<AXNode::AXID> labeledby_ids = {2};
- root.AddIntListAttribute(ax::mojom::IntListAttribute::kLabelledbyIds,
- labeledby_ids);
+TEST_F(AXPlatformNodeWinTest, GetPropertyValue_LabeledByTest) {
+ // ++1 root
+ // ++++2 kGenericContainer LabeledBy 3
+ // ++++++3 kStaticText "Hello"
+ // ++++4 kGenericContainer LabeledBy 5
+ // ++++++5 kGenericContainer
+ // ++++++++6 kStaticText "3.14"
+ // ++++7 kAlert LabeledBy 6
+ AXNodeData root_1;
+ AXNodeData gc_2;
+ AXNodeData static_text_3;
+ AXNodeData gc_4;
+ AXNodeData gc_5;
+ AXNodeData static_text_6;
+ AXNodeData alert_7;
+
+ root_1.id = 1;
+ gc_2.id = 2;
+ static_text_3.id = 3;
+ gc_4.id = 4;
+ gc_5.id = 5;
+ static_text_6.id = 6;
+ alert_7.id = 7;
+
+ root_1.role = ax::mojom::Role::kRootWebArea;
+ root_1.child_ids = {gc_2.id, gc_4.id, alert_7.id};
+
+ gc_2.role = ax::mojom::Role::kGenericContainer;
+ gc_2.AddIntListAttribute(ax::mojom::IntListAttribute::kLabelledbyIds,
+ {static_text_3.id});
+ gc_2.child_ids = {static_text_3.id};
+
+ static_text_3.role = ax::mojom::Role::kStaticText;
+ static_text_3.SetName("Hello");
+
+ gc_4.role = ax::mojom::Role::kGenericContainer;
+ gc_4.AddIntListAttribute(ax::mojom::IntListAttribute::kLabelledbyIds,
+ {gc_5.id});
+ gc_4.child_ids = {gc_5.id};
+
+ gc_5.role = ax::mojom::Role::kGenericContainer;
+ gc_5.child_ids = {static_text_6.id};
+
+ static_text_6.role = ax::mojom::Role::kStaticText;
+ static_text_6.SetName("3.14");
+
+ alert_7.role = ax::mojom::Role::kAlert;
+ alert_7.AddIntListAttribute(ax::mojom::IntListAttribute::kLabelledbyIds,
+ {static_text_6.id});
+
+ Init(root_1, gc_2, static_text_3, gc_4, gc_5, static_text_6, alert_7);
- AXNodeData referenced_node;
- referenced_node.SetName("Name");
- referenced_node.role = ax::mojom::Role::kNone;
- referenced_node.id = 2;
+ AXNode* root_node = GetRootAsAXNode();
+ AXNode* gc_2_node = root_node->children()[0];
+ AXNode* static_text_3_node = gc_2_node->children()[0];
+ AXNode* gc_4_node = root_node->children()[1];
+ AXNode* static_text_6_node = gc_4_node->children()[0]->children()[0];
+ AXNode* alert_7_node = root_node->children()[2];
- root.child_ids.push_back(referenced_node.id);
- Init(root, referenced_node);
+ // Case 1: |gc_2| is labeled by |static_text_3|.
- ComPtr<IRawElementProviderSimple> root_node =
- GetRootIRawElementProviderSimple();
- ScopedVariant propertyValue;
- EXPECT_EQ(S_OK, root_node->GetPropertyValue(UIA_LabeledByPropertyId,
- propertyValue.Receive()));
- ASSERT_EQ(propertyValue.type(), VT_UNKNOWN);
- ComPtr<IRawElementProviderSimple> referenced_element;
- EXPECT_EQ(S_OK, propertyValue.ptr()->punkVal->QueryInterface(
- IID_PPV_ARGS(&referenced_element)));
- EXPECT_UIA_BSTR_EQ(referenced_element, UIA_NamePropertyId, L"Name");
-
- // Remove referenced_node's native event target and verify it's no longer
+ ComPtr<IRawElementProviderSimple> gc_2_provider =
+ GetIRawElementProviderSimpleFromTree(gc_2_node->tree()->GetAXTreeID(),
+ gc_2_node->id());
+ ScopedVariant property_value;
+ EXPECT_EQ(S_OK, gc_2_provider->GetPropertyValue(UIA_LabeledByPropertyId,
+ property_value.Receive()));
+ ASSERT_EQ(property_value.type(), VT_UNKNOWN);
+ ComPtr<IRawElementProviderSimple> static_text_3_provider;
+ EXPECT_EQ(S_OK, property_value.ptr()->punkVal->QueryInterface(
+ IID_PPV_ARGS(&static_text_3_provider)));
+ EXPECT_UIA_BSTR_EQ(static_text_3_provider, UIA_NamePropertyId, L"Hello");
+
+ // Case 2: |gc_4| is labeled by |gc_5| and should return the first static text
+ // child of that node, which is |static_text_6|.
+
+ ComPtr<IRawElementProviderSimple> gc_4_provider =
+ GetIRawElementProviderSimpleFromTree(gc_4_node->tree()->GetAXTreeID(),
+ gc_4_node->id());
+ property_value.Reset();
+ EXPECT_EQ(S_OK, gc_4_provider->GetPropertyValue(UIA_LabeledByPropertyId,
+ property_value.Receive()));
+ ASSERT_EQ(property_value.type(), VT_UNKNOWN);
+ ComPtr<IRawElementProviderSimple> static_text_6_provider;
+ EXPECT_EQ(S_OK, property_value.ptr()->punkVal->QueryInterface(
+ IID_PPV_ARGS(&static_text_6_provider)));
+ EXPECT_UIA_BSTR_EQ(static_text_6_provider, UIA_NamePropertyId, L"3.14");
+
+ // Case 3: Some UIA control types always expect an empty value for this
+ // property. The role kAlert corresponds to UIA_TextControlTypeId, which
+ // always expects an empty value. |alert_7| is marked as labeled by
+ // |static_text_6|, but shouldn't expose it to the UIA_LabeledByPropertyId.
+
+ ComPtr<IRawElementProviderSimple> alert_7_provider =
+ GetIRawElementProviderSimpleFromTree(alert_7_node->tree()->GetAXTreeID(),
+ alert_7_node->id());
+ property_value.Reset();
+ EXPECT_EQ(S_OK, alert_7_provider->GetPropertyValue(UIA_LabeledByPropertyId,
+ property_value.Receive()));
+ ASSERT_EQ(property_value.type(), VT_EMPTY);
+
+ // Remove the referenced nodes' native event targets and verify it's no longer
// returned.
- TestAXNodeWrapper* referenced_node_wrapper = TestAXNodeWrapper::GetOrCreate(
- GetTree(), GetRootAsAXNode()->children()[0]);
- referenced_node_wrapper->ResetNativeEventTarget();
- propertyValue.Reset();
- EXPECT_EQ(S_OK, root_node->GetPropertyValue(UIA_LabeledByPropertyId,
- propertyValue.Receive()));
- EXPECT_EQ(propertyValue.type(), VT_EMPTY);
+ // Case 1.
+ TestAXNodeWrapper* static_text_3_node_wrapper =
+ TestAXNodeWrapper::GetOrCreate(GetTree(), static_text_3_node);
+ static_text_3_node_wrapper->ResetNativeEventTarget();
+
+ property_value.Reset();
+ EXPECT_EQ(S_OK, gc_2_provider->GetPropertyValue(UIA_LabeledByPropertyId,
+ property_value.Receive()));
+ EXPECT_EQ(property_value.type(), VT_EMPTY);
+
+ // Case 2.
+ TestAXNodeWrapper* static_text_6_node_wrapper =
+ TestAXNodeWrapper::GetOrCreate(GetTree(), static_text_6_node);
+ static_text_6_node_wrapper->ResetNativeEventTarget();
+
+ property_value.Reset();
+ EXPECT_EQ(S_OK, gc_4_provider->GetPropertyValue(UIA_LabeledByPropertyId,
+ property_value.Receive()));
+ EXPECT_EQ(property_value.type(), VT_EMPTY);
}
-TEST_F(AXPlatformNodeWinTest, TestGetPropertyValue_HelpText) {
+TEST_F(AXPlatformNodeWinTest, GetPropertyValue_HelpText) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -4216,7 +4292,7 @@ TEST_F(AXPlatformNodeWinTest, TestGetPropertyValue_HelpText) {
UIA_HelpTextPropertyId, ScopedVariant::kEmptyVariant);
}
-TEST_F(AXPlatformNodeWinTest, TestGetPropertyValue_LocalizedControlType) {
+TEST_F(AXPlatformNodeWinTest, GetPropertyValue_LocalizedControlType) {
AXNodeData root;
root.role = ax::mojom::Role::kUnknown;
root.id = 1;
@@ -4250,7 +4326,7 @@ TEST_F(AXPlatformNodeWinTest, TestGetPropertyValue_LocalizedControlType) {
UIA_LocalizedControlTypePropertyId, L"search box");
}
-TEST_F(AXPlatformNodeWinTest, TestGetPropertyValue_IsControlElement) {
+TEST_F(AXPlatformNodeWinTest, GetPropertyValue_IsControlElement) {
AXTreeUpdate update;
ui::AXTreeID tree_id = ui::AXTreeID::CreateNewAXTreeID();
update.tree_data.tree_id = tree_id;
@@ -4344,7 +4420,7 @@ TEST_F(AXPlatformNodeWinTest, TestGetPropertyValue_IsControlElement) {
UIA_IsControlElementPropertyId, true);
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetProviderOptions) {
+TEST_F(AXPlatformNodeWinTest, UIAGetProviderOptions) {
AXNodeData root_data;
Init(root_data);
@@ -4360,7 +4436,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAGetProviderOptions) {
provider_options);
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetHostRawElementProvider) {
+TEST_F(AXPlatformNodeWinTest, UIAGetHostRawElementProvider) {
AXNodeData root_data;
Init(root_data);
@@ -4373,7 +4449,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAGetHostRawElementProvider) {
EXPECT_EQ(nullptr, host_provider.Get());
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetBoundingRectangle) {
+TEST_F(AXPlatformNodeWinTest, UIAGetBoundingRectangle) {
AXNodeData root_data;
root_data.id = 1;
root_data.relative_bounds.bounds = gfx::RectF(10, 20, 30, 50);
@@ -4391,7 +4467,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAGetBoundingRectangle) {
EXPECT_EQ(50, bounding_rectangle.height);
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetFragmentRoot) {
+TEST_F(AXPlatformNodeWinTest, UIAGetFragmentRoot) {
// This test needs to be run on a child node since AXPlatformRootNodeWin
// overrides the method.
AXNodeData root_data;
@@ -4431,7 +4507,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAGetFragmentRoot) {
element1_provider->get_FragmentRoot(&actual_fragment_root));
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetEmbeddedFragmentRoots) {
+TEST_F(AXPlatformNodeWinTest, UIAGetEmbeddedFragmentRoots) {
AXNodeData root_data;
root_data.id = 1;
Init(root_data);
@@ -4445,7 +4521,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAGetEmbeddedFragmentRoots) {
EXPECT_EQ(nullptr, embedded_fragment_roots.Get());
}
-TEST_F(AXPlatformNodeWinTest, TestUIAGetRuntimeId) {
+TEST_F(AXPlatformNodeWinTest, UIAGetRuntimeId) {
AXNodeData root_data;
root_data.id = 1;
Init(root_data);
@@ -4475,7 +4551,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAGetRuntimeId) {
EXPECT_HRESULT_SUCCEEDED(::SafeArrayUnaccessData(runtime_id.Get()));
}
-TEST_F(AXPlatformNodeWinTest, TestUIAIWindowProviderGetIsModalUnset) {
+TEST_F(AXPlatformNodeWinTest, UIAIWindowProviderGetIsModalUnset) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -4489,7 +4565,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAIWindowProviderGetIsModalUnset) {
ASSERT_EQ(nullptr, window_provider.Get());
}
-TEST_F(AXPlatformNodeWinTest, TestUIAIWindowProviderGetIsModalFalse) {
+TEST_F(AXPlatformNodeWinTest, UIAIWindowProviderGetIsModalFalse) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -4508,7 +4584,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAIWindowProviderGetIsModalFalse) {
ASSERT_FALSE(is_modal);
}
-TEST_F(AXPlatformNodeWinTest, TestUIAIWindowProviderGetIsModalTrue) {
+TEST_F(AXPlatformNodeWinTest, UIAIWindowProviderGetIsModalTrue) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -4527,7 +4603,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAIWindowProviderGetIsModalTrue) {
ASSERT_TRUE(is_modal);
}
-TEST_F(AXPlatformNodeWinTest, TestUIAIWindowProviderInvalidArgument) {
+TEST_F(AXPlatformNodeWinTest, UIAIWindowProviderInvalidArgument) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -4550,7 +4626,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAIWindowProviderInvalidArgument) {
ASSERT_EQ(E_INVALIDARG, window_provider->get_IsTopmost(nullptr));
}
-TEST_F(AXPlatformNodeWinTest, TestUIAIWindowProviderNotSupported) {
+TEST_F(AXPlatformNodeWinTest, UIAIWindowProviderNotSupported) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -4588,7 +4664,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAIWindowProviderNotSupported) {
window_provider->get_IsTopmost(&bool_result));
}
-TEST_F(AXPlatformNodeWinTest, TestUIANavigate) {
+TEST_F(AXPlatformNodeWinTest, UIANavigate) {
AXNodeData root_data;
root_data.id = 1;
@@ -4652,11 +4728,10 @@ TEST_F(AXPlatformNodeWinTest, TestUIANavigate) {
nullptr);
}
-TEST_F(AXPlatformNodeWinTest, TestISelectionProviderCanSelectMultipleDefault) {
+TEST_F(AXPlatformNodeWinTest, ISelectionProviderCanSelectMultipleDefault) {
Init(BuildListBox(/*option_1_is_selected*/ false,
/*option_2_is_selected*/ false,
- /*option_3_is_selected*/ false,
- /*additional_state*/ ax::mojom::State::kNone));
+ /*option_3_is_selected*/ false, {}));
ComPtr<ISelectionProvider> selection_provider(
QueryInterfaceFromNode<ISelectionProvider>(GetRootAsAXNode()));
@@ -4667,11 +4742,13 @@ TEST_F(AXPlatformNodeWinTest, TestISelectionProviderCanSelectMultipleDefault) {
EXPECT_FALSE(multiple);
}
-TEST_F(AXPlatformNodeWinTest, TestISelectionProviderCanSelectMultipleTrue) {
+TEST_F(AXPlatformNodeWinTest, ISelectionProviderCanSelectMultipleTrue) {
+ const std::vector<ax::mojom::State> state = {
+ ax::mojom::State::kMultiselectable, ax::mojom::State::kFocusable};
Init(BuildListBox(/*option_1_is_selected*/ false,
/*option_2_is_selected*/ false,
/*option_3_is_selected*/ false,
- /*additional_state*/ ax::mojom::State::kMultiselectable));
+ /*additional_state*/ state));
ComPtr<ISelectionProvider> selection_provider(
QueryInterfaceFromNode<ISelectionProvider>(GetRootAsAXNode()));
@@ -4682,12 +4759,11 @@ TEST_F(AXPlatformNodeWinTest, TestISelectionProviderCanSelectMultipleTrue) {
EXPECT_TRUE(multiple);
}
-TEST_F(AXPlatformNodeWinTest,
- TestISelectionProviderIsSelectionRequiredDefault) {
+TEST_F(AXPlatformNodeWinTest, ISelectionProviderIsSelectionRequiredDefault) {
Init(BuildListBox(/*option_1_is_selected*/ false,
/*option_2_is_selected*/ false,
/*option_3_is_selected*/ false,
- /*additional_state*/ ax::mojom::State::kNone));
+ /*additional_state*/ {}));
ComPtr<ISelectionProvider> selection_provider(
QueryInterfaceFromNode<ISelectionProvider>(GetRootAsAXNode()));
@@ -4698,11 +4774,11 @@ TEST_F(AXPlatformNodeWinTest,
EXPECT_FALSE(selection_required);
}
-TEST_F(AXPlatformNodeWinTest, TestISelectionProviderIsSelectionRequiredTrue) {
+TEST_F(AXPlatformNodeWinTest, ISelectionProviderIsSelectionRequiredTrue) {
Init(BuildListBox(/*option_1_is_selected*/ false,
/*option_2_is_selected*/ false,
/*option_3_is_selected*/ false,
- /*additional_state*/ ax::mojom::State::kRequired));
+ /*additional_state*/ {ax::mojom::State::kRequired}));
ComPtr<ISelectionProvider> selection_provider(
QueryInterfaceFromNode<ISelectionProvider>(GetRootAsAXNode()));
@@ -4713,11 +4789,11 @@ TEST_F(AXPlatformNodeWinTest, TestISelectionProviderIsSelectionRequiredTrue) {
EXPECT_TRUE(selection_required);
}
-TEST_F(AXPlatformNodeWinTest, TestISelectionProviderGetSelectionNoneSelected) {
+TEST_F(AXPlatformNodeWinTest, ISelectionProviderGetSelectionNoneSelected) {
Init(BuildListBox(/*option_1_is_selected*/ false,
/*option_2_is_selected*/ false,
/*option_3_is_selected*/ false,
- /*additional_state*/ ax::mojom::State::kNone));
+ /*additional_state*/ {ax::mojom::State::kFocusable}));
ComPtr<ISelectionProvider> selection_provider(
QueryInterfaceFromNode<ISelectionProvider>(GetRootAsAXNode()));
@@ -4739,11 +4815,11 @@ TEST_F(AXPlatformNodeWinTest, TestISelectionProviderGetSelectionNoneSelected) {
}
TEST_F(AXPlatformNodeWinTest,
- TestISelectionProviderGetSelectionSingleItemSelected) {
+ ISelectionProviderGetSelectionSingleItemSelected) {
Init(BuildListBox(/*option_1_is_selected*/ false,
/*option_2_is_selected*/ true,
/*option_3_is_selected*/ false,
- /*additional_state*/ ax::mojom::State::kNone));
+ /*additional_state*/ {ax::mojom::State::kFocusable}));
ComPtr<ISelectionProvider> selection_provider(
QueryInterfaceFromNode<ISelectionProvider>(GetRootAsAXNode()));
@@ -4774,11 +4850,13 @@ TEST_F(AXPlatformNodeWinTest,
}
TEST_F(AXPlatformNodeWinTest,
- TestISelectionProviderGetSelectionMultipleItemsSelected) {
+ ISelectionProviderGetSelectionMultipleItemsSelected) {
+ const std::vector<ax::mojom::State> state = {
+ ax::mojom::State::kMultiselectable, ax::mojom::State::kFocusable};
Init(BuildListBox(/*option_1_is_selected*/ true,
/*option_2_is_selected*/ true,
/*option_3_is_selected*/ true,
- /*additional_state*/ ax::mojom::State::kNone));
+ /*additional_state*/ state));
ComPtr<ISelectionProvider> selection_provider(
QueryInterfaceFromNode<ISelectionProvider>(GetRootAsAXNode()));
@@ -4817,7 +4895,7 @@ TEST_F(AXPlatformNodeWinTest,
EXPECT_HRESULT_SUCCEEDED(::SafeArrayUnaccessData(selected_items.Get()));
}
-TEST_F(AXPlatformNodeWinTest, TestComputeUIAControlType) {
+TEST_F(AXPlatformNodeWinTest, ComputeUIAControlType) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -4862,7 +4940,7 @@ TEST_F(AXPlatformNodeWinTest, TestComputeUIAControlType) {
UIA_ControlTypePropertyId, int{UIA_EditControlTypeId});
}
-TEST_F(AXPlatformNodeWinTest, TestUIALandmarkType) {
+TEST_F(AXPlatformNodeWinTest, UIALandmarkType) {
auto TestLandmarkType = [this](ax::mojom::Role node_role,
base::Optional<LONG> expected_landmark_type,
const std::string& node_name = {}) {
@@ -4906,7 +4984,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIALandmarkType) {
TestLandmarkType(ax::mojom::Role::kTable, {});
}
-TEST_F(AXPlatformNodeWinTest, TestUIALocalizedLandmarkType) {
+TEST_F(AXPlatformNodeWinTest, UIALocalizedLandmarkType) {
auto TestLocalizedLandmarkType =
[this](ax::mojom::Role node_role,
const std::wstring& expected_localized_landmark,
@@ -4949,7 +5027,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIALocalizedLandmarkType) {
TestLocalizedLandmarkType(ax::mojom::Role::kTable, {});
}
-TEST_F(AXPlatformNodeWinTest, TestIRawElementProviderSimple2ShowContextMenu) {
+TEST_F(AXPlatformNodeWinTest, IRawElementProviderSimple2ShowContextMenu) {
AXNodeData root_data;
root_data.id = 1;
@@ -4982,7 +5060,7 @@ TEST_F(AXPlatformNodeWinTest, TestIRawElementProviderSimple2ShowContextMenu) {
EXPECT_EQ(root_node, TestAXNodeWrapper::GetNodeFromLastShowContextMenu());
}
-TEST_F(AXPlatformNodeWinTest, TestUIAErrorHandling) {
+TEST_F(AXPlatformNodeWinTest, UIAErrorHandling) {
AXNodeData root;
Init(root);
@@ -5199,7 +5277,7 @@ TEST_F(AXPlatformNodeWinTest, TestUIAErrorHandling) {
window_provider->get_IsTopmost(nullptr));
}
-TEST_F(AXPlatformNodeWinTest, TestGetPatternProviderSupportedPatterns) {
+TEST_F(AXPlatformNodeWinTest, GetPatternProviderSupportedPatterns) {
constexpr AXNode::AXID root_id = 1;
constexpr AXNode::AXID text_field_with_combo_box_id = 2;
constexpr AXNode::AXID meter_id = 3;
@@ -5364,7 +5442,7 @@ TEST_F(AXPlatformNodeWinTest, TestGetPatternProviderSupportedPatterns) {
GetSupportedPatternsFromNodeId(grid_with_header_cell_id));
}
-TEST_F(AXPlatformNodeWinTest, TestGetPatternProviderExpandCollapsePattern) {
+TEST_F(AXPlatformNodeWinTest, GetPatternProviderExpandCollapsePattern) {
ui::AXNodeData root;
root.id = 1;
@@ -5482,7 +5560,7 @@ TEST_F(AXPlatformNodeWinTest, TestGetPatternProviderExpandCollapsePattern) {
EXPECT_NE(nullptr, expandcollapse_provider.Get());
}
-TEST_F(AXPlatformNodeWinTest, TestGetPatternProviderInvokePattern) {
+TEST_F(AXPlatformNodeWinTest, GetPatternProviderInvokePattern) {
ui::AXNodeData root;
root.id = 1;
@@ -5548,7 +5626,7 @@ TEST_F(AXPlatformNodeWinTest, TestGetPatternProviderInvokePattern) {
EXPECT_EQ(nullptr, invoke_provider.Get());
}
-TEST_F(AXPlatformNodeWinTest, TestIExpandCollapsePatternProviderAction) {
+TEST_F(AXPlatformNodeWinTest, IExpandCollapsePatternProviderAction) {
ui::AXNodeData root;
root.id = 1;
@@ -5559,6 +5637,7 @@ TEST_F(AXPlatformNodeWinTest, TestIExpandCollapsePatternProviderAction) {
ui::AXNodeData button_has_popup_menu;
ui::AXNodeData button_has_popup_menu_pressed;
ui::AXNodeData button_has_popup_true;
+ ui::AXNodeData generic_container_has_popup_menu;
combo_box_grouping_has_popup.id = 2;
combo_box_grouping_expanded.id = 3;
@@ -5567,14 +5646,13 @@ TEST_F(AXPlatformNodeWinTest, TestIExpandCollapsePatternProviderAction) {
button_has_popup_menu.id = 6;
button_has_popup_menu_pressed.id = 7;
button_has_popup_true.id = 8;
+ generic_container_has_popup_menu.id = 9;
- root.child_ids.push_back(combo_box_grouping_has_popup.id);
- root.child_ids.push_back(combo_box_grouping_expanded.id);
- root.child_ids.push_back(combo_box_grouping_collapsed.id);
- root.child_ids.push_back(combo_box_grouping_disabled.id);
- root.child_ids.push_back(button_has_popup_menu.id);
- root.child_ids.push_back(button_has_popup_menu_pressed.id);
- root.child_ids.push_back(button_has_popup_true.id);
+ root.child_ids = {
+ combo_box_grouping_has_popup.id, combo_box_grouping_expanded.id,
+ combo_box_grouping_collapsed.id, combo_box_grouping_disabled.id,
+ button_has_popup_menu.id, button_has_popup_menu_pressed.id,
+ button_has_popup_true.id, generic_container_has_popup_menu.id};
// combo_box_grouping HasPopup set to true, can collapse, can expand.
// state is ExpandCollapseState_LeafNode.
@@ -5598,21 +5676,31 @@ TEST_F(AXPlatformNodeWinTest, TestIExpandCollapsePatternProviderAction) {
// button_has_popup_menu HasPopup set to kMenu and is not STATE_PRESSED.
// state is ExpandCollapseState_Collapsed.
+ button_has_popup_menu.role = ax::mojom::Role::kButton;
button_has_popup_menu.SetHasPopup(ax::mojom::HasPopup::kMenu);
// button_has_popup_menu_pressed HasPopup set to kMenu and is STATE_PRESSED.
// state is ExpandCollapseState_Expanded.
+ button_has_popup_menu_pressed.role = ax::mojom::Role::kButton;
button_has_popup_menu_pressed.SetHasPopup(ax::mojom::HasPopup::kMenu);
button_has_popup_menu_pressed.SetCheckedState(ax::mojom::CheckedState::kTrue);
// button_has_popup_true HasPopup set to true but is not a menu.
// state is ExpandCollapseState_LeafNode.
+ button_has_popup_true.role = ax::mojom::Role::kButton;
button_has_popup_true.SetHasPopup(ax::mojom::HasPopup::kTrue);
+ // generic_container_has_popup_menu HasPopup set to menu but with no expand
+ // state set.
+ // state is ExpandCollapseState_LeafNode.
+ generic_container_has_popup_menu.role = ax::mojom::Role::kGenericContainer;
+ generic_container_has_popup_menu.SetHasPopup(ax::mojom::HasPopup::kMenu);
+
Init(root, combo_box_grouping_has_popup, combo_box_grouping_disabled,
combo_box_grouping_expanded, combo_box_grouping_collapsed,
combo_box_grouping_disabled, button_has_popup_menu,
- button_has_popup_menu_pressed, button_has_popup_true);
+ button_has_popup_menu_pressed, button_has_popup_true,
+ generic_container_has_popup_menu);
// combo_box_grouping HasPopup set to true, can collapse, can expand.
// state is ExpandCollapseState_LeafNode.
@@ -5621,7 +5709,7 @@ TEST_F(AXPlatformNodeWinTest, TestIExpandCollapsePatternProviderAction) {
ComPtr<IExpandCollapseProvider> expandcollapse_provider;
EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
UIA_ExpandCollapsePatternId, &expandcollapse_provider));
- EXPECT_NE(nullptr, expandcollapse_provider.Get());
+ ASSERT_NE(nullptr, expandcollapse_provider.Get());
EXPECT_HRESULT_SUCCEEDED(expandcollapse_provider->Collapse());
EXPECT_HRESULT_SUCCEEDED(expandcollapse_provider->Expand());
ExpandCollapseState state;
@@ -5634,7 +5722,7 @@ TEST_F(AXPlatformNodeWinTest, TestIExpandCollapsePatternProviderAction) {
raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(1);
EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
UIA_ExpandCollapsePatternId, &expandcollapse_provider));
- EXPECT_NE(nullptr, expandcollapse_provider.Get());
+ ASSERT_NE(nullptr, expandcollapse_provider.Get());
EXPECT_HRESULT_SUCCEEDED(expandcollapse_provider->Collapse());
EXPECT_HRESULT_FAILED(expandcollapse_provider->Expand());
EXPECT_HRESULT_SUCCEEDED(
@@ -5646,7 +5734,7 @@ TEST_F(AXPlatformNodeWinTest, TestIExpandCollapsePatternProviderAction) {
raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(2);
EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
UIA_ExpandCollapsePatternId, &expandcollapse_provider));
- EXPECT_NE(nullptr, expandcollapse_provider.Get());
+ ASSERT_NE(nullptr, expandcollapse_provider.Get());
EXPECT_HRESULT_FAILED(expandcollapse_provider->Collapse());
EXPECT_HRESULT_SUCCEEDED(expandcollapse_provider->Expand());
EXPECT_HRESULT_SUCCEEDED(
@@ -5658,7 +5746,7 @@ TEST_F(AXPlatformNodeWinTest, TestIExpandCollapsePatternProviderAction) {
raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(3);
EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
UIA_ExpandCollapsePatternId, &expandcollapse_provider));
- EXPECT_NE(nullptr, expandcollapse_provider.Get());
+ ASSERT_NE(nullptr, expandcollapse_provider.Get());
EXPECT_HRESULT_FAILED(expandcollapse_provider->Collapse());
EXPECT_HRESULT_FAILED(expandcollapse_provider->Expand());
EXPECT_HRESULT_SUCCEEDED(
@@ -5670,7 +5758,7 @@ TEST_F(AXPlatformNodeWinTest, TestIExpandCollapsePatternProviderAction) {
raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(4);
EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
UIA_ExpandCollapsePatternId, &expandcollapse_provider));
- EXPECT_NE(nullptr, expandcollapse_provider.Get());
+ ASSERT_NE(nullptr, expandcollapse_provider.Get());
EXPECT_HRESULT_SUCCEEDED(
expandcollapse_provider->get_ExpandCollapseState(&state));
EXPECT_EQ(ExpandCollapseState_Collapsed, state);
@@ -5680,7 +5768,7 @@ TEST_F(AXPlatformNodeWinTest, TestIExpandCollapsePatternProviderAction) {
raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(5);
EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
UIA_ExpandCollapsePatternId, &expandcollapse_provider));
- EXPECT_NE(nullptr, expandcollapse_provider.Get());
+ ASSERT_NE(nullptr, expandcollapse_provider.Get());
EXPECT_HRESULT_SUCCEEDED(
expandcollapse_provider->get_ExpandCollapseState(&state));
EXPECT_EQ(ExpandCollapseState_Expanded, state);
@@ -5690,13 +5778,24 @@ TEST_F(AXPlatformNodeWinTest, TestIExpandCollapsePatternProviderAction) {
raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(6);
EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
UIA_ExpandCollapsePatternId, &expandcollapse_provider));
- EXPECT_NE(nullptr, expandcollapse_provider.Get());
+ ASSERT_NE(nullptr, expandcollapse_provider.Get());
+ EXPECT_HRESULT_SUCCEEDED(
+ expandcollapse_provider->get_ExpandCollapseState(&state));
+ EXPECT_EQ(ExpandCollapseState_LeafNode, state);
+
+ // generic_container_has_popup_menu HasPopup set to menu but with no expand
+ // state set.
+ // state is ExpandCollapseState_LeafNode.
+ raw_element_provider_simple = GetIRawElementProviderSimpleFromChildIndex(7);
+ EXPECT_HRESULT_SUCCEEDED(raw_element_provider_simple->GetPatternProvider(
+ UIA_ExpandCollapsePatternId, &expandcollapse_provider));
+ ASSERT_NE(nullptr, expandcollapse_provider.Get());
EXPECT_HRESULT_SUCCEEDED(
expandcollapse_provider->get_ExpandCollapseState(&state));
EXPECT_EQ(ExpandCollapseState_LeafNode, state);
}
-TEST_F(AXPlatformNodeWinTest, TestIInvokeProviderInvoke) {
+TEST_F(AXPlatformNodeWinTest, IInvokeProviderInvoke) {
ui::AXNodeData root;
root.id = 1;
@@ -5737,7 +5836,7 @@ TEST_F(AXPlatformNodeWinTest, TestIInvokeProviderInvoke) {
EXPECT_UIA_ELEMENTNOTENABLED(invoke_provider->Invoke());
}
-TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderNotSupported) {
+TEST_F(AXPlatformNodeWinTest, ISelectionItemProviderNotSupported) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kNone;
@@ -5752,7 +5851,7 @@ TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderNotSupported) {
ASSERT_EQ(nullptr, selection_item_provider.Get());
}
-TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderDisabled) {
+TEST_F(AXPlatformNodeWinTest, ISelectionItemProviderDisabled) {
AXNodeData root;
root.id = 1;
root.AddIntAttribute(ax::mojom::IntAttribute::kRestriction,
@@ -5778,7 +5877,7 @@ TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderDisabled) {
EXPECT_TRUE(selected);
}
-TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderNotSelectable) {
+TEST_F(AXPlatformNodeWinTest, ISelectionItemProviderNotSelectable) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kTab;
@@ -5793,7 +5892,7 @@ TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderNotSelectable) {
ASSERT_EQ(nullptr, selection_item_provider.Get());
}
-TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderSimple) {
+TEST_F(AXPlatformNodeWinTest, ISelectionItemProviderSimple) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kListBox;
@@ -5853,7 +5952,7 @@ TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderSimple) {
EXPECT_TRUE(selected);
}
-TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderRadioButton) {
+TEST_F(AXPlatformNodeWinTest, ISelectionItemProviderRadioButton) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRadioGroup;
@@ -5941,7 +6040,7 @@ TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderRadioButton) {
ASSERT_EQ(nullptr, option4_provider.Get());
}
-TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderMenuItemRadio) {
+TEST_F(AXPlatformNodeWinTest, ISelectionItemProviderMenuItemRadio) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kMenu;
@@ -6029,7 +6128,7 @@ TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderMenuItemRadio) {
ASSERT_EQ(nullptr, option4_provider.Get());
}
-TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderTable) {
+TEST_F(AXPlatformNodeWinTest, ISelectionItemProviderTable) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kTable;
@@ -6054,7 +6153,7 @@ TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderTable) {
ASSERT_EQ(nullptr, selection_item_provider.Get());
}
-TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderGrid) {
+TEST_F(AXPlatformNodeWinTest, ISelectionItemProviderGrid) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kGrid;
@@ -6121,7 +6220,7 @@ TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderGrid) {
EXPECT_TRUE(selected);
}
-TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderGetSelectionContainer) {
+TEST_F(AXPlatformNodeWinTest, ISelectionItemProviderGetSelectionContainer) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kGrid;
@@ -6152,7 +6251,7 @@ TEST_F(AXPlatformNodeWinTest, TestISelectionItemProviderGetSelectionContainer) {
EXPECT_EQ(container, container_provider);
}
-TEST_F(AXPlatformNodeWinTest, TestIValueProvider_GetValue) {
+TEST_F(AXPlatformNodeWinTest, IValueProvider_GetValue) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -6201,7 +6300,7 @@ TEST_F(AXPlatformNodeWinTest, TestIValueProvider_GetValue) {
bstr_value.Reset();
}
-TEST_F(AXPlatformNodeWinTest, TestIAccessibleValue) {
+TEST_F(AXPlatformNodeWinTest, IAccessibleValue) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -6224,7 +6323,7 @@ TEST_F(AXPlatformNodeWinTest, TestIAccessibleValue) {
EXPECT_DOUBLE_EQ(3.0, V_R8(value.ptr()));
}
-TEST_F(AXPlatformNodeWinTest, TestIValueProvider_SetValue) {
+TEST_F(AXPlatformNodeWinTest, IValueProvider_SetValue) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -6281,7 +6380,7 @@ TEST_F(AXPlatformNodeWinTest, TestIValueProvider_SetValue) {
bstr_value.Reset();
}
-TEST_F(AXPlatformNodeWinTest, TestIValueProvider_IsReadOnly) {
+TEST_F(AXPlatformNodeWinTest, IValueProvider_IsReadOnly) {
AXNodeData root;
root.id = 1;
root.role = ax::mojom::Role::kRootWebArea;
@@ -6406,7 +6505,7 @@ TEST_F(AXPlatformNodeWinTest, IScrollProviderSetScrollPercent) {
EXPECT_EQ(y_scroll_percent, 34);
}
-TEST_F(AXPlatformNodeWinTest, TestSanitizeStringAttributeForIA2) {
+TEST_F(AXPlatformNodeWinTest, SanitizeStringAttributeForIA2) {
std::string input("\\:=,;");
std::string output;
AXPlatformNodeWin::SanitizeStringAttributeForIA2(input, &output);
diff --git a/chromium/ui/accessibility/platform/ax_system_caret_win.cc b/chromium/ui/accessibility/platform/ax_system_caret_win.cc
index c2a996e377d..00aede8ab16 100644
--- a/chromium/ui/accessibility/platform/ax_system_caret_win.cc
+++ b/chromium/ui/accessibility/platform/ax_system_caret_win.cc
@@ -6,7 +6,8 @@
#include <windows.h>
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/platform/ax_platform_node_win.h"
#include "ui/display/win/screen_win.h"
diff --git a/chromium/ui/accessibility/platform/ax_unique_id.cc b/chromium/ui/accessibility/platform/ax_unique_id.cc
index 9da346f6bb5..163fcdc39e0 100644
--- a/chromium/ui/accessibility/platform/ax_unique_id.cc
+++ b/chromium/ui/accessibility/platform/ax_unique_id.cc
@@ -8,6 +8,7 @@
#include <unordered_set>
#include "base/lazy_instance.h"
+#include "base/logging.h"
#include "base/stl_util.h"
namespace ui {
diff --git a/chromium/ui/accessibility/tree_generator.cc b/chromium/ui/accessibility/tree_generator.cc
index 6946077922a..92b2166cdff 100644
--- a/chromium/ui/accessibility/tree_generator.cc
+++ b/chromium/ui/accessibility/tree_generator.cc
@@ -44,23 +44,64 @@ int TreeGenerator::UniqueTreeCount() const {
}
void TreeGenerator::BuildUniqueTree(int tree_index, AXTree* out_tree) const {
+ AXTreeUpdate update;
+ BuildUniqueTreeUpdate(tree_index, &update);
+ CHECK(out_tree->Unserialize(update)) << out_tree->error();
+}
+
+int TreeGenerator::IgnoredPermutationCountPerUniqueTree(int tree_index) const {
+ int unique_tree_count_so_far = 0;
+ for (int node_count = 1; node_count <= max_node_count_; ++node_count) {
+ int unique_tree_count = unique_tree_count_by_size_[node_count];
+ if (tree_index - unique_tree_count_so_far < unique_tree_count) {
+ // Each node other than the root can be either ignored or not,
+ // so return 2 ^ (node_count - 1)
+ return 1 << (node_count - 1);
+ }
+ unique_tree_count_so_far += unique_tree_count;
+ }
+
+ NOTREACHED();
+ return 0;
+}
+
+void TreeGenerator::BuildUniqueTreeWithIgnoredNodes(int tree_index,
+ int ignored_index,
+ AXTree* out_tree) const {
+ AXTreeUpdate update;
+ BuildUniqueTreeUpdate(tree_index, &update);
+
+ int node_count = int{update.nodes.size()};
+ CHECK_GE(ignored_index, 0);
+ CHECK_LT(ignored_index, 1 << (node_count - 1));
+
+ for (int i = 0; i < node_count - 1; i++) {
+ if (ignored_index & (1 << i))
+ update.nodes[i + 1].AddState(ax::mojom::State::kIgnored);
+ }
+ CHECK(out_tree->Unserialize(update)) << out_tree->error();
+}
+
+void TreeGenerator::BuildUniqueTreeUpdate(int tree_index,
+ AXTreeUpdate* out_update) const {
CHECK_LT(tree_index, total_unique_tree_count_);
int unique_tree_count_so_far = 0;
for (int node_count = 1; node_count <= max_node_count_; ++node_count) {
int unique_tree_count = unique_tree_count_by_size_[node_count];
if (tree_index - unique_tree_count_so_far < unique_tree_count) {
- BuildUniqueTreeWithSize(node_count,
- tree_index - unique_tree_count_so_far,
- out_tree);
+ BuildUniqueTreeUpdateWithSize(
+ node_count, tree_index - unique_tree_count_so_far, out_update);
return;
}
unique_tree_count_so_far += unique_tree_count;
}
}
-void TreeGenerator::BuildUniqueTreeWithSize(
- int node_count, int tree_index, AXTree* out_tree) const {
+void TreeGenerator::BuildUniqueTreeUpdateWithSize(
+ int node_count,
+ int tree_index,
+ AXTreeUpdate* out_update) const {
std::vector<int> indices;
std::vector<int> permuted;
int unique_tree_count = unique_tree_count_by_size_[node_count];
@@ -84,26 +125,22 @@ void TreeGenerator::BuildUniqueTreeWithSize(
// Build an AXTreeUpdate. The first two nodes of the tree always
// go in the same place.
- AXTreeUpdate update;
- update.root_id = permuted[0];
- update.nodes.resize(node_count);
- update.nodes[0].id = permuted[0];
+ out_update->root_id = permuted[0];
+ out_update->nodes.resize(node_count);
+ out_update->nodes[0].id = permuted[0];
if (node_count > 1) {
- update.nodes[0].child_ids.push_back(permuted[1]);
- update.nodes[1].id = permuted[1];
+ out_update->nodes[0].child_ids.push_back(permuted[1]);
+ out_update->nodes[1].id = permuted[1];
}
// The remaining nodes are assigned based on their parent
// selected from the next bits from |tree_index|.
for (int i = 2; i < node_count; ++i) {
- update.nodes[i].id = permuted[i];
+ out_update->nodes[i].id = permuted[i];
int parent_index = (tree_index % i);
tree_index /= i;
- update.nodes[parent_index].child_ids.push_back(permuted[i]);
+ out_update->nodes[parent_index].child_ids.push_back(permuted[i]);
}
-
- // Unserialize the tree update into the destination tree.
- CHECK(out_tree->Unserialize(update)) << out_tree->error();
}
} // namespace ui
diff --git a/chromium/ui/accessibility/tree_generator.h b/chromium/ui/accessibility/tree_generator.h
index cd0b2b14bbb..509cd21ffad 100644
--- a/chromium/ui/accessibility/tree_generator.h
+++ b/chromium/ui/accessibility/tree_generator.h
@@ -2,8 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifndef UI_ACCESSIBILITY_TREE_GENERATOR_H_
+#define UI_ACCESSIBILITY_TREE_GENERATOR_H_
+
#include <vector>
+#include "ui/accessibility/ax_tree_update_forward.h"
+
namespace ui {
class AXTree;
@@ -45,13 +50,23 @@ class TreeGenerator {
TreeGenerator(int max_node_count, bool permutations);
~TreeGenerator();
+ // Build all unique trees (no nodes ignored).
int UniqueTreeCount() const;
-
void BuildUniqueTree(int tree_index, AXTree* out_tree) const;
+ // Support for returning every permutation of ignored nodes
+ // (other than the root, which is never ignored) per unique tree.
+ int IgnoredPermutationCountPerUniqueTree(int tree_index) const;
+ void BuildUniqueTreeWithIgnoredNodes(int tree_index,
+ int ignored_index,
+ AXTree* out_tree) const;
+
private:
- void BuildUniqueTreeWithSize(
- int node_count, int tree_index, AXTree* out_tree) const;
+ void BuildUniqueTreeUpdate(int tree_index,
+ AXTreeUpdate* out_tree_update) const;
+ void BuildUniqueTreeUpdateWithSize(int node_count,
+ int tree_index,
+ AXTreeUpdate* out_tree_update) const;
int max_node_count_;
bool permutations_;
@@ -60,3 +75,5 @@ class TreeGenerator {
};
} // namespace ui
+
+#endif // UI_ACCESSIBILITY_TREE_GENERATOR_H_
diff --git a/chromium/ui/android/BUILD.gn b/chromium/ui/android/BUILD.gn
index 1ed762d23e5..0f5c728944c 100644
--- a/chromium/ui/android/BUILD.gn
+++ b/chromium/ui/android/BUILD.gn
@@ -66,7 +66,7 @@ component("android") {
"//skia",
"//third_party/blink/public:blink_headers",
"//ui/base",
- "//ui/base/mojom:cursor_type",
+ "//ui/base/cursor/mojom:cursor_type",
"//ui/compositor",
"//ui/display",
"//ui/events",
@@ -121,61 +121,10 @@ java_cpp_enum("java_enums_srcjar") {
java_strings_grd("ui_strings_grd") {
grd_file = "java/strings/android_ui_strings.grd"
- outputs = [
- "values/android_ui_strings.xml",
- "values-am/android_ui_strings.xml",
- "values-ar/android_ui_strings.xml",
- "values-bg/android_ui_strings.xml",
- "values-bn/android_ui_strings.xml",
- "values-ca/android_ui_strings.xml",
- "values-cs/android_ui_strings.xml",
- "values-da/android_ui_strings.xml",
- "values-de/android_ui_strings.xml",
- "values-el/android_ui_strings.xml",
- "values-en-rGB/android_ui_strings.xml",
- "values-es/android_ui_strings.xml",
- "values-es-rUS/android_ui_strings.xml",
- "values-et/android_ui_strings.xml",
- "values-fa/android_ui_strings.xml",
- "values-fi/android_ui_strings.xml",
- "values-fr/android_ui_strings.xml",
- "values-gu/android_ui_strings.xml",
- "values-hi/android_ui_strings.xml",
- "values-hr/android_ui_strings.xml",
- "values-hu/android_ui_strings.xml",
- "values-in/android_ui_strings.xml",
- "values-it/android_ui_strings.xml",
- "values-iw/android_ui_strings.xml",
- "values-ja/android_ui_strings.xml",
- "values-kn/android_ui_strings.xml",
- "values-ko/android_ui_strings.xml",
- "values-lt/android_ui_strings.xml",
- "values-lv/android_ui_strings.xml",
- "values-ml/android_ui_strings.xml",
- "values-mr/android_ui_strings.xml",
- "values-ms/android_ui_strings.xml",
- "values-nb/android_ui_strings.xml",
- "values-nl/android_ui_strings.xml",
- "values-pl/android_ui_strings.xml",
- "values-pt-rBR/android_ui_strings.xml",
- "values-pt-rPT/android_ui_strings.xml",
- "values-ro/android_ui_strings.xml",
- "values-ru/android_ui_strings.xml",
- "values-sk/android_ui_strings.xml",
- "values-sl/android_ui_strings.xml",
- "values-sr/android_ui_strings.xml",
- "values-sv/android_ui_strings.xml",
- "values-sw/android_ui_strings.xml",
- "values-ta/android_ui_strings.xml",
- "values-te/android_ui_strings.xml",
- "values-th/android_ui_strings.xml",
- "values-tl/android_ui_strings.xml",
- "values-tr/android_ui_strings.xml",
- "values-uk/android_ui_strings.xml",
- "values-vi/android_ui_strings.xml",
- "values-zh-rCN/android_ui_strings.xml",
- "values-zh-rTW/android_ui_strings.xml",
- ]
+ outputs = [ "values/android_ui_strings.xml" ] +
+ process_file_template(
+ android_bundle_locales_as_resources,
+ [ "values-{{source_name_part}}/android_ui_strings.xml" ])
}
android_resources("ui_java_resources") {
@@ -195,21 +144,26 @@ android_resources("ui_java_resources") {
"java/res/color/filled_button_bg.xml",
"java/res/color/filled_button_ripple_color.xml",
"java/res/color/text_button_ripple_color.xml",
+ "java/res/drawable-hdpi/btn_close.png",
"java/res/drawable-hdpi/ic_expand_less_black_24dp.png",
"java/res/drawable-hdpi/ic_expand_more_black_24dp.png",
"java/res/drawable-hdpi/popup_bg.9.png",
+ "java/res/drawable-mdpi/btn_close.png",
"java/res/drawable-mdpi/ic_expand_less_black_24dp.png",
"java/res/drawable-mdpi/ic_expand_more_black_24dp.png",
"java/res/drawable-mdpi/popup_bg.9.png",
"java/res/drawable-v21/popup_bg_tinted.xml",
"java/res/drawable-v21/transition_expand_less_expand_more_black_24dp.xml",
"java/res/drawable-v21/transition_expand_more_expand_less_black_24dp.xml",
+ "java/res/drawable-xhdpi/btn_close.png",
"java/res/drawable-xhdpi/ic_expand_less_black_24dp.png",
"java/res/drawable-xhdpi/ic_expand_more_black_24dp.png",
"java/res/drawable-xhdpi/popup_bg.9.png",
+ "java/res/drawable-xxhdpi/btn_close.png",
"java/res/drawable-xxhdpi/ic_expand_less_black_24dp.png",
"java/res/drawable-xxhdpi/ic_expand_more_black_24dp.png",
"java/res/drawable-xxhdpi/popup_bg.9.png",
+ "java/res/drawable-xxxhdpi/btn_close.png",
"java/res/drawable-xxxhdpi/ic_expand_less_black_24dp.png",
"java/res/drawable-xxxhdpi/ic_expand_more_black_24dp.png",
"java/res/drawable-xxxhdpi/popup_bg.9.png",
@@ -293,6 +247,7 @@ android_library("ui_full_java") {
"java/src/org/chromium/ui/base/EventForwarder.java",
"java/src/org/chromium/ui/base/EventOffsetHandler.java",
"java/src/org/chromium/ui/base/IdleDetector.java",
+ "java/src/org/chromium/ui/base/ImmutableWeakReference.java",
"java/src/org/chromium/ui/base/IntentWindowAndroid.java",
"java/src/org/chromium/ui/base/LocalizationUtils.java",
"java/src/org/chromium/ui/base/PermissionCallback.java",
@@ -362,8 +317,6 @@ android_library("ui_full_java") {
"java/src/org/chromium/ui/resources/system/SystemResourceLoader.java",
"java/src/org/chromium/ui/text/NoUnderlineClickableSpan.java",
"java/src/org/chromium/ui/text/SpanApplier.java",
- "java/src/org/chromium/ui/touchless/CursorObserver.java",
- "java/src/org/chromium/ui/touchless/TouchlessEventHandler.java",
"java/src/org/chromium/ui/util/ColorUtils.java",
"java/src/org/chromium/ui/util/TokenHolder.java",
"java/src/org/chromium/ui/vr/VrModeObserver.java",
@@ -394,7 +347,7 @@ android_library("ui_full_java") {
"//third_party/android_deps:androidx_annotation_annotation_java",
"//third_party/android_deps:androidx_asynclayoutinflater_asynclayoutinflater_java",
"//third_party/android_deps:androidx_recyclerview_recyclerview_java",
- "//ui/base/mojom:cursor_type_java",
+ "//ui/base/cursor/mojom:cursor_type_java",
]
annotation_processor_deps = [ "//base/android/jni_generator:jni_processor" ]
srcjar_deps = [ ":java_enums_srcjar" ]
@@ -452,6 +405,7 @@ junit_binary("ui_junit_tests") {
"junit/src/org/chromium/ui/modelutil/PropertyListModelTest.java",
"junit/src/org/chromium/ui/modelutil/PropertyModelTest.java",
"junit/src/org/chromium/ui/modelutil/SimpleListObservableTest.java",
+ "junit/src/org/chromium/ui/modelutil/SimpleRecyclerViewAdapterTest.java",
"junit/src/org/chromium/ui/resources/dynamics/BitmapDynamicResourceTest.java",
"junit/src/org/chromium/ui/resources/dynamics/ViewResourceAdapterTest.java",
"junit/src/org/chromium/ui/shadows/ShadowAnimatedStateListDrawable.java",
diff --git a/chromium/ui/android/delegated_frame_host_android.cc b/chromium/ui/android/delegated_frame_host_android.cc
index a9ee3fe218f..da695040108 100644
--- a/chromium/ui/android/delegated_frame_host_android.cc
+++ b/chromium/ui/android/delegated_frame_host_android.cc
@@ -6,7 +6,8 @@
#include "base/android/build_info.h"
#include "base/bind.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "cc/layers/solid_color_layer.h"
#include "cc/layers/surface_layer.h"
#include "cc/trees/layer_tree_host.h"
@@ -109,15 +110,22 @@ void DelegatedFrameHostAndroid::CopyFromCompositingSurface(
base::OnceCallback<void(const SkBitmap&)> callback) {
DCHECK(CanCopyFromCompositingSurface());
+ std::unique_ptr<ui::WindowAndroidCompositor::ReadbackRef> readback_ref;
+ if (view_->GetWindowAndroid() && view_->GetWindowAndroid()->GetCompositor()) {
+ readback_ref =
+ view_->GetWindowAndroid()->GetCompositor()->TakeReadbackRef();
+ }
std::unique_ptr<viz::CopyOutputRequest> request =
std::make_unique<viz::CopyOutputRequest>(
viz::CopyOutputRequest::ResultFormat::RGBA_BITMAP,
base::BindOnce(
[](base::OnceCallback<void(const SkBitmap&)> callback,
+ std::unique_ptr<ui::WindowAndroidCompositor::ReadbackRef>
+ readback_ref,
std::unique_ptr<viz::CopyOutputResult> result) {
std::move(callback).Run(result->AsSkBitmap());
},
- std::move(callback)));
+ std::move(callback), std::move(readback_ref)));
if (!src_subrect.IsEmpty())
request->set_area(src_subrect);
diff --git a/chromium/ui/android/dummy_screen_android.cc b/chromium/ui/android/dummy_screen_android.cc
index 7e8e2db49db..489d2e0ace8 100644
--- a/chromium/ui/android/dummy_screen_android.cc
+++ b/chromium/ui/android/dummy_screen_android.cc
@@ -33,6 +33,12 @@ class DummyScreenAndroid : public display::Screen {
return NULL;
}
+ gfx::NativeWindow GetLocalProcessWindowAtPoint(
+ const gfx::Point& point,
+ const std::set<gfx::NativeWindow>& ignore) override {
+ return nullptr;
+ }
+
int GetNumDisplays() const override { return 1; }
const std::vector<Display>& GetAllDisplays() const override {
diff --git a/chromium/ui/android/edge_effect_base.cc b/chromium/ui/android/edge_effect_base.cc
index 2572754174a..5d04175dfbf 100644
--- a/chromium/ui/android/edge_effect_base.cc
+++ b/chromium/ui/android/edge_effect_base.cc
@@ -4,6 +4,8 @@
#include "ui/android/edge_effect_base.h"
+#include "base/notreached.h"
+
namespace ui {
// static
diff --git a/chromium/ui/android/junit/src/org/chromium/ui/modelutil/ListModelBaseTest.java b/chromium/ui/android/junit/src/org/chromium/ui/modelutil/ListModelBaseTest.java
index f9bc276a172..6493d15df40 100644
--- a/chromium/ui/android/junit/src/org/chromium/ui/modelutil/ListModelBaseTest.java
+++ b/chromium/ui/android/junit/src/org/chromium/ui/modelutil/ListModelBaseTest.java
@@ -20,6 +20,8 @@ import org.robolectric.annotation.Config;
import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.ui.modelutil.ListObservable.ListObserver;
+import java.util.Arrays;
+
/**
* Basic test ensuring the {@link ListModel} notifies listeners properly.
* TODO(yuezhanggg) Merge this test with SimpleListObservableTest.
@@ -57,6 +59,10 @@ public class ListModelBaseTest {
verify(mObserver).onItemRangeInserted(mIntegerList, 3, 1);
assertThat(mIntegerList.size(), is(4));
assertThat(mIntegerList.get(3), is(55555));
+
+ // Adding multiple items also triggers event.
+ mIntegerList.addAll(Arrays.asList(333, 88888888, 22), 2);
+ verify(mObserver).onItemRangeInserted(mIntegerList, 2, 3);
}
@Test
@@ -127,4 +133,4 @@ public class ListModelBaseTest {
mIntegerList.set(new Integer[] {});
verifyNoMoreInteractions(mObserver);
}
-} \ No newline at end of file
+}
diff --git a/chromium/ui/android/junit/src/org/chromium/ui/modelutil/PropertyListModelTest.java b/chromium/ui/android/junit/src/org/chromium/ui/modelutil/PropertyListModelTest.java
index c88a5e4dba2..342e48e7e10 100644
--- a/chromium/ui/android/junit/src/org/chromium/ui/modelutil/PropertyListModelTest.java
+++ b/chromium/ui/android/junit/src/org/chromium/ui/modelutil/PropertyListModelTest.java
@@ -26,7 +26,7 @@ import java.util.List;
@RunWith(BaseRobolectricTestRunner.class)
@Config(manifest = Config.NONE)
public class PropertyListModelTest implements ListObservable.ListObserver<PropertyKey> {
- private static final int METHOD_COUNT = 32;
+ private static final int METHOD_COUNT = 33;
private static final PropertyModel.WritableIntPropertyKey INTEGER_KEY =
new PropertyModel.WritableIntPropertyKey();
diff --git a/chromium/ui/android/junit/src/org/chromium/ui/modelutil/SimpleRecyclerViewAdapterTest.java b/chromium/ui/android/junit/src/org/chromium/ui/modelutil/SimpleRecyclerViewAdapterTest.java
new file mode 100644
index 00000000000..c96dd990af5
--- /dev/null
+++ b/chromium/ui/android/junit/src/org/chromium/ui/modelutil/SimpleRecyclerViewAdapterTest.java
@@ -0,0 +1,145 @@
+// Copyright 2020 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.
+
+package org.chromium.ui.modelutil;
+
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+import android.view.View;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+import org.robolectric.annotation.Config;
+
+import org.chromium.base.test.BaseRobolectricTestRunner;
+import org.chromium.ui.modelutil.MVCListAdapter.ModelList;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Tests to ensure/validate SimpleRecyclerViewAdapter behavior.
+ */
+@RunWith(BaseRobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class SimpleRecyclerViewAdapterTest {
+ private static final PropertyModel.WritableIntPropertyKey INT_PROPERTY =
+ new PropertyModel.WritableIntPropertyKey();
+ private static final Integer VIEW_TYPE_1 = 1;
+ private static final Integer VIEW_TYPE_2 = 2;
+ private static final Integer VIEW_TYPE_3 = 3;
+
+ private ModelList mModelList;
+ private PropertyModel mModel;
+
+ // Mockito Spies allow us to intercept calls to parent class.
+ private SimpleRecyclerViewAdapter mSpyAdapter;
+
+ @Mock
+ View mMockView;
+
+ @Before
+ public void setUp() {
+ MockitoAnnotations.initMocks(this);
+
+ mModel = new PropertyModel(INT_PROPERTY);
+ mModelList = new ModelList();
+
+ // Note: this behaves both like a mock and a real object.
+ // Methods calls can be mocked or tracked to validate class behavior.
+ mSpyAdapter = Mockito.mock(SimpleRecyclerViewAdapter.class,
+ Mockito.withSettings()
+ .useConstructor(mModelList)
+ .defaultAnswer(Mockito.CALLS_REAL_METHODS));
+
+ mSpyAdapter.registerType(VIEW_TYPE_1, parent -> mMockView, (m, v, p) -> {});
+ mSpyAdapter.registerType(VIEW_TYPE_2, parent -> mMockView, (m, v, p) -> {});
+ mSpyAdapter.registerType(VIEW_TYPE_3, parent -> mMockView, (m, v, p) -> {});
+ }
+
+ @Test
+ public void testObserver_listModelItemsAdded() {
+ mModelList.add(new ModelListAdapter.ListItem(VIEW_TYPE_1, mModel));
+ verify(mSpyAdapter, times(1)).notifyItemRangeInserted(0, 1);
+ mModelList.add(new ModelListAdapter.ListItem(VIEW_TYPE_2, mModel));
+ verify(mSpyAdapter, times(1)).notifyItemRangeInserted(1, 1);
+ }
+
+ @Test
+ public void testObserver_listModelItemsAddedInBatch() {
+ mModelList.add(new ModelListAdapter.ListItem(VIEW_TYPE_1, mModel));
+ verify(mSpyAdapter, times(1)).notifyItemRangeInserted(0, 1);
+ List<ModelListAdapter.ListItem> items = new ArrayList<>();
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_1, mModel));
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_2, mModel));
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_3, mModel));
+ mModelList.addAll(items);
+ verify(mSpyAdapter, times(1)).notifyItemRangeInserted(1, 3);
+ }
+
+ @Test
+ public void testObserver_listModelItemsSet() {
+ List<ModelListAdapter.ListItem> items = new ArrayList<>();
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_1, mModel));
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_2, mModel));
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_3, mModel));
+ mModelList.set(items);
+ verify(mSpyAdapter, times(1)).notifyItemRangeInserted(0, 3);
+ }
+
+ @Test
+ public void testObserver_listModelItemsRemove() {
+ List<ModelListAdapter.ListItem> items = new ArrayList<>();
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_1, mModel));
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_2, mModel));
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_3, mModel));
+ mModelList.set(items);
+ verify(mSpyAdapter, times(1)).notifyItemRangeInserted(0, 3);
+ mModelList.removeRange(0, 2);
+ verify(mSpyAdapter, times(1)).notifyItemRangeRemoved(0, 2);
+ }
+
+ @Test
+ public void testObserver_listModelItemsClear() {
+ List<ModelListAdapter.ListItem> items = new ArrayList<>();
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_1, mModel));
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_2, mModel));
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_3, mModel));
+ mModelList.set(items);
+ verify(mSpyAdapter, times(1)).notifyItemRangeInserted(0, 3);
+ mModelList.clear();
+ verify(mSpyAdapter, times(1)).notifyItemRangeRemoved(0, 3);
+ }
+
+ @Test
+ public void testObserver_listModelItemMoved() {
+ List<ModelListAdapter.ListItem> items = new ArrayList<>();
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_1, mModel));
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_2, mModel));
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_3, mModel));
+ mModelList.set(items);
+ verify(mSpyAdapter, times(1)).notifyItemRangeInserted(0, 3);
+
+ mModelList.move(1, 2);
+ verify(mSpyAdapter, times(1)).notifyItemMoved(1, 2);
+ }
+
+ @Test
+ public void testObserver_listModelItemUpdated() {
+ List<ModelListAdapter.ListItem> items = new ArrayList<>();
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_1, mModel));
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_2, mModel));
+ items.add(new ModelListAdapter.ListItem(VIEW_TYPE_3, mModel));
+ mModelList.set(items);
+ verify(mSpyAdapter, times(1)).notifyItemRangeInserted(0, 3);
+
+ mModelList.update(1, new ModelListAdapter.ListItem(VIEW_TYPE_2, mModel));
+ verify(mSpyAdapter, times(1)).notifyItemRangeChanged(1, 1);
+ }
+}
diff --git a/chromium/ui/android/junit/src/org/chromium/ui/resources/dynamics/ViewResourceAdapterTest.java b/chromium/ui/android/junit/src/org/chromium/ui/resources/dynamics/ViewResourceAdapterTest.java
index e86336af926..1391e23bf1f 100644
--- a/chromium/ui/android/junit/src/org/chromium/ui/resources/dynamics/ViewResourceAdapterTest.java
+++ b/chromium/ui/android/junit/src/org/chromium/ui/resources/dynamics/ViewResourceAdapterTest.java
@@ -19,14 +19,12 @@ import android.graphics.Canvas;
import android.graphics.Rect;
import android.view.View;
-import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.robolectric.annotation.Config;
-import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.test.BaseRobolectricTestRunner;
import java.lang.ref.WeakReference;
@@ -63,12 +61,6 @@ public class ViewResourceAdapterTest {
protected void capture(Canvas canvas) {}
};
- RecordHistogram.setDisabledForTests(true);
- }
-
- @After
- public void tearDown() {
- RecordHistogram.setDisabledForTests(false);
}
@Test
diff --git a/chromium/ui/android/overscroll_refresh.cc b/chromium/ui/android/overscroll_refresh.cc
index e99b7664b96..14a9bf2b3ac 100644
--- a/chromium/ui/android/overscroll_refresh.cc
+++ b/chromium/ui/android/overscroll_refresh.cc
@@ -4,7 +4,8 @@
#include "ui/android/overscroll_refresh.h"
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "cc/input/overscroll_behavior.h"
#include "ui/android/overscroll_refresh_handler.h"
#include "ui/gfx/geometry/point_f.h"
diff --git a/chromium/ui/android/view_android.cc b/chromium/ui/android/view_android.cc
index 83722089ea5..7d2e6ded2f0 100644
--- a/chromium/ui/android/view_android.cc
+++ b/chromium/ui/android/view_android.cc
@@ -17,8 +17,8 @@
#include "ui/android/event_forwarder.h"
#include "ui/android/ui_android_jni_headers/ViewAndroidDelegate_jni.h"
#include "ui/android/window_android.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/layout.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
#include "ui/events/android/drag_event_android.h"
#include "ui/events/android/event_handler_android.h"
#include "ui/events/android/gesture_event_android.h"
@@ -434,7 +434,6 @@ void ViewAndroid::OnTopControlsChanged(float top_controls_offset,
void ViewAndroid::OnBottomControlsChanged(
float bottom_controls_offset,
- float bottom_content_offset,
float bottom_controls_min_height_offset) {
ScopedJavaLocalRef<jobject> delegate(GetViewAndroidDelegate());
if (delegate.is_null())
@@ -442,7 +441,6 @@ void ViewAndroid::OnBottomControlsChanged(
JNIEnv* env = base::android::AttachCurrentThread();
Java_ViewAndroidDelegate_onBottomControlsChanged(
env, delegate, std::round(bottom_controls_offset),
- std::round(bottom_content_offset),
std::round(bottom_controls_min_height_offset));
}
@@ -665,44 +663,4 @@ void ViewAndroid::SetLayoutForTesting(int x, int y, int width, int height) {
bounds_.SetRect(x, y, width, height);
}
-bool ViewAndroid::HasTouchlessEventHandler() {
- JNIEnv* env = base::android::AttachCurrentThread();
- static bool s_has_touchless_event_handler =
- Java_ViewAndroidDelegate_hasTouchlessEventHandler(env);
-
- return s_has_touchless_event_handler;
-}
-
-bool ViewAndroid::OnUnconsumedKeyboardEventAck(int native_code) {
- if (!HasTouchlessEventHandler())
- return false;
-
- JNIEnv* env = base::android::AttachCurrentThread();
-
- return Java_ViewAndroidDelegate_onUnconsumedKeyboardEventAck(env,
- native_code);
-}
-
-void ViewAndroid::FallbackCursorModeLockCursor(bool left,
- bool right,
- bool up,
- bool down) {
- if (!HasTouchlessEventHandler())
- return;
-
- JNIEnv* env = base::android::AttachCurrentThread();
-
- Java_ViewAndroidDelegate_fallbackCursorModeLockCursor(env, left, right, up,
- down);
-}
-
-void ViewAndroid::FallbackCursorModeSetCursorVisibility(bool visible) {
- if (!HasTouchlessEventHandler())
- return;
-
- JNIEnv* env = base::android::AttachCurrentThread();
-
- Java_ViewAndroidDelegate_fallbackCursorModeSetCursorVisibility(env, visible);
-}
-
} // namespace ui
diff --git a/chromium/ui/android/view_android.h b/chromium/ui/android/view_android.h
index ca130319719..cf88a186583 100644
--- a/chromium/ui/android/view_android.h
+++ b/chromium/ui/android/view_android.h
@@ -162,7 +162,6 @@ class UI_ANDROID_EXPORT ViewAndroid {
float top_content_offset,
float top_controls_min_height_offset);
void OnBottomControlsChanged(float bottom_controls_offset,
- float bottom_content_offset,
float bottom_controls_min_height_offset);
void OnBrowserControlsHeightChanged();
@@ -204,10 +203,6 @@ class UI_ANDROID_EXPORT ViewAndroid {
return OnTouchEvent(event);
}
- bool OnUnconsumedKeyboardEventAck(int native_code);
- void FallbackCursorModeLockCursor(bool left, bool right, bool up, bool down);
- void FallbackCursorModeSetCursorVisibility(bool visible);
-
protected:
void RemoveAllChildren(bool attached_to_window);
@@ -275,8 +270,6 @@ class UI_ANDROID_EXPORT ViewAndroid {
void OnSizeChangedInternal(const gfx::Size& size);
void DispatchOnSizeChanged();
- bool HasTouchlessEventHandler();
-
// Returns the Java delegate for this view. This is used to delegate work
// up to the embedding view (or the embedder that can deal with the
// implementation details).
diff --git a/chromium/ui/android/window_android.cc b/chromium/ui/android/window_android.cc
index c7d8d996439..8f8e75ff09e 100644
--- a/chromium/ui/android/window_android.cc
+++ b/chromium/ui/android/window_android.cc
@@ -198,22 +198,6 @@ void WindowAndroid::SetVSyncPaused(JNIEnv* env,
compositor_->SetVSyncPaused(paused);
}
-void WindowAndroid::OnCursorVisibilityChanged(
- JNIEnv* env,
- const base::android::JavaParamRef<jobject>& obj,
- bool visible) {
- for (WindowAndroidObserver& observer : observer_list_)
- observer.OnCursorVisibilityChanged(visible);
-}
-
-void WindowAndroid::OnFallbackCursorModeToggled(
- JNIEnv* env,
- const base::android::JavaParamRef<jobject>& obj,
- bool is_on) {
- for (WindowAndroidObserver& observer : observer_list_)
- observer.OnFallbackCursorModeToggled(is_on);
-}
-
void WindowAndroid::OnUpdateRefreshRate(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
@@ -238,6 +222,11 @@ void WindowAndroid::OnSupportedRefreshRatesUpdated(
Force60HzRefreshRateIfNeeded();
}
+void WindowAndroid::SetWideColorEnabled(bool enabled) {
+ JNIEnv* env = AttachCurrentThread();
+ Java_WindowAndroid_setWideColorEnabled(env, GetJavaObject(), enabled);
+}
+
void WindowAndroid::SetForce60HzRefreshRate() {
if (force_60hz_refresh_rate_)
return;
diff --git a/chromium/ui/android/window_android.h b/chromium/ui/android/window_android.h
index 21aa04c1d90..d6d0ac73706 100644
--- a/chromium/ui/android/window_android.h
+++ b/chromium/ui/android/window_android.h
@@ -69,10 +69,6 @@ class UI_ANDROID_EXPORT WindowAndroid : public ViewAndroid {
void OnVisibilityChanged(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
bool visible);
- void OnFallbackCursorModeToggled(
- JNIEnv* env,
- const base::android::JavaParamRef<jobject>& obj,
- bool is_on);
void OnActivityStopped(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj);
void OnActivityStarted(JNIEnv* env,
@@ -80,10 +76,6 @@ class UI_ANDROID_EXPORT WindowAndroid : public ViewAndroid {
void SetVSyncPaused(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
bool paused);
- void OnCursorVisibilityChanged(
- JNIEnv* env,
- const base::android::JavaParamRef<jobject>& obj,
- bool visible);
void OnUpdateRefreshRate(JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
float refresh_rate);
@@ -110,6 +102,8 @@ class UI_ANDROID_EXPORT WindowAndroid : public ViewAndroid {
// See comment on WindowAndroid.getWindowIsWideColorGamut for details.
display::Display GetDisplayWithWindowColorSpace();
+ void SetWideColorEnabled(bool enabled);
+
void SetForce60HzRefreshRate();
bool ApplyDisableSurfaceControlWorkaround();
diff --git a/chromium/ui/android/window_android_compositor.h b/chromium/ui/android/window_android_compositor.h
index d299b657429..20f07b27a17 100644
--- a/chromium/ui/android/window_android_compositor.h
+++ b/chromium/ui/android/window_android_compositor.h
@@ -12,10 +12,6 @@
#include "ui/android/ui_android_export.h"
#include "ui/compositor/compositor_lock.h"
-namespace cc {
-class Layer;
-}
-
namespace ui {
class ResourceManager;
@@ -25,7 +21,19 @@ class UI_ANDROID_EXPORT WindowAndroidCompositor {
public:
virtual ~WindowAndroidCompositor() {}
- virtual void AttachLayerForReadback(scoped_refptr<cc::Layer> layer) = 0;
+ // Ref must be destroyed on same thread as WindowAndroidCompositor.
+ class ReadbackRef {
+ public:
+ virtual ~ReadbackRef() = default;
+
+ protected:
+ ReadbackRef() = default;
+ };
+
+ // While there are outstanding ReadbackRefs, Compositor will attempt to
+ // ensure any pending viz::CopyOutputRequest in any part of the compositor
+ // surface tree are fulfilled in a timely manner.
+ virtual std::unique_ptr<ReadbackRef> TakeReadbackRef() = 0;
virtual void RequestCopyOfOutputOnRootLayer(
std::unique_ptr<viz::CopyOutputRequest> request) = 0;
virtual void SetNeedsAnimate() = 0;
diff --git a/chromium/ui/android/window_android_observer.h b/chromium/ui/android/window_android_observer.h
index 065b455fde4..0a07fd84385 100644
--- a/chromium/ui/android/window_android_observer.h
+++ b/chromium/ui/android/window_android_observer.h
@@ -22,8 +22,6 @@ class UI_ANDROID_EXPORT WindowAndroidObserver {
// should account for whether or not this is the case.
virtual void OnActivityStopped() = 0;
virtual void OnActivityStarted() = 0;
- virtual void OnCursorVisibilityChanged(bool visible) {}
- virtual void OnFallbackCursorModeToggled(bool is_on) {}
protected:
virtual ~WindowAndroidObserver() {}
diff --git a/chromium/ui/aura/BUILD.gn b/chromium/ui/aura/BUILD.gn
index ef3c22fd6a7..633a0bb87db 100644
--- a/chromium/ui/aura/BUILD.gn
+++ b/chromium/ui/aura/BUILD.gn
@@ -119,8 +119,8 @@ jumbo_component("aura") {
"//skia",
"//ui/base",
"//ui/base/clipboard",
+ "//ui/base/cursor/mojom:cursor_type",
"//ui/base/ime/init",
- "//ui/base/mojom:cursor_type",
"//ui/display",
"//ui/events",
"//ui/events:dom_keyboard_layout",
@@ -226,8 +226,8 @@ jumbo_static_library("test_support") {
"//testing/gtest",
"//ui/base:test_support",
"//ui/base/cursor",
+ "//ui/base/cursor/mojom:cursor_type",
"//ui/base/ime/init",
- "//ui/base/mojom:cursor_type",
"//ui/compositor:test_support",
"//ui/display",
"//ui/display/manager",
diff --git a/chromium/ui/aura/demo/demo_main.cc b/chromium/ui/aura/demo/demo_main.cc
index 0b1c1cab40a..235f635a06e 100644
--- a/chromium/ui/aura/demo/demo_main.cc
+++ b/chromium/ui/aura/demo/demo_main.cc
@@ -42,10 +42,6 @@
#include "ui/gl/gl_switches.h"
#include "ui/gl/init/gl_factory.h"
-#if defined(USE_X11)
-#include "ui/gfx/x/x11_connection.h" // nogncheck
-#endif
-
#if defined(OS_WIN)
#include "ui/display/win/dpi.h"
#endif
@@ -158,12 +154,6 @@ void RunRunLoopUntilOnHostCloseRequested(aura::WindowTreeHost* host) {
}
int DemoMain() {
-#if defined(USE_X11)
- // This demo uses InProcessContextFactory which uses X on a separate Gpu
- // thread.
- gfx::InitializeThreadedX11();
-#endif
-
gl::init::InitializeGLOneOff();
#if defined(OS_WIN)
diff --git a/chromium/ui/aura/env.cc b/chromium/ui/aura/env.cc
index 9f30162d3cd..56d2ef94f1c 100644
--- a/chromium/ui/aura/env.cc
+++ b/chromium/ui/aura/env.cc
@@ -218,7 +218,6 @@ void Env::Init() {
// instead of checking flags here.
params.single_process = command_line->HasSwitch("single-process") ||
command_line->HasSwitch("in-process-gpu");
- params.using_mojo = features::IsOzoneDrmMojo();
ui::OzonePlatform::InitializeForUI(params);
#endif
diff --git a/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc b/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc
index ec817fc53a9..a796c62911f 100644
--- a/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc
+++ b/chromium/ui/aura/gestures/gesture_recognizer_unittest.cc
@@ -508,8 +508,7 @@ class TimedEvents {
y += dy;
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(x, y), tick_clock_.NowTicks(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- touch_id));
+ ui::PointerDetails(ui::EventPointerType::kTouch, touch_id));
ui::EventDispatchDetails details = sink->OnEventFromSource(&move);
ASSERT_FALSE(details.dispatcher_destroyed);
tick_clock_.Advance(base::TimeDelta::FromMilliseconds(time_step_ms));
@@ -524,7 +523,7 @@ class TimedEvents {
delegate->Reset();
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(), Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, touch_id));
+ ui::PointerDetails(ui::EventPointerType::kTouch, touch_id));
move.set_location_f(gfx::PointF(x, y));
move.set_root_location_f(gfx::PointF(x, y));
ui::EventDispatchDetails details = sink->OnEventFromSource(&move);
@@ -629,10 +628,9 @@ void SetTouchRadius(ui::TouchEvent* event, float radius_x, float radius_y) {
// Using ctor (over direct struct access) due to it's special behavior with
// radii.
ui::PointerDetails details(
- ui::EventPointerType::POINTER_TYPE_TOUCH, event->pointer_details().id,
- radius_x, radius_y, event->pointer_details().force,
- event->pointer_details().twist, event->pointer_details().tilt_x,
- event->pointer_details().tilt_y,
+ ui::EventPointerType::kTouch, event->pointer_details().id, radius_x,
+ radius_y, event->pointer_details().force, event->pointer_details().twist,
+ event->pointer_details().tilt_x, event->pointer_details().tilt_y,
event->pointer_details().tangential_pressure);
event->SetPointerDetailsForTest(details);
@@ -687,7 +685,7 @@ TEST_F(GestureRecognizerTest, TouchCancelCanDestroyWindow) {
// Dispatch an event to |host_window| that will be cancelled.
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 101), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
// Cancel event, verify there is no crash.
@@ -714,7 +712,7 @@ TEST_F(GestureRecognizerTest, GestureEventTap) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->show_press());
@@ -736,7 +734,7 @@ TEST_F(GestureRecognizerTest, GestureEventTap) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_TRUE(delegate->tap());
@@ -769,8 +767,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
SetTouchRadius(&press, 5, 12);
DispatchEventUsingWindowDispatcher(&press);
EXPECT_FALSE(delegate->tap());
@@ -787,8 +784,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
SetTouchRadius(&release, 5, 12);
DispatchEventUsingWindowDispatcher(&release);
@@ -814,8 +810,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(365, 290), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
SetTouchRadius(&press, 8, 14);
DispatchEventUsingWindowDispatcher(&press);
EXPECT_FALSE(delegate->tap());
@@ -830,8 +825,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(367, 291), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
SetTouchRadius(&release, 20, 13);
DispatchEventUsingWindowDispatcher(&release);
@@ -857,8 +851,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(46, 205), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
SetTouchRadius(&press, 6, 10);
DispatchEventUsingWindowDispatcher(&press);
EXPECT_FALSE(delegate->tap());
@@ -874,8 +867,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
delegate->Reset();
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(49, 204), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
SetTouchRadius(&move, 8, 12);
DispatchEventUsingWindowDispatcher(&move);
EXPECT_FALSE(delegate->tap());
@@ -890,8 +882,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(49, 204), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
SetTouchRadius(&release, 4, 8);
DispatchEventUsingWindowDispatcher(&release);
@@ -917,8 +908,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(400, 150), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
SetTouchRadius(&press, 7, 10);
DispatchEventUsingWindowDispatcher(&press);
EXPECT_FALSE(delegate->tap());
@@ -933,8 +923,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
delegate->Reset();
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(397, 151), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
SetTouchRadius(&move, 13, 12);
DispatchEventUsingWindowDispatcher(&move);
EXPECT_FALSE(delegate->tap());
@@ -949,8 +938,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
delegate->Reset();
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(397, 149), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
SetTouchRadius(&move1, 16, 16);
DispatchEventUsingWindowDispatcher(&move1);
EXPECT_FALSE(delegate->tap());
@@ -965,8 +953,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
delegate->Reset();
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(400, 150), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
SetTouchRadius(&move2, 14, 10);
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_FALSE(delegate->tap());
@@ -981,8 +968,7 @@ TEST_F(GestureRecognizerTest, GestureEventTapRegion) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(401, 149), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
SetTouchRadius(&release, 8, 9);
DispatchEventUsingWindowDispatcher(&release);
@@ -1024,7 +1010,7 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_2_EVENTS(delegate->events(),
ui::ET_GESTURE_BEGIN,
@@ -1067,7 +1053,7 @@ TEST_F(GestureRecognizerTest, GestureEventScroll) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_2_EVENTS(delegate->events(),
ui::ET_SCROLL_FLING_START,
@@ -1099,7 +1085,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) {
gfx::Vector2dF total_scroll;
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(96, 196), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_2_EVENTS(delegate->events(),
ui::ET_GESTURE_BEGIN,
@@ -1109,7 +1095,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) {
// Get rid of touch slop.
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(111, 211), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move);
EXPECT_3_EVENTS(delegate->events(),
ui::ET_GESTURE_TAP_CANCEL,
@@ -1146,7 +1132,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollPrediction) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release);
}
@@ -1169,7 +1155,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(kPositionX, kPositionY), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_EQ(gfx::Rect(kPositionX - radius, kPositionY - radius, radius * 2,
radius * 2),
@@ -1191,7 +1177,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollBoundingBox) {
ui::ET_TOUCH_RELEASED,
gfx::Point(kPositionX + kScrollAmount, kPositionY + kScrollAmount),
press.time_stamp() + base::TimeDelta::FromMilliseconds(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_EQ(
gfx::Rect(kPositionX + kScrollAmount - radius,
@@ -1214,13 +1200,13 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) {
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
// Get rid of touch slop.
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(10, 0), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move);
delegate->Reset();
@@ -1239,7 +1225,7 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailFling) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_TRUE(delegate->fling());
@@ -1261,13 +1247,13 @@ TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) {
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
// Get rid of touch slop.
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(0, 10), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move);
delegate->Reset();
@@ -1287,7 +1273,7 @@ TEST_F(GestureRecognizerTest, GestureEventVerticalRailFling) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 206), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_TRUE(delegate->fling());
@@ -1311,7 +1297,7 @@ TEST_F(GestureRecognizerTest, GestureEventNonRailFling) {
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
// Move the touch-point such that a non-rail scroll begins, and we're outside
@@ -1327,7 +1313,7 @@ TEST_F(GestureRecognizerTest, GestureEventNonRailFling) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_TRUE(delegate->fling());
@@ -1351,7 +1337,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPress) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_TRUE(delegate->tap_down());
EXPECT_TRUE(delegate->begin());
@@ -1368,7 +1354,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPress) {
delegate->Reset();
ui::TouchEvent release1(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release1);
EXPECT_FALSE(delegate->long_press());
@@ -1393,7 +1379,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_TRUE(delegate->tap_down());
@@ -1414,7 +1400,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledByScroll) {
delegate->Reset();
ui::TouchEvent release1(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(10),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release1);
EXPECT_FALSE(delegate->long_press());
EXPECT_FALSE(delegate->tap_cancel());
@@ -1437,7 +1423,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongTap) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_TRUE(delegate->tap_down());
EXPECT_TRUE(delegate->begin());
@@ -1454,7 +1440,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongTap) {
delegate->Reset();
ui::TouchEvent release1(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release1);
EXPECT_FALSE(delegate->long_press());
EXPECT_TRUE(delegate->long_tap());
@@ -1480,7 +1466,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_TRUE(delegate->tap_down());
EXPECT_TRUE(delegate->begin());
@@ -1492,7 +1478,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) {
delegate->Reset();
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap.
EXPECT_TRUE(delegate->tap_cancel());
@@ -1507,7 +1493,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressCancelledBySecondTap) {
delegate->Reset();
ui::TouchEvent release1(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&release1);
EXPECT_FALSE(delegate->long_press());
EXPECT_TRUE(delegate->two_finger_tap());
@@ -1527,13 +1513,13 @@ TEST_F(GestureRecognizerTest, GestureEventHorizontalRailScroll) {
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
// Get rid of touch slop.
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(5, 0), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move);
delegate->Reset();
@@ -1578,13 +1564,13 @@ TEST_F(GestureRecognizerTest, GestureEventVerticalRailScroll) {
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
// Get rid of touch slop.
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(0, 5), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move);
delegate->Reset();
@@ -1637,7 +1623,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -1651,7 +1637,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_TRUE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -1665,7 +1651,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
delegate->Reset();
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.LeapForward(1000),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -1677,7 +1663,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
// Get rid of touch slop.
ui::TouchEvent move_remove_slop(
ui::ET_TOUCH_MOVED, gfx::Point(116, 216), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move_remove_slop);
EXPECT_TRUE(delegate->tap_cancel());
EXPECT_TRUE(delegate->scroll_begin());
@@ -1694,7 +1680,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
delegate->Reset();
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(135, 235), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -1709,7 +1695,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
delegate->Reset();
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(115, 216), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move1);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -1725,7 +1711,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
delegate->Reset();
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(145, 220), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -1740,7 +1726,7 @@ TEST_F(GestureRecognizerTest, GestureTapFollowedByScroll) {
delegate->Reset();
ui::TouchEvent release1(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release1);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -1769,7 +1755,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
queued_delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_FALSE(queued_delegate->tap());
EXPECT_FALSE(queued_delegate->tap_down());
@@ -1785,7 +1771,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
press.time_stamp() + base::TimeDelta::FromMilliseconds(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_FALSE(queued_delegate->tap());
EXPECT_FALSE(queued_delegate->tap_down());
@@ -1805,7 +1791,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
delegate->Reset();
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(10, 20), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -1818,7 +1804,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
ui::TouchEvent release2(
ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&release2);
// Process the first queued event.
@@ -1850,7 +1836,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
queued_delegate->Reset();
ui::TouchEvent press3(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press3);
EXPECT_FALSE(queued_delegate->tap());
EXPECT_FALSE(queued_delegate->tap_down());
@@ -1867,7 +1853,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
delegate->Reset();
ui::TouchEvent press4(
ui::ET_TOUCH_PRESSED, gfx::Point(103, 203), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press4);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -1895,8 +1881,7 @@ TEST_F(GestureRecognizerTest, AsynchronousGestureRecognition) {
gfx::Point(203 + ui::GestureConfiguration::GetInstance()
->max_touch_move_in_pixels_for_click(),
303),
- tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ tes.Now(), ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&move);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -1970,7 +1955,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_2_EVENTS(delegate->events(),
ui::ET_GESTURE_BEGIN,
@@ -1981,7 +1966,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
delegate->Reset();
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(130, 301), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move);
EXPECT_3_EVENTS(delegate->events(),
ui::ET_GESTURE_TAP_CANCEL,
@@ -1993,7 +1978,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
delegate->Reset();
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_BEGIN);
EXPECT_EQ(gfx::Rect(10, 10, 120, 291).ToString(),
@@ -2003,7 +1988,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
delegate->Reset();
ui::TouchEvent move3(
ui::ET_TOUCH_MOVED, gfx::Point(95, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move3);
EXPECT_3_EVENTS(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE,
ui::ET_GESTURE_PINCH_BEGIN, ui::ET_GESTURE_PINCH_UPDATE);
@@ -2014,7 +1999,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
delegate->Reset();
ui::TouchEvent move4(
ui::ET_TOUCH_MOVED, gfx::Point(55, 15), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&move4);
EXPECT_2_EVENTS(delegate->events(),
ui::ET_GESTURE_SCROLL_UPDATE,
@@ -2026,7 +2011,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_2_EVENTS(delegate->events(),
ui::ET_GESTURE_PINCH_END,
@@ -2038,7 +2023,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScroll) {
delegate->Reset();
ui::TouchEvent move5(
ui::ET_TOUCH_MOVED, gfx::Point(25, 10), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&move5);
EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
EXPECT_TRUE(delegate->bounding_box().IsEmpty());
@@ -2058,12 +2043,12 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) {
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press);
delegate->Reset();
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
EXPECT_FALSE(delegate->pinch_begin());
@@ -2081,7 +2066,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_TRUE(delegate->pinch_end());
@@ -2092,13 +2077,13 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromScrollFromPinch) {
delegate->Reset();
ui::TouchEvent press3(
ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press3);
// Now the touch points are close. So we will go into two finger tap.
// Move the touch-point enough to break two-finger-tap and enter pinch.
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(101, 50), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_TRUE(delegate->pinch_begin());
@@ -2121,7 +2106,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_2_EVENTS(delegate->events(),
ui::ET_GESTURE_BEGIN,
@@ -2132,7 +2117,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
delegate->Reset();
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
EXPECT_2_EVENTS(delegate->events(),
ui::ET_GESTURE_TAP_CANCEL,
@@ -2144,7 +2129,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
delegate->Reset();
ui::TouchEvent move3(
ui::ET_TOUCH_MOVED, gfx::Point(65, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move3);
EXPECT_4_EVENTS(delegate->events(), ui::ET_GESTURE_SCROLL_BEGIN,
ui::ET_GESTURE_SCROLL_UPDATE, ui::ET_GESTURE_PINCH_BEGIN,
@@ -2156,7 +2141,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
delegate->Reset();
ui::TouchEvent move4(
ui::ET_TOUCH_MOVED, gfx::Point(55, 15), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&move4);
EXPECT_2_EVENTS(delegate->events(),
ui::ET_GESTURE_SCROLL_UPDATE,
@@ -2168,7 +2153,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(10),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_2_EVENTS(delegate->events(),
ui::ET_GESTURE_PINCH_END,
@@ -2180,7 +2165,7 @@ TEST_F(GestureRecognizerTest, GestureEventPinchFromTap) {
delegate->Reset();
ui::TouchEvent move5(
ui::ET_TOUCH_MOVED, gfx::Point(25, 10), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&move5);
EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
EXPECT_TRUE(delegate->bounding_box().IsEmpty());
@@ -2191,9 +2176,9 @@ TEST_F(GestureRecognizerTest, GestureEventIgnoresDisconnectedEvents) {
new GestureEventConsumeDelegate());
TimedEvents tes;
- ui::TouchEvent release1(
- ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 6));
+ ui::TouchEvent release1(ui::ET_TOUCH_RELEASED, gfx::Point(101, 201),
+ tes.Now(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 6));
DispatchEventUsingWindowDispatcher(&release1);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -2230,9 +2215,9 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
windows[i] = CreateTestWindowWithDelegate(
delegates[i], i, window_bounds[i], root_window());
windows[i]->set_id(i);
- ui::TouchEvent press(
- ui::ET_TOUCH_PRESSED, window_bounds[i].origin(), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, i));
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, window_bounds[i].origin(),
+ tes.Now(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, i));
DispatchEventUsingWindowDispatcher(&press);
}
@@ -2254,13 +2239,11 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
// Add a touch in the middle associated with windows[2]
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(0, 500), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kNumWindows));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kNumWindows));
DispatchEventUsingWindowDispatcher(&press);
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(250, 250), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kNumWindows));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kNumWindows));
DispatchEventUsingWindowDispatcher(&move);
target =
@@ -2286,8 +2269,7 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockSelectsCorrectWindow) {
// Move a touch associated with windows[2] to 1000, 1000
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(1000, 1000), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kNumWindows));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kNumWindows));
DispatchEventUsingWindowDispatcher(&move2);
target =
@@ -2316,14 +2298,14 @@ TEST_F(GestureRecognizerTest, GestureEventTouchLockIgnoresOtherScreens) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(5, 5), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
ui::EventTestApi test_press1(&press1);
test_press1.set_source_device_id(1);
DispatchEventUsingWindowDispatcher(&press1);
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
ui::EventTestApi test_press2(&press2);
test_press2.set_source_device_id(2);
DispatchEventUsingWindowDispatcher(&press2);
@@ -2345,15 +2327,13 @@ TEST_F(GestureRecognizerTest, GestureEventOutsideRootWindowTap) {
gfx::Rect(-100, -100, 2000, 2000), root_window()));
gfx::Point pos1(-10, -10);
- ui::TouchEvent press1(
- ui::ET_TOUCH_PRESSED, pos1, tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, pos1, tes.Now(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&press1);
gfx::Point pos2(1000, 1000);
- ui::TouchEvent press2(
- ui::ET_TOUCH_PRESSED, pos2, tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, pos2, tes.Now(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
DispatchEventUsingWindowDispatcher(&press2);
// As these presses were outside the root window, they should be
@@ -2383,11 +2363,11 @@ TEST_F(GestureRecognizerTest, NoTapWithPreventDefaultedRelease) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release);
delegate->Reset();
@@ -2414,16 +2394,13 @@ TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(15, 25), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(20, 95), tes.LeapForward(200),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press);
DispatchEventUsingWindowDispatcher(&move);
DispatchEventUsingWindowDispatcher(&release);
@@ -2452,22 +2429,22 @@ TEST_F(GestureRecognizerTest, PinchScrollWithPreventDefaultedRelease) {
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(15, 25), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(20, 95), tes.LeapForward(200),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(15, 25), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(55, 25), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(145, 85), tes.LeapForward(1000),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
ui::TouchEvent release2(
ui::ET_TOUCH_RELEASED, gfx::Point(145, 85), tes.LeapForward(14),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
// Do a pinch.
DispatchEventUsingWindowDispatcher(&press);
@@ -2570,12 +2547,12 @@ TEST_F(GestureRecognizerTest, CaptureDoesNotCancelFinishedTouches) {
TimedEvents tes;
// Generate two touch-press events on the window.
- std::unique_ptr<ui::TouchEvent> touch0(new ui::TouchEvent(
- ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0)));
- std::unique_ptr<ui::TouchEvent> touch1(new ui::TouchEvent(
- ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1)));
+ std::unique_ptr<ui::TouchEvent> touch0(
+ new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), tes.Now(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0)));
+ std::unique_ptr<ui::TouchEvent> touch1(
+ new ui::TouchEvent(ui::ET_TOUCH_PRESSED, gfx::Point(30, 30), tes.Now(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1)));
generator.Dispatch(touch0.get());
generator.Dispatch(touch1.get());
RunAllPendingInMessageLoop();
@@ -2588,10 +2565,10 @@ TEST_F(GestureRecognizerTest, CaptureDoesNotCancelFinishedTouches) {
// cover both cases.
touch0 = std::make_unique<ui::TouchEvent>(
ui::ET_TOUCH_RELEASED, gfx::Point(20, 20), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
touch1 = std::make_unique<ui::TouchEvent>(
ui::ET_TOUCH_CANCELLED, gfx::Point(30, 30), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
generator.Dispatch(touch0.get());
generator.Dispatch(touch1.get());
RunAllPendingInMessageLoop();
@@ -2619,9 +2596,8 @@ TEST_F(GestureRecognizerTest, PressDoesNotCrash) {
std::unique_ptr<aura::Window> window(CreateTestWindowWithDelegate(
delegate.get(), -1234, gfx::Rect(10, 10, 300, 300), root_window()));
- ui::TouchEvent press(
- ui::ET_TOUCH_PRESSED, gfx::Point(45, 45), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 7));
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(45, 45), tes.Now(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 7));
SetTouchRadius(&press, 40, 0);
DispatchEventUsingWindowDispatcher(&press);
EXPECT_TRUE(delegate->tap_down());
@@ -2629,9 +2605,8 @@ TEST_F(GestureRecognizerTest, PressDoesNotCrash) {
delegate->bounding_box().ToString());
delegate->Reset();
- ui::TouchEvent press2(
- ui::ET_TOUCH_PRESSED, gfx::Point(55, 45), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 7));
+ ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(55, 45), tes.Now(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 7));
DispatchEventUsingWindowDispatcher(&press2);
EXPECT_FALSE(delegate->begin());
@@ -2655,7 +2630,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTap) {
delegate->Reset();
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_2_EVENTS(
delegate->events(), ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_TAP_DOWN);
@@ -2663,7 +2638,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTap) {
delegate->Reset();
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
EXPECT_2_EVENTS(
delegate->events(), ui::ET_GESTURE_TAP_CANCEL, ui::ET_GESTURE_BEGIN);
@@ -2673,11 +2648,11 @@ TEST_F(GestureRecognizerTest, TwoFingerTap) {
delegate->Reset();
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(102, 202), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move1);
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(131, 202), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_0_EVENTS(delegate->events());
@@ -2686,7 +2661,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTap) {
delegate->Reset();
ui::TouchEvent release1(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&release1);
EXPECT_2_EVENTS(
@@ -2698,7 +2673,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTap) {
delegate->Reset();
ui::TouchEvent release2(
ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&release2);
EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_END);
@@ -2719,20 +2694,20 @@ TEST_F(GestureRecognizerTest, TwoFingerTapExpired) {
delegate->Reset();
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press1);
delegate->Reset();
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
// Send release event after sufficient delay so that two finger time expires.
delegate->Reset();
ui::TouchEvent release1(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(1000),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&release1);
EXPECT_FALSE(delegate->two_finger_tap());
@@ -2743,7 +2718,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTapExpired) {
delegate->Reset();
ui::TouchEvent release2(
ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&release2);
EXPECT_FALSE(delegate->two_finger_tap());
@@ -2767,15 +2742,13 @@ TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) {
delegate->Reset();
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press1);
delegate->Reset();
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
tes.SendScrollEvent(event_sink(), 230, 330, kTouchId1, delegate.get());
@@ -2787,8 +2760,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_FALSE(delegate->two_finger_tap());
@@ -2804,15 +2776,13 @@ TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) {
delegate->Reset();
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press1);
delegate->Reset();
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
tes.SendScrollEvent(event_sink(), 301, 230, kTouchId2, delegate.get());
@@ -2824,8 +2794,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTapChangesToPinch) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_FALSE(delegate->two_finger_tap());
@@ -2849,14 +2818,14 @@ TEST_F(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) {
delegate->Reset();
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press1);
tes.SendScrollEvent(event_sink(), 130, 230, kTouchId1, delegate.get());
delegate->Reset();
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
EXPECT_FALSE(delegate->pinch_begin());
@@ -2866,7 +2835,7 @@ TEST_F(GestureRecognizerTest, NoTwoFingerTapWhenFirstFingerHasScrolled) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_FALSE(delegate->two_finger_tap());
@@ -2953,22 +2922,19 @@ TEST_F(GestureRecognizerTest, TwoFingerTapCancelled) {
delegate->Reset();
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press1);
delegate->Reset();
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
delegate->Reset();
ui::TouchEvent cancel(
ui::ET_TOUCH_CANCELLED, gfx::Point(130, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&cancel);
EXPECT_FALSE(delegate->two_finger_tap());
@@ -2977,8 +2943,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTapCancelled) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_FALSE(delegate->two_finger_tap());
@@ -2993,22 +2958,19 @@ TEST_F(GestureRecognizerTest, TwoFingerTapCancelled) {
delegate->Reset();
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press1);
delegate->Reset();
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
delegate->Reset();
ui::TouchEvent cancel(
ui::ET_TOUCH_CANCELLED, gfx::Point(130, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&cancel);
EXPECT_FALSE(delegate->two_finger_tap());
@@ -3017,8 +2979,7 @@ TEST_F(GestureRecognizerTest, TwoFingerTapCancelled) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_FALSE(delegate->two_finger_tap());
@@ -3040,7 +3001,7 @@ TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) {
delegate->Reset();
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -3054,7 +3015,7 @@ TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) {
delegate->Reset();
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(430, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down()); // no touch down for second tap.
@@ -3069,7 +3030,7 @@ TEST_F(GestureRecognizerTest, VeryWideTwoFingerTouchDownShouldBeAPinch) {
delegate->Reset();
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(530, 301), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -3097,11 +3058,11 @@ TEST_F(GestureRecognizerTest, FlushAllOnHide) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press1);
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(20, 20), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
window->Hide();
EXPECT_EQ(
@@ -3127,7 +3088,7 @@ TEST_F(GestureRecognizerTest, LongPressTimerStopsOnPreventDefaultedTouchMoves) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
// Scroll around, to cancel the long press
tes.SendScrollEvent(event_sink(), 130, 230, kTouchId, delegate.get());
@@ -3182,7 +3143,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -3210,7 +3171,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMoveConsumed) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(130, 230), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -3241,7 +3202,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) {
delegate->Reset();
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press1);
tes.SendScrollEvent(event_sink(), 131, 231, kTouchId1, delegate.get());
@@ -3253,7 +3214,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) {
// Second finger touches down and moves.
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(130, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
tes.SendScrollEvent(event_sink(), 161, 231, kTouchId2, delegate.get());
EXPECT_0_EVENTS(delegate->events());
@@ -3278,10 +3239,10 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTwoFingerTouchMoveConsumed) {
delegate->Reset();
ui::TouchEvent release1(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
ui::TouchEvent release2(
ui::ET_TOUCH_RELEASED, gfx::Point(130, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&release1);
DispatchEventUsingWindowDispatcher(&release2);
@@ -3308,7 +3269,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_FALSE(delegate->tap());
EXPECT_TRUE(delegate->tap_down());
@@ -3379,7 +3340,7 @@ TEST_F(GestureRecognizerTest, GestureEventScrollTouchMovePartialConsumed) {
delegate->Reset();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_FALSE(delegate->tap());
EXPECT_FALSE(delegate->tap_down());
@@ -3408,22 +3369,22 @@ TEST_F(GestureRecognizerTest, GestureEventDoubleTap) {
// First tap (tested in GestureEventTap)
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(104, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
ui::TouchEvent release1(
ui::ET_TOUCH_RELEASED, gfx::Point(104, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release1);
delegate->Reset();
// Second tap
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 203), tes.LeapForward(200),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press2);
ui::TouchEvent release2(
ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release2);
EXPECT_TRUE(delegate->tap());
@@ -3453,11 +3414,11 @@ TEST_F(GestureRecognizerTest, GestureEventTripleTap) {
// First tap (tested in GestureEventTap)
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(104, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
ui::TouchEvent release1(
ui::ET_TOUCH_RELEASED, gfx::Point(104, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release1);
EXPECT_EQ(1, delegate->tap_count());
@@ -3466,11 +3427,11 @@ TEST_F(GestureRecognizerTest, GestureEventTripleTap) {
// Second tap (tested in GestureEventDoubleTap)
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 203), tes.LeapForward(200),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press2);
ui::TouchEvent release2(
ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release2);
EXPECT_EQ(2, delegate->tap_count());
@@ -3479,11 +3440,11 @@ TEST_F(GestureRecognizerTest, GestureEventTripleTap) {
// Third tap
ui::TouchEvent press3(
ui::ET_TOUCH_PRESSED, gfx::Point(102, 206), tes.LeapForward(200),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press3);
ui::TouchEvent release3(
ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release3);
// Third, Fourth and Fifth Taps. Taps after the third should have their
@@ -3491,11 +3452,11 @@ TEST_F(GestureRecognizerTest, GestureEventTripleTap) {
for (int i = 3; i < 5; ++i) {
ui::TouchEvent press3(
ui::ET_TOUCH_PRESSED, gfx::Point(102, 206), tes.LeapForward(200),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press3);
ui::TouchEvent release3(
ui::ET_TOUCH_RELEASED, gfx::Point(102, 206), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release3);
EXPECT_TRUE(delegate->tap());
@@ -3525,22 +3486,22 @@ TEST_F(GestureRecognizerTest, TwoTapsFarApart) {
// First tap (tested in GestureEventTap)
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
ui::TouchEvent release1(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release1);
delegate->Reset();
// Second tap, close in time but far in distance
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(201, 201), tes.LeapForward(200),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press2);
ui::TouchEvent release2(
ui::ET_TOUCH_RELEASED, gfx::Point(201, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release2);
EXPECT_TRUE(delegate->tap());
@@ -3571,22 +3532,22 @@ TEST_F(GestureRecognizerTest, TwoTapsWithDelayBetween) {
// First tap (tested in GestureEventTap)
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
ui::TouchEvent release1(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release1);
delegate->Reset();
// Second tap, close in distance but after some delay
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.LeapForward(2000),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press2);
ui::TouchEvent release2(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release2);
EXPECT_TRUE(delegate->tap());
@@ -3617,7 +3578,7 @@ TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_TRUE(delegate->bounding_box().IsEmpty());
@@ -3625,7 +3586,7 @@ TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) {
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(201, 201), tes.LeapForward(400),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
SetTouchRadius(&press2, 5, 0);
DispatchEventUsingWindowDispatcher(&press2);
EXPECT_FALSE(delegate->pinch_begin());
@@ -3636,7 +3597,7 @@ TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) {
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(50, 50), tes.LeapForward(40),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move1);
EXPECT_TRUE(delegate->pinch_begin());
EXPECT_EQ(gfx::Rect(50, 50, 156, 156).ToString(),
@@ -3647,7 +3608,7 @@ TEST_F(GestureRecognizerTest, BoundingBoxRadiusChange) {
// The position doesn't move, but the radius changes.
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(50, 50), tes.LeapForward(40),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
SetTouchRadius(&move2, 50, 60);
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_FALSE(delegate->tap());
@@ -3675,7 +3636,7 @@ TEST_F(GestureRecognizerTest, NoDriftInScroll) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 208), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_TRUE(delegate->begin());
@@ -3683,7 +3644,7 @@ TEST_F(GestureRecognizerTest, NoDriftInScroll) {
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(101, 206), tes.LeapForward(40),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move1);
EXPECT_FALSE(delegate->scroll_begin());
@@ -3691,7 +3652,7 @@ TEST_F(GestureRecognizerTest, NoDriftInScroll) {
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(101, 204), tes.LeapForward(40),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_TRUE(delegate->tap_cancel());
EXPECT_TRUE(delegate->scroll_begin());
@@ -3704,7 +3665,7 @@ TEST_F(GestureRecognizerTest, NoDriftInScroll) {
ui::TouchEvent move3(
ui::ET_TOUCH_MOVED, gfx::Point(101, 204), tes.LeapForward(40),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move3);
EXPECT_FALSE(delegate->scroll_update());
@@ -3712,7 +3673,7 @@ TEST_F(GestureRecognizerTest, NoDriftInScroll) {
ui::TouchEvent move4(
ui::ET_TOUCH_MOVED, gfx::Point(101, 203), tes.LeapForward(40),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move4);
EXPECT_TRUE(delegate->scroll_update());
EXPECT_EQ(-1, delegate->scroll_y());
@@ -3735,7 +3696,7 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveCanFireTapCancel) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
delegate->set_consume_touch_move(false);
DispatchEventUsingWindowDispatcher(&press);
@@ -3774,21 +3735,21 @@ TEST_F(GestureRecognizerTest, CancelAllActiveTouches) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_2_EVENTS(
delegate->events(), ui::ET_GESTURE_BEGIN, ui::ET_GESTURE_TAP_DOWN);
delegate->Reset();
ui::TouchEvent p2(
ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&p2);
EXPECT_2_EVENTS(
delegate->events(), ui::ET_GESTURE_TAP_CANCEL, ui::ET_GESTURE_BEGIN);
delegate->Reset();
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(350, 300), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&move);
EXPECT_4_EVENTS(delegate->events(), ui::ET_GESTURE_SCROLL_BEGIN,
ui::ET_GESTURE_SCROLL_UPDATE, ui::ET_GESTURE_PINCH_BEGIN,
@@ -3834,7 +3795,7 @@ TEST_F(GestureRecognizerTest, GestureEventShowPress) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_TRUE(delegate->tap_down());
EXPECT_TRUE(delegate->begin());
@@ -3851,7 +3812,7 @@ TEST_F(GestureRecognizerTest, GestureEventShowPress) {
delegate->Reset();
ui::TouchEvent release1(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release1);
EXPECT_FALSE(delegate->long_press());
@@ -3876,7 +3837,7 @@ TEST_F(GestureRecognizerTest, GestureEventShowPressCancelledByScroll) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_TRUE(delegate->tap_down());
@@ -3894,7 +3855,7 @@ TEST_F(GestureRecognizerTest, GestureEventShowPressCancelledByScroll) {
delegate->Reset();
ui::TouchEvent release1(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(10),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release1);
EXPECT_FALSE(delegate->show_press());
EXPECT_FALSE(delegate->tap_cancel());
@@ -3916,7 +3877,7 @@ TEST_F(GestureRecognizerTest, GestureEventShowPressSentOnTap) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_TRUE(delegate->tap_down());
@@ -3927,7 +3888,7 @@ TEST_F(GestureRecognizerTest, GestureEventShowPressSentOnTap) {
delegate->Reset();
ui::TouchEvent release1(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release1);
EXPECT_TRUE(delegate->show_press());
EXPECT_FALSE(delegate->tap_cancel());
@@ -3947,7 +3908,7 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) {
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
delegate->ReceivedAck();
@@ -3956,13 +3917,13 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveScrollTest) {
// consumed, so make sure this touch move exceeds the slop region.
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(10, 10), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move1);
delegate->ReceivedAckPreventDefaulted();
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(20, 20), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move2);
delegate->ReceivedAck();
@@ -3985,19 +3946,19 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveTapTest) {
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
delegate->ReceivedAck();
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(2, 2), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move);
delegate->ReceivedAckPreventDefaulted();
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(2, 2), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release);
delegate->ReceivedAck();
@@ -4021,13 +3982,13 @@ TEST_F(GestureRecognizerTest, GestureEventConsumedTouchMoveLongPressTest) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
delegate->ReceivedAck();
ui::TouchEvent move(
ui::ET_TOUCH_MOVED, gfx::Point(103, 203), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move);
delegate->ReceivedAckPreventDefaulted();
@@ -4052,7 +4013,7 @@ TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) {
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_FALSE(delegate->scroll_begin());
EXPECT_FALSE(delegate->scroll_update());
@@ -4060,7 +4021,7 @@ TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) {
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(11, 10), tes.LeapForward(40),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move1);
EXPECT_FALSE(delegate->scroll_begin());
EXPECT_FALSE(delegate->scroll_update());
@@ -4070,7 +4031,7 @@ TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) {
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(12, 10), tes.LeapForward(40),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_FALSE(delegate->scroll_begin());
EXPECT_FALSE(delegate->scroll_update());
@@ -4080,7 +4041,7 @@ TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) {
ui::TouchEvent move3(
ui::ET_TOUCH_MOVED, gfx::Point(), tes.LeapForward(40),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
move3.set_location_f(gfx::PointF(13.1f, 10.f));
move3.set_root_location_f(gfx::PointF(13.1f, 10.f));
DispatchEventUsingWindowDispatcher(&move3);
@@ -4092,7 +4053,7 @@ TEST_F(GestureRecognizerTest, TestExceedingSlopSlowly) {
ui::TouchEvent move4(
ui::ET_TOUCH_MOVED, gfx::Point(14, 10), tes.LeapForward(40),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move4);
EXPECT_FALSE(delegate->scroll_begin());
EXPECT_TRUE(delegate->scroll_update());
@@ -4120,7 +4081,7 @@ TEST_F(GestureRecognizerTest, ScrollAlternatelyConsumedTest) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(x, y), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
delegate->ReceivedAck();
EXPECT_FALSE(delegate->scroll_begin());
@@ -4131,7 +4092,7 @@ TEST_F(GestureRecognizerTest, ScrollAlternatelyConsumedTest) {
y += 100;
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(x, y), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move1);
delegate->ReceivedAck();
EXPECT_TRUE(delegate->scroll_begin());
@@ -4143,7 +4104,7 @@ TEST_F(GestureRecognizerTest, ScrollAlternatelyConsumedTest) {
y += 10;
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(x, y), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move2);
delegate->ReceivedAck();
EXPECT_FALSE(delegate->scroll_begin());
@@ -4156,7 +4117,7 @@ TEST_F(GestureRecognizerTest, ScrollAlternatelyConsumedTest) {
y += 20;
ui::TouchEvent move3(
ui::ET_TOUCH_MOVED, gfx::Point(x, y), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&move3);
delegate->ReceivedAckPreventDefaulted();
EXPECT_FALSE(delegate->scroll_begin());
@@ -4181,7 +4142,7 @@ TEST_F(GestureRecognizerTest, PinchAlternatelyConsumedTest) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press1);
delegate->ReceivedAck();
EXPECT_FALSE(delegate->scroll_begin());
@@ -4193,7 +4154,7 @@ TEST_F(GestureRecognizerTest, PinchAlternatelyConsumedTest) {
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(x, y), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
delegate->ReceivedAck();
EXPECT_FALSE(delegate->scroll_begin());
@@ -4207,7 +4168,7 @@ TEST_F(GestureRecognizerTest, PinchAlternatelyConsumedTest) {
y += 100;
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(x, y), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&move1);
delegate->ReceivedAck();
EXPECT_TRUE(delegate->scroll_begin());
@@ -4223,8 +4184,7 @@ TEST_F(GestureRecognizerTest, PinchAlternatelyConsumedTest) {
y += 50;
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(x, y), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&move2);
delegate->ReceivedAck();
EXPECT_FALSE(delegate->scroll_begin());
@@ -4242,8 +4202,7 @@ TEST_F(GestureRecognizerTest, PinchAlternatelyConsumedTest) {
y += 100;
ui::TouchEvent move3(
ui::ET_TOUCH_MOVED, gfx::Point(x, y), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&move3);
delegate->ReceivedAckPreventDefaulted();
EXPECT_FALSE(delegate->scroll_begin());
@@ -4272,7 +4231,7 @@ TEST_F(GestureRecognizerTest, GestureEventFlagsPassedFromTouchEvent) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_TRUE(delegate->tap_down());
@@ -4280,7 +4239,7 @@ TEST_F(GestureRecognizerTest, GestureEventFlagsPassedFromTouchEvent) {
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(397, 149), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
move1.set_flags(992);
DispatchEventUsingWindowDispatcher(&move1);
@@ -4322,7 +4281,7 @@ TEST_F(GestureRecognizerTest, GestureEventLongPressDeletingWindow) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_TRUE(window != NULL);
@@ -4345,18 +4304,18 @@ TEST_F(GestureRecognizerWithSwitchTest, GestureEventSmallPinchDisabled) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press1);
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
// Move the first finger.
delegate->Reset();
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(65, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move1);
EXPECT_4_EVENTS(delegate->events(), ui::ET_GESTURE_SCROLL_BEGIN,
@@ -4368,7 +4327,7 @@ TEST_F(GestureRecognizerWithSwitchTest, GestureEventSmallPinchDisabled) {
delegate->Reset();
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(65, 202), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_1_EVENT(delegate->events(), ui::ET_GESTURE_SCROLL_UPDATE);
}
@@ -4387,18 +4346,18 @@ TEST_F(GestureRecognizerTest, GestureEventSmallPinchEnabled) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press1);
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
// Move the first finger.
delegate->Reset();
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(65, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move1);
EXPECT_4_EVENTS(delegate->events(), ui::ET_GESTURE_SCROLL_BEGIN,
@@ -4408,7 +4367,7 @@ TEST_F(GestureRecognizerTest, GestureEventSmallPinchEnabled) {
delegate->Reset();
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(65, 202), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_2_EVENTS(delegate->events(),
ui::ET_GESTURE_SCROLL_UPDATE,
@@ -4430,11 +4389,11 @@ TEST_F(GestureRecognizerTest, EagerGestureDetection) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(101, 201), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release);
delegate->Reset();
@@ -4468,7 +4427,7 @@ TEST_F(GestureRecognizerTest, IgnoredEventsDontBreakGestureRecognition) {
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(101, 301), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press1);
delegate->ReceivedAck();
@@ -4479,7 +4438,7 @@ TEST_F(GestureRecognizerTest, IgnoredEventsDontBreakGestureRecognition) {
delegate->Reset();
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(65, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move1);
delegate->ReceivedAck();
@@ -4493,7 +4452,7 @@ TEST_F(GestureRecognizerTest, IgnoredEventsDontBreakGestureRecognition) {
// Send a valid event, but don't ack it.
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(65, 202), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_0_EVENTS(delegate->events());
@@ -4501,7 +4460,7 @@ TEST_F(GestureRecognizerTest, IgnoredEventsDontBreakGestureRecognition) {
// event. This shouldn't do anything.
ui::TouchEvent move3(
ui::ET_TOUCH_MOVED, gfx::Point(65, 202), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move3);
// Ack the previous valid event. The intermediary invalid event shouldn't
@@ -4527,13 +4486,13 @@ TEST_F(GestureRecognizerTest,
// Start a scroll gesture.
ui::TouchEvent press1(
ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press1);
delegate->ReceivedAck();
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, gfx::Point(100, 100), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move1);
delegate->ReceivedAck();
@@ -4542,27 +4501,27 @@ TEST_F(GestureRecognizerTest,
delegate->set_synchronous_ack_for_next_event(true);
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, gfx::Point(200, 200), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_0_EVENTS(delegate->events());
// Dispatch a touch move, but don't ack it.
ui::TouchEvent move3(
ui::ET_TOUCH_MOVED, gfx::Point(300, 300), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move3);
// Dispatch two synchronously consumed touch moves, which should be ignored.
delegate->set_synchronous_ack_for_next_event(true);
ui::TouchEvent move4(
ui::ET_TOUCH_MOVED, gfx::Point(400, 400), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move4);
delegate->set_synchronous_ack_for_next_event(true);
ui::TouchEvent move5(
ui::ET_TOUCH_MOVED, gfx::Point(500, 500), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move5);
EXPECT_0_EVENTS(delegate->events());
@@ -4577,14 +4536,14 @@ TEST_F(GestureRecognizerTest,
delegate->Reset();
ui::TouchEvent move6(
ui::ET_TOUCH_MOVED, gfx::Point(600, 600), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move6);
// Dispatch a synchronously unconsumed touch move.
delegate->set_synchronous_ack_for_next_event(false);
ui::TouchEvent move7(
ui::ET_TOUCH_MOVED, gfx::Point(700, 700), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&move7);
// The synchronous ack is stuck behind the pending touch move.
@@ -4612,7 +4571,7 @@ TEST_F(GestureRecognizerTest, GestureEventTwoWindowsActive) {
queued_delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(151, 201), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId1));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_FALSE(queued_delegate->tap());
EXPECT_FALSE(queued_delegate->tap_down());
@@ -4634,7 +4593,7 @@ TEST_F(GestureRecognizerTest, GestureEventTwoWindowsActive) {
queued_delegate2->Reset();
ui::TouchEvent press2(
ui::ET_TOUCH_PRESSED, gfx::Point(1, 1), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId2));
DispatchEventUsingWindowDispatcher(&press2);
EXPECT_FALSE(queued_delegate2->tap());
EXPECT_FALSE(queued_delegate2->tap_down());
@@ -4695,7 +4654,7 @@ TEST_F(GestureRecognizerTest, TransferEventsToRoutesAckCorrectly) {
delegate_1->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(512, 512), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
// Create a new consumer and Touch event delegate.
@@ -4721,7 +4680,7 @@ TEST_F(GestureRecognizerTest, TransferEventsToRoutesAckCorrectly) {
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, gfx::Point(550, 512), tes.LeapForward(50),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&release);
// Events dispatched after the transfer should go to the new window.
@@ -4752,7 +4711,7 @@ TEST_F(GestureRecognizerTest, GestureConsumerCleanupBeforeTouchAck) {
delegate->Reset();
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, gfx::Point(512, 512), tes.Now(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
+ ui::PointerDetails(ui::EventPointerType::kTouch, kTouchId));
DispatchEventUsingWindowDispatcher(&press);
window->Hide();
diff --git a/chromium/ui/aura/null_window_targeter.cc b/chromium/ui/aura/null_window_targeter.cc
index eaf41c696c2..50f0c33085e 100644
--- a/chromium/ui/aura/null_window_targeter.cc
+++ b/chromium/ui/aura/null_window_targeter.cc
@@ -4,7 +4,7 @@
#include "ui/aura/null_window_targeter.h"
-#include "base/logging.h"
+#include "base/notreached.h"
namespace aura {
diff --git a/chromium/ui/aura/screen_ozone.cc b/chromium/ui/aura/screen_ozone.cc
index 6299b6221d6..c811c1c4898 100644
--- a/chromium/ui/aura/screen_ozone.cc
+++ b/chromium/ui/aura/screen_ozone.cc
@@ -33,24 +33,19 @@ bool ScreenOzone::IsWindowUnderCursor(gfx::NativeWindow window) {
}
gfx::NativeWindow ScreenOzone::GetWindowAtScreenPoint(const gfx::Point& point) {
- auto widget = platform_screen_->GetAcceleratedWidgetAtScreenPoint(point);
- if (!widget)
- return nullptr;
-
- aura::WindowTreeHost* host =
- aura::WindowTreeHost::GetForAcceleratedWidget(widget);
- if (!host)
- return nullptr;
-
- gfx::NativeWindow window = host->window();
- gfx::Point local_point = point;
+ return GetNativeWindowFromAcceleratedWidget(
+ platform_screen_->GetAcceleratedWidgetAtScreenPoint(point));
+}
- aura::client::ScreenPositionClient* position_client =
- aura::client::GetScreenPositionClient(window);
- if (position_client)
- position_client->ConvertPointFromScreen(window, &local_point);
+gfx::NativeWindow ScreenOzone::GetLocalProcessWindowAtPoint(
+ const gfx::Point& point,
+ const std::set<gfx::NativeWindow>& ignore) {
+ std::set<gfx::AcceleratedWidget> ignore_top_level;
+ for (auto* const window : ignore)
+ ignore_top_level.emplace(window->GetHost()->GetAcceleratedWidget());
- return window->GetEventHandlerForPoint(local_point);
+ return GetNativeWindowFromAcceleratedWidget(
+ platform_screen_->GetLocalProcessWidgetAtPoint(point, ignore_top_level));
}
int ScreenOzone::GetNumDisplays() const {
@@ -101,6 +96,11 @@ std::string ScreenOzone::GetCurrentWorkspace() {
return platform_screen_->GetCurrentWorkspace();
}
+gfx::NativeWindow ScreenOzone::GetNativeWindowFromAcceleratedWidget(
+ gfx::AcceleratedWidget widget) const {
+ return nullptr;
+}
+
gfx::AcceleratedWidget ScreenOzone::GetAcceleratedWidgetForWindow(
aura::Window* window) const {
if (!window)
diff --git a/chromium/ui/aura/screen_ozone.h b/chromium/ui/aura/screen_ozone.h
index 0f8f18c2319..864c6e38681 100644
--- a/chromium/ui/aura/screen_ozone.h
+++ b/chromium/ui/aura/screen_ozone.h
@@ -28,6 +28,9 @@ class AURA_EXPORT ScreenOzone : public display::Screen {
gfx::Point GetCursorScreenPoint() override;
bool IsWindowUnderCursor(gfx::NativeWindow window) override;
gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override;
+ gfx::NativeWindow GetLocalProcessWindowAtPoint(
+ const gfx::Point& point,
+ const std::set<gfx::NativeWindow>& ignore) override;
int GetNumDisplays() const override;
const std::vector<display::Display>& GetAllDisplays() const override;
display::Display GetDisplayNearestWindow(
@@ -42,6 +45,10 @@ class AURA_EXPORT ScreenOzone : public display::Screen {
void RemoveObserver(display::DisplayObserver* observer) override;
std::string GetCurrentWorkspace() override;
+ // Returns the NativeWindow associated with the AcceleratedWidget.
+ virtual gfx::NativeWindow GetNativeWindowFromAcceleratedWidget(
+ gfx::AcceleratedWidget widget) const;
+
private:
gfx::AcceleratedWidget GetAcceleratedWidgetForWindow(
aura::Window* window) const;
diff --git a/chromium/ui/aura/test/ui_controls_factory_ozone.cc b/chromium/ui/aura/test/ui_controls_factory_ozone.cc
index 1886334eb2c..23e318e82c9 100644
--- a/chromium/ui/aura/test/ui_controls_factory_ozone.cc
+++ b/chromium/ui/aura/test/ui_controls_factory_ozone.cc
@@ -313,8 +313,8 @@ class UIControlsOzone : public ui_controls::UIControlsAura {
int id,
int64_t display_id,
base::OnceClosure closure) {
- ui::PointerDetails details(ui::EventPointerType::POINTER_TYPE_TOUCH, id,
- 1.0f, 1.0f, 0.0f);
+ ui::PointerDetails details(ui::EventPointerType::kTouch, id, 1.0f, 1.0f,
+ 0.0f);
ui::TouchEvent touch_event(type, host_location, host_location,
ui::EventTimeForNow(), details);
SendEventToSink(&touch_event, display_id, std::move(closure));
diff --git a/chromium/ui/aura/window_event_dispatcher.cc b/chromium/ui/aura/window_event_dispatcher.cc
index 5949a5613fb..47ed7c1f1a3 100644
--- a/chromium/ui/aura/window_event_dispatcher.cc
+++ b/chromium/ui/aura/window_event_dispatcher.cc
@@ -9,7 +9,8 @@
#include <utility>
#include "base/bind.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
@@ -194,8 +195,11 @@ void WindowEventDispatcher::ProcessedTouchEvent(
}
void WindowEventDispatcher::HoldPointerMoves() {
- if (!move_hold_count_)
+ if (!move_hold_count_) {
+ // |synthesize_mouse_events_| is explicitly not changed. It is handled and
+ // reset in ReleasePointerMoves.
held_event_factory_.InvalidateWeakPtrs();
+ }
++move_hold_count_;
TRACE_EVENT_ASYNC_BEGIN0("ui", "WindowEventDispatcher::HoldPointerMoves",
this);
@@ -205,6 +209,11 @@ void WindowEventDispatcher::ReleasePointerMoves() {
--move_hold_count_;
DCHECK_GE(move_hold_count_, 0);
if (!move_hold_count_) {
+ // HoldPointerMoves cancels the pending synthesized mouse move if any.
+ // So ReleasePointerMoves should ensure that |synthesize_mouse_move_|
+ // resets. Otherwise, PostSynthesizeMouseMove is blocked indefintely.
+ const bool pending_synthesize_mouse_move = synthesize_mouse_move_;
+ synthesize_mouse_move_ = false;
if (held_move_event_) {
// We don't want to call DispatchHeldEvents directly, because this might
// be called from a deep stack while another event, in which case
@@ -219,6 +228,11 @@ void WindowEventDispatcher::ReleasePointerMoves() {
} else {
if (did_dispatch_held_move_event_callback_)
std::move(did_dispatch_held_move_event_callback_).Run();
+ if (pending_synthesize_mouse_move) {
+ // Schedule a synthesized mouse move event when there is no held mouse
+ // move and we should generate one.
+ PostSynthesizeMouseMove();
+ }
}
}
TRACE_EVENT_ASYNC_END0("ui", "WindowEventDispatcher::HoldPointerMoves", this);
@@ -312,10 +326,7 @@ ui::EventDispatchDetails WindowEventDispatcher::DispatchMouseEnterOrExit(
// coordinate system.
if (!target)
target = window();
- ui::MouseEvent translated_event(event,
- target,
- mouse_moved_handler_,
- type,
+ ui::MouseEvent translated_event(event, target, mouse_moved_handler_, type,
event.flags() | ui::EF_IS_SYNTHESIZED);
return DispatchEvent(mouse_moved_handler_, &translated_event);
}
@@ -693,8 +704,10 @@ void WindowEventDispatcher::OnWindowBoundsChanged(
Window::ConvertRectToTarget(window->parent(), host_->window(),
&new_bounds_in_root);
gfx::Point last_mouse_location = GetLastMouseLocationInRoot();
- if (old_bounds_in_root.Contains(last_mouse_location) !=
- new_bounds_in_root.Contains(last_mouse_location)) {
+ if ((old_bounds_in_root.Contains(last_mouse_location) !=
+ new_bounds_in_root.Contains(last_mouse_location)) ||
+ (new_bounds_in_root.Contains(last_mouse_location) &&
+ new_bounds_in_root.origin() != old_bounds_in_root.origin())) {
PostSynthesizeMouseMove();
}
}
@@ -874,8 +887,7 @@ DispatchDetails WindowEventDispatcher::PreDispatchMouseEvent(
// We allow synthesized mouse exit events through even if mouse events are
// disabled. This ensures that hover state, etc on controls like buttons is
// cleared.
- if (cursor_client &&
- !cursor_client->IsMouseEventsEnabled() &&
+ if (cursor_client && !cursor_client->IsMouseEventsEnabled() &&
(event->flags() & ui::EF_IS_SYNTHESIZED) &&
(event->type() != ui::ET_MOUSE_EXITED)) {
event->SetHandled();
diff --git a/chromium/ui/aura/window_event_dispatcher_unittest.cc b/chromium/ui/aura/window_event_dispatcher_unittest.cc
index 49bfbd9329c..ef8dcda8b67 100644
--- a/chromium/ui/aura/window_event_dispatcher_unittest.cc
+++ b/chromium/ui/aura/window_event_dispatcher_unittest.cc
@@ -56,11 +56,8 @@ namespace {
class NonClientDelegate : public test::TestWindowDelegate {
public:
NonClientDelegate()
- : non_client_count_(0),
- mouse_event_count_(0),
- mouse_event_flags_(0x0) {
- }
- ~NonClientDelegate() override {}
+ : non_client_count_(0), mouse_event_count_(0), mouse_event_flags_(0x0) {}
+ ~NonClientDelegate() override = default;
int non_client_count() const { return non_client_count_; }
const gfx::Point& non_client_location() const { return non_client_location_; }
@@ -166,7 +163,7 @@ TEST_F(WindowEventDispatcherTest, RepostEvent) {
ui::TouchEvent touch_pressed_event(
ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
host()->dispatcher()->RepostEvent(&touch_pressed_event);
RunAllPendingInMessageLoop();
EXPECT_TRUE(Env::GetInstance()->is_touch_down());
@@ -182,16 +179,16 @@ TEST_F(WindowEventDispatcherTest, TouchDownState) {
ui::TouchEvent touch_pressed_event1(
ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
ui::TouchEvent touch_pressed_event2(
ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 2));
ui::TouchEvent touch_released_event1(
ui::ET_TOUCH_RELEASED, gfx::Point(10, 10), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
ui::TouchEvent touch_released_event2(
ui::ET_TOUCH_RELEASED, gfx::Point(10, 10), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 2));
EXPECT_FALSE(Env::GetInstance()->is_touch_down());
host()->dispatcher()->OnEventFromSource(&touch_pressed_event1);
@@ -260,9 +257,8 @@ TEST_F(WindowEventDispatcherTest, TranslatedEvent) {
EXPECT_EQ("100,100", root.location().ToString());
EXPECT_EQ("100,100", root.root_location().ToString());
- ui::MouseEvent translated_event(
- root, static_cast<Window*>(root_window()), w1.get(),
- ui::ET_MOUSE_ENTERED, root.flags());
+ ui::MouseEvent translated_event(root, static_cast<Window*>(root_window()),
+ w1.get(), ui::ET_MOUSE_ENTERED, root.flags());
EXPECT_EQ("50,50", translated_event.location().ToString());
EXPECT_EQ("100,100", translated_event.root_location().ToString());
}
@@ -275,8 +271,7 @@ class TestEventClient : public client::EventClient {
static const int kLockWindowId = 200;
explicit TestEventClient(Window* root_window)
- : root_window_(root_window),
- lock_(false) {
+ : root_window_(root_window), lock_(false) {
client::SetEventClient(root_window_, this);
Window* lock_window =
test::CreateTestWindowWithBounds(root_window_->bounds(), root_window_);
@@ -289,12 +284,8 @@ class TestEventClient : public client::EventClient {
// Starts/stops locking. Locking prevents windows other than those inside
// the lock container from receiving events, getting focus etc.
- void Lock() {
- lock_ = true;
- }
- void Unlock() {
- lock_ = false;
- }
+ void Lock() { lock_ = true; }
+ void Unlock() { lock_ = false; }
Window* GetLockWindow() {
return const_cast<Window*>(
@@ -310,9 +301,9 @@ class TestEventClient : public client::EventClient {
private:
// Overridden from client::EventClient:
bool CanProcessEventsWithinSubtree(const Window* window) const override {
- return lock_ ?
- window->Contains(GetLockWindow()) || GetLockWindow()->Contains(window) :
- true;
+ return lock_ ? window->Contains(GetLockWindow()) ||
+ GetLockWindow()->Contains(window)
+ : true;
}
ui::EventTarget* GetToplevelEventTarget() override { return NULL; }
@@ -438,18 +429,16 @@ TEST_F(WindowEventDispatcherTest, TouchEventsOutsideBounds) {
gfx::Point position = root_window()->bounds().origin();
position.Offset(-10, -10);
- ui::TouchEvent press(
- ui::ET_TOUCH_PRESSED, position, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, position, ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_EQ(1, handler.num_touch_events());
position = root_window()->bounds().origin();
position.Offset(root_window()->bounds().width() + 10,
root_window()->bounds().height() + 10);
- ui::TouchEvent release(
- ui::ET_TOUCH_RELEASED, position, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent release(ui::ET_TOUCH_RELEASED, position, ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_EQ(2, handler.num_touch_events());
root_window()->RemovePreTargetHandler(&handler);
@@ -466,24 +455,14 @@ TEST_F(WindowEventDispatcherTest, ScrollEventDispatch) {
w1->SetBounds(gfx::Rect(20, 20, 40, 40));
// A scroll event on the root-window itself is dispatched.
- ui::ScrollEvent scroll1(ui::ET_SCROLL,
- gfx::Point(10, 10),
- now,
- 0,
- 0, -10,
- 0, -10,
- 2);
+ ui::ScrollEvent scroll1(ui::ET_SCROLL, gfx::Point(10, 10), now, 0, 0, -10, 0,
+ -10, 2);
DispatchEventUsingWindowDispatcher(&scroll1);
EXPECT_EQ(1, handler.num_scroll_events());
// Scroll event on a window should be dispatched properly.
- ui::ScrollEvent scroll2(ui::ET_SCROLL,
- gfx::Point(25, 30),
- now,
- 0,
- -10, 0,
- -10, 0,
- 2);
+ ui::ScrollEvent scroll2(ui::ET_SCROLL, gfx::Point(25, 30), now, 0, -10, 0,
+ -10, 0, 2);
DispatchEventUsingWindowDispatcher(&scroll2);
EXPECT_EQ(2, handler.num_scroll_events());
root_window()->RemovePreTargetHandler(&handler);
@@ -500,8 +479,7 @@ class EventFilterRecorder : public ui::EventHandler {
EventFilterRecorder()
: wait_until_event_(ui::ET_UNKNOWN),
- last_touch_may_cause_scrolling_(false) {
- }
+ last_touch_may_cause_scrolling_(false) {}
const Events& events() const { return events_; }
@@ -693,7 +671,8 @@ TEST_F(WindowEventDispatcherTest, MAYBE(RepostTargetsCaptureWindow)) {
RunAllPendingInMessageLoop(); // Necessitated by RepostEvent().
// Mouse moves/enters may be generated. We only care about a pressed.
EXPECT_TRUE(EventTypesToString(recorder.events()).find("MOUSE_PRESSED") !=
- std::string::npos) << EventTypesToString(recorder.events());
+ std::string::npos)
+ << EventTypesToString(recorder.events());
window->RemovePreTargetHandler(&recorder);
}
@@ -837,7 +816,7 @@ TEST_F(WindowEventDispatcherTest, TouchMovesHeld) {
// test.
ui::TouchEvent touch_pressed_event(
ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&touch_pressed_event);
recorder.WaitUntilReceivedEvent(ui::ET_GESTURE_SHOW_PRESS);
recorder.Reset();
@@ -847,13 +826,13 @@ TEST_F(WindowEventDispatcherTest, TouchMovesHeld) {
// Check that we don't immediately dispatch the TOUCH_MOVED event.
ui::TouchEvent touch_moved_event(
ui::ET_TOUCH_MOVED, gfx::Point(10, 10), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
ui::TouchEvent touch_moved_event2(
ui::ET_TOUCH_MOVED, gfx::Point(11, 10), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
ui::TouchEvent touch_moved_event3(
ui::ET_TOUCH_MOVED, gfx::Point(12, 10), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&touch_moved_event);
EXPECT_TRUE(recorder.events().empty());
@@ -872,7 +851,7 @@ TEST_F(WindowEventDispatcherTest, TouchMovesHeld) {
// immediately before it.
ui::TouchEvent touch_released_event(
ui::ET_TOUCH_RELEASED, gfx::Point(10, 10), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
recorder.Reset();
host()->dispatcher()->HoldPointerMoves();
DispatchEventUsingWindowDispatcher(&touch_moved_event3);
@@ -991,10 +970,8 @@ class HoldPointerOnScrollHandler : public ui::test::TestEventHandler {
public:
HoldPointerOnScrollHandler(WindowEventDispatcher* dispatcher,
EventFilterRecorder* filter)
- : dispatcher_(dispatcher),
- filter_(filter),
- holding_moves_(false) {}
- ~HoldPointerOnScrollHandler() override {}
+ : dispatcher_(dispatcher), filter_(filter), holding_moves_(false) {}
+ ~HoldPointerOnScrollHandler() override = default;
private:
// ui::test::TestEventHandler:
@@ -1028,9 +1005,8 @@ TEST_F(WindowEventDispatcherTest, TouchMovesHeldOnScroll) {
window->AddPreTargetHandler(&handler);
ui::test::EventGenerator generator(root_window());
- generator.GestureScrollSequence(
- gfx::Point(60, 60), gfx::Point(10, 60),
- base::TimeDelta::FromMilliseconds(100), 25);
+ generator.GestureScrollSequence(gfx::Point(60, 60), gfx::Point(10, 60),
+ base::TimeDelta::FromMilliseconds(100), 25);
// |handler| will have reset |filter| and started holding the touch-move
// events when scrolling started. At the end of the scroll (i.e. upon
@@ -1058,19 +1034,17 @@ TEST_F(WindowEventDispatcherTest, HeldTouchMoveContributesToGesture) {
root_window()->AddPreTargetHandler(&recorder);
const gfx::Point location(20, 20);
- ui::TouchEvent press(
- ui::ET_TOUCH_PRESSED, location, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, location, ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_PRESSED));
recorder.Reset();
host()->dispatcher()->HoldPointerMoves();
- ui::TouchEvent move(
- ui::ET_TOUCH_MOVED, location + gfx::Vector2d(100, 100),
- ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent move(ui::ET_TOUCH_MOVED, location + gfx::Vector2d(100, 100),
+ ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&move);
EXPECT_FALSE(recorder.HasReceivedEvent(ui::ET_TOUCH_MOVED));
EXPECT_FALSE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_BEGIN));
@@ -1216,12 +1190,36 @@ TEST_F(WindowEventDispatcherTest,
EXPECT_EQ(ui::EF_IS_SYNTHESIZED, recorder.mouse_event_flags().back());
recorder.Reset();
+ // Update the window bounds so that cursor is back inside the window.
+ // The origin of window bounds change so this should trigger a synthetic
+ // event.
+ gfx::Rect bounds2(5, 5, 100, 100);
+ window->SetBounds(bounds2);
+ RunAllPendingInMessageLoop();
+ ASSERT_FALSE(recorder.events().empty());
+ ASSERT_FALSE(recorder.mouse_event_flags().empty());
+ EXPECT_EQ(ui::ET_MOUSE_MOVED, recorder.events().back());
+ EXPECT_EQ(ui::EF_IS_SYNTHESIZED, recorder.mouse_event_flags().back());
+ recorder.Reset();
+
+ // Update the window bounds so that cursor is still inside the window.
+ // The origin of window bounds doesn't change so this should not trigger
+ // a synthetic event.
+ gfx::Rect bounds3(5, 5, 200, 200);
+ window->SetBounds(bounds3);
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(recorder.events().empty());
+ recorder.Reset();
+
// Set window to ignore events.
window->SetEventTargetingPolicy(EventTargetingPolicy::kNone);
- // Update the window bounds so that cursor is back inside the window.
- // This should not trigger a synthetic event.
- gfx::Rect bounds2(5, 5, 100, 100);
+ // Update the window bounds so that cursor is from outside to inside the
+ // window. This should not trigger a synthetic event.
+ window->SetBounds(bounds1);
+ RunAllPendingInMessageLoop();
+ EXPECT_TRUE(recorder.events().empty());
+ recorder.Reset();
window->SetBounds(bounds2);
RunAllPendingInMessageLoop();
EXPECT_TRUE(recorder.events().empty());
@@ -1352,9 +1350,8 @@ TEST_F(WindowEventDispatcherTest,
class DeletingEventFilter : public ui::EventHandler {
public:
- DeletingEventFilter()
- : delete_during_pre_handle_(false) {}
- ~DeletingEventFilter() override {}
+ DeletingEventFilter() : delete_during_pre_handle_(false) {}
+ ~DeletingEventFilter() override = default;
void Reset(bool delete_during_pre_handle) {
delete_during_pre_handle_ = delete_during_pre_handle;
@@ -1380,10 +1377,8 @@ class DeletingEventFilter : public ui::EventHandler {
class DeletingWindowDelegate : public test::TestWindowDelegate {
public:
DeletingWindowDelegate()
- : window_(NULL),
- delete_during_handle_(false),
- got_event_(false) {}
- ~DeletingWindowDelegate() override {}
+ : window_(nullptr), delete_during_handle_(false), got_event_(false) {}
+ ~DeletingWindowDelegate() override = default;
void Reset(Window* window, bool delete_during_handle) {
window_ = window;
@@ -1567,16 +1562,13 @@ TEST_F(WindowEventDispatcherTest, RepostTapdownGestureTest) {
ui::GestureEventDetails details(ui::ET_GESTURE_TAP_DOWN);
gfx::Point point(10, 10);
- ui::GestureEvent event(point.x(),
- point.y(),
- 0,
- ui::EventTimeForNow(),
+ ui::GestureEvent event(point.x(), point.y(), 0, ui::EventTimeForNow(),
details);
host()->dispatcher()->RepostEvent(&event);
RunAllPendingInMessageLoop();
// TODO(rbyers): Currently disabled - crbug.com/170987
EXPECT_FALSE(EventTypesToString(recorder.events()).find("GESTURE_TAP_DOWN") !=
- std::string::npos);
+ std::string::npos);
recorder.Reset();
root_window()->RemovePreTargetHandler(&recorder);
}
@@ -1640,12 +1632,13 @@ class RepostGestureEventRecorder : public EventFilterRecorder {
TEST_F(WindowEventDispatcherTest, GestureRepostEventOrder) {
// Expected events at the end for the repost_target window defined below.
const char kExpectedTargetEvents[] =
- // TODO)(rbyers): Gesture event reposting is disabled - crbug.com/279039.
- // "GESTURE_BEGIN GESTURE_TAP_DOWN "
- "TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_MOVED "
- "GESTURE_TAP_CANCEL GESTURE_SCROLL_BEGIN GESTURE_SCROLL_UPDATE TOUCH_MOVED "
- "GESTURE_SCROLL_UPDATE TOUCH_MOVED GESTURE_SCROLL_UPDATE TOUCH_RELEASED "
- "GESTURE_SCROLL_END GESTURE_END";
+ // TODO)(rbyers): Gesture event reposting is disabled - crbug.com/279039.
+ // "GESTURE_BEGIN GESTURE_TAP_DOWN "
+ "TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_MOVED "
+ "GESTURE_TAP_CANCEL GESTURE_SCROLL_BEGIN GESTURE_SCROLL_UPDATE "
+ "TOUCH_MOVED "
+ "GESTURE_SCROLL_UPDATE TOUCH_MOVED GESTURE_SCROLL_UPDATE TOUCH_RELEASED "
+ "GESTURE_SCROLL_END GESTURE_END";
// We create two windows.
// The first window (repost_source) is the one to which the initial tap
// gesture is sent. It reposts this event to the second window
@@ -1671,10 +1664,8 @@ TEST_F(WindowEventDispatcherTest, GestureRepostEventOrder) {
ui::test::EventGenerator scroll_generator(root_window(), repost_target.get());
scroll_generator.GestureScrollSequence(
- gfx::Point(80, 80),
- gfx::Point(100, 100),
- base::TimeDelta::FromMilliseconds(100),
- 3);
+ gfx::Point(80, 80), gfx::Point(100, 100),
+ base::TimeDelta::FromMilliseconds(100), 3);
RunAllPendingInMessageLoop();
int tap_down_count = 0;
@@ -1835,9 +1826,7 @@ class ValidRootDuringDestructionWindowObserver : public aura::WindowObserver {
public:
ValidRootDuringDestructionWindowObserver(bool* got_destroying,
bool* has_valid_root)
- : got_destroying_(got_destroying),
- has_valid_root_(has_valid_root) {
- }
+ : got_destroying_(got_destroying), has_valid_root_(has_valid_root) {}
// WindowObserver:
void OnWindowDestroying(aura::Window* window) override {
@@ -1879,9 +1868,8 @@ namespace {
class DontResetHeldEventWindowDelegate : public test::TestWindowDelegate {
public:
explicit DontResetHeldEventWindowDelegate(aura::Window* root)
- : root_(root),
- mouse_event_count_(0) {}
- ~DontResetHeldEventWindowDelegate() override {}
+ : root_(root), mouse_event_count_(0) {}
+ ~DontResetHeldEventWindowDelegate() override = default;
int mouse_event_count() const { return mouse_event_count_; }
@@ -1933,15 +1921,11 @@ TEST_F(WindowEventDispatcherTest, DontResetHeldEvent) {
namespace {
// See description above DeleteHostFromHeldMouseEvent for details.
-class DeleteHostFromHeldMouseEventDelegate
- : public test::TestWindowDelegate {
+class DeleteHostFromHeldMouseEventDelegate : public test::TestWindowDelegate {
public:
explicit DeleteHostFromHeldMouseEventDelegate(WindowTreeHost* host)
- : host_(host),
- got_mouse_event_(false),
- got_destroy_(false) {
- }
- ~DeleteHostFromHeldMouseEventDelegate() override {}
+ : host_(host), got_mouse_event_(false), got_destroy_(false) {}
+ ~DeleteHostFromHeldMouseEventDelegate() override = default;
bool got_mouse_event() const { return got_mouse_event_; }
bool got_destroy() const { return got_destroy_; }
@@ -1997,9 +1981,8 @@ TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveTouches) {
&delegate, 1, gfx::Rect(0, 0, 100, 100), root_window()));
gfx::Point position1 = root_window()->bounds().origin();
- ui::TouchEvent press(
- ui::ET_TOUCH_PRESSED, position1, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, position1, ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_EQ("TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN",
@@ -2024,19 +2007,16 @@ TEST_F(WindowEventDispatcherTest, WindowHideCancelsActiveGestures) {
gfx::Point position1 = root_window()->bounds().origin();
gfx::Point position2 = root_window()->bounds().CenterPoint();
- ui::TouchEvent press(
- ui::ET_TOUCH_PRESSED, position1, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, position1, ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&press);
- ui::TouchEvent move(
- ui::ET_TOUCH_MOVED, position2, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent move(ui::ET_TOUCH_MOVED, position2, ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&move);
- ui::TouchEvent press2(
- ui::ET_TOUCH_PRESSED, position1, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, position1, ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
DispatchEventUsingWindowDispatcher(&press2);
// TODO(tdresser): once the unified Gesture Recognizer has stuck, remove the
@@ -2132,23 +2112,22 @@ TEST_F(WindowEventDispatcherTest, EndingEventDoesntRetarget) {
window2->AddPreTargetHandler(&recorder2);
gfx::Point position = window1->bounds().origin();
- ui::TouchEvent press(
- ui::ET_TOUCH_PRESSED, position, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, position, ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&press);
gfx::Point position2 = window1->bounds().CenterPoint();
- ui::TouchEvent move(
- ui::ET_TOUCH_MOVED, position2, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent move(ui::ET_TOUCH_MOVED, position2, ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&move);
window2->SetCapture();
- EXPECT_EQ("TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_MOVED "
- "GESTURE_TAP_CANCEL GESTURE_SCROLL_BEGIN GESTURE_SCROLL_UPDATE "
- "TOUCH_CANCELLED GESTURE_SCROLL_END GESTURE_END",
- EventTypesToString(recorder1.events()));
+ EXPECT_EQ(
+ "TOUCH_PRESSED GESTURE_BEGIN GESTURE_TAP_DOWN TOUCH_MOVED "
+ "GESTURE_TAP_CANCEL GESTURE_SCROLL_BEGIN GESTURE_SCROLL_UPDATE "
+ "TOUCH_CANCELLED GESTURE_SCROLL_END GESTURE_END",
+ EventTypesToString(recorder1.events()));
EXPECT_TRUE(recorder2.events().empty());
@@ -2171,9 +2150,7 @@ class CaptureWindowTracker : public test::TestWindowDelegate {
capture_window_->SetCapture();
}
- void reset() {
- capture_window_.reset();
- }
+ void reset() { capture_window_.reset(); }
void OnCaptureLost() override { capture_window_.reset(); }
@@ -2190,7 +2167,7 @@ class CaptureWindowTracker : public test::TestWindowDelegate {
DISALLOW_COPY_AND_ASSIGN(CaptureWindowTracker);
};
-}
+} // namespace
// Verifies handling loss of capture by the capture window being hidden.
TEST_F(WindowEventDispatcherTest, CaptureWindowHidden) {
@@ -2428,9 +2405,8 @@ TEST_F(WindowEventDispatcherTestInHighDPI, TouchMovesHeldOnScroll) {
window->AddPreTargetHandler(&handler);
ui::test::EventGenerator generator(root_window());
- generator.GestureScrollSequence(
- gfx::Point(120, 120), gfx::Point(20, 120),
- base::TimeDelta::FromMilliseconds(100), 25);
+ generator.GestureScrollSequence(gfx::Point(120, 120), gfx::Point(20, 120),
+ base::TimeDelta::FromMilliseconds(100), 25);
// |handler| will have reset |filter| and started holding the touch-move
// events when scrolling started. At the end of the scroll (i.e. upon
@@ -2543,19 +2519,16 @@ class SelfDestructDelegate : public test::TestWindowDelegate {
TEST_F(WindowEventDispatcherTest, SynthesizedLocatedEvent) {
ui::test::EventGenerator generator(root_window());
generator.MoveMouseTo(10, 10);
- EXPECT_EQ("10,10",
- Env::GetInstance()->last_mouse_location().ToString());
+ EXPECT_EQ("10,10", Env::GetInstance()->last_mouse_location().ToString());
// Synthesized event should not update the mouse location.
ui::MouseEvent mouseev(ui::ET_MOUSE_MOVED, gfx::Point(), gfx::Point(),
ui::EventTimeForNow(), ui::EF_IS_SYNTHESIZED, 0);
generator.Dispatch(&mouseev);
- EXPECT_EQ("10,10",
- Env::GetInstance()->last_mouse_location().ToString());
+ EXPECT_EQ("10,10", Env::GetInstance()->last_mouse_location().ToString());
generator.MoveMouseTo(0, 0);
- EXPECT_EQ("0,0",
- Env::GetInstance()->last_mouse_location().ToString());
+ EXPECT_EQ("0,0", Env::GetInstance()->last_mouse_location().ToString());
// Make sure the location gets updated when a syntheiszed enter
// event destroyed the window.
@@ -2567,8 +2540,7 @@ TEST_F(WindowEventDispatcherTest, SynthesizedLocatedEvent) {
generator.MoveMouseTo(100, 100);
EXPECT_FALSE(delegate.has_window());
- EXPECT_EQ("100,100",
- Env::GetInstance()->last_mouse_location().ToString());
+ EXPECT_EQ("100,100", Env::GetInstance()->last_mouse_location().ToString());
}
// Tests that the window which has capture can get destroyed as a result of
@@ -2595,9 +2567,8 @@ TEST_F(WindowEventDispatcherTest, DestroyWindowOnCaptureChanged) {
class StaticFocusClient : public client::FocusClient {
public:
- explicit StaticFocusClient(Window* focused)
- : focused_(focused) {}
- ~StaticFocusClient() override {}
+ explicit StaticFocusClient(Window* focused) : focused_(focused) {}
+ ~StaticFocusClient() override = default;
private:
// client::FocusClient:
@@ -2633,11 +2604,11 @@ TEST_F(WindowEventDispatcherTest, HostCancelModeWithFocusedWindowOutside) {
class DispatchEventHandler : public ui::EventHandler {
public:
explicit DispatchEventHandler(Window* target)
- : target_(target),
- dispatched_(false) {}
- ~DispatchEventHandler() override {}
+ : target_(target), dispatched_(false) {}
+ ~DispatchEventHandler() override = default;
bool dispatched() const { return dispatched_; }
+
private:
// ui::EventHandler:
void OnMouseEvent(ui::MouseEvent* mouse) override {
@@ -2665,9 +2636,8 @@ class DispatchEventHandler : public ui::EventHandler {
class MoveWindowHandler : public ui::EventHandler {
public:
MoveWindowHandler(Window* window, Window* root_window)
- : window_to_move_(window),
- root_window_to_move_to_(root_window) {}
- ~MoveWindowHandler() override {}
+ : window_to_move_(window), root_window_to_move_to_(root_window) {}
+ ~MoveWindowHandler() override = default;
private:
// ui::EventHandler:
@@ -2846,9 +2816,8 @@ class AsyncWindowDelegate : public test::TestWindowDelegate {
AsyncWindowDelegate(WindowEventDispatcher* dispatcher)
: dispatcher_(dispatcher), window_(nullptr) {}
- void set_window(Window* window) {
- window_ = window;
- }
+ void set_window(Window* window) { window_ = window; }
+
private:
void OnTouchEvent(ui::TouchEvent* event) override {
// Convert touch event back to root window coordinates.
@@ -2886,7 +2855,7 @@ TEST_F(WindowEventDispatcherTest, GestureEventCoordinates) {
ui::TouchEvent touch_pressed_event(
ui::ET_TOUCH_PRESSED, gfx::Point(), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
touch_pressed_event.set_location_f(gfx::PointF(kX, kY));
touch_pressed_event.set_root_location_f(gfx::PointF(kX, kY));
@@ -2909,18 +2878,16 @@ TEST_F(WindowEventDispatcherTest, TouchMovesMarkedWhenCausingScroll) {
root_window()->AddPreTargetHandler(&recorder);
const gfx::Point location(20, 20);
- ui::TouchEvent press(
- ui::ET_TOUCH_PRESSED, location, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, location, ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_FALSE(recorder.LastTouchMayCauseScrolling());
EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_PRESSED));
recorder.Reset();
- ui::TouchEvent move(
- ui::ET_TOUCH_MOVED, location + gfx::Vector2d(100, 100),
- ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent move(ui::ET_TOUCH_MOVED, location + gfx::Vector2d(100, 100),
+ ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&move);
EXPECT_TRUE(recorder.LastTouchMayCauseScrolling());
EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_MOVED));
@@ -2928,10 +2895,9 @@ TEST_F(WindowEventDispatcherTest, TouchMovesMarkedWhenCausingScroll) {
EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_GESTURE_SCROLL_UPDATE));
recorder.Reset();
- ui::TouchEvent move2(
- ui::ET_TOUCH_MOVED, location + gfx::Vector2d(200, 200),
- ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent move2(ui::ET_TOUCH_MOVED, location + gfx::Vector2d(200, 200),
+ ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_TRUE(recorder.LastTouchMayCauseScrolling());
EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_MOVED));
@@ -2942,7 +2908,7 @@ TEST_F(WindowEventDispatcherTest, TouchMovesMarkedWhenCausingScroll) {
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, location + gfx::Vector2d(200, 200),
ui::EventTimeForNow() + base::TimeDelta::FromSeconds(1),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_TRUE(recorder.LastTouchMayCauseScrolling());
EXPECT_TRUE(recorder.HasReceivedEvent(ui::ET_TOUCH_RELEASED));
@@ -3060,10 +3026,10 @@ TEST_F(WindowEventDispatcherTest, TouchEventWithScaledWindow) {
const gfx::Point touch_position(-5, -5);
ui::TouchEvent pressed_event(
ui::ET_TOUCH_PRESSED, touch_position, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
ui::TouchEvent released_event(
ui::ET_TOUCH_RELEASED, touch_position, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
dispatcher->OnEventFromSource(&pressed_event);
dispatcher->OnEventFromSource(&released_event);
EXPECT_EQ(expected_events, EventTypesToString(root_recorder.events()));
@@ -3078,10 +3044,10 @@ TEST_F(WindowEventDispatcherTest, TouchEventWithScaledWindow) {
const gfx::Point touch_position(5, 5);
ui::TouchEvent pressed_event(
ui::ET_TOUCH_PRESSED, touch_position, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
ui::TouchEvent released_event(
ui::ET_TOUCH_RELEASED, touch_position, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
dispatcher->OnEventFromSource(&pressed_event);
dispatcher->OnEventFromSource(&released_event);
EXPECT_EQ(expected_events, EventTypesToString(root_recorder.events()));
diff --git a/chromium/ui/aura/window_observer.cc b/chromium/ui/aura/window_observer.cc
index 1c8a745d55a..688bd40bb9d 100644
--- a/chromium/ui/aura/window_observer.cc
+++ b/chromium/ui/aura/window_observer.cc
@@ -4,7 +4,7 @@
#include "ui/aura/window_observer.h"
-#include "base/logging.h"
+#include "base/check.h"
namespace aura {
diff --git a/chromium/ui/aura/window_occlusion_change_builder.cc b/chromium/ui/aura/window_occlusion_change_builder.cc
index b7acb5f244c..5fadff604dc 100644
--- a/chromium/ui/aura/window_occlusion_change_builder.cc
+++ b/chromium/ui/aura/window_occlusion_change_builder.cc
@@ -4,8 +4,8 @@
#include "ui/aura/window_occlusion_change_builder.h"
+#include "base/check_op.h"
#include "base/containers/flat_map.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "components/viz/client/frame_eviction_manager.h"
#include "third_party/skia/include/core/SkRegion.h"
diff --git a/chromium/ui/aura/window_tree_host.cc b/chromium/ui/aura/window_tree_host.cc
index 53119cd0f74..29c93adb189 100644
--- a/chromium/ui/aura/window_tree_host.cc
+++ b/chromium/ui/aura/window_tree_host.cc
@@ -19,10 +19,10 @@
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_targeter.h"
#include "ui/aura/window_tree_host_observer.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/ime/init/input_method_factory.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/layout.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/view_prop.h"
#include "ui/compositor/compositor_switches.h"
diff --git a/chromium/ui/aura/window_tree_host_platform.cc b/chromium/ui/aura/window_tree_host_platform.cc
index cf8d78806de..8cb0d96a566 100644
--- a/chromium/ui/aura/window_tree_host_platform.cc
+++ b/chromium/ui/aura/window_tree_host_platform.cc
@@ -16,8 +16,8 @@
#include "ui/aura/window.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host_observer.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/layout.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
#include "ui/compositor/compositor.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
diff --git a/chromium/ui/aura/window_unittest.cc b/chromium/ui/aura/window_unittest.cc
index 71f2f0ed353..86204d85e62 100644
--- a/chromium/ui/aura/window_unittest.cc
+++ b/chromium/ui/aura/window_unittest.cc
@@ -817,9 +817,8 @@ TEST_F(WindowTest, CaptureTests) {
EXPECT_EQ(2, delegate.mouse_event_count());
delegate.ResetCounts();
- ui::TouchEvent touchev(
- ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), getTime(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent touchev(ui::ET_TOUCH_PRESSED, gfx::Point(50, 50), getTime(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&touchev);
EXPECT_EQ(1, delegate.touch_event_count());
delegate.ResetCounts();
@@ -834,9 +833,8 @@ TEST_F(WindowTest, CaptureTests) {
generator.PressLeftButton();
EXPECT_EQ(1, delegate.mouse_event_count());
- ui::TouchEvent touchev2(
- ui::ET_TOUCH_PRESSED, gfx::Point(250, 250), getTime(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::TouchEvent touchev2(ui::ET_TOUCH_PRESSED, gfx::Point(250, 250), getTime(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
DispatchEventUsingWindowDispatcher(&touchev2);
EXPECT_EQ(0, delegate.touch_event_count());
@@ -858,9 +856,8 @@ TEST_F(WindowTest, TouchCaptureCancelsOtherTouches) {
&delegate2, 0, gfx::Rect(50, 50, 50, 50), root_window()));
// Press on w1.
- ui::TouchEvent press1(
- ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), getTime(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), getTime(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&press1);
// We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN.
EXPECT_EQ(2, delegate1.gesture_event_count());
@@ -873,27 +870,24 @@ TEST_F(WindowTest, TouchCaptureCancelsOtherTouches) {
delegate1.ResetCounts();
delegate2.ResetCounts();
- // Events are now untargetted.
- ui::TouchEvent move(
- ui::ET_TOUCH_MOVED, gfx::Point(10, 20), getTime(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ // Events are now untargeted.
+ ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), getTime(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&move);
EXPECT_EQ(0, delegate1.gesture_event_count());
EXPECT_EQ(0, delegate1.touch_event_count());
EXPECT_EQ(0, delegate2.gesture_event_count());
EXPECT_EQ(0, delegate2.touch_event_count());
- ui::TouchEvent release(
- ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), getTime(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), getTime(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_EQ(0, delegate1.gesture_event_count());
EXPECT_EQ(0, delegate2.gesture_event_count());
// A new press is captured by w2.
- ui::TouchEvent press2(
- ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), getTime(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent press2(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), getTime(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&press2);
EXPECT_EQ(0, delegate1.gesture_event_count());
// We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN.
@@ -916,9 +910,8 @@ TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) {
base::TimeTicks time = getTime();
const int kTimeDelta = 100;
- ui::TouchEvent press(
- ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), time,
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), time,
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&press);
// We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN.
@@ -934,9 +927,8 @@ TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) {
// On move We will get TOUCH_MOVED, GESTURE_TAP_CANCEL,
// GESTURE_SCROLL_START and GESTURE_SCROLL_UPDATE.
time += base::TimeDelta::FromMilliseconds(kTimeDelta);
- ui::TouchEvent move(
- ui::ET_TOUCH_MOVED, gfx::Point(10, 20), time,
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(10, 20), time,
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&move);
EXPECT_EQ(1, delegate.touch_event_count());
EXPECT_EQ(3, delegate.gesture_event_count());
@@ -950,9 +942,8 @@ TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) {
// On move we still get TOUCH_MOVED and GESTURE_SCROLL_UPDATE.
time += base::TimeDelta::FromMilliseconds(kTimeDelta);
- ui::TouchEvent move2(
- ui::ET_TOUCH_MOVED, gfx::Point(10, 30), time,
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent move2(ui::ET_TOUCH_MOVED, gfx::Point(10, 30), time,
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&move2);
EXPECT_EQ(1, delegate.touch_event_count());
EXPECT_EQ(1, delegate.gesture_event_count());
@@ -960,9 +951,8 @@ TEST_F(WindowTest, TouchCaptureDoesntCancelCapturedTouches) {
// And on release we get TOUCH_RELEASED, GESTURE_SCROLL_END, GESTURE_END
time += base::TimeDelta::FromMilliseconds(kTimeDelta);
- ui::TouchEvent release(
- ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), time,
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(10, 20), time,
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_EQ(1, delegate.touch_event_count());
EXPECT_EQ(2, delegate.gesture_event_count());
@@ -974,9 +964,8 @@ TEST_F(WindowTest, TransferCaptureTouchEvents) {
CaptureWindowDelegateImpl d1;
std::unique_ptr<Window> w1(CreateTestWindowWithDelegate(
&d1, 0, gfx::Rect(0, 0, 20, 20), root_window()));
- ui::TouchEvent p1(
- ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), getTime(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent p1(ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), getTime(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&p1);
// We will get both GESTURE_BEGIN and GESTURE_TAP_DOWN.
EXPECT_EQ(1, d1.touch_event_count());
@@ -987,9 +976,8 @@ TEST_F(WindowTest, TransferCaptureTouchEvents) {
CaptureWindowDelegateImpl d2;
std::unique_ptr<Window> w2(CreateTestWindowWithDelegate(
&d2, 0, gfx::Rect(40, 0, 40, 20), root_window()));
- ui::TouchEvent p2(
- ui::ET_TOUCH_PRESSED, gfx::Point(41, 10), getTime(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::TouchEvent p2(ui::ET_TOUCH_PRESSED, gfx::Point(41, 10), getTime(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
DispatchEventUsingWindowDispatcher(&p2);
EXPECT_EQ(0, d1.touch_event_count());
EXPECT_EQ(0, d1.gesture_event_count());
@@ -1024,9 +1012,8 @@ TEST_F(WindowTest, TransferCaptureTouchEvents) {
// Move touch id originally associated with |w2|. The touch has been
// cancelled, so no events should be dispatched.
- ui::TouchEvent m3(
- ui::ET_TOUCH_MOVED, gfx::Point(110, 105), getTime(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::TouchEvent m3(ui::ET_TOUCH_MOVED, gfx::Point(110, 105), getTime(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
DispatchEventUsingWindowDispatcher(&m3);
EXPECT_EQ(0, d1.touch_event_count());
EXPECT_EQ(0, d1.gesture_event_count());
@@ -1045,9 +1032,8 @@ TEST_F(WindowTest, TransferCaptureTouchEvents) {
EXPECT_EQ(0, d3.gesture_event_count());
// The touch has been cancelled, so no events are dispatched.
- ui::TouchEvent m4(
- ui::ET_TOUCH_MOVED, gfx::Point(120, 105), getTime(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::TouchEvent m4(ui::ET_TOUCH_MOVED, gfx::Point(120, 105), getTime(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
DispatchEventUsingWindowDispatcher(&m4);
EXPECT_EQ(0, d1.touch_event_count());
EXPECT_EQ(0, d1.gesture_event_count());
@@ -1688,9 +1674,9 @@ TEST_F(WindowTest, TransformGesture) {
host()->SetRootTransform(OverlayTransformToTransform(
gfx::OVERLAY_TRANSFORM_ROTATE_90, gfx::SizeF(size)));
- ui::TouchEvent press(
- ui::ET_TOUCH_PRESSED, gfx::Point(size.height() - 10, 10), getTime(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(size.height() - 10, 10),
+ getTime(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
DispatchEventUsingWindowDispatcher(&press);
EXPECT_EQ(gfx::Point(10, 10).ToString(), delegate->position().ToString());
}
diff --git a/chromium/ui/base/BUILD.gn b/chromium/ui/base/BUILD.gn
index 33be56acd44..547ecab34e4 100644
--- a/chromium/ui/base/BUILD.gn
+++ b/chromium/ui/base/BUILD.gn
@@ -99,7 +99,6 @@ jumbo_component("base") {
"default_style.h",
"device_form_factor.h",
"device_form_factor_desktop.cc",
- "dragdrop/download_file_interface.h",
"dragdrop/drag_drop_types.h",
"dragdrop/drop_target_event.cc",
"dragdrop/drop_target_event.h",
@@ -123,6 +122,8 @@ jumbo_component("base") {
"models/combobox_model.cc",
"models/combobox_model.h",
"models/combobox_model_observer.h",
+ "models/image_model.cc",
+ "models/image_model.h",
"models/list_model.h",
"models/list_model_observer.h",
"models/list_selection_model.cc",
@@ -266,6 +267,8 @@ jumbo_component("base") {
"cocoa/focus_window_set.mm",
"cocoa/menu_controller.h",
"cocoa/menu_controller.mm",
+ "cocoa/permissions_utils.h",
+ "cocoa/permissions_utils.mm",
"cocoa/quartz_util.h",
"cocoa/quartz_util.mm",
"cocoa/remote_accessibility_api.h",
@@ -332,8 +335,6 @@ jumbo_component("base") {
"base_window.h",
"cursor/cursor_util.cc",
"cursor/cursor_util.h",
- "default_theme_provider.cc",
- "default_theme_provider.h",
"emoji/emoji_panel_helper.h",
"pointer/pointer_device.h",
"pointer/pointer_device_util.cc",
@@ -425,7 +426,7 @@ jumbo_component("base") {
"//base",
"//skia",
"//ui/base/cursor",
- "//ui/base/mojom:cursor_type",
+ "//ui/base/cursor/mojom:cursor_type",
"//ui/gfx",
"//ui/gfx/geometry",
]
@@ -439,6 +440,7 @@ jumbo_component("base") {
"//third_party/modp_b64",
"//third_party/zlib:zlib",
"//third_party/zlib/google:compression_utils",
+ "//ui/base:data_exchange",
"//ui/base/clipboard:clipboard_types",
"//ui/display",
"//ui/events",
@@ -479,13 +481,11 @@ jumbo_component("base") {
if (is_desktop_linux && (use_x11 || ozone_platform_x11)) {
public_deps += [ "//ui/base/x" ]
- configs += [ "//build/config/linux:x11" ]
# X11 drag and drop wants to use common drag and drop types.
allow_circular_includes_from = [ "//ui/base/x" ]
if (!is_chromeos) {
- configs += [ "//build/config/linux:xscrnsaver" ]
deps += [ "//ui/gfx/x" ]
}
}
@@ -507,8 +507,8 @@ jumbo_component("base") {
if (!is_chromeos) {
# These Aura X11 files aren't used on ChromeOS.
sources += [
- "dragdrop/os_exchange_data_provider_aurax11.cc",
- "dragdrop/os_exchange_data_provider_aurax11.h",
+ "dragdrop/os_exchange_data_provider_x11.cc",
+ "dragdrop/os_exchange_data_provider_x11.h",
]
}
}
@@ -629,7 +629,6 @@ jumbo_component("base") {
libs += [ "jnigraphics" ]
sources -= [
- "default_theme_provider.cc",
"l10n/l10n_font_util.cc",
"models/button_menu_item_model.cc",
"pointer/touch_editing_controller.cc",
@@ -653,6 +652,28 @@ jumbo_component("base") {
}
}
+component("data_exchange") {
+ defines = [ "IS_UI_BASE_DATA_EXCHANGE_IMPL" ]
+
+ sources = [
+ "dragdrop/download_file_info.cc",
+ "dragdrop/download_file_info.h",
+ "dragdrop/download_file_interface.h",
+ "dragdrop/os_exchange_data_provider.h",
+ "dragdrop/os_exchange_data_provider_factory_ozone.cc",
+ "dragdrop/os_exchange_data_provider_factory_ozone.h",
+ ]
+
+ deps = [
+ "//base",
+ "//ui/base/clipboard:clipboard_types",
+ "//ui/base/dragdrop/file_info",
+ "//ui/gfx",
+ "//ui/gfx/geometry",
+ "//url",
+ ]
+}
+
component("features") {
output_name = "ui_base_features"
@@ -669,7 +690,7 @@ component("features") {
]
}
-if (!is_ios) {
+if (is_win || is_mac || (is_linux && !is_chromeos)) {
jumbo_static_library("pixel_diff_test_support") {
testonly = true
sources = [
@@ -687,7 +708,9 @@ if (!is_ios) {
data_deps = [ ":goldctl" ]
}
}
+}
+if (!is_ios) {
group("goldctl") {
data = []
@@ -747,6 +770,8 @@ jumbo_static_library("test_support") {
sources += [
"accelerators/test_accelerator_target.cc",
"accelerators/test_accelerator_target.h",
+ "test/mock_base_window.cc",
+ "test/mock_base_window.h",
"test/ui_controls.h",
"test/view_tree_validator.h",
]
@@ -893,6 +918,7 @@ test("ui_base_unittests") {
"l10n/l10n_util_unittest.cc",
"l10n/time_format_unittest.cc",
"layout_unittest.cc",
+ "models/image_model_unittest.cc",
"models/simple_menu_model_unittest.cc",
"models/tree_node_iterator_unittest.cc",
"pointer/touch_ui_controller_unittest.cc",
@@ -938,6 +964,7 @@ test("ui_base_unittests") {
"//third_party/icu",
"//third_party/zlib/google:compression_utils",
"//ui/base",
+ "//ui/base:data_exchange",
"//ui/base:test_support",
"//ui/base:ui_data_pack",
"//ui/base/clipboard:clipboard_test",
@@ -977,14 +1004,12 @@ test("ui_base_unittests") {
"models/list_model_unittest.cc",
"models/list_selection_model_unittest.cc",
"models/tree_node_model_unittest.cc",
- "test/skia_gold_pixel_diff_unittest.cc",
"text/bytes_formatting_unittest.cc",
"webui/web_ui_util_unittest.cc",
]
deps += [
- ":pixel_diff_test_support",
"//components/system_media_controls:test_support",
- "//ui/base/mojom:cursor_type",
+ "//ui/base/cursor/mojom:cursor_type",
]
if (is_linux) {
@@ -1008,6 +1033,11 @@ test("ui_base_unittests") {
}
}
+ if (is_win || is_mac || (is_linux && !is_chromeos)) {
+ sources += [ "test/skia_gold_pixel_diff_unittest.cc" ]
+ deps += [ ":pixel_diff_test_support" ]
+ }
+
if (build_ime) {
sources += [
"ime/candidate_window_unittest.cc",
@@ -1077,7 +1107,7 @@ test("ui_base_unittests") {
} else {
deps += [
"//ui/base/accelerators/mojom:unittests",
- "//ui/base/mojom:unittests",
+ "//ui/base/cursor/mojom:unittests",
]
}
@@ -1115,8 +1145,6 @@ test("ui_base_unittests") {
}
if (use_x11) {
- configs += [ "//build/config/linux:x11" ]
-
deps += [
"//ui/events/platform/x11",
"//ui/gfx/x",
@@ -1142,7 +1170,7 @@ test("ui_base_unittests") {
if (use_x11) {
sources += [
- "dragdrop/os_exchange_data_provider_aurax11_unittest.cc",
+ "dragdrop/os_exchange_data_provider_x11_unittest.cc",
"x/selection_requestor_unittest.cc",
]
}
diff --git a/chromium/ui/base/accelerators/accelerator.cc b/chromium/ui/base/accelerators/accelerator.cc
index 291bdeec97b..2ab364badbe 100644
--- a/chromium/ui/base/accelerators/accelerator.cc
+++ b/chromium/ui/base/accelerators/accelerator.cc
@@ -7,8 +7,9 @@
#include <stdint.h>
#include <tuple>
+#include "base/check_op.h"
#include "base/i18n/rtl.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chromium/ui/base/accelerators/accelerator_manager.cc b/chromium/ui/base/accelerators/accelerator_manager.cc
index 3ee4a7e60a2..c3db7cc5f2c 100644
--- a/chromium/ui/base/accelerators/accelerator_manager.cc
+++ b/chromium/ui/base/accelerators/accelerator_manager.cc
@@ -6,7 +6,8 @@
#include <algorithm>
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
namespace ui {
diff --git a/chromium/ui/base/accelerators/mojom/BUILD.gn b/chromium/ui/base/accelerators/mojom/BUILD.gn
index 03a7b86989c..bf8a1f3d7d9 100644
--- a/chromium/ui/base/accelerators/mojom/BUILD.gn
+++ b/chromium/ui/base/accelerators/mojom/BUILD.gn
@@ -10,6 +10,23 @@ mojom("mojom") {
"//mojo/public/mojom/base",
"//ui/events/mojom",
]
+
+ cpp_typemaps = [
+ {
+ types = [
+ {
+ mojom = "ui.mojom.Accelerator"
+ cpp = "::ui::Accelerator"
+ },
+ {
+ mojom = "ui.mojom.AcceleratorKeyState"
+ cpp = "::ui::Accelerator::KeyState"
+ },
+ ]
+ traits_headers = [ "accelerator_mojom_traits.h" ]
+ traits_public_deps = [ ":mojom_traits" ]
+ },
+ ]
}
source_set("mojom_traits") {
diff --git a/chromium/ui/base/accelerators/mojom/OWNERS b/chromium/ui/base/accelerators/mojom/OWNERS
index 743855d259f..1feb5149750 100644
--- a/chromium/ui/base/accelerators/mojom/OWNERS
+++ b/chromium/ui/base/accelerators/mojom/OWNERS
@@ -1,8 +1,4 @@
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-per-file *.typemap=set noparent
-per-file *.typemap=file://ipc/SECURITY_OWNERS
-
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
diff --git a/chromium/ui/base/accelerators/mojom/accelerator.typemap b/chromium/ui/base/accelerators/mojom/accelerator.typemap
deleted file mode 100644
index f25a35150de..00000000000
--- a/chromium/ui/base/accelerators/mojom/accelerator.typemap
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2017 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.
-
-mojom = "//ui/base/accelerators/mojom/accelerator.mojom"
-public_headers = [ "//ui/base/accelerators/accelerator.h" ]
-traits_headers = [ "//ui/base/accelerators/mojom/accelerator_mojom_traits.h" ]
-deps = [
- "//ui/base/accelerators/mojom:mojom_traits",
-]
-type_mappings = [
- "ui.mojom.Accelerator=::ui::Accelerator",
- "ui.mojom.AcceleratorKeyState=::ui::Accelerator::KeyState",
-]
diff --git a/chromium/ui/base/accelerators/mojom/typemaps.gni b/chromium/ui/base/accelerators/mojom/typemaps.gni
deleted file mode 100644
index 3a1663d3aa3..00000000000
--- a/chromium/ui/base/accelerators/mojom/typemaps.gni
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2018 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.
-
-typemaps = [ "//ui/base/accelerators/mojom/accelerator.typemap" ]
diff --git a/chromium/ui/base/accelerators/test_accelerator_target.h b/chromium/ui/base/accelerators/test_accelerator_target.h
index d1c7e3eadcd..06537eb2cf2 100644
--- a/chromium/ui/base/accelerators/test_accelerator_target.h
+++ b/chromium/ui/base/accelerators/test_accelerator_target.h
@@ -5,6 +5,7 @@
#ifndef UI_BASE_ACCELERATORS_TEST_ACCELERATOR_TARGET_H_
#define UI_BASE_ACCELERATORS_TEST_ACCELERATOR_TARGET_H_
+#include "base/macros.h"
#include "ui/base/accelerators/accelerator.h"
namespace ui {
diff --git a/chromium/ui/base/clipboard/BUILD.gn b/chromium/ui/base/clipboard/BUILD.gn
index 15f86a7b2ac..61570cc1f2e 100644
--- a/chromium/ui/base/clipboard/BUILD.gn
+++ b/chromium/ui/base/clipboard/BUILD.gn
@@ -126,7 +126,6 @@ jumbo_component("clipboard") {
"clipboard_x11.cc",
"clipboard_x11.h",
]
- configs += [ "//build/config/linux:x11" ]
deps += [
"//ui/base",
"//ui/base/x",
diff --git a/chromium/ui/base/clipboard/clipboard.cc b/chromium/ui/base/clipboard/clipboard.cc
index a1231970667..a91de7c9517 100644
--- a/chromium/ui/base/clipboard/clipboard.cc
+++ b/chromium/ui/base/clipboard/clipboard.cc
@@ -8,8 +8,9 @@
#include <limits>
#include <memory>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/memory/ptr_util.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/geometry/size.h"
diff --git a/chromium/ui/base/clipboard/clipboard.h b/chromium/ui/base/clipboard/clipboard.h
index eb07cfd9c08..40f0e4d5e0d 100644
--- a/chromium/ui/base/clipboard/clipboard.h
+++ b/chromium/ui/base/clipboard/clipboard.h
@@ -118,8 +118,7 @@ class COMPONENT_EXPORT(UI_BASE_CLIPBOARD) Clipboard
// Includes all sanitized types.
// Also, includes pickled types by splitting them out of the pickled format.
virtual void ReadAvailableTypes(ClipboardBuffer buffer,
- std::vector<base::string16>* types,
- bool* contains_filenames) const = 0;
+ std::vector<base::string16>* types) const = 0;
// Includes all types, including unsanitized types.
// Omits formats held within pickles, as they're different from what a native
// application would see.
diff --git a/chromium/ui/base/clipboard/clipboard_android.cc b/chromium/ui/base/clipboard/clipboard_android.cc
index cab3e7647da..501d191e961 100644
--- a/chromium/ui/base/clipboard/clipboard_android.cc
+++ b/chromium/ui/base/clipboard/clipboard_android.cc
@@ -10,6 +10,7 @@
#include <utility>
#include <vector>
+#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h"
#include "base/bind.h"
@@ -26,7 +27,7 @@
#include "ui/base/clipboard/clipboard_constants.h"
#include "ui/base/ui_base_jni_headers/Clipboard_jni.h"
#include "ui/gfx/android/java_bitmap.h"
-#include "ui/gfx/geometry/size.h"
+#include "ui/gfx/image/image.h"
// TODO:(andrewhayden) Support additional formats in Android: Bitmap, URI, HTML,
// HTML+text now that Android's clipboard system supports them, then nuke the
@@ -45,11 +46,14 @@ using base::android::ConvertJavaStringToUTF8;
using base::android::ConvertUTF8ToJavaString;
using base::android::ScopedJavaGlobalRef;
using base::android::ScopedJavaLocalRef;
+using base::android::ToJavaByteArray;
namespace ui {
namespace {
+constexpr char kPngExtension[] = ".png";
+
using ReadImageCallback = ClipboardAndroid::ReadImageCallback;
// Fetching image data from Java.
@@ -223,6 +227,15 @@ void ClipboardMap::CommitToAndroidClipboard() {
env, map_[ClipboardFormatType::GetPlainTextType().GetName()]);
DCHECK(str.obj());
Java_Clipboard_setText(env, clipboard_manager_, str);
+ } else if (base::Contains(map_,
+ ClipboardFormatType::GetBitmapType().GetName())) {
+ ScopedJavaLocalRef<jbyteArray> image_data = ToJavaByteArray(
+ env, map_[ClipboardFormatType::GetBitmapType().GetName()]);
+ ScopedJavaLocalRef<jstring> image_extension =
+ ConvertUTF8ToJavaString(env, kPngExtension);
+ DCHECK(image_data.obj());
+ Java_Clipboard_setImage(env, clipboard_manager_, image_data,
+ image_extension);
} else {
Java_Clipboard_clear(env, clipboard_manager_);
// TODO(huangdarwin): Implement raw clipboard support for arbitrary formats.
@@ -368,16 +381,12 @@ void ClipboardAndroid::Clear(ClipboardBuffer buffer) {
g_map.Get().Clear();
}
-void ClipboardAndroid::ReadAvailableTypes(ClipboardBuffer buffer,
- std::vector<base::string16>* types,
- bool* contains_filenames) const {
+void ClipboardAndroid::ReadAvailableTypes(
+ ClipboardBuffer buffer,
+ std::vector<base::string16>* types) const {
DCHECK(CalledOnValidThread());
DCHECK_EQ(buffer, ClipboardBuffer::kCopyPaste);
-
- if (!types || !contains_filenames) {
- NOTREACHED();
- return;
- }
+ DCHECK(types);
types->clear();
@@ -394,7 +403,6 @@ void ClipboardAndroid::ReadAvailableTypes(ClipboardBuffer buffer,
types->push_back(base::UTF8ToUTF16(kMimeTypeRTF));
if (IsFormatAvailable(ClipboardFormatType::GetBitmapType(), buffer))
types->push_back(base::UTF8ToUTF16(kMimeTypePNG));
- *contains_filenames = false;
}
std::vector<base::string16>
@@ -547,14 +555,13 @@ void ClipboardAndroid::WriteWebSmartPaste() {
std::string());
}
-// Note: we implement this to pass all unit tests but it is currently unclear
-// how some code would consume this.
-void ClipboardAndroid::WriteBitmap(const SkBitmap& bitmap) {
- gfx::Size size(bitmap.width(), bitmap.height());
+// Encoding SkBitmap to PNG data. Then, |g_map| can commit the PNG data to
+// Android system clipboard without encode/decode.
+void ClipboardAndroid::WriteBitmap(const SkBitmap& sk_bitmap) {
+ scoped_refptr<base::RefCountedMemory> image_memory =
+ gfx::Image::CreateFrom1xBitmap(sk_bitmap).As1xPNGBytes();
+ std::string packed(image_memory->front_as<char>(), image_memory->size());
- std::string packed(reinterpret_cast<const char*>(&size), sizeof(size));
- packed += std::string(static_cast<const char*>(bitmap.getPixels()),
- bitmap.computeByteSize());
g_map.Get().Set(ClipboardFormatType::GetBitmapType().GetName(), packed);
}
diff --git a/chromium/ui/base/clipboard/clipboard_android.h b/chromium/ui/base/clipboard/clipboard_android.h
index 4ed96be73ea..c86bd91e81a 100644
--- a/chromium/ui/base/clipboard/clipboard_android.h
+++ b/chromium/ui/base/clipboard/clipboard_android.h
@@ -63,8 +63,7 @@ class ClipboardAndroid : public Clipboard {
ClipboardBuffer buffer) const override;
void Clear(ClipboardBuffer buffer) override;
void ReadAvailableTypes(ClipboardBuffer buffer,
- std::vector<base::string16>* types,
- bool* contains_filenames) const override;
+ std::vector<base::string16>* types) const override;
std::vector<base::string16> ReadAvailablePlatformSpecificFormatNames(
ClipboardBuffer buffer) const override;
void ReadText(ClipboardBuffer buffer, base::string16* result) const override;
diff --git a/chromium/ui/base/clipboard/clipboard_aura.cc b/chromium/ui/base/clipboard/clipboard_aura.cc
index 968759df837..9f4ae70a5ed 100644
--- a/chromium/ui/base/clipboard/clipboard_aura.cc
+++ b/chromium/ui/base/clipboard/clipboard_aura.cc
@@ -11,11 +11,12 @@
#include <memory>
#include <utility>
+#include "base/check_op.h"
#include "base/files/file_path.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/no_destructor.h"
+#include "base/notreached.h"
#include "base/strings/utf_string_conversions.h"
#include "skia/ext/skia_utils_base.h"
#include "third_party/skia/include/core/SkBitmap.h"
@@ -461,17 +462,13 @@ void ClipboardAura::Clear(ClipboardBuffer buffer) {
clipboard_internal_->Clear();
}
-void ClipboardAura::ReadAvailableTypes(ClipboardBuffer buffer,
- std::vector<base::string16>* types,
- bool* contains_filenames) const {
+void ClipboardAura::ReadAvailableTypes(
+ ClipboardBuffer buffer,
+ std::vector<base::string16>* types) const {
DCHECK(CalledOnValidThread());
- if (!types || !contains_filenames) {
- NOTREACHED();
- return;
- }
+ DCHECK(types);
types->clear();
- *contains_filenames = false;
if (IsFormatAvailable(ClipboardFormatType::GetPlainTextType(), buffer))
types->push_back(
base::UTF8ToUTF16(ClipboardFormatType::GetPlainTextType().GetName()));
diff --git a/chromium/ui/base/clipboard/clipboard_aura.h b/chromium/ui/base/clipboard/clipboard_aura.h
index 59c5127ed9f..6a6862ba688 100644
--- a/chromium/ui/base/clipboard/clipboard_aura.h
+++ b/chromium/ui/base/clipboard/clipboard_aura.h
@@ -28,8 +28,7 @@ class ClipboardAura : public Clipboard {
ClipboardBuffer buffer) const override;
void Clear(ClipboardBuffer buffer) override;
void ReadAvailableTypes(ClipboardBuffer buffer,
- std::vector<base::string16>* types,
- bool* contains_filenames) const override;
+ std::vector<base::string16>* types) const override;
std::vector<base::string16> ReadAvailablePlatformSpecificFormatNames(
ClipboardBuffer buffer) const override;
void ReadText(ClipboardBuffer buffer, base::string16* result) const override;
diff --git a/chromium/ui/base/clipboard/clipboard_format_type_win.cc b/chromium/ui/base/clipboard/clipboard_format_type_win.cc
index 4cf30f94fc4..36c0c8b182d 100644
--- a/chromium/ui/base/clipboard/clipboard_format_type_win.cc
+++ b/chromium/ui/base/clipboard/clipboard_format_type_win.cc
@@ -7,10 +7,10 @@
#include <shlobj.h>
#include "base/containers/flat_map.h"
-#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
+#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chromium/ui/base/clipboard/clipboard_mac.h b/chromium/ui/base/clipboard/clipboard_mac.h
index e4dd55835a2..9ebd21cd157 100644
--- a/chromium/ui/base/clipboard/clipboard_mac.h
+++ b/chromium/ui/base/clipboard/clipboard_mac.h
@@ -35,8 +35,7 @@ class COMPONENT_EXPORT(UI_BASE_CLIPBOARD) ClipboardMac : public Clipboard {
ClipboardBuffer buffer) const override;
void Clear(ClipboardBuffer buffer) override;
void ReadAvailableTypes(ClipboardBuffer buffer,
- std::vector<base::string16>* types,
- bool* contains_filenames) const override;
+ std::vector<base::string16>* types) const override;
std::vector<base::string16> ReadAvailablePlatformSpecificFormatNames(
ClipboardBuffer buffer) const override;
void ReadText(ClipboardBuffer buffer, base::string16* result) const override;
diff --git a/chromium/ui/base/clipboard/clipboard_mac.mm b/chromium/ui/base/clipboard/clipboard_mac.mm
index ee7f2c74419..4c8e0e874b0 100644
--- a/chromium/ui/base/clipboard/clipboard_mac.mm
+++ b/chromium/ui/base/clipboard/clipboard_mac.mm
@@ -93,10 +93,12 @@ void ClipboardMac::Clear(ClipboardBuffer buffer) {
[pb declareTypes:@[] owner:nil];
}
-void ClipboardMac::ReadAvailableTypes(ClipboardBuffer buffer,
- std::vector<base::string16>* types,
- bool* contains_filenames) const {
+void ClipboardMac::ReadAvailableTypes(
+ ClipboardBuffer buffer,
+ std::vector<base::string16>* types) const {
DCHECK(CalledOnValidThread());
+ DCHECK(types);
+
types->clear();
if (IsFormatAvailable(ClipboardFormatType::GetPlainTextType(), buffer))
types->push_back(base::UTF8ToUTF16(kMimeTypeText));
@@ -108,7 +110,6 @@ void ClipboardMac::ReadAvailableTypes(ClipboardBuffer buffer,
NSPasteboard* pb = GetPasteboard();
if (pb && [NSImage canInitWithPasteboard:pb])
types->push_back(base::UTF8ToUTF16(kMimeTypePNG));
- *contains_filenames = false;
if ([[pb types] containsObject:kWebCustomDataPboardType]) {
NSData* data = [pb dataForType:kWebCustomDataPboardType];
diff --git a/chromium/ui/base/clipboard/clipboard_ozone.cc b/chromium/ui/base/clipboard/clipboard_ozone.cc
index 99a4581ec6b..bb5b7ad7182 100644
--- a/chromium/ui/base/clipboard/clipboard_ozone.cc
+++ b/chromium/ui/base/clipboard/clipboard_ozone.cc
@@ -343,10 +343,11 @@ void ClipboardOzone::Clear(ClipboardBuffer buffer) {
async_clipboard_ozone_->Clear(buffer);
}
-void ClipboardOzone::ReadAvailableTypes(ClipboardBuffer buffer,
- std::vector<base::string16>* types,
- bool* contains_filenames) const {
+void ClipboardOzone::ReadAvailableTypes(
+ ClipboardBuffer buffer,
+ std::vector<base::string16>* types) const {
DCHECK(CalledOnValidThread());
+ DCHECK(types);
types->clear();
diff --git a/chromium/ui/base/clipboard/clipboard_ozone.h b/chromium/ui/base/clipboard/clipboard_ozone.h
index 7d139e521ef..207ba7ba715 100644
--- a/chromium/ui/base/clipboard/clipboard_ozone.h
+++ b/chromium/ui/base/clipboard/clipboard_ozone.h
@@ -30,8 +30,7 @@ class ClipboardOzone : public Clipboard {
ClipboardBuffer buffer) const override;
void Clear(ClipboardBuffer buffer) override;
void ReadAvailableTypes(ClipboardBuffer buffer,
- std::vector<base::string16>* types,
- bool* contains_filenames) const override;
+ std::vector<base::string16>* types) const override;
std::vector<base::string16> ReadAvailablePlatformSpecificFormatNames(
ClipboardBuffer buffer) const override;
void ReadText(ClipboardBuffer buffer, base::string16* result) const override;
diff --git a/chromium/ui/base/clipboard/clipboard_test_template.h b/chromium/ui/base/clipboard/clipboard_test_template.h
index cce2e542f8f..f31c2594b7d 100644
--- a/chromium/ui/base/clipboard/clipboard_test_template.h
+++ b/chromium/ui/base/clipboard/clipboard_test_template.h
@@ -81,9 +81,8 @@ class ClipboardTest : public PlatformTest {
Clipboard& clipboard() { return *clipboard_; }
std::vector<base::string16> GetAvailableTypes(ClipboardBuffer buffer) {
- bool contains_filenames;
std::vector<base::string16> types;
- clipboard().ReadAvailableTypes(buffer, &types, &contains_filenames);
+ clipboard().ReadAvailableTypes(buffer, &types);
return types;
}
diff --git a/chromium/ui/base/clipboard/clipboard_util_win.h b/chromium/ui/base/clipboard/clipboard_util_win.h
index dc60fc84881..a1e8d5438b0 100644
--- a/chromium/ui/base/clipboard/clipboard_util_win.h
+++ b/chromium/ui/base/clipboard/clipboard_util_win.h
@@ -12,6 +12,7 @@
#include <utility>
#include <vector>
+#include "base/callback_forward.h"
#include "base/component_export.h"
#include "base/files/file_path.h"
#include "base/strings/string16.h"
diff --git a/chromium/ui/base/clipboard/clipboard_win.cc b/chromium/ui/base/clipboard/clipboard_win.cc
index 4362daa04e8..9bfabd34eab 100644
--- a/chromium/ui/base/clipboard/clipboard_win.cc
+++ b/chromium/ui/base/clipboard/clipboard_win.cc
@@ -11,11 +11,12 @@
#include <shlobj.h>
#include "base/bind.h"
+#include "base/check_op.h"
#include "base/files/file_path.h"
#include "base/lazy_instance.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/message_loop/message_loop_current.h"
+#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
@@ -258,13 +259,10 @@ void ClipboardWin::Clear(ClipboardBuffer buffer) {
::EmptyClipboard();
}
-void ClipboardWin::ReadAvailableTypes(ClipboardBuffer buffer,
- std::vector<base::string16>* types,
- bool* contains_filenames) const {
- if (!types || !contains_filenames) {
- NOTREACHED();
- return;
- }
+void ClipboardWin::ReadAvailableTypes(
+ ClipboardBuffer buffer,
+ std::vector<base::string16>* types) const {
+ DCHECK(types);
types->clear();
if (::IsClipboardFormatAvailable(
@@ -278,7 +276,6 @@ void ClipboardWin::ReadAvailableTypes(ClipboardBuffer buffer,
types->push_back(base::UTF8ToUTF16(kMimeTypeRTF));
if (::IsClipboardFormatAvailable(CF_DIB))
types->push_back(base::UTF8ToUTF16(kMimeTypePNG));
- *contains_filenames = false;
// Acquire the clipboard to read WebCustomDataType types.
ScopedClipboard clipboard;
diff --git a/chromium/ui/base/clipboard/clipboard_win.h b/chromium/ui/base/clipboard/clipboard_win.h
index d01ea2a6b2f..f919abd308f 100644
--- a/chromium/ui/base/clipboard/clipboard_win.h
+++ b/chromium/ui/base/clipboard/clipboard_win.h
@@ -40,8 +40,7 @@ class ClipboardWin : public Clipboard {
ClipboardBuffer buffer) const override;
void Clear(ClipboardBuffer buffer) override;
void ReadAvailableTypes(ClipboardBuffer buffer,
- std::vector<base::string16>* types,
- bool* contains_filenames) const override;
+ std::vector<base::string16>* types) const override;
std::vector<base::string16> ReadAvailablePlatformSpecificFormatNames(
ClipboardBuffer buffer) const override;
void ReadText(ClipboardBuffer buffer, base::string16* result) const override;
diff --git a/chromium/ui/base/clipboard/clipboard_x11.cc b/chromium/ui/base/clipboard/clipboard_x11.cc
index 633a80096ad..95e2caff21a 100644
--- a/chromium/ui/base/clipboard/clipboard_x11.cc
+++ b/chromium/ui/base/clipboard/clipboard_x11.cc
@@ -549,14 +549,11 @@ void ClipboardX11::Clear(ClipboardBuffer buffer) {
x11_details_->Clear(buffer);
}
-void ClipboardX11::ReadAvailableTypes(ClipboardBuffer buffer,
- std::vector<base::string16>* types,
- bool* contains_filenames) const {
+void ClipboardX11::ReadAvailableTypes(
+ ClipboardBuffer buffer,
+ std::vector<base::string16>* types) const {
DCHECK(CalledOnValidThread());
- if (!types || !contains_filenames) {
- NOTREACHED();
- return;
- }
+ DCHECK(types);
TargetList target_list = x11_details_->WaitAndGetTargetsList(buffer);
@@ -570,7 +567,6 @@ void ClipboardX11::ReadAvailableTypes(ClipboardBuffer buffer,
types->push_back(base::UTF8ToUTF16(kMimeTypeRTF));
if (target_list.ContainsFormat(ClipboardFormatType::GetBitmapType()))
types->push_back(base::UTF8ToUTF16(kMimeTypePNG));
- *contains_filenames = false;
SelectionData data(x11_details_->RequestAndWaitForTypes(
buffer, x11_details_->GetAtomsForFormat(
diff --git a/chromium/ui/base/clipboard/clipboard_x11.h b/chromium/ui/base/clipboard/clipboard_x11.h
index d41a6a18891..68e87132d28 100644
--- a/chromium/ui/base/clipboard/clipboard_x11.h
+++ b/chromium/ui/base/clipboard/clipboard_x11.h
@@ -29,8 +29,7 @@ class ClipboardX11 : public Clipboard {
ClipboardBuffer buffer) const override;
void Clear(ClipboardBuffer buffer) override;
void ReadAvailableTypes(ClipboardBuffer buffer,
- std::vector<base::string16>* types,
- bool* contains_filenames) const override;
+ std::vector<base::string16>* types) const override;
std::vector<base::string16> ReadAvailablePlatformSpecificFormatNames(
ClipboardBuffer buffer) const override;
void ReadText(ClipboardBuffer buffer, base::string16* result) const override;
diff --git a/chromium/ui/base/clipboard/scoped_clipboard_writer.cc b/chromium/ui/base/clipboard/scoped_clipboard_writer.cc
index aea904e78ee..1b8312f5fc5 100644
--- a/chromium/ui/base/clipboard/scoped_clipboard_writer.cc
+++ b/chromium/ui/base/clipboard/scoped_clipboard_writer.cc
@@ -134,14 +134,6 @@ void ScopedClipboardWriter::WritePickledData(
void ScopedClipboardWriter::WriteData(const base::string16& format,
mojo_base::BigBuffer data) {
- // Conservative limit to maximum format and data string size, to avoid
- // potential attacks with long strings. Callers should implement similar
- // checks.
- constexpr size_t kMaxFormatSize = 1024;
- constexpr size_t kMaxDataSize = 1 << 30; // 1 GB
- DCHECK_LT(format.size(), kMaxFormatSize);
- DCHECK_LT(data.size(), kMaxDataSize);
-
platform_representations_.push_back(
{base::UTF16ToUTF8(format), std::move(data)});
}
diff --git a/chromium/ui/base/cocoa/command_dispatcher.mm b/chromium/ui/base/cocoa/command_dispatcher.mm
index 506ab361580..efe7a1862ce 100644
--- a/chromium/ui/base/cocoa/command_dispatcher.mm
+++ b/chromium/ui/base/cocoa/command_dispatcher.mm
@@ -5,7 +5,9 @@
#import "ui/base/cocoa/command_dispatcher.h"
#include "base/auto_reset.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
+#include "base/trace_event/trace_event.h"
#include "ui/base/cocoa/cocoa_base_utils.h"
#import "ui/base/cocoa/user_interface_item_command_handler.h"
@@ -21,44 +23,6 @@
- (NSWindow<CommandDispatchingWindow>*)bubbleParent;
@end
-namespace {
-
-// Duplicate the given key event, but changing the associated window.
-NSEvent* KeyEventForWindow(NSWindow* window, NSEvent* event) {
- NSEventType event_type = [event type];
-
- // Convert the event's location from the original window's coordinates into
- // our own.
- NSPoint location = [event locationInWindow];
- location = ui::ConvertPointFromWindowToScreen([event window], location);
- location = ui::ConvertPointFromScreenToWindow(window, location);
-
- // Various things *only* apply to key down/up.
- bool is_a_repeat = false;
- NSString* characters = nil;
- NSString* charactors_ignoring_modifiers = nil;
- if (event_type == NSKeyDown || event_type == NSKeyUp) {
- is_a_repeat = [event isARepeat];
- characters = [event characters];
- charactors_ignoring_modifiers = [event charactersIgnoringModifiers];
- }
-
- // This synthesis may be slightly imperfect: we provide nil for the context,
- // since I (viettrungluu) am sceptical that putting in the original context
- // (if one is given) is valid.
- return [NSEvent keyEventWithType:event_type
- location:location
- modifierFlags:[event modifierFlags]
- timestamp:[event timestamp]
- windowNumber:[window windowNumber]
- context:nil
- characters:characters
- charactersIgnoringModifiers:charactors_ignoring_modifiers
- isARepeat:is_a_repeat
- keyCode:[event keyCode]];
-}
-
-} // namespace
@implementation CommandDispatcher {
@private
@@ -94,6 +58,9 @@ NSEvent* KeyEventForWindow(NSWindow* window, NSEvent* event) {
// call, we rely on the fact that method calls to nil return nil, and that nil
// == ui::PerformKeyEquivalentResult::kUnhandled;
- (BOOL)performKeyEquivalent:(NSEvent*)event {
+ // TODO(bokan): Tracing added temporarily to diagnose crbug.com/1039833.
+ TRACE_EVENT2("ui", "CommandDispatcher::performKeyEquivalent", "window num",
+ [_owner windowNumber], "is keyWin", [NSApp keyWindow] == _owner);
DCHECK_EQ(NSKeyDown, [event type]);
// If the event is being redispatched, then this is the second time
@@ -107,10 +74,14 @@ NSEvent* KeyEventForWindow(NSWindow* window, NSEvent* event) {
// We skip all steps before postPerformKeyEquivalent, since those were already
// triggered on the first pass of the event.
if ([self isEventBeingRedispatched:event]) {
+ // TODO(bokan): Tracing added temporarily to diagnose crbug.com/1039833.
+ TRACE_EVENT_INSTANT0("ui", "IsRedispatch", TRACE_EVENT_SCOPE_THREAD);
ui::PerformKeyEquivalentResult result =
[_delegate postPerformKeyEquivalent:event
window:_owner
isRedispatch:YES];
+ TRACE_EVENT_INSTANT1("ui", "postPerformKeyEquivalent",
+ TRACE_EVENT_SCOPE_THREAD, "result", result);
if (result == ui::PerformKeyEquivalentResult::kHandled)
return YES;
if (result == ui::PerformKeyEquivalentResult::kPassToMainMenu)
@@ -183,6 +154,10 @@ NSEvent* KeyEventForWindow(NSWindow* window, NSEvent* event) {
}
- (BOOL)redispatchKeyEvent:(NSEvent*)event {
+ // TODO(bokan): Tracing added temporarily to diagnose crbug.com/1039833.
+ TRACE_EVENT2("ui", "CommandDispatcher::redispatchKeyEvent", "window num",
+ [_owner windowNumber], "event window num",
+ [[event window] windowNumber]);
DCHECK(!_isRedispatchingKeyEvent);
base::AutoReset<BOOL> resetter(&_isRedispatchingKeyEvent, YES);
@@ -194,14 +169,10 @@ NSEvent* KeyEventForWindow(NSWindow* window, NSEvent* event) {
return YES; // Pretend it's been handled in an effort to limit damage.
}
- // Ordinarily, the event's window should be |owner_|. However, when switching
- // between normal and fullscreen mode, we switch out the window, and the
- // event's window might be the previous window (or even an earlier one if the
- // renderer is running slowly and several mode switches occur). In this rare
- // case, we synthesize a new key event so that its associate window (number)
- // is our |owner_|'s.
- if ([event window] != _owner)
- event = KeyEventForWindow(_owner, event);
+ // TODO(lgrey): This is a temporary sanity check since the code that was
+ // here previously did *not* assume this. Remove shortly after this lands if
+ // nothing blew up.
+ DCHECK_EQ([event window], _owner);
// Redispatch the event.
_eventHandled = YES;
@@ -214,6 +185,11 @@ NSEvent* KeyEventForWindow(NSWindow* window, NSEvent* event) {
}
- (BOOL)preSendEvent:(NSEvent*)event {
+ // TODO(bokan): Tracing added temporarily to diagnose crbug.com/1039833.
+ TRACE_EVENT2("ui", "CommandDispatcher::preSendEvent", "window num",
+ [_owner windowNumber], "event window num",
+ [[event window] windowNumber]);
+
// AppKit does not call performKeyEquivalent: if the event only has the
// NSEventModifierFlagOption modifier. However, Chrome wants to treat these
// events just like keyEquivalents, since they can be consumed by extensions.
diff --git a/chromium/ui/base/cocoa/defaults_utils.mm b/chromium/ui/base/cocoa/defaults_utils.mm
index 822fe3b899b..f3017b0a0d1 100644
--- a/chromium/ui/base/cocoa/defaults_utils.mm
+++ b/chromium/ui/base/cocoa/defaults_utils.mm
@@ -4,7 +4,6 @@
#include <AppKit/AppKit.h>
-#include "base/logging.h"
#include "ui/base/cocoa/defaults_utils.h"
namespace ui {
diff --git a/chromium/ui/base/cocoa/find_pasteboard.mm b/chromium/ui/base/cocoa/find_pasteboard.mm
index a26f0b64d05..0968d213f09 100644
--- a/chromium/ui/base/cocoa/find_pasteboard.mm
+++ b/chromium/ui/base/cocoa/find_pasteboard.mm
@@ -4,7 +4,7 @@
#import "ui/base/cocoa/find_pasteboard.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "base/strings/sys_string_conversions.h"
NSString* kFindPasteboardChangedNotification =
diff --git a/chromium/ui/base/cocoa/menu_controller.mm b/chromium/ui/base/cocoa/menu_controller.mm
index d50bbf6caf4..df978482bd4 100644
--- a/chromium/ui/base/cocoa/menu_controller.mm
+++ b/chromium/ui/base/cocoa/menu_controller.mm
@@ -5,12 +5,13 @@
#import "ui/base/cocoa/menu_controller.h"
#include "base/bind.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/accelerators/platform_accelerator_cocoa.h"
#include "ui/base/l10n/l10n_util_mac.h"
+#include "ui/base/models/image_model.h"
#include "ui/base/models/simple_menu_model.h"
#import "ui/events/event_utils.h"
#include "ui/gfx/font_list.h"
@@ -191,9 +192,9 @@ bool MenuHasVisibleItems(const ui::MenuModel* model) {
keyEquivalent:@""]);
// If the menu item has an icon, set it.
- gfx::Image icon;
- if (model->GetIconAt(index, &icon) && !icon.IsEmpty())
- [item setImage:icon.ToNSImage()];
+ ui::ImageModel icon = model->GetIconAt(index);
+ if (icon.IsImage())
+ [item setImage:icon.GetImage().ToNSImage()];
ui::MenuModel::ItemType type = model->GetTypeAt(index);
if (type == ui::MenuModel::TYPE_SUBMENU && model->IsVisibleAt(index)) {
@@ -263,9 +264,8 @@ bool MenuHasVisibleItems(const ui::MenuModel* model) {
l10n_util::FixUpWindowsStyleLabel(model->GetLabelAt(modelIndex));
[(id)item setTitle:label];
- gfx::Image icon;
- model->GetIconAt(modelIndex, &icon);
- [(id)item setImage:icon.IsEmpty() ? nil : icon.ToNSImage()];
+ ui::ImageModel icon = model->GetIconAt(modelIndex);
+ [(id)item setImage:icon.IsImage() ? icon.GetImage().ToNSImage() : nil];
}
const gfx::FontList* font_list = model->GetLabelFontListAt(modelIndex);
if (font_list) {
diff --git a/chromium/ui/base/cocoa/menu_controller_unittest.mm b/chromium/ui/base/cocoa/menu_controller_unittest.mm
index 6578019ee22..19a7cecd832 100644
--- a/chromium/ui/base/cocoa/menu_controller_unittest.mm
+++ b/chromium/ui/base/cocoa/menu_controller_unittest.mm
@@ -12,6 +12,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#import "ui/base/cocoa/menu_controller.h"
#include "ui/base/l10n/l10n_util_mac.h"
+#include "ui/base/models/image_model.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/resource/resource_bundle.h"
#import "ui/base/test/cocoa_helper.h"
@@ -148,13 +149,9 @@ class DynamicDelegate : public Delegate {
base::string16 GetLabelForCommandId(int command_id) const override {
return label_;
}
- bool GetIconForCommandId(int command_id, gfx::Image* icon) const override {
- if (icon_.IsEmpty()) {
- return false;
- } else {
- *icon = icon_;
- return true;
- }
+ ui::ImageModel GetIconForCommandId(int command_id) const override {
+ return icon_.IsEmpty() ? ui::ImageModel()
+ : ui::ImageModel::FromImage(icon_);
}
void SetDynamicLabel(base::string16 label) { label_ = label; }
void SetDynamicIcon(const gfx::Image& icon) { icon_ = icon; }
diff --git a/chromium/ui/base/cocoa/permissions_utils.h b/chromium/ui/base/cocoa/permissions_utils.h
new file mode 100644
index 00000000000..14355053988
--- /dev/null
+++ b/chromium/ui/base/cocoa/permissions_utils.h
@@ -0,0 +1,21 @@
+// Copyright 2020 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 UI_BASE_COCOA_PERMISSIONS_UTILS_H_
+#define UI_BASE_COCOA_PERMISSIONS_UTILS_H_
+
+#include "ui/base/ui_base_export.h"
+
+namespace ui {
+
+// Heuristic to check screen capture permission.
+// Starting on macOS 10.15, the ability to screen capture is restricted and
+// requires a permission authorization. There is no direct way to query the
+// permission state, so this uses a heuristic to evaluate whether the permission
+// has been granted.
+UI_BASE_EXPORT bool IsScreenCaptureAllowed();
+
+} // namespace ui
+
+#endif // UI_BASE_COCOA_PERMISSIONS_UTILS_H_
diff --git a/chromium/ui/base/cocoa/permissions_utils.mm b/chromium/ui/base/cocoa/permissions_utils.mm
new file mode 100644
index 00000000000..ae34a26d827
--- /dev/null
+++ b/chromium/ui/base/cocoa/permissions_utils.mm
@@ -0,0 +1,52 @@
+// Copyright 2020 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 "ui/base/cocoa/permissions_utils.h"
+
+#include <CoreGraphics/CoreGraphics.h>
+#include <Foundation/Foundation.h>
+
+#include "base/mac/foundation_util.h"
+#include "base/mac/scoped_cftyperef.h"
+
+namespace ui {
+
+// Screen Capture is considered allowed if the name of at least one normal
+// or dock window running on another process is visible.
+// See https://crbug.com/993692.
+bool IsScreenCaptureAllowed() {
+ if (@available(macOS 10.15, *)) {
+ base::ScopedCFTypeRef<CFArrayRef> window_list(
+ CGWindowListCopyWindowInfo(kCGWindowListOptionAll, kCGNullWindowID));
+ int current_pid = [[NSProcessInfo processInfo] processIdentifier];
+ for (NSDictionary* window in base::mac::CFToNSCast(window_list.get())) {
+ NSNumber* window_pid =
+ [window objectForKey:base::mac::CFToNSCast(kCGWindowOwnerPID)];
+ if (!window_pid || [window_pid integerValue] == current_pid)
+ continue;
+
+ NSString* window_name =
+ [window objectForKey:base::mac::CFToNSCast(kCGWindowName)];
+ if (!window_name)
+ continue;
+
+ NSNumber* layer =
+ [window objectForKey:base::mac::CFToNSCast(kCGWindowLayer)];
+ if (!layer)
+ continue;
+
+ NSInteger layer_integer = [layer integerValue];
+ if (layer_integer == CGWindowLevelForKey(kCGNormalWindowLevelKey) ||
+ layer_integer == CGWindowLevelForKey(kCGDockWindowLevelKey)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ // Screen capture is always allowed in older macOS versions.
+ return true;
+}
+
+} // namespace ui
diff --git a/chromium/ui/base/cocoa/secure_password_input.mm b/chromium/ui/base/cocoa/secure_password_input.mm
index d0345336d4c..c9d003216ec 100644
--- a/chromium/ui/base/cocoa/secure_password_input.mm
+++ b/chromium/ui/base/cocoa/secure_password_input.mm
@@ -6,7 +6,7 @@
#import <Carbon/Carbon.h>
-#include "base/logging.h"
+#include "base/check_op.h"
namespace {
diff --git a/chromium/ui/base/cocoa/text_services_context_menu.cc b/chromium/ui/base/cocoa/text_services_context_menu.cc
index e4de9323daf..d149dd8df63 100644
--- a/chromium/ui/base/cocoa/text_services_context_menu.cc
+++ b/chromium/ui/base/cocoa/text_services_context_menu.cc
@@ -17,6 +17,22 @@
namespace {
+enum MenuCommands {
+ // These must not overlap with the command IDs used by other menus that
+ // incorporate text services.
+ // TODO(ellyjones): This is an ugly global dependency, especially on
+ // //ui/views. What can we do about this? Can we get rid of the global
+ // implicit namespace of command IDs?
+ kSpeechMenu = 100,
+ kSpeechStartSpeaking,
+ kSpeechStopSpeaking,
+
+ kWritingDirectionMenu,
+ kWritingDirectionDefault,
+ kWritingDirectionLtr,
+ kWritingDirectionRtl,
+};
+
// The speech channel used for speaking. This is shared to check if a speech
// channel is currently speaking.
SpeechChannel g_speech_channel;
@@ -25,11 +41,11 @@ SpeechChannel g_speech_channel;
// |command_id|.
base::i18n::TextDirection GetTextDirectionFromCommandId(int command_id) {
switch (command_id) {
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_DEFAULT:
+ case kWritingDirectionDefault:
return base::i18n::UNKNOWN_DIRECTION;
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_LTR:
+ case kWritingDirectionLtr:
return base::i18n::LEFT_TO_RIGHT;
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_RTL:
+ case kWritingDirectionRtl:
return base::i18n::RIGHT_TO_LEFT;
default:
NOTREACHED();
@@ -47,20 +63,17 @@ TextServicesContextMenu::TextServicesContextMenu(Delegate* delegate)
delegate_(delegate) {
DCHECK(delegate);
- speech_submenu_model_.AddItemWithStringId(IDS_SPEECH_START_SPEAKING_MAC,
+ speech_submenu_model_.AddItemWithStringId(kSpeechStartSpeaking,
IDS_SPEECH_START_SPEAKING_MAC);
- speech_submenu_model_.AddItemWithStringId(IDS_SPEECH_STOP_SPEAKING_MAC,
+ speech_submenu_model_.AddItemWithStringId(kSpeechStopSpeaking,
IDS_SPEECH_STOP_SPEAKING_MAC);
bidi_submenu_model_.AddCheckItemWithStringId(
- IDS_CONTENT_CONTEXT_WRITING_DIRECTION_DEFAULT,
- IDS_CONTENT_CONTEXT_WRITING_DIRECTION_DEFAULT);
+ kWritingDirectionDefault, IDS_CONTENT_CONTEXT_WRITING_DIRECTION_DEFAULT);
bidi_submenu_model_.AddCheckItemWithStringId(
- IDS_CONTENT_CONTEXT_WRITING_DIRECTION_LTR,
- IDS_CONTENT_CONTEXT_WRITING_DIRECTION_LTR);
+ kWritingDirectionLtr, IDS_CONTENT_CONTEXT_WRITING_DIRECTION_LTR);
bidi_submenu_model_.AddCheckItemWithStringId(
- IDS_CONTENT_CONTEXT_WRITING_DIRECTION_RTL,
- IDS_CONTENT_CONTEXT_WRITING_DIRECTION_RTL);
+ kWritingDirectionRtl, IDS_CONTENT_CONTEXT_WRITING_DIRECTION_RTL);
}
void TextServicesContextMenu::SpeakText(const base::string16& text) {
@@ -88,7 +101,7 @@ bool TextServicesContextMenu::IsSpeaking() {
void TextServicesContextMenu::AppendToContextMenu(SimpleMenuModel* model) {
model->AddSeparator(NORMAL_SEPARATOR);
- model->AddSubMenuWithStringId(IDS_SPEECH_MAC, IDS_SPEECH_MAC,
+ model->AddSubMenuWithStringId(kSpeechMenu, IDS_SPEECH_MAC,
&speech_submenu_model_);
}
@@ -96,20 +109,20 @@ void TextServicesContextMenu::AppendEditableItems(SimpleMenuModel* model) {
// MacOS provides a contextual menu to set writing direction for BiDi
// languages. This functionality is exposed as a keyboard shortcut on
// Windows and Linux.
- model->AddSubMenuWithStringId(IDS_CONTENT_CONTEXT_WRITING_DIRECTION_MENU,
+ model->AddSubMenuWithStringId(kWritingDirectionMenu,
IDS_CONTENT_CONTEXT_WRITING_DIRECTION_MENU,
&bidi_submenu_model_);
}
bool TextServicesContextMenu::SupportsCommand(int command_id) const {
switch (command_id) {
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_MENU:
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_DEFAULT:
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_LTR:
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_RTL:
- case IDS_SPEECH_MAC:
- case IDS_SPEECH_START_SPEAKING_MAC:
- case IDS_SPEECH_STOP_SPEAKING_MAC:
+ case kWritingDirectionMenu:
+ case kWritingDirectionDefault:
+ case kWritingDirectionLtr:
+ case kWritingDirectionRtl:
+ case kSpeechMenu:
+ case kSpeechStartSpeaking:
+ case kSpeechStopSpeaking:
return true;
}
@@ -118,13 +131,13 @@ bool TextServicesContextMenu::SupportsCommand(int command_id) const {
bool TextServicesContextMenu::IsCommandIdChecked(int command_id) const {
switch (command_id) {
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_DEFAULT:
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_LTR:
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_RTL:
+ case kWritingDirectionDefault:
+ case kWritingDirectionLtr:
+ case kWritingDirectionRtl:
return delegate_->IsTextDirectionChecked(
GetTextDirectionFromCommandId(command_id));
- case IDS_SPEECH_START_SPEAKING_MAC:
- case IDS_SPEECH_STOP_SPEAKING_MAC:
+ case kSpeechStartSpeaking:
+ case kSpeechStopSpeaking:
return false;
}
@@ -134,17 +147,17 @@ bool TextServicesContextMenu::IsCommandIdChecked(int command_id) const {
bool TextServicesContextMenu::IsCommandIdEnabled(int command_id) const {
switch (command_id) {
- case IDS_SPEECH_MAC:
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_MENU:
+ case kSpeechMenu:
+ case kWritingDirectionMenu:
return true;
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_DEFAULT:
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_LTR:
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_RTL:
+ case kWritingDirectionDefault:
+ case kWritingDirectionLtr:
+ case kWritingDirectionRtl:
return delegate_->IsTextDirectionEnabled(
GetTextDirectionFromCommandId(command_id));
- case IDS_SPEECH_START_SPEAKING_MAC:
+ case kSpeechStartSpeaking:
return true;
- case IDS_SPEECH_STOP_SPEAKING_MAC:
+ case kSpeechStopSpeaking:
return IsSpeaking();
}
@@ -154,15 +167,15 @@ bool TextServicesContextMenu::IsCommandIdEnabled(int command_id) const {
void TextServicesContextMenu::ExecuteCommand(int command_id, int event_flags) {
switch (command_id) {
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_DEFAULT:
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_LTR:
- case IDS_CONTENT_CONTEXT_WRITING_DIRECTION_RTL:
+ case kWritingDirectionDefault:
+ case kWritingDirectionLtr:
+ case kWritingDirectionRtl:
delegate_->UpdateTextDirection(GetTextDirectionFromCommandId(command_id));
break;
- case IDS_SPEECH_START_SPEAKING_MAC:
+ case kSpeechStartSpeaking:
SpeakText(delegate_->GetSelectedText());
break;
- case IDS_SPEECH_STOP_SPEAKING_MAC:
+ case kSpeechStopSpeaking:
StopSpeaking();
break;
default:
@@ -170,4 +183,4 @@ void TextServicesContextMenu::ExecuteCommand(int command_id, int event_flags) {
}
}
-} // namespace ui \ No newline at end of file
+} // namespace ui
diff --git a/chromium/ui/base/cocoa/tool_tip_base_view.mm b/chromium/ui/base/cocoa/tool_tip_base_view.mm
index aaa5dd85912..e03b2416dad 100644
--- a/chromium/ui/base/cocoa/tool_tip_base_view.mm
+++ b/chromium/ui/base/cocoa/tool_tip_base_view.mm
@@ -4,7 +4,8 @@
#import "ui/base/cocoa/tool_tip_base_view.h"
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
// Below is the nasty tooltip stuff -- copied from WebKit's WebHTMLView.mm
// with minor modifications for code style and commenting.
diff --git a/chromium/ui/base/cocoa/tracking_area.h b/chromium/ui/base/cocoa/tracking_area.h
index bc83d3f160a..4d7cd334e72 100644
--- a/chromium/ui/base/cocoa/tracking_area.h
+++ b/chromium/ui/base/cocoa/tracking_area.h
@@ -31,14 +31,6 @@ UI_BASE_EXPORT
// Prevents any future messages from being delivered to the |owner|.
- (void)clearOwner;
-// Watches |window| for its NSWindowWillCloseNotification and calls
-// |-clearOwner| when the notification is observed.
-- (void)clearOwnerWhenWindowWillClose:(NSWindow*)window;
-
-// Returns YES if the mouse is inside the tracking area's rect. |view| is the
-// NSView the tracking area is attached to.
-- (BOOL)mouseInsideTrackingAreaForView:(NSView*)view;
-
@end
// Scoper //////////////////////////////////////////////////////////////////////
diff --git a/chromium/ui/base/cocoa/tracking_area.mm b/chromium/ui/base/cocoa/tracking_area.mm
index 46489ee299f..7c28675da24 100644
--- a/chromium/ui/base/cocoa/tracking_area.mm
+++ b/chromium/ui/base/cocoa/tracking_area.mm
@@ -4,7 +4,7 @@
#import "ui/base/cocoa/tracking_area.h"
-#include "base/logging.h"
+#include "base/check.h"
// NSTrackingArea does not retain its |owner| so CrTrackingArea wraps the real
// owner in this proxy, which can stop forwarding messages to the owner when
@@ -92,26 +92,6 @@
[_ownerProxy setAlive:NO];
}
-- (void)clearOwnerWhenWindowWillClose:(NSWindow*)window {
- DCHECK(window);
- NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
- [center addObserver:self
- selector:@selector(windowWillClose:)
- name:NSWindowWillCloseNotification
- object:window];
-}
-
-- (BOOL)mouseInsideTrackingAreaForView:(NSView*)view {
- DCHECK(view);
- NSPoint mouseLoc = [[view window] mouseLocationOutsideOfEventStream];
- NSPoint mousePos = [view convertPoint:mouseLoc fromView:nil];
- return NSMouseInRect(mousePos, [self rect], [view isFlipped]);
-}
-
-- (void)windowWillClose:(NSNotification*)notif {
- [self clearOwner];
-}
-
@end
// Scoper //////////////////////////////////////////////////////////////////////
diff --git a/chromium/ui/base/cocoa/tracking_area_unittest.mm b/chromium/ui/base/cocoa/tracking_area_unittest.mm
index 274d3c765ee..7ee13930c67 100644
--- a/chromium/ui/base/cocoa/tracking_area_unittest.mm
+++ b/chromium/ui/base/cocoa/tracking_area_unittest.mm
@@ -57,19 +57,6 @@ TEST_F(CrTrackingAreaTest, OwnerStopsForwarding) {
EXPECT_EQ(1U, [owner_ messageCount]);
}
-TEST_F(CrTrackingAreaTest, OwnerAutomaticallyStopsForwardingOnClose) {
- [test_window() orderFront:nil];
- [trackingArea_ clearOwnerWhenWindowWillClose:test_window()];
-
- [[trackingArea_ owner] performMessage];
- EXPECT_EQ(1U, [owner_ messageCount]);
-
- [test_window() close];
-
- [[trackingArea_ owner] performMessage];
- EXPECT_EQ(1U, [owner_ messageCount]);
-}
-
TEST_F(CrTrackingAreaTest, ScoperInit) {
{
ScopedCrTrackingArea scoper([trackingArea_ retain]);
diff --git a/chromium/ui/base/cocoa/underlay_opengl_hosting_window.mm b/chromium/ui/base/cocoa/underlay_opengl_hosting_window.mm
index d9e592c47f4..7da7cbc28d5 100644
--- a/chromium/ui/base/cocoa/underlay_opengl_hosting_window.mm
+++ b/chromium/ui/base/cocoa/underlay_opengl_hosting_window.mm
@@ -4,7 +4,7 @@
#import "ui/base/cocoa/underlay_opengl_hosting_window.h"
-#include "base/logging.h"
+#include "base/check.h"
@implementation UnderlayOpenGLHostingWindow
diff --git a/chromium/ui/base/cursor/BUILD.gn b/chromium/ui/base/cursor/BUILD.gn
index ff2b371650e..e69e571c44b 100644
--- a/chromium/ui/base/cursor/BUILD.gn
+++ b/chromium/ui/base/cursor/BUILD.gn
@@ -18,7 +18,7 @@ component("cursor") {
public_deps = [
"//base",
"//skia",
- "//ui/base/mojom:cursor_type",
+ "//ui/base/cursor/mojom:cursor_type",
"//ui/gfx/geometry",
]
diff --git a/chromium/ui/base/cursor/cursor.cc b/chromium/ui/base/cursor/cursor.cc
index 99d485f8f20..6b19377f80c 100644
--- a/chromium/ui/base/cursor/cursor.cc
+++ b/chromium/ui/base/cursor/cursor.cc
@@ -4,7 +4,7 @@
#include "ui/base/cursor/cursor.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "ui/gfx/skia_util.h"
namespace ui {
diff --git a/chromium/ui/base/cursor/cursor.h b/chromium/ui/base/cursor/cursor.h
index 15bd7a90728..095798ce964 100644
--- a/chromium/ui/base/cursor/cursor.h
+++ b/chromium/ui/base/cursor/cursor.h
@@ -8,7 +8,7 @@
#include "base/component_export.h"
#include "build/build_config.h"
#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/gfx/geometry/point.h"
#if defined(OS_WIN)
diff --git a/chromium/ui/base/cursor/cursor_loader.h b/chromium/ui/base/cursor/cursor_loader.h
index f7e7ee2df26..95141089ffe 100644
--- a/chromium/ui/base/cursor/cursor_loader.h
+++ b/chromium/ui/base/cursor/cursor_loader.h
@@ -8,7 +8,7 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/strings/string16.h"
-#include "ui/base/mojom/cursor_type.mojom-forward.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-forward.h"
#include "ui/base/ui_base_export.h"
#include "ui/display/display.h"
#include "ui/gfx/geometry/point.h"
diff --git a/chromium/ui/base/cursor/cursor_loader_ozone.cc b/chromium/ui/base/cursor/cursor_loader_ozone.cc
index 461ebe93a44..8668095578e 100644
--- a/chromium/ui/base/cursor/cursor_loader_ozone.cc
+++ b/chromium/ui/base/cursor/cursor_loader_ozone.cc
@@ -8,7 +8,7 @@
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/cursor_util.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/ozone/public/cursor_factory_ozone.h"
namespace ui {
diff --git a/chromium/ui/base/cursor/cursor_loader_ozone.h b/chromium/ui/base/cursor/cursor_loader_ozone.h
index d966d9c78af..9d561727761 100644
--- a/chromium/ui/base/cursor/cursor_loader_ozone.h
+++ b/chromium/ui/base/cursor/cursor_loader_ozone.h
@@ -10,7 +10,7 @@
#include "base/macros.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/cursor_loader.h"
-#include "ui/base/mojom/cursor_type.mojom-forward.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-forward.h"
namespace ui {
diff --git a/chromium/ui/base/cursor/cursor_loader_win.cc b/chromium/ui/base/cursor/cursor_loader_win.cc
index 6a3ef621094..d981eb79cda 100644
--- a/chromium/ui/base/cursor/cursor_loader_win.cc
+++ b/chromium/ui/base/cursor/cursor_loader_win.cc
@@ -9,7 +9,7 @@
#include "base/lazy_instance.h"
#include "base/strings/string16.h"
#include "ui/base/cursor/cursor.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/resources/grit/ui_unscaled_resources.h"
namespace ui {
@@ -109,10 +109,9 @@ const wchar_t* GetCursorId(gfx::NativeCursor native_cursor) {
return MAKEINTRESOURCE(IDC_COPYCUR);
case mojom::CursorType::kAlias:
return MAKEINTRESOURCE(IDC_ALIAS);
- case mojom::CursorType::kNone:
- return MAKEINTRESOURCE(IDC_CURSOR_NONE);
case mojom::CursorType::kContextMenu:
case mojom::CursorType::kCustom:
+ case mojom::CursorType::kNone:
NOTIMPLEMENTED();
return IDC_ARROW;
default:
@@ -151,19 +150,28 @@ void CursorLoaderWin::UnloadAll() {
}
void CursorLoaderWin::SetPlatformCursor(gfx::NativeCursor* cursor) {
- if (cursor->type() != mojom::CursorType::kCustom) {
- if (cursor->platform()) {
- cursor->SetPlatformCursor(cursor->platform());
- } else {
- const wchar_t* cursor_id = GetCursorId(*cursor);
- PlatformCursor platform_cursor = LoadCursor(NULL, cursor_id);
- if (!platform_cursor && !g_cursor_resource_module_name.Get().empty()) {
- platform_cursor = LoadCursor(
- GetModuleHandle(g_cursor_resource_module_name.Get().c_str()),
- cursor_id);
- }
- cursor->SetPlatformCursor(platform_cursor);
+ if (cursor->type() == mojom::CursorType::kCustom)
+ return;
+
+ // Using a dark 1x1 bit bmp kNone cursor may still cause DWM to do composition
+ // work unnecessarily. Better to totally remove it from the screen.
+ // crbug.com/1069698
+ if (cursor->type() == mojom::CursorType::kNone) {
+ cursor->SetPlatformCursor(nullptr);
+ return;
+ }
+
+ if (cursor->platform()) {
+ cursor->SetPlatformCursor(cursor->platform());
+ } else {
+ const wchar_t* cursor_id = GetCursorId(*cursor);
+ PlatformCursor platform_cursor = LoadCursor(nullptr, cursor_id);
+ if (!platform_cursor && !g_cursor_resource_module_name.Get().empty()) {
+ platform_cursor = LoadCursor(
+ GetModuleHandle(g_cursor_resource_module_name.Get().c_str()),
+ cursor_id);
}
+ cursor->SetPlatformCursor(platform_cursor);
}
}
diff --git a/chromium/ui/base/cursor/cursor_loader_x11.cc b/chromium/ui/base/cursor/cursor_loader_x11.cc
index 741126dd59c..e0b52555d62 100644
--- a/chromium/ui/base/cursor/cursor_loader_x11.cc
+++ b/chromium/ui/base/cursor/cursor_loader_x11.cc
@@ -6,14 +6,15 @@
#include <float.h>
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "build/build_config.h"
#include "skia/ext/image_operations.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/cursor_size.h"
#include "ui/base/cursor/cursor_util.h"
#include "ui/base/cursor/cursors_aura.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/x/x11_util.h"
#include "ui/display/display.h"
#include "ui/gfx/geometry/point_conversions.h"
@@ -188,7 +189,7 @@ void CursorLoaderX11::LoadImageCursor(mojom::CursorType id,
gfx::Point hotspot = hot;
GetImageCursorBitmap(resource_id, scale(), rotation(), &hotspot, &bitmap);
- XcursorImage* x_image = SkBitmapToXcursorImage(&bitmap, hotspot);
+ XcursorImage* x_image = SkBitmapToXcursorImage(bitmap, hotspot);
image_cursors_[id] =
std::make_unique<ImageCursor>(x_image, scale(), rotation());
}
@@ -207,7 +208,7 @@ void CursorLoaderX11::LoadAnimatedCursor(mojom::CursorType id,
x_images->nimage = bitmaps.size();
for (unsigned int frame = 0; frame < bitmaps.size(); ++frame) {
- XcursorImage* x_image = SkBitmapToXcursorImage(&bitmaps[frame], hotspot);
+ XcursorImage* x_image = SkBitmapToXcursorImage(bitmaps[frame], hotspot);
x_image->delay = frame_delay_ms;
x_images->images[frame] = x_image;
}
diff --git a/chromium/ui/base/cursor/cursor_loader_x11.h b/chromium/ui/base/cursor/cursor_loader_x11.h
index 233ec5f9ceb..26870d09e03 100644
--- a/chromium/ui/base/cursor/cursor_loader_x11.h
+++ b/chromium/ui/base/cursor/cursor_loader_x11.h
@@ -14,7 +14,7 @@
#include "ui/base/cursor/cursor_loader.h"
#include "ui/base/cursor/cursor_theme_manager_linux.h"
#include "ui/base/cursor/cursor_theme_manager_linux_observer.h"
-#include "ui/base/mojom/cursor_type.mojom-forward.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-forward.h"
#include "ui/base/ui_base_export.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/x/x11.h"
diff --git a/chromium/ui/base/cursor/cursor_lookup.cc b/chromium/ui/base/cursor/cursor_lookup.cc
index e50a1805728..06214af4c25 100644
--- a/chromium/ui/base/cursor/cursor_lookup.cc
+++ b/chromium/ui/base/cursor/cursor_lookup.cc
@@ -6,7 +6,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/cursor/cursor.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/gfx/geometry/point.h"
#if defined(USE_AURA)
diff --git a/chromium/ui/base/cursor/cursor_unittest.cc b/chromium/ui/base/cursor/cursor_unittest.cc
index 6d08246652f..ef2d9e1e58f 100644
--- a/chromium/ui/base/cursor/cursor_unittest.cc
+++ b/chromium/ui/base/cursor/cursor_unittest.cc
@@ -6,11 +6,10 @@
#include <algorithm>
-#include "base/logging.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/cursor/cursor_lookup.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/gfx/skia_util.h"
namespace ui {
diff --git a/chromium/ui/base/cursor/cursor_util.cc b/chromium/ui/base/cursor/cursor_util.cc
index caca9287107..4af26e57833 100644
--- a/chromium/ui/base/cursor/cursor_util.cc
+++ b/chromium/ui/base/cursor/cursor_util.cc
@@ -4,7 +4,8 @@
#include "ui/base/cursor/cursor_util.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
diff --git a/chromium/ui/base/cursor/cursor_util_unittest.cc b/chromium/ui/base/cursor/cursor_util_unittest.cc
index 0d5ba8902b9..1e2d55f6385 100644
--- a/chromium/ui/base/cursor/cursor_util_unittest.cc
+++ b/chromium/ui/base/cursor/cursor_util_unittest.cc
@@ -4,7 +4,6 @@
#include "ui/base/cursor/cursor_util.h"
-#include "base/logging.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
diff --git a/chromium/ui/base/cursor/cursors_aura.cc b/chromium/ui/base/cursor/cursors_aura.cc
index f8fb8b653df..2a7ba7784c1 100644
--- a/chromium/ui/base/cursor/cursors_aura.cc
+++ b/chromium/ui/base/cursor/cursors_aura.cc
@@ -10,7 +10,7 @@
#include "build/build_config.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/cursor/cursor_size.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/image/image_skia.h"
@@ -312,48 +312,6 @@ const char* CursorCssNameFromId(mojom::CursorType id) {
return "grab";
case mojom::CursorType::kGrabbing:
return "grabbing";
-
-#if defined(OS_CHROMEOS)
- case mojom::CursorType::kNull:
- case mojom::CursorType::kPointer:
- case mojom::CursorType::kNoDrop:
- case mojom::CursorType::kNotAllowed:
- case mojom::CursorType::kCopy:
- case mojom::CursorType::kMove:
- case mojom::CursorType::kEastResize:
- case mojom::CursorType::kNorthResize:
- case mojom::CursorType::kSouthResize:
- case mojom::CursorType::kWestResize:
- case mojom::CursorType::kNorthEastResize:
- case mojom::CursorType::kNorthWestResize:
- case mojom::CursorType::kSouthWestResize:
- case mojom::CursorType::kSouthEastResize:
- case mojom::CursorType::kIBeam:
- case mojom::CursorType::kAlias:
- case mojom::CursorType::kCell:
- case mojom::CursorType::kContextMenu:
- case mojom::CursorType::kCross:
- case mojom::CursorType::kHelp:
- case mojom::CursorType::kWait:
- case mojom::CursorType::kNorthSouthResize:
- case mojom::CursorType::kEastWestResize:
- case mojom::CursorType::kNorthEastSouthWestResize:
- case mojom::CursorType::kNorthWestSouthEastResize:
- case mojom::CursorType::kProgress:
- case mojom::CursorType::kColumnResize:
- case mojom::CursorType::kRowResize:
- case mojom::CursorType::kVerticalText:
- case mojom::CursorType::kZoomIn:
- case mojom::CursorType::kZoomOut:
- case mojom::CursorType::kHand:
- case mojom::CursorType::kDndNone:
- case mojom::CursorType::kDndMove:
- case mojom::CursorType::kDndCopy:
- case mojom::CursorType::kDndLink:
- // In some environments, the image assets are not set (e.g. in
- // content-browsertests, content-shell etc.).
- return "left_ptr";
-#else // defined(OS_CHROMEOS)
case mojom::CursorType::kNull:
return "left_ptr";
case mojom::CursorType::kPointer:
@@ -430,7 +388,6 @@ const char* CursorCssNameFromId(mojom::CursorType id) {
return "dnd-copy";
case mojom::CursorType::kDndLink:
return "dnd-link";
-#endif // defined(OS_CHROMEOS)
case mojom::CursorType::kCustom:
NOTREACHED();
return "left_ptr";
diff --git a/chromium/ui/base/cursor/cursors_aura.h b/chromium/ui/base/cursor/cursors_aura.h
index d9cb356c0e7..778a5d3c871 100644
--- a/chromium/ui/base/cursor/cursors_aura.h
+++ b/chromium/ui/base/cursor/cursors_aura.h
@@ -6,7 +6,7 @@
#define UI_BASE_CURSOR_CURSORS_AURA_H_
#include "ui/base/cursor/cursor.h"
-#include "ui/base/mojom/cursor_type.mojom-forward.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-forward.h"
#include "ui/base/ui_base_export.h"
class SkBitmap;
diff --git a/chromium/ui/base/cursor/image_cursors.cc b/chromium/ui/base/cursor/image_cursors.cc
index 7ce69220935..4612bedb350 100644
--- a/chromium/ui/base/cursor/image_cursors.cc
+++ b/chromium/ui/base/cursor/image_cursors.cc
@@ -7,13 +7,14 @@
#include <float.h>
#include <stddef.h>
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
#include "base/strings/string16.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/cursor_loader.h"
#include "ui/base/cursor/cursors_aura.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/display/display.h"
#include "ui/gfx/geometry/point.h"
diff --git a/chromium/ui/base/cursor/mojom/BUILD.gn b/chromium/ui/base/cursor/mojom/BUILD.gn
new file mode 100644
index 00000000000..042d2160861
--- /dev/null
+++ b/chromium/ui/base/cursor/mojom/BUILD.gn
@@ -0,0 +1,63 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import("//mojo/public/tools/bindings/mojom.gni")
+
+mojom("mojom") {
+ generate_java = true
+ sources = [ "cursor.mojom" ]
+ public_deps = [
+ ":cursor_type",
+ "//skia/public/mojom",
+ "//ui/gfx/geometry/mojom",
+ ]
+ shared_cpp_typemap = {
+ types = [
+ {
+ mojom = "ui.mojom.Cursor"
+ cpp = "::ui::Cursor"
+ },
+ ]
+ traits_headers = [ "cursor_mojom_traits.h" ]
+ traits_public_deps = [ ":mojom_traits" ]
+ }
+ cpp_typemaps = [ shared_cpp_typemap ]
+ blink_cpp_typemaps = [ shared_cpp_typemap ]
+}
+
+source_set("mojom_traits") {
+ sources = [
+ "cursor_mojom_traits.cc",
+ "cursor_mojom_traits.h",
+ ]
+ public_deps = [
+ ":mojom_shared",
+ "//ui/base/cursor",
+ ]
+ deps = [
+ "//skia",
+ "//skia/public/mojom:shared_typemap_traits",
+ "//ui/gfx/geometry",
+ "//ui/gfx/geometry/mojom:mojom_traits",
+ ]
+}
+
+mojom("cursor_type") {
+ generate_java = true
+ sources = [ "cursor_type.mojom" ]
+}
+
+source_set("unittests") {
+ testonly = true
+ sources = [ "cursor_mojom_traits_unittest.cc" ]
+ deps = [
+ ":mojom",
+ ":mojom_traits",
+ "//testing/gtest",
+ "//ui/base",
+ "//ui/base/cursor",
+ "//ui/gfx:geometry_skia",
+ "//ui/gfx/geometry/mojom:mojom_traits",
+ ]
+}
diff --git a/chromium/ui/base/cursor/mojom/DEPS b/chromium/ui/base/cursor/mojom/DEPS
new file mode 100644
index 00000000000..36383c6d846
--- /dev/null
+++ b/chromium/ui/base/cursor/mojom/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+skia/public/mojom"
+]
diff --git a/chromium/ui/base/cursor/mojom/OWNERS b/chromium/ui/base/cursor/mojom/OWNERS
new file mode 100644
index 00000000000..1feb5149750
--- /dev/null
+++ b/chromium/ui/base/cursor/mojom/OWNERS
@@ -0,0 +1,4 @@
+per-file *.mojom=set noparent
+per-file *.mojom=file://ipc/SECURITY_OWNERS
+per-file *_mojom_traits*.*=set noparent
+per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
diff --git a/chromium/ui/base/mojom/cursor.mojom b/chromium/ui/base/cursor/mojom/cursor.mojom
index cdc49bf2e07..56230736c31 100644
--- a/chromium/ui/base/mojom/cursor.mojom
+++ b/chromium/ui/base/cursor/mojom/cursor.mojom
@@ -4,9 +4,8 @@
module ui.mojom;
-import "mojo/public/mojom/base/time.mojom";
import "skia/public/mojom/bitmap.mojom";
-import "ui/base/mojom/cursor_type.mojom";
+import "ui/base/cursor/mojom/cursor_type.mojom";
import "ui/gfx/geometry/mojom/geometry.mojom";
// A description of a cursor.
diff --git a/chromium/ui/base/mojom/cursor_mojom_traits.cc b/chromium/ui/base/cursor/mojom/cursor_mojom_traits.cc
index 85fdf48b097..99d06b6c2df 100644
--- a/chromium/ui/base/mojom/cursor_mojom_traits.cc
+++ b/chromium/ui/base/cursor/mojom/cursor_mojom_traits.cc
@@ -2,28 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/base/mojom/cursor_mojom_traits.h"
+#include "ui/base/cursor/mojom/cursor_mojom_traits.h"
#include "skia/public/mojom/bitmap_skbitmap_mojom_traits.h"
#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/base/mojom/cursor.mojom.h"
#include "ui/gfx/geometry/mojom/geometry_mojom_traits.h"
+#include "ui/gfx/geometry/point.h"
namespace mojo {
// static
-gfx::Point StructTraits<ui::mojom::CursorDataView, ui::Cursor>::hotspot(
- const ui::Cursor& c) {
- return c.custom_hotspot();
-}
-
-// static
-SkBitmap StructTraits<ui::mojom::CursorDataView, ui::Cursor>::bitmap(
- const ui::Cursor& c) {
- return c.custom_bitmap();
-}
-
-// static
bool StructTraits<ui::mojom::CursorDataView, ui::Cursor>::Read(
ui::mojom::CursorDataView data,
ui::Cursor* out) {
diff --git a/chromium/ui/base/mojom/cursor_mojom_traits.h b/chromium/ui/base/cursor/mojom/cursor_mojom_traits.h
index 26793316e74..4e39e4930f2 100644
--- a/chromium/ui/base/mojom/cursor_mojom_traits.h
+++ b/chromium/ui/base/cursor/mojom/cursor_mojom_traits.h
@@ -2,20 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_BASE_MOJOM_CURSOR_MOJOM_TRAITS_H_
-#define UI_BASE_MOJOM_CURSOR_MOJOM_TRAITS_H_
+#ifndef UI_BASE_CURSOR_MOJOM_CURSOR_MOJOM_TRAITS_H_
+#define UI_BASE_CURSOR_MOJOM_CURSOR_MOJOM_TRAITS_H_
#include "ui/base/cursor/cursor.h"
-#include "ui/base/mojom/cursor.mojom-shared.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
+
+class SkBitmap;
+
+namespace gfx {
+class Point;
+}
namespace mojo {
template <>
struct StructTraits<ui::mojom::CursorDataView, ui::Cursor> {
static ui::mojom::CursorType type(const ui::Cursor& c) { return c.type(); }
- static gfx::Point hotspot(const ui::Cursor& c);
- static SkBitmap bitmap(const ui::Cursor& c);
+ static gfx::Point hotspot(const ui::Cursor& c) { return c.custom_hotspot(); }
+ static SkBitmap bitmap(const ui::Cursor& c) { return c.custom_bitmap(); }
static float image_scale_factor(const ui::Cursor& c) {
return c.image_scale_factor();
}
@@ -24,4 +30,4 @@ struct StructTraits<ui::mojom::CursorDataView, ui::Cursor> {
} // namespace mojo
-#endif // UI_BASE_MOJOM_CURSOR_MOJOM_TRAITS_H_
+#endif // UI_BASE_CURSOR_MOJOM_CURSOR_MOJOM_TRAITS_H_
diff --git a/chromium/ui/base/mojom/cursor_mojom_traits_unittest.cc b/chromium/ui/base/cursor/mojom/cursor_mojom_traits_unittest.cc
index c63ad1d7de3..d3b1aee2f12 100644
--- a/chromium/ui/base/mojom/cursor_mojom_traits_unittest.cc
+++ b/chromium/ui/base/cursor/mojom/cursor_mojom_traits_unittest.cc
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/base/mojom/cursor_mojom_traits.h"
+#include "ui/base/cursor/mojom/cursor_mojom_traits.h"
#include "skia/public/mojom/bitmap_skbitmap_mojom_traits.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/cursor_lookup.h"
-#include "ui/base/mojom/cursor.mojom.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor.mojom.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/gfx/geometry/mojom/geometry_mojom_traits.h"
#include "ui/gfx/skia_util.h"
diff --git a/chromium/ui/base/mojom/cursor_type.mojom b/chromium/ui/base/cursor/mojom/cursor_type.mojom
index c3dd2db1b87..c3dd2db1b87 100644
--- a/chromium/ui/base/mojom/cursor_type.mojom
+++ b/chromium/ui/base/cursor/mojom/cursor_type.mojom
diff --git a/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc b/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc
index 682648d53d1..44037bc6142 100644
--- a/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc
+++ b/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.cc
@@ -6,11 +6,11 @@
#include <algorithm>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/cursor/cursor_lookup.h"
#include "ui/base/cursor/cursors_aura.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
namespace ui {
diff --git a/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h b/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h
index 1e062468f22..95ed10b051b 100644
--- a/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h
+++ b/chromium/ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h
@@ -11,7 +11,7 @@
#include "base/memory/ref_counted.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/cursor/cursor.h"
-#include "ui/base/mojom/cursor_type.mojom-forward.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-forward.h"
#include "ui/base/ui_base_export.h"
#include "ui/gfx/geometry/point.h"
#include "ui/ozone/public/cursor_factory_ozone.h"
diff --git a/chromium/ui/base/default_theme_provider.cc b/chromium/ui/base/default_theme_provider.cc
deleted file mode 100644
index a3eec4894ff..00000000000
--- a/chromium/ui/base/default_theme_provider.cc
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) 2012 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 "ui/base/default_theme_provider.h"
-
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/gfx/color_palette.h"
-#include "ui/gfx/color_utils.h"
-#include "ui/gfx/image/image_skia.h"
-
-namespace ui {
-
-DefaultThemeProvider::DefaultThemeProvider() {}
-
-DefaultThemeProvider::~DefaultThemeProvider() {}
-
-gfx::ImageSkia* DefaultThemeProvider::GetImageSkiaNamed(int id) const {
- return ResourceBundle::GetSharedInstance().GetImageSkiaNamed(id);
-}
-
-SkColor DefaultThemeProvider::GetColor(int id) const {
- return gfx::kPlaceholderColor;
-}
-
-color_utils::HSL DefaultThemeProvider::GetTint(int id) const {
- return color_utils::HSL();
-}
-
-int DefaultThemeProvider::GetDisplayProperty(int id) const {
- return -1;
-}
-
-bool DefaultThemeProvider::ShouldUseNativeFrame() const {
- return false;
-}
-
-bool DefaultThemeProvider::HasCustomImage(int id) const {
- return false;
-}
-
-bool DefaultThemeProvider::HasCustomColor(int id) const {
- return false;
-}
-
-base::RefCountedMemory* DefaultThemeProvider::GetRawData(
- int id,
- ui::ScaleFactor scale_factor) const {
- return NULL;
-}
-
-} // namespace ui
diff --git a/chromium/ui/base/default_theme_provider.h b/chromium/ui/base/default_theme_provider.h
deleted file mode 100644
index c5bf36835b6..00000000000
--- a/chromium/ui/base/default_theme_provider.h
+++ /dev/null
@@ -1,39 +0,0 @@
-// Copyright (c) 2012 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 UI_BASE_DEFAULT_THEME_PROVIDER_H_
-#define UI_BASE_DEFAULT_THEME_PROVIDER_H_
-
-#include <vector>
-
-#include "base/compiler_specific.h"
-#include "base/macros.h"
-#include "ui/base/theme_provider.h"
-#include "ui/base/ui_base_export.h"
-
-namespace ui {
-
-class UI_BASE_EXPORT DefaultThemeProvider : public ThemeProvider {
- public:
- DefaultThemeProvider();
- ~DefaultThemeProvider() override;
-
- // Overridden from ui::ThemeProvider:
- gfx::ImageSkia* GetImageSkiaNamed(int id) const override;
- SkColor GetColor(int id) const override;
- color_utils::HSL GetTint(int id) const override;
- int GetDisplayProperty(int id) const override;
- bool ShouldUseNativeFrame() const override;
- bool HasCustomImage(int id) const override;
- bool HasCustomColor(int id) const override;
- base::RefCountedMemory* GetRawData(int id, ui::ScaleFactor scale_factor)
- const override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DefaultThemeProvider);
-};
-
-} // namespace ui
-
-#endif // UI_BASE_DEFAULT_THEME_PROVIDER_H_
diff --git a/chromium/ui/base/dragdrop/DEPS b/chromium/ui/base/dragdrop/DEPS
index 0f8f3995e85..52815a10ba9 100644
--- a/chromium/ui/base/dragdrop/DEPS
+++ b/chromium/ui/base/dragdrop/DEPS
@@ -1,3 +1,4 @@
include_rules = [
+ "+ui/ozone/public/ozone_platform.h",
"+third_party/mozilla",
]
diff --git a/chromium/ui/base/dragdrop/cocoa_dnd_util.mm b/chromium/ui/base/dragdrop/cocoa_dnd_util.mm
index dcf71da4fe3..0913578fc12 100644
--- a/chromium/ui/base/dragdrop/cocoa_dnd_util.mm
+++ b/chromium/ui/base/dragdrop/cocoa_dnd_util.mm
@@ -4,7 +4,7 @@
#import "ui/base/dragdrop/cocoa_dnd_util.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/strings/sys_string_conversions.h"
#import "third_party/mozilla/NSPasteboard+Utils.h"
#include "url/gurl.h"
diff --git a/chromium/ui/base/dragdrop/download_file_info.cc b/chromium/ui/base/dragdrop/download_file_info.cc
new file mode 100644
index 00000000000..f22d2759c6f
--- /dev/null
+++ b/chromium/ui/base/dragdrop/download_file_info.cc
@@ -0,0 +1,18 @@
+// Copyright (c) 2020 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 "ui/base/dragdrop/download_file_info.h"
+
+#include <utility>
+
+namespace ui {
+
+DownloadFileInfo::DownloadFileInfo(
+ const base::FilePath& filename,
+ std::unique_ptr<DownloadFileProvider> downloader)
+ : filename(filename), downloader(std::move(downloader)) {}
+
+DownloadFileInfo::~DownloadFileInfo() = default;
+
+} // namespace ui
diff --git a/chromium/ui/base/dragdrop/download_file_info.h b/chromium/ui/base/dragdrop/download_file_info.h
new file mode 100644
index 00000000000..64cfbd4d8c4
--- /dev/null
+++ b/chromium/ui/base/dragdrop/download_file_info.h
@@ -0,0 +1,28 @@
+// Copyright 2020 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 UI_BASE_DRAGDROP_DOWNLOAD_FILE_INFO_H_
+#define UI_BASE_DRAGDROP_DOWNLOAD_FILE_INFO_H_
+
+#include <memory>
+
+#include "base/component_export.h"
+#include "base/files/file_path.h"
+#include "ui/base/dragdrop/download_file_interface.h"
+
+namespace ui {
+
+// Encapsulates the info about a file to be downloaded.
+struct COMPONENT_EXPORT(UI_BASE_DATA_EXCHANGE) DownloadFileInfo {
+ DownloadFileInfo(const base::FilePath& filename,
+ std::unique_ptr<DownloadFileProvider> downloader);
+ ~DownloadFileInfo();
+
+ base::FilePath filename;
+ std::unique_ptr<DownloadFileProvider> downloader;
+};
+
+} // namespace ui
+
+#endif // UI_BASE_DRAGDROP_DOWNLOAD_FILE_INFO_H_
diff --git a/chromium/ui/base/dragdrop/download_file_interface.h b/chromium/ui/base/dragdrop/download_file_interface.h
index 72e41ce4a40..b668b12d9e6 100644
--- a/chromium/ui/base/dragdrop/download_file_interface.h
+++ b/chromium/ui/base/dragdrop/download_file_interface.h
@@ -7,10 +7,9 @@
#include "build/build_config.h"
+#include "base/component_export.h"
#include "base/memory/ref_counted.h"
-#include "ui/base/ui_base_export.h"
-
#if defined(OS_WIN)
#include <objidl.h>
#endif
@@ -22,7 +21,7 @@ class FilePath;
namespace ui {
// Defines the interface to observe the status of file download.
-class UI_BASE_EXPORT DownloadFileObserver
+class COMPONENT_EXPORT(UI_BASE_DATA_EXCHANGE) DownloadFileObserver
: public base::RefCountedThreadSafe<DownloadFileObserver> {
public:
virtual void OnDownloadCompleted(const base::FilePath& file_path) = 0;
@@ -34,7 +33,7 @@ class UI_BASE_EXPORT DownloadFileObserver
};
// Defines the interface to control how a file is downloaded.
-class UI_BASE_EXPORT DownloadFileProvider {
+class COMPONENT_EXPORT(UI_BASE_DATA_EXCHANGE) DownloadFileProvider {
public:
virtual ~DownloadFileProvider() = default;
diff --git a/chromium/ui/base/dragdrop/drag_drop_types_mac.mm b/chromium/ui/base/dragdrop/drag_drop_types_mac.mm
index dd0226e29fc..9138df80034 100644
--- a/chromium/ui/base/dragdrop/drag_drop_types_mac.mm
+++ b/chromium/ui/base/dragdrop/drag_drop_types_mac.mm
@@ -8,7 +8,7 @@
namespace ui {
-uint64_t ui::DragDropTypes::DragOperationToNSDragOperation(int drag_operation) {
+uint64_t DragDropTypes::DragOperationToNSDragOperation(int drag_operation) {
NSUInteger ns_drag_operation = NSDragOperationNone;
if (drag_operation & DRAG_LINK)
@@ -21,8 +21,7 @@ uint64_t ui::DragDropTypes::DragOperationToNSDragOperation(int drag_operation) {
return ns_drag_operation;
}
-int ui::DragDropTypes::NSDragOperationToDragOperation(
- uint64_t ns_drag_operation) {
+int DragDropTypes::NSDragOperationToDragOperation(uint64_t ns_drag_operation) {
NSUInteger drag_operation = DRAG_NONE;
if (ns_drag_operation & NSDragOperationLink)
diff --git a/chromium/ui/base/dragdrop/drag_drop_types_win.cc b/chromium/ui/base/dragdrop/drag_drop_types_win.cc
index d189b82f5c3..b7ab5a0fc4b 100644
--- a/chromium/ui/base/dragdrop/drag_drop_types_win.cc
+++ b/chromium/ui/base/dragdrop/drag_drop_types_win.cc
@@ -9,7 +9,7 @@
namespace ui {
-int ui::DragDropTypes::DropEffectToDragOperation(uint32_t effect) {
+int DragDropTypes::DropEffectToDragOperation(uint32_t effect) {
int drag_operation = DRAG_NONE;
if (effect & DROPEFFECT_LINK)
drag_operation |= DRAG_LINK;
@@ -20,7 +20,7 @@ int ui::DragDropTypes::DropEffectToDragOperation(uint32_t effect) {
return drag_operation;
}
-uint32_t ui::DragDropTypes::DragOperationToDropEffect(int drag_operation) {
+uint32_t DragDropTypes::DragOperationToDropEffect(int drag_operation) {
uint32_t drop_effect = DROPEFFECT_NONE;
if (drag_operation & DRAG_LINK)
drop_effect |= DROPEFFECT_LINK;
diff --git a/chromium/ui/base/dragdrop/drag_source_win.cc b/chromium/ui/base/dragdrop/drag_source_win.cc
index a797a721a77..fe201a8d9c1 100644
--- a/chromium/ui/base/dragdrop/drag_source_win.cc
+++ b/chromium/ui/base/dragdrop/drag_source_win.cc
@@ -8,8 +8,8 @@
namespace ui {
-Microsoft::WRL::ComPtr<ui::DragSourceWin> DragSourceWin::Create() {
- return Microsoft::WRL::Make<ui::DragSourceWin>();
+Microsoft::WRL::ComPtr<DragSourceWin> DragSourceWin::Create() {
+ return Microsoft::WRL::Make<DragSourceWin>();
}
DragSourceWin::DragSourceWin() : cancel_drag_(false), data_(nullptr) {
@@ -39,8 +39,7 @@ HRESULT DragSourceWin::GiveFeedback(DWORD effect) {
void DragSourceWin::OnDragSourceDrop() {
DCHECK(data_);
- ui::OSExchangeDataProviderWin::GetDataObjectImpl(*data_)
- ->set_in_drag_loop(false);
+ OSExchangeDataProviderWin::GetDataObjectImpl(*data_)->set_in_drag_loop(false);
}
} // namespace ui
diff --git a/chromium/ui/base/dragdrop/drag_source_win.h b/chromium/ui/base/dragdrop/drag_source_win.h
index ecb129c7155..5634d7082c1 100644
--- a/chromium/ui/base/dragdrop/drag_source_win.h
+++ b/chromium/ui/base/dragdrop/drag_source_win.h
@@ -26,7 +26,7 @@ class DragSourceWin
IDropSource> {
public:
// Factory method to avoid exporting the class and all it derives from.
- static UI_BASE_EXPORT Microsoft::WRL::ComPtr<ui::DragSourceWin> Create();
+ static UI_BASE_EXPORT Microsoft::WRL::ComPtr<DragSourceWin> Create();
// Use Create() to construct these objects. Direct calls to the constructor
// are an error - it is only public because a WRL helper function creates the
diff --git a/chromium/ui/base/dragdrop/drop_target_win.cc b/chromium/ui/base/dragdrop/drop_target_win.cc
index 9b943290947..6b373a226ae 100644
--- a/chromium/ui/base/dragdrop/drop_target_win.cc
+++ b/chromium/ui/base/dragdrop/drop_target_win.cc
@@ -6,7 +6,7 @@
#include <shlobj.h>
-#include "base/logging.h"
+#include "base/check.h"
namespace ui {
diff --git a/chromium/ui/base/dragdrop/os_exchange_data.cc b/chromium/ui/base/dragdrop/os_exchange_data.cc
index 4af8c7b6fcd..727deb75a01 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data.cc
+++ b/chromium/ui/base/dragdrop/os_exchange_data.cc
@@ -9,27 +9,18 @@
#include "base/callback.h"
#include "base/pickle.h"
-#include "build/build_config.h"
#include "ui/base/clipboard/clipboard_format_type.h"
#include "ui/base/dragdrop/os_exchange_data_provider_factory.h"
#include "url/gurl.h"
namespace ui {
-OSExchangeData::DownloadFileInfo::DownloadFileInfo(
- const base::FilePath& filename,
- std::unique_ptr<DownloadFileProvider> downloader)
- : filename(filename), downloader(std::move(downloader)) {}
-
-OSExchangeData::DownloadFileInfo::~DownloadFileInfo() = default;
-
OSExchangeData::OSExchangeData()
: provider_(OSExchangeDataProviderFactory::CreateProvider()) {
}
-OSExchangeData::OSExchangeData(std::unique_ptr<Provider> provider)
- : provider_(std::move(provider)) {
-}
+OSExchangeData::OSExchangeData(std::unique_ptr<OSExchangeDataProvider> provider)
+ : provider_(std::move(provider)) {}
OSExchangeData::~OSExchangeData() {
}
diff --git a/chromium/ui/base/dragdrop/os_exchange_data.h b/chromium/ui/base/dragdrop/os_exchange_data.h
index 32518275943..58b160be349 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data.h
+++ b/chromium/ui/base/dragdrop/os_exchange_data.h
@@ -17,9 +17,10 @@
#include <objidl.h>
#endif
+#include "base/callback_forward.h"
#include "base/files/file_path.h"
#include "base/macros.h"
-#include "ui/base/dragdrop/download_file_interface.h"
+#include "ui/base/dragdrop/os_exchange_data_provider.h"
#include "ui/base/ui_base_export.h"
class GURL;
@@ -28,11 +29,6 @@ namespace base {
class Pickle;
}
-namespace gfx {
-class ImageSkia;
-class Vector2d;
-}
-
namespace ui {
class ClipboardFormatType;
@@ -68,100 +64,16 @@ class UI_BASE_EXPORT OSExchangeData {
#endif
};
- // Controls whether or not filenames should be converted to file: URLs when
- // getting a URL.
- enum FilenameToURLPolicy { CONVERT_FILENAMES, DO_NOT_CONVERT_FILENAMES, };
-
- // Encapsulates the info about a file to be downloaded.
- struct UI_BASE_EXPORT DownloadFileInfo {
- DownloadFileInfo(const base::FilePath& filename,
- std::unique_ptr<DownloadFileProvider> downloader);
- ~DownloadFileInfo();
-
- base::FilePath filename;
- std::unique_ptr<DownloadFileProvider> downloader;
- };
-
- // Provider defines the platform specific part of OSExchangeData that
- // interacts with the native system.
- class UI_BASE_EXPORT Provider {
- public:
- Provider() {}
- virtual ~Provider() {}
-
- virtual std::unique_ptr<Provider> Clone() const = 0;
-
- virtual void MarkOriginatedFromRenderer() = 0;
- virtual bool DidOriginateFromRenderer() const = 0;
-
- virtual void SetString(const base::string16& data) = 0;
- virtual void SetURL(const GURL& url, const base::string16& title) = 0;
- virtual void SetFilename(const base::FilePath& path) = 0;
- virtual void SetFilenames(const std::vector<FileInfo>& file_names) = 0;
- virtual void SetPickledData(const ClipboardFormatType& format,
- const base::Pickle& data) = 0;
-
- virtual bool GetString(base::string16* data) const = 0;
- virtual bool GetURLAndTitle(FilenameToURLPolicy policy,
- GURL* url,
- base::string16* title) const = 0;
- virtual bool GetFilename(base::FilePath* path) const = 0;
- virtual bool GetFilenames(std::vector<FileInfo>* file_names) const = 0;
- virtual bool GetPickledData(const ClipboardFormatType& format,
- base::Pickle* data) const = 0;
-
- virtual bool HasString() const = 0;
- virtual bool HasURL(FilenameToURLPolicy policy) const = 0;
- virtual bool HasFile() const = 0;
- virtual bool HasCustomFormat(const ClipboardFormatType& format) const = 0;
-
-#if defined(USE_X11) || defined(OS_WIN)
- virtual void SetFileContents(const base::FilePath& filename,
- const std::string& file_contents) = 0;
-#endif
-#if defined(OS_WIN)
- virtual bool GetFileContents(base::FilePath* filename,
- std::string* file_contents) const = 0;
- virtual bool HasFileContents() const = 0;
- virtual bool HasVirtualFilenames() const = 0;
- virtual bool GetVirtualFilenames(
- std::vector<FileInfo>* file_names) const = 0;
- virtual bool GetVirtualFilesAsTempFiles(
- base::OnceCallback<void(
- const std::vector<std::pair</*temp path*/ base::FilePath,
- /*display name*/ base::FilePath>>&)>
- callback) const = 0;
- virtual void SetVirtualFileContentsForTesting(
- const std::vector<std::pair<base::FilePath, std::string>>&
- filenames_and_contents,
- DWORD tymed) = 0;
- virtual void SetDownloadFileInfo(DownloadFileInfo* download) = 0;
-#endif
-
-#if defined(USE_AURA)
- virtual void SetHtml(const base::string16& html, const GURL& base_url) = 0;
- virtual bool GetHtml(base::string16* html, GURL* base_url) const = 0;
- virtual bool HasHtml() const = 0;
-#endif
-
-#if defined(USE_AURA) || defined(OS_MACOSX)
- virtual void SetDragImage(const gfx::ImageSkia& image,
- const gfx::Vector2d& cursor_offset) = 0;
- virtual gfx::ImageSkia GetDragImage() const = 0;
- virtual gfx::Vector2d GetDragImageOffset() const = 0;
-#endif
- };
-
OSExchangeData();
// Creates an OSExchangeData with the specified provider. OSExchangeData
// takes ownership of the supplied provider.
- explicit OSExchangeData(std::unique_ptr<Provider> provider);
+ explicit OSExchangeData(std::unique_ptr<OSExchangeDataProvider> provider);
~OSExchangeData();
// Returns the Provider, which actually stores and manages the data.
- const Provider& provider() const { return *provider_; }
- Provider& provider() { return *provider_; }
+ const OSExchangeDataProvider& provider() const { return *provider_; }
+ OSExchangeDataProvider& provider() { return *provider_; }
// Marks drag data as tainted if it originates from the renderer. This is used
// to avoid granting privileges to a renderer when dragging in tainted data,
@@ -279,7 +191,7 @@ class UI_BASE_EXPORT OSExchangeData {
private:
// Provides the actual data.
- std::unique_ptr<Provider> provider_;
+ std::unique_ptr<OSExchangeDataProvider> provider_;
DISALLOW_COPY_AND_ASSIGN(OSExchangeData);
};
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider.h b/chromium/ui/base/dragdrop/os_exchange_data_provider.h
new file mode 100644
index 00000000000..2e45ee878fb
--- /dev/null
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider.h
@@ -0,0 +1,113 @@
+// Copyright 2020 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 UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_H_
+#define UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_H_
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "build/build_config.h"
+
+#if defined(OS_WIN)
+#include <objidl.h>
+#endif
+
+#include "base/component_export.h"
+#include "base/files/file_path.h"
+#include "base/strings/string16.h"
+#include "ui/base/clipboard/clipboard_format_type.h"
+#include "ui/base/dragdrop/download_file_info.h"
+#include "ui/base/dragdrop/download_file_interface.h"
+#include "ui/base/dragdrop/file_info/file_info.h"
+#include "url/gurl.h"
+
+#if defined(USE_AURA) || defined(OS_MACOSX)
+#include "ui/gfx/geometry/vector2d.h"
+#include "ui/gfx/image/image_skia.h"
+#endif
+
+namespace ui {
+
+// Controls whether or not filenames should be converted to file: URLs when
+// getting a URL.
+// TODO(crbug.com/1070138): convert to enum class.
+enum FilenameToURLPolicy {
+ CONVERT_FILENAMES,
+ DO_NOT_CONVERT_FILENAMES,
+};
+
+// Provider defines the platform specific part of OSExchangeData that
+// interacts with the native system.
+class COMPONENT_EXPORT(UI_BASE_DATA_EXCHANGE) OSExchangeDataProvider {
+ public:
+ OSExchangeDataProvider() = default;
+ virtual ~OSExchangeDataProvider() = default;
+
+ virtual std::unique_ptr<OSExchangeDataProvider> Clone() const = 0;
+
+ virtual void MarkOriginatedFromRenderer() = 0;
+ virtual bool DidOriginateFromRenderer() const = 0;
+
+ virtual void SetString(const base::string16& data) = 0;
+ virtual void SetURL(const GURL& url, const base::string16& title) = 0;
+ virtual void SetFilename(const base::FilePath& path) = 0;
+ virtual void SetFilenames(const std::vector<FileInfo>& file_names) = 0;
+ virtual void SetPickledData(const ClipboardFormatType& format,
+ const base::Pickle& data) = 0;
+
+ virtual bool GetString(base::string16* data) const = 0;
+ virtual bool GetURLAndTitle(FilenameToURLPolicy policy,
+ GURL* url,
+ base::string16* title) const = 0;
+ virtual bool GetFilename(base::FilePath* path) const = 0;
+ virtual bool GetFilenames(std::vector<FileInfo>* file_names) const = 0;
+ virtual bool GetPickledData(const ClipboardFormatType& format,
+ base::Pickle* data) const = 0;
+
+ virtual bool HasString() const = 0;
+ virtual bool HasURL(FilenameToURLPolicy policy) const = 0;
+ virtual bool HasFile() const = 0;
+ virtual bool HasCustomFormat(const ClipboardFormatType& format) const = 0;
+
+#if defined(USE_X11) || defined(OS_WIN)
+ virtual void SetFileContents(const base::FilePath& filename,
+ const std::string& file_contents) = 0;
+#endif
+#if defined(OS_WIN)
+ virtual bool GetFileContents(base::FilePath* filename,
+ std::string* file_contents) const = 0;
+ virtual bool HasFileContents() const = 0;
+ virtual bool HasVirtualFilenames() const = 0;
+ virtual bool GetVirtualFilenames(std::vector<FileInfo>* file_names) const = 0;
+ virtual bool GetVirtualFilesAsTempFiles(
+ base::OnceCallback<
+ void(const std::vector<std::pair</*temp path*/ base::FilePath,
+ /*display name*/ base::FilePath>>&)>
+ callback) const = 0;
+ virtual void SetVirtualFileContentsForTesting(
+ const std::vector<std::pair<base::FilePath, std::string>>&
+ filenames_and_contents,
+ DWORD tymed) = 0;
+ virtual void SetDownloadFileInfo(DownloadFileInfo* download) = 0;
+#endif
+
+#if defined(USE_AURA)
+ virtual void SetHtml(const base::string16& html, const GURL& base_url) = 0;
+ virtual bool GetHtml(base::string16* html, GURL* base_url) const = 0;
+ virtual bool HasHtml() const = 0;
+#endif
+
+#if defined(USE_AURA) || defined(OS_MACOSX)
+ virtual void SetDragImage(const gfx::ImageSkia& image,
+ const gfx::Vector2d& cursor_offset) = 0;
+ virtual gfx::ImageSkia GetDragImage() const = 0;
+ virtual gfx::Vector2d GetDragImageOffset() const = 0;
+#endif
+};
+
+} // namespace ui
+
+#endif // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_H_
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_aura.cc b/chromium/ui/base/dragdrop/os_exchange_data_provider_aura.cc
index 3e35706f2a3..7131bc01992 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data_provider_aura.cc
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider_aura.cc
@@ -4,7 +4,7 @@
#include "ui/base/dragdrop/os_exchange_data_provider_aura.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
#include "net/base/filename_util.h"
@@ -19,8 +19,8 @@ OSExchangeDataProviderAura::OSExchangeDataProviderAura()
OSExchangeDataProviderAura::~OSExchangeDataProviderAura() = default;
-std::unique_ptr<OSExchangeData::Provider>
-OSExchangeDataProviderAura::Clone() const {
+std::unique_ptr<OSExchangeDataProvider> OSExchangeDataProviderAura::Clone()
+ const {
OSExchangeDataProviderAura* ret = new OSExchangeDataProviderAura();
ret->formats_ = formats_;
ret->string_ = string_;
@@ -32,7 +32,7 @@ OSExchangeDataProviderAura::Clone() const {
ret->html_ = html_;
ret->base_url_ = base_url_;
- return base::WrapUnique<OSExchangeData::Provider>(ret);
+ return base::WrapUnique<OSExchangeDataProvider>(ret);
}
void OSExchangeDataProviderAura::MarkOriginatedFromRenderer() {
@@ -87,14 +87,13 @@ bool OSExchangeDataProviderAura::GetString(base::string16* data) const {
return true;
}
-bool OSExchangeDataProviderAura::GetURLAndTitle(
- OSExchangeData::FilenameToURLPolicy policy,
- GURL* url,
- base::string16* title) const {
+bool OSExchangeDataProviderAura::GetURLAndTitle(FilenameToURLPolicy policy,
+ GURL* url,
+ base::string16* title) const {
if ((formats_ & OSExchangeData::URL) == 0) {
title->clear();
return GetPlainTextURL(url) ||
- (policy == OSExchangeData::CONVERT_FILENAMES && GetFileURL(url));
+ (policy == CONVERT_FILENAMES && GetFileURL(url));
}
if (!url_.is_valid())
@@ -136,14 +135,13 @@ bool OSExchangeDataProviderAura::HasString() const {
return (formats_ & OSExchangeData::STRING) != 0;
}
-bool OSExchangeDataProviderAura::HasURL(
- OSExchangeData::FilenameToURLPolicy policy) const {
+bool OSExchangeDataProviderAura::HasURL(FilenameToURLPolicy policy) const {
if ((formats_ & OSExchangeData::URL) != 0) {
return true;
}
// No URL, see if we have plain text that can be parsed as a URL.
return GetPlainTextURL(NULL) ||
- (policy == OSExchangeData::CONVERT_FILENAMES && GetFileURL(nullptr));
+ (policy == CONVERT_FILENAMES && GetFileURL(nullptr));
}
bool OSExchangeDataProviderAura::HasFile() const {
@@ -152,7 +150,7 @@ bool OSExchangeDataProviderAura::HasFile() const {
bool OSExchangeDataProviderAura::HasCustomFormat(
const ClipboardFormatType& format) const {
- return pickle_data_.find(format) != pickle_data_.end();
+ return base::Contains(pickle_data_, format);
}
void OSExchangeDataProviderAura::SetHtml(const base::string16& html,
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_aura.h b/chromium/ui/base/dragdrop/os_exchange_data_provider_aura.h
index bafab062a69..c535f08666a 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data_provider_aura.h
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider_aura.h
@@ -19,15 +19,15 @@ namespace ui {
class ClipboardFormatType;
-// OSExchangeData::Provider implementation for aura on linux.
+// OSExchangeDataProvider implementation for aura on linux.
class UI_BASE_EXPORT OSExchangeDataProviderAura
- : public OSExchangeData::Provider {
+ : public OSExchangeDataProvider {
public:
OSExchangeDataProviderAura();
~OSExchangeDataProviderAura() override;
- // Overridden from OSExchangeData::Provider:
- std::unique_ptr<Provider> Clone() const override;
+ // Overridden from OSExchangeDataProvider:
+ std::unique_ptr<OSExchangeDataProvider> Clone() const override;
void MarkOriginatedFromRenderer() override;
bool DidOriginateFromRenderer() const override;
void SetString(const base::string16& data) override;
@@ -37,7 +37,7 @@ class UI_BASE_EXPORT OSExchangeDataProviderAura
void SetPickledData(const ClipboardFormatType& format,
const base::Pickle& data) override;
bool GetString(base::string16* data) const override;
- bool GetURLAndTitle(OSExchangeData::FilenameToURLPolicy policy,
+ bool GetURLAndTitle(FilenameToURLPolicy policy,
GURL* url,
base::string16* title) const override;
bool GetFilename(base::FilePath* path) const override;
@@ -45,7 +45,7 @@ class UI_BASE_EXPORT OSExchangeDataProviderAura
bool GetPickledData(const ClipboardFormatType& format,
base::Pickle* data) const override;
bool HasString() const override;
- bool HasURL(OSExchangeData::FilenameToURLPolicy policy) const override;
+ bool HasURL(FilenameToURLPolicy policy) const override;
bool HasFile() const override;
bool HasCustomFormat(const ClipboardFormatType& format) const override;
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_aurax11.h b/chromium/ui/base/dragdrop/os_exchange_data_provider_aurax11.h
deleted file mode 100644
index 992165b49b0..00000000000
--- a/chromium/ui/base/dragdrop/os_exchange_data_provider_aurax11.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2012 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 UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_AURAX11_H_
-#define UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_AURAX11_H_
-
-#include "ui/base/x/x11_os_exchange_data_provider.h"
-#include "ui/events/platform/x11/x11_event_source.h"
-
-namespace ui {
-
-// OSExchangeData::Provider implementation for aura on linux.
-class UI_BASE_EXPORT OSExchangeDataProviderAuraX11
- : public XOSExchangeDataProvider,
- public XEventDispatcher {
- public:
- // |x_window| is the window the cursor is over, and |selection| is the set of
- // data being offered.
- OSExchangeDataProviderAuraX11(XID x_window,
- const SelectionFormatMap& selection);
-
- // Creates a Provider for sending drag information. This creates its own,
- // hidden X11 window to own send data.
- OSExchangeDataProviderAuraX11();
-
- ~OSExchangeDataProviderAuraX11() override;
-
- OSExchangeDataProviderAuraX11(const OSExchangeDataProviderAuraX11&) = delete;
- OSExchangeDataProviderAuraX11& operator=(
- const OSExchangeDataProviderAuraX11&) = delete;
-
- // OSExchangeData::Provider:
- std::unique_ptr<Provider> Clone() const override;
- void SetFileContents(const base::FilePath& filename,
- const std::string& file_contents) override;
-
- // XEventDispatcher:
- bool DispatchXEvent(XEvent* xev) override;
-
- private:
- friend class OSExchangeDataProviderAuraX11Test;
-};
-
-} // namespace ui
-
-#endif // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_AURAX11_H_
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_builder_mac.h b/chromium/ui/base/dragdrop/os_exchange_data_provider_builder_mac.h
index 14351be46b5..6e84814a5d8 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data_provider_builder_mac.h
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider_builder_mac.h
@@ -7,13 +7,13 @@
#include <memory>
-#include "ui/base/dragdrop/os_exchange_data.h"
+#include "ui/base/dragdrop/os_exchange_data_provider.h"
namespace ui {
// We can't include os_exchange_data_provider_mac.h from arbitrary C++ files
// because it depends on the Objective-C headers.
-std::unique_ptr<OSExchangeData::Provider> BuildOSExchangeDataProviderMac();
+std::unique_ptr<OSExchangeDataProvider> BuildOSExchangeDataProviderMac();
} // namespace ui
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_builder_mac.mm b/chromium/ui/base/dragdrop/os_exchange_data_provider_builder_mac.mm
index a115b31d15d..3aa0a666e16 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data_provider_builder_mac.mm
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider_builder_mac.mm
@@ -8,7 +8,7 @@
namespace ui {
-std::unique_ptr<OSExchangeData::Provider> BuildOSExchangeDataProviderMac() {
+std::unique_ptr<OSExchangeDataProvider> BuildOSExchangeDataProviderMac() {
return OSExchangeDataProviderMac::CreateProvider();
}
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_factory.cc b/chromium/ui/base/dragdrop/os_exchange_data_provider_factory.cc
index 4c5fbfbc079..52efa7c8e6a 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data_provider_factory.cc
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider_factory.cc
@@ -4,11 +4,15 @@
#include "ui/base/dragdrop/os_exchange_data_provider_factory.h"
+#include "base/notreached.h"
#include "build/build_config.h"
#if defined(USE_X11)
-#include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h"
+#include "ui/base/dragdrop/os_exchange_data_provider_x11.h"
#elif defined(OS_LINUX)
+#if defined(USE_OZONE)
+#include "ui/base/dragdrop/os_exchange_data_provider_factory_ozone.h"
+#endif
#include "ui/base/dragdrop/os_exchange_data_provider_aura.h"
#elif defined(OS_MACOSX)
#include "ui/base/dragdrop/os_exchange_data_provider_builder_mac.h"
@@ -19,14 +23,25 @@
namespace ui {
//static
-std::unique_ptr<OSExchangeData::Provider>
+std::unique_ptr<OSExchangeDataProvider>
OSExchangeDataProviderFactory::CreateProvider() {
#if defined(USE_X11)
- return std::make_unique<OSExchangeDataProviderAuraX11>();
+ return std::make_unique<OSExchangeDataProviderX11>();
#elif defined(OS_LINUX)
+#if defined(USE_OZONE)
+ // The instance can be nullptr in tests that do not instantiate the platform,
+ // or on platforms that do not implement specific drag'n'drop. For them,
+ // falling back to the Aura provider should be fine.
+ if (OSExchangeDataProviderFactoryOzone::Instance()) {
+ auto provider =
+ OSExchangeDataProviderFactoryOzone::Instance()->CreateProvider();
+ if (provider)
+ return provider;
+ }
+#endif
return std::make_unique<OSExchangeDataProviderAura>();
#elif defined(OS_MACOSX)
- return ui::BuildOSExchangeDataProviderMac();
+ return BuildOSExchangeDataProviderMac();
#elif defined(OS_WIN)
return std::make_unique<OSExchangeDataProviderWin>();
#elif defined(OS_FUCHSIA)
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_factory.h b/chromium/ui/base/dragdrop/os_exchange_data_provider_factory.h
index 626b7ea2f8c..b3fbd31a564 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data_provider_factory.h
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider_factory.h
@@ -7,7 +7,7 @@
#include <memory>
-#include "ui/base/dragdrop/os_exchange_data.h"
+#include "ui/base/dragdrop/os_exchange_data_provider.h"
#include "ui/base/ui_base_export.h"
namespace ui {
@@ -16,7 +16,7 @@ namespace ui {
class UI_BASE_EXPORT OSExchangeDataProviderFactory {
public:
// Creates a Provider based on the current platform.
- static std::unique_ptr<OSExchangeData::Provider> CreateProvider();
+ static std::unique_ptr<OSExchangeDataProvider> CreateProvider();
};
} // namespace ui
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_factory_ozone.cc b/chromium/ui/base/dragdrop/os_exchange_data_provider_factory_ozone.cc
new file mode 100644
index 00000000000..9c371c0a583
--- /dev/null
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider_factory_ozone.cc
@@ -0,0 +1,18 @@
+// Copyright 2020 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 "ui/base/dragdrop/os_exchange_data_provider_factory_ozone.h"
+
+namespace ui {
+
+OSExchangeDataProviderFactoryOzone*
+ OSExchangeDataProviderFactoryOzone::instance_ = nullptr;
+
+// static
+void OSExchangeDataProviderFactoryOzone::SetInstance(
+ OSExchangeDataProviderFactoryOzone* instance) {
+ instance_ = instance;
+}
+
+} // namespace ui
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_factory_ozone.h b/chromium/ui/base/dragdrop/os_exchange_data_provider_factory_ozone.h
new file mode 100644
index 00000000000..8d68410f3a7
--- /dev/null
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider_factory_ozone.h
@@ -0,0 +1,35 @@
+// Copyright 2020 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 UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_FACTORY_OZONE_H_
+#define UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_FACTORY_OZONE_H_
+
+#include <memory>
+
+#include "base/component_export.h"
+#include "ui/base/dragdrop/os_exchange_data_provider.h"
+
+namespace ui {
+
+// Builds platform specific OSExchangeDataProviders.
+class COMPONENT_EXPORT(UI_BASE_DATA_EXCHANGE)
+ OSExchangeDataProviderFactoryOzone {
+ public:
+ // Creates a Provider based on the current platform.
+ virtual std::unique_ptr<OSExchangeDataProvider> CreateProvider() = 0;
+
+ virtual ~OSExchangeDataProviderFactoryOzone() = default;
+
+ static OSExchangeDataProviderFactoryOzone* Instance() { return instance_; }
+
+ protected:
+ static void SetInstance(OSExchangeDataProviderFactoryOzone* instance);
+
+ private:
+ static OSExchangeDataProviderFactoryOzone* instance_;
+};
+
+} // namespace ui
+
+#endif // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_FACTORY_OZONE_H_
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_mac.h b/chromium/ui/base/dragdrop/os_exchange_data_provider_mac.h
index 0b61404342b..11465f8cc86 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data_provider_mac.h
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider_mac.h
@@ -12,6 +12,7 @@
#include "base/memory/ref_counted.h"
#import "ui/base/clipboard/clipboard_util_mac.h"
#include "ui/base/dragdrop/os_exchange_data.h"
+#include "ui/base/dragdrop/os_exchange_data_provider.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/image/image_skia.h"
@@ -23,9 +24,8 @@
namespace ui {
-// OSExchangeData::Provider implementation for Mac.
-class UI_BASE_EXPORT OSExchangeDataProviderMac
- : public OSExchangeData::Provider {
+// OSExchangeDataProvider implementation for Mac.
+class UI_BASE_EXPORT OSExchangeDataProviderMac : public OSExchangeDataProvider {
public:
~OSExchangeDataProviderMac() override;
@@ -37,7 +37,7 @@ class UI_BASE_EXPORT OSExchangeDataProviderMac
static std::unique_ptr<OSExchangeDataProviderMac>
CreateProviderWrappingPasteboard(NSPasteboard* pasteboard);
- // Overridden from OSExchangeData::Provider:
+ // Overridden from OSExchangeDataProvider:
void MarkOriginatedFromRenderer() override;
bool DidOriginateFromRenderer() const override;
void SetString(const base::string16& data) override;
@@ -47,7 +47,7 @@ class UI_BASE_EXPORT OSExchangeDataProviderMac
void SetPickledData(const ClipboardFormatType& format,
const base::Pickle& data) override;
bool GetString(base::string16* data) const override;
- bool GetURLAndTitle(OSExchangeData::FilenameToURLPolicy policy,
+ bool GetURLAndTitle(FilenameToURLPolicy policy,
GURL* url,
base::string16* title) const override;
bool GetFilename(base::FilePath* path) const override;
@@ -55,7 +55,7 @@ class UI_BASE_EXPORT OSExchangeDataProviderMac
bool GetPickledData(const ClipboardFormatType& format,
base::Pickle* data) const override;
bool HasString() const override;
- bool HasURL(OSExchangeData::FilenameToURLPolicy policy) const override;
+ bool HasURL(FilenameToURLPolicy policy) const override;
bool HasFile() const override;
bool HasCustomFormat(const ClipboardFormatType& format) const override;
void SetDragImage(const gfx::ImageSkia& image,
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_mac.mm b/chromium/ui/base/dragdrop/os_exchange_data_provider_mac.mm
index 9cbb7461fd5..4c7cbf41185 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data_provider_mac.mm
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider_mac.mm
@@ -6,8 +6,9 @@
#import <Cocoa/Cocoa.h>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/memory/ptr_util.h"
+#include "base/notreached.h"
#include "base/pickle.h"
#include "base/strings/sys_string_conversions.h"
#include "base/strings/utf_string_conversions.h"
@@ -79,11 +80,10 @@ namespace {
class OwningProvider : public OSExchangeDataProviderMac {
public:
OwningProvider()
- : OSExchangeDataProviderMac(),
- owned_pasteboard_(new ui::UniquePasteboard) {}
+ : OSExchangeDataProviderMac(), owned_pasteboard_(new UniquePasteboard) {}
OwningProvider(const OwningProvider& provider) = default;
- std::unique_ptr<OSExchangeData::Provider> Clone() const override {
+ std::unique_ptr<OSExchangeDataProvider> Clone() const override {
return std::make_unique<OwningProvider>(*this);
}
@@ -92,7 +92,7 @@ class OwningProvider : public OSExchangeDataProviderMac {
}
private:
- scoped_refptr<ui::UniquePasteboard> owned_pasteboard_;
+ scoped_refptr<UniquePasteboard> owned_pasteboard_;
};
class WrappingProvider : public OSExchangeDataProviderMac {
@@ -101,7 +101,7 @@ class WrappingProvider : public OSExchangeDataProviderMac {
: OSExchangeDataProviderMac(), wrapped_pasteboard_([pasteboard retain]) {}
WrappingProvider(const WrappingProvider& provider) = default;
- std::unique_ptr<OSExchangeData::Provider> Clone() const override {
+ std::unique_ptr<OSExchangeDataProvider> Clone() const override {
return std::make_unique<WrappingProvider>(*this);
}
@@ -153,7 +153,7 @@ void OSExchangeDataProviderMac::SetURL(const GURL& url,
base::scoped_nsobject<NSPasteboardItem> item =
ClipboardUtil::PasteboardItemFromUrl(base::SysUTF8ToNSString(url.spec()),
base::SysUTF16ToNSString(title));
- ui::ClipboardUtil::AddDataToPasteboard(GetPasteboard(), item);
+ ClipboardUtil::AddDataToPasteboard(GetPasteboard(), item);
}
void OSExchangeDataProviderMac::SetFilename(const base::FilePath& path) {
@@ -193,23 +193,20 @@ bool OSExchangeDataProviderMac::GetString(base::string16* data) const {
// There was no NSString, check for an NSURL.
GURL url;
base::string16 title;
- bool result =
- GetURLAndTitle(OSExchangeData::DO_NOT_CONVERT_FILENAMES, &url, &title);
+ bool result = GetURLAndTitle(DO_NOT_CONVERT_FILENAMES, &url, &title);
if (result)
*data = base::UTF8ToUTF16(url.spec());
return result;
}
-bool OSExchangeDataProviderMac::GetURLAndTitle(
- OSExchangeData::FilenameToURLPolicy policy,
- GURL* url,
- base::string16* title) const {
+bool OSExchangeDataProviderMac::GetURLAndTitle(FilenameToURLPolicy policy,
+ GURL* url,
+ base::string16* title) const {
DCHECK(url);
DCHECK(title);
- if (ui::PopulateURLAndTitleFromPasteboard(url, title, GetPasteboard(),
- false)) {
+ if (PopulateURLAndTitleFromPasteboard(url, title, GetPasteboard(), false)) {
return true;
}
@@ -221,8 +218,7 @@ bool OSExchangeDataProviderMac::GetURLAndTitle(
// the trailing slashes off of paths and always returns the last path element
// as the title whereas no path conversion nor title is wanted.
base::FilePath path;
- if (policy != OSExchangeData::DO_NOT_CONVERT_FILENAMES &&
- GetFilename(&path)) {
+ if (policy != DO_NOT_CONVERT_FILENAMES && GetFilename(&path)) {
NSURL* fileUrl =
[NSURL fileURLWithPath:base::SysUTF8ToNSString(path.value())];
*url =
@@ -273,8 +269,7 @@ bool OSExchangeDataProviderMac::HasString() const {
return GetString(&string);
}
-bool OSExchangeDataProviderMac::HasURL(
- OSExchangeData::FilenameToURLPolicy policy) const {
+bool OSExchangeDataProviderMac::HasURL(FilenameToURLPolicy policy) const {
GURL url;
base::string16 title;
return GetURLAndTitle(policy, &url, &title);
@@ -333,10 +328,10 @@ NSDraggingItem* OSExchangeDataProviderMac::GetDraggingItem() const {
// static
NSArray* OSExchangeDataProviderMac::SupportedPasteboardTypes() {
return @[
- kWebCustomDataPboardType, ui::ClipboardUtil::UTIForWebURLsAndTitles(),
- NSURLPboardType, NSFilenamesPboardType, ui::kChromeDragDummyPboardType,
+ kWebCustomDataPboardType, ClipboardUtil::UTIForWebURLsAndTitles(),
+ NSURLPboardType, NSFilenamesPboardType, kChromeDragDummyPboardType,
NSStringPboardType, NSHTMLPboardType, NSRTFPboardType,
- NSFilenamesPboardType, ui::kWebCustomDataPboardType, NSPasteboardTypeString
+ NSFilenamesPboardType, kWebCustomDataPboardType, NSPasteboardTypeString
];
}
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_win.cc b/chromium/ui/base/dragdrop/os_exchange_data_provider_win.cc
index c5183eaab99..9be3da2f9de 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data_provider_win.cc
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider_win.cc
@@ -16,11 +16,12 @@
#include <iterator>
#include "base/callback.h"
+#include "base/check_op.h"
#include "base/containers/span.h"
#include "base/files/file_path.h"
#include "base/i18n/file_util_icu.h"
-#include "base/logging.h"
#include "base/no_destructor.h"
+#include "base/notreached.h"
#include "base/pickle.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -44,7 +45,7 @@ namespace ui {
static const ClipboardFormatType& GetRendererTaintFormatType() {
static base::NoDestructor<ClipboardFormatType> format(
- ui::ClipboardFormatType::GetType("chromium/x-renderer-taint"));
+ ClipboardFormatType::GetType("chromium/x-renderer-taint"));
return *format;
}
@@ -292,8 +293,8 @@ OSExchangeDataProviderWin::OSExchangeDataProviderWin()
OSExchangeDataProviderWin::~OSExchangeDataProviderWin() {
}
-std::unique_ptr<OSExchangeData::Provider>
-OSExchangeDataProviderWin::Clone() const {
+std::unique_ptr<OSExchangeDataProvider> OSExchangeDataProviderWin::Clone()
+ const {
return std::make_unique<OSExchangeDataProviderWin>(data_object());
}
@@ -537,14 +538,13 @@ bool OSExchangeDataProviderWin::GetString(base::string16* data) const {
return ClipboardUtil::GetPlainText(source_object_.Get(), data);
}
-bool OSExchangeDataProviderWin::GetURLAndTitle(
- OSExchangeData::FilenameToURLPolicy policy,
- GURL* url,
- base::string16* title) const {
+bool OSExchangeDataProviderWin::GetURLAndTitle(FilenameToURLPolicy policy,
+ GURL* url,
+ base::string16* title) const {
base::string16 url_str;
- bool success = ClipboardUtil::GetUrl(
- source_object_.Get(), url, title,
- policy == OSExchangeData::CONVERT_FILENAMES ? true : false);
+ bool success =
+ ClipboardUtil::GetUrl(source_object_.Get(), url, title,
+ policy == CONVERT_FILENAMES ? true : false);
if (success) {
DCHECK(url->is_valid());
return true;
@@ -656,11 +656,9 @@ bool OSExchangeDataProviderWin::HasString() const {
return ClipboardUtil::HasPlainText(source_object_.Get());
}
-bool OSExchangeDataProviderWin::HasURL(
- OSExchangeData::FilenameToURLPolicy policy) const {
- return (ClipboardUtil::HasUrl(
- source_object_.Get(),
- policy == OSExchangeData::CONVERT_FILENAMES ? true : false) ||
+bool OSExchangeDataProviderWin::HasURL(FilenameToURLPolicy policy) const {
+ return (ClipboardUtil::HasUrl(source_object_.Get(),
+ policy == CONVERT_FILENAMES ? true : false) ||
HasPlainTextURL(source_object_.Get()));
}
@@ -683,7 +681,7 @@ bool OSExchangeDataProviderWin::HasCustomFormat(
}
void OSExchangeDataProviderWin::SetDownloadFileInfo(
- OSExchangeData::DownloadFileInfo* download) {
+ DownloadFileInfo* download) {
// If the filename is not provided, set storage to NULL to indicate that
// the delay rendering will be used.
// TODO(dcheng): Is it actually possible for filename to be empty here? I
@@ -753,7 +751,7 @@ void OSExchangeDataProviderWin::SetDragImage(
gfx::ImageSkia OSExchangeDataProviderWin::GetDragImage() const {
// This class sets the image on data_object() so it shouldn't be used in
// situations where the drag image is later queried. In that case a different
- // OSExchangeData::Provider should be used.
+ // OSExchangeDataProvider should be used.
NOTREACHED();
return gfx::ImageSkia();
}
@@ -761,7 +759,7 @@ gfx::ImageSkia OSExchangeDataProviderWin::GetDragImage() const {
gfx::Vector2d OSExchangeDataProviderWin::GetDragImageOffset() const {
// This class sets the image on data_object() so it shouldn't be used in
// situations where the drag image is later queried. In that case a different
- // OSExchangeData::Provider should be used.
+ // OSExchangeDataProvider should be used.
NOTREACHED();
return gfx::Vector2d();
}
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_win.h b/chromium/ui/base/dragdrop/os_exchange_data_provider_win.h
index 70fba4d7611..481e18f4ab2 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data_provider_win.h
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider_win.h
@@ -25,6 +25,7 @@
#include "base/macros.h"
#include "ui/base/dragdrop/os_exchange_data.h"
+#include "ui/base/dragdrop/os_exchange_data_provider.h"
#include "ui/base/ui_base_export.h"
#include "ui/gfx/geometry/vector2d.h"
#include "ui/gfx/image/image_skia.h"
@@ -114,8 +115,7 @@ class DataObjectImpl : public DownloadFileObserver,
bool async_operation_started_;
};
-class UI_BASE_EXPORT OSExchangeDataProviderWin
- : public OSExchangeData::Provider {
+class UI_BASE_EXPORT OSExchangeDataProviderWin : public OSExchangeDataProvider {
public:
// Returns true if source has plain text that is a valid url.
static bool HasPlainTextURL(IDataObject* source);
@@ -137,8 +137,8 @@ class UI_BASE_EXPORT OSExchangeDataProviderWin
IDataObject* data_object() const { return data_.get(); }
IDataObjectAsyncCapability* async_operation() const { return data_.get(); }
- // OSExchangeData::Provider methods.
- std::unique_ptr<Provider> Clone() const override;
+ // OSExchangeDataProvider methods.
+ std::unique_ptr<OSExchangeDataProvider> Clone() const override;
void MarkOriginatedFromRenderer() override;
bool DidOriginateFromRenderer() const override;
void SetString(const base::string16& data) override;
@@ -159,7 +159,7 @@ class UI_BASE_EXPORT OSExchangeDataProviderWin
void SetHtml(const base::string16& html, const GURL& base_url) override;
bool GetString(base::string16* data) const override;
- bool GetURLAndTitle(OSExchangeData::FilenameToURLPolicy policy,
+ bool GetURLAndTitle(FilenameToURLPolicy policy,
GURL* url,
base::string16* title) const override;
bool GetFilename(base::FilePath* path) const override;
@@ -176,13 +176,12 @@ class UI_BASE_EXPORT OSExchangeDataProviderWin
std::string* file_contents) const override;
bool GetHtml(base::string16* html, GURL* base_url) const override;
bool HasString() const override;
- bool HasURL(OSExchangeData::FilenameToURLPolicy policy) const override;
+ bool HasURL(FilenameToURLPolicy policy) const override;
bool HasFile() const override;
bool HasFileContents() const override;
bool HasHtml() const override;
bool HasCustomFormat(const ClipboardFormatType& format) const override;
- void SetDownloadFileInfo(
- OSExchangeData::DownloadFileInfo* download_info) override;
+ void SetDownloadFileInfo(DownloadFileInfo* download_info) override;
void SetDragImage(const gfx::ImageSkia& image_skia,
const gfx::Vector2d& cursor_offset) override;
gfx::ImageSkia GetDragImage() const override;
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc b/chromium/ui/base/dragdrop/os_exchange_data_provider_x11.cc
index 406921aa08a..f336655478b 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data_provider_aurax11.cc
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider_x11.cc
@@ -2,11 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h"
+#include "ui/base/dragdrop/os_exchange_data_provider_x11.h"
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/base/clipboard/clipboard_constants.h"
#include "ui/base/x/selection_utils.h"
#include "ui/events/platform/platform_event_source.h"
@@ -14,34 +14,33 @@
namespace ui {
-OSExchangeDataProviderAuraX11::OSExchangeDataProviderAuraX11(
+OSExchangeDataProviderX11::OSExchangeDataProviderX11(
XID x_window,
const SelectionFormatMap& selection)
: XOSExchangeDataProvider(x_window, selection) {}
-OSExchangeDataProviderAuraX11::OSExchangeDataProviderAuraX11() {
+OSExchangeDataProviderX11::OSExchangeDataProviderX11() {
X11EventSource::GetInstance()->AddXEventDispatcher(this);
}
-OSExchangeDataProviderAuraX11::~OSExchangeDataProviderAuraX11() {
+OSExchangeDataProviderX11::~OSExchangeDataProviderX11() {
if (own_window())
X11EventSource::GetInstance()->RemoveXEventDispatcher(this);
}
-std::unique_ptr<OSExchangeData::Provider>
-OSExchangeDataProviderAuraX11::Clone() const {
- std::unique_ptr<OSExchangeDataProviderAuraX11> ret(
- new OSExchangeDataProviderAuraX11());
+std::unique_ptr<OSExchangeDataProvider> OSExchangeDataProviderX11::Clone()
+ const {
+ std::unique_ptr<OSExchangeDataProviderX11> ret(
+ new OSExchangeDataProviderX11());
ret->set_format_map(format_map());
return std::move(ret);
}
-void OSExchangeDataProviderAuraX11::SetFileContents(
+void OSExchangeDataProviderX11::SetFileContents(
const base::FilePath& filename,
const std::string& file_contents) {
DCHECK(!filename.empty());
- DCHECK(format_map().end() ==
- format_map().find(gfx::GetAtom(kMimeTypeMozillaURL)));
+ DCHECK(!base::Contains(format_map(), gfx::GetAtom(kMimeTypeMozillaURL)));
set_file_contents_name(filename);
@@ -70,7 +69,7 @@ void OSExchangeDataProviderAuraX11::SetFileContents(
base::RefCountedString::TakeString(&file_contents_copy)));
}
-bool OSExchangeDataProviderAuraX11::DispatchXEvent(XEvent* xev) {
+bool OSExchangeDataProviderX11::DispatchXEvent(XEvent* xev) {
if (xev->type == SelectionRequest && xev->xany.window == x_window()) {
selection_owner().OnSelectionRequest(*xev);
return true;
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_x11.h b/chromium/ui/base/dragdrop/os_exchange_data_provider_x11.h
new file mode 100644
index 00000000000..980b384c3c5
--- /dev/null
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider_x11.h
@@ -0,0 +1,45 @@
+// Copyright (c) 2012 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 UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_X11_H_
+#define UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_X11_H_
+
+#include "ui/base/x/x11_os_exchange_data_provider.h"
+#include "ui/events/platform/x11/x11_event_source.h"
+
+namespace ui {
+
+// OSExchangeDataProvider implementation for x11 linux.
+class UI_BASE_EXPORT OSExchangeDataProviderX11 : public XOSExchangeDataProvider,
+ public XEventDispatcher {
+ public:
+ // |x_window| is the window the cursor is over, and |selection| is the set of
+ // data being offered.
+ OSExchangeDataProviderX11(XID x_window, const SelectionFormatMap& selection);
+
+ // Creates a Provider for sending drag information. This creates its own,
+ // hidden X11 window to own send data.
+ OSExchangeDataProviderX11();
+
+ ~OSExchangeDataProviderX11() override;
+
+ OSExchangeDataProviderX11(const OSExchangeDataProviderX11&) = delete;
+ OSExchangeDataProviderX11& operator=(const OSExchangeDataProviderX11&) =
+ delete;
+
+ // OSExchangeDataProvider:
+ std::unique_ptr<OSExchangeDataProvider> Clone() const override;
+ void SetFileContents(const base::FilePath& filename,
+ const std::string& file_contents) override;
+
+ // XEventDispatcher:
+ bool DispatchXEvent(XEvent* xev) override;
+
+ private:
+ friend class OSExchangeDataProviderX11Test;
+};
+
+} // namespace ui
+
+#endif // UI_BASE_DRAGDROP_OS_EXCHANGE_DATA_PROVIDER_X11_H_
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc b/chromium/ui/base/dragdrop/os_exchange_data_provider_x11_unittest.cc
index 1fa9fa1decf..82f9c71aabd 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data_provider_aurax11_unittest.cc
+++ b/chromium/ui/base/dragdrop/os_exchange_data_provider_x11_unittest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h"
+#include "ui/base/dragdrop/os_exchange_data_provider_x11.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
@@ -21,9 +21,9 @@ const char kGoogleURL[] = "http://www.google.com/";
namespace ui {
-class OSExchangeDataProviderAuraX11Test : public testing::Test {
+class OSExchangeDataProviderX11Test : public testing::Test {
public:
- OSExchangeDataProviderAuraX11Test()
+ OSExchangeDataProviderX11Test()
: task_environment_(base::test::TaskEnvironment::MainThreadType::UI),
event_source(gfx::GetXDisplay()) {}
@@ -32,23 +32,23 @@ class OSExchangeDataProviderAuraX11Test : public testing::Test {
scoped_refptr<base::RefCountedMemory> mem(
base::RefCountedString::TakeString(&contents_copy));
- provider.format_map_.Insert(gfx::GetAtom(ui::kMimeTypeURIList), mem);
+ provider.format_map_.Insert(gfx::GetAtom(kMimeTypeURIList), mem);
}
protected:
base::test::TaskEnvironment task_environment_;
X11EventSource event_source;
- ui::OSExchangeDataProviderAuraX11 provider;
+ OSExchangeDataProviderX11 provider;
};
-TEST_F(OSExchangeDataProviderAuraX11Test, MozillaURL) {
+TEST_F(OSExchangeDataProviderX11Test, MozillaURL) {
// Check that we can get titled entries.
provider.SetURL(GURL(kGoogleURL), base::ASCIIToUTF16(kGoogleTitle));
{
GURL out_gurl;
base::string16 out_str;
- EXPECT_TRUE(provider.GetURLAndTitle(
- OSExchangeData::DO_NOT_CONVERT_FILENAMES, &out_gurl, &out_str));
+ EXPECT_TRUE(
+ provider.GetURLAndTitle(DO_NOT_CONVERT_FILENAMES, &out_gurl, &out_str));
EXPECT_EQ(base::ASCIIToUTF16(kGoogleTitle), out_str);
EXPECT_EQ(kGoogleURL, out_gurl.spec());
}
@@ -58,35 +58,35 @@ TEST_F(OSExchangeDataProviderAuraX11Test, MozillaURL) {
{
GURL out_gurl;
base::string16 out_str;
- EXPECT_TRUE(provider.GetURLAndTitle(
- OSExchangeData::DO_NOT_CONVERT_FILENAMES, &out_gurl, &out_str));
+ EXPECT_TRUE(
+ provider.GetURLAndTitle(DO_NOT_CONVERT_FILENAMES, &out_gurl, &out_str));
EXPECT_EQ(base::string16(), out_str);
EXPECT_EQ(kGoogleURL, out_gurl.spec());
}
}
-TEST_F(OSExchangeDataProviderAuraX11Test, FilesArentURLs) {
+TEST_F(OSExchangeDataProviderX11Test, FilesArentURLs) {
AddURLList(kFileURL);
EXPECT_TRUE(provider.HasFile());
- EXPECT_TRUE(provider.HasURL(ui::OSExchangeData::CONVERT_FILENAMES));
- EXPECT_FALSE(provider.HasURL(ui::OSExchangeData::DO_NOT_CONVERT_FILENAMES));
+ EXPECT_TRUE(provider.HasURL(ui::CONVERT_FILENAMES));
+ EXPECT_FALSE(provider.HasURL(ui::DO_NOT_CONVERT_FILENAMES));
}
-TEST_F(OSExchangeDataProviderAuraX11Test, HTTPURLsArentFiles) {
+TEST_F(OSExchangeDataProviderX11Test, HTTPURLsArentFiles) {
AddURLList(kGoogleURL);
EXPECT_FALSE(provider.HasFile());
- EXPECT_TRUE(provider.HasURL(ui::OSExchangeData::CONVERT_FILENAMES));
- EXPECT_TRUE(provider.HasURL(ui::OSExchangeData::DO_NOT_CONVERT_FILENAMES));
+ EXPECT_TRUE(provider.HasURL(ui::CONVERT_FILENAMES));
+ EXPECT_TRUE(provider.HasURL(ui::DO_NOT_CONVERT_FILENAMES));
}
-TEST_F(OSExchangeDataProviderAuraX11Test, URIListWithBoth) {
+TEST_F(OSExchangeDataProviderX11Test, URIListWithBoth) {
AddURLList("file:///home/user/file.txt\nhttp://www.google.com");
EXPECT_TRUE(provider.HasFile());
- EXPECT_TRUE(provider.HasURL(ui::OSExchangeData::CONVERT_FILENAMES));
- EXPECT_TRUE(provider.HasURL(ui::OSExchangeData::DO_NOT_CONVERT_FILENAMES));
+ EXPECT_TRUE(provider.HasURL(ui::CONVERT_FILENAMES));
+ EXPECT_TRUE(provider.HasURL(ui::DO_NOT_CONVERT_FILENAMES));
// We should only receive the file from GetFilenames().
std::vector<FileInfo> filenames;
@@ -97,21 +97,21 @@ TEST_F(OSExchangeDataProviderAuraX11Test, URIListWithBoth) {
// We should only receive the URL here.
GURL out_gurl;
base::string16 out_str;
- EXPECT_TRUE(provider.GetURLAndTitle(
- OSExchangeData::DO_NOT_CONVERT_FILENAMES, &out_gurl, &out_str));
+ EXPECT_TRUE(
+ provider.GetURLAndTitle(DO_NOT_CONVERT_FILENAMES, &out_gurl, &out_str));
EXPECT_EQ(base::string16(), out_str);
EXPECT_EQ(kGoogleURL, out_gurl.spec());
}
-TEST_F(OSExchangeDataProviderAuraX11Test, OnlyStringURLIsUnfiltered) {
+TEST_F(OSExchangeDataProviderX11Test, OnlyStringURLIsUnfiltered) {
const base::string16 file_url = base::UTF8ToUTF16(kFileURL);
provider.SetString(file_url);
EXPECT_TRUE(provider.HasString());
- EXPECT_FALSE(provider.HasURL(ui::OSExchangeData::DO_NOT_CONVERT_FILENAMES));
+ EXPECT_FALSE(provider.HasURL(ui::DO_NOT_CONVERT_FILENAMES));
}
-TEST_F(OSExchangeDataProviderAuraX11Test, StringAndURIListFilterString) {
+TEST_F(OSExchangeDataProviderX11Test, StringAndURIListFilterString) {
const base::string16 file_url = base::UTF8ToUTF16(kFileURL);
provider.SetString(file_url);
AddURLList(kFileURL);
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_unittest.cc b/chromium/ui/base/dragdrop/os_exchange_data_unittest.cc
index 654ed1c76f6..3c000b0f0a7 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data_unittest.cc
+++ b/chromium/ui/base/dragdrop/os_exchange_data_unittest.cc
@@ -15,6 +15,7 @@
#include "ui/base/clipboard/clipboard_format_type.h"
#include "ui/base/dragdrop/file_info/file_info.h"
#include "ui/base/dragdrop/os_exchange_data.h"
+#include "ui/base/dragdrop/os_exchange_data_provider.h"
#include "ui/events/platform/platform_event_source.h"
#include "url/gurl.h"
@@ -39,7 +40,7 @@ TEST_F(OSExchangeDataTest, StringDataGetAndSet) {
EXPECT_TRUE(data.HasString());
OSExchangeData data2(
- std::unique_ptr<OSExchangeData::Provider>(data.provider().Clone()));
+ std::unique_ptr<OSExchangeDataProvider>(data.provider().Clone()));
base::string16 output;
EXPECT_TRUE(data2.HasString());
EXPECT_TRUE(data2.GetString(&output));
@@ -47,8 +48,7 @@ TEST_F(OSExchangeDataTest, StringDataGetAndSet) {
std::string url_spec = "http://www.goats.com/";
GURL url(url_spec);
base::string16 title;
- EXPECT_FALSE(data2.GetURLAndTitle(
- OSExchangeData::DO_NOT_CONVERT_FILENAMES, &url, &title));
+ EXPECT_FALSE(data2.GetURLAndTitle(DO_NOT_CONVERT_FILENAMES, &url, &title));
// No URLs in |data|, so url should be untouched.
EXPECT_EQ(url_spec, url.spec());
}
@@ -58,19 +58,19 @@ TEST_F(OSExchangeDataTest, TestURLExchangeFormats) {
std::string url_spec = "http://www.google.com/";
GURL url(url_spec);
base::string16 url_title = base::ASCIIToUTF16("www.google.com");
- EXPECT_FALSE(data.HasURL(OSExchangeData::DO_NOT_CONVERT_FILENAMES));
+ EXPECT_FALSE(data.HasURL(DO_NOT_CONVERT_FILENAMES));
data.SetURL(url, url_title);
- EXPECT_TRUE(data.HasURL(OSExchangeData::DO_NOT_CONVERT_FILENAMES));
+ EXPECT_TRUE(data.HasURL(DO_NOT_CONVERT_FILENAMES));
OSExchangeData data2(
- std::unique_ptr<OSExchangeData::Provider>(data.provider().Clone()));
+ std::unique_ptr<OSExchangeDataProvider>(data.provider().Clone()));
// URL spec and title should match
GURL output_url;
base::string16 output_title;
- EXPECT_TRUE(data2.HasURL(OSExchangeData::DO_NOT_CONVERT_FILENAMES));
- EXPECT_TRUE(data2.GetURLAndTitle(
- OSExchangeData::DO_NOT_CONVERT_FILENAMES, &output_url, &output_title));
+ EXPECT_TRUE(data2.HasURL(DO_NOT_CONVERT_FILENAMES));
+ EXPECT_TRUE(data2.GetURLAndTitle(DO_NOT_CONVERT_FILENAMES, &output_url,
+ &output_title));
EXPECT_EQ(url_spec, output_url.spec());
EXPECT_EQ(url_title, output_title);
base::string16 output_string;
@@ -96,16 +96,16 @@ TEST_F(OSExchangeDataTest, URLAndString) {
GURL output_url;
base::string16 output_title;
- EXPECT_TRUE(data.GetURLAndTitle(
- OSExchangeData::DO_NOT_CONVERT_FILENAMES, &output_url, &output_title));
+ EXPECT_TRUE(data.GetURLAndTitle(DO_NOT_CONVERT_FILENAMES, &output_url,
+ &output_title));
EXPECT_EQ(url_spec, output_url.spec());
EXPECT_EQ(url_title, output_title);
}
TEST_F(OSExchangeDataTest, TestFileToURLConversion) {
OSExchangeData data;
- EXPECT_FALSE(data.HasURL(OSExchangeData::DO_NOT_CONVERT_FILENAMES));
- EXPECT_FALSE(data.HasURL(OSExchangeData::CONVERT_FILENAMES));
+ EXPECT_FALSE(data.HasURL(DO_NOT_CONVERT_FILENAMES));
+ EXPECT_FALSE(data.HasURL(CONVERT_FILENAMES));
EXPECT_FALSE(data.HasFile());
base::FilePath current_directory;
@@ -114,21 +114,21 @@ TEST_F(OSExchangeDataTest, TestFileToURLConversion) {
data.SetFilename(current_directory);
{
- EXPECT_FALSE(data.HasURL(OSExchangeData::DO_NOT_CONVERT_FILENAMES));
+ EXPECT_FALSE(data.HasURL(DO_NOT_CONVERT_FILENAMES));
GURL actual_url;
base::string16 actual_title;
- EXPECT_FALSE(data.GetURLAndTitle(
- OSExchangeData::DO_NOT_CONVERT_FILENAMES, &actual_url, &actual_title));
+ EXPECT_FALSE(data.GetURLAndTitle(DO_NOT_CONVERT_FILENAMES, &actual_url,
+ &actual_title));
EXPECT_EQ(GURL(), actual_url);
EXPECT_EQ(base::string16(), actual_title);
}
{
- EXPECT_TRUE(data.HasURL(OSExchangeData::CONVERT_FILENAMES));
+ EXPECT_TRUE(data.HasURL(CONVERT_FILENAMES));
GURL actual_url;
base::string16 actual_title;
- EXPECT_TRUE(data.GetURLAndTitle(OSExchangeData::CONVERT_FILENAMES,
- &actual_url, &actual_title));
+ EXPECT_TRUE(
+ data.GetURLAndTitle(CONVERT_FILENAMES, &actual_url, &actual_title));
// Some Mac OS versions return the URL in file://localhost form instead
// of file:///, so we compare the url's path not its absolute string.
EXPECT_EQ(net::FilePathToFileURL(current_directory).path(),
@@ -142,8 +142,8 @@ TEST_F(OSExchangeDataTest, TestFileToURLConversion) {
}
TEST_F(OSExchangeDataTest, TestPickledData) {
- const ui::ClipboardFormatType kTestFormat =
- ui::ClipboardFormatType::GetType("application/vnd.chromium.test");
+ const ClipboardFormatType kTestFormat =
+ ClipboardFormatType::GetType("application/vnd.chromium.test");
base::Pickle saved_pickle;
saved_pickle.WriteInt(1);
@@ -152,7 +152,7 @@ TEST_F(OSExchangeDataTest, TestPickledData) {
data.SetPickledData(kTestFormat, saved_pickle);
OSExchangeData copy(
- std::unique_ptr<OSExchangeData::Provider>(data.provider().Clone()));
+ std::unique_ptr<OSExchangeDataProvider>(data.provider().Clone()));
EXPECT_TRUE(copy.HasCustomFormat(kTestFormat));
base::Pickle restored_pickle;
@@ -200,7 +200,7 @@ TEST_F(OSExchangeDataTest, TestHTML) {
data.SetHtml(html, url);
OSExchangeData copy(
- std::unique_ptr<OSExchangeData::Provider>(data.provider().Clone()));
+ std::unique_ptr<OSExchangeDataProvider>(data.provider().Clone()));
base::string16 read_html;
EXPECT_TRUE(copy.HasHtml());
EXPECT_TRUE(copy.GetHtml(&read_html, &url));
diff --git a/chromium/ui/base/dragdrop/os_exchange_data_win_unittest.cc b/chromium/ui/base/dragdrop/os_exchange_data_win_unittest.cc
index 8ba5221961f..750fd72ea75 100644
--- a/chromium/ui/base/dragdrop/os_exchange_data_win_unittest.cc
+++ b/chromium/ui/base/dragdrop/os_exchange_data_win_unittest.cc
@@ -100,11 +100,10 @@ TEST_F(OSExchangeDataWinTest, StringDataWritingViaCOM) {
// Construct a new object with the old object so that we can use our access
// APIs.
OSExchangeData data2(data.provider().Clone());
- EXPECT_TRUE(data2.HasURL(OSExchangeData::CONVERT_FILENAMES));
+ EXPECT_TRUE(data2.HasURL(CONVERT_FILENAMES));
GURL url_from_data;
std::wstring title;
- EXPECT_TRUE(data2.GetURLAndTitle(
- OSExchangeData::CONVERT_FILENAMES, &url_from_data, &title));
+ EXPECT_TRUE(data2.GetURLAndTitle(CONVERT_FILENAMES, &url_from_data, &title));
GURL reference_url(input);
EXPECT_EQ(reference_url.spec(), url_from_data.spec());
}
@@ -148,11 +147,10 @@ TEST_F(OSExchangeDataWinTest, RemoveData) {
// Construct a new object with the old object so that we can use our access
// APIs.
OSExchangeData data2(data.provider().Clone());
- EXPECT_TRUE(data2.HasURL(OSExchangeData::CONVERT_FILENAMES));
+ EXPECT_TRUE(data2.HasURL(CONVERT_FILENAMES));
GURL url_from_data;
std::wstring title;
- EXPECT_TRUE(data2.GetURLAndTitle(
- OSExchangeData::CONVERT_FILENAMES, &url_from_data, &title));
+ EXPECT_TRUE(data2.GetURLAndTitle(CONVERT_FILENAMES, &url_from_data, &title));
EXPECT_EQ(GURL(input2).spec(), url_from_data.spec());
}
@@ -406,8 +404,8 @@ TEST_F(OSExchangeDataWinTest, VirtualFiles) {
} else {
// IStorage uses compound files, so temp files won't be flat text files.
// Just make sure the original contents appears in the compound files.
- EXPECT_TRUE(read_contents.find(kTestFilenamesAndContents[i].second) !=
- std::string::npos);
+ EXPECT_TRUE(
+ base::Contains(read_contents, kTestFilenamesAndContents[i].second));
}
}
}
@@ -542,8 +540,8 @@ TEST_F(OSExchangeDataWinTest, VirtualFilesDuplicateNames) {
} else {
// IStorage uses compound files, so temp files won't be flat text files.
// Just make sure the original contents appears in the compound files.
- EXPECT_TRUE(read_contents.find(kTestFilenamesAndContents[i].second) !=
- std::string::npos);
+ EXPECT_TRUE(
+ base::Contains(read_contents, kTestFilenamesAndContents[i].second));
}
}
}
@@ -625,8 +623,8 @@ TEST_F(OSExchangeDataWinTest, VirtualFilesDuplicateNamesCaseInsensitivity) {
} else {
// IStorage uses compound files, so temp files won't be flat text files.
// Just make sure the original contents appears in the compound files.
- EXPECT_TRUE(read_contents.find(kTestFilenamesAndContents[i].second) !=
- std::string::npos);
+ EXPECT_TRUE(
+ base::Contains(read_contents, kTestFilenamesAndContents[i].second));
}
}
}
@@ -747,8 +745,8 @@ TEST_F(OSExchangeDataWinTest, VirtualFilesInvalidAndDuplicateNames) {
} else {
// IStorage uses compound files, so temp files won't be flat text files.
// Just make sure the original contents appears in the compound files.
- EXPECT_TRUE(read_contents.find(kTestFilenamesAndContents[i].second) !=
- std::string::npos);
+ EXPECT_TRUE(
+ base::Contains(read_contents, kTestFilenamesAndContents[i].second));
}
}
}
@@ -855,15 +853,14 @@ TEST_F(OSExchangeDataWinTest, ProvideURLForPlainTextURL) {
data.SetString(L"http://google.com");
OSExchangeData data2(data.provider().Clone());
- ASSERT_TRUE(data2.HasURL(OSExchangeData::CONVERT_FILENAMES));
+ ASSERT_TRUE(data2.HasURL(CONVERT_FILENAMES));
GURL read_url;
std::wstring title;
- EXPECT_TRUE(data2.GetURLAndTitle(
- OSExchangeData::CONVERT_FILENAMES, &read_url, &title));
+ EXPECT_TRUE(data2.GetURLAndTitle(CONVERT_FILENAMES, &read_url, &title));
EXPECT_EQ(GURL("http://google.com"), read_url);
}
-class MockDownloadFileProvider : public ui::DownloadFileProvider {
+class MockDownloadFileProvider : public DownloadFileProvider {
public:
MockDownloadFileProvider() = default;
~MockDownloadFileProvider() override = default;
@@ -890,7 +887,7 @@ TEST_F(OSExchangeDataWinTest, OnDownloadCompleted) {
auto download_file_provider = std::make_unique<MockDownloadFileProvider>();
auto weak_ptr = download_file_provider->GetWeakPtr();
- OSExchangeData::DownloadFileInfo file_info(
+ DownloadFileInfo file_info(
base::FilePath(FILE_PATH_LITERAL("file_with_no_contents.txt")),
std::move(download_file_provider));
provider.SetDownloadFileInfo(&file_info);
diff --git a/chromium/ui/base/emoji/emoji_panel_helper_chromeos.cc b/chromium/ui/base/emoji/emoji_panel_helper_chromeos.cc
index 9789028ee70..e3740dd1c96 100644
--- a/chromium/ui/base/emoji/emoji_panel_helper_chromeos.cc
+++ b/chromium/ui/base/emoji/emoji_panel_helper_chromeos.cc
@@ -4,7 +4,7 @@
#include "ui/base/emoji/emoji_panel_helper.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "base/no_destructor.h"
namespace ui {
diff --git a/chromium/ui/base/idle/BUILD.gn b/chromium/ui/base/idle/BUILD.gn
index 01551baa34f..9120a2df91e 100644
--- a/chromium/ui/base/idle/BUILD.gn
+++ b/chromium/ui/base/idle/BUILD.gn
@@ -61,10 +61,7 @@ component("idle") {
}
if (use_x11 && !is_chromeos) {
- configs += [
- "//build/config/linux:x11",
- "//build/config/linux:xscrnsaver",
- ]
+ configs += [ "//build/config/linux:xscrnsaver" ]
deps += [ "//ui/gfx/x" ]
sources += [
"idle_query_x11.cc",
diff --git a/chromium/ui/base/idle/idle_android.cc b/chromium/ui/base/idle/idle_android.cc
index fd366ac405e..4031c559698 100644
--- a/chromium/ui/base/idle/idle_android.cc
+++ b/chromium/ui/base/idle/idle_android.cc
@@ -6,8 +6,8 @@
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h"
-#include "base/logging.h"
#include "base/memory/singleton.h"
+#include "base/notreached.h"
#include "ui/base/idle/idle_internal.h"
#include "ui/base/ui_base_jni_headers/IdleDetector_jni.h"
diff --git a/chromium/ui/base/idle/idle_fuchsia.cc b/chromium/ui/base/idle/idle_fuchsia.cc
index 47c26ff7684..5af2356cbd2 100644
--- a/chromium/ui/base/idle/idle_fuchsia.cc
+++ b/chromium/ui/base/idle/idle_fuchsia.cc
@@ -4,7 +4,7 @@
#include "ui/base/idle/idle.h"
-#include "base/logging.h"
+#include "base/notreached.h"
namespace ui {
diff --git a/chromium/ui/base/idle/scoped_set_idle_state.h b/chromium/ui/base/idle/scoped_set_idle_state.h
index fa3e61786c5..7309095d37b 100644
--- a/chromium/ui/base/idle/scoped_set_idle_state.h
+++ b/chromium/ui/base/idle/scoped_set_idle_state.h
@@ -5,6 +5,7 @@
#ifndef UI_BASE_IDLE_SCOPED_SET_IDLE_STATE_H_
#define UI_BASE_IDLE_SCOPED_SET_IDLE_STATE_H_
+#include "base/macros.h"
#include "base/optional.h"
#include "ui/base/idle/idle.h"
diff --git a/chromium/ui/base/ime/BUILD.gn b/chromium/ui/base/ime/BUILD.gn
index 0c266ac86e3..2a0670796c0 100644
--- a/chromium/ui/base/ime/BUILD.gn
+++ b/chromium/ui/base/ime/BUILD.gn
@@ -57,12 +57,12 @@ jumbo_component("ime") {
sources = [
"constants.cc",
"constants.h",
+ "ime_assistive_window_handler_interface.h",
"ime_bridge.cc",
"ime_bridge.h",
"ime_candidate_window_handler_interface.h",
"ime_engine_handler_interface.h",
"ime_input_context_handler_interface.h",
- "ime_suggestion_window_handler_interface.h",
"input_method.h",
"input_method_base.cc",
"input_method_base.h",
@@ -81,6 +81,7 @@ jumbo_component("ime") {
"text_edit_commands.h",
"text_input_client.cc",
"text_input_client.h",
+ "virtual_keyboard_visibility_request.h",
]
defines = [ "IS_UI_BASE_IME_IMPL" ]
diff --git a/chromium/ui/base/ime/candidate_window.cc b/chromium/ui/base/ime/candidate_window.cc
index 30259f50b05..f37508298aa 100644
--- a/chromium/ui/base/ime/candidate_window.cc
+++ b/chromium/ui/base/ime/candidate_window.cc
@@ -7,7 +7,7 @@
#include <stddef.h>
#include <string>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
@@ -90,8 +90,9 @@ CandidateWindow::CandidateWindowProperty::CandidateWindowProperty()
is_cursor_visible(true),
is_vertical(false),
show_window_at_composition(false),
- is_auxiliary_text_visible(false) {
-}
+ is_auxiliary_text_visible(false),
+ current_candidate_index(-1),
+ total_candidates(0) {}
CandidateWindow::CandidateWindowProperty::~CandidateWindowProperty() {
}
diff --git a/chromium/ui/base/ime/candidate_window.h b/chromium/ui/base/ime/candidate_window.h
index 82c3fac288d..3299744aeab 100644
--- a/chromium/ui/base/ime/candidate_window.h
+++ b/chromium/ui/base/ime/candidate_window.h
@@ -38,6 +38,10 @@ class COMPONENT_EXPORT(UI_BASE_IME_TYPES) CandidateWindow {
// window.
std::string auxiliary_text;
bool is_auxiliary_text_visible;
+
+ // The index of the current chosen candidate out of total candidates
+ int current_candidate_index;
+ int total_candidates;
};
// Represents a candidate entry.
@@ -113,6 +117,12 @@ class COMPONENT_EXPORT(UI_BASE_IME_TYPES) CandidateWindow {
property_->auxiliary_text = auxiliary_text;
}
+ const int& current_candidate_index() const {
+ return property_->current_candidate_index;
+ }
+
+ const int& total_candidates() const { return property_->total_candidates; }
+
const std::vector<Entry>& candidates() const { return candidates_; }
std::vector<Entry>* mutable_candidates() { return &candidates_; }
diff --git a/chromium/ui/base/ime/candidate_window_unittest.cc b/chromium/ui/base/ime/candidate_window_unittest.cc
index f1568f97ac0..60498d4aedb 100644
--- a/chromium/ui/base/ime/candidate_window_unittest.cc
+++ b/chromium/ui/base/ime/candidate_window_unittest.cc
@@ -11,7 +11,6 @@
#include <string>
#include "base/compiler_specific.h"
-#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/chromium/ui/base/ime/character_composer.cc b/chromium/ui/base/ime/character_composer.cc
index d1ddcaa826a..ab03a0a7c6a 100644
--- a/chromium/ui/base/ime/character_composer.cc
+++ b/chromium/ui/base/ime/character_composer.cc
@@ -8,6 +8,8 @@
#include <iterator>
#include <string>
+#include "base/check.h"
+#include "base/notreached.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversion_utils.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chromium/ui/base/ime/ime_assistive_window_handler_interface.h b/chromium/ui/base/ime/ime_assistive_window_handler_interface.h
new file mode 100644
index 00000000000..8807731e9a0
--- /dev/null
+++ b/chromium/ui/base/ime/ime_assistive_window_handler_interface.h
@@ -0,0 +1,53 @@
+// Copyright 2020 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 UI_BASE_IME_IME_ASSISTIVE_WINDOW_HANDLER_INTERFACE_H_
+#define UI_BASE_IME_IME_ASSISTIVE_WINDOW_HANDLER_INTERFACE_H_
+
+#include <stdint.h>
+
+#include "base/component_export.h"
+#include "base/strings/string16.h"
+
+namespace gfx {
+class Rect;
+} // namespace gfx
+
+namespace chromeos {
+
+struct AssistiveWindowProperties;
+
+// A interface to handle the assistive windows related method call.
+class COMPONENT_EXPORT(UI_BASE_IME) IMEAssistiveWindowHandlerInterface {
+ public:
+ virtual ~IMEAssistiveWindowHandlerInterface() {}
+
+ // Called when showing/hiding assistive window.
+ virtual void SetAssistiveWindowProperties(
+ const AssistiveWindowProperties& window) {}
+
+ virtual void ShowSuggestion(const base::string16& text,
+ const size_t confirmed_length,
+ const bool show_tab) {}
+ virtual void HideSuggestion() {}
+
+ // Called to get the current suggestion text.
+ virtual base::string16 GetSuggestionText() const = 0;
+
+ // Called to get length of the confirmed part of suggestion text.
+ virtual size_t GetConfirmedLength() const = 0;
+
+ // Called when the application changes its caret bounds.
+ virtual void SetBounds(const gfx::Rect& cursor_bounds) = 0;
+
+ // Called when the text field's focus state is changed.
+ virtual void FocusStateChanged() {}
+
+ protected:
+ IMEAssistiveWindowHandlerInterface() {}
+};
+
+} // namespace chromeos
+
+#endif // UI_BASE_IME_IME_ASSISTIVE_WINDOW_HANDLER_INTERFACE_H_
diff --git a/chromium/ui/base/ime/ime_bridge.cc b/chromium/ui/base/ime/ime_bridge.cc
index ff810817f26..5e44712f9a0 100644
--- a/chromium/ui/base/ime/ime_bridge.cc
+++ b/chromium/ui/base/ime/ime_bridge.cc
@@ -6,7 +6,6 @@
#include <map>
-#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/singleton.h"
#include "base/observer_list.h"
@@ -93,15 +92,15 @@ class IMEBridgeImpl : public IMEBridge {
}
// IMEBridge override.
- void SetSuggestionWindowHandler(
- chromeos::IMESuggestionWindowHandlerInterface* handler) override {
- suggestion_window_handler_ = handler;
+ void SetAssistiveWindowHandler(
+ chromeos::IMEAssistiveWindowHandlerInterface* handler) override {
+ assistive_window_handler_ = handler;
}
// IMEBridge override.
- chromeos::IMESuggestionWindowHandlerInterface* GetSuggestionWindowHandler()
+ chromeos::IMEAssistiveWindowHandlerInterface* GetAssistiveWindowHandler()
const override {
- return suggestion_window_handler_;
+ return assistive_window_handler_;
}
#endif
@@ -114,7 +113,7 @@ class IMEBridgeImpl : public IMEBridge {
#if defined(OS_CHROMEOS)
chromeos::IMECandidateWindowHandlerInterface* candidate_window_handler_ =
nullptr;
- chromeos::IMESuggestionWindowHandlerInterface* suggestion_window_handler_ =
+ chromeos::IMEAssistiveWindowHandlerInterface* assistive_window_handler_ =
nullptr;
#endif
diff --git a/chromium/ui/base/ime/ime_bridge.h b/chromium/ui/base/ime/ime_bridge.h
index fe4b0d16c83..9fade0b1944 100644
--- a/chromium/ui/base/ime/ime_bridge.h
+++ b/chromium/ui/base/ime/ime_bridge.h
@@ -13,12 +13,12 @@
#include "ui/base/ime/ime_input_context_handler_interface.h"
#if defined(OS_CHROMEOS)
+#include "ui/base/ime/ime_assistive_window_handler_interface.h"
#include "ui/base/ime/ime_candidate_window_handler_interface.h"
-#include "ui/base/ime/ime_suggestion_window_handler_interface.h"
namespace chromeos {
class IMECandidateWindowHandlerInterface;
-class IMESuggestionWindowHandlerInterface;
+class IMEAssistiveWindowHandlerInterface;
}
#endif
@@ -84,10 +84,10 @@ class COMPONENT_EXPORT(UI_BASE_IME) IMEBridge {
virtual void SetCandidateWindowHandler(
chromeos::IMECandidateWindowHandlerInterface* handler) = 0;
- virtual chromeos::IMESuggestionWindowHandlerInterface*
- GetSuggestionWindowHandler() const = 0;
- virtual void SetSuggestionWindowHandler(
- chromeos::IMESuggestionWindowHandlerInterface* handler) = 0;
+ virtual chromeos::IMEAssistiveWindowHandlerInterface*
+ GetAssistiveWindowHandler() const = 0;
+ virtual void SetAssistiveWindowHandler(
+ chromeos::IMEAssistiveWindowHandlerInterface* handler) = 0;
#endif
protected:
diff --git a/chromium/ui/base/ime/ime_suggestion_window_handler_interface.h b/chromium/ui/base/ime/ime_suggestion_window_handler_interface.h
deleted file mode 100644
index ab0f6b53aef..00000000000
--- a/chromium/ui/base/ime/ime_suggestion_window_handler_interface.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2020 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 UI_BASE_IME_IME_SUGGESTION_WINDOW_HANDLER_INTERFACE_H_
-#define UI_BASE_IME_IME_SUGGESTION_WINDOW_HANDLER_INTERFACE_H_
-
-#include <stdint.h>
-
-#include "base/component_export.h"
-#include "base/strings/string16.h"
-
-namespace gfx {
-class Rect;
-} // namespace gfx
-
-namespace chromeos {
-
-// A interface to handle the suggestion window related method call.
-class COMPONENT_EXPORT(UI_BASE_IME) IMESuggestionWindowHandlerInterface {
- public:
- virtual ~IMESuggestionWindowHandlerInterface() {}
-
- // Called when showing/hiding suggestion window.
- virtual void Show(const base::string16& text) {}
- virtual void Hide() {}
-
- // Called to get the current suggestion text.
- virtual base::string16 GetText() const = 0;
-
- // Called when the application changes its caret bounds.
- virtual void SetBounds(const gfx::Rect& cursor_bounds) = 0;
-
- // Called when the text field's focus state is changed.
- virtual void FocusStateChanged() {}
-
- protected:
- IMESuggestionWindowHandlerInterface() {}
-};
-
-} // namespace chromeos
-
-#endif // UI_BASE_IME_IME_SUGGESTION_WINDOW_HANDLER_INTERFACE_H_
diff --git a/chromium/ui/base/ime/init/input_method_factory.h b/chromium/ui/base/ime/init/input_method_factory.h
index d2d933ace97..80666d6494a 100644
--- a/chromium/ui/base/ime/init/input_method_factory.h
+++ b/chromium/ui/base/ime/init/input_method_factory.h
@@ -9,6 +9,7 @@
#include "base/compiler_specific.h"
#include "base/component_export.h"
+#include "base/macros.h"
#include "ui/base/ime/init/input_method_initializer.h"
#include "ui/gfx/native_widget_types.h"
diff --git a/chromium/ui/base/ime/init/input_method_initializer.cc b/chromium/ui/base/ime/init/input_method_initializer.cc
index e903d1beba0..1a453109dbc 100644
--- a/chromium/ui/base/ime/init/input_method_initializer.cc
+++ b/chromium/ui/base/ime/init/input_method_initializer.cc
@@ -4,12 +4,14 @@
#include "ui/base/ime/init/input_method_initializer.h"
+#include <ostream>
+
#include "build/build_config.h"
#if defined(OS_CHROMEOS)
#include "ui/base/ime/ime_bridge.h"
#elif defined(USE_AURA) && defined(OS_LINUX)
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/base/ime/linux/fake_input_method_context_factory.h"
#elif defined(OS_WIN)
#include "ui/base/ime/init/input_method_factory.h"
diff --git a/chromium/ui/base/ime/input_method_base.cc b/chromium/ui/base/ime/input_method_base.cc
index 5bf12f65292..6051072ddb7 100644
--- a/chromium/ui/base/ime/input_method_base.cc
+++ b/chromium/ui/base/ime/input_method_base.cc
@@ -6,7 +6,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "ui/base/ime/ime_bridge.h"
diff --git a/chromium/ui/base/ime/linux/composition_text_util_pango_unittest.cc b/chromium/ui/base/ime/linux/composition_text_util_pango_unittest.cc
index c75fbab8cc7..3d37d710feb 100644
--- a/chromium/ui/base/ime/linux/composition_text_util_pango_unittest.cc
+++ b/chromium/ui/base/ime/linux/composition_text_util_pango_unittest.cc
@@ -11,7 +11,7 @@
#include <string>
#include <utility>
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/ime/composition_text.h"
diff --git a/chromium/ui/base/ime/linux/text_edit_command_auralinux.cc b/chromium/ui/base/ime/linux/text_edit_command_auralinux.cc
index 40aeda6c394..a694f59397e 100644
--- a/chromium/ui/base/ime/linux/text_edit_command_auralinux.cc
+++ b/chromium/ui/base/ime/linux/text_edit_command_auralinux.cc
@@ -4,7 +4,7 @@
#include "ui/base/ime/linux/text_edit_command_auralinux.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "ui/base/ime/text_edit_commands.h"
namespace ui {
diff --git a/chromium/ui/base/ime/mock_ime_input_context_handler.cc b/chromium/ui/base/ime/mock_ime_input_context_handler.cc
index 949d67b9282..f6d7cf6decb 100644
--- a/chromium/ui/base/ime/mock_ime_input_context_handler.cc
+++ b/chromium/ui/base/ime/mock_ime_input_context_handler.cc
@@ -4,6 +4,7 @@
#include "ui/base/ime/mock_ime_input_context_handler.h"
+#include "base/logging.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/base/ime/composition_text.h"
#include "ui/base/ime/input_method.h"
diff --git a/chromium/ui/base/ime/mojom/BUILD.gn b/chromium/ui/base/ime/mojom/BUILD.gn
index e32beab0c69..dd96cc53288 100644
--- a/chromium/ui/base/ime/mojom/BUILD.gn
+++ b/chromium/ui/base/ime/mojom/BUILD.gn
@@ -9,6 +9,36 @@ mojom("mojom") {
sources = [ "ime_types.mojom" ]
public_deps = [ "//mojo/public/mojom/base" ]
+
+ cpp_typemaps = [
+ {
+ types = [
+ {
+ mojom = "ui.mojom.ImeTextSpan"
+ cpp = "::ui::ImeTextSpan"
+ },
+ {
+ mojom = "ui.mojom.ImeTextSpanThickness"
+ cpp = "::ui::ImeTextSpan::Thickness"
+ },
+ {
+ mojom = "ui.mojom.ImeTextSpanUnderlineStyle"
+ cpp = "::ui::ImeTextSpan::UnderlineStyle"
+ },
+ {
+ mojom = "ui.mojom.TextInputType"
+ cpp = "::ui::TextInputType"
+ },
+ ]
+
+ traits_sources = [ "ime_types_mojom_traits.cc" ]
+ traits_headers = [ "ime_types_mojom_traits.h" ]
+ traits_public_deps = [
+ "//ui/base/ime:ime_types",
+ "//ui/gfx/range",
+ ]
+ },
+ ]
}
mojom("test_interfaces") {
diff --git a/chromium/ui/base/ime/mojom/OWNERS b/chromium/ui/base/ime/mojom/OWNERS
index 7ed4e44a4d5..b36774dad1d 100644
--- a/chromium/ui/base/ime/mojom/OWNERS
+++ b/chromium/ui/base/ime/mojom/OWNERS
@@ -1,8 +1,4 @@
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
-
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-per-file *.typemap=set noparent
-per-file *.typemap=file://ipc/SECURITY_OWNERS
diff --git a/chromium/ui/base/ime/mojom/ime_types.mojom b/chromium/ui/base/ime/mojom/ime_types.mojom
index 3e772ac903c..57b07029fa3 100644
--- a/chromium/ui/base/ime/mojom/ime_types.mojom
+++ b/chromium/ui/base/ime/mojom/ime_types.mojom
@@ -25,7 +25,8 @@ enum TextInputType {
TEXT_AREA,
CONTENT_EDITABLE,
DATE_TIME_FIELD,
- MAX = DATE_TIME_FIELD,
+ TYPE_NULL,
+ MAX = TYPE_NULL,
};
// See comments for ui::ImeTextSpan::Type for more details.
diff --git a/chromium/ui/base/ime/mojom/ime_types.typemap b/chromium/ui/base/ime/mojom/ime_types.typemap
deleted file mode 100644
index 3f76dfaddbe..00000000000
--- a/chromium/ui/base/ime/mojom/ime_types.typemap
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2019 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.
-
-mojom = "//ui/base/ime/mojom/ime_types.mojom"
-public_headers = [
- "//ui/base/ime/ime_text_span.h",
- "//ui/base/ime/text_input_type.h",
-]
-traits_headers = [ "//ui/base/ime/mojom/ime_types_mojom_traits.h" ]
-sources = [
- "//ui/base/ime/mojom/ime_types_mojom_traits.cc",
-]
-public_deps = [
- "//ui/base/ime:ime_types",
-]
-deps = [
- "//ui/gfx/range",
-]
-
-type_mappings = [
- "ui.mojom.ImeTextSpan=::ui::ImeTextSpan",
- "ui.mojom.ImeTextSpanThickness=::ui::ImeTextSpan::Thickness",
- "ui.mojom.ImeTextSpanUnderlineStyle=::ui::ImeTextSpan::UnderlineStyle",
- "ui.mojom.TextInputType=::ui::TextInputType",
-]
diff --git a/chromium/ui/base/ime/mojom/ime_types_mojom_traits.cc b/chromium/ui/base/ime/mojom/ime_types_mojom_traits.cc
index f464349f2ae..694959deddd 100644
--- a/chromium/ui/base/ime/mojom/ime_types_mojom_traits.cc
+++ b/chromium/ui/base/ime/mojom/ime_types_mojom_traits.cc
@@ -32,6 +32,9 @@ EnumTraits<ui::mojom::TextInputType, ui::TextInputType>::ToMojom(
UI_TO_MOJO_TYPE_CASE(TEXT_AREA);
UI_TO_MOJO_TYPE_CASE(CONTENT_EDITABLE);
UI_TO_MOJO_TYPE_CASE(DATE_TIME_FIELD);
+ // Unfortunately we cannot use the macro due to the definition conflict.
+ case ui::TEXT_INPUT_TYPE_NULL:
+ return ui::mojom::TextInputType::TYPE_NULL;
}
NOTREACHED();
return ui::mojom::TextInputType::NONE;
@@ -66,6 +69,10 @@ bool EnumTraits<ui::mojom::TextInputType, ui::TextInputType>::FromMojom(
MOJO_TO_UI_TYPE_CASE(TEXT_AREA);
MOJO_TO_UI_TYPE_CASE(CONTENT_EDITABLE);
MOJO_TO_UI_TYPE_CASE(DATE_TIME_FIELD);
+ // Unfortunately we cannot use the macro due to the definition conflict.
+ case ui::mojom::TextInputType::TYPE_NULL:
+ *out = ui::TEXT_INPUT_TYPE_NULL;
+ return true;
}
#undef MOJO_TO_UI_TYPE_CASE
return false;
diff --git a/chromium/ui/base/ime/mojom/typemaps.gni b/chromium/ui/base/ime/mojom/typemaps.gni
deleted file mode 100644
index b14ca59024c..00000000000
--- a/chromium/ui/base/ime/mojom/typemaps.gni
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2019 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.
-
-typemaps = [ "//ui/base/ime/mojom/ime_types.typemap" ]
diff --git a/chromium/ui/base/ime/text_input_type.h b/chromium/ui/base/ime/text_input_type.h
index 641cb7ec8e0..ba37902b791 100644
--- a/chromium/ui/base/ime/text_input_type.h
+++ b/chromium/ui/base/ime/text_input_type.h
@@ -7,8 +7,9 @@
namespace ui {
-// Intentionally keep sync with blink::WebTextInputType defined in:
-// third_party/WebKit/public/platform/WebTextInputType.h
+// TextInputType is the enum type representing every type of text input fields.
+// TextInputType should include all types defined in blink::WebTextInputType
+// defined in: third_party/WebKit/public/platform/WebTextInputType.h
//
// A Java counterpart will be generated for this enum.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.ui.base.ime
@@ -44,7 +45,14 @@ enum TextInputType {
// for on-screen keyboard.
TEXT_INPUT_TYPE_DATE_TIME_FIELD,
- TEXT_INPUT_TYPE_MAX = TEXT_INPUT_TYPE_DATE_TIME_FIELD,
+ // Input caret is in an editable node which doesn't support rich editing.
+ // It means that the editable node cannot support the features like candidate
+ // texts and retrieving text around cursor.
+ // However, it still can process raw key events and needs the on-screen
+ // keyboard if it wants.
+ TEXT_INPUT_TYPE_NULL,
+
+ TEXT_INPUT_TYPE_MAX = TEXT_INPUT_TYPE_NULL,
};
} // namespace ui
diff --git a/chromium/ui/base/ime/virtual_keyboard_visibility_request.h b/chromium/ui/base/ime/virtual_keyboard_visibility_request.h
new file mode 100644
index 00000000000..65cee20f299
--- /dev/null
+++ b/chromium/ui/base/ime/virtual_keyboard_visibility_request.h
@@ -0,0 +1,21 @@
+// Copyright 2020 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 UI_BASE_IME_VIRTUAL_KEYBOARD_VISIBILITY_REQUEST_H_
+#define UI_BASE_IME_VIRTUAL_KEYBOARD_VISIBILITY_REQUEST_H_
+
+namespace ui {
+
+// This mode corresponds to VirtualKeyboard API show/hide.
+// https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/master/VirtualKeyboardPolicy/explainer.md
+enum class VirtualKeyboardVisibilityRequest {
+ SHOW,
+ HIDE,
+ NONE,
+ MAX = NONE,
+};
+
+} // namespace ui
+
+#endif // UI_BASE_IME_VIRTUAL_KEYBOARD_VISIBILITY_REQUEST_H_
diff --git a/chromium/ui/base/ime/win/BUILD.gn b/chromium/ui/base/ime/win/BUILD.gn
index 4502991cb0b..5a7c0c7d53c 100644
--- a/chromium/ui/base/ime/win/BUILD.gn
+++ b/chromium/ui/base/ime/win/BUILD.gn
@@ -29,6 +29,8 @@ jumbo_component("win") {
"tsf_input_scope.h",
"tsf_text_store.cc",
"tsf_text_store.h",
+ "virtual_keyboard_debounce_timer.cc",
+ "virtual_keyboard_debounce_timer.h",
]
defines = [ "IS_UI_BASE_IME_WIN_IMPL" ]
diff --git a/chromium/ui/base/ime/win/mock_tsf_bridge.cc b/chromium/ui/base/ime/win/mock_tsf_bridge.cc
index 62364c9aaeb..935da4d4e2f 100644
--- a/chromium/ui/base/ime/win/mock_tsf_bridge.cc
+++ b/chromium/ui/base/ime/win/mock_tsf_bridge.cc
@@ -4,7 +4,7 @@
#include "ui/base/ime/win/mock_tsf_bridge.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "ui/base/ime/text_input_client.h"
namespace ui {
diff --git a/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_input_pane.cc b/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_input_pane.cc
index 748825541ed..cf2caabef7d 100644
--- a/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_input_pane.cc
+++ b/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_input_pane.cc
@@ -8,6 +8,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
+#include "base/trace_event/trace_event.h"
#include "base/win/com_init_util.h"
#include "base/win/core_winrt_util.h"
#include "base/win/windows_version.h"
@@ -51,6 +52,9 @@ class OnScreenKeyboardDisplayManagerInputPane::VirtualKeyboardInputPane
if (!EnsureInputPanePointersInBackgroundThread(hwnd))
return;
boolean res;
+ TRACE_EVENT0("vk",
+ "OnScreenKeyboardDisplayManagerInputPane::"
+ "VirtualKeyboardInputPane::TryShowInBackgroundThread");
input_pane2_->TryShow(&res);
}
@@ -61,6 +65,9 @@ class OnScreenKeyboardDisplayManagerInputPane::VirtualKeyboardInputPane
if (!EnsureInputPanePointersInBackgroundThread(hwnd))
return;
boolean res;
+ TRACE_EVENT0("vk",
+ "OnScreenKeyboardDisplayManagerInputPane::"
+ "VirtualKeyboardInputPane::TryHideInBackgroundThread");
input_pane2_->TryHide(&res);
}
@@ -131,6 +138,10 @@ class OnScreenKeyboardDisplayManagerInputPane::VirtualKeyboardInputPane
ABI::Windows::Foundation::Rect rect;
input_pane_->get_OccludedRect(&rect);
gfx::Rect dip_rect(rect.X, rect.Y, rect.Width, rect.Height);
+ TRACE_EVENT1("vk",
+ "OnScreenKeyboardDisplayManagerInputPane::"
+ "VirtualKeyboardInputPane::OnInputPaneShown",
+ "dip_rect", dip_rect.ToString());
main_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&OnScreenKeyboardDisplayManagerInputPane::
@@ -143,6 +154,9 @@ class OnScreenKeyboardDisplayManagerInputPane::VirtualKeyboardInputPane
ABI::Windows::UI::ViewManagement::IInputPane* pane,
ABI::Windows::UI::ViewManagement::IInputPaneVisibilityEventArgs* args) {
DCHECK(!main_task_runner_->BelongsToCurrentThread());
+ TRACE_EVENT0("vk",
+ "OnScreenKeyboardDisplayManagerInputPane::"
+ "VirtualKeyboardInputPane::OnInputPaneHidden");
main_task_runner_->PostTask(
FROM_HERE, base::BindOnce(&OnScreenKeyboardDisplayManagerInputPane::
NotifyObserversOnKeyboardHidden,
@@ -188,6 +202,9 @@ OnScreenKeyboardDisplayManagerInputPane::
is_keyboard_visible_(false) {
DCHECK_GE(base::win::GetVersion(), base::win::Version::WIN10_RS1);
DCHECK(main_task_runner_->BelongsToCurrentThread());
+ // 300ms is the timer we chose after experimenting with users on windows touch
+ // devices.
+ debouncer_ = std::make_unique<VirtualKeyboardDebounceTimer>(300);
// We post the initiation of |virtual_keyboard_input_pane_| to the background
// thread first, and any other tasks posted to the background thread are
@@ -201,23 +218,50 @@ OnScreenKeyboardDisplayManagerInputPane::
weak_factory_.GetWeakPtr()));
}
+void OnScreenKeyboardDisplayManagerInputPane::Run() {
+ // Execute show() or hide() on the background thread after the debounce
+ // expires.
+ switch (last_vk_visibility_request_) {
+ case VirtualKeyboardVisibilityRequest::SHOW: {
+ background_task_runner_->PostTask(
+ FROM_HERE,
+ base::BindOnce(
+ &OnScreenKeyboardDisplayManagerInputPane::
+ VirtualKeyboardInputPane::TryShowInBackgroundThread,
+ base::RetainedRef(virtual_keyboard_input_pane_), hwnd_));
+ break;
+ }
+ case VirtualKeyboardVisibilityRequest::HIDE: {
+ background_task_runner_->PostTask(
+ FROM_HERE,
+ base::BindOnce(
+ &OnScreenKeyboardDisplayManagerInputPane::
+ VirtualKeyboardInputPane::TryHideInBackgroundThread,
+ base::RetainedRef(virtual_keyboard_input_pane_), hwnd_));
+ break;
+ }
+ case VirtualKeyboardVisibilityRequest::NONE: {
+ break;
+ }
+ }
+ // Reset the VK visibility state to none so we can keep track of subsequent
+ // API calls.
+ last_vk_visibility_request_ = VirtualKeyboardVisibilityRequest::NONE;
+}
+
bool OnScreenKeyboardDisplayManagerInputPane::DisplayVirtualKeyboard() {
DCHECK(main_task_runner_->BelongsToCurrentThread());
- background_task_runner_->PostTask(
- FROM_HERE,
- base::BindOnce(&OnScreenKeyboardDisplayManagerInputPane::
- VirtualKeyboardInputPane::TryShowInBackgroundThread,
- base::RetainedRef(virtual_keyboard_input_pane_), hwnd_));
+ last_vk_visibility_request_ = VirtualKeyboardVisibilityRequest::SHOW;
+ debouncer_->RequestRun(base::BindOnce(
+ &OnScreenKeyboardDisplayManagerInputPane::Run, base::Unretained(this)));
return true;
}
void OnScreenKeyboardDisplayManagerInputPane::DismissVirtualKeyboard() {
DCHECK(main_task_runner_->BelongsToCurrentThread());
- background_task_runner_->PostTask(
- FROM_HERE,
- base::BindOnce(&OnScreenKeyboardDisplayManagerInputPane::
- VirtualKeyboardInputPane::TryHideInBackgroundThread,
- base::RetainedRef(virtual_keyboard_input_pane_), hwnd_));
+ last_vk_visibility_request_ = VirtualKeyboardVisibilityRequest::HIDE;
+ debouncer_->RequestRun(base::BindOnce(
+ &OnScreenKeyboardDisplayManagerInputPane::Run, base::Unretained(this)));
}
void OnScreenKeyboardDisplayManagerInputPane::AddObserver(
@@ -268,6 +312,8 @@ void OnScreenKeyboardDisplayManagerInputPane::
OnScreenKeyboardDisplayManagerInputPane::
~OnScreenKeyboardDisplayManagerInputPane() {
DCHECK(main_task_runner_->BelongsToCurrentThread());
+ // In-case there is a debouncer task running, cancel it.
+ debouncer_->CancelRequest();
if (virtual_keyboard_input_pane_.get()) {
background_task_runner_->ReleaseSoon(
FROM_HERE, std::move(virtual_keyboard_input_pane_));
diff --git a/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_input_pane.h b/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_input_pane.h
index c5e4388a3e3..40c8578cb79 100644
--- a/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_input_pane.h
+++ b/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_input_pane.h
@@ -18,6 +18,8 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/win/windows_types.h"
#include "ui/base/ime/input_method_keyboard_controller.h"
+#include "ui/base/ime/virtual_keyboard_visibility_request.h"
+#include "ui/base/ime/win/virtual_keyboard_debounce_timer.h"
#include "ui/gfx/geometry/rect.h"
namespace ui {
@@ -43,6 +45,12 @@ class COMPONENT_EXPORT(UI_BASE_IME_WIN)
void SetInputPaneForTesting(
Microsoft::WRL::ComPtr<ABI::Windows::UI::ViewManagement::IInputPane>
pane);
+ // Returns whether show/hide VK API is called from
+ // InputMethodKeyboardController or not.
+ VirtualKeyboardVisibilityRequest GetLastVirtualKeyboardVisibilityRequest()
+ const {
+ return last_vk_visibility_request_;
+ }
private:
class VirtualKeyboardInputPane;
@@ -50,6 +58,8 @@ class COMPONENT_EXPORT(UI_BASE_IME_WIN)
void NotifyObserversOnKeyboardShown(gfx::Rect rect);
void NotifyObserversOnKeyboardHidden();
+ // This executes when the debounce timer expires.
+ void Run();
// The main window which displays the on screen keyboard.
const HWND hwnd_;
@@ -59,6 +69,9 @@ class COMPONENT_EXPORT(UI_BASE_IME_WIN)
const scoped_refptr<base::SingleThreadTaskRunner> background_task_runner_;
scoped_refptr<VirtualKeyboardInputPane> virtual_keyboard_input_pane_;
bool is_keyboard_visible_;
+ VirtualKeyboardVisibilityRequest last_vk_visibility_request_ =
+ VirtualKeyboardVisibilityRequest::NONE;
+ std::unique_ptr<VirtualKeyboardDebounceTimer> debouncer_;
base::WeakPtrFactory<OnScreenKeyboardDisplayManagerInputPane> weak_factory_{
this};
diff --git a/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_unittest.cc b/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_unittest.cc
index 67dbb33b90d..00a2eca6e97 100644
--- a/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_unittest.cc
+++ b/chromium/ui/base/ime/win/on_screen_keyboard_display_manager_unittest.cc
@@ -6,7 +6,6 @@
#include "base/files/file_path.h"
#include "base/files/file_util.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/strings/string16.h"
#include "base/test/task_environment.h"
@@ -177,12 +176,48 @@ TEST_F(OnScreenKeyboardTest, InputPane) {
EXPECT_CALL(*observer, OnKeyboardVisible(testing::_)).Times(1);
keyboard_display_manager->AddObserver(observer.get());
keyboard_display_manager->DisplayVirtualKeyboard();
- WaitForEventsWithTimeDelay(100);
+ // Additional 300ms for debounce timer.
+ WaitForEventsWithTimeDelay(400);
testing::Mock::VerifyAndClearExpectations(observer.get());
EXPECT_CALL(*observer, OnKeyboardHidden()).Times(1);
keyboard_display_manager->DismissVirtualKeyboard();
- WaitForEventsWithTimeDelay(100);
+ // Additional 300ms for debounce timer.
+ WaitForEventsWithTimeDelay(400);
+ keyboard_display_manager->RemoveObserver(observer.get());
+}
+
+TEST_F(OnScreenKeyboardTest, InputPaneDebounceTimerTest) {
+ // InputPane is supported only on RS1 and later.
+ if (base::win::GetVersion() < base::win::Version::WIN10_RS1)
+ return;
+ std::unique_ptr<OnScreenKeyboardDisplayManagerInputPane>
+ keyboard_display_manager = CreateInputPane();
+
+ std::unique_ptr<MockInputMethodKeyboardControllerObserver> observer =
+ std::make_unique<MockInputMethodKeyboardControllerObserver>();
+
+ Microsoft::WRL::ComPtr<MockInputPane> input_pane =
+ Microsoft::WRL::Make<MockInputPane>();
+ keyboard_display_manager->SetInputPaneForTesting(input_pane);
+
+ EXPECT_CALL(*observer, OnKeyboardVisible(testing::_)).Times(1);
+ keyboard_display_manager->AddObserver(observer.get());
+ keyboard_display_manager->DisplayVirtualKeyboard();
+ keyboard_display_manager->DismissVirtualKeyboard();
+ keyboard_display_manager->DisplayVirtualKeyboard();
+ keyboard_display_manager->DismissVirtualKeyboard();
+ keyboard_display_manager->DisplayVirtualKeyboard();
+ // Additional 300ms for debounce timer.
+ WaitForEventsWithTimeDelay(400);
+
+ testing::Mock::VerifyAndClearExpectations(observer.get());
+ EXPECT_CALL(*observer, OnKeyboardHidden()).Times(1);
+ keyboard_display_manager->DismissVirtualKeyboard();
+ keyboard_display_manager->DisplayVirtualKeyboard();
+ keyboard_display_manager->DismissVirtualKeyboard();
+ // Additional 300ms for debounce timer.
+ WaitForEventsWithTimeDelay(400);
keyboard_display_manager->RemoveObserver(observer.get());
}
diff --git a/chromium/ui/base/ime/win/tsf_input_scope.cc b/chromium/ui/base/ime/win/tsf_input_scope.cc
index e58c5663268..54e009e0a1e 100644
--- a/chromium/ui/base/ime/win/tsf_input_scope.cc
+++ b/chromium/ui/base/ime/win/tsf_input_scope.cc
@@ -6,8 +6,8 @@
#include <stddef.h>
+#include "base/check.h"
#include "base/compiler_specific.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/message_loop/message_loop_current.h"
#include "base/stl_util.h"
diff --git a/chromium/ui/base/ime/win/tsf_text_store.cc b/chromium/ui/base/ime/win/tsf_text_store.cc
index 2a8cde4995f..22f43ff72b0 100644
--- a/chromium/ui/base/ime/win/tsf_text_store.cc
+++ b/chromium/ui/base/ime/win/tsf_text_store.cc
@@ -1415,28 +1415,29 @@ void TSFTextStore::GetStyle(const TF_DISPLAYATTRIBUTE& attribute,
// any style or not.
span->thickness = attribute.fBoldLine ? ImeTextSpan::Thickness::kThick
: ImeTextSpan::Thickness::kThin;
- span->underline_style = ImeTextSpan::UnderlineStyle::kSolid;
- if (attribute.lsStyle != TF_LS_NONE) {
- switch (attribute.lsStyle) {
- case TF_LS_SOLID: {
- span->underline_style = ImeTextSpan::UnderlineStyle::kSolid;
- break;
- }
- case TF_LS_DOT: {
- span->underline_style = ImeTextSpan::UnderlineStyle::kDot;
- break;
- }
- case TF_LS_DASH: {
- span->underline_style = ImeTextSpan::UnderlineStyle::kDash;
- break;
- }
- case TF_LS_SQUIGGLE: {
- span->underline_style = ImeTextSpan::UnderlineStyle::kSquiggle;
- break;
- }
- default: {
- span->underline_style = ImeTextSpan::UnderlineStyle::kSolid;
- }
+ switch (attribute.lsStyle) {
+ case TF_LS_SOLID: {
+ span->underline_style = ImeTextSpan::UnderlineStyle::kSolid;
+ break;
+ }
+ case TF_LS_DOT: {
+ span->underline_style = ImeTextSpan::UnderlineStyle::kDot;
+ break;
+ }
+ case TF_LS_DASH: {
+ span->underline_style = ImeTextSpan::UnderlineStyle::kDash;
+ break;
+ }
+ case TF_LS_SQUIGGLE: {
+ span->underline_style = ImeTextSpan::UnderlineStyle::kSquiggle;
+ break;
+ }
+ case TF_LS_NONE: {
+ span->underline_style = ImeTextSpan::UnderlineStyle::kNone;
+ break;
+ }
+ default: {
+ span->underline_style = ImeTextSpan::UnderlineStyle::kSolid;
}
}
if (attribute.crText.type != TF_CT_NONE) {
diff --git a/chromium/ui/base/ime/win/virtual_keyboard_debounce_timer.cc b/chromium/ui/base/ime/win/virtual_keyboard_debounce_timer.cc
new file mode 100644
index 00000000000..1caa0bf6aa3
--- /dev/null
+++ b/chromium/ui/base/ime/win/virtual_keyboard_debounce_timer.cc
@@ -0,0 +1,37 @@
+// Copyright 2020 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 "ui/base/ime/win/virtual_keyboard_debounce_timer.h"
+
+namespace ui {
+
+VirtualKeyboardDebounceTimer::VirtualKeyboardDebounceTimer(int delay_ms)
+ : delay_ms_(delay_ms) {}
+
+VirtualKeyboardDebounceTimer::~VirtualKeyboardDebounceTimer() = default;
+
+void VirtualKeyboardDebounceTimer::RequestRun(base::OnceClosure callback) {
+ // Null callback isn't a valid scenario.
+ DCHECK(callback);
+ callback_ = std::move(callback);
+ base::TimeDelta delay(base::TimeDelta::FromMilliseconds(delay_ms_));
+ delay -= base::TimeTicks::Now() - time_last_run_;
+ // If delay is <= 0, then it is run immediately asynchronously.
+ timer_.Start(
+ FROM_HERE, delay, this,
+ &VirtualKeyboardDebounceTimer::HandleLastVirtualKeyboardVisibility);
+}
+
+void VirtualKeyboardDebounceTimer::CancelRequest() {
+ timer_.Stop();
+}
+
+void VirtualKeyboardDebounceTimer::HandleLastVirtualKeyboardVisibility() {
+ // Based on the state call the respective show/hide
+ time_last_run_ = base::TimeTicks::Now();
+ if (callback_)
+ std::move(callback_).Run();
+}
+
+} // namespace ui
diff --git a/chromium/ui/base/ime/win/virtual_keyboard_debounce_timer.h b/chromium/ui/base/ime/win/virtual_keyboard_debounce_timer.h
new file mode 100644
index 00000000000..6f59c351b09
--- /dev/null
+++ b/chromium/ui/base/ime/win/virtual_keyboard_debounce_timer.h
@@ -0,0 +1,54 @@
+// Copyright 2020 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 UI_BASE_IME_WIN_VIRTUAL_KEYBOARD_DEBOUNCE_TIMER_H_
+#define UI_BASE_IME_WIN_VIRTUAL_KEYBOARD_DEBOUNCE_TIMER_H_
+
+#include "base/callback.h"
+#include "base/macros.h"
+#include "base/time/time.h"
+#include "base/timer/timer.h"
+
+namespace ui {
+
+// This class debounces a method call to the on-screen keyboard show/hide.
+// This is used to throttle the TryShow/TryHide system API calls to OS and it
+// doesn't introduce a strong guarantee about the keyboard visibility itself as
+// that is ultimately controlled by the OS input service.
+class VirtualKeyboardDebounceTimer {
+ public:
+ explicit VirtualKeyboardDebounceTimer(int delay_ms);
+
+ ~VirtualKeyboardDebounceTimer();
+
+ // Request |callback| to be invoked after the debouncing delay. If called
+ // while a previous request is still pending, the previous request will be
+ // cancelled.
+ void RequestRun(base::OnceClosure callback);
+
+ // Cancels any pending request.
+ void CancelRequest();
+
+ private:
+ // This is called when the |timer_| expires.
+ // It then invokes the |TryShow()|/|TryHide()| API based on the last reported
+ // state of |VirtualKeyboardVisibilityRequest|.
+ void HandleLastVirtualKeyboardVisibility();
+
+ // The debounce delay.
+ int delay_ms_ = 0;
+
+ // Tracks when to next invoke |callback_|.
+ base::OneShotTimer timer_;
+
+ // The last time |Run| was invoked.
+ base::TimeTicks time_last_run_;
+
+ // The callback to invoke once |timer_| expires.
+ base::OnceClosure callback_;
+};
+
+} // namespace ui
+
+#endif // UI_BASE_IME_WIN_VIRTUAL_KEYBOARD_DEBOUNCE_TIMER_H_
diff --git a/chromium/ui/base/l10n/formatter.cc b/chromium/ui/base/l10n/formatter.cc
index 486a3a029cb..72ed375005f 100644
--- a/chromium/ui/base/l10n/formatter.cc
+++ b/chromium/ui/base/l10n/formatter.cc
@@ -9,7 +9,7 @@
#include <memory>
#include <vector>
-#include "base/logging.h"
+#include "base/check.h"
#include "third_party/icu/source/common/unicode/unistr.h"
#include "third_party/icu/source/i18n/unicode/msgfmt.h"
#include "ui/base/l10n/l10n_util.h"
diff --git a/chromium/ui/base/l10n/l10n_font_util.cc b/chromium/ui/base/l10n/l10n_font_util.cc
index 5e9f4da195f..fa6f7d950e4 100644
--- a/chromium/ui/base/l10n/l10n_font_util.cc
+++ b/chromium/ui/base/l10n/l10n_font_util.cc
@@ -4,7 +4,7 @@
#include "ui/base/l10n/l10n_font_util.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/strings/string_number_conversions.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/font.h"
diff --git a/chromium/ui/base/l10n/l10n_util.cc b/chromium/ui/base/l10n/l10n_util.cc
index 70cae720fc1..489cde62132 100644
--- a/chromium/ui/base/l10n/l10n_util.cc
+++ b/chromium/ui/base/l10n/l10n_util.cc
@@ -10,6 +10,7 @@
#include <memory>
#include <string>
+#include "base/check_op.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/files/file_util.h"
@@ -19,6 +20,7 @@
#include "base/i18n/rtl.h"
#include "base/i18n/string_compare.h"
#include "base/lazy_instance.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
@@ -888,6 +890,12 @@ void GetAcceptLanguagesForLocale(const std::string& display_locale,
}
}
+void GetAcceptLanguages(std::vector<std::string>* locale_codes) {
+ for (const char* accept_language : kAcceptLanguageList) {
+ locale_codes->push_back(accept_language);
+ }
+}
+
bool IsLanguageAccepted(const std::string& display_locale,
const std::string& locale) {
for (const char* accept_language : kAcceptLanguageList) {
diff --git a/chromium/ui/base/l10n/l10n_util.h b/chromium/ui/base/l10n/l10n_util.h
index a371dc424ea..21de14825df 100644
--- a/chromium/ui/base/l10n/l10n_util.h
+++ b/chromium/ui/base/l10n/l10n_util.h
@@ -212,6 +212,9 @@ UI_BASE_EXPORT void GetAcceptLanguagesForLocale(
const std::string& display_locale,
std::vector<std::string>* locale_codes);
+// Returns a vector of untranslated locale codes usable for accept-languages.
+UI_BASE_EXPORT void GetAcceptLanguages(std::vector<std::string>* locale_codes);
+
// Returns true if |locale| is in a predefined AcceptLanguageList and
// a display name for the |locale| is available in the locale |display_locale|.
UI_BASE_EXPORT bool IsLanguageAccepted(const std::string& display_locale,
diff --git a/chromium/ui/base/l10n/l10n_util_android.cc b/chromium/ui/base/l10n/l10n_util_android.cc
index 6ef8c773fd5..9d3ce2a1fae 100644
--- a/chromium/ui/base/l10n/l10n_util_android.cc
+++ b/chromium/ui/base/l10n/l10n_util_android.cc
@@ -9,8 +9,8 @@
#include "base/android/jni_android.h"
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h"
+#include "base/check.h"
#include "base/i18n/rtl.h"
-#include "base/logging.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "third_party/icu/source/common/unicode/uloc.h"
diff --git a/chromium/ui/base/l10n/l10n_util_mac.mm b/chromium/ui/base/l10n/l10n_util_mac.mm
index 874a2948fbf..5fd261bd54f 100644
--- a/chromium/ui/base/l10n/l10n_util_mac.mm
+++ b/chromium/ui/base/l10n/l10n_util_mac.mm
@@ -4,8 +4,8 @@
#import <Foundation/Foundation.h>
+#include "base/check.h"
#include "base/lazy_instance.h"
-#include "base/logging.h"
#include "base/mac/bundle_locations.h"
#import "base/mac/scoped_nsobject.h"
#include "base/strings/sys_string_conversions.h"
diff --git a/chromium/ui/base/l10n/l10n_util_unittest.cc b/chromium/ui/base/l10n/l10n_util_unittest.cc
index c3070971446..cb652df1649 100644
--- a/chromium/ui/base/l10n/l10n_util_unittest.cc
+++ b/chromium/ui/base/l10n/l10n_util_unittest.cc
@@ -115,7 +115,7 @@ TEST_F(L10nUtilTest, GetAppLocale) {
for (size_t i = 0; i < base::size(filenames); ++i) {
base::FilePath filename = new_locale_dir.AppendASCII(
filenames[i] + ".pak");
- base::WriteFile(filename, "", 0);
+ base::WriteFile(filename, "");
}
// Keep a copy of ICU's default locale before we overwrite it.
@@ -546,7 +546,7 @@ TEST_F(L10nUtilTest, IsValidLocaleSyntax) {
EXPECT_TRUE(l10n_util::IsValidLocaleSyntax("en_IE_u_cu_IEP"));
EXPECT_TRUE(l10n_util::IsValidLocaleSyntax("en_IE@currency=IEP"));
EXPECT_TRUE(l10n_util::IsValidLocaleSyntax("fr@x=y"));
- EXPECT_TRUE(l10n_util::IsValidLocaleSyntax("zn_CN@foo=bar"));
+ EXPECT_TRUE(l10n_util::IsValidLocaleSyntax("zh_CN@foo=bar"));
EXPECT_TRUE(l10n_util::IsValidLocaleSyntax(
"fr@collation=phonebook;calendar=islamic-civil"));
EXPECT_TRUE(l10n_util::IsValidLocaleSyntax(
diff --git a/chromium/ui/base/l10n/time_format.cc b/chromium/ui/base/l10n/time_format.cc
index 58e4c9431bf..c5a98fc850d 100644
--- a/chromium/ui/base/l10n/time_format.cc
+++ b/chromium/ui/base/l10n/time_format.cc
@@ -6,8 +6,9 @@
#include <limits>
+#include "base/check_op.h"
#include "base/lazy_instance.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "third_party/icu/source/common/unicode/unistr.h"
diff --git a/chromium/ui/base/layout.cc b/chromium/ui/base/layout.cc
index 0a32eb28d8c..fce80d356ce 100644
--- a/chromium/ui/base/layout.cc
+++ b/chromium/ui/base/layout.cc
@@ -10,7 +10,7 @@
#include <cmath>
#include <limits>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "ui/base/pointer/pointer_device.h"
diff --git a/chromium/ui/base/models/image_model.cc b/chromium/ui/base/models/image_model.cc
new file mode 100644
index 00000000000..501f8dc9495
--- /dev/null
+++ b/chromium/ui/base/models/image_model.cc
@@ -0,0 +1,97 @@
+// Copyright 2020 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 "ui/base/models/image_model.h"
+
+namespace ui {
+
+VectorIconModel::VectorIconModel() = default;
+
+VectorIconModel::VectorIconModel(const gfx::VectorIcon& vector_icon,
+ int color_id,
+ int icon_size)
+ : vector_icon_(&vector_icon), icon_size_(icon_size), color_id_(color_id) {}
+
+VectorIconModel::VectorIconModel(const gfx::VectorIcon& vector_icon,
+ SkColor color,
+ int icon_size)
+ : vector_icon_(&vector_icon), icon_size_(icon_size), color_(color) {}
+
+VectorIconModel::~VectorIconModel() = default;
+
+VectorIconModel::VectorIconModel(const VectorIconModel&) = default;
+
+VectorIconModel& VectorIconModel::operator=(const VectorIconModel&) = default;
+
+VectorIconModel::VectorIconModel(VectorIconModel&&) = default;
+
+VectorIconModel& VectorIconModel::operator=(VectorIconModel&&) = default;
+
+ImageModel::ImageModel() = default;
+
+ImageModel::ImageModel(const VectorIconModel& vector_icon_model)
+ : vector_icon_model_(vector_icon_model) {}
+
+ImageModel::ImageModel(const gfx::Image& image) : image_(image) {}
+
+ImageModel::ImageModel(const gfx::ImageSkia& image_skia)
+ : ImageModel(gfx::Image(image_skia)) {}
+
+ImageModel::~ImageModel() = default;
+
+ImageModel::ImageModel(const ImageModel&) = default;
+
+ImageModel& ImageModel::operator=(const ImageModel&) = default;
+
+ImageModel::ImageModel(ImageModel&&) = default;
+
+ImageModel& ImageModel::operator=(ImageModel&&) = default;
+
+// static
+ImageModel ImageModel::FromVectorIcon(const gfx::VectorIcon& vector_icon,
+ int color_id,
+ int icon_size) {
+ return ImageModel(VectorIconModel(vector_icon, color_id, icon_size));
+}
+
+// static
+ImageModel ImageModel::FromVectorIcon(const gfx::VectorIcon& vector_icon,
+ SkColor color,
+ int icon_size) {
+ return ImageModel(VectorIconModel(vector_icon, color, icon_size));
+}
+
+// static
+ImageModel ImageModel::FromImage(const gfx::Image& image) {
+ return ImageModel(image);
+}
+
+// static
+ImageModel ImageModel::FromImageSkia(const gfx::ImageSkia& image_skia) {
+ return ImageModel(image_skia);
+}
+
+bool ImageModel::IsEmpty() const {
+ return !IsVectorIcon() && !IsImage();
+}
+
+bool ImageModel::IsVectorIcon() const {
+ return vector_icon_model_ && !vector_icon_model_.value().is_empty();
+}
+
+bool ImageModel::IsImage() const {
+ return image_ && !image_.value().IsEmpty();
+}
+
+const VectorIconModel ImageModel::GetVectorIcon() const {
+ DCHECK(IsVectorIcon());
+ return vector_icon_model_.value();
+}
+
+const gfx::Image ImageModel::GetImage() const {
+ DCHECK(IsImage());
+ return image_.value();
+}
+
+} // namespace ui \ No newline at end of file
diff --git a/chromium/ui/base/models/image_model.h b/chromium/ui/base/models/image_model.h
new file mode 100644
index 00000000000..098a92ed42d
--- /dev/null
+++ b/chromium/ui/base/models/image_model.h
@@ -0,0 +1,113 @@
+// Copyright 2020 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 UI_BASE_MODELS_IMAGE_MODEL_H_
+#define UI_BASE_MODELS_IMAGE_MODEL_H_
+
+#include "base/callback.h"
+#include "base/optional.h"
+#include "third_party/skia/include/core/SkColor.h"
+#include "ui/base/ui_base_export.h"
+#include "ui/gfx/image/image.h"
+#include "ui/gfx/image/image_skia.h"
+
+namespace gfx {
+struct VectorIcon;
+} // namespace gfx
+
+namespace ui {
+
+// The following classes encapsulate the various ways that a model may provide
+// or otherwise specify an icon or image. Most notably, these are used by the
+// MenuModel and SimpleMenuModel for building actual menus.
+//
+// The VectorIconModel represents the combination of the icon path and its
+// optional color id. The optional color is provided by the color id which is
+// eventually resolved by the ColorProvider from the correct context. This class
+// is only used internal to ImageModel and should never be instantiated except
+// by ImageModel.
+
+class UI_BASE_EXPORT VectorIconModel {
+ public:
+ VectorIconModel();
+ VectorIconModel(const VectorIconModel&);
+ VectorIconModel& operator=(const VectorIconModel&);
+ VectorIconModel(VectorIconModel&&);
+ VectorIconModel& operator=(VectorIconModel&&);
+ ~VectorIconModel();
+
+ bool is_empty() const { return !vector_icon_; }
+
+ private:
+ friend class ThemedVectorIcon;
+ friend class ImageModel;
+
+ VectorIconModel(const gfx::VectorIcon& vector_icon,
+ int color_id,
+ int icon_size);
+ // TODO (kylixrd): This should be eventually removed once all instances of
+ // hard-coded SkColor constants are removed in favor of using a color id.
+ VectorIconModel(const gfx::VectorIcon& vector_icon,
+ SkColor color,
+ int icon_size);
+
+ const gfx::VectorIcon* vector_icon() const { return vector_icon_; }
+ int icon_size() const { return icon_size_; }
+ int color_id() const { return color_id_.value(); }
+ SkColor color() const { return color_.value(); }
+ bool has_color() const { return color_.has_value(); }
+
+ const gfx::VectorIcon* vector_icon_ = nullptr;
+ int icon_size_ = 0;
+ // Only one of the following will ever be assigned.
+ // TODO: Update to use std::variant or base:Variant once one of them is
+ // available to use.
+ base::Optional<int> color_id_;
+ base::Optional<SkColor> color_;
+};
+
+// ImageModel encapsulates either a gfx::Image or a VectorIconModel. Only one
+// of the two may be specified at a given time. This class is instantiated via
+// the FromXXXX static factory functions.
+
+class UI_BASE_EXPORT ImageModel {
+ public:
+ ImageModel();
+ ImageModel(const ImageModel&);
+ ImageModel& operator=(const ImageModel&);
+ ImageModel(ImageModel&&);
+ ImageModel& operator=(ImageModel&&);
+ ~ImageModel();
+
+ static ImageModel FromVectorIcon(const gfx::VectorIcon& vector_icon,
+ int color_id = -1,
+ int icon_size = 0);
+ static ImageModel FromVectorIcon(const gfx::VectorIcon& vector_icon,
+ SkColor color,
+ int icon_size = 0);
+ static ImageModel FromImage(const gfx::Image& image);
+ static ImageModel FromImageSkia(const gfx::ImageSkia& image_skia);
+
+ bool IsEmpty() const;
+ bool IsVectorIcon() const;
+ bool IsImage() const;
+ // Only valid if IsVectorIcon() or IsImage() return true, respectively.
+ const VectorIconModel GetVectorIcon() const;
+ const gfx::Image GetImage() const;
+
+ private:
+ ImageModel(const gfx::Image& image);
+ ImageModel(const gfx::ImageSkia& image_skia);
+ ImageModel(const VectorIconModel& vector_icon_model);
+
+ // Only one of the following will ever be assigned.
+ // TODO: Update to use std::variant or base:Variant once one of them is
+ // available to use.
+ base::Optional<VectorIconModel> vector_icon_model_;
+ base::Optional<gfx::Image> image_;
+};
+
+} // namespace ui
+
+#endif // UI_BASE_MODELS_IMAGE_MODEL_H_
diff --git a/chromium/ui/base/models/image_model_unittest.cc b/chromium/ui/base/models/image_model_unittest.cc
new file mode 100644
index 00000000000..3b494797afc
--- /dev/null
+++ b/chromium/ui/base/models/image_model_unittest.cc
@@ -0,0 +1,95 @@
+// Copyright 2020 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 "ui/base/models/image_model.h"
+
+#include "base/macros.h"
+#include "base/strings/string_util.h"
+#include "base/strings/utf_string_conversions.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/image/image_unittest_util.h"
+#include "ui/gfx/paint_vector_icon.h"
+#include "ui/gfx/vector_icon_types.h"
+
+namespace ui {
+
+namespace {
+
+const gfx::VectorIcon& GetVectorIcon() {
+ static constexpr gfx::PathElement path[] = {gfx::CommandType::CIRCLE, 24, 18,
+ 5};
+ static const gfx::VectorIconRep rep[] = {{path, 4}};
+ static constexpr gfx::VectorIcon circle_icon = {rep, 1, "circle"};
+
+ return circle_icon;
+}
+
+} // namespace
+
+TEST(ImageModelTest, DefaultEmpty) {
+ ImageModel image_model;
+
+ EXPECT_TRUE(image_model.IsEmpty());
+}
+
+TEST(ImageModelTest, DefaultVectorIconEmpty) {
+ VectorIconModel vector_icon_model;
+
+ EXPECT_TRUE(vector_icon_model.is_empty());
+}
+
+TEST(ImageModelTest, CheckForVectorIcon) {
+ ImageModel image_model = ImageModel::FromVectorIcon(GetVectorIcon());
+
+ EXPECT_FALSE(image_model.IsEmpty());
+ EXPECT_TRUE(image_model.IsVectorIcon());
+}
+
+TEST(ImageModelTest, CheckForImage) {
+ ImageModel image_model =
+ ImageModel::FromImage(gfx::test::CreateImage(16, 16));
+
+ EXPECT_FALSE(image_model.IsEmpty());
+ EXPECT_TRUE(image_model.IsImage());
+}
+
+TEST(ImageModelTest, CheckAssignVectorIcon) {
+ VectorIconModel vector_icon_model_dest;
+ VectorIconModel vector_icon_model_src =
+ ImageModel::FromVectorIcon(GetVectorIcon()).GetVectorIcon();
+
+ EXPECT_TRUE(vector_icon_model_dest.is_empty());
+ EXPECT_FALSE(vector_icon_model_src.is_empty());
+
+ vector_icon_model_dest = vector_icon_model_src;
+ EXPECT_FALSE(vector_icon_model_dest.is_empty());
+}
+
+TEST(ImageModelTest, CheckAssignImage) {
+ ImageModel image_model_dest;
+ ImageModel image_model_src =
+ ImageModel::FromImage(gfx::test::CreateImage(16, 16));
+
+ EXPECT_TRUE(image_model_dest.IsEmpty());
+ EXPECT_FALSE(image_model_src.IsEmpty());
+ EXPECT_TRUE(image_model_src.IsImage());
+ EXPECT_FALSE(image_model_src.IsVectorIcon());
+
+ image_model_dest = image_model_src;
+
+ EXPECT_FALSE(image_model_dest.IsEmpty());
+ EXPECT_TRUE(image_model_dest.IsImage());
+ EXPECT_FALSE(image_model_dest.IsVectorIcon());
+
+ image_model_src = ImageModel::FromVectorIcon(GetVectorIcon());
+
+ EXPECT_TRUE(image_model_src.IsVectorIcon());
+
+ image_model_dest = image_model_src;
+
+ EXPECT_TRUE(image_model_dest.IsVectorIcon());
+ EXPECT_FALSE(image_model_dest.IsImage());
+}
+
+} // namespace ui
diff --git a/chromium/ui/base/models/list_selection_model.cc b/chromium/ui/base/models/list_selection_model.cc
index a3288f9cab1..90c66420a9b 100644
--- a/chromium/ui/base/models/list_selection_model.cc
+++ b/chromium/ui/base/models/list_selection_model.cc
@@ -7,7 +7,7 @@
#include <algorithm>
#include <valarray>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/stl_util.h"
namespace ui {
diff --git a/chromium/ui/base/models/menu_model.cc b/chromium/ui/base/models/menu_model.cc
index 73f0ab6d84d..90a350cf9ce 100644
--- a/chromium/ui/base/models/menu_model.cc
+++ b/chromium/ui/base/models/menu_model.cc
@@ -4,6 +4,8 @@
#include "ui/base/models/menu_model.h"
+#include "ui/base/models/image_model.h"
+
namespace ui {
MenuModel::MenuModel() : menu_model_delegate_(nullptr) {}
@@ -50,15 +52,11 @@ base::string16 MenuModel::GetMinorTextAt(int index) const {
return base::string16();
}
-const gfx::VectorIcon* MenuModel::GetMinorIconAt(int index) const {
- return nullptr;
+ImageModel MenuModel::GetMinorIconAt(int index) const {
+ return ImageModel();
}
const gfx::FontList* MenuModel::GetLabelFontListAt(int index) const {
- return NULL;
-}
-
-const gfx::VectorIcon* MenuModel::GetVectorIconAt(int index) const {
return nullptr;
}
diff --git a/chromium/ui/base/models/menu_model.h b/chromium/ui/base/models/menu_model.h
index 5bcc6204c2b..887eee64e27 100644
--- a/chromium/ui/base/models/menu_model.h
+++ b/chromium/ui/base/models/menu_model.h
@@ -10,19 +10,17 @@
#include "ui/base/models/menu_model_delegate.h"
#include "ui/base/models/menu_separator_types.h"
#include "ui/base/ui_base_export.h"
-#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/native_widget_types.h"
namespace gfx {
class FontList;
-class Image;
-struct VectorIcon;
}
namespace ui {
class Accelerator;
class ButtonMenuItemModel;
+class ImageModel;
// An interface implemented by an object that provides the content of a menu.
class UI_BASE_EXPORT MenuModel : public base::SupportsWeakPtr<MenuModel> {
@@ -73,7 +71,7 @@ class UI_BASE_EXPORT MenuModel : public base::SupportsWeakPtr<MenuModel> {
// Returns the minor icon of the item at the specified index. The minor icon
// is rendered to the left of the minor text.
- virtual const gfx::VectorIcon* GetMinorIconAt(int index) const;
+ virtual ImageModel GetMinorIconAt(int index) const;
// Returns true if the menu item (label/sublabel/icon) at the specified
// index can change over the course of the menu's lifetime. If this function
@@ -97,13 +95,9 @@ class UI_BASE_EXPORT MenuModel : public base::SupportsWeakPtr<MenuModel> {
// index belongs to.
virtual int GetGroupIdAt(int index) const = 0;
- // Gets the icon for the item at the specified index, returning true if there
- // is an icon, false otherwise.
- virtual bool GetIconAt(int index, gfx::Image* icon) const = 0;
-
- // Gets the vector icon for the item at the specified index. At most one of
- // GetIconAt() and GetVectorIconAt() should be used for a single menu index.
- virtual const gfx::VectorIcon* GetVectorIconAt(int index) const;
+ // Gets the icon for the item at the specified index. ImageModel is empty if
+ // there is no icon.
+ virtual ImageModel GetIconAt(int index) const = 0;
// Returns the model for a menu item with a line of buttons at |index|.
virtual ButtonMenuItemModel* GetButtonMenuItemAt(int index) const = 0;
diff --git a/chromium/ui/base/models/simple_menu_model.cc b/chromium/ui/base/models/simple_menu_model.cc
index 6a55c0f82ce..88053e9d501 100644
--- a/chromium/ui/base/models/simple_menu_model.cc
+++ b/chromium/ui/base/models/simple_menu_model.cc
@@ -12,6 +12,9 @@
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/models/image_model.h"
+#include "ui/gfx/image/image.h"
+#include "ui/gfx/vector_icon_types.h"
namespace ui {
@@ -46,14 +49,9 @@ base::string16 SimpleMenuModel::Delegate::GetLabelForCommandId(
return base::string16();
}
-bool SimpleMenuModel::Delegate::GetIconForCommandId(
- int command_id, gfx::Image* image_skia) const {
- return false;
-}
-
-const gfx::VectorIcon* SimpleMenuModel::Delegate::GetVectorIconForCommandId(
+ImageModel SimpleMenuModel::Delegate::GetIconForCommandId(
int command_id) const {
- return nullptr;
+ return ImageModel();
}
void SimpleMenuModel::Delegate::OnMenuWillShow(SimpleMenuModel* /*source*/) {}
@@ -80,34 +78,30 @@ void SimpleMenuModel::AddItem(int command_id, const base::string16& label) {
}
void SimpleMenuModel::AddItemWithStringId(int command_id, int string_id) {
+ // Prevent this dangerous pattern:
+ // model->AddItemWithStringId(IDS_FOO, IDS_FOO);
+ // This conflates string IDs with command IDs, which are separate namespaces.
+ // Sometimes this is an accident where this is meant:
+ // model->AddItemWithStringId(IDC_FOO, IDS_FOO);
+ // but sometimes it is deliberate, usually in situations where there is no
+ // matching IDC constant or the matching IDC constant is not available.
+ // Using IDS constants for command IDs can cause confusion elsewhere, since
+ // command IDs are usually either IDC values or strictly local constants.
+ DCHECK_NE(command_id, string_id);
AddItem(command_id, l10n_util::GetStringUTF16(string_id));
}
void SimpleMenuModel::AddItemWithIcon(int command_id,
const base::string16& label,
- const gfx::ImageSkia& icon) {
- Item item(command_id, TYPE_COMMAND, label);
- item.icon = gfx::Image(icon);
- AppendItem(std::move(item));
-}
-
-void SimpleMenuModel::AddItemWithIcon(int command_id,
- const base::string16& label,
- const gfx::VectorIcon& icon) {
+ const ImageModel& icon) {
Item item(command_id, TYPE_COMMAND, label);
- item.vector_icon = &icon;
+ item.icon = icon;
AppendItem(std::move(item));
}
void SimpleMenuModel::AddItemWithStringIdAndIcon(int command_id,
int string_id,
- const gfx::ImageSkia& icon) {
- AddItemWithIcon(command_id, l10n_util::GetStringUTF16(string_id), icon);
-}
-
-void SimpleMenuModel::AddItemWithStringIdAndIcon(int command_id,
- int string_id,
- const gfx::VectorIcon& icon) {
+ const ImageModel& icon) {
AddItemWithIcon(command_id, l10n_util::GetStringUTF16(string_id), icon);
}
@@ -135,9 +129,9 @@ void SimpleMenuModel::AddRadioItemWithStringId(int command_id, int string_id,
void SimpleMenuModel::AddHighlightedItemWithIcon(int command_id,
const base::string16& label,
- const gfx::ImageSkia& icon) {
+ const ImageModel& icon) {
Item item(command_id, TYPE_HIGHLIGHTED, label);
- item.icon = gfx::Image(icon);
+ item.icon = icon;
AppendItem(std::move(item));
}
@@ -188,25 +182,13 @@ void SimpleMenuModel::AddSubMenuWithStringId(int command_id,
AddSubMenu(command_id, l10n_util::GetStringUTF16(string_id), model);
}
-void SimpleMenuModel::AddSubMenuWithStringIdAndIcon(
- int command_id,
- int string_id,
- MenuModel* model,
- const gfx::ImageSkia& icon) {
+void SimpleMenuModel::AddSubMenuWithStringIdAndIcon(int command_id,
+ int string_id,
+ MenuModel* model,
+ const ImageModel& icon) {
Item item(command_id, TYPE_SUBMENU, l10n_util::GetStringUTF16(string_id));
item.submenu = model;
- item.icon = gfx::Image(icon);
- AppendItem(std::move(item));
-}
-
-void SimpleMenuModel::AddSubMenuWithStringIdAndIcon(
- int command_id,
- int string_id,
- MenuModel* model,
- const gfx::VectorIcon& icon) {
- Item item(command_id, TYPE_SUBMENU, l10n_util::GetStringUTF16(string_id));
- item.submenu = model;
- item.vector_icon = &icon;
+ item.icon = icon;
AppendItem(std::move(item));
}
@@ -222,23 +204,11 @@ void SimpleMenuModel::AddActionableSubmenuWithStringIdAndIcon(
int command_id,
int string_id,
MenuModel* model,
- const gfx::ImageSkia& icon) {
- Item item(command_id, TYPE_ACTIONABLE_SUBMENU,
- l10n_util::GetStringUTF16(string_id));
- item.submenu = model;
- item.icon = gfx::Image(icon);
- AppendItem(std::move(item));
-}
-
-void SimpleMenuModel::AddActionableSubmenuWithStringIdAndIcon(
- int command_id,
- int string_id,
- MenuModel* model,
- const gfx::VectorIcon& icon) {
+ const ImageModel& icon) {
Item item(command_id, TYPE_ACTIONABLE_SUBMENU,
l10n_util::GetStringUTF16(string_id));
item.submenu = model;
- item.vector_icon = &icon;
+ item.icon = icon;
AppendItem(std::move(item));
}
@@ -311,17 +281,8 @@ void SimpleMenuModel::RemoveItemAt(int index) {
MenuItemsChanged();
}
-void SimpleMenuModel::SetIcon(int index, const gfx::Image& icon) {
- Item* item = &items_[ValidateItemIndex(index)];
- DCHECK(!item->vector_icon);
- item->icon = icon;
- MenuItemsChanged();
-}
-
-void SimpleMenuModel::SetIcon(int index, const gfx::VectorIcon& icon) {
- Item* item = &items_[ValidateItemIndex(index)];
- DCHECK(item->icon.IsEmpty());
- item->vector_icon = &icon;
+void SimpleMenuModel::SetIcon(int index, const ui::ImageModel& icon) {
+ items_[ValidateItemIndex(index)].icon = icon;
MenuItemsChanged();
}
@@ -336,8 +297,8 @@ void SimpleMenuModel::SetMinorText(int index,
}
void SimpleMenuModel::SetMinorIcon(int index,
- const gfx::VectorIcon& minor_icon) {
- items_[ValidateItemIndex(index)].minor_icon = &minor_icon;
+ const ui::ImageModel& minor_icon) {
+ items_[ValidateItemIndex(index)].minor_icon = minor_icon;
}
void SimpleMenuModel::SetEnabledAt(int index, bool enabled) {
@@ -374,8 +335,7 @@ int SimpleMenuModel::GetIndexOfCommandId(int command_id) const {
bool SimpleMenuModel::HasIcons() const {
for (int i = 0; i < GetItemCount(); ++i) {
- gfx::Image icon;
- if (GetIconAt(i, &icon) || GetVectorIconAt(i))
+ if (!GetIconAt(i).IsEmpty())
return true;
}
@@ -408,7 +368,7 @@ base::string16 SimpleMenuModel::GetMinorTextAt(int index) const {
return items_[ValidateItemIndex(index)].minor_text;
}
-const gfx::VectorIcon* SimpleMenuModel::GetMinorIconAt(int index) const {
+ImageModel SimpleMenuModel::GetMinorIconAt(int index) const {
return items_[ValidateItemIndex(index)].minor_icon;
}
@@ -439,23 +399,12 @@ int SimpleMenuModel::GetGroupIdAt(int index) const {
return items_[ValidateItemIndex(index)].group_id;
}
-bool SimpleMenuModel::GetIconAt(int index, gfx::Image* icon) const {
+ImageModel SimpleMenuModel::GetIconAt(int index) const {
if (IsItemDynamicAt(index))
- return delegate_->GetIconForCommandId(GetCommandIdAt(index), icon);
+ return delegate_->GetIconForCommandId(GetCommandIdAt(index));
ValidateItemIndex(index);
- if (items_[index].icon.IsEmpty())
- return false;
-
- *icon = items_[index].icon;
- return true;
-}
-
-const gfx::VectorIcon* SimpleMenuModel::GetVectorIconAt(int index) const {
- if (IsItemDynamicAt(index))
- return delegate_->GetVectorIconForCommandId(GetCommandIdAt(index));
-
- return items_[ValidateItemIndex(index)].vector_icon;
+ return items_[index].icon;
}
ButtonMenuItemModel* SimpleMenuModel::GetButtonMenuItemAt(int index) const {
diff --git a/chromium/ui/base/models/simple_menu_model.h b/chromium/ui/base/models/simple_menu_model.h
index 1ae8909a140..2b06f3f4a03 100644
--- a/chromium/ui/base/models/simple_menu_model.h
+++ b/chromium/ui/base/models/simple_menu_model.h
@@ -13,12 +13,8 @@
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "ui/base/accelerators/accelerator.h"
+#include "ui/base/models/image_model.h"
#include "ui/base/models/menu_model.h"
-#include "ui/gfx/image/image.h"
-
-namespace gfx {
-struct VectorIcon;
-}
namespace ui {
@@ -47,15 +43,8 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel {
// Some command ids have labels and icons that change over time.
virtual bool IsItemForCommandIdDynamic(int command_id) const;
virtual base::string16 GetLabelForCommandId(int command_id) const;
- // Gets the icon for the item with the specified id, returning true if there
- // is an icon, false otherwise.
- virtual bool GetIconForCommandId(int command_id,
- gfx::Image* icon) const;
-
- // Returns the vector icon for the given command id, or null if there is
- // none. Only used for dynamic menu items.
- virtual const gfx::VectorIcon* GetVectorIconForCommandId(
- int command_id) const;
+ // Gets the icon for the item with the specified id.
+ virtual ImageModel GetIconForCommandId(int command_id) const;
// Performs the action associates with the specified command id.
// The passed |event_flags| are the flags from the event which issued this
@@ -88,23 +77,17 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel {
void AddItemWithStringId(int command_id, int string_id);
void AddItemWithIcon(int command_id,
const base::string16& label,
- const gfx::ImageSkia& icon);
- void AddItemWithIcon(int command_id,
- const base::string16& label,
- const gfx::VectorIcon& icon);
+ const ui::ImageModel& icon);
void AddItemWithStringIdAndIcon(int command_id,
int string_id,
- const gfx::ImageSkia& icon);
- void AddItemWithStringIdAndIcon(int command_id,
- int string_id,
- const gfx::VectorIcon& icon);
+ const ui::ImageModel& icon);
void AddCheckItem(int command_id, const base::string16& label);
void AddCheckItemWithStringId(int command_id, int string_id);
void AddRadioItem(int command_id, const base::string16& label, int group_id);
void AddRadioItemWithStringId(int command_id, int string_id, int group_id);
void AddHighlightedItemWithIcon(int command_id,
const base::string16& label,
- const gfx::ImageSkia& icon);
+ const ui::ImageModel& icon);
void AddTitle(const base::string16& label);
// Adds a separator of the specified type to the model.
@@ -124,22 +107,14 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel {
void AddSubMenuWithStringIdAndIcon(int command_id,
int string_id,
MenuModel* model,
- const gfx::ImageSkia& icon);
- void AddSubMenuWithStringIdAndIcon(int command_id,
- int string_id,
- MenuModel* model,
- const gfx::VectorIcon& icon);
+ const ui::ImageModel& icon);
void AddActionableSubMenu(int command_id,
const base::string16& label,
MenuModel* model);
void AddActionableSubmenuWithStringIdAndIcon(int command_id,
int string_id,
MenuModel* model,
- const gfx::ImageSkia& icon);
- void AddActionableSubmenuWithStringIdAndIcon(int command_id,
- int string_id,
- MenuModel* model,
- const gfx::VectorIcon& icon);
+ const ui::ImageModel& icon);
// Methods for inserting items into the model.
void InsertItemAt(int index, int command_id, const base::string16& label);
@@ -166,10 +141,7 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel {
void RemoveItemAt(int index);
// Sets the icon for the item at |index|.
- void SetIcon(int index, const gfx::Image& icon);
-
- // As above, but uses a VectorIcon. Only one of the two should be set.
- void SetIcon(int index, const gfx::VectorIcon& icon);
+ void SetIcon(int index, const ui::ImageModel& icon);
// Sets the label for the item at |index|.
void SetLabel(int index, const base::string16& label);
@@ -178,7 +150,7 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel {
void SetMinorText(int index, const base::string16& minor_text);
// Sets the minor icon for the item at |index|.
- void SetMinorIcon(int index, const gfx::VectorIcon& minor_icon);
+ void SetMinorIcon(int index, const ui::ImageModel& minor_icon);
// Sets whether the item at |index| is enabled.
void SetEnabledAt(int index, bool enabled);
@@ -201,13 +173,12 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel {
int GetCommandIdAt(int index) const override;
base::string16 GetLabelAt(int index) const override;
base::string16 GetMinorTextAt(int index) const override;
- const gfx::VectorIcon* GetMinorIconAt(int index) const override;
+ ImageModel GetMinorIconAt(int index) const override;
bool IsItemDynamicAt(int index) const override;
bool GetAcceleratorAt(int index, ui::Accelerator* accelerator) const override;
bool IsItemCheckedAt(int index) const override;
int GetGroupIdAt(int index) const override;
- bool GetIconAt(int index, gfx::Image* icon) const override;
- const gfx::VectorIcon* GetVectorIconAt(int index) const override;
+ ImageModel GetIconAt(int index) const override;
ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const override;
bool IsEnabledAt(int index) const override;
bool IsVisibleAt(int index) const override;
@@ -236,9 +207,8 @@ class UI_BASE_EXPORT SimpleMenuModel : public MenuModel {
ItemType type = TYPE_COMMAND;
base::string16 label;
base::string16 minor_text;
- const gfx::VectorIcon* minor_icon = nullptr;
- gfx::Image icon;
- const gfx::VectorIcon* vector_icon = nullptr;
+ ImageModel minor_icon;
+ ImageModel icon;
int group_id = -1;
MenuModel* submenu = nullptr;
ButtonMenuItemModel* button_model = nullptr;
diff --git a/chromium/ui/base/models/simple_menu_model_unittest.cc b/chromium/ui/base/models/simple_menu_model_unittest.cc
index a03654196f8..4fe768d11b9 100644
--- a/chromium/ui/base/models/simple_menu_model_unittest.cc
+++ b/chromium/ui/base/models/simple_menu_model_unittest.cc
@@ -43,8 +43,10 @@ class DelegateBase : public SimpleMenuModel::Delegate {
return item_with_icon_ == command_id;
}
- bool GetIconForCommandId(int command_id, gfx::Image* icon) const override {
- return item_with_icon_ == command_id;
+ ImageModel GetIconForCommandId(int command_id) const override {
+ return item_with_icon_ == command_id
+ ? ImageModel::FromImage(gfx::test::CreateImage(16, 16))
+ : ImageModel();
}
private:
@@ -164,7 +166,7 @@ TEST(SimpleMenuModelTest, HasIconsViaAddItem) {
simple_menu_model.AddItemWithIcon(
/*command_id*/ 11, base::ASCIIToUTF16("menu item"),
- gfx::test::CreateImage(16, 16).AsImageSkia());
+ ui::ImageModel::FromImage(gfx::test::CreateImage(16, 16)));
EXPECT_TRUE(simple_menu_model.HasIcons());
}
@@ -179,7 +181,8 @@ TEST(SimpleMenuModelTest, HasIconsViaVectorIcon) {
gfx::VectorIcon circle_icon = {rep, 1, "circle"};
simple_menu_model.AddItemWithIcon(
- /*command_id*/ 11, base::ASCIIToUTF16("menu item"), circle_icon);
+ /*command_id*/ 11, base::ASCIIToUTF16("menu item"),
+ ui::ImageModel::FromVectorIcon(circle_icon));
EXPECT_TRUE(simple_menu_model.HasIcons());
}
diff --git a/chromium/ui/base/models/table_model.cc b/chromium/ui/base/models/table_model.cc
index 144ba862c0b..5275d7089e2 100644
--- a/chromium/ui/base/models/table_model.cc
+++ b/chromium/ui/base/models/table_model.cc
@@ -4,8 +4,9 @@
#include "ui/base/models/table_model.h"
+#include "base/check.h"
#include "base/i18n/string_compare.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/image/image_skia.h"
diff --git a/chromium/ui/base/models/tree_model.cc b/chromium/ui/base/models/tree_model.cc
index b30a13bdc46..a787f8cb8c4 100644
--- a/chromium/ui/base/models/tree_model.cc
+++ b/chromium/ui/base/models/tree_model.cc
@@ -4,7 +4,7 @@
#include "ui/base/models/tree_model.h"
-#include "base/logging.h"
+#include "base/notreached.h"
namespace ui {
diff --git a/chromium/ui/base/mojom/BUILD.gn b/chromium/ui/base/mojom/BUILD.gn
index fe2e9e0624c..8b330d88d52 100644
--- a/chromium/ui/base/mojom/BUILD.gn
+++ b/chromium/ui/base/mojom/BUILD.gn
@@ -7,36 +7,33 @@ import("//mojo/public/tools/bindings/mojom.gni")
mojom("mojom") {
generate_java = true
sources = [
- "cursor.mojom",
"ui_base_types.mojom",
"window_open_disposition.mojom",
]
-
- public_deps = [
- ":cursor_type",
- "//mojo/public/mojom/base",
- "//skia/public/mojom",
- "//ui/gfx/geometry/mojom",
- "//url/mojom:url_mojom_gurl",
- ]
-}
-
-mojom("cursor_type") {
- generate_java = true
-
- sources = [ "cursor_type.mojom" ]
-}
-
-source_set("unittests") {
- testonly = true
- sources = [ "cursor_mojom_traits_unittest.cc" ]
- deps = [
- ":mojom",
- "//skia/public/mojom",
- "//testing/gtest",
- "//ui/base",
- "//ui/base/cursor",
- "//ui/events",
- "//ui/gfx/geometry/mojom:mojom_traits",
+ cpp_typemaps = [
+ {
+ types = [
+ {
+ mojom = "ui.mojom.DialogButton"
+ cpp = "::ui::DialogButton"
+ },
+ {
+ mojom = "ui.mojom.ModalType"
+ cpp = "::ui::ModalType"
+ },
+ ]
+ traits_headers = [ "ui_base_types_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/base" ]
+ },
+ {
+ types = [
+ {
+ mojom = "ui.mojom.WindowOpenDisposition"
+ cpp = "::WindowOpenDisposition"
+ },
+ ]
+ traits_headers = [ "window_open_disposition_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/base" ]
+ },
]
}
diff --git a/chromium/ui/base/mojom/DEPS b/chromium/ui/base/mojom/DEPS
index 4c3c748695e..8fbb25defe1 100644
--- a/chromium/ui/base/mojom/DEPS
+++ b/chromium/ui/base/mojom/DEPS
@@ -1,6 +1,4 @@
include_rules = [
- "+mojo/public/cpp/base",
"+mojo/public/cpp/bindings",
"+third_party/blink/public/mojom/clipboard/clipboard.mojom-shared.h",
- "+skia/public/mojom"
]
diff --git a/chromium/ui/base/mojom/OWNERS b/chromium/ui/base/mojom/OWNERS
index ae29a36aac8..1feb5149750 100644
--- a/chromium/ui/base/mojom/OWNERS
+++ b/chromium/ui/base/mojom/OWNERS
@@ -2,5 +2,3 @@ per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
-per-file *.typemap=set noparent
-per-file *.typemap=file://ipc/SECURITY_OWNERS
diff --git a/chromium/ui/base/mojom/clipboard_blink.typemap b/chromium/ui/base/mojom/clipboard_blink.typemap
deleted file mode 100644
index eae5586c385..00000000000
--- a/chromium/ui/base/mojom/clipboard_blink.typemap
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright 2017 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.
-
-mojom = "//third_party/blink/public/mojom/clipboard/clipboard.mojom"
-public_headers = [ "//ui/base/clipboard/clipboard_buffer.h" ]
-traits_headers = [ "//ui/base/mojom/clipboard_blink_mojom_traits.h" ]
-public_deps = [
- "//ui/base/clipboard:clipboard_types",
-]
-type_mappings = [ "blink.mojom.ClipboardBuffer=ui::ClipboardBuffer" ]
diff --git a/chromium/ui/base/mojom/cursor.typemap b/chromium/ui/base/mojom/cursor.typemap
deleted file mode 100644
index 44f71db3da7..00000000000
--- a/chromium/ui/base/mojom/cursor.typemap
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2017 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.
-
-mojom = "//ui/base/mojom/cursor.mojom"
-public_headers = [ "//ui/base/cursor/cursor.h" ]
-traits_headers = [ "//ui/base/mojom/cursor_mojom_traits.h" ]
-sources = [ "//ui/base/mojom/cursor_mojom_traits.cc" ]
-public_deps = [ "//ui/base/cursor" ]
-deps = [
- "//ui/gfx/geometry",
- "//ui/gfx/geometry/mojom:mojom_traits",
-]
-
-type_mappings = [ "ui.mojom.Cursor=::ui::Cursor[copyable_pass_by_value]" ]
diff --git a/chromium/ui/base/mojom/typemaps.gni b/chromium/ui/base/mojom/typemaps.gni
deleted file mode 100644
index db2b54c9156..00000000000
--- a/chromium/ui/base/mojom/typemaps.gni
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-typemaps = [
- "//ui/base/mojom/clipboard_blink.typemap",
- "//ui/base/mojom/cursor.typemap",
- "//ui/base/mojom/ui_base_types.typemap",
- "//ui/base/mojom/window_open_disposition.typemap",
-]
diff --git a/chromium/ui/base/mojom/ui_base_types.typemap b/chromium/ui/base/mojom/ui_base_types.typemap
deleted file mode 100644
index e59afa79884..00000000000
--- a/chromium/ui/base/mojom/ui_base_types.typemap
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-mojom = "//ui/base/mojom/ui_base_types.mojom"
-public_headers = [ "//ui/base/ui_base_types.h" ]
-public_deps = [
- "//mojo/public/cpp/bindings",
- "//ui/base",
-]
-traits_headers = [ "//ui/base/mojom/ui_base_types_mojom_traits.h" ]
-type_mappings = [
- "ui.mojom.DialogButton=::ui::DialogButton",
- "ui.mojom.ModalType=::ui::ModalType",
-]
diff --git a/chromium/ui/base/mojom/window_open_disposition.typemap b/chromium/ui/base/mojom/window_open_disposition.typemap
deleted file mode 100644
index b3386cd4350..00000000000
--- a/chromium/ui/base/mojom/window_open_disposition.typemap
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2017 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.
-
-mojom = "//ui/base/mojom/window_open_disposition.mojom"
-public_headers = [ "//ui/base/window_open_disposition.h" ]
-public_deps = [
- "//mojo/public/cpp/bindings",
- "//ui/base",
-]
-traits_headers = [ "//ui/base/mojom/window_open_disposition_mojom_traits.h" ]
-type_mappings = [ "ui.mojom.WindowOpenDisposition=::WindowOpenDisposition" ]
diff --git a/chromium/ui/base/page_transition_types.cc b/chromium/ui/base/page_transition_types.cc
index 7f1d6e489d8..b055b4dc55b 100644
--- a/chromium/ui/base/page_transition_types.cc
+++ b/chromium/ui/base/page_transition_types.cc
@@ -4,7 +4,10 @@
#include "ui/base/page_transition_types.h"
-#include "base/logging.h"
+#include <ostream>
+
+#include "base/check_op.h"
+#include "base/notreached.h"
namespace ui {
diff --git a/chromium/ui/base/pointer/pointer_device_android.cc b/chromium/ui/base/pointer/pointer_device_android.cc
index 2113c9ae4a8..a1043e9a416 100644
--- a/chromium/ui/base/pointer/pointer_device_android.cc
+++ b/chromium/ui/base/pointer/pointer_device_android.cc
@@ -5,7 +5,7 @@
#include "ui/base/pointer/pointer_device.h"
#include "base/android/jni_array.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "ui/base/ui_base_jni_headers/TouchDevice_jni.h"
using base::android::AttachCurrentThread;
diff --git a/chromium/ui/base/pointer/pointer_device_linux.cc b/chromium/ui/base/pointer/pointer_device_linux.cc
index d30054c75e0..1d819d878c4 100644
--- a/chromium/ui/base/pointer/pointer_device_linux.cc
+++ b/chromium/ui/base/pointer/pointer_device_linux.cc
@@ -4,7 +4,7 @@
#include "ui/base/pointer/pointer_device.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "ui/events/devices/device_data_manager.h"
namespace ui {
diff --git a/chromium/ui/base/pointer/pointer_device_win.cc b/chromium/ui/base/pointer/pointer_device_win.cc
index 5f9839ea3e7..66f400e5b9a 100644
--- a/chromium/ui/base/pointer/pointer_device_win.cc
+++ b/chromium/ui/base/pointer/pointer_device_win.cc
@@ -4,7 +4,7 @@
#include "ui/base/pointer/pointer_device.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/win/win_util.h"
#include "ui/base/win/hidden_window.h"
diff --git a/chromium/ui/base/pointer/touch_editing_controller.h b/chromium/ui/base/pointer/touch_editing_controller.h
index e735129b4dc..e55fb3c9be1 100644
--- a/chromium/ui/base/pointer/touch_editing_controller.h
+++ b/chromium/ui/base/pointer/touch_editing_controller.h
@@ -19,6 +19,15 @@ namespace ui {
// using touch.
class UI_BASE_EXPORT TouchEditable : public ui::SimpleMenuModel::Delegate {
public:
+ // Commands that all TouchEditables support:
+ enum MenuCommands {
+ // Don't use command ID 0 - a lot of tests use 0 for "no command".
+ kCut = 1,
+ kCopy,
+ kPaste,
+ kLastTouchEditableCommandId = kPaste,
+ };
+
// TODO(mohsen): Consider switching from local coordinates to screen
// coordinates in this interface and see if it will simplify things.
diff --git a/chromium/ui/base/pointer/touch_ui_controller.cc b/chromium/ui/base/pointer/touch_ui_controller.cc
index 2726e035116..f594a6db23c 100644
--- a/chromium/ui/base/pointer/touch_ui_controller.cc
+++ b/chromium/ui/base/pointer/touch_ui_controller.cc
@@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/message_loop/message_loop_current.h"
#include "base/no_destructor.h"
+#include "base/trace_event/trace_event.h"
#include "ui/base/ui_base_switches.h"
#if defined(OS_WIN)
@@ -78,8 +79,10 @@ TouchUiController::~TouchUiController() = default;
void TouchUiController::OnTabletModeToggled(bool enabled) {
const bool was_touch_ui = touch_ui();
tablet_mode_ = enabled;
- if (touch_ui() != was_touch_ui)
+ if (touch_ui() != was_touch_ui) {
+ TRACE_EVENT0("ui", "TouchUiController.NotifyListeners");
callback_list_.Notify();
+ }
}
std::unique_ptr<TouchUiController::Subscription>
@@ -91,8 +94,10 @@ TouchUiController::TouchUiState TouchUiController::SetTouchUiState(
TouchUiState touch_ui_state) {
const bool was_touch_ui = touch_ui();
const TouchUiState old_state = std::exchange(touch_ui_state_, touch_ui_state);
- if (touch_ui() != was_touch_ui)
+ if (touch_ui() != was_touch_ui) {
+ TRACE_EVENT0("ui", "TouchUiController.NotifyListeners");
callback_list_.Notify();
+ }
return old_state;
}
diff --git a/chromium/ui/base/resource/data_pack_unittest.cc b/chromium/ui/base/resource/data_pack_unittest.cc
index 86e34b8ae0f..386d1841c5c 100644
--- a/chromium/ui/base/resource/data_pack_unittest.cc
+++ b/chromium/ui/base/resource/data_pack_unittest.cc
@@ -36,8 +36,8 @@ TEST(DataPackTest, LoadFromPath) {
dir.GetPath().Append(FILE_PATH_LITERAL("sample.pak"));
// Dump contents into the pak file.
- ASSERT_EQ(base::WriteFile(data_path, kSamplePakContentsV4, kSamplePakSizeV4),
- static_cast<int>(kSamplePakSizeV4));
+ ASSERT_TRUE(base::WriteFile(
+ data_path, base::StringPiece(kSamplePakContentsV4, kSamplePakSizeV4)));
// Load the file through the data pack API.
DataPack pack(SCALE_FACTOR_100P);
@@ -72,8 +72,7 @@ TEST(DataPackTest, LoadFromPathCompressed) {
std::string compressed;
ASSERT_TRUE(compression::GzipCompress(
base::StringPiece(kSamplePakContentsV4, kSamplePakSizeV4), &compressed));
- ASSERT_EQ(base::WriteFile(data_path, compressed.c_str(), compressed.length()),
- static_cast<int>(compressed.length()));
+ ASSERT_TRUE(base::WriteFile(data_path, compressed));
// Load the file through the data pack API.
DataPack pack(SCALE_FACTOR_100P);
@@ -105,8 +104,8 @@ TEST(DataPackTest, LoadFromFile) {
dir.GetPath().Append(FILE_PATH_LITERAL("sample.pak"));
// Dump contents into the pak file.
- ASSERT_EQ(base::WriteFile(data_path, kSamplePakContentsV4, kSamplePakSizeV4),
- static_cast<int>(kSamplePakSizeV4));
+ ASSERT_TRUE(base::WriteFile(
+ data_path, base::StringPiece(kSamplePakContentsV4, kSamplePakSizeV4)));
base::File file(data_path, base::File::FLAG_OPEN | base::File::FLAG_READ);
ASSERT_TRUE(file.IsValid());
@@ -142,9 +141,8 @@ TEST(DataPackTest, LoadFromFileRegion) {
// Construct a file which has a non page-aligned zero-filled header followed
// by the actual pak file content.
- const char kPadding[5678] = {0};
- ASSERT_EQ(static_cast<int>(sizeof(kPadding)),
- base::WriteFile(data_path, kPadding, sizeof(kPadding)));
+ const uint8_t kPadding[5678] = {0};
+ ASSERT_TRUE(base::WriteFile(data_path, kPadding));
ASSERT_TRUE(
base::AppendToFile(data_path, kSamplePakContentsV4, kSamplePakSizeV4));
@@ -344,8 +342,8 @@ TEST(DataPackTest, ModifiedWhileUsed) {
dir.GetPath().Append(FILE_PATH_LITERAL("sample.pak"));
// Dump contents into the pak file.
- ASSERT_EQ(base::WriteFile(data_path, kSamplePakContentsV4, kSamplePakSizeV4),
- static_cast<int>(kSamplePakSizeV4));
+ ASSERT_TRUE(base::WriteFile(
+ data_path, base::StringPiece(kSamplePakContentsV4, kSamplePakSizeV4)));
base::File file(data_path, base::File::FLAG_OPEN | base::File::FLAG_READ);
ASSERT_TRUE(file.IsValid());
@@ -358,9 +356,9 @@ TEST(DataPackTest, ModifiedWhileUsed) {
ASSERT_TRUE(pack.HasResource(10));
ASSERT_TRUE(pack.GetStringPiece(10, &data));
- ASSERT_EQ(base::WriteFile(data_path, kSampleCorruptPakContents,
- kSampleCorruptPakSize),
- static_cast<int>(kSampleCorruptPakSize));
+ ASSERT_TRUE(base::WriteFile(
+ data_path,
+ base::StringPiece(kSampleCorruptPakContents, kSampleCorruptPakSize)));
// Reading asset #10 should now fail as it extends past the end of the file.
ASSERT_TRUE(pack.HasResource(10));
diff --git a/chromium/ui/base/resource/resource_bundle.h b/chromium/ui/base/resource/resource_bundle.h
index 3daa73bdc6d..0b62c5dba94 100644
--- a/chromium/ui/base/resource/resource_bundle.h
+++ b/chromium/ui/base/resource/resource_bundle.h
@@ -120,7 +120,8 @@ class UI_BASE_EXPORT ResourceBundle {
};
// Initialize the ResourceBundle for this process. Does not take ownership of
- // the |delegate| value. Returns the language selected.
+ // the |delegate| value. Returns the language selected or an empty string if
+ // initialization failed (e.g. resource bundle not found or corrupted).
// NOTE: Mac ignores this and always loads up resources for the language
// defined by the Cocoa UI (i.e., NSBundle does the language work).
//
@@ -194,11 +195,12 @@ class UI_BASE_EXPORT ResourceBundle {
ScaleFactor scale_factor);
// Changes the locale for an already-initialized ResourceBundle, returning the
- // name of the newly-loaded locale. Future calls to get strings will return
- // the strings for this new locale. This has no effect on existing or future
- // image resources. |locale_resources_data_| is protected by a lock for the
- // duration of the swap, as GetLocalizedString() may be concurrently invoked
- // on another thread.
+ // name of the newly-loaded locale, or an empty string if initialization
+ // failed (e.g. resource bundle not found or corrupted). Future calls to get
+ // strings will return the strings for this new locale. This has no effect on
+ // existing or future image resources. |locale_resources_data_| is protected
+ // by a lock for the duration of the swap, as GetLocalizedString() may be
+ // concurrently invoked on another thread.
std::string ReloadLocaleResources(const std::string& pref_locale);
// Gets image with the specified resource_id from the current module data.
diff --git a/chromium/ui/base/resource/resource_bundle_fuchsia.cc b/chromium/ui/base/resource/resource_bundle_fuchsia.cc
index 92b25bdf740..e4139f25896 100644
--- a/chromium/ui/base/resource/resource_bundle_fuchsia.cc
+++ b/chromium/ui/base/resource/resource_bundle_fuchsia.cc
@@ -4,7 +4,6 @@
#include "ui/base/resource/resource_bundle.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "ui/gfx/image/image.h"
diff --git a/chromium/ui/base/resource/resource_bundle_unittest.cc b/chromium/ui/base/resource/resource_bundle_unittest.cc
index b038ccc23f8..904695c9291 100644
--- a/chromium/ui/base/resource/resource_bundle_unittest.cc
+++ b/chromium/ui/base/resource/resource_bundle_unittest.cc
@@ -10,10 +10,10 @@
#include "base/base_paths.h"
#include "base/big_endian.h"
+#include "base/check_op.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/logging.h"
#include "base/memory/ref_counted_memory.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -258,9 +258,9 @@ TEST_F(ResourceBundleTest, IsGzipped) {
base::FilePath data_path =
temp_dir_.GetPath().Append(FILE_PATH_LITERAL("sample.pak"));
// Dump contents into a pak file and load it.
- ASSERT_EQ(base::WriteFile(data_path, kSampleCompressPakContentsV5,
- kSampleCompressPakSizeV5),
- static_cast<int>(kSampleCompressPakSizeV5));
+ ASSERT_TRUE(
+ base::WriteFile(data_path, base::StringPiece(kSampleCompressPakContentsV5,
+ kSampleCompressPakSizeV5)));
ResourceBundle* resource_bundle = CreateResourceBundle(nullptr);
resource_bundle->AddDataPackFromPath(data_path, SCALE_FACTOR_100P);
@@ -277,9 +277,9 @@ TEST_F(ResourceBundleTest, IsBrotli) {
base::FilePath data_path =
temp_dir_.GetPath().Append(FILE_PATH_LITERAL("sample.pak"));
// Dump contents into a pak file and load it.
- ASSERT_EQ(base::WriteFile(data_path, kSampleCompressPakContentsV5,
- kSampleCompressPakSizeV5),
- static_cast<int>(kSampleCompressPakSizeV5));
+ ASSERT_TRUE(
+ base::WriteFile(data_path, base::StringPiece(kSampleCompressPakContentsV5,
+ kSampleCompressPakSizeV5)));
ResourceBundle* resource_bundle = CreateResourceBundle(nullptr);
resource_bundle->AddDataPackFromPath(data_path, SCALE_FACTOR_100P);
@@ -377,8 +377,8 @@ class ResourceBundleImageTest : public ResourceBundleTest {
// Write an empty data pak for locale data.
const base::FilePath& locale_path = dir_path().Append(
FILE_PATH_LITERAL("locale.pak"));
- EXPECT_EQ(base::WriteFile(locale_path, kEmptyPakContents, kEmptyPakSize),
- static_cast<int>(kEmptyPakSize));
+ EXPECT_TRUE(base::WriteFile(
+ locale_path, base::StringPiece(kEmptyPakContents, kEmptyPakSize)));
ui::ResourceBundle* resource_bundle = CreateResourceBundle(nullptr);
@@ -406,9 +406,9 @@ TEST_F(ResourceBundleImageTest, LoadDataResourceBytes) {
base::FilePath data_path = dir_path().Append(FILE_PATH_LITERAL("sample.pak"));
// Dump contents into the pak files.
- ASSERT_EQ(base::WriteFile(data_path, kSampleCompressPakContentsV5,
- kSampleCompressPakSizeV5),
- static_cast<int>(kSampleCompressPakSizeV5));
+ ASSERT_TRUE(
+ base::WriteFile(data_path, base::StringPiece(kSampleCompressPakContentsV5,
+ kSampleCompressPakSizeV5)));
// Load pak file.
ResourceBundle* resource_bundle = CreateResourceBundleWithEmptyLocalePak();
@@ -439,8 +439,8 @@ TEST_F(ResourceBundleImageTest, LoadDataResourceBytesNotFound) {
base::FilePath data_path = dir_path().Append(FILE_PATH_LITERAL("sample.pak"));
// Dump contents into the pak files.
- ASSERT_EQ(base::WriteFile(data_path, kEmptyPakContents,
- kEmptyPakSize), static_cast<int>(kEmptyPakSize));
+ ASSERT_TRUE(base::WriteFile(
+ data_path, base::StringPiece(kEmptyPakContents, kEmptyPakSize)));
// Create a resource bundle from the file.
ResourceBundle* resource_bundle = CreateResourceBundleWithEmptyLocalePak();
@@ -464,12 +464,12 @@ TEST_F(ResourceBundleImageTest, LoadDataResourceStringForScale) {
dir_path().Append(FILE_PATH_LITERAL("sample_2x.pak"));
// Dump content into pak files.
- ASSERT_EQ(base::WriteFile(data_path, kSampleCompressPakContentsV5,
- kSampleCompressPakSizeV5),
- static_cast<int>(kSampleCompressPakSizeV5));
- ASSERT_EQ(base::WriteFile(data_2x_path, kSampleCompressScaledPakContents,
- kSampleCompressScaledPakSize),
- static_cast<int>(kSampleCompressScaledPakSize));
+ ASSERT_TRUE(
+ base::WriteFile(data_path, base::StringPiece(kSampleCompressPakContentsV5,
+ kSampleCompressPakSizeV5)));
+ ASSERT_TRUE(base::WriteFile(
+ data_2x_path, base::StringPiece(kSampleCompressScaledPakContents,
+ kSampleCompressScaledPakSize)));
// Load pak files.
ResourceBundle* resource_bundle = CreateResourceBundleWithEmptyLocalePak();
@@ -487,9 +487,9 @@ TEST_F(ResourceBundleImageTest, LoadDataResourceStringForScale) {
TEST_F(ResourceBundleImageTest, LoadLocalizedResourceString) {
base::FilePath data_path = dir_path().Append(FILE_PATH_LITERAL("sample.pak"));
// Dump content into pak file.
- ASSERT_EQ(base::WriteFile(data_path, kSampleCompressPakContentsV5,
- kSampleCompressPakSizeV5),
- static_cast<int>(kSampleCompressPakSizeV5));
+ ASSERT_TRUE(
+ base::WriteFile(data_path, base::StringPiece(kSampleCompressPakContentsV5,
+ kSampleCompressPakSizeV5)));
// Load pak file.
ResourceBundle* resource_bundle = CreateResourceBundleWithEmptyLocalePak();
resource_bundle->AddDataPackFromPath(data_path, SCALE_FACTOR_NONE);
@@ -502,9 +502,9 @@ TEST_F(ResourceBundleImageTest, LoadLocalizedResourceString) {
TEST_F(ResourceBundleImageTest, LoadDataResourceString) {
base::FilePath data_path = dir_path().Append(FILE_PATH_LITERAL("sample.pak"));
// Dump content into pak file.
- ASSERT_EQ(base::WriteFile(data_path, kSampleCompressPakContentsV5,
- kSampleCompressPakSizeV5),
- static_cast<int>(kSampleCompressPakSizeV5));
+ ASSERT_TRUE(
+ base::WriteFile(data_path, base::StringPiece(kSampleCompressPakContentsV5,
+ kSampleCompressPakSizeV5)));
// Load pak file.
ResourceBundle* resource_bundle = CreateResourceBundleWithEmptyLocalePak();
resource_bundle->AddDataPackFromPath(data_path, SCALE_FACTOR_NONE);
@@ -525,10 +525,10 @@ TEST_F(ResourceBundleImageTest, GetRawDataResource) {
dir_path().Append(FILE_PATH_LITERAL("sample_2x.pak"));
// Dump contents into the pak files.
- ASSERT_EQ(base::WriteFile(data_path, kSamplePakContentsV4, kSamplePakSizeV4),
- static_cast<int>(kSamplePakSizeV4));
- ASSERT_EQ(base::WriteFile(data_2x_path, kSamplePakContents2x,
- kSamplePakSize2x), static_cast<int>(kSamplePakSize2x));
+ ASSERT_TRUE(base::WriteFile(
+ data_path, base::StringPiece(kSamplePakContentsV4, kSamplePakSizeV4)));
+ ASSERT_TRUE(base::WriteFile(
+ data_2x_path, base::StringPiece(kSamplePakContents2x, kSamplePakSize2x)));
// Load the regular and 2x pak files.
ResourceBundle* resource_bundle = CreateResourceBundleWithEmptyLocalePak();
diff --git a/chromium/ui/base/resource/resource_bundle_win.cc b/chromium/ui/base/resource/resource_bundle_win.cc
index d9f74a5656e..1cf3aaffc76 100644
--- a/chromium/ui/base/resource/resource_bundle_win.cc
+++ b/chromium/ui/base/resource/resource_bundle_win.cc
@@ -4,7 +4,6 @@
#include "ui/base/resource/resource_bundle_win.h"
-#include "base/logging.h"
#include "base/path_service.h"
#include "base/strings/utf_string_conversions.h"
#include "skia/ext/image_operations.h"
diff --git a/chromium/ui/base/resource/resource_data_dll_win.cc b/chromium/ui/base/resource/resource_data_dll_win.cc
index 74dd1c40b5d..77a1c3c4962 100644
--- a/chromium/ui/base/resource/resource_data_dll_win.cc
+++ b/chromium/ui/base/resource/resource_data_dll_win.cc
@@ -6,7 +6,7 @@
#include <stddef.h>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/memory/ref_counted_memory.h"
#include "base/win/resource_util.h"
diff --git a/chromium/ui/base/template_expressions.cc b/chromium/ui/base/template_expressions.cc
index b3f2c279cc7..2d7af5e5bc4 100644
--- a/chromium/ui/base/template_expressions.cc
+++ b/chromium/ui/base/template_expressions.cc
@@ -6,7 +6,7 @@
#include <stddef.h>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/optional.h"
#include "base/stl_util.h"
#include "base/values.h"
@@ -65,22 +65,23 @@ HtmlTemplate FindHtmlTemplate(const base::StringPiece& source) {
}
// Escape quotes and backslashes ('"\).
-std::string PolymerParameterEscape(const std::string& in_string) {
+std::string PolymerParameterEscape(const std::string& in_string,
+ bool is_javascript) {
std::string out;
out.reserve(in_string.size() * 2);
for (const char c : in_string) {
switch (c) {
case '\\':
- out.append("\\\\");
+ out.append(is_javascript ? R"(\\\\)" : R"(\\)");
break;
case '\'':
- out.append("\\'");
+ out.append(is_javascript ? R"(\\')" : R"(\')");
break;
case '"':
out.append("&quot;");
break;
case ',':
- out.append("\\\\,");
+ out.append(is_javascript ? R"(\\,)" : R"(\,)");
break;
default:
out += c;
@@ -130,7 +131,8 @@ bool ReplaceTemplateExpressionsInternal(
base::StringPiece source,
const ui::TemplateReplacements& replacements,
bool is_javascript,
- std::string* formatted) {
+ std::string* formatted,
+ bool skip_unexpected_placeholder_check = false) {
const size_t kValueLengthGuess = 16;
formatted->reserve(source.length() + replacements.size() * kValueLengthGuess);
// Two position markers are used as cursors through the |source|.
@@ -182,7 +184,7 @@ bool ReplaceTemplateExpressionsInternal(
// Pass the replacement through unchanged.
} else if (context == "Polymer") {
// Escape quotes and backslash for '$i18nPolymer{}' use (i.e. quoted).
- replacement = PolymerParameterEscape(replacement);
+ replacement = PolymerParameterEscape(replacement, is_javascript);
} else {
CHECK(false) << "Unknown context " << context;
}
@@ -190,7 +192,7 @@ bool ReplaceTemplateExpressionsInternal(
#if DCHECK_IS_ON()
// Replacements in Polymer WebUI may invoke JavaScript to replace string
// placeholders. In other contexts, placeholders should already be replaced.
- if (context != "Polymer") {
+ if (!skip_unexpected_placeholder_check && context != "Polymer") {
DCHECK(!HasUnexpectedPlaceholder(key, replacement))
<< "Dangling placeholder found in " << key;
}
@@ -263,11 +265,12 @@ bool ReplaceTemplateExpressionsInJS(base::StringPiece source,
return true;
}
-std::string ReplaceTemplateExpressions(
- base::StringPiece source,
- const TemplateReplacements& replacements) {
+std::string ReplaceTemplateExpressions(base::StringPiece source,
+ const TemplateReplacements& replacements,
+ bool skip_unexpected_placeholder_check) {
std::string formatted;
- ReplaceTemplateExpressionsInternal(source, replacements, false, &formatted);
+ ReplaceTemplateExpressionsInternal(source, replacements, false, &formatted,
+ skip_unexpected_placeholder_check);
return formatted;
}
} // namespace ui
diff --git a/chromium/ui/base/template_expressions.h b/chromium/ui/base/template_expressions.h
index a2768258553..a12f5b2fad8 100644
--- a/chromium/ui/base/template_expressions.h
+++ b/chromium/ui/base/template_expressions.h
@@ -35,7 +35,8 @@ UI_BASE_EXPORT void TemplateReplacementsFromDictionaryValue(
// be unaltered.
UI_BASE_EXPORT std::string ReplaceTemplateExpressions(
base::StringPiece source,
- const TemplateReplacements& replacements);
+ const TemplateReplacements& replacements,
+ bool skip_unexpected_placeholder_check = false);
// Replace $i18n*{foo} in the HTML template contained in |source| with the
// value for the foo key in |replacements| and return the result in |output|.
diff --git a/chromium/ui/base/template_expressions_unittest.cc b/chromium/ui/base/template_expressions_unittest.cc
index eee1bee3327..8e646b4c5c6 100644
--- a/chromium/ui/base/template_expressions_unittest.cc
+++ b/chromium/ui/base/template_expressions_unittest.cc
@@ -58,6 +58,20 @@ TEST(TemplateExpressionsTest, ReplaceTemplateExpressionsRaw) {
ReplaceTemplateExpressions("$i18nRaw{rawSample}", substitutions));
}
+TEST(TemplateExpressionsTest, ReplaceTemplateExpressionsSkipPlaceholderCheck) {
+ static TemplateReplacements substitutions;
+ substitutions["rawSample"] = "$1";
+ // Skips DCHECK if |skip_unexpected_placeholder_check| is true.
+ ReplaceTemplateExpressions("$i18nRaw{rawSample}", substitutions,
+ /* skip_unexpected_placeholder_check= */ true);
+ EXPECT_DCHECK_DEATH(ReplaceTemplateExpressions(
+ "$i18nRaw{rawSample}", substitutions,
+ /* skip_unexpected_placeholder_check= */ false));
+ // |skip_unexpected_placeholder_check|'s default value is false.
+ EXPECT_DCHECK_DEATH(
+ ReplaceTemplateExpressions("$i18nRaw{rawSample}", substitutions));
+}
+
TEST(TemplateExpressionsTest, ReplaceTemplateExpressionsPolymerQuoting) {
static TemplateReplacements substitutions;
substitutions["singleSample"] = "don't do it";
@@ -76,14 +90,14 @@ TEST(TemplateExpressionsTest, ReplaceTemplateExpressionsPolymerQuoting) {
TEST(TemplateExpressionsTest, ReplaceTemplateExpressionsPolymerMixed) {
static TemplateReplacements substitutions;
- substitutions["punctuationSample"] = "a\"b'c<d>e&f,g";
+ substitutions["punctuationSample"] = R"(a"b'c<d>e&f,g)";
substitutions["htmlSample"] = "<div>hello</div>";
- EXPECT_EQ("a&quot;b\\'c<d>e&f\\\\,g",
+ EXPECT_EQ(R"(a&quot;b\'c<d>e&f\,g)",
ReplaceTemplateExpressions("$i18nPolymer{punctuationSample}",
substitutions));
EXPECT_EQ("<div>hello</div>", ReplaceTemplateExpressions(
"$i18nPolymer{htmlSample}", substitutions));
- EXPECT_EQ("multiple: <div>hello</div>, a&quot;b\\'c<d>e&f\\\\,g.",
+ EXPECT_EQ(R"(multiple: <div>hello</div>, a&quot;b\'c<d>e&f\,g.)",
ReplaceTemplateExpressions("multiple: $i18nPolymer{htmlSample}, "
"$i18nPolymer{punctuationSample}.",
substitutions));
@@ -561,4 +575,33 @@ TEST(TemplateExpressionsTest, JSMultipleTemplates) {
}
}
+TEST(TemplateExpressionsTest, ReplaceTemplateExpressionsPolymerQuotingJS) {
+ static TemplateReplacements substitutions;
+ substitutions["quotesAndCommas"] = R"(don't "moo", they said)";
+ substitutions["backslashes"] = R"(\ \\ \n \r \t \b \f \0)";
+ const TestCase kTestCases[] = {
+ // Case: quotesAndCommas
+ {R"(<!--_html_template_start_-->
+ <div>[[Call('$i18nPolymer{quotesAndCommas}')]]</div>
+ <!--_html_template_end_-->)",
+ R"(<!--_html_template_start_-->
+ <div>[[Call('don\\'t &quot;moo&quot;\\, they said')]]</div>
+ <!--_html_template_end_-->)"},
+ // Case: backslashes
+ {R"(<!--_html_template_start_-->
+ <div>[[Call('$i18nPolymer{backslashes}')]]</div>
+ <!--_html_template_end_-->)",
+ R"(<!--_html_template_start_-->
+ <div>[[Call('\\\\ \\\\\\\\ \\\\n \\\\r \\\\t \\\\b \\\\f \\\\0')]]</div>
+ <!--_html_template_end_-->)"},
+ };
+ std::string formatted;
+ for (const TestCase test_case : kTestCases) {
+ ASSERT_TRUE(ReplaceTemplateExpressionsInJS(test_case.js_in, substitutions,
+ &formatted));
+ EXPECT_EQ(test_case.expected_out, formatted);
+ formatted.clear();
+ }
+}
+
} // namespace ui
diff --git a/chromium/ui/base/text/bytes_formatting.cc b/chromium/ui/base/text/bytes_formatting.cc
index 4596414cfb8..999e29ffe6b 100644
--- a/chromium/ui/base/text/bytes_formatting.cc
+++ b/chromium/ui/base/text/bytes_formatting.cc
@@ -4,8 +4,9 @@
#include "ui/base/text/bytes_formatting.h"
+#include "base/check.h"
#include "base/i18n/number_formatting.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chromium/ui/base/ui_base_features.cc b/chromium/ui/base/ui_base_features.cc
index f81a6d8a531..7050729f302 100644
--- a/chromium/ui/base/ui_base_features.cc
+++ b/chromium/ui/base/ui_base_features.cc
@@ -96,10 +96,19 @@ const base::Feature kCompositorThreadedScrollbarScrolling = {
// Enables the use of a touch fling curve that is based on the behavior of
// native apps on Windows.
-const base::Feature kExperimentalFlingAnimation{
- "ExperimentalFlingAnimation", base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kExperimentalFlingAnimation {
+ "ExperimentalFlingAnimation",
+#if defined(OS_WIN) || (defined(OS_LINUX) && !defined(OS_CHROMEOS))
+ base::FEATURE_ENABLED_BY_DEFAULT
+#else
+ base::FEATURE_DISABLED_BY_DEFAULT
+#endif
+};
#if defined(OS_WIN)
+const base::Feature kElasticOverscrollWin = {"ElasticOverscrollWin",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+
// Enables InputPane API for controlling on screen keyboard.
const base::Feature kInputPaneOnScreenKeyboard = {
"InputPaneOnScreenKeyboard", base::FEATURE_ENABLED_BY_DEFAULT};
@@ -183,13 +192,6 @@ bool IsUseCommonSelectPopupEnabled() {
const base::Feature kWebUIA11yEnhancements{"WebUIA11yEnhancements",
base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kEnableOzoneDrmMojo = {"OzoneDrmMojo",
- base::FEATURE_ENABLED_BY_DEFAULT};
-
-bool IsOzoneDrmMojo() {
- return base::FeatureList::IsEnabled(kEnableOzoneDrmMojo);
-}
-
#if defined(OS_CHROMEOS)
const base::Feature kHandwritingGesture = {"HandwritingGesture",
base::FEATURE_DISABLED_BY_DEFAULT};
diff --git a/chromium/ui/base/ui_base_features.h b/chromium/ui/base/ui_base_features.h
index d1c07ab9fe0..83d7157f8d0 100644
--- a/chromium/ui/base/ui_base_features.h
+++ b/chromium/ui/base/ui_base_features.h
@@ -47,6 +47,8 @@ COMPONENT_EXPORT(UI_BASE_FEATURES) bool IsUiGpuRasterizationEnabled();
COMPONENT_EXPORT(UI_BASE_FEATURES)
extern const base::Feature kCalculateNativeWinOcclusion;
COMPONENT_EXPORT(UI_BASE_FEATURES)
+extern const base::Feature kElasticOverscrollWin;
+COMPONENT_EXPORT(UI_BASE_FEATURES)
extern const base::Feature kInputPaneOnScreenKeyboard;
COMPONENT_EXPORT(UI_BASE_FEATURES)
extern const base::Feature kPointerEventsForTouch;
@@ -81,14 +83,6 @@ COMPONENT_EXPORT(UI_BASE_FEATURES)
extern const base::Feature kUseCommonSelectPopup;
COMPONENT_EXPORT(UI_BASE_FEATURES) bool IsUseCommonSelectPopupEnabled();
-// Use mojo communication in the drm platform instead of paramtraits. Remove
-// this switch (and associated code) when the drm platform always uses mojo
-// communication.
-// TODO(rjkroege): Remove in http://crbug.com/806092.
-COMPONENT_EXPORT(UI_BASE_FEATURES)
-extern const base::Feature kEnableOzoneDrmMojo;
-COMPONENT_EXPORT(UI_BASE_FEATURES) bool IsOzoneDrmMojo();
-
#if defined(OS_CHROMEOS)
COMPONENT_EXPORT(UI_BASE_FEATURES)
extern const base::Feature kHandwritingGesture;
diff --git a/chromium/ui/base/ui_base_paths.cc b/chromium/ui/base/ui_base_paths.cc
index 61e83855e03..82448af8754 100644
--- a/chromium/ui/base/ui_base_paths.cc
+++ b/chromium/ui/base/ui_base_paths.cc
@@ -7,7 +7,6 @@
#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
-#include "base/logging.h"
#include "base/path_service.h"
#include "build/build_config.h"
diff --git a/chromium/ui/base/ui_features.gni b/chromium/ui/base/ui_features.gni
index c3c412747b6..5ac2e9ce288 100644
--- a/chromium/ui/base/ui_features.gni
+++ b/chromium/ui/base/ui_features.gni
@@ -12,7 +12,7 @@ declare_args() {
has_native_accessibility = use_atk || is_win || is_mac
# Whether the message center should be included for displaying notifications.
- enable_message_center = is_win || is_mac || is_linux
+ enable_message_center = is_win || is_mac || is_linux || is_fuchsia
}
enable_hidpi = is_mac || is_win || is_linux || is_ios
diff --git a/chromium/ui/base/user_activity/user_activity_detector_unittest.cc b/chromium/ui/base/user_activity/user_activity_detector_unittest.cc
index d19d452cd97..eb26013e179 100644
--- a/chromium/ui/base/user_activity/user_activity_detector_unittest.cc
+++ b/chromium/ui/base/user_activity/user_activity_detector_unittest.cc
@@ -139,7 +139,7 @@ TEST_F(UserActivityDetectorTest, Basic) {
AdvanceTime(advance_delta);
ui::TouchEvent touch_event(
ui::ET_TOUCH_PRESSED, gfx::Point(), base::TimeTicks(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
OnEvent(&touch_event);
EXPECT_FALSE(touch_event.handled());
EXPECT_EQ(now_, detector_->last_activity_time());
diff --git a/chromium/ui/base/webui/i18n_source_stream.cc b/chromium/ui/base/webui/i18n_source_stream.cc
index d3327218f07..9aa3589988e 100644
--- a/chromium/ui/base/webui/i18n_source_stream.cc
+++ b/chromium/ui/base/webui/i18n_source_stream.cc
@@ -7,7 +7,7 @@
#include <algorithm>
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/strings/string_piece.h"
#include "net/base/io_buffer.h"
diff --git a/chromium/ui/base/webui/jstemplate_builder.cc b/chromium/ui/base/webui/jstemplate_builder.cc
index c101158c48e..b2b2b142275 100644
--- a/chromium/ui/base/webui/jstemplate_builder.cc
+++ b/chromium/ui/base/webui/jstemplate_builder.cc
@@ -7,9 +7,10 @@
#include "ui/base/webui/jstemplate_builder.h"
+#include "base/check.h"
#include "base/json/json_file_value_serializer.h"
#include "base/json/json_string_value_serializer.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/strings/string_util.h"
#include "ui/base/layout.h"
#include "ui/base/resource/resource_bundle.h"
diff --git a/chromium/ui/base/win/accessibility_misc_utils.cc b/chromium/ui/base/win/accessibility_misc_utils.cc
index 4bd2cdf5135..a5d3c7af4c7 100644
--- a/chromium/ui/base/win/accessibility_misc_utils.cc
+++ b/chromium/ui/base/win/accessibility_misc_utils.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "ui/base/win/accessibility_misc_utils.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/base/win/atl_module.h"
namespace base {
diff --git a/chromium/ui/base/win/hwnd_subclass.cc b/chromium/ui/base/win/hwnd_subclass.cc
index 8d92ece82c3..6b35766a9b4 100644
--- a/chromium/ui/base/win/hwnd_subclass.cc
+++ b/chromium/ui/base/win/hwnd_subclass.cc
@@ -6,7 +6,7 @@
#include <algorithm>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/memory/singleton.h"
diff --git a/chromium/ui/base/win/lock_state.cc b/chromium/ui/base/win/lock_state.cc
index 97748f0b9d5..995c38454f3 100644
--- a/chromium/ui/base/win/lock_state.cc
+++ b/chromium/ui/base/win/lock_state.cc
@@ -8,7 +8,6 @@
#include <wtsapi32.h>
#include "base/bind.h"
-#include "base/logging.h"
#include "base/no_destructor.h"
#include "base/win/windows_version.h"
#include "ui/base/win/session_change_observer.h"
diff --git a/chromium/ui/base/win/scoped_ole_initializer.cc b/chromium/ui/base/win/scoped_ole_initializer.cc
index d3d72f883b8..5b116af4afb 100644
--- a/chromium/ui/base/win/scoped_ole_initializer.cc
+++ b/chromium/ui/base/win/scoped_ole_initializer.cc
@@ -6,7 +6,7 @@
#include <ole2.h>
-#include "base/logging.h"
+#include "base/check_op.h"
namespace ui {
diff --git a/chromium/ui/base/x/BUILD.gn b/chromium/ui/base/x/BUILD.gn
index 76584b2ac9a..0daf5090985 100644
--- a/chromium/ui/base/x/BUILD.gn
+++ b/chromium/ui/base/x/BUILD.gn
@@ -15,6 +15,8 @@ jumbo_component("x") {
sources = [
"selection_utils.cc",
"selection_utils.h",
+ "x11_desktop_window_move_client.cc",
+ "x11_desktop_window_move_client.h",
"x11_display_manager.cc",
"x11_display_manager.h",
"x11_display_util.cc",
@@ -23,6 +25,8 @@ jumbo_component("x") {
"x11_menu_list.h",
"x11_menu_registrar.cc",
"x11_menu_registrar.h",
+ "x11_move_loop.h",
+ "x11_move_loop_delegate.h",
"x11_pointer_grab.cc",
"x11_pointer_grab.h",
"x11_shm_image_pool.cc",
@@ -34,6 +38,8 @@ jumbo_component("x") {
"x11_util.cc",
"x11_util.h",
"x11_util_internal.h",
+ "x11_whole_screen_move_loop.cc",
+ "x11_whole_screen_move_loop.h",
"x11_window.cc",
"x11_window.h",
"x11_workspace_handler.cc",
@@ -53,10 +59,7 @@ jumbo_component("x") {
]
}
- configs += [
- "//build/config/linux:x11",
- "//build/config/linux:xrandr",
- ]
+ public_configs = [ "//build/config/linux:xrandr" ]
defines = [ "IS_UI_BASE_X_IMPL" ]
@@ -65,6 +68,7 @@ jumbo_component("x") {
"//base:i18n",
"//net",
"//skia",
+ "//ui/base:data_exchange",
"//ui/base:hit_test",
"//ui/base:wm_role_names",
"//ui/base/clipboard:clipboard_types",
@@ -80,3 +84,34 @@ jumbo_component("x") {
"//ui/platform_window/common",
]
}
+
+source_set("gl") {
+ sources = [
+ "x11_gl_egl_utility.cc",
+ "x11_gl_egl_utility.h",
+ ]
+
+ configs += [ "//third_party/khronos:khronos_headers" ]
+ deps = [
+ ":x",
+ "//base",
+ "//third_party/angle:includes",
+ "//ui/gfx/x",
+ "//ui/gl",
+ ]
+}
+
+source_set("test_support") {
+ testonly = true
+
+ sources = [
+ "test/x11_property_change_waiter.cc",
+ "test/x11_property_change_waiter.h",
+ ]
+
+ deps = [
+ "//ui/events:platform_event",
+ "//ui/events/platform/x11",
+ "//ui/gfx/x",
+ ]
+}
diff --git a/chromium/ui/base/x/DEPS b/chromium/ui/base/x/DEPS
index edeb0030468..4a0553fdd96 100644
--- a/chromium/ui/base/x/DEPS
+++ b/chromium/ui/base/x/DEPS
@@ -1,3 +1,5 @@
include_rules = [
"+ui/platform_window/common/platform_window_defaults.h",
+ "+ui/gl/gl_surface_egl.h",
+ "+third_party/khronos/EGL/egl.h",
]
diff --git a/chromium/ui/base/x/OWNERS b/chromium/ui/base/x/OWNERS
index 3d049464c44..b33ceac9288 100644
--- a/chromium/ui/base/x/OWNERS
+++ b/chromium/ui/base/x/OWNERS
@@ -1,2 +1,3 @@
sadrul@chromium.org
thomasanderson@chromium.org
+msisov@igalia.com
diff --git a/chromium/ui/base/x/selection_utils.cc b/chromium/ui/base/x/selection_utils.cc
index 972fb5e1e81..a5eaa7443e0 100644
--- a/chromium/ui/base/x/selection_utils.cc
+++ b/chromium/ui/base/x/selection_utils.cc
@@ -9,7 +9,7 @@
#include <set>
#include "base/i18n/icu_string_conversions.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
diff --git a/chromium/ui/base/x/x11_desktop_window_move_client.cc b/chromium/ui/base/x/x11_desktop_window_move_client.cc
new file mode 100644
index 00000000000..9b810e0f39e
--- /dev/null
+++ b/chromium/ui/base/x/x11_desktop_window_move_client.cc
@@ -0,0 +1,43 @@
+// Copyright (c) 2012 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 "ui/base/x/x11_desktop_window_move_client.h"
+
+#include "ui/base/x/x11_util.h"
+#include "ui/base/x/x11_window.h"
+#include "ui/events/event.h"
+#include "ui/gfx/x/x11.h"
+
+namespace ui {
+
+X11DesktopWindowMoveClient::X11DesktopWindowMoveClient(ui::XWindow* window)
+ : window_(window) {}
+
+X11DesktopWindowMoveClient::~X11DesktopWindowMoveClient() = default;
+
+void X11DesktopWindowMoveClient::OnMouseMovement(const gfx::Point& screen_point,
+ int flags,
+ base::TimeTicks event_time) {
+ gfx::Point system_loc = screen_point - window_offset_;
+ window_->SetBounds(gfx::Rect(system_loc, window_->bounds().size()));
+}
+
+void X11DesktopWindowMoveClient::OnMouseReleased() {
+ EndMoveLoop();
+}
+
+void X11DesktopWindowMoveClient::OnMoveLoopEnded() {}
+
+bool X11DesktopWindowMoveClient::RunMoveLoop(bool can_grab_pointer,
+ const gfx::Vector2d& drag_offset) {
+ window_offset_ = drag_offset;
+ return move_loop_.RunMoveLoop(can_grab_pointer, window_->last_cursor(),
+ window_->last_cursor());
+}
+
+void X11DesktopWindowMoveClient::EndMoveLoop() {
+ move_loop_.EndMoveLoop();
+}
+
+} // namespace ui
diff --git a/chromium/ui/views/widget/desktop_aura/x11_desktop_window_move_client.h b/chromium/ui/base/x/x11_desktop_window_move_client.h
index 3305ca520bc..aaa32c3c16c 100644
--- a/chromium/ui/views/widget/desktop_aura/x11_desktop_window_move_client.h
+++ b/chromium/ui/base/x/x11_desktop_window_move_client.h
@@ -2,30 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_
-#define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_
+#ifndef UI_BASE_X_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_
+#define UI_BASE_X_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_
#include "base/callback.h"
#include "base/compiler_specific.h"
+#include "base/component_export.h"
+#include "ui/base/x/x11_move_loop_delegate.h"
+#include "ui/base/x/x11_whole_screen_move_loop.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/x/x11.h"
-#include "ui/views/views_export.h"
-#include "ui/views/widget/desktop_aura/x11_move_loop_delegate.h"
-#include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h"
-#include "ui/wm/public/window_move_client.h"
-namespace aura {
-class WindowTreeHost;
-}
+namespace ui {
-namespace views {
+class XWindow;
// When we're dragging tabs, we need to manually position our window.
-class VIEWS_EXPORT X11DesktopWindowMoveClient
- : public views::X11MoveLoopDelegate,
- public wm::WindowMoveClient {
+class COMPONENT_EXPORT(UI_BASE_X) X11DesktopWindowMoveClient
+ : public X11MoveLoopDelegate {
public:
- X11DesktopWindowMoveClient();
+ explicit X11DesktopWindowMoveClient(ui::XWindow* window);
~X11DesktopWindowMoveClient() override;
// Overridden from X11WholeScreenMoveLoopDelegate:
@@ -35,18 +31,15 @@ class VIEWS_EXPORT X11DesktopWindowMoveClient
void OnMouseReleased() override;
void OnMoveLoopEnded() override;
- // Overridden from wm::WindowMoveClient:
- wm::WindowMoveResult RunMoveLoop(aura::Window* window,
- const gfx::Vector2d& drag_offset,
- wm::WindowMoveSource move_source) override;
- void EndMoveLoop() override;
+ bool RunMoveLoop(bool can_grab_pointer, const gfx::Vector2d& drag_offset);
+ void EndMoveLoop();
private:
X11WholeScreenMoveLoop move_loop_{this};
// We need to keep track of this so we can actually move it when reacting to
// mouse events.
- aura::WindowTreeHost* host_ = nullptr;
+ ui::XWindow* const window_;
// Our cursor offset from the top left window origin when the drag
// started. Used to calculate the window's new bounds relative to the current
@@ -54,6 +47,6 @@ class VIEWS_EXPORT X11DesktopWindowMoveClient
gfx::Vector2d window_offset_;
};
-} // namespace views
+} // namespace ui
-#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_
+#endif // UI_BASE_X_X11_DESKTOP_WINDOW_MOVE_CLIENT_H_
diff --git a/chromium/ui/base/x/x11_drag_drop_client.cc b/chromium/ui/base/x/x11_drag_drop_client.cc
index e39c5937208..6329bd377f0 100644
--- a/chromium/ui/base/x/x11_drag_drop_client.cc
+++ b/chromium/ui/base/x/x11_drag_drop_client.cc
@@ -6,6 +6,7 @@
#include "base/lazy_instance.h"
#include "ui/base/clipboard/clipboard_constants.h"
+#include "ui/base/dragdrop/os_exchange_data.h"
#include "ui/base/x/x11_os_exchange_data_provider.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/x/x11_atom_cache.h"
@@ -261,6 +262,26 @@ void XDragDropClient::ProcessMouseMove(const gfx::Point& screen_point,
}
}
+bool XDragDropClient::HandleXdndEvent(const XClientMessageEvent& event) {
+ Atom message_type = event.message_type;
+ if (message_type == gfx::GetAtom("XdndEnter")) {
+ OnXdndEnter(event);
+ } else if (message_type == gfx::GetAtom("XdndLeave")) {
+ OnXdndLeave(event);
+ } else if (message_type == gfx::GetAtom("XdndPosition")) {
+ OnXdndPosition(event);
+ } else if (message_type == gfx::GetAtom("XdndStatus")) {
+ OnXdndStatus(event);
+ } else if (message_type == gfx::GetAtom("XdndFinished")) {
+ OnXdndFinished(event);
+ } else if (message_type == gfx::GetAtom("XdndDrop")) {
+ OnXdndDrop(event);
+ } else {
+ return false;
+ }
+ return true;
+}
+
void XDragDropClient::OnXdndEnter(const XClientMessageEvent& event) {
DVLOG(1) << "OnXdndEnter, version " << ((event.data.l[1] & 0xff000000) >> 24);
@@ -418,7 +439,7 @@ void XDragDropClient::OnSelectionNotify(const XSelectionEvent& xselection) {
XDeleteProperty(xdisplay_, xwindow_, xselection.property);
}
-void XDragDropClient::InitDrag(int operation, OSExchangeData* data) {
+void XDragDropClient::InitDrag(int operation, const OSExchangeData* data) {
source_current_window_ = x11::None;
source_state_ = SourceState::kOther;
waiting_on_status_ = false;
@@ -584,28 +605,8 @@ void XDragDropClient::SendXClientEvent(XID xid, XEvent* xev) {
// Don't send messages to the X11 message queue if we can help it.
XDragDropClient* short_circuit = GetForWindow(xid);
- if (short_circuit) {
- Atom message_type = xev->xclient.message_type;
- if (message_type == gfx::GetAtom(kXdndEnter)) {
- short_circuit->OnXdndEnter(xev->xclient);
- return;
- } else if (message_type == gfx::GetAtom(kXdndLeave)) {
- short_circuit->OnXdndLeave(xev->xclient);
- return;
- } else if (message_type == gfx::GetAtom(kXdndPosition)) {
- short_circuit->OnXdndPosition(xev->xclient);
- return;
- } else if (message_type == gfx::GetAtom(kXdndStatus)) {
- short_circuit->OnXdndStatus(xev->xclient);
- return;
- } else if (message_type == gfx::GetAtom(kXdndFinished)) {
- short_circuit->OnXdndFinished(xev->xclient);
- return;
- } else if (message_type == gfx::GetAtom(kXdndDrop)) {
- short_circuit->OnXdndDrop(xev->xclient);
- return;
- }
- }
+ if (short_circuit && short_circuit->HandleXdndEvent(xev->xclient))
+ return;
// I don't understand why the GTK+ code is doing what it's doing here. It
// goes out of its way to send the XEvent so that it receives a callback on
@@ -668,6 +669,7 @@ void XDragDropClient::SendXdndDrop(XID dest_window) {
}
void XDragDropClient::EndMoveLoop() {
+ StopEndMoveLoopTimer();
delegate_->EndMoveLoop();
}
diff --git a/chromium/ui/base/x/x11_drag_drop_client.h b/chromium/ui/base/x/x11_drag_drop_client.h
index c00d5f42c40..9a0df14cf71 100644
--- a/chromium/ui/base/x/x11_drag_drop_client.h
+++ b/chromium/ui/base/x/x11_drag_drop_client.h
@@ -64,9 +64,23 @@ class COMPONENT_EXPORT(UI_BASE_X) XDragDropClient {
virtual void EndMoveLoop() = 0;
protected:
- virtual ~Delegate() {}
+ virtual ~Delegate() = default;
};
+ XDragDropClient(Delegate* delegate, Display* xdisplay, XID xwindow);
+ virtual ~XDragDropClient();
+ XDragDropClient(const XDragDropClient&) = delete;
+ XDragDropClient& operator=(const XDragDropClient&) = delete;
+
+ XID xwindow() const { return xwindow_; }
+ XDragContext* target_current_context() {
+ return target_current_context_.get();
+ }
+ const XOSExchangeDataProvider* source_provider() const {
+ return source_provider_;
+ }
+ int current_modifier_state() const { return current_modifier_state_; }
+
// Handling XdndPosition can be paused while waiting for more data; this is
// called either synchronously from OnXdndPosition, or asynchronously after
// we've received data requested from the other window.
@@ -75,27 +89,38 @@ class COMPONENT_EXPORT(UI_BASE_X) XDragDropClient {
void ProcessMouseMove(const gfx::Point& screen_point,
unsigned long event_time);
- const XOSExchangeDataProvider* source_provider() const {
- return source_provider_;
- }
- int current_modifier_state() const { return current_modifier_state_; }
-
// During the blocking StartDragAndDrop() call, this converts the views-style
// |drag_operation_| bitfield into a vector of Atoms to offer to other
// processes.
std::vector<Atom> GetOfferedDragOperations() const;
- // These methods handle the various X11 client messages from the platform.
- void OnXdndEnter(const XClientMessageEvent& event);
- void OnXdndPosition(const XClientMessageEvent& event);
- void OnXdndStatus(const XClientMessageEvent& event);
- void OnXdndLeave(const XClientMessageEvent& event);
- void OnXdndDrop(const XClientMessageEvent& event);
- void OnXdndFinished(const XClientMessageEvent& event);
+ // Tries to handle the XDND event. Returns true for all known event types:
+ // XdndEnter, XdndLeave, XdndPosition, XdndStatus, XdndDrop, and XdndFinished;
+ // returns false if an event of an unexpected type has been passed.
+ bool HandleXdndEvent(const XClientMessageEvent& event);
+
+ // These |Handle...| methods essentially implement the
+ // views::X11MoveLoopDelegate interface.
+ void HandleMouseMovement(const gfx::Point& screen_point,
+ int flags,
+ base::TimeTicks event_time);
+ void HandleMouseReleased();
+ void HandleMoveLoopEnded();
// Called when XSelection data has been copied to our process.
void OnSelectionNotify(const XSelectionEvent& xselection);
+ // Resets the drag state so the object is ready to handle the drag. Sets
+ // X window properties so that the desktop environment is aware of available
+ // actions. Sets |source_provider_| so properties of dragged data can be
+ // queried afterwards. Should be called before entering the main drag loop.
+ void InitDrag(int operation, const OSExchangeData* data);
+
+ // Cleans up the drag state after the drag is done. Removes the X window
+ // properties related to the drag operation. Should be called after exiting
+ // the main drag loop.
+ void CleanupDrag();
+
protected:
enum class SourceState {
// |source_current_window_| will receive a drop once we receive an
@@ -112,31 +137,10 @@ class COMPONENT_EXPORT(UI_BASE_X) XDragDropClient {
kOther,
};
- XDragDropClient(Delegate* delegate, Display* xdisplay, XID xwindow);
- virtual ~XDragDropClient();
-
- XDragDropClient(const XDragDropClient&) = delete;
- XDragDropClient& operator=(const XDragDropClient&) = delete;
-
- XID xwindow() const { return xwindow_; }
- XDragContext* target_current_context() {
- return target_current_context_.get();
- }
DragDropTypes::DragOperation negotiated_operation() const {
return negotiated_operation_;
}
- // Resets the drag state so the object is ready to handle the drag. Sets
- // X window properties so that the desktop environment is aware of available
- // actions. Sets |source_provider_| so properties of dragged data can be
- // queried afterwards. Should be called before entering the main drag loop.
- void InitDrag(int operation, OSExchangeData* data);
-
- // Cleans up the drag state after the drag is done. Removes the X window
- // properties related to the drag operation. Should be called after exiting
- // the main drag loop.
- void CleanupDrag();
-
// Updates |current_modifier_state_| with the given set of flags.
void UpdateModifierState(int flags);
@@ -150,15 +154,15 @@ class COMPONENT_EXPORT(UI_BASE_X) XDragDropClient {
void StartEndMoveLoopTimer();
void StopEndMoveLoopTimer();
- // These |Handle...| methods essentially implement the
- // views::X11MoveLoopDelegate interface.
- void HandleMouseMovement(const gfx::Point& screen_point,
- int flags,
- base::TimeTicks event_time);
- void HandleMouseReleased();
- void HandleMoveLoopEnded();
-
private:
+ // These methods handle the various X11 client messages from the platform.
+ void OnXdndEnter(const XClientMessageEvent& event);
+ void OnXdndPosition(const XClientMessageEvent& event);
+ void OnXdndStatus(const XClientMessageEvent& event);
+ void OnXdndLeave(const XClientMessageEvent& event);
+ void OnXdndDrop(const XClientMessageEvent& event);
+ void OnXdndFinished(const XClientMessageEvent& event);
+
// Creates an XEvent and fills it in with values typical for XDND messages:
// the type of event is set to ClientMessage, the format is set to 32 (longs),
// and the zero member of data payload is set to |xwindow_|. All other data
diff --git a/chromium/ui/base/x/x11_gl_egl_utility.cc b/chromium/ui/base/x/x11_gl_egl_utility.cc
new file mode 100644
index 00000000000..2a7fd03779f
--- /dev/null
+++ b/chromium/ui/base/x/x11_gl_egl_utility.cc
@@ -0,0 +1,47 @@
+// Copyright 2020 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 "ui/base/x/x11_gl_egl_utility.h"
+
+#include "ui/base/x/x11_util_internal.h"
+#include "ui/gfx/x/x11.h"
+#include "ui/gl/gl_surface_egl.h"
+
+#ifndef EGL_ANGLE_x11_visual
+#define EGL_ANGLE_x11_visual 1
+#define EGL_X11_VISUAL_ID_ANGLE 0x33A3
+#endif /* EGL_ANGLE_x11_visual */
+
+#ifndef EGL_ANGLE_platform_angle_null
+#define EGL_ANGLE_platform_angle_null 1
+#define EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE 0x33AE
+#endif /* EGL_ANGLE_platform_angle_null */
+
+namespace ui {
+
+void GetPlatformExtraDisplayAttribs(EGLenum platform_type,
+ std::vector<EGLAttrib>* attributes) {
+ // ANGLE_NULL doesn't use the visual, and may run without X11 where we can't
+ // get it anyway.
+ if (platform_type != EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE) {
+ Visual* visual;
+ ui::XVisualManager::GetInstance()->ChooseVisualForWindow(
+ true, &visual, nullptr, nullptr, nullptr);
+ attributes->push_back(EGL_X11_VISUAL_ID_ANGLE);
+ attributes->push_back(static_cast<EGLAttrib>(XVisualIDFromVisual(visual)));
+ }
+}
+
+void ChoosePlatformCustomAlphaAndBufferSize(EGLint* alpha_size,
+ EGLint* buffer_size) {
+ // If we're using ANGLE_NULL, we may not have a display, in which case we
+ // can't use XVisualManager.
+ if (gl::GLSurfaceEGL::GetNativeDisplay() != EGL_DEFAULT_DISPLAY) {
+ ui::XVisualManager::GetInstance()->ChooseVisualForWindow(
+ true, nullptr, buffer_size, nullptr, nullptr);
+ *alpha_size = *buffer_size == 32 ? 8 : 0;
+ }
+}
+
+} // namespace ui
diff --git a/chromium/ui/base/x/x11_gl_egl_utility.h b/chromium/ui/base/x/x11_gl_egl_utility.h
new file mode 100644
index 00000000000..eb3ca99a784
--- /dev/null
+++ b/chromium/ui/base/x/x11_gl_egl_utility.h
@@ -0,0 +1,24 @@
+// Copyright 2020 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 UI_BASE_X_X11_GL_EGL_UTILITY_H_
+#define UI_BASE_X_X11_GL_EGL_UTILITY_H_
+
+#include <vector>
+
+#include "third_party/khronos/EGL/egl.h"
+
+namespace ui {
+
+// Returns display attributes for the given |platform_type|.
+void GetPlatformExtraDisplayAttribs(EGLenum platform_type,
+ std::vector<EGLAttrib>* attributes);
+
+// Sets custom alpha and buffer size.
+void ChoosePlatformCustomAlphaAndBufferSize(EGLint* alpha_size,
+ EGLint* buffer_size);
+
+} // namespace ui
+
+#endif // UI_BASE_X_X11_GL_EGL_UTILITY_H_ \ No newline at end of file
diff --git a/chromium/ui/views/widget/desktop_aura/x11_move_loop.h b/chromium/ui/base/x/x11_move_loop.h
index b12cbecde9c..24000a9a30b 100644
--- a/chromium/ui/views/widget/desktop_aura/x11_move_loop.h
+++ b/chromium/ui/base/x/x11_move_loop.h
@@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_H_
-#define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_H_
+#ifndef UI_BASE_X_X11_MOVE_LOOP_H_
+#define UI_BASE_X_X11_MOVE_LOOP_H_
#include "ui/gfx/native_widget_types.h"
+#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_types.h"
-namespace views {
+namespace ui {
// Runs a nested run loop and grabs the mouse. This is used to implement
// dragging.
@@ -20,15 +21,17 @@ class X11MoveLoop {
// the mouse cursor. Returns true if the move-loop is completed successfully.
// If the pointer-grab fails, or the move-loop is canceled by the user (e.g.
// by pressing escape), then returns false.
- virtual bool RunMoveLoop(aura::Window* window, gfx::NativeCursor cursor) = 0;
+ virtual bool RunMoveLoop(bool can_grab_pointer,
+ ::Cursor old_cursor,
+ ::Cursor new_cursor) = 0;
// Updates the cursor while the move loop is running.
- virtual void UpdateCursor(gfx::NativeCursor cursor) = 0;
+ virtual void UpdateCursor(::Cursor cursor) = 0;
// Ends the move loop that's currently in progress.
virtual void EndMoveLoop() = 0;
};
-} // namespace views
+} // namespace ui
-#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_H_
+#endif // UI_BASE_X_X11_MOVE_LOOP_H_
diff --git a/chromium/ui/views/widget/desktop_aura/x11_move_loop_delegate.h b/chromium/ui/base/x/x11_move_loop_delegate.h
index b5eee9b7257..a9ac2330937 100644
--- a/chromium/ui/views/widget/desktop_aura/x11_move_loop_delegate.h
+++ b/chromium/ui/base/x/x11_move_loop_delegate.h
@@ -2,18 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_DELEGATE_H_
-#define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_DELEGATE_H_
+#ifndef UI_BASE_X_X11_MOVE_LOOP_DELEGATE_H_
+#define UI_BASE_X_X11_MOVE_LOOP_DELEGATE_H_
namespace gfx {
class Point;
}
-namespace views {
+namespace ui {
// Receives mouse events while the X11MoveLoop is tracking a drag.
class X11MoveLoopDelegate {
public:
+ virtual ~X11MoveLoopDelegate() = default;
+
// Called when we receive a mouse move event.
virtual void OnMouseMovement(const gfx::Point& screen_point,
int flags,
@@ -27,6 +29,6 @@ class X11MoveLoopDelegate {
virtual void OnMoveLoopEnded() = 0;
};
-} // namespace views
+} // namespace ui
-#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_MOVE_LOOP_DELEGATE_H_
+#endif // UI_BASE_X_X11_MOVE_LOOP_DELEGATE_H_
diff --git a/chromium/ui/base/x/x11_os_exchange_data_provider.cc b/chromium/ui/base/x/x11_os_exchange_data_provider.cc
index 41190f9f56a..88a24bab57b 100644
--- a/chromium/ui/base/x/x11_os_exchange_data_provider.cc
+++ b/chromium/ui/base/x/x11_os_exchange_data_provider.cc
@@ -6,7 +6,6 @@
#include <utility>
-#include "base/logging.h"
#include "base/memory/ref_counted_memory.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
@@ -84,6 +83,14 @@ SelectionFormatMap XOSExchangeDataProvider::GetFormatMap() const {
return selection_owner_.selection_format_map();
}
+#if defined(USE_OZONE)
+std::unique_ptr<OSExchangeDataProvider> XOSExchangeDataProvider::Clone() const {
+ std::unique_ptr<XOSExchangeDataProvider> ret(new XOSExchangeDataProvider());
+ ret->set_format_map(format_map());
+ return std::move(ret);
+}
+#endif
+
void XOSExchangeDataProvider::MarkOriginatedFromRenderer() {
std::string empty;
format_map_.Insert(gfx::GetAtom(kRendererTaint),
@@ -206,10 +213,9 @@ bool XOSExchangeDataProvider::GetString(base::string16* result) const {
return false;
}
-bool XOSExchangeDataProvider::GetURLAndTitle(
- OSExchangeData::FilenameToURLPolicy policy,
- GURL* url,
- base::string16* title) const {
+bool XOSExchangeDataProvider::GetURLAndTitle(FilenameToURLPolicy policy,
+ GURL* url,
+ base::string16* title) const {
std::vector<Atom> url_atoms = ui::GetURLAtomsFrom();
std::vector<Atom> requested_types;
GetAtomIntersection(url_atoms, GetTargets(), &requested_types);
@@ -241,8 +247,7 @@ bool XOSExchangeDataProvider::GetURLAndTitle(
std::vector<std::string> tokens = ui::ParseURIList(data);
for (const std::string& token : tokens) {
GURL test_url(token);
- if (!test_url.SchemeIsFile() ||
- policy == OSExchangeData::CONVERT_FILENAMES) {
+ if (!test_url.SchemeIsFile() || policy == CONVERT_FILENAMES) {
*url = test_url;
*title = base::string16();
return true;
@@ -310,8 +315,7 @@ bool XOSExchangeDataProvider::HasString() const {
return !requested_types.empty() && !HasFile();
}
-bool XOSExchangeDataProvider::HasURL(
- OSExchangeData::FilenameToURLPolicy policy) const {
+bool XOSExchangeDataProvider::HasURL(FilenameToURLPolicy policy) const {
std::vector<Atom> url_atoms = ui::GetURLAtomsFrom();
std::vector<Atom> requested_types;
GetAtomIntersection(url_atoms, GetTargets(), &requested_types);
@@ -329,8 +333,7 @@ bool XOSExchangeDataProvider::HasURL(
} else if (data.GetType() == gfx::GetAtom(ui::kMimeTypeURIList)) {
std::vector<std::string> tokens = ui::ParseURIList(data);
for (const std::string& token : tokens) {
- if (!GURL(token).SchemeIsFile() ||
- policy == OSExchangeData::CONVERT_FILENAMES)
+ if (!GURL(token).SchemeIsFile() || policy == CONVERT_FILENAMES)
return true;
}
diff --git a/chromium/ui/base/x/x11_os_exchange_data_provider.h b/chromium/ui/base/x/x11_os_exchange_data_provider.h
index fb542844533..6763eb0aea7 100644
--- a/chromium/ui/base/x/x11_os_exchange_data_provider.h
+++ b/chromium/ui/base/x/x11_os_exchange_data_provider.h
@@ -12,7 +12,7 @@
#include "base/files/file_path.h"
#include "base/macros.h"
#include "base/pickle.h"
-#include "ui/base/dragdrop/os_exchange_data.h"
+#include "ui/base/dragdrop/os_exchange_data_provider.h"
#include "ui/base/x/selection_owner.h"
#include "ui/base/x/selection_requestor.h"
#include "ui/base/x/selection_utils.h"
@@ -23,13 +23,13 @@
namespace ui {
-class OSExchangeDataProviderAuraX11Test;
+class OSExchangeDataProviderX11Test;
-// Generic OSExchangeData::Provider implementation for X11. Lacks the event
+// Generic OSExchangeDataProvider implementation for X11. Lacks the event
// handling; the subclass should listen for SelectionRequest X events and
// route them to the |selection_owner_|.
class COMPONENT_EXPORT(UI_BASE_X) XOSExchangeDataProvider
- : public OSExchangeData::Provider {
+ : public OSExchangeDataProvider {
public:
// |x_window| is the window the cursor is over, and |selection| is the set of
// data being offered.
@@ -59,7 +59,10 @@ class COMPONENT_EXPORT(UI_BASE_X) XOSExchangeDataProvider
return file_contents_name_;
}
- // Overridden from OSExchangeData::Provider:
+ // Overridden from OSExchangeDataProvider:
+#if defined(USE_OZONE)
+ std::unique_ptr<OSExchangeDataProvider> Clone() const override;
+#endif
void MarkOriginatedFromRenderer() override;
bool DidOriginateFromRenderer() const override;
void SetString(const base::string16& data) override;
@@ -69,7 +72,7 @@ class COMPONENT_EXPORT(UI_BASE_X) XOSExchangeDataProvider
void SetPickledData(const ClipboardFormatType& format,
const base::Pickle& pickle) override;
bool GetString(base::string16* data) const override;
- bool GetURLAndTitle(OSExchangeData::FilenameToURLPolicy policy,
+ bool GetURLAndTitle(FilenameToURLPolicy policy,
GURL* url,
base::string16* title) const override;
bool GetFilename(base::FilePath* path) const override;
@@ -77,7 +80,7 @@ class COMPONENT_EXPORT(UI_BASE_X) XOSExchangeDataProvider
bool GetPickledData(const ClipboardFormatType& format,
base::Pickle* pickle) const override;
bool HasString() const override;
- bool HasURL(OSExchangeData::FilenameToURLPolicy policy) const override;
+ bool HasURL(FilenameToURLPolicy policy) const override;
bool HasFile() const override;
bool HasCustomFormat(const ClipboardFormatType& format) const override;
@@ -90,8 +93,8 @@ class COMPONENT_EXPORT(UI_BASE_X) XOSExchangeDataProvider
gfx::Vector2d GetDragImageOffset() const override;
protected:
- friend class OSExchangeDataProviderAuraX11Test;
- typedef std::map<ClipboardFormatType, base::Pickle> PickleData;
+ friend class OSExchangeDataProviderX11Test;
+ using PickleData = std::map<ClipboardFormatType, base::Pickle>;
bool own_window() const { return own_window_; }
XID x_window() const { return x_window_; }
diff --git a/chromium/ui/base/x/x11_pointer_grab.cc b/chromium/ui/base/x/x11_pointer_grab.cc
index efe07531f79..01c0efb666b 100644
--- a/chromium/ui/base/x/x11_pointer_grab.cc
+++ b/chromium/ui/base/x/x11_pointer_grab.cc
@@ -4,7 +4,7 @@
#include "ui/base/x/x11_pointer_grab.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/base/x/x11_util.h"
#include "ui/events/devices/x11/device_data_manager_x11.h"
#include "ui/gfx/x/x11.h"
diff --git a/chromium/ui/base/x/x11_util.cc b/chromium/ui/base/x/x11_util.cc
index 52f116723de..4f35d362363 100644
--- a/chromium/ui/base/x/x11_util.cc
+++ b/chromium/ui/base/x/x11_util.cc
@@ -13,6 +13,7 @@
#include <sys/shm.h>
#include <bitset>
+#include <limits>
#include <list>
#include <map>
#include <utility>
@@ -39,6 +40,7 @@
#include "build/build_config.h"
#include "skia/ext/image_operations.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#include "third_party/skia/include/core/SkImageInfo.h"
#include "third_party/skia/include/core/SkTypes.h"
#include "ui/base/x/x11_menu_list.h"
#include "ui/base/x/x11_util_internal.h"
@@ -56,9 +58,11 @@
#include "ui/gfx/image/image_skia_rep.h"
#include "ui/gfx/skia_util.h"
#include "ui/gfx/switches.h"
+#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/x11_error_tracker.h"
+#include "ui/gfx/x/xproto_util.h"
#if defined(OS_FREEBSD)
#include <sys/sysctl.h>
@@ -92,14 +96,13 @@ int DefaultX11ErrorHandler(XDisplay* d, XErrorEvent* e) {
if (base::MessageLoopCurrent::Get()) {
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindOnce(&LogErrorEventDescription, d, *e));
+ FROM_HERE, base::BindOnce(&x11::LogErrorEventDescription, *e));
} else {
- LOG(ERROR)
- << "X error received: "
- << "serial " << e->serial << ", "
- << "error_code " << static_cast<int>(e->error_code) << ", "
- << "request_code " << static_cast<int>(e->request_code) << ", "
- << "minor_code " << static_cast<int>(e->minor_code);
+ LOG(ERROR) << "X error received: "
+ << "serial " << e->serial << ", "
+ << "error_code " << static_cast<int>(e->error_code) << ", "
+ << "request_code " << static_cast<int>(e->request_code) << ", "
+ << "minor_code " << static_cast<int>(e->minor_code);
}
return 0;
}
@@ -110,18 +113,47 @@ int DefaultX11IOErrorHandler(XDisplay* d) {
_exit(1);
}
-// Note: The caller should free the resulting value data.
-bool GetProperty(XID window, const std::string& property_name, long max_length,
- XAtom* type, int* format, unsigned long* num_items,
- unsigned char** property) {
- XAtom property_atom = gfx::GetAtom(property_name.c_str());
- unsigned long remaining_bytes = 0;
- return XGetWindowProperty(gfx::GetXDisplay(), window, property_atom,
- 0, // offset into property data to read
- max_length, // max length to get
- x11::False, // deleted
- AnyPropertyType, type, format, num_items,
- &remaining_bytes, property);
+template <typename T>
+bool GetProperty(XID window, const std::string& property_name, T* value) {
+ static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4, "");
+ auto response = x11::Connection::Get()
+ ->GetProperty({
+ .window = static_cast<x11::Window>(window),
+ .property = static_cast<x11::Atom>(
+ gfx::GetAtom(property_name.c_str())),
+ .long_length = std::max<uint32_t>(1, sizeof(T) / 4),
+ })
+ .Sync();
+ if (!response || response->format != 8 * sizeof(T) ||
+ response->value.size() != sizeof(T)) {
+ return false;
+ }
+
+ DCHECK_EQ(response->format / 8 * response->value_len, response->value.size());
+ memcpy(value, response->value.data(), sizeof(T));
+ return true;
+}
+
+template <typename T>
+bool GetArrayProperty(XID window,
+ const std::string& property_name,
+ std::vector<T>* value) {
+ static_assert(sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4, "");
+ auto response = x11::Connection::Get()
+ ->GetProperty({
+ .window = static_cast<x11::Window>(window),
+ .property = static_cast<x11::Atom>(
+ gfx::GetAtom(property_name.c_str())),
+ .long_length = std::numeric_limits<uint32_t>::max(),
+ })
+ .Sync();
+ if (!response || response->format != 8 * sizeof(T))
+ return false;
+
+ DCHECK_EQ(response->format / 8 * response->value_len, response->value.size());
+ value->resize(response->value_len);
+ memcpy(value->data(), response->value.data(), response->value.size());
+ return true;
}
bool SupportsEWMH() {
@@ -131,8 +163,7 @@ bool SupportsEWMH() {
supports_ewmh_cached = true;
int wm_window = 0u;
- if (!GetIntProperty(GetX11RootWindow(),
- "_NET_SUPPORTING_WM_CHECK",
+ if (!GetIntProperty(GetX11RootWindow(), "_NET_SUPPORTING_WM_CHECK",
&wm_window)) {
supports_ewmh = false;
return false;
@@ -149,10 +180,9 @@ bool SupportsEWMH() {
// we check that too.
gfx::X11ErrorTracker err_tracker;
int wm_window_property = 0;
- bool result = GetIntProperty(
- wm_window, "_NET_SUPPORTING_WM_CHECK", &wm_window_property);
- supports_ewmh = !err_tracker.FoundNewError() &&
- result &&
+ bool result = GetIntProperty(wm_window, "_NET_SUPPORTING_WM_CHECK",
+ &wm_window_property);
+ supports_ewmh = !err_tracker.FoundNewError() && result &&
wm_window_property == wm_window;
}
@@ -165,15 +195,14 @@ bool GetWindowManagerName(std::string* wm_name) {
return false;
int wm_window = 0;
- if (!GetIntProperty(GetX11RootWindow(),
- "_NET_SUPPORTING_WM_CHECK",
+ if (!GetIntProperty(GetX11RootWindow(), "_NET_SUPPORTING_WM_CHECK",
&wm_window)) {
return false;
}
gfx::X11ErrorTracker err_tracker;
- bool result = GetStringProperty(
- static_cast<XID>(wm_window), "_NET_WM_NAME", wm_name);
+ bool result =
+ GetStringProperty(static_cast<XID>(wm_window), "_NET_WM_NAME", wm_name);
return !err_tracker.FoundNewError() && result;
}
@@ -207,18 +236,14 @@ class XCustomCursorCache {
return xcursor;
}
- void Ref(::Cursor cursor) {
- cache_[cursor]->Ref();
- }
+ void Ref(::Cursor cursor) { cache_[cursor]->Ref(); }
void Unref(::Cursor cursor) {
if (cache_[cursor]->Unref())
cache_.erase(cursor);
}
- void Clear() {
- cache_.clear();
- }
+ void Clear() { cache_.clear(); }
const XcursorImage* GetXcursorImage(::Cursor cursor) const {
return cache_.find(cursor)->second->image();
@@ -230,9 +255,7 @@ class XCustomCursorCache {
class XCustomCursor {
public:
// This takes ownership of the image.
- XCustomCursor(XcursorImage* image)
- : image_(image),
- ref_(1) {
+ explicit XCustomCursor(XcursorImage* image) : image_(image), ref_(1) {
cursor_ = XcursorImageLoadCursor(gfx::GetXDisplay(), image);
}
@@ -243,9 +266,7 @@ class XCustomCursorCache {
::Cursor cursor() const { return cursor_; }
- void Ref() {
- ++ref_;
- }
+ void Ref() { ++ref_; }
// Returns true if the cursor was destroyed because of the unref.
bool Unref() {
@@ -266,15 +287,27 @@ class XCustomCursorCache {
DISALLOW_COPY_AND_ASSIGN(XCustomCursor);
};
- XCustomCursorCache() {}
- ~XCustomCursorCache() {
- Clear();
- }
+ XCustomCursorCache() = default;
+ ~XCustomCursorCache() { Clear(); }
- std::map< ::Cursor, XCustomCursor*> cache_;
+ std::map<::Cursor, XCustomCursor*> cache_;
DISALLOW_COPY_AND_ASSIGN(XCustomCursorCache);
};
+// Converts a SKBitmap to unpremul alpha.
+SkBitmap ConvertSkBitmapToUnpremul(const SkBitmap& bitmap) {
+ DCHECK_NE(bitmap.alphaType(), kUnpremul_SkAlphaType);
+
+ SkImageInfo image_info = SkImageInfo::MakeN32(bitmap.width(), bitmap.height(),
+ kUnpremul_SkAlphaType);
+ SkBitmap converted_bitmap;
+ converted_bitmap.allocPixels(image_info);
+ bitmap.readPixels(image_info, converted_bitmap.getPixels(),
+ image_info.minRowBytes(), 0, 0);
+
+ return converted_bitmap;
+}
+
} // namespace
bool IsXInput2Available() {
@@ -315,11 +348,18 @@ void UnrefCustomXCursor(::Cursor cursor) {
XCustomCursorCache::GetInstance()->Unref(cursor);
}
-XcursorImage* SkBitmapToXcursorImage(const SkBitmap* cursor_image,
+XcursorImage* SkBitmapToXcursorImage(const SkBitmap& cursor_image,
const gfx::Point& hotspot) {
// TODO(crbug.com/596782): It is possible for cursor_image to be zeroed out
// at this point, which leads to benign debug errors. Once this is fixed, we
- // should DCHECK_EQ(cursor_image->colorType(), kN32_SkColorType).
+ // should DCHECK_EQ(cursor_image.colorType(), kN32_SkColorType).
+
+ // X11 expects bitmap with unpremul alpha. If bitmap is premul then convert,
+ // otherwise semi-transparent parts of cursor will look strange.
+ const SkBitmap converted = (cursor_image.alphaType() != kUnpremul_SkAlphaType)
+ ? ConvertSkBitmapToUnpremul(cursor_image)
+ : cursor_image;
+
gfx::Point hotspot_point = hotspot;
SkBitmap scaled;
@@ -327,31 +367,30 @@ XcursorImage* SkBitmapToXcursorImage(const SkBitmap* cursor_image,
// pixels. So rescale the image if necessary.
static const float kMaxPixel = GetMaxCursorSize();
bool needs_scale = false;
- if (cursor_image->width() > kMaxPixel || cursor_image->height() > kMaxPixel) {
+ if (converted.width() > kMaxPixel || converted.height() > kMaxPixel) {
float scale = 1.f;
- if (cursor_image->width() > cursor_image->height())
- scale = kMaxPixel / cursor_image->width();
+ if (converted.width() > converted.height())
+ scale = kMaxPixel / converted.width();
else
- scale = kMaxPixel / cursor_image->height();
+ scale = kMaxPixel / converted.height();
- scaled = skia::ImageOperations::Resize(*cursor_image,
- skia::ImageOperations::RESIZE_BETTER,
- static_cast<int>(cursor_image->width() * scale),
- static_cast<int>(cursor_image->height() * scale));
+ scaled = skia::ImageOperations::Resize(
+ converted, skia::ImageOperations::RESIZE_BETTER,
+ static_cast<int>(converted.width() * scale),
+ static_cast<int>(converted.height() * scale));
hotspot_point = gfx::ScaleToFlooredPoint(hotspot, scale);
needs_scale = true;
}
- const SkBitmap* bitmap = needs_scale ? &scaled : cursor_image;
- XcursorImage* image = XcursorImageCreate(bitmap->width(), bitmap->height());
- image->xhot = std::min(bitmap->width() - 1, hotspot_point.x());
- image->yhot = std::min(bitmap->height() - 1, hotspot_point.y());
+ const SkBitmap& bitmap = needs_scale ? scaled : converted;
+ XcursorImage* image = XcursorImageCreate(bitmap.width(), bitmap.height());
+ image->xhot = std::min(bitmap.width() - 1, hotspot_point.x());
+ image->yhot = std::min(bitmap.height() - 1, hotspot_point.y());
- if (bitmap->width() && bitmap->height()) {
+ if (bitmap.width() && bitmap.height()) {
// The |bitmap| contains ARGB image, so just copy it.
- memcpy(image->pixels,
- bitmap->getPixels(),
- bitmap->width() * bitmap->height() * 4);
+ memcpy(image->pixels, bitmap.getPixels(),
+ bitmap.width() * bitmap.height() * 4);
}
return image;
@@ -455,14 +494,13 @@ void HideHostCursor() {
::Cursor CreateInvisibleCursor() {
XDisplay* xdisplay = gfx::GetXDisplay();
::Cursor invisible_cursor;
- char nodata[] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+ char nodata[] = {0, 0, 0, 0, 0, 0, 0, 0};
XColor black;
black.red = black.green = black.blue = 0;
- Pixmap blank = XCreateBitmapFromData(xdisplay,
- DefaultRootWindow(xdisplay),
+ Pixmap blank = XCreateBitmapFromData(xdisplay, DefaultRootWindow(xdisplay),
nodata, 8, 8);
- invisible_cursor = XCreatePixmapCursor(xdisplay, blank, blank,
- &black, &black, 0, 0);
+ invisible_cursor =
+ XCreatePixmapCursor(xdisplay, blank, blank, &black, &black, 0, 0);
XFreePixmap(xdisplay, blank);
return invisible_cursor;
}
@@ -488,14 +526,10 @@ void SetUseOSWindowFrame(XID window, bool use_os_window_frame) {
motif_hints.decorations = use_os_window_frame ? 1 : 0;
XAtom hint_atom = gfx::GetAtom("_MOTIF_WM_HINTS");
- XChangeProperty(gfx::GetXDisplay(),
- window,
- hint_atom,
- hint_atom,
- 32,
+ XChangeProperty(gfx::GetXDisplay(), window, hint_atom, hint_atom, 32,
PropModeReplace,
reinterpret_cast<unsigned char*>(&motif_hints),
- sizeof(MotifWmHints)/sizeof(long));
+ sizeof(MotifWmHints) / sizeof(long));
}
bool IsShapeExtensionAvailable() {
@@ -536,11 +570,8 @@ void ClearX11DefaultRootWindow() {
XGCValues gc_values = {0};
gc_values.foreground = BlackPixel(display, DefaultScreen(display));
GC gc = XCreateGC(display, root_window, GCForeground, &gc_values);
- XFillRectangle(display, root_window, gc,
- root_bounds.x(),
- root_bounds.y(),
- root_bounds.width(),
- root_bounds.height());
+ XFillRectangle(display, root_window, gc, root_bounds.x(), root_bounds.y(),
+ root_bounds.width(), root_bounds.height());
XFreeGC(display, gc);
}
@@ -566,8 +597,7 @@ bool IsWindowVisible(XID window) {
int window_desktop, current_desktop;
return (!GetWindowDesktop(window, &window_desktop) ||
!GetCurrentDesktop(&current_desktop) ||
- window_desktop == kAllDesktops ||
- window_desktop == current_desktop);
+ window_desktop == kAllDesktops || window_desktop == current_desktop);
}
bool GetInnerWindowBounds(XID window, gfx::Rect* rect) {
@@ -576,12 +606,12 @@ bool GetInnerWindowBounds(XID window, gfx::Rect* rect) {
unsigned int width, height;
unsigned int border_width, depth;
- if (!XGetGeometry(gfx::GetXDisplay(), window, &root, &x, &y,
- &width, &height, &border_width, &depth))
+ if (!XGetGeometry(gfx::GetXDisplay(), window, &root, &x, &y, &width, &height,
+ &border_width, &depth))
return false;
- if (!XTranslateCoordinates(gfx::GetXDisplay(), window, root,
- 0, 0, &x, &y, &child))
+ if (!XTranslateCoordinates(gfx::GetXDisplay(), window, root, 0, 0, &x, &y,
+ &child))
return false;
*rect = gfx::Rect(x, y, width, height);
@@ -617,7 +647,6 @@ bool GetOuterWindowBounds(XID window, gfx::Rect* rect) {
return true;
}
-
bool WindowContainsPoint(XID window, gfx::Point screen_loc) {
TRACE_EVENT0("ui", "WindowContainsPoint");
@@ -645,13 +674,11 @@ bool WindowContainsPoint(XID window, gfx::Point screen_loc) {
// included in both the default input region and the client bounding region
// will not be included in the effective input region on the screen.
int rectangle_kind[] = {ShapeInput, ShapeBounding};
- for (size_t kind_index = 0; kind_index < base::size(rectangle_kind);
- kind_index++) {
+ for (int kind_index : rectangle_kind) {
int dummy;
int shape_rects_size = 0;
gfx::XScopedPtr<XRectangle[]> shape_rects(XShapeGetRectangles(
- gfx::GetXDisplay(), window, rectangle_kind[kind_index],
- &shape_rects_size, &dummy));
+ gfx::GetXDisplay(), window, kind_index, &shape_rects_size, &dummy));
if (!shape_rects) {
// The shape is empty. This can occur when |window| is minimized.
DCHECK_EQ(0, shape_rects_size);
@@ -676,20 +703,16 @@ bool WindowContainsPoint(XID window, gfx::Point screen_loc) {
return true;
}
-
bool PropertyExists(XID window, const std::string& property_name) {
- XAtom type = x11::None;
- int format = 0; // size in bits of each item in 'property'
- unsigned long num_items = 0;
- unsigned char* property = nullptr;
-
- int result = GetProperty(window, property_name, 1,
- &type, &format, &num_items, &property);
- gfx::XScopedPtr<unsigned char> scoped_property(property);
- if (result != x11::Success)
- return false;
-
- return num_items > 0;
+ auto response = x11::Connection::Get()
+ ->GetProperty({
+ .window = static_cast<x11::Window>(window),
+ .property = static_cast<x11::Atom>(
+ gfx::GetAtom(property_name.c_str())),
+ .long_length = 1,
+ })
+ .Sync();
+ return response && response->format;
}
bool GetRawBytesOfProperty(XID window,
@@ -745,110 +768,41 @@ bool GetRawBytesOfProperty(XID window,
}
bool GetIntProperty(XID window, const std::string& property_name, int* value) {
- XAtom type = x11::None;
- int format = 0; // size in bits of each item in 'property'
- unsigned long num_items = 0;
- unsigned char* property = nullptr;
-
- int result = GetProperty(window, property_name, 1,
- &type, &format, &num_items, &property);
- gfx::XScopedPtr<unsigned char> scoped_property(property);
- if (result != x11::Success)
- return false;
-
- if (format != 32 || num_items != 1)
- return false;
-
- *value = static_cast<int>(*(reinterpret_cast<long*>(property)));
- return true;
+ return GetProperty(window, property_name, value);
}
bool GetXIDProperty(XID window, const std::string& property_name, XID* value) {
- XAtom type = x11::None;
- int format = 0; // size in bits of each item in 'property'
- unsigned long num_items = 0;
- unsigned char* property = nullptr;
-
- int result = GetProperty(window, property_name, 1,
- &type, &format, &num_items, &property);
- gfx::XScopedPtr<unsigned char> scoped_property(property);
- if (result != x11::Success)
- return false;
-
- if (format != 32 || num_items != 1)
+ uint32_t xid;
+ if (!GetProperty(window, property_name, &xid))
return false;
-
- *value = *(reinterpret_cast<XID*>(property));
+ *value = xid;
return true;
}
bool GetIntArrayProperty(XID window,
const std::string& property_name,
std::vector<int>* value) {
- XAtom type = x11::None;
- int format = 0; // size in bits of each item in 'property'
- unsigned long num_items = 0;
- unsigned char* properties = nullptr;
-
- int result = GetProperty(window, property_name,
- (~0L), // (all of them)
- &type, &format, &num_items, &properties);
- gfx::XScopedPtr<unsigned char> scoped_properties(properties);
- if (result != x11::Success)
- return false;
-
- if (format != 32)
- return false;
-
- long* int_properties = reinterpret_cast<long*>(properties);
- value->clear();
- for (unsigned long i = 0; i < num_items; ++i) {
- value->push_back(static_cast<int>(int_properties[i]));
- }
- return true;
+ return GetArrayProperty(window, property_name, value);
}
bool GetAtomArrayProperty(XID window,
const std::string& property_name,
std::vector<XAtom>* value) {
- XAtom type = x11::None;
- int format = 0; // size in bits of each item in 'property'
- unsigned long num_items = 0;
- unsigned char* properties = nullptr;
-
- int result = GetProperty(window, property_name,
- (~0L), // (all of them)
- &type, &format, &num_items, &properties);
- gfx::XScopedPtr<unsigned char> scoped_properties(properties);
- if (result != x11::Success)
+ std::vector<uint32_t> value32;
+ if (!GetArrayProperty(window, property_name, &value32))
return false;
-
- if (type != XA_ATOM)
- return false;
-
- XAtom* atom_properties = reinterpret_cast<XAtom*>(properties);
- value->clear();
- value->insert(value->begin(), atom_properties, atom_properties + num_items);
+ *value = std::vector<XAtom>(value32.begin(), value32.end());
return true;
}
-bool GetStringProperty(
- XID window, const std::string& property_name, std::string* value) {
- XAtom type = x11::None;
- int format = 0; // size in bits of each item in 'property'
- unsigned long num_items = 0;
- unsigned char* property = nullptr;
-
- int result = GetProperty(window, property_name, 1024,
- &type, &format, &num_items, &property);
- gfx::XScopedPtr<unsigned char> scoped_property(property);
- if (result != x11::Success)
+bool GetStringProperty(XID window,
+ const std::string& property_name,
+ std::string* value) {
+ std::vector<char> str;
+ if (!GetArrayProperty(window, property_name, &str))
return false;
- if (format != 8)
- return false;
-
- value->assign(reinterpret_cast<char*>(property), num_items);
+ value->assign(str.data(), str.size());
return true;
}
@@ -874,10 +828,7 @@ bool SetIntArrayProperty(XID window,
data[i] = value[i];
gfx::X11ErrorTracker err_tracker;
- XChangeProperty(gfx::GetXDisplay(),
- window,
- name_atom,
- type_atom,
+ XChangeProperty(gfx::GetXDisplay(), window, name_atom, type_atom,
32, // size in bits of items in 'value'
PropModeReplace,
reinterpret_cast<const unsigned char*>(data.get()),
@@ -907,10 +858,7 @@ bool SetAtomArrayProperty(XID window,
data[i] = value[i];
gfx::X11ErrorTracker err_tracker;
- XChangeProperty(gfx::GetXDisplay(),
- window,
- name_atom,
- type_atom,
+ XChangeProperty(gfx::GetXDisplay(), window, name_atom, type_atom,
32, // size in bits of items in 'value'
PropModeReplace,
reinterpret_cast<const unsigned char*>(data.get()),
@@ -923,14 +871,9 @@ bool SetStringProperty(XID window,
XAtom type,
const std::string& value) {
gfx::X11ErrorTracker err_tracker;
- XChangeProperty(gfx::GetXDisplay(),
- window,
- property,
- type,
- 8,
- PropModeReplace,
- reinterpret_cast<const unsigned char*>(value.c_str()),
- value.size());
+ XChangeProperty(
+ gfx::GetXDisplay(), window, property, type, 8, PropModeReplace,
+ reinterpret_cast<const unsigned char*>(value.c_str()), value.size());
return !err_tracker.FoundNewError();
}
@@ -1018,21 +961,14 @@ bool GetCustomFramePrefDefault() {
// Also disable custom frames for (at-least-partially-)EWMH-supporting tiling
// window managers.
ui::WindowManagerName wm = GuessWindowManager();
- if (wm == WM_AWESOME ||
- wm == WM_I3 ||
- wm == WM_ION3 ||
- wm == WM_MATCHBOX ||
- wm == WM_NOTION ||
- wm == WM_QTILE ||
- wm == WM_RATPOISON ||
- wm == WM_STUMPWM ||
- wm == WM_WMII)
+ if (wm == WM_AWESOME || wm == WM_I3 || wm == WM_ION3 || wm == WM_MATCHBOX ||
+ wm == WM_NOTION || wm == WM_QTILE || wm == WM_RATPOISON ||
+ wm == WM_STUMPWM || wm == WM_WMII)
return false;
// Handle a few more window managers that don't get along well with custom
// frames.
- if (wm == WM_ICE_WM ||
- wm == WM_KWIN)
+ if (wm == WM_ICE_WM || wm == WM_KWIN)
return false;
// For everything else, use custom frames.
@@ -1098,8 +1034,10 @@ bool IsWindowNamed(XID window) {
return true;
}
-bool EnumerateChildren(EnumerateWindowsDelegate* delegate, XID window,
- const int max_depth, int depth) {
+bool EnumerateChildren(EnumerateWindowsDelegate* delegate,
+ XID window,
+ const int max_depth,
+ int depth) {
if (depth > max_depth)
return false;
@@ -1174,27 +1112,13 @@ void EnumerateTopLevelWindows(ui::EnumerateWindowsDelegate* delegate) {
}
bool GetXWindowStack(Window window, std::vector<XID>* windows) {
- windows->clear();
-
- Atom type;
- int format;
- unsigned long count;
- unsigned char* data = nullptr;
- if (GetProperty(window, "_NET_CLIENT_LIST_STACKING", ~0L, &type, &format,
- &count, &data) != x11::Success) {
+ std::vector<uint32_t> value32;
+ if (!GetArrayProperty(window, "_NET_CLIENT_LIST_STACKING", &value32))
return false;
- }
- gfx::XScopedPtr<unsigned char> scoped_data(data);
-
- bool result = false;
- if (type == XA_WINDOW && format == 32 && data && count > 0) {
- result = true;
- XID* stack = reinterpret_cast<XID*>(data);
- for (long i = static_cast<long>(count) - 1; i >= 0; i--)
- windows->push_back(stack[i]);
- }
-
- return result;
+ // It's more common to iterate from lowest window to highest,
+ // so reverse the vector.
+ *windows = std::vector<XID>(value32.rbegin(), value32.rend());
+ return true;
}
WindowManagerName GuessWindowManager() {
@@ -1274,9 +1198,7 @@ bool IsX11WindowFullScreen(XID window) {
XAtom fullscreen_atom = gfx::GetAtom("_NET_WM_STATE_FULLSCREEN");
if (WmSupportsHint(fullscreen_atom)) {
std::vector<XAtom> atom_properties;
- if (GetAtomArrayProperty(window,
- "_NET_WM_STATE",
- &atom_properties)) {
+ if (GetAtomArrayProperty(window, "_NET_WM_STATE", &atom_properties)) {
return base::Contains(atom_properties, fullscreen_atom);
}
}
@@ -1302,8 +1224,7 @@ bool WmSupportsHint(XAtom atom) {
return false;
std::vector<XAtom> supported_atoms;
- if (!GetAtomArrayProperty(GetX11RootWindow(),
- "_NET_SUPPORTED",
+ if (!GetAtomArrayProperty(GetX11RootWindow(), "_NET_SUPPORTED",
&supported_atoms)) {
return false;
}
@@ -1394,8 +1315,7 @@ SkColorType ColorTypeForVisual(void* visual) {
}
XRefcountedMemory::XRefcountedMemory(unsigned char* x11_data, size_t length)
- : x11_data_(length ? x11_data : nullptr), length_(length) {
-}
+ : x11_data_(length ? x11_data : nullptr), length_(length) {}
const unsigned char* XRefcountedMemory::front() const {
return x11_data_.get();
@@ -1405,13 +1325,10 @@ size_t XRefcountedMemory::size() const {
return length_;
}
-XRefcountedMemory::~XRefcountedMemory() {
-}
+XRefcountedMemory::~XRefcountedMemory() = default;
XScopedCursor::XScopedCursor(::Cursor cursor, XDisplay* display)
- : cursor_(cursor),
- display_(display) {
-}
+ : cursor_(cursor), display_(display) {}
XScopedCursor::~XScopedCursor() {
reset(0U);
@@ -1436,7 +1353,7 @@ namespace test {
const XcursorImage* GetCachedXcursorImage(::Cursor cursor) {
return XCustomCursorCache::GetInstance()->GetXcursorImage(cursor);
}
-}
+} // namespace test
// ----------------------------------------------------------------------------
// These functions are declared in x11_util_internal.h because they require
@@ -1459,11 +1376,9 @@ XRenderPictFormat* GetRenderARGB32Format(XDisplay* dpy) {
templ.direct.alphaMask = 0;
static const unsigned long kMask =
- PictFormatType | PictFormatDepth |
- PictFormatRed | PictFormatRedMask |
- PictFormatGreen | PictFormatGreenMask |
- PictFormatBlue | PictFormatBlueMask |
- PictFormatAlphaMask;
+ PictFormatType | PictFormatDepth | PictFormatRed | PictFormatRedMask |
+ PictFormatGreen | PictFormatGreenMask | PictFormatBlue |
+ PictFormatBlueMask | PictFormatAlphaMask;
pictformat = XRenderFindFormat(dpy, kMask, &templ, 0 /* first result */);
@@ -1480,51 +1395,8 @@ XRenderPictFormat* GetRenderARGB32Format(XDisplay* dpy) {
void SetX11ErrorHandlers(XErrorHandler error_handler,
XIOErrorHandler io_error_handler) {
XSetErrorHandler(error_handler ? error_handler : DefaultX11ErrorHandler);
- XSetIOErrorHandler(
- io_error_handler ? io_error_handler : DefaultX11IOErrorHandler);
-}
-
-void LogErrorEventDescription(XDisplay* dpy,
- const XErrorEvent& error_event) {
- char error_str[256];
- char request_str[256];
-
- XGetErrorText(dpy, error_event.error_code, error_str, sizeof(error_str));
-
- strncpy(request_str, "Unknown", sizeof(request_str));
- if (error_event.request_code < 128) {
- std::string num = base::NumberToString(error_event.request_code);
- XGetErrorDatabaseText(
- dpy, "XRequest", num.c_str(), "Unknown", request_str,
- sizeof(request_str));
- } else {
- int num_ext;
- gfx::XScopedPtr<char* [],
- gfx::XObjectDeleter<char*, int, XFreeExtensionList>>
- ext_list(XListExtensions(dpy, &num_ext));
-
- for (int i = 0; i < num_ext; i++) {
- int ext_code, first_event, first_error;
- XQueryExtension(dpy, ext_list[i], &ext_code, &first_event, &first_error);
- if (error_event.request_code == ext_code) {
- std::string msg = base::StringPrintf(
- "%s.%d", ext_list[i], error_event.minor_code);
- XGetErrorDatabaseText(
- dpy, "XRequest", msg.c_str(), "Unknown", request_str,
- sizeof(request_str));
- break;
- }
- }
- }
-
- LOG(WARNING)
- << "X error received: "
- << "serial " << error_event.serial << ", "
- << "error_code " << static_cast<int>(error_event.error_code)
- << " (" << error_str << "), "
- << "request_code " << static_cast<int>(error_event.request_code) << ", "
- << "minor_code " << static_cast<int>(error_event.minor_code)
- << " (" << request_str << ")";
+ XSetIOErrorHandler(io_error_handler ? io_error_handler
+ : DefaultX11IOErrorHandler);
}
// static
@@ -1577,7 +1449,7 @@ XVisualManager::XVisualManager()
DCHECK(visuals_.find(transparent_visual_id_) != visuals_.end());
}
-XVisualManager::~XVisualManager() {}
+XVisualManager::~XVisualManager() = default;
void XVisualManager::ChooseVisualForWindow(bool want_argb_visual,
Visual** visual,
@@ -1648,7 +1520,8 @@ bool XVisualManager::GetVisualInfoImpl(VisualID visual_id,
if (depth)
*depth = visual_info.depth;
if (colormap)
- *colormap = is_default_visual ? CopyFromParent : visual_data.GetColormap();
+ *colormap =
+ is_default_visual ? 0 /* CopyFromParent */ : visual_data.GetColormap();
if (visual_has_alpha) {
auto popcount = [](auto x) {
return std::bitset<8 * sizeof(decltype(x))>(x).count();
@@ -1662,16 +1535,15 @@ bool XVisualManager::GetVisualInfoImpl(VisualID visual_id,
}
XVisualManager::XVisualData::XVisualData(XVisualInfo visual_info)
- : visual_info(visual_info), colormap_(CopyFromParent) {}
+ : visual_info(visual_info), colormap_(0 /* CopyFromParent */) {}
-XVisualManager::XVisualData::~XVisualData() {
- // Do not XFreeColormap as this would uninstall the colormap even for
- // non-Chromium clients.
-}
+// Do not XFreeColormap as this would uninstall the colormap even for
+// non-Chromium clients.
+XVisualManager::XVisualData::~XVisualData() = default;
Colormap XVisualManager::XVisualData::GetColormap() {
XDisplay* display = gfx::GetXDisplay();
- if (colormap_ == CopyFromParent) {
+ if (colormap_ == 0 /* CopyFromParent */) {
colormap_ = XCreateColormap(display, DefaultRootWindow(display),
visual_info.visual, AllocNone);
}
@@ -1681,5 +1553,4 @@ Colormap XVisualManager::XVisualData::GetColormap() {
// ----------------------------------------------------------------------------
// End of x11_util_internal.h
-
} // namespace ui
diff --git a/chromium/ui/base/x/x11_util.h b/chromium/ui/base/x/x11_util.h
index 0f6c5391b35..ff1dd2c5635 100644
--- a/chromium/ui/base/x/x11_util.h
+++ b/chromium/ui/base/x/x11_util.h
@@ -67,10 +67,10 @@ COMPONENT_EXPORT(UI_BASE_X) void RefCustomXCursor(::Cursor cursor);
// Decreases the refcount of the custom cursor, and destroys it if it reaches 0.
COMPONENT_EXPORT(UI_BASE_X) void UnrefCustomXCursor(::Cursor cursor);
-// Creates a XcursorImage and copies the SkBitmap |bitmap| on it. |bitmap|
-// should be non-null. Caller owns the returned object.
+// Creates a XcursorImage and copies the SkBitmap |bitmap| on it. Caller owns
+// the returned object.
COMPONENT_EXPORT(UI_BASE_X)
-XcursorImage* SkBitmapToXcursorImage(const SkBitmap* bitmap,
+XcursorImage* SkBitmapToXcursorImage(const SkBitmap& bitmap,
const gfx::Point& hotspot);
// Coalesce all pending motion events (touch or mouse) that are at the top of
diff --git a/chromium/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc b/chromium/ui/base/x/x11_whole_screen_move_loop.cc
index 01509c2d677..2f7aaf4037a 100644
--- a/chromium/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.cc
+++ b/chromium/ui/base/x/x11_whole_screen_move_loop.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h"
+#include "ui/base/x/x11_whole_screen_move_loop.h"
#include <stddef.h>
@@ -16,12 +16,6 @@
#include "base/single_thread_task_runner.h"
#include "base/stl_util.h"
#include "base/threading/thread_task_runner_handle.h"
-#include "ui/aura/client/capture_client.h"
-#include "ui/aura/env.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_event_dispatcher.h"
-#include "ui/aura/window_tree_host.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
#include "ui/base/x/x11_pointer_grab.h"
#include "ui/base/x/x11_util.h"
#include "ui/events/event.h"
@@ -34,7 +28,7 @@
#include "ui/events/x/x11_window_event_manager.h"
#include "ui/gfx/x/x11.h"
-namespace views {
+namespace ui {
// XGrabKey requires the modifier mask to explicitly be specified.
const unsigned int kModifiersMasks[] = {0, // No additional modifier.
@@ -49,8 +43,7 @@ const unsigned int kModifiersMasks[] = {0, // No additional modifier.
X11WholeScreenMoveLoop::X11WholeScreenMoveLoop(X11MoveLoopDelegate* delegate)
: delegate_(delegate),
in_move_loop_(false),
- initial_cursor_(ui::mojom::CursorType::kNull),
- should_reset_mouse_flags_(false),
+ initial_cursor_(x11::None),
grab_input_window_(x11::None),
grabbed_pointer_(false),
canceled_(false) {}
@@ -129,29 +122,28 @@ uint32_t X11WholeScreenMoveLoop::DispatchEvent(const ui::PlatformEvent& event) {
return ui::POST_DISPATCH_PERFORM_DEFAULT;
}
-bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source,
- gfx::NativeCursor cursor) {
+bool X11WholeScreenMoveLoop::RunMoveLoop(bool can_grab_pointer,
+ ::Cursor old_cursor,
+ ::Cursor new_cursor) {
DCHECK(!in_move_loop_); // Can only handle one nested loop at a time.
// Query the mouse cursor prior to the move loop starting so that it can be
// restored when the move loop finishes.
- initial_cursor_ = source->GetHost()->last_cursor();
+ initial_cursor_ = old_cursor;
CreateDragInputWindow(gfx::GetXDisplay());
- // Only grab mouse capture of |grab_input_window_| if |source| does not have
- // capture.
- // - The caller may intend to transfer capture to a different aura::Window
+ // Only grab mouse capture of |grab_input_window_| if |can_grab_pointer| is
+ // true aka the source that initiated the move loop doesn't have explicit
+ // grab.
+ // - The caller may intend to transfer capture to a different X11Window
// when the move loop ends and not release capture.
// - Releasing capture and X window destruction are both asynchronous. We drop
// events targeted at |grab_input_window_| in the time between the move
// loop ends and |grab_input_window_| loses capture.
grabbed_pointer_ = false;
- if (!source->HasCapture()) {
- aura::client::CaptureClient* capture_client =
- aura::client::GetCaptureClient(source->GetRootWindow());
- CHECK(capture_client->GetGlobalCaptureWindow() == nullptr);
- grabbed_pointer_ = GrabPointer(cursor);
+ if (can_grab_pointer) {
+ grabbed_pointer_ = GrabPointer(new_cursor);
if (!grabbed_pointer_) {
XDestroyWindow(gfx::GetXDisplay(), grab_input_window_);
return false;
@@ -165,15 +157,6 @@ bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source,
nested_dispatcher_ =
ui::PlatformEventSource::GetInstance()->OverrideDispatcher(this);
- // We are handling a mouse drag outside of the aura::Window system. We must
- // manually make aura think that the mouse button is pressed so that we don't
- // draw extraneous tooltips.
- aura::Env* env = aura::Env::GetInstance();
- if (!env->IsMouseButtonDown()) {
- env->set_mouse_button_flags(ui::EF_LEFT_MOUSE_BUTTON);
- should_reset_mouse_flags_ = true;
- }
-
base::WeakPtr<X11WholeScreenMoveLoop> alive(weak_factory_.GetWeakPtr());
in_move_loop_ = true;
@@ -189,9 +172,9 @@ bool X11WholeScreenMoveLoop::RunMoveLoop(aura::Window* source,
return !canceled_;
}
-void X11WholeScreenMoveLoop::UpdateCursor(gfx::NativeCursor cursor) {
+void X11WholeScreenMoveLoop::UpdateCursor(::Cursor cursor) {
if (in_move_loop_)
- ui::ChangeActivePointerGrabCursor(cursor.platform());
+ ui::ChangeActivePointerGrabCursor(cursor);
}
void X11WholeScreenMoveLoop::EndMoveLoop() {
@@ -201,12 +184,6 @@ void X11WholeScreenMoveLoop::EndMoveLoop() {
// Prevent DispatchMouseMovement from dispatching any posted motion event.
last_motion_in_screen_.reset();
- // We undo our emulated mouse click from RunMoveLoop();
- if (should_reset_mouse_flags_) {
- aura::Env::GetInstance()->set_mouse_button_flags(0);
- should_reset_mouse_flags_ = false;
- }
-
// TODO(erg): Is this ungrab the cause of having to click to give input focus
// on drawn out windows? Not ungrabbing here screws the X server until I kill
// the chrome process.
@@ -233,12 +210,12 @@ void X11WholeScreenMoveLoop::EndMoveLoop() {
std::move(quit_closure_).Run();
}
-bool X11WholeScreenMoveLoop::GrabPointer(gfx::NativeCursor cursor) {
+bool X11WholeScreenMoveLoop::GrabPointer(::Cursor cursor) {
XDisplay* display = gfx::GetXDisplay();
// Pass "owner_events" as false so that X sends all mouse events to
// |grab_input_window_|.
- int ret = ui::GrabPointer(grab_input_window_, false, cursor.platform());
+ int ret = ui::GrabPointer(grab_input_window_, false, cursor);
if (ret != GrabSuccess) {
DLOG(ERROR) << "Grabbing pointer for dragging failed: "
<< ui::GetX11ErrorString(display, ret);
@@ -272,4 +249,4 @@ void X11WholeScreenMoveLoop::CreateDragInputWindow(XDisplay* display) {
XMapRaised(display, grab_input_window_);
}
-} // namespace views
+} // namespace ui
diff --git a/chromium/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h b/chromium/ui/base/x/x11_whole_screen_move_loop.h
index 1fa5bbd5cca..1132b905529 100644
--- a/chromium/ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h
+++ b/chromium/ui/base/x/x11_whole_screen_move_loop.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_
-#define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_
+#ifndef UI_BASE_X_X11_WHOLE_SCREEN_MOVE_LOOP_H_
+#define UI_BASE_X_X11_WHOLE_SCREEN_MOVE_LOOP_H_
#include <stdint.h>
@@ -11,33 +11,27 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
+#include "base/component_export.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
-#include "ui/base/cursor/cursor.h"
+#include "ui/base/x/x11_move_loop.h"
+#include "ui/base/x/x11_move_loop_delegate.h"
#include "ui/events/platform/platform_event_dispatcher.h"
#include "ui/gfx/geometry/vector2d_f.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/x11_types.h"
-#include "ui/views/widget/desktop_aura/x11_move_loop.h"
-#include "ui/views/widget/desktop_aura/x11_move_loop_delegate.h"
-
-namespace aura {
-class Window;
-}
namespace ui {
class MouseEvent;
class ScopedEventDispatcher;
class XScopedEventSelector;
-} // namespace ui
-
-namespace views {
// Runs a nested run loop and grabs the mouse. This is used to implement
// dragging.
-class X11WholeScreenMoveLoop : public X11MoveLoop,
- public ui::PlatformEventDispatcher {
+class COMPONENT_EXPORT(UI_BASE_X) X11WholeScreenMoveLoop
+ : public X11MoveLoop,
+ public ui::PlatformEventDispatcher {
public:
explicit X11WholeScreenMoveLoop(X11MoveLoopDelegate* delegate);
~X11WholeScreenMoveLoop() override;
@@ -47,14 +41,16 @@ class X11WholeScreenMoveLoop : public X11MoveLoop,
uint32_t DispatchEvent(const ui::PlatformEvent& event) override;
// X11MoveLoop:
- bool RunMoveLoop(aura::Window* window, gfx::NativeCursor cursor) override;
- void UpdateCursor(gfx::NativeCursor cursor) override;
+ bool RunMoveLoop(bool can_grab_pointer,
+ ::Cursor old_cursor,
+ ::Cursor new_cursor) override;
+ void UpdateCursor(::Cursor cursor) override;
void EndMoveLoop() override;
private:
// Grabs the pointer, setting the mouse cursor to |cursor|. Returns true if
// successful.
- bool GrabPointer(gfx::NativeCursor cursor);
+ bool GrabPointer(::Cursor cursor);
void GrabEscKey();
@@ -74,9 +70,7 @@ class X11WholeScreenMoveLoop : public X11MoveLoop,
// Cursor in use prior to the move loop starting. Restored when the move loop
// quits.
- gfx::NativeCursor initial_cursor_;
-
- bool should_reset_mouse_flags_;
+ ::Cursor initial_cursor_;
// An invisible InputOnly window. Keyboard grab and sometimes mouse grab
// are set on this window.
@@ -100,6 +94,6 @@ class X11WholeScreenMoveLoop : public X11MoveLoop,
DISALLOW_COPY_AND_ASSIGN(X11WholeScreenMoveLoop);
};
-} // namespace views
+} // namespace ui
-#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_WHOLE_SCREEN_MOVE_LOOP_H_
+#endif // UI_BASE_X_X11_WHOLE_SCREEN_MOVE_LOOP_H_
diff --git a/chromium/ui/base/x/x11_window.cc b/chromium/ui/base/x/x11_window.cc
index f58ab14a3a0..70f520bccd4 100644
--- a/chromium/ui/base/x/x11_window.cc
+++ b/chromium/ui/base/x/x11_window.cc
@@ -643,6 +643,11 @@ void XWindow::SetBounds(const gfx::Rect& requested_bounds_in_pixels) {
// |bounds_in_pixels_| later.
bounds_in_pixels_ = bounds_in_pixels;
ResetWindowRegion();
+
+ // Even if the pixel bounds didn't change this call to the delegate should
+ // still happen. The device scale factor may have changed which effectively
+ // changes the bounds.
+ OnXWindowBoundsChanged(bounds_in_pixels);
}
bool XWindow::IsXWindowVisible() const {
@@ -721,6 +726,7 @@ void XWindow::StackXWindowAtTop() {
}
void XWindow::SetCursor(::Cursor cursor) {
+ last_cursor_ = cursor;
XDefineCursor(xdisplay_, xwindow_, cursor);
}
@@ -1398,8 +1404,6 @@ void XWindow::DispatchResize() {
}
void XWindow::DelayedResize(const gfx::Rect& bounds_in_pixels) {
- base::WeakPtr<XWindow> alive(resize_weak_factory_.GetWeakPtr());
-
if (configure_counter_value_is_extended_ &&
(current_counter_value_ % 2) == 0) {
// Increase the |extended_update_counter_|, so the compositor will know we
@@ -1409,16 +1413,13 @@ void XWindow::DelayedResize(const gfx::Rect& bounds_in_pixels) {
SyncSetCounter(xdisplay_, extended_update_counter_,
++current_counter_value_);
}
- NotifyBoundsChanged(bounds_in_pixels);
-
- // Bounds change propagation above may spin a window move loop, which might
- // end up closing and destroying this instance (e.g: when a chrome window is
- // snapped into a tab strip). So we must handle this possible scenario before
- // trying to access any class variable/function. See crbug.com/1068755.
- if (!alive)
- return;
CancelResize();
+ NotifyBoundsChanged(bounds_in_pixels);
+
+ // No more member accesses here: bounds change propagation may have deleted
+ // |this| (e.g. when a chrome window is snapped into a tab strip. Further
+ // details at crbug.com/1068755).
}
void XWindow::CancelResize() {
diff --git a/chromium/ui/base/x/x11_window.h b/chromium/ui/base/x/x11_window.h
index d0f852b1d69..feec9b62e6d 100644
--- a/chromium/ui/base/x/x11_window.h
+++ b/chromium/ui/base/x/x11_window.h
@@ -169,6 +169,7 @@ class COMPONENT_EXPORT(UI_BASE_X) XWindow {
::Region shape() const { return window_shape_.get(); }
XID update_counter() const { return update_counter_; }
XID extended_update_counter() const { return extended_update_counter_; }
+ ::Cursor last_cursor() const { return last_cursor_; }
protected:
// Updates |xwindow_|'s _NET_WM_USER_TIME if |xwindow_| is active.
@@ -378,7 +379,7 @@ class COMPONENT_EXPORT(UI_BASE_X) XWindow {
bool has_pointer_barriers_ = false;
std::array<XID, 4> pointer_barriers_;
- base::WeakPtrFactory<XWindow> resize_weak_factory_{this};
+ ::Cursor last_cursor_ = x11::None;
};
} // namespace ui
diff --git a/chromium/ui/base/x/x11_workspace_handler.cc b/chromium/ui/base/x/x11_workspace_handler.cc
index 223c3c44d7c..72ea0fb82d5 100644
--- a/chromium/ui/base/x/x11_workspace_handler.cc
+++ b/chromium/ui/base/x/x11_workspace_handler.cc
@@ -7,10 +7,27 @@
#include "base/strings/string_number_conversions.h"
#include "ui/base/x/x11_util.h"
#include "ui/events/x/x11_window_event_manager.h"
+#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/x11_atom_cache.h"
+#include "ui/gfx/x/xproto.h"
namespace ui {
+namespace {
+
+x11::Future<x11::XProto::GetPropertyReply> GetWorkspace() {
+ auto* connection = x11::Connection::Get();
+ return connection->GetProperty({
+ .window =
+ static_cast<x11::Window>(XDefaultRootWindow(connection->display())),
+ .property = static_cast<x11::Atom>(gfx::GetAtom("_NET_CURRENT_DESKTOP")),
+ .type = static_cast<x11::Atom>(gfx::GetAtom("CARDINAL")),
+ .long_length = 1,
+ });
+}
+
+} // namespace
+
X11WorkspaceHandler::X11WorkspaceHandler(Delegate* delegate)
: xdisplay_(gfx::GetXDisplay()),
x_root_window_(DefaultRootWindow(xdisplay_)),
@@ -30,19 +47,10 @@ X11WorkspaceHandler::~X11WorkspaceHandler() {
std::string X11WorkspaceHandler::GetCurrentWorkspace() {
if (workspace_.empty())
- UpdateWorkspace();
+ OnWorkspaceResponse(GetWorkspace().Sync());
return workspace_;
}
-bool X11WorkspaceHandler::UpdateWorkspace() {
- int desktop;
- if (ui::GetCurrentDesktop(&desktop)) {
- workspace_ = base::NumberToString(desktop);
- return true;
- }
- return false;
-}
-
bool X11WorkspaceHandler::DispatchXEvent(XEvent* event) {
if (event->type != PropertyNotify ||
event->xproperty.window != x_root_window_) {
@@ -51,8 +59,9 @@ bool X11WorkspaceHandler::DispatchXEvent(XEvent* event) {
switch (event->type) {
case PropertyNotify: {
if (event->xproperty.atom == gfx::GetAtom("_NET_CURRENT_DESKTOP")) {
- if (UpdateWorkspace())
- delegate_->OnCurrentWorkspaceChanged(workspace_);
+ GetWorkspace().OnResponse(
+ base::BindOnce(&X11WorkspaceHandler::OnWorkspaceResponse,
+ weak_factory_.GetWeakPtr()));
}
break;
}
@@ -62,4 +71,17 @@ bool X11WorkspaceHandler::DispatchXEvent(XEvent* event) {
return false;
}
+void X11WorkspaceHandler::OnWorkspaceResponse(
+ x11::XProto::GetPropertyResponse response) {
+ if (!response || response->format != 32 || response->value.size() < 4)
+ return;
+ DCHECK_EQ(response->bytes_after, 0U);
+ DCHECK_EQ(response->type, static_cast<x11::Atom>(gfx::GetAtom("CARDINAL")));
+
+ uint32_t workspace;
+ memcpy(&workspace, response->value.data(), 4);
+ workspace_ = base::NumberToString(workspace);
+ delegate_->OnCurrentWorkspaceChanged(workspace_);
+}
+
} // namespace ui
diff --git a/chromium/ui/base/x/x11_workspace_handler.h b/chromium/ui/base/x/x11_workspace_handler.h
index 8a9afe75afa..b60f91a9f56 100644
--- a/chromium/ui/base/x/x11_workspace_handler.h
+++ b/chromium/ui/base/x/x11_workspace_handler.h
@@ -8,8 +8,10 @@
#include <memory>
#include "base/component_export.h"
+#include "base/memory/weak_ptr.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/x/x11.h"
+#include "ui/gfx/x/xproto.h"
namespace ui {
@@ -40,8 +42,7 @@ class COMPONENT_EXPORT(UI_BASE_X) X11WorkspaceHandler
// ui::XEventDispatcher
bool DispatchXEvent(XEvent* event) override;
- // Makes a round trip to the X server to get the current workspace.
- bool UpdateWorkspace();
+ void OnWorkspaceResponse(x11::XProto::GetPropertyResponse response);
// The display and the native X window hosting the root window.
XDisplay* xdisplay_;
@@ -55,6 +56,8 @@ class COMPONENT_EXPORT(UI_BASE_X) X11WorkspaceHandler
std::string workspace_;
Delegate* const delegate_;
+
+ base::WeakPtrFactory<X11WorkspaceHandler> weak_factory_{this};
};
} // namespace ui
diff --git a/chromium/ui/chromeos/BUILD.gn b/chromium/ui/chromeos/BUILD.gn
index 8f55d2d4b3c..89da79afca0 100644
--- a/chromium/ui/chromeos/BUILD.gn
+++ b/chromium/ui/chromeos/BUILD.gn
@@ -11,6 +11,7 @@ component("chromeos") {
sources = [
"devicetype_utils.cc",
"devicetype_utils.h",
+ "ime/assistive_delegate.h",
"ime/candidate_view.cc",
"ime/candidate_view.h",
"ime/candidate_window_constants.h",
@@ -26,6 +27,8 @@ component("chromeos") {
"ime/suggestion_view.h",
"ime/suggestion_window_view.cc",
"ime/suggestion_window_view.h",
+ "ime/undo_window.cc",
+ "ime/undo_window.h",
"user_activity_power_manager_notifier.cc",
"user_activity_power_manager_notifier.h",
]
@@ -42,6 +45,7 @@ component("chromeos") {
"//services/device/public/mojom",
"//services/service_manager/public/cpp",
"//skia",
+ "//ui/accessibility:ax_base",
"//ui/aura",
"//ui/base",
"//ui/base/ime",
diff --git a/chromium/ui/color/BUILD.gn b/chromium/ui/color/BUILD.gn
index 3b81686b53d..a39c290e6b4 100644
--- a/chromium/ui/color/BUILD.gn
+++ b/chromium/ui/color/BUILD.gn
@@ -84,14 +84,19 @@ jumbo_component("mixers") {
public_deps = [ "//base" ]
if (is_chromeos) {
- sources += [ "cros/native_color_mixer.cc" ]
+ sources += [ "cros/native_color_mixers.cc" ]
} else if (is_fuchsia) {
- sources += [ "fuchsia/native_color_mixer.cc" ]
+ sources += [ "fuchsia/native_color_mixers.cc" ]
} else if (is_linux) {
- sources += [ "linux/native_color_mixer.cc" ]
+ sources += [ "linux/native_color_mixers.cc" ]
} else if (is_mac) {
- sources += [ "mac/native_color_mixer.cc" ]
+ libs = [ "AppKit.framework" ]
+ sources += [
+ "mac/native_color_mixers.mm",
+ "mac/scoped_current_nsappearance.h",
+ "mac/scoped_current_nsappearance.mm",
+ ]
} else if (is_win) {
- sources += [ "win/native_color_mixer.cc" ]
+ sources += [ "win/native_color_mixers.cc" ]
}
}
diff --git a/chromium/ui/color/DEPS b/chromium/ui/color/DEPS
index 41134f52feb..71c08463be7 100644
--- a/chromium/ui/color/DEPS
+++ b/chromium/ui/color/DEPS
@@ -1,4 +1,5 @@
include_rules = [
"+third_party/skia/include",
+ "+skia/ext",
"+ui/gfx",
]
diff --git a/chromium/ui/color/color_id.h b/chromium/ui/color/color_id.h
index ea3a9470860..43304ff2d8f 100644
--- a/chromium/ui/color/color_id.h
+++ b/chromium/ui/color/color_id.h
@@ -5,6 +5,7 @@
#ifndef UI_COLOR_COLOR_ID_H_
#define UI_COLOR_COLOR_ID_H_
+#include "base/logging.h"
#include "build/build_config.h"
#include "build/buildflag.h"
@@ -28,7 +29,7 @@
E(kColorBubbleBackground, NativeTheme::kColorId_BubbleBackground) \
E(kColorBubbleFooterBackground, \
NativeTheme::kColorId_BubbleFooterBackground) \
- E(kColorButtonBackground, NativeTheme::kColorId_DialogBackground) \
+ E(kColorButtonBackground, NativeTheme::kColorId_ButtonColor) \
E(kColorButtonBorder, NativeTheme::kColorId_ButtonBorderColor) \
E(kColorButtonDisabledForeground, NativeTheme::kColorId_ButtonDisabledColor) \
E(kColorButtonForeground, NativeTheme::kColorId_ButtonEnabledColor) \
@@ -49,6 +50,7 @@
E(kColorFocusableBorderFocused, NativeTheme::kColorId_FocusedBorderColor) \
E(kColorFocusableBorderUnfocused, \
NativeTheme::kColorId_UnfocusedBorderColor) \
+ E(kColorMenuIcon, NativeTheme::kColorId_MenuIconColor) \
E(kColorIcon, NativeTheme::kColorId_DefaultIconColor) \
E(kColorLabelDisabledForeground, NativeTheme::kColorId_LabelDisabledColor) \
E(kColorLabelForeground, NativeTheme::kColorId_LabelEnabledColor) \
@@ -86,8 +88,6 @@
E(kColorTabSelectedForeground, \
NativeTheme::kColorId_TabTitleColorActive) \
E(kColorTableBackground, NativeTheme::kColorId_TableBackground) \
- E(kColorTableBackgroundAlternate, \
- NativeTheme::kColorId_TableBackgroundAlternate) \
E(kColorTableForeground, NativeTheme::kColorId_TableText) \
E(kColorTableGroupingIndicator, \
NativeTheme::kColorId_TableGroupingIndicatorColor) \
@@ -165,10 +165,20 @@
E(kColorNativeWindowText, COLOR_WINDOWTEXT)
#endif
+#if defined(OS_MACOSX)
+#define MACOSX_COLOR_IDS \
+ E(kColorTableBackgroundAlternate, \
+ NativeTheme::kColorId_TableBackgroundAlternate)
+#endif
+
#if defined(OS_WIN)
#define COLOR_IDS \
CROSS_PLATFORM_COLOR_IDS \
WIN_COLOR_IDS
+#elif defined(OS_MACOSX)
+#define COLOR_IDS \
+ CROSS_PLATFORM_COLOR_IDS \
+ MACOSX_COLOR_IDS
#else
#define COLOR_IDS CROSS_PLATFORM_COLOR_IDS
#endif
diff --git a/chromium/ui/color/color_mixers.h b/chromium/ui/color/color_mixers.h
index 0ca317a3896..07647e2718f 100644
--- a/chromium/ui/color/color_mixers.h
+++ b/chromium/ui/color/color_mixers.h
@@ -11,20 +11,30 @@ namespace ui {
class ColorProvider;
-// Adds color mixers to |provider| that provide kColorSetNative, as well as
-// mappings from this set to cross-platform IDs. This function should be
-// implemented on a per-platform basis in relevant subdirectories.
-COMPONENT_EXPORT(COLOR) void AddNativeColorMixers(ColorProvider* provider);
+// The ordering of the mixer functions below reflects the
+// order in which they are added to the providers.
-// Adds color mixers to |provider| that provide kColorSetCoreDefaults.
+// Adds a color mixer to |provider| that provide kColorSetCoreDefaults.
// |dark window| should be set if the window for this provider is "dark themed",
// e.g. system native dark mode is enabled or the window is incognito.
COMPONENT_EXPORT(COLOR)
-void AddCoreDefaultColorMixers(ColorProvider* provider, bool dark_window);
+void AddCoreDefaultColorMixer(ColorProvider* provider, bool dark_window);
-// Adds color mixers to |provider| that combine the above color sets with
+// Adds a color mixer to |provider| that provide kColorSetNative.
+// This function should be implemented on a per-platform basis in
+// relevant subdirectories.
+COMPONENT_EXPORT(COLOR)
+void AddNativeCoreColorMixer(ColorProvider* provider, bool dark_window);
+
+// Adds a color mixer to |provider| that combine the above color sets with
// recipes as necessary to produce all colors needed by ui/.
-COMPONENT_EXPORT(COLOR) void AddUiColorMixers(ColorProvider* provider);
+COMPONENT_EXPORT(COLOR) void AddUiColorMixer(ColorProvider* provider);
+
+// Adds a color mixer to |provider| that can add to kColorSetNative.
+// Intended for colors needed by ui/ that this platform overrides but
+// are outside the set defined in the core mixer.
+COMPONENT_EXPORT(COLOR)
+void AddNativeUiColorMixer(ColorProvider* provider, bool dark_window);
} // namespace ui
diff --git a/chromium/ui/color/color_provider_manager.cc b/chromium/ui/color/color_provider_manager.cc
index e7bd7e5ef79..be2b1b3ed25 100644
--- a/chromium/ui/color/color_provider_manager.cc
+++ b/chromium/ui/color/color_provider_manager.cc
@@ -6,7 +6,7 @@
#include <algorithm>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/no_destructor.h"
#include "base/optional.h"
#include "ui/color/color_provider.h"
diff --git a/chromium/ui/color/core_default_color_mixer.cc b/chromium/ui/color/core_default_color_mixer.cc
index dbdd4b5d2ed..6552471e7d2 100644
--- a/chromium/ui/color/core_default_color_mixer.cc
+++ b/chromium/ui/color/core_default_color_mixer.cc
@@ -58,7 +58,7 @@ ColorMixer& AddMixerForLightMode(ColorProvider* provider) {
} // namespace
-void AddCoreDefaultColorMixers(ColorProvider* provider, bool dark_window) {
+void AddCoreDefaultColorMixer(ColorProvider* provider, bool dark_window) {
ColorMixer& mixer = dark_window ? AddMixerForDarkMode(provider)
: AddMixerForLightMode(provider);
mixer[kColorDisabledForeground] = BlendForMinContrast(
diff --git a/chromium/ui/color/cros/native_color_mixer.cc b/chromium/ui/color/cros/native_color_mixer.cc
deleted file mode 100644
index 67253b447f4..00000000000
--- a/chromium/ui/color/cros/native_color_mixer.cc
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2019 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 "ui/color/color_mixers.h"
-
-#include "base/logging.h"
-
-namespace ui {
-
-void AddNativeColorMixers(ColorProvider* provider) {
- NOTIMPLEMENTED();
-}
-
-} // namespace ui
diff --git a/chromium/ui/color/fuchsia/native_color_mixer.cc b/chromium/ui/color/cros/native_color_mixers.cc
index 825e5e5fc89..2ea973bff1f 100644
--- a/chromium/ui/color/fuchsia/native_color_mixer.cc
+++ b/chromium/ui/color/cros/native_color_mixers.cc
@@ -4,11 +4,15 @@
#include "ui/color/color_mixers.h"
-#include "base/logging.h"
+#include "base/notreached.h"
namespace ui {
-void AddNativeColorMixers(ColorProvider* provider) {
+void AddNativeCoreColorMixer(ColorProvider* provider, bool dark_window) {
+ NOTIMPLEMENTED();
+}
+
+void AddNativeUiColorMixer(ColorProvider* provider, bool dark_window) {
NOTIMPLEMENTED();
}
diff --git a/chromium/ui/color/fuchsia/native_color_mixers.cc b/chromium/ui/color/fuchsia/native_color_mixers.cc
new file mode 100644
index 00000000000..2ea973bff1f
--- /dev/null
+++ b/chromium/ui/color/fuchsia/native_color_mixers.cc
@@ -0,0 +1,19 @@
+// Copyright 2020 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 "ui/color/color_mixers.h"
+
+#include "base/notreached.h"
+
+namespace ui {
+
+void AddNativeCoreColorMixer(ColorProvider* provider, bool dark_window) {
+ NOTIMPLEMENTED();
+}
+
+void AddNativeUiColorMixer(ColorProvider* provider, bool dark_window) {
+ NOTIMPLEMENTED();
+}
+
+} // namespace ui
diff --git a/chromium/ui/color/linux/native_color_mixer.cc b/chromium/ui/color/linux/native_color_mixer.cc
deleted file mode 100644
index 67253b447f4..00000000000
--- a/chromium/ui/color/linux/native_color_mixer.cc
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2019 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 "ui/color/color_mixers.h"
-
-#include "base/logging.h"
-
-namespace ui {
-
-void AddNativeColorMixers(ColorProvider* provider) {
- NOTIMPLEMENTED();
-}
-
-} // namespace ui
diff --git a/chromium/ui/color/linux/native_color_mixers.cc b/chromium/ui/color/linux/native_color_mixers.cc
new file mode 100644
index 00000000000..2ea973bff1f
--- /dev/null
+++ b/chromium/ui/color/linux/native_color_mixers.cc
@@ -0,0 +1,19 @@
+// Copyright 2020 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 "ui/color/color_mixers.h"
+
+#include "base/notreached.h"
+
+namespace ui {
+
+void AddNativeCoreColorMixer(ColorProvider* provider, bool dark_window) {
+ NOTIMPLEMENTED();
+}
+
+void AddNativeUiColorMixer(ColorProvider* provider, bool dark_window) {
+ NOTIMPLEMENTED();
+}
+
+} // namespace ui
diff --git a/chromium/ui/color/mac/native_color_mixer.cc b/chromium/ui/color/mac/native_color_mixer.cc
deleted file mode 100644
index 67253b447f4..00000000000
--- a/chromium/ui/color/mac/native_color_mixer.cc
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright 2019 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 "ui/color/color_mixers.h"
-
-#include "base/logging.h"
-
-namespace ui {
-
-void AddNativeColorMixers(ColorProvider* provider) {
- NOTIMPLEMENTED();
-}
-
-} // namespace ui
diff --git a/chromium/ui/color/mac/native_color_mixers.mm b/chromium/ui/color/mac/native_color_mixers.mm
new file mode 100644
index 00000000000..c90a86f1423
--- /dev/null
+++ b/chromium/ui/color/mac/native_color_mixers.mm
@@ -0,0 +1,66 @@
+// Copyright 2020 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 "ui/color/color_mixers.h"
+
+#import <Cocoa/Cocoa.h>
+#import "skia/ext/skia_utils_mac.h"
+#include "ui/color/color_mixer.h"
+#include "ui/color/color_provider.h"
+#include "ui/color/color_recipe.h"
+#include "ui/color/color_set.h"
+#include "ui/color/mac/scoped_current_nsappearance.h"
+#include "ui/gfx/color_palette.h"
+
+namespace ui {
+
+void AddNativeCoreColorMixer(ColorProvider* provider, bool dark_window) {
+ ScopedCurrentNSAppearance scoped_nsappearance(dark_window);
+ ColorMixer& mixer = provider->AddMixer();
+ mixer.AddSet({kColorSetNative,
+ {
+ {kColorTextSelectionBackground,
+ skia::NSSystemColorToSkColor(
+ [NSColor selectedTextBackgroundColor])},
+ }});
+}
+
+void AddNativeUiColorMixer(ColorProvider* provider, bool dark_window) {
+ ScopedCurrentNSAppearance scoped_nsappearance(dark_window);
+ ColorMixer& mixer = provider->AddMixer();
+ mixer.AddSet(
+ {kColorSetNative,
+ {
+ {kColorFocusableBorderFocused,
+ SkColorSetA(skia::NSSystemColorToSkColor(
+ [NSColor keyboardFocusIndicatorColor]),
+ 0x66)},
+ {kColorMenuBorder, SkColorSetA(SK_ColorBLACK, 0x60)},
+ {kColorMenuItemDisabledForeground,
+ skia::NSSystemColorToSkColor([NSColor disabledControlTextColor])},
+ {kColorMenuItemForeground,
+ skia::NSSystemColorToSkColor([NSColor controlTextColor])},
+ {kColorTextSelectionBackground,
+ skia::NSSystemColorToSkColor(
+ [NSColor selectedTextBackgroundColor])},
+ }});
+
+ mixer[kColorMenuItemHighlightedForeground] = {kColorPrimaryForeground};
+ mixer[kColorMenuItemSelectedForeground] = {kColorPrimaryForeground};
+
+ if (@available(macOS 10.14, *)) {
+ mixer[kColorTableBackgroundAlternate] = {skia::NSSystemColorToSkColor(
+ NSColor.alternatingContentBackgroundColors[1])};
+ } else {
+ mixer[kColorTableBackgroundAlternate] = {skia::NSSystemColorToSkColor(
+ NSColor.controlAlternatingRowBackgroundColors[1])};
+ }
+
+ SkColor menu_separator_color = dark_window
+ ? SkColorSetA(gfx::kGoogleGrey800, 0xCC)
+ : SkColorSetA(SK_ColorBLACK, 0x26);
+ mixer[kColorMenuSeparator] = {menu_separator_color};
+}
+
+} // namespace ui
diff --git a/chromium/ui/color/mac/scoped_current_nsappearance.h b/chromium/ui/color/mac/scoped_current_nsappearance.h
new file mode 100644
index 00000000000..7b134c1e68c
--- /dev/null
+++ b/chromium/ui/color/mac/scoped_current_nsappearance.h
@@ -0,0 +1,28 @@
+// Copyright 2020 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 UI_COLOR_MAC_SCOPED_CURRENT_NSAPPEARANCE_H_
+#define UI_COLOR_MAC_SCOPED_CURRENT_NSAPPEARANCE_H_
+
+#include "base/component_export.h"
+
+namespace ui {
+
+// Class for handling changing the NSAppearance to get colors in a scoped way
+// based on the desired light/dark colors scheme.
+class COMPONENT_EXPORT(COLOR) ScopedCurrentNSAppearance {
+ public:
+ explicit ScopedCurrentNSAppearance(bool dark);
+
+ // There should be no reason to copy or move a ScopedCurrentNSAppearance.
+ ScopedCurrentNSAppearance(const ScopedCurrentNSAppearance&) = delete;
+ ScopedCurrentNSAppearance& operator=(const ScopedCurrentNSAppearance&) =
+ delete;
+
+ ~ScopedCurrentNSAppearance();
+};
+
+} // namespace ui
+
+#endif \ No newline at end of file
diff --git a/chromium/ui/color/mac/scoped_current_nsappearance.mm b/chromium/ui/color/mac/scoped_current_nsappearance.mm
new file mode 100644
index 00000000000..62bfad44801
--- /dev/null
+++ b/chromium/ui/color/mac/scoped_current_nsappearance.mm
@@ -0,0 +1,23 @@
+// Copyright 2020 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 "ui/color/mac/scoped_current_nsappearance.h"
+
+#import <Cocoa/Cocoa.h>
+
+namespace ui {
+ScopedCurrentNSAppearance::ScopedCurrentNSAppearance(bool dark) {
+ if (@available(macOS 10.14, *)) {
+ NSAppearanceName appearance =
+ dark ? NSAppearanceNameDarkAqua : NSAppearanceNameAqua;
+ [NSAppearance
+ setCurrentAppearance:[NSAppearance appearanceNamed:appearance]];
+ }
+}
+
+ScopedCurrentNSAppearance::~ScopedCurrentNSAppearance() {
+ if (@available(macOS 10.14, *))
+ [NSAppearance setCurrentAppearance:nil];
+}
+} \ No newline at end of file
diff --git a/chromium/ui/color/run_all_unittests.cc b/chromium/ui/color/run_all_unittests.cc
index 141c20207d5..a1ea172f56b 100644
--- a/chromium/ui/color/run_all_unittests.cc
+++ b/chromium/ui/color/run_all_unittests.cc
@@ -10,6 +10,5 @@ int main(int argc, char* argv[]) {
base::TestSuite test_suite(argc, argv);
return base::LaunchUnitTests(
argc, argv,
- base::BindRepeating(&base::TestSuite::Run,
- base::Unretained(&test_suite)));
+ base::BindOnce(&base::TestSuite::Run, base::Unretained(&test_suite)));
} \ No newline at end of file
diff --git a/chromium/ui/color/ui_color_mixer.cc b/chromium/ui/color/ui_color_mixer.cc
index e7864a3aa89..7949aa26f50 100644
--- a/chromium/ui/color/ui_color_mixer.cc
+++ b/chromium/ui/color/ui_color_mixer.cc
@@ -1,7 +1,7 @@
// Copyright 2019 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 "build/build_config.h"
#include "ui/color/color_mixers.h"
#include "ui/color/color_mixer.h"
@@ -12,7 +12,7 @@
namespace ui {
-void AddUiColorMixers(ColorProvider* provider) {
+void AddUiColorMixer(ColorProvider* provider) {
ColorMixer& mixer = provider->AddMixer();
mixer[kColorBubbleBackground] = {kColorPrimaryBackground};
@@ -35,6 +35,7 @@ void AddUiColorMixers(ColorProvider* provider) {
mixer[kColorFocusableBorderFocused] = SetAlpha(kColorAccent, 0x4D);
mixer[kColorFocusableBorderUnfocused] = {kColorBorderAndSeparatorForeground};
mixer[kColorIcon] = {kColorSecondaryForeground};
+ mixer[kColorMenuIcon] = {kColorIcon};
mixer[kColorLabelDisabledForeground] = {kColorDisabledForeground};
mixer[kColorLabelForeground] = {kColorPrimaryForeground};
mixer[kColorLabelSecondaryForeground] = {kColorSecondaryForeground};
diff --git a/chromium/ui/color/win/native_color_mixer.cc b/chromium/ui/color/win/native_color_mixers.cc
index 1f50142e37c..75b9326f5ac 100644
--- a/chromium/ui/color/win/native_color_mixer.cc
+++ b/chromium/ui/color/win/native_color_mixers.cc
@@ -1,4 +1,4 @@
-// Copyright 2019 The Chromium Authors. All rights reserved.
+// Copyright 2020 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.
@@ -14,7 +14,7 @@
namespace ui {
-void AddMixerForNativeColors(ColorProvider* provider) {
+void AddNativeCoreColorMixer(ColorProvider* provider, bool dark_window) {
// TODO(pkasting): Not clear whether this is really the set of interest.
// Maybe there's some way to query colors used by UxTheme.dll, or maybe we
// should be hardcoding a list of colors for system light/dark modes based on
@@ -58,13 +58,8 @@ void AddMixerForNativeColors(ColorProvider* provider) {
}});
}
-void AddMixerToMapToCrossPlatformIds(ColorProvider* provider) {
+void AddNativeUiColorMixer(ColorProvider* provider, bool dark_window) {
// TODO(pkasting): Add recipes
}
-void AddNativeColorMixers(ColorProvider* provider) {
- AddMixerForNativeColors(provider);
- AddMixerToMapToCrossPlatformIds(provider);
-}
-
} // namespace ui
diff --git a/chromium/ui/compositor/BUILD.gn b/chromium/ui/compositor/BUILD.gn
index 2cf0ce04b69..a9fa6400328 100644
--- a/chromium/ui/compositor/BUILD.gn
+++ b/chromium/ui/compositor/BUILD.gn
@@ -76,6 +76,9 @@ jumbo_component("compositor") {
"scoped_animation_duration_scale_mode.h",
"scoped_layer_animation_settings.cc",
"scoped_layer_animation_settings.h",
+ "throughput_tracker.cc",
+ "throughput_tracker.h",
+ "throughput_tracker_host.h",
"transform_animation_curve_adapter.cc",
"transform_animation_curve_adapter.h",
"transform_recorder.cc",
@@ -190,7 +193,6 @@ jumbo_static_library("test_support") {
]
if (use_x11) {
- configs += [ "//build/config/linux:x11" ]
deps += [
"//ui/events/x",
"//ui/gfx/x",
diff --git a/chromium/ui/compositor/animation_metrics_recorder.cc b/chromium/ui/compositor/animation_metrics_recorder.cc
index 2c9d7b7739d..1b60427856e 100644
--- a/chromium/ui/compositor/animation_metrics_recorder.cc
+++ b/chromium/ui/compositor/animation_metrics_recorder.cc
@@ -4,7 +4,7 @@
#include "ui/compositor/animation_metrics_recorder.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "ui/compositor/animation_metrics_reporter.h"
namespace ui {
diff --git a/chromium/ui/compositor/compositor.cc b/chromium/ui/compositor/compositor.cc
index dd4f89d7676..178fc2628e3 100644
--- a/chromium/ui/compositor/compositor.cc
+++ b/chromium/ui/compositor/compositor.cc
@@ -27,6 +27,7 @@
#include "cc/input/input_handler.h"
#include "cc/layers/layer.h"
#include "cc/metrics/begin_main_frame_metrics.h"
+#include "cc/metrics/frame_sequence_tracker.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_settings.h"
#include "components/viz/common/features.h"
@@ -258,7 +259,7 @@ Compositor::Compositor(const viz::FrameSinkId& frame_sink_id,
}
Compositor::~Compositor() {
- TRACE_EVENT0("shutdown", "Compositor::destructor");
+ TRACE_EVENT0("shutdown,viz", "Compositor::destructor");
for (auto& observer : observer_list_)
observer.OnCompositingShuttingDown(this);
@@ -311,6 +312,7 @@ void Compositor::SetLayerTreeFrameSink(
// Display properties are reset when the output surface is lost, so update it
// to match the Compositor's.
if (display_private_) {
+ disabled_swap_until_resize_ = false;
display_private_->Resize(size());
display_private_->SetDisplayVisible(host_->IsVisible());
display_private_->SetDisplayColorSpaces(display_color_spaces_);
@@ -381,8 +383,12 @@ void Compositor::ScheduleRedrawRect(const gfx::Rect& damage_rect) {
}
#if defined(OS_WIN)
+void Compositor::SetShouldDisableSwapUntilResize(bool should) {
+ should_disable_swap_until_resize_ = should;
+}
+
void Compositor::DisableSwapUntilResize() {
- if (display_private_) {
+ if (should_disable_swap_until_resize_ && display_private_) {
// Browser needs to block for Viz to receive and process this message.
// Otherwise when we return from WM_WINDOWPOSCHANGING message handler and
// receive a WM_WINDOWPOSCHANGED the resize is finalized and any swaps of
@@ -396,7 +402,7 @@ void Compositor::DisableSwapUntilResize() {
}
void Compositor::ReenableSwap() {
- if (display_private_)
+ if (should_disable_swap_until_resize_ && display_private_)
display_private_->Resize(size_);
}
#endif
@@ -608,6 +614,10 @@ void Compositor::IssueExternalBeginFrame(
args, force, std::move(callback));
}
+ThroughputTracker Compositor::RequestNewThroughputTracker() {
+ return ThroughputTracker(next_throughput_tracker_id_++, this);
+}
+
void Compositor::DidUpdateLayers() {
// Dump property trees and layers if run with:
// --vmodule=*ui/compositor*=3
@@ -670,6 +680,12 @@ Compositor::GetBeginMainFrameMetrics() {
return nullptr;
}
+void Compositor::NotifyThroughputTrackerResults(
+ cc::CustomTrackerResults results) {
+ for (auto& pair : results)
+ ReportThroughputForTracker(pair.first, std::move(pair.second));
+}
+
void Compositor::DidReceiveCompositorFrameAck() {
++activated_frame_count_;
for (auto& observer : observer_list_)
@@ -705,6 +721,25 @@ void Compositor::OnFrameTokenChanged(uint32_t frame_token) {
NOTREACHED();
}
+void Compositor::StartThroughputTracker(
+ TrackerId tracker_id,
+ ThroughputTrackerHost::ReportCallback callback) {
+ DCHECK(!base::Contains(throughput_tracker_map_, tracker_id));
+ throughput_tracker_map_[tracker_id] = std::move(callback);
+ animation_host_->StartThroughputTracking(tracker_id);
+}
+
+void Compositor::StopThroughtputTracker(TrackerId tracker_id) {
+ DCHECK(base::Contains(throughput_tracker_map_, tracker_id));
+ animation_host_->StopThroughputTracking(tracker_id);
+}
+
+void Compositor::CancelThroughtputTracker(TrackerId tracker_id) {
+ DCHECK(base::Contains(throughput_tracker_map_, tracker_id));
+ StopThroughtputTracker(tracker_id);
+ throughput_tracker_map_.erase(tracker_id);
+}
+
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
void Compositor::OnCompleteSwapWithNewSize(const gfx::Size& size) {
for (auto& observer : observer_list_)
@@ -732,4 +767,15 @@ void Compositor::RequestPresentationTimeForNextFrame(
host_->RequestPresentationTimeForNextFrame(std::move(callback));
}
+void Compositor::ReportThroughputForTracker(
+ int tracker_id,
+ cc::FrameSequenceMetrics::ThroughputData throughput) {
+ auto it = throughput_tracker_map_.find(tracker_id);
+ if (it == throughput_tracker_map_.end())
+ return;
+
+ std::move(it->second).Run(std::move(throughput));
+ throughput_tracker_map_.erase(it);
+}
+
} // namespace ui
diff --git a/chromium/ui/compositor/compositor.h b/chromium/ui/compositor/compositor.h
index 3e2d2304faf..48cd5ff63d7 100644
--- a/chromium/ui/compositor/compositor.h
+++ b/chromium/ui/compositor/compositor.h
@@ -11,12 +11,14 @@
#include <string>
#include "base/callback_forward.h"
+#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/observer_list.h"
#include "base/single_thread_task_runner.h"
#include "base/time/time.h"
#include "build/build_config.h"
+#include "cc/metrics/frame_sequence_tracker.h"
#include "cc/paint/element_id.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_host_client.h"
@@ -33,6 +35,8 @@
#include "ui/compositor/compositor_lock.h"
#include "ui/compositor/compositor_observer.h"
#include "ui/compositor/layer_animator_collection.h"
+#include "ui/compositor/throughput_tracker.h"
+#include "ui/compositor/throughput_tracker_host.h"
#include "ui/gfx/display_color_spaces.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/vector2d.h"
@@ -80,6 +84,7 @@ class Compositor;
class Layer;
class ScopedAnimationDurationScaleMode;
class ScrollInputHandler;
+class ThroughputTracker;
struct PendingBeginFrameArgs;
constexpr int kCompositorLockTimeoutMs = 67;
@@ -129,7 +134,8 @@ class COMPOSITOR_EXPORT ContextFactory {
// view hierarchy.
class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient,
public cc::LayerTreeHostSingleThreadClient,
- public viz::HostFrameSinkClient {
+ public viz::HostFrameSinkClient,
+ public ThroughputTrackerHost {
public:
Compositor(const viz::FrameSinkId& frame_sink_id,
ui::ContextFactory* context_factory,
@@ -187,6 +193,10 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient,
void ScheduleRedrawRect(const gfx::Rect& damage_rect);
#if defined(OS_WIN)
+ // Until this is called with |should| true then both DisableSwapUntilResize()
+ // and ReenableSwap() do nothing.
+ void SetShouldDisableSwapUntilResize(bool should);
+
// Attempts to immediately swap a frame with the current size if possible,
// then disables swapping on this surface until it is resized.
void DisableSwapUntilResize();
@@ -295,6 +305,9 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient,
bool force,
base::OnceCallback<void(const viz::BeginFrameAck&)> callback);
+ // Creates a ThroughputTracker for tracking this Compositor.
+ ThroughputTracker RequestNewThroughputTracker();
+
// LayerTreeHostClient implementation.
void WillBeginMainFrame() override {}
void DidBeginMainFrame() override {}
@@ -331,6 +344,8 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient,
cc::ActiveFrameSequenceTrackers trackers) override {}
std::unique_ptr<cc::BeginMainFrameMetrics> GetBeginMainFrameMetrics()
override;
+ void NotifyThroughputTrackerResults(
+ cc::CustomTrackerResults results) override;
// cc::LayerTreeHostSingleThreadClient implementation.
void DidSubmitCompositorFrame() override;
@@ -341,6 +356,13 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient,
void OnFirstSurfaceActivation(const viz::SurfaceInfo& surface_info) override;
void OnFrameTokenChanged(uint32_t frame_token) override;
+ // ThroughputTrackerHost implementation.
+ void StartThroughputTracker(
+ TrackerId tracker_id,
+ ThroughputTrackerHost::ReportCallback callback) override;
+ void StopThroughtputTracker(TrackerId tracker_id) override;
+ void CancelThroughtputTracker(TrackerId tracker_id) override;
+
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
void OnCompleteSwapWithNewSize(const gfx::Size& size);
#endif
@@ -378,6 +400,11 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient,
private:
friend class base::RefCounted<Compositor>;
+ // Called when throughput data for the tracker of |tracker_id| is ready.
+ void ReportThroughputForTracker(
+ int tracker_id,
+ cc::FrameSequenceMetrics::ThroughputData throughput);
+
gfx::Size size_;
ui::ContextFactory* context_factory_;
@@ -443,9 +470,18 @@ class COMPOSITOR_EXPORT Compositor : public cc::LayerTreeHostClient,
std::unique_ptr<ScrollInputHandler> scroll_input_handler_;
+#if defined(OS_WIN)
+ bool should_disable_swap_until_resize_ = false;
+#endif
+
// Set in DisableSwapUntilResize and reset when a resize happens.
bool disabled_swap_until_resize_ = false;
+ TrackerId next_throughput_tracker_id_ = 1u;
+ using ThroughputTrackerMap =
+ base::flat_map<TrackerId, ThroughputTrackerHost::ReportCallback>;
+ ThroughputTrackerMap throughput_tracker_map_;
+
base::WeakPtrFactory<Compositor> context_creation_weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(Compositor);
diff --git a/chromium/ui/compositor/compositor_unittest.cc b/chromium/ui/compositor/compositor_unittest.cc
index 0eb30ab7684..e92a5eb1362 100644
--- a/chromium/ui/compositor/compositor_unittest.cc
+++ b/chromium/ui/compositor/compositor_unittest.cc
@@ -7,10 +7,12 @@
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
+#include "base/test/bind_test_util.h"
#include "base/test/task_environment.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
+#include "cc/metrics/frame_sequence_tracker.h"
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -28,8 +30,8 @@ namespace {
class CompositorTest : public testing::Test {
public:
- CompositorTest() {}
- ~CompositorTest() override {}
+ CompositorTest() = default;
+ ~CompositorTest() override = default;
void SetUp() override {
context_factories_ = std::make_unique<TestContextFactories>(false);
@@ -104,7 +106,7 @@ TEST_F(CompositorTestWithMessageLoop, ShouldUpdateDisplayProperties) {
compositor()->SetRootLayer(root_layer.get());
compositor()->SetScaleAndSize(1.0f, gfx::Size(10, 10),
allocator.GetCurrentLocalSurfaceIdAllocation());
- DCHECK(compositor()->IsVisible());
+ ASSERT_TRUE(compositor()->IsVisible());
// Set a non-identity color matrix, color space, sdr white level, vsync
// timebase and vsync interval, and expect it to be set on the context
@@ -164,6 +166,110 @@ TEST_F(CompositorTestWithMockedTime,
compositor()->SetVisible(true);
}
+TEST_F(CompositorTestWithMessageLoop, MoveThroughputTracker) {
+ // Move a not started instance.
+ {
+ auto tracker = compositor()->RequestNewThroughputTracker();
+ auto moved_tracker = std::move(tracker);
+ }
+
+ // Move a started instance.
+ {
+ auto tracker = compositor()->RequestNewThroughputTracker();
+ tracker.Start(base::BindLambdaForTesting(
+ [&](cc::FrameSequenceMetrics::ThroughputData throughput) {
+ // This should not be called since the tracking is auto canceled.
+ ADD_FAILURE();
+ }));
+ auto moved_tracker = std::move(tracker);
+ }
+
+ // Move a started instance and stop.
+ {
+ auto tracker = compositor()->RequestNewThroughputTracker();
+ tracker.Start(base::BindLambdaForTesting(
+ [&](cc::FrameSequenceMetrics::ThroughputData throughput) {
+ // May be called since Stop() is called.
+ }));
+ auto moved_tracker = std::move(tracker);
+ moved_tracker.Stop();
+ }
+
+ // Move a started instance and cancel.
+ {
+ auto tracker = compositor()->RequestNewThroughputTracker();
+ tracker.Start(base::BindLambdaForTesting(
+ [&](cc::FrameSequenceMetrics::ThroughputData throughput) {
+ // This should not be called since Cancel() is called.
+ ADD_FAILURE();
+ }));
+ auto moved_tracker = std::move(tracker);
+ moved_tracker.Cancel();
+ }
+
+ // Move a stopped instance.
+ {
+ auto tracker = compositor()->RequestNewThroughputTracker();
+ tracker.Start(base::BindLambdaForTesting(
+ [&](cc::FrameSequenceMetrics::ThroughputData throughput) {
+ // May be called since Stop() is called.
+ }));
+ tracker.Stop();
+ auto moved_tracker = std::move(tracker);
+ }
+
+ // Move a canceled instance.
+ {
+ auto tracker = compositor()->RequestNewThroughputTracker();
+ tracker.Start(base::BindLambdaForTesting(
+ [&](cc::FrameSequenceMetrics::ThroughputData throughput) {
+ // This should not be called since Cancel() is called.
+ ADD_FAILURE();
+ }));
+ tracker.Cancel();
+ auto moved_tracker = std::move(tracker);
+ }
+}
+
+TEST_F(CompositorTestWithMessageLoop, ThroughputTracker) {
+ auto root_layer = std::make_unique<Layer>(ui::LAYER_SOLID_COLOR);
+ viz::ParentLocalSurfaceIdAllocator allocator;
+ allocator.GenerateId();
+ root_layer->SetBounds(gfx::Rect(10, 10));
+ compositor()->SetRootLayer(root_layer.get());
+ compositor()->SetScaleAndSize(1.0f, gfx::Size(10, 10),
+ allocator.GetCurrentLocalSurfaceIdAllocation());
+ ASSERT_TRUE(compositor()->IsVisible());
+
+ ThroughputTracker tracker = compositor()->RequestNewThroughputTracker();
+
+ base::RunLoop run_loop;
+ tracker.Start(base::BindLambdaForTesting(
+ [&](cc::FrameSequenceMetrics::ThroughputData throughput) {
+ EXPECT_GT(throughput.frames_expected, 0u);
+ EXPECT_GT(throughput.frames_produced, 0u);
+ run_loop.Quit();
+ }));
+
+ // Generates a few frames after tracker starts to have some data collected.
+ for (int i = 0; i < 5; ++i) {
+ compositor()->ScheduleFullRedraw();
+ DrawWaiterForTest::WaitForCompositingEnded(compositor());
+ }
+
+ tracker.Stop();
+
+ // Generates a few frames after tracker stops. Note the number of frames
+ // must be at least two: one to trigger underlying cc::FrameSequenceTracker to
+ // be scheduled for termination and one to report data.
+ for (int i = 0; i < 5; ++i) {
+ compositor()->ScheduleFullRedraw();
+ DrawWaiterForTest::WaitForCompositingEnded(compositor());
+ }
+
+ run_loop.Run();
+}
+
#if defined(OS_WIN)
// TODO(crbug.com/608436): Flaky on windows trybots
#define MAYBE_CreateAndReleaseOutputSurface \
@@ -179,7 +285,7 @@ TEST_F(CompositorTestWithMessageLoop, MAYBE_CreateAndReleaseOutputSurface) {
compositor()->SetRootLayer(root_layer.get());
compositor()->SetScaleAndSize(1.0f, gfx::Size(10, 10),
allocator.GetCurrentLocalSurfaceIdAllocation());
- DCHECK(compositor()->IsVisible());
+ ASSERT_TRUE(compositor()->IsVisible());
compositor()->ScheduleDraw();
DrawWaiterForTest::WaitForCompositingEnded(compositor());
compositor()->SetVisible(false);
diff --git a/chromium/ui/compositor/debug_utils.cc b/chromium/ui/compositor/debug_utils.cc
index a2b385dc906..11a3aaf6eeb 100644
--- a/chromium/ui/compositor/debug_utils.cc
+++ b/chromium/ui/compositor/debug_utils.cc
@@ -67,6 +67,21 @@ void PrintLayerHierarchyImp(const Layer* layer,
if (!layer->GetSubpixelOffset().IsZero())
*out << " " << layer->GetSubpixelOffset().ToString();
+ const cc::Layer* cc_layer = layer->cc_layer_for_testing();
+ if (cc_layer) {
+ // Property trees must be updated in order to get valid render surface
+ // reasons.
+ if (cc_layer->layer_tree_host() &&
+ !cc_layer->layer_tree_host()->property_trees()->needs_rebuild) {
+ cc::RenderSurfaceReason render_surface =
+ cc_layer->GetRenderSurfaceReason();
+ if (render_surface != cc::RenderSurfaceReason::kNone) {
+ *out << " render-surface-reason: "
+ << cc::RenderSurfaceReasonToString(render_surface);
+ }
+ }
+ }
+
const ui::Layer* mask = const_cast<ui::Layer*>(layer)->layer_mask_layer();
if (mask) {
@@ -108,10 +123,16 @@ void PrintLayerHierarchyImp(const Layer* layer,
void PrintLayerHierarchy(const Layer* layer, const gfx::Point& mouse_location) {
std::ostringstream out;
- out << "Layer hierarchy:\n";
- PrintLayerHierarchyImp(layer, 0, mouse_location, &out);
+ PrintLayerHierarchy(layer, mouse_location, &out);
// Error so logs can be collected from end-users.
LOG(ERROR) << out.str();
}
+void PrintLayerHierarchy(const Layer* layer,
+ const gfx::Point& mouse_location,
+ std::ostringstream* out) {
+ *out << "Layer hierarchy:\n";
+ PrintLayerHierarchyImp(layer, 0, mouse_location, out);
+}
+
} // namespace ui
diff --git a/chromium/ui/compositor/debug_utils.h b/chromium/ui/compositor/debug_utils.h
index f66998cf5f6..f8ba9642a0e 100644
--- a/chromium/ui/compositor/debug_utils.h
+++ b/chromium/ui/compositor/debug_utils.h
@@ -5,6 +5,8 @@
#ifndef UI_COMPOSITOR_DEBUG_UTILS_H_
#define UI_COMPOSITOR_DEBUG_UTILS_H_
+#include <sstream>
+
#include "ui/compositor/compositor_export.h"
namespace gfx {
@@ -19,6 +21,12 @@ class Layer;
COMPOSITOR_EXPORT void PrintLayerHierarchy(const Layer* layer,
const gfx::Point& mouse_location);
+// Print the layer hierarchy to |out|. Mark layers which contain
+// |mouse_location| with '*'.
+COMPOSITOR_EXPORT void PrintLayerHierarchy(const Layer* layer,
+ const gfx::Point& mouse_location,
+ std::ostringstream* out);
+
} // namespace ui
#endif // UI_COMPOSITOR_DEBUG_UTILS_H_
diff --git a/chromium/ui/compositor/layer.cc b/chromium/ui/compositor/layer.cc
index 3e4761805a3..ec9f20471ae 100644
--- a/chromium/ui/compositor/layer.cc
+++ b/chromium/ui/compositor/layer.cc
@@ -10,9 +10,9 @@
#include "base/auto_reset.h"
#include "base/bind.h"
+#include "base/check_op.h"
#include "base/command_line.h"
#include "base/json/json_writer.h"
-#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/numerics/ranges.h"
#include "base/trace_event/trace_event.h"
diff --git a/chromium/ui/compositor/layer_animator.cc b/chromium/ui/compositor/layer_animator.cc
index 839d5f2175d..e3e564a1037 100644
--- a/chromium/ui/compositor/layer_animator.cc
+++ b/chromium/ui/compositor/layer_animator.cc
@@ -8,7 +8,7 @@
#include <memory>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/stl_util.h"
#include "base/trace_event/trace_event.h"
#include "cc/animation/animation.h"
diff --git a/chromium/ui/compositor/layer_type.cc b/chromium/ui/compositor/layer_type.cc
index 8abc00aa812..65a025525f7 100644
--- a/chromium/ui/compositor/layer_type.cc
+++ b/chromium/ui/compositor/layer_type.cc
@@ -4,7 +4,7 @@
#include "ui/compositor/layer_type.h"
-#include "base/logging.h"
+#include "base/notreached.h"
namespace ui {
diff --git a/chromium/ui/compositor/overscroll/DEPS b/chromium/ui/compositor/overscroll/DEPS
index df9eac45a55..51f738cd9c3 100644
--- a/chromium/ui/compositor/overscroll/DEPS
+++ b/chromium/ui/compositor/overscroll/DEPS
@@ -1,3 +1,4 @@
include_rules = [
"+ui/events/event.h",
+ "+ui/events/types/scroll_input_type.h",
] \ No newline at end of file
diff --git a/chromium/ui/compositor/overscroll/scroll_input_handler.cc b/chromium/ui/compositor/overscroll/scroll_input_handler.cc
index f6c9067da22..6b2a80c5cfe 100644
--- a/chromium/ui/compositor/overscroll/scroll_input_handler.cc
+++ b/chromium/ui/compositor/overscroll/scroll_input_handler.cc
@@ -4,9 +4,9 @@
#include "ui/compositor/overscroll/scroll_input_handler.h"
-#include "cc/input/scroll_input_type.h"
#include "ui/compositor/layer.h"
#include "ui/events/event.h"
+#include "ui/events/types/scroll_input_type.h"
namespace ui {
@@ -66,7 +66,7 @@ bool ScrollInputHandler::OnScrollEvent(const ScrollEvent& event,
// Note: the WHEEL type covers both actual wheels as well as trackpad
// scrolling.
input_handler_weak_ptr_->ScrollBegin(&scroll_state_begin,
- cc::ScrollInputType::kWheel);
+ ui::ScrollInputType::kWheel);
cc::ScrollState scroll_state = CreateScrollState(event, false);
input_handler_weak_ptr_->ScrollUpdate(&scroll_state, base::TimeDelta());
diff --git a/chromium/ui/compositor/test/test_compositor_host_ozone.cc b/chromium/ui/compositor/test/test_compositor_host_ozone.cc
index f8cd1943ea3..d60cbe986af 100644
--- a/chromium/ui/compositor/test/test_compositor_host_ozone.cc
+++ b/chromium/ui/compositor/test/test_compositor_host_ozone.cc
@@ -7,8 +7,8 @@
#include <memory>
#include "base/bind.h"
+#include "base/check_op.h"
#include "base/compiler_specific.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/threading/thread_task_runner_handle.h"
diff --git a/chromium/ui/compositor/throughput_tracker.cc b/chromium/ui/compositor/throughput_tracker.cc
new file mode 100644
index 00000000000..04e9b22c3e8
--- /dev/null
+++ b/chromium/ui/compositor/throughput_tracker.cc
@@ -0,0 +1,54 @@
+// Copyright 2020 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 "ui/compositor/throughput_tracker.h"
+
+#include <utility>
+
+#include "base/callback.h"
+#include "base/check.h"
+
+namespace ui {
+
+ThroughputTracker::ThroughputTracker(TrackerId id, ThroughputTrackerHost* host)
+ : id_(id), host_(host) {
+ DCHECK(host_);
+}
+
+ThroughputTracker::ThroughputTracker(ThroughputTracker&& other) {
+ *this = std::move(other);
+}
+
+ThroughputTracker& ThroughputTracker::operator=(ThroughputTracker&& other) {
+ id_ = other.id_;
+ host_ = other.host_;
+ started_ = other.started_;
+
+ other.id_ = kInvalidId;
+ other.host_ = nullptr;
+ other.started_ = false;
+ return *this;
+}
+
+ThroughputTracker::~ThroughputTracker() {
+ if (started_)
+ Cancel();
+}
+
+void ThroughputTracker::Start(ThroughputTrackerHost::ReportCallback callback) {
+ started_ = true;
+ host_->StartThroughputTracker(id_, std::move(callback));
+}
+
+void ThroughputTracker::Stop() {
+ started_ = false;
+ host_->StopThroughtputTracker(id_);
+}
+
+void ThroughputTracker::Cancel() {
+ started_ = false;
+ host_->CancelThroughtputTracker(id_);
+}
+
+} // namespace ui
diff --git a/chromium/ui/compositor/throughput_tracker.h b/chromium/ui/compositor/throughput_tracker.h
new file mode 100644
index 00000000000..def502b4229
--- /dev/null
+++ b/chromium/ui/compositor/throughput_tracker.h
@@ -0,0 +1,60 @@
+// Copyright 2020 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 UI_COMPOSITOR_THROUGHPUT_TRACKER_H_
+#define UI_COMPOSITOR_THROUGHPUT_TRACKER_H_
+
+#include "base/callback_forward.h"
+#include "ui/compositor/compositor_export.h"
+#include "ui/compositor/throughput_tracker_host.h"
+
+namespace ui {
+
+class Compositor;
+class ThroughputTrackerHost;
+
+// A class to track the throughput of Compositor. The tracking is identified by
+// an id. The id is passed into impl side and be used as the sequence id to
+// create and stop a kCustom typed cc::FrameSequenceTracker. The class is
+// move-only to have only one holder of the id. When ThroughputTracker is
+// destroyed with an active tracking, the tracking will be canceled and report
+// callback will not be invoked.
+class COMPOSITOR_EXPORT ThroughputTracker {
+ public:
+ using TrackerId = ThroughputTrackerHost::TrackerId;
+
+ // Move only.
+ ThroughputTracker(ThroughputTracker&& other);
+ ThroughputTracker& operator=(ThroughputTracker&& other);
+
+ ~ThroughputTracker();
+
+ // Starts tracking Compositor and provides a callback for reporting. The
+ // throughput data collection starts after the next commit.
+ void Start(ThroughputTrackerHost::ReportCallback callback);
+
+ // Stops tracking. The supplied callback will be invoked when the data
+ // collection finishes after the next frame presentation. Note that no data
+ // will be reported if Stop() is not called,
+ void Stop();
+
+ // Cancels tracking. The supplied callback will not be invoked.
+ void Cancel();
+
+ private:
+ friend class Compositor;
+
+ // Private since it should only be created via Compositor's
+ // RequestNewThroughputTracker call.
+ ThroughputTracker(TrackerId id, ThroughputTrackerHost* host);
+
+ static const TrackerId kInvalidId = 0u;
+ TrackerId id_ = kInvalidId;
+ ThroughputTrackerHost* host_ = nullptr;
+ bool started_ = false;
+};
+
+} // namespace ui
+
+#endif // UI_COMPOSITOR_THROUGHPUT_TRACKER_H_
diff --git a/chromium/ui/compositor/throughput_tracker_host.h b/chromium/ui/compositor/throughput_tracker_host.h
new file mode 100644
index 00000000000..9082d00c4c1
--- /dev/null
+++ b/chromium/ui/compositor/throughput_tracker_host.h
@@ -0,0 +1,37 @@
+// Copyright 2020 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 UI_COMPOSITOR_THROUGHPUT_TRACKER_HOST_H_
+#define UI_COMPOSITOR_THROUGHPUT_TRACKER_HOST_H_
+
+#include "base/callback_forward.h"
+#include "cc/metrics/frame_sequence_tracker.h"
+#include "ui/compositor/compositor_export.h"
+
+namespace ui {
+
+// An interface for ThroughputTracker to call its host.
+class COMPOSITOR_EXPORT ThroughputTrackerHost {
+ public:
+ using TrackerId = size_t;
+
+ virtual ~ThroughputTrackerHost() = default;
+
+ // Starts the tracking for the given tracker id. |callback| is invoked after
+ // the tracker is stopped and the throughput data is collected.
+ using ReportCallback = base::OnceCallback<void(
+ const cc::FrameSequenceMetrics::ThroughputData throughput)>;
+ virtual void StartThroughputTracker(TrackerId tracker_id,
+ ReportCallback callback) = 0;
+
+ // Stops the tracking for the given tracker id.
+ virtual void StopThroughtputTracker(TrackerId tracker_id) = 0;
+
+ // Cancels the tracking for the given tracker id.
+ virtual void CancelThroughtputTracker(TrackerId tracker_id) = 0;
+};
+
+} // namespace ui
+
+#endif // UI_COMPOSITOR_THROUGHPUT_TRACKER_HOST_H_
diff --git a/chromium/ui/content_accelerators/accelerator_util.cc b/chromium/ui/content_accelerators/accelerator_util.cc
index 4417e5819b3..027c6e802e0 100644
--- a/chromium/ui/content_accelerators/accelerator_util.cc
+++ b/chromium/ui/content_accelerators/accelerator_util.cc
@@ -24,7 +24,7 @@ ui::Accelerator GetAcceleratorFromNativeWebKeyboardEvent(
}
#endif
Accelerator::KeyState key_state =
- event.GetType() == blink::WebInputEvent::kKeyUp
+ event.GetType() == blink::WebInputEvent::Type::kKeyUp
? Accelerator::KeyState::RELEASED
: Accelerator::KeyState::PRESSED;
ui::KeyboardCode keyboard_code =
diff --git a/chromium/ui/display/BUILD.gn b/chromium/ui/display/BUILD.gn
index 6c2d7723415..2ce0eb72a65 100644
--- a/chromium/ui/display/BUILD.gn
+++ b/chromium/ui/display/BUILD.gn
@@ -58,18 +58,24 @@ jumbo_component("display") {
if (is_win) {
sources += [
+ "win/base_window_finder_win.cc",
+ "win/base_window_finder_win.h",
"win/color_profile_reader.cc",
"win/color_profile_reader.h",
"win/display_info.cc",
"win/display_info.h",
"win/dpi.cc",
"win/dpi.h",
+ "win/local_process_window_finder_win.cc",
+ "win/local_process_window_finder_win.h",
"win/scaling_util.cc",
"win/scaling_util.h",
"win/screen_win.cc",
"win/screen_win.h",
"win/screen_win_display.cc",
"win/screen_win_display.h",
+ "win/topmost_window_finder_win.cc",
+ "win/topmost_window_finder_win.h",
"win/uwp_text_scale_factor.cc",
"win/uwp_text_scale_factor.h",
]
diff --git a/chromium/ui/display/display_finder.cc b/chromium/ui/display/display_finder.cc
index c4e42f82d9d..52e710e382d 100644
--- a/chromium/ui/display/display_finder.cc
+++ b/chromium/ui/display/display_finder.cc
@@ -7,7 +7,7 @@
#include <algorithm>
#include <limits>
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/display/display.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/rect.h"
diff --git a/chromium/ui/display/display_transform.cc b/chromium/ui/display/display_transform.cc
index 883ef4633f4..e19a91c721d 100644
--- a/chromium/ui/display/display_transform.cc
+++ b/chromium/ui/display/display_transform.cc
@@ -4,6 +4,7 @@
#include "ui/display/display_transform.h"
+#include "base/notreached.h"
#include "ui/gfx/overlay_transform_utils.h"
namespace display {
diff --git a/chromium/ui/display/fake/fake_display_snapshot.cc b/chromium/ui/display/fake/fake_display_snapshot.cc
index 94da2c4e398..af8fad503ca 100644
--- a/chromium/ui/display/fake/fake_display_snapshot.cc
+++ b/chromium/ui/display/fake/fake_display_snapshot.cc
@@ -9,6 +9,7 @@
#include <utility>
#include <vector>
+#include "base/logging.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
diff --git a/chromium/ui/display/ios/screen_ios.mm b/chromium/ui/display/ios/screen_ios.mm
index cb3c47b282b..dd048905453 100644
--- a/chromium/ui/display/ios/screen_ios.mm
+++ b/chromium/ui/display/ios/screen_ios.mm
@@ -4,7 +4,8 @@
#import <UIKit/UIKit.h>
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "ui/display/display.h"
#include "ui/display/screen_base.h"
diff --git a/chromium/ui/display/mac/screen_mac.mm b/chromium/ui/display/mac/screen_mac.mm
index de5994300fc..a4e374dd355 100644
--- a/chromium/ui/display/mac/screen_mac.mm
+++ b/chromium/ui/display/mac/screen_mac.mm
@@ -4,6 +4,7 @@
#include "ui/display/screen.h"
+#import <AppKit/AppKit.h>
#import <ApplicationServices/ApplicationServices.h>
#import <Cocoa/Cocoa.h>
#include <stdint.h>
@@ -22,6 +23,7 @@
#include "ui/display/display.h"
#include "ui/display/display_change_notifier.h"
#include "ui/display/mac/display_link_mac.h"
+#include "ui/gfx/geometry/point.h"
#include "ui/gfx/icc_profile.h"
#include "ui/gfx/mac/coordinate_conversion.h"
@@ -32,10 +34,6 @@ Boolean CGDisplayUsesForceToGray(void);
namespace display {
namespace {
-// The delay to handle the display configuration changes. This is in place to
-// coalesce display update notifications and thereby avoid thrashing.
-const int64_t kConfigureDelayMs = 500;
-
NSScreen* GetMatchingScreen(const gfx::Rect& match_rect) {
// Default to the monitor with the current keyboard focus, in case
// |match_rect| is not on any screen at all.
@@ -85,8 +83,8 @@ Display BuildDisplayForScreen(NSScreen* screen) {
// Examine the presence of HDR.
bool enable_hdr = false;
if (@available(macOS 10.15, *)) {
- if ([screen maximumPotentialExtendedDynamicRangeColorComponentValue] >=
- 2.0) {
+ if ([screen maximumPotentialExtendedDynamicRangeColorComponentValue] >
+ 1.0) {
enable_hdr = true;
}
}
@@ -148,6 +146,51 @@ Display BuildPrimaryDisplay() {
return BuildDisplayForScreen([[NSScreen screens] firstObject]);
}
+std::vector<Display> BuildDisplaysFromQuartz() {
+ // Don't just return all online displays. This would include displays
+ // that mirror other displays, which are not desired in this list. It's
+ // tempting to use the count returned by CGGetActiveDisplayList, but active
+ // displays exclude sleeping displays, and those are desired.
+
+ // It would be ridiculous to have this many displays connected, but
+ // CGDirectDisplayID is just an integer, so supporting up to this many
+ // doesn't hurt.
+ CGDirectDisplayID online_displays[1024];
+ CGDisplayCount online_display_count = 0;
+ if (CGGetOnlineDisplayList(base::size(online_displays), online_displays,
+ &online_display_count) != kCGErrorSuccess) {
+ return std::vector<Display>(1, BuildPrimaryDisplay());
+ }
+
+ typedef std::map<int64_t, NSScreen*> ScreenIdsToScreensMap;
+ ScreenIdsToScreensMap screen_ids_to_screens;
+ for (NSScreen* screen in [NSScreen screens]) {
+ NSDictionary* screen_device_description = [screen deviceDescription];
+ int64_t screen_id = [[screen_device_description
+ objectForKey:@"NSScreenNumber"] unsignedIntValue];
+ screen_ids_to_screens[screen_id] = screen;
+ }
+
+ std::vector<Display> displays;
+ for (CGDisplayCount online_display_index = 0;
+ online_display_index < online_display_count; ++online_display_index) {
+ CGDirectDisplayID online_display = online_displays[online_display_index];
+ if (CGDisplayMirrorsDisplay(online_display) == kCGNullDirectDisplay) {
+ // If this display doesn't mirror any other, include it in the list.
+ // The primary display in a mirrored set will be counted, but those that
+ // mirror it will not be.
+ ScreenIdsToScreensMap::iterator foundScreen =
+ screen_ids_to_screens.find(online_display);
+ if (foundScreen != screen_ids_to_screens.end()) {
+ displays.push_back(BuildDisplayForScreen(foundScreen->second));
+ }
+ }
+ }
+
+ return displays.empty() ? std::vector<Display>(1, BuildPrimaryDisplay())
+ : displays;
+}
+
// Returns the minimum Manhattan distance from |point| to corners of |screen|
// frame.
CGFloat GetMinimumDistanceToCorner(const NSPoint& point, NSScreen* screen) {
@@ -165,12 +208,8 @@ CGFloat GetMinimumDistanceToCorner(const NSPoint& point, NSScreen* screen) {
class ScreenMac : public Screen {
public:
- ScreenMac()
- : configure_timer_(FROM_HERE,
- base::TimeDelta::FromMilliseconds(kConfigureDelayMs),
- base::BindRepeating(&ScreenMac::ConfigureTimerFired,
- base::Unretained(this))) {
- old_displays_ = displays_ = BuildDisplaysFromQuartz();
+ ScreenMac() {
+ displays_ = BuildDisplaysFromQuartz();
CGDisplayRegisterReconfigurationCallback(
ScreenMac::DisplayReconfigurationCallBack, this);
@@ -216,17 +255,39 @@ class ScreenMac : public Screen {
return gfx::NativeWindow();
}
+ gfx::NativeWindow GetLocalProcessWindowAtPoint(
+ const gfx::Point& point,
+ const std::set<gfx::NativeWindow>& ignore) override {
+ const NSPoint ns_point = gfx::ScreenPointToNSPoint(point);
+
+ // Note: [NSApp orderedWindows] doesn't include NSPanels.
+ for (NSWindow* window : [NSApp orderedWindows]) {
+ if (ignore.count(window))
+ continue;
+
+ if (![window isOnActiveSpace])
+ continue;
+
+ // NativeWidgetMac::Close() calls -orderOut: on NSWindows before actually
+ // closing them.
+ if (![window isVisible])
+ continue;
+
+ if (NSPointInRect(ns_point, [window frame]))
+ return window;
+ }
+
+ return nil;
+ }
+
int GetNumDisplays() const override { return GetAllDisplays().size(); }
const std::vector<Display>& GetAllDisplays() const override {
- UpdateDisplaysIfNeeded();
return displays_;
}
Display GetDisplayNearestWindow(
gfx::NativeWindow native_window) const override {
- UpdateDisplaysIfNeeded();
-
if (displays_.size() == 1)
return displays_[0];
@@ -309,102 +370,32 @@ class ScreenMac : public Screen {
private:
Display GetCachedDisplayForScreen(NSScreen* screen) const {
- UpdateDisplaysIfNeeded();
const CGDirectDisplayID display_id = [[[screen deviceDescription]
objectForKey:@"NSScreenNumber"] unsignedIntValue];
for (const Display& display : displays_) {
if (display_id == display.id())
return display;
}
- // In theory, this should not be reached, because |displays_require_update_|
- // should have been set prior to -[NSScreen screens] changing. In practice,
- // on Catalina, it has been observed that -[NSScreen screens] changes before
- // any notifications are received.
+ // In theory, this should not be reached, but in practice, on Catalina, it
+ // has been observed that -[NSScreen screens] changes before any
+ // notifications are received.
// https://crbug.com/1021340.
- OnNSScreensMayHaveChanged();
DLOG(ERROR) << "Value of -[NSScreen screens] changed before notification.";
return BuildDisplayForScreen(screen);
}
- void UpdateDisplaysIfNeeded() const {
- if (displays_require_update_) {
- displays_ = BuildDisplaysFromQuartz();
- displays_require_update_ = false;
- }
- }
-
- void ConfigureTimerFired() {
- UpdateDisplaysIfNeeded();
- change_notifier_.NotifyDisplaysChanged(old_displays_, displays_);
- old_displays_ = displays_;
- }
-
- std::vector<Display> BuildDisplaysFromQuartz() const {
- // Don't just return all online displays. This would include displays
- // that mirror other displays, which are not desired in this list. It's
- // tempting to use the count returned by CGGetActiveDisplayList, but active
- // displays exclude sleeping displays, and those are desired.
-
- // It would be ridiculous to have this many displays connected, but
- // CGDirectDisplayID is just an integer, so supporting up to this many
- // doesn't hurt.
- CGDirectDisplayID online_displays[1024];
- CGDisplayCount online_display_count = 0;
- if (CGGetOnlineDisplayList(base::size(online_displays), online_displays,
- &online_display_count) != kCGErrorSuccess) {
- return std::vector<Display>(1, BuildPrimaryDisplay());
- }
-
- typedef std::map<int64_t, NSScreen*> ScreenIdsToScreensMap;
- ScreenIdsToScreensMap screen_ids_to_screens;
- for (NSScreen* screen in [NSScreen screens]) {
- NSDictionary* screen_device_description = [screen deviceDescription];
- int64_t screen_id = [[screen_device_description
- objectForKey:@"NSScreenNumber"] unsignedIntValue];
- screen_ids_to_screens[screen_id] = screen;
- }
-
- std::vector<Display> displays;
- for (CGDisplayCount online_display_index = 0;
- online_display_index < online_display_count; ++online_display_index) {
- CGDirectDisplayID online_display = online_displays[online_display_index];
- if (CGDisplayMirrorsDisplay(online_display) == kCGNullDirectDisplay) {
- // If this display doesn't mirror any other, include it in the list.
- // The primary display in a mirrored set will be counted, but those that
- // mirror it will not be.
- ScreenIdsToScreensMap::iterator foundScreen =
- screen_ids_to_screens.find(online_display);
- if (foundScreen != screen_ids_to_screens.end()) {
- displays.push_back(BuildDisplayForScreen(foundScreen->second));
- }
- }
- }
-
- return displays.empty() ? std::vector<Display>(1, BuildPrimaryDisplay())
- : displays;
- }
-
- void OnNSScreensMayHaveChanged() const {
- // Timer::Reset() ensures at least another interval passes before the
- // associated task runs, effectively coalescing these events.
- configure_timer_.Reset();
- displays_require_update_ = true;
+ void OnNSScreensMayHaveChanged() {
+ auto new_displays = BuildDisplaysFromQuartz();
+ if (displays_ == new_displays)
+ return;
+ auto old_displays = std::move(displays_);
+ displays_ = std::move(new_displays);
+ change_notifier_.NotifyDisplaysChanged(old_displays, displays_);
}
// The displays currently attached to the device. Updated by
- // UpdateDisplaysIfNeeded.
- mutable std::vector<Display> displays_;
-
- // Whether or not |displays_| might need to be upated. Set in
- // OnNSScreensMayHaveChanged, and un-set by UpdateDisplaysIfNeeded.
- mutable bool displays_require_update_ = false;
-
- // The timer to delay configuring outputs and notifying observers (to coalesce
- // several updates into one update).
- mutable base::RetainingOneShotTimer configure_timer_;
-
- // The displays last communicated to the DisplayChangeNotifier.
- std::vector<Display> old_displays_;
+ // OnNSScreensMayHaveChanged.
+ std::vector<Display> displays_;
// The observers notified by NSScreenColorSpaceDidChangeNotification and
// NSApplicationDidChangeScreenParametersNotification.
diff --git a/chromium/ui/display/manager/content_protection_manager.cc b/chromium/ui/display/manager/content_protection_manager.cc
index 986d9617d1b..4b3bda1ad4b 100644
--- a/chromium/ui/display/manager/content_protection_manager.cc
+++ b/chromium/ui/display/manager/content_protection_manager.cc
@@ -7,7 +7,7 @@
#include <algorithm>
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/observer_list.h"
#include "base/stl_util.h"
#include "ui/display/manager/apply_content_protection_task.h"
diff --git a/chromium/ui/display/manager/display_change_observer.cc b/chromium/ui/display/manager/display_change_observer.cc
index 799d896d8e7..93961fa5a03 100644
--- a/chromium/ui/display/manager/display_change_observer.cc
+++ b/chromium/ui/display/manager/display_change_observer.cc
@@ -12,8 +12,8 @@
#include <utility>
#include <vector>
+#include "base/check_op.h"
#include "base/command_line.h"
-#include "base/logging.h"
#include "base/stl_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/user_activity/user_activity_detector.h"
diff --git a/chromium/ui/display/manager/display_layout_store.cc b/chromium/ui/display/manager/display_layout_store.cc
index d9913a16c9a..82c903775c9 100644
--- a/chromium/ui/display/manager/display_layout_store.cc
+++ b/chromium/ui/display/manager/display_layout_store.cc
@@ -7,8 +7,9 @@
#include <string>
#include <utility>
+#include "base/check_op.h"
#include "base/command_line.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "ui/display/display.h"
#include "ui/display/display_switches.h"
#include "ui/display/manager/display_layout_store.h"
diff --git a/chromium/ui/display/manager/display_manager.cc b/chromium/ui/display/manager/display_manager.cc
index 9d4a6bffa96..11423d46aae 100644
--- a/chromium/ui/display/manager/display_manager.cc
+++ b/chromium/ui/display/manager/display_manager.cc
@@ -49,6 +49,7 @@
#include "ui/display/manager/display_configurator.h"
#include "ui/display/manager/display_util.h"
#include "ui/display/types/native_display_delegate.h"
+#include "ui/events/devices/touchscreen_device.h"
#endif
#if defined(OS_WIN)
@@ -1472,25 +1473,25 @@ void DisplayManager::SetTouchCalibrationData(
int64_t display_id,
const TouchCalibrationData::CalibrationPointPairQuad& point_pair_quad,
const gfx::Size& display_bounds,
- const TouchDeviceIdentifier& touch_device_identifier) {
+ const ui::TouchscreenDevice& touchdevice) {
// We do not proceed with setting the calibration and association if the
// touch device identified by |touch_device_identifier| is an internal touch
// device.
- if (IsInternalTouchscreenDevice(touch_device_identifier))
+ if (touchdevice.type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL)
return;
// Id of the display the touch device in context is currently associated
// with. This display id will be equal to |display_id| if no reassociation is
// being performed.
int64_t previous_display_id =
- touch_device_manager_->GetAssociatedDisplay(touch_device_identifier);
+ touch_device_manager_->GetAssociatedDisplay(touchdevice);
bool update_add_support = false;
bool update_remove_support = false;
TouchCalibrationData calibration_data(point_pair_quad, display_bounds);
- touch_device_manager_->AddTouchCalibrationData(touch_device_identifier,
- display_id, calibration_data);
+ touch_device_manager_->AddTouchCalibrationData(touchdevice, display_id,
+ calibration_data);
DisplayInfoList display_info_list;
for (const auto& display : active_display_list_) {
@@ -1531,10 +1532,9 @@ void DisplayManager::SetTouchCalibrationData(
void DisplayManager::ClearTouchCalibrationData(
int64_t display_id,
- base::Optional<TouchDeviceIdentifier> touch_device_identifier) {
- if (touch_device_identifier) {
- touch_device_manager_->ClearTouchCalibrationData(*touch_device_identifier,
- display_id);
+ base::Optional<ui::TouchscreenDevice> touchdevice) {
+ if (touchdevice) {
+ touch_device_manager_->ClearTouchCalibrationData(*touchdevice, display_id);
} else {
touch_device_manager_->ClearAllTouchCalibrationData(display_id);
}
diff --git a/chromium/ui/display/manager/display_manager.h b/chromium/ui/display/manager/display_manager.h
index 883da148a28..d979f1f4e07 100644
--- a/chromium/ui/display/manager/display_manager.h
+++ b/chromium/ui/display/manager/display_manager.h
@@ -447,10 +447,10 @@ class DISPLAY_MANAGER_EXPORT DisplayManager
int64_t display_id,
const TouchCalibrationData::CalibrationPointPairQuad& point_pair_quad,
const gfx::Size& display_bounds,
- const TouchDeviceIdentifier& touch_device_identifier);
+ const ui::TouchscreenDevice& touchdevice);
void ClearTouchCalibrationData(
int64_t display_id,
- base::Optional<TouchDeviceIdentifier> touch_device_identifier);
+ base::Optional<ui::TouchscreenDevice> touchdevice);
void UpdateZoomFactor(int64_t display_id, float zoom_factor);
bool HasUnassociatedDisplay() const;
#endif
diff --git a/chromium/ui/display/manager/display_manager_utilities.cc b/chromium/ui/display/manager/display_manager_utilities.cc
index d3f7b015d55..ac8acd8910d 100644
--- a/chromium/ui/display/manager/display_manager_utilities.cc
+++ b/chromium/ui/display/manager/display_manager_utilities.cc
@@ -6,6 +6,8 @@
#include <algorithm>
#include <set>
+#include <sstream>
+#include <vector>
#include "base/command_line.h"
#include "base/strings/string_number_conversions.h"
diff --git a/chromium/ui/display/manager/display_util.cc b/chromium/ui/display/manager/display_util.cc
index 8ce08efbd79..310e6293da6 100644
--- a/chromium/ui/display/manager/display_util.cc
+++ b/chromium/ui/display/manager/display_util.cc
@@ -9,7 +9,8 @@
#include <array>
#include <cmath>
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "ui/display/manager/managed_display_info.h"
diff --git a/chromium/ui/display/manager/json_converter_unittest.cc b/chromium/ui/display/manager/json_converter_unittest.cc
index 4bc838a318e..559e836d1dd 100644
--- a/chromium/ui/display/manager/json_converter_unittest.cc
+++ b/chromium/ui/display/manager/json_converter_unittest.cc
@@ -49,9 +49,8 @@ TEST(JsonConverterTest, JsonFromToDisplayLayout) {
"}";
base::JSONReader::ValueWithError result =
base::JSONReader::ReadAndReturnValueWithError(data, 0);
- ASSERT_EQ(base::JSONReader::JSON_NO_ERROR, result.error_code)
- << result.error_message << " at " << result.error_line << ":"
- << result.error_column;
+ ASSERT_TRUE(result.value) << result.error_message << " at "
+ << result.error_line << ":" << result.error_column;
EXPECT_EQ(value, result.value.value());
DisplayLayout read_layout;
@@ -71,9 +70,8 @@ TEST(JsonConverterTest, OldJsonToDisplayLayout) {
"}";
base::JSONReader::ValueWithError result =
base::JSONReader::ReadAndReturnValueWithError(data, 0);
- ASSERT_EQ(base::JSONReader::JSON_NO_ERROR, result.error_code)
- << result.error_message << " at " << result.error_line << ":"
- << result.error_column;
+ ASSERT_TRUE(result.value) << result.error_message << " at "
+ << result.error_line << ":" << result.error_column;
DisplayLayout read_layout;
EXPECT_TRUE(JsonToDisplayLayout(result.value.value(), &read_layout));
diff --git a/chromium/ui/display/manager/managed_display_info.cc b/chromium/ui/display/manager/managed_display_info.cc
index 0cfb0609f82..e40b18c2cce 100644
--- a/chromium/ui/display/manager/managed_display_info.cc
+++ b/chromium/ui/display/manager/managed_display_info.cc
@@ -19,6 +19,7 @@
#include "ui/display/display.h"
#include "ui/display/display_features.h"
#include "ui/display/display_switches.h"
+#include "ui/display/manager/display_manager_utilities.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/size_f.h"
@@ -33,7 +34,7 @@ namespace {
// Use larger than max int to catch overflow early.
const int64_t kSynthesizedDisplayIdStart = 2200000000LL;
-int64_t synthesized_display_id = kSynthesizedDisplayIdStart;
+int64_t next_synthesized_display_id = kSynthesizedDisplayIdStart;
const float kDpi96 = 96.0;
@@ -234,8 +235,10 @@ ManagedDisplayInfo ManagedDisplayInfo::CreateFromSpecWithID(
true, dm.device_scale_factor());
}
- if (id == kInvalidDisplayId)
- id = synthesized_display_id++;
+ if (id == kInvalidDisplayId) {
+ id = next_synthesized_display_id;
+ next_synthesized_display_id = GetNextSynthesizedDisplayId(id);
+ }
ManagedDisplayInfo display_info(
id, base::StringPrintf("Display-%d", static_cast<int>(id)), has_overscan);
display_info.set_device_scale_factor(device_scale_factor);
@@ -489,7 +492,17 @@ Display::Rotation ManagedDisplayInfo::GetRotationWithPanelOrientation(
}
void ResetDisplayIdForTest() {
- synthesized_display_id = kSynthesizedDisplayIdStart;
+ next_synthesized_display_id = kSynthesizedDisplayIdStart;
+}
+
+int64_t GetNextSynthesizedDisplayId(int64_t id) {
+ int next_output_index = id & 0xFF;
+ next_output_index++;
+ DCHECK_GT(0x100, next_output_index);
+ int64_t base = GetDisplayIdWithoutOutputIndex(id);
+ if (id == kSynthesizedDisplayIdStart)
+ return id + 0x100 + next_output_index;
+ return base + next_output_index;
}
} // namespace display
diff --git a/chromium/ui/display/manager/managed_display_info.h b/chromium/ui/display/manager/managed_display_info.h
index 263a4f618ae..e340223f8e0 100644
--- a/chromium/ui/display/manager/managed_display_info.h
+++ b/chromium/ui/display/manager/managed_display_info.h
@@ -383,6 +383,10 @@ class DISPLAY_MANAGER_EXPORT ManagedDisplayInfo {
// is necessary to avoid overflowing the output index.
void DISPLAY_MANAGER_EXPORT ResetDisplayIdForTest();
+// Generates a fake, synthesized display ID that will be used when the
+// |kInvalidDisplayId| is passed to |ManagedDisplayInfo| constructor.
+int64_t DISPLAY_MANAGER_EXPORT GetNextSynthesizedDisplayId(int64_t id);
+
} // namespace display
#endif // UI_DISPLAY_MANAGER_MANAGED_DISPLAY_INFO_H_
diff --git a/chromium/ui/display/manager/touch_device_manager.cc b/chromium/ui/display/manager/touch_device_manager.cc
index ee34bfff718..fc7499a38ca 100644
--- a/chromium/ui/display/manager/touch_device_manager.cc
+++ b/chromium/ui/display/manager/touch_device_manager.cc
@@ -198,6 +198,8 @@ uint32_t TouchDeviceIdentifier::GenerateIdentifier(std::string name,
// static
TouchDeviceIdentifier TouchDeviceIdentifier::FromDevice(
const ui::TouchscreenDevice& touch_device) {
+ if (!touch_device.id)
+ return GetFallbackTouchDeviceIdentifier();
return TouchDeviceIdentifier(
GenerateIdentifier(touch_device.name, touch_device.vendor_id,
touch_device.product_id),
@@ -594,9 +596,11 @@ void TouchDeviceManager::Associate(ManagedDisplayInfo* display,
// Managing Touch device calibration data
void TouchDeviceManager::AddTouchCalibrationData(
- const TouchDeviceIdentifier& identifier,
+ const ui::TouchscreenDevice& device,
int64_t display_id,
const TouchCalibrationData& data) {
+ const TouchDeviceIdentifier identifier =
+ TouchDeviceIdentifier::FromDevice(device);
if (!base::Contains(touch_associations_, identifier))
touch_associations_.emplace(identifier, AssociationInfoMap());
@@ -627,8 +631,10 @@ void TouchDeviceManager::AddTouchCalibrationData(
}
void TouchDeviceManager::ClearTouchCalibrationData(
- const TouchDeviceIdentifier& identifier,
+ const ui::TouchscreenDevice& device,
int64_t display_id) {
+ const TouchDeviceIdentifier identifier =
+ TouchDeviceIdentifier::FromDevice(device);
if (base::Contains(touch_associations_, identifier)) {
ClearCalibrationDataInMap(touch_associations_.at(identifier), display_id);
}
@@ -681,27 +687,36 @@ TouchCalibrationData TouchDeviceManager::GetCalibrationData(
bool TouchDeviceManager::DisplayHasTouchDevice(
int64_t display_id,
- const TouchDeviceIdentifier& identifier) const {
+ const ui::TouchscreenDevice& device) const {
+ const TouchDeviceIdentifier identifier =
+ TouchDeviceIdentifier::FromDevice(device);
return base::Contains(active_touch_associations_, identifier) &&
active_touch_associations_.at(identifier) == display_id;
}
int64_t TouchDeviceManager::GetAssociatedDisplay(
- const TouchDeviceIdentifier& identifier) const {
+ const ui::TouchscreenDevice& device) const {
+ const TouchDeviceIdentifier identifier =
+ TouchDeviceIdentifier::FromDevice(device);
if (base::Contains(active_touch_associations_, identifier))
return active_touch_associations_.at(identifier);
return kInvalidDisplayId;
}
-std::vector<TouchDeviceIdentifier>
+std::vector<ui::TouchscreenDevice>
TouchDeviceManager::GetAssociatedTouchDevicesForDisplay(
int64_t display_id) const {
- std::vector<TouchDeviceIdentifier> identifiers;
- for (const auto& association : active_touch_associations_) {
- if (association.second == display_id)
- identifiers.push_back(association.first);
+ std::vector<ui::TouchscreenDevice> result;
+ for (const auto& device :
+ ui::DeviceDataManager::GetInstance()->GetTouchscreenDevices()) {
+ const TouchDeviceIdentifier identifier =
+ TouchDeviceIdentifier::FromDevice(device);
+
+ const auto it = active_touch_associations_.find(identifier);
+ if (it != active_touch_associations_.end() && it->second == display_id)
+ result.push_back(device);
}
- return identifiers;
+ return result;
}
void TouchDeviceManager::RegisterTouchAssociations(
@@ -728,15 +743,4 @@ bool HasExternalTouchscreenDevice() {
return false;
}
-bool IsInternalTouchscreenDevice(const TouchDeviceIdentifier& identifier) {
- for (const auto& device :
- ui::DeviceDataManager::GetInstance()->GetTouchscreenDevices()) {
- if (TouchDeviceIdentifier::FromDevice(device) == identifier)
- return device.type == ui::InputDeviceType::INPUT_DEVICE_INTERNAL;
- }
- VLOG(1) << "Touch device identified by " << identifier << " is currently"
- << " not connected to the device or is an invalid device.";
- return false;
-}
-
} // namespace display
diff --git a/chromium/ui/display/manager/touch_device_manager.h b/chromium/ui/display/manager/touch_device_manager.h
index 53fd442602e..d45757516b4 100644
--- a/chromium/ui/display/manager/touch_device_manager.h
+++ b/chromium/ui/display/manager/touch_device_manager.h
@@ -145,17 +145,17 @@ class DISPLAY_MANAGER_EXPORT TouchDeviceManager {
const std::vector<ui::TouchscreenDevice>& all_devices);
// Adds/updates the touch calibration data for touch device identified by
- // |identifier| and display with id |display_id|. This updates the mapping for
+ // |device| and display with id |display_id|. This updates the mapping for
// |active_touch_associations_|.
- void AddTouchCalibrationData(const TouchDeviceIdentifier& identifier,
+ void AddTouchCalibrationData(const ui::TouchscreenDevice& device,
int64_t display_id,
const TouchCalibrationData& data);
// Clears any touch calibration data associated with the pair, touch device
- // identified by |identifier| and display identified by |display_id|.
+ // identified by |device| and display identified by |display_id|.
// NOTE: This does not disassociate the pair, it only resets the calibration
// data.
- void ClearTouchCalibrationData(const TouchDeviceIdentifier& identifier,
+ void ClearTouchCalibrationData(const ui::TouchscreenDevice& device,
int64_t display_id);
// Clears all touch calibration data associated with the display identified
@@ -173,20 +173,20 @@ class DISPLAY_MANAGER_EXPORT TouchDeviceManager {
int64_t display_id = kInvalidDisplayId) const;
// Returns true of the display identified by |display_id| is associated with
- // the touch device identified by |identifier|.
+ // the touch device identified by |device|.
bool DisplayHasTouchDevice(int64_t display_id,
- const TouchDeviceIdentifier& identifier) const;
+ const ui::TouchscreenDevice& device) const;
// Returns the display id of the display that the touch device identified by
- // |identifier| is currently associated with. Returns |kInvalidDisplayId| if
+ // |device| is currently associated with. Returns |kInvalidDisplayId| if
// no display associated to touch device was found.
- int64_t GetAssociatedDisplay(const TouchDeviceIdentifier& identifier) const;
+ int64_t GetAssociatedDisplay(const ui::TouchscreenDevice& device) const;
// Returns a list of touch devices that are associated with the display with
// id as |display_id|. This list only includes active associations, that is,
// the devices that are currently connected to the system and associated with
// this display.
- std::vector<TouchDeviceIdentifier> GetAssociatedTouchDevicesForDisplay(
+ std::vector<ui::TouchscreenDevice> GetAssociatedTouchDevicesForDisplay(
int64_t display_id) const;
// Registers the touch associations and port associations retrieved from the
@@ -259,11 +259,6 @@ DISPLAY_MANAGER_EXPORT std::ostream& operator<<(
// Returns true if the device has any external touch devices attached.
DISPLAY_MANAGER_EXPORT bool HasExternalTouchscreenDevice();
-
-// Returns true if the touch device identified by |identifier| is an
-// internal touchscreen device.
-DISPLAY_MANAGER_EXPORT bool IsInternalTouchscreenDevice(
- const TouchDeviceIdentifier& identifier);
} // namespace display
#endif // UI_DISPLAY_MANAGER_TOUCH_DEVICE_MANAGER_H_
diff --git a/chromium/ui/display/manager/touch_device_manager_unittest.cc b/chromium/ui/display/manager/touch_device_manager_unittest.cc
index b94271d017a..aab804a0893 100644
--- a/chromium/ui/display/manager/touch_device_manager_unittest.cc
+++ b/chromium/ui/display/manager/touch_device_manager_unittest.cc
@@ -466,8 +466,7 @@ TEST_F(TouchAssociationFromPrefTest, UpdateMappingBeforeAssociation) {
// Reassociate display with id 4 to touch device with id 3. This will
// bring the display to the top of the priority list.
touch_device_manager()->AddTouchCalibrationData(
- TouchDeviceIdentifier::FromDevice(devices_[2]), displays_[3].id(),
- TouchCalibrationData());
+ devices_[2], displays_[3].id(), TouchCalibrationData());
touch_device_manager()->AssociateTouchscreens(&displays_, devices_);
@@ -494,8 +493,7 @@ TEST_F(TouchAssociationFromPrefTest, UpdateMappingAfterAssociation) {
// bring the display to the top of the priority list. This should work even
// though the association of devices and displays is complete.
touch_device_manager()->AddTouchCalibrationData(
- TouchDeviceIdentifier::FromDevice(devices_[2]), displays_[3].id(),
- TouchCalibrationData());
+ devices_[2], displays_[3].id(), TouchCalibrationData());
EXPECT_EQ(GetTouchDeviceCount(displays_[0]), 1u);
EXPECT_TRUE(AreAssociated(displays_[0], devices_[0]));
@@ -517,8 +515,7 @@ TEST_F(TouchAssociationFromPrefTest, AssociatingDeviceToNewDisplay) {
// Reassociate display with id 4 to touch device with id 3. This will
// bring the display to the top of the priority list.
touch_device_manager()->AddTouchCalibrationData(
- TouchDeviceIdentifier::FromDevice(devices_[0]), displays_[2].id(),
- TouchCalibrationData());
+ devices_[0], displays_[2].id(), TouchCalibrationData());
touch_device_manager()->AssociateTouchscreens(&displays_, devices_);
@@ -546,8 +543,7 @@ TEST_F(TouchAssociationFromPrefTest,
// bring the display to the top of the priority list. This should work even
// though the association of devices and displays is already complete.
touch_device_manager()->AddTouchCalibrationData(
- TouchDeviceIdentifier::FromDevice(devices_[0]), displays_[2].id(),
- TouchCalibrationData());
+ devices_[0], displays_[2].id(), TouchCalibrationData());
EXPECT_EQ(GetTouchDeviceCount(displays_[0]), 0u);
@@ -791,8 +787,7 @@ TEST_F(TouchAssociationWithDuplicateDeviceTest, UpdatePortBeforeAssociation) {
// bring the display to the top of the priority list and map the port the
// device is connected to, to display 3.
touch_device_manager()->AddTouchCalibrationData(
- TouchDeviceIdentifier::FromDevice(devices_[2]), displays_[3].id(),
- TouchCalibrationData());
+ devices_[2], displays_[3].id(), TouchCalibrationData());
touch_device_manager()->AssociateTouchscreens(&displays_, devices_);
@@ -821,8 +816,7 @@ TEST_F(TouchAssociationWithDuplicateDeviceTest, ChangeAssociation) {
// bring the display to the top of the priority list and map the port the
// device is connected to, to display 3.
touch_device_manager()->AddTouchCalibrationData(
- TouchDeviceIdentifier::FromDevice(devices_[2]), displays_[3].id(),
- TouchCalibrationData());
+ devices_[2], displays_[3].id(), TouchCalibrationData());
touch_device_manager()->AssociateTouchscreens(&displays_, devices_);
diff --git a/chromium/ui/display/manager/touch_transform_controller.cc b/chromium/ui/display/manager/touch_transform_controller.cc
index 8f49a26803a..62ce69c4fc5 100644
--- a/chromium/ui/display/manager/touch_transform_controller.cc
+++ b/chromium/ui/display/manager/touch_transform_controller.cc
@@ -23,18 +23,6 @@ namespace display {
namespace {
-ui::TouchscreenDevice FindTouchscreenByIdentifier(
- const TouchDeviceIdentifier& identifier) {
- const std::vector<ui::TouchscreenDevice>& touchscreens =
- ui::DeviceDataManager::GetInstance()->GetTouchscreenDevices();
- for (const auto& touchscreen : touchscreens) {
- if (TouchDeviceIdentifier::FromDevice(touchscreen) == identifier)
- return touchscreen;
- }
-
- return ui::TouchscreenDevice();
-}
-
// Given an array of touch point and display point pairs, this function computes
// and returns the constants(defined below) using a least fit algorithm.
// If (xt, yt) is a touch point then its corresponding (xd, yd) would be defined
@@ -297,13 +285,12 @@ void TouchTransformController::UpdateTouchTransforms() const {
void TouchTransformController::UpdateTouchRadius(
const ManagedDisplayInfo& display,
UpdateData* update_data) const {
- for (const auto& identifier :
+ for (const auto& device :
display_manager_->touch_device_manager()
->GetAssociatedTouchDevicesForDisplay(display.id())) {
- DCHECK_EQ(0u, update_data->device_to_scale.count(identifier));
+ DCHECK_EQ(0u, update_data->device_to_scale.count(device.id));
update_data->device_to_scale.emplace(
- identifier, GetTouchResolutionScale(
- display, FindTouchscreenByIdentifier(identifier)));
+ device.id, GetTouchResolutionScale(display, device));
}
}
@@ -314,14 +301,13 @@ void TouchTransformController::UpdateTouchTransform(
UpdateData* update_data) const {
ui::TouchDeviceTransform touch_device_transform;
touch_device_transform.display_id = target_display_id;
- for (const auto& identifier :
+ for (const auto& device :
display_manager_->touch_device_manager()
->GetAssociatedTouchDevicesForDisplay(touch_display.id())) {
- ui::TouchscreenDevice device = FindTouchscreenByIdentifier(identifier);
touch_device_transform.device_id = device.id;
touch_device_transform.transform =
GetTouchTransform(target_display, touch_display, device);
- auto device_to_scale_iter = update_data->device_to_scale.find(identifier);
+ auto device_to_scale_iter = update_data->device_to_scale.find(device.id);
if (device_to_scale_iter != update_data->device_to_scale.end())
touch_device_transform.radius_scale = device_to_scale_iter->second;
update_data->touch_device_transforms.push_back(touch_device_transform);
diff --git a/chromium/ui/display/manager/touch_transform_controller.h b/chromium/ui/display/manager/touch_transform_controller.h
index 00c7914aae6..2bf65b758f9 100644
--- a/chromium/ui/display/manager/touch_transform_controller.h
+++ b/chromium/ui/display/manager/touch_transform_controller.h
@@ -25,7 +25,6 @@ namespace display {
class DisplayManager;
class ManagedDisplayInfo;
class TouchTransformSetter;
-class TouchDeviceIdentifier;
namespace test {
class TouchTransformControllerTest;
@@ -58,7 +57,7 @@ class DISPLAY_MANAGER_EXPORT TouchTransformController {
UpdateData();
~UpdateData();
- std::map<display::TouchDeviceIdentifier, double> device_to_scale;
+ std::map<int, double> device_to_scale;
std::vector<ui::TouchDeviceTransform> touch_device_transforms;
};
diff --git a/chromium/ui/display/manager/touch_transform_controller_unittest.cc b/chromium/ui/display/manager/touch_transform_controller_unittest.cc
index 880611fe423..223cfa0bf32 100644
--- a/chromium/ui/display/manager/touch_transform_controller_unittest.cc
+++ b/chromium/ui/display/manager/touch_transform_controller_unittest.cc
@@ -557,9 +557,8 @@ TEST_F(TouchTransformControllerTest, AccurateUserTouchCalibration) {
const std::string msg = GetTouchPointString(user_input);
- touch_device_manager()->AddTouchCalibrationData(
- display::TouchDeviceIdentifier::FromDevice(touchscreen), display.id(),
- touch_data);
+ touch_device_manager()->AddTouchCalibrationData(touchscreen, display.id(),
+ touch_data);
EXPECT_FALSE(touch_device_manager()
->GetCalibrationData(touchscreen, display.id())
@@ -607,9 +606,8 @@ TEST_F(TouchTransformControllerTest, ErrorProneUserTouchCalibration) {
const std::string msg = GetTouchPointString(user_input);
- touch_device_manager()->AddTouchCalibrationData(
- display::TouchDeviceIdentifier::FromDevice(touchscreen), display.id(),
- touch_data);
+ touch_device_manager()->AddTouchCalibrationData(touchscreen, display.id(),
+ touch_data);
EXPECT_FALSE(touch_device_manager()
->GetCalibrationData(touchscreen, display.id())
@@ -659,9 +657,8 @@ TEST_F(TouchTransformControllerTest, ResolutionChangeUserTouchCalibration) {
const std::string msg = GetTouchPointString(user_input);
- touch_device_manager()->AddTouchCalibrationData(
- display::TouchDeviceIdentifier::FromDevice(touchscreen), display.id(),
- touch_data);
+ touch_device_manager()->AddTouchCalibrationData(touchscreen, display.id(),
+ touch_data);
EXPECT_FALSE(touch_device_manager()
->GetCalibrationData(touchscreen, display.id())
@@ -706,9 +703,8 @@ TEST_F(TouchTransformControllerTest, DifferentBoundsUserTouchCalibration) {
const std::string msg = GetTouchPointString(user_input);
- touch_device_manager()->AddTouchCalibrationData(
- display::TouchDeviceIdentifier::FromDevice(touchscreen), display.id(),
- touch_data);
+ touch_device_manager()->AddTouchCalibrationData(touchscreen, display.id(),
+ touch_data);
EXPECT_FALSE(touch_device_manager()
->GetCalibrationData(touchscreen, display.id())
@@ -770,8 +766,7 @@ TEST_F(TouchTransformControllerTest, LetterboxingUserTouchCalibration) {
// The calibration was performed at the native display resolution.
TouchCalibrationData touch_data(user_input, kNativeDisplaySize);
touch_device_manager()->AddTouchCalibrationData(
- display::TouchDeviceIdentifier::FromDevice(internal_touchscreen),
- internal_display_info.id(), touch_data);
+ internal_touchscreen, internal_display_info.id(), touch_data);
EXPECT_FALSE(
touch_device_manager()
@@ -849,8 +844,7 @@ TEST_F(TouchTransformControllerTest, PillarBoxingUserTouchCalibration) {
TouchCalibrationData touch_data(user_input, kNativeDisplaySize);
touch_device_manager()->AddTouchCalibrationData(
- display::TouchDeviceIdentifier::FromDevice(internal_touchscreen),
- internal_display_info.id(), touch_data);
+ internal_touchscreen, internal_display_info.id(), touch_data);
EXPECT_FALSE(
touch_device_manager()
diff --git a/chromium/ui/display/mojom/BUILD.gn b/chromium/ui/display/mojom/BUILD.gn
index a759490b15a..af12f462fb1 100644
--- a/chromium/ui/display/mojom/BUILD.gn
+++ b/chromium/ui/display/mojom/BUILD.gn
@@ -21,4 +21,136 @@ mojom("mojom") {
"//ui/gfx/geometry/mojom",
"//ui/gfx/mojom",
]
+
+ shared_cpp_typemaps = [
+ {
+ types = [
+ {
+ mojom = "display.mojom.Rotation"
+ cpp = "::display::Display::Rotation"
+ },
+ ]
+ traits_headers = [ "display_mojom_traits.h" ]
+ traits_public_deps = [ ":shared_mojom_traits" ]
+ },
+ ]
+
+ cpp_typemaps = [
+ {
+ types = [
+ {
+ mojom = "display.mojom.Display"
+ cpp = "::display::Display"
+ },
+ {
+ mojom = "display.mojom.TouchSupport"
+ cpp = "::display::Display::TouchSupport"
+ },
+ {
+ mojom = "display.mojom.AccelerometerSupport"
+ cpp = "::display::Display::AccelerometerSupport"
+ },
+ ]
+ traits_headers = [ "display_mojom_traits.h" ]
+ traits_public_deps = [ ":shared_mojom_traits" ]
+ },
+ {
+ types = [
+ {
+ mojom = "display.mojom.DisplayConnectionType"
+ cpp = "::display::DisplayConnectionType"
+ },
+ {
+ mojom = "display.mojom.HDCPState"
+ cpp = "::display::HDCPState"
+ },
+ {
+ mojom = "display.mojom.PrivacyScreenState"
+ cpp = "::display::PrivacyScreenState"
+ },
+ ]
+ traits_sources = [ "display_constants_mojom_traits.cc" ]
+ traits_headers = [ "display_constants_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/display" ]
+ },
+ {
+ types = [
+ {
+ mojom = "display.mojom.Position"
+ cpp = "::display::DisplayPlacement::Position"
+ },
+ {
+ mojom = "display.mojom.OffsetReference"
+ cpp = "::display::DisplayPlacement::OffsetReference"
+ },
+ {
+ mojom = "display.mojom.DisplayPlacement"
+ cpp = "::display::DisplayPlacement"
+ },
+ {
+ mojom = "display.mojom.DisplayLayout"
+ cpp = "::std::unique_ptr<::display::DisplayLayout>"
+ move_only = true
+ },
+ ]
+ traits_sources = [ "display_layout_mojom_traits.cc" ]
+ traits_headers = [ "display_layout_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/display" ]
+ },
+ {
+ types = [
+ {
+ mojom = "display.mojom.DisplayMode"
+ cpp = "::std::unique_ptr<::display::DisplayMode>"
+ move_only = true
+ },
+ ]
+ traits_sources = [ "display_mode_mojom_traits.cc" ]
+ traits_headers = [ "display_mode_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/display" ]
+ traits_deps = [ "//ui/gfx/geometry" ]
+ },
+ {
+ types = [
+ {
+ mojom = "display.mojom.DisplaySnapshot"
+ cpp = "::std::unique_ptr<::display::DisplaySnapshot>"
+ move_only = true
+ },
+ ]
+ traits_sources = [ "display_snapshot_mojom_traits.cc" ]
+ traits_headers = [ "display_snapshot_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/display" ]
+ traits_deps = [ "//ui/gfx/geometry" ]
+ },
+ {
+ types = [
+ {
+ mojom = "display.mojom.GammaRampRGBEntry"
+ cpp = "::display::GammaRampRGBEntry"
+ },
+ ]
+ traits_sources = [ "gamma_ramp_rgb_entry_mojom_traits.cc" ]
+ traits_headers = [ "gamma_ramp_rgb_entry_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/display" ]
+ },
+ ]
+
+ cpp_typemaps += shared_cpp_typemaps
+ blink_cpp_typemaps = shared_cpp_typemaps
+}
+
+component("shared_mojom_traits") {
+ output_name = "display_shared_mojom_traits"
+ defines = [ "IS_DISPLAY_SHARED_MOJOM_TRAITS_IMPL" ]
+ sources = [
+ "display_mojom_traits.cc",
+ "display_mojom_traits.h",
+ ]
+ public_deps = [
+ ":mojom_shared",
+ "//base",
+ "//ui/display",
+ "//ui/gfx/mojom",
+ ]
}
diff --git a/chromium/ui/display/mojom/OWNERS b/chromium/ui/display/mojom/OWNERS
index 7ed4e44a4d5..b36774dad1d 100644
--- a/chromium/ui/display/mojom/OWNERS
+++ b/chromium/ui/display/mojom/OWNERS
@@ -1,8 +1,4 @@
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
-
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-per-file *.typemap=set noparent
-per-file *.typemap=file://ipc/SECURITY_OWNERS
diff --git a/chromium/ui/display/mojom/display.typemap b/chromium/ui/display/mojom/display.typemap
deleted file mode 100644
index a9f26622978..00000000000
--- a/chromium/ui/display/mojom/display.typemap
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-mojom = "//ui/display/mojom/display.mojom"
-public_headers = [ "//ui/display/display.h" ]
-traits_headers = [ "//ui/display/mojom/display_mojom_traits.h" ]
-sources = [
- "//ui/display/mojom/display_mojom_traits.cc",
-]
-public_deps = [
- "//ui/display",
-]
-deps = [
- "//ui/gfx/geometry",
- "//ui/gfx/geometry/mojom:mojom_traits",
-]
-
-type_mappings = [
- "display.mojom.Display=::display::Display",
- "display.mojom.Rotation=::display::Display::Rotation",
- "display.mojom.TouchSupport=::display::Display::TouchSupport",
- "display.mojom.AccelerometerSupport=::display::Display::AccelerometerSupport",
-]
diff --git a/chromium/ui/display/mojom/display_constants.typemap b/chromium/ui/display/mojom/display_constants.typemap
deleted file mode 100644
index c7a3db17313..00000000000
--- a/chromium/ui/display/mojom/display_constants.typemap
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2017 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.
-
-mojom = "//ui/display/mojom/display_constants.mojom"
-public_headers = [ "//ui/display/types/display_constants.h" ]
-traits_headers = [ "//ui/display/mojom/display_constants_mojom_traits.h" ]
-sources = [
- "//ui/display/mojom/display_constants_mojom_traits.cc",
-]
-public_deps = [
- "//ui/display",
-]
-type_mappings = [
- "display.mojom.DisplayConnectionType=::display::DisplayConnectionType",
- "display.mojom.HDCPState=::display::HDCPState",
- "display.mojom.PrivacyScreenState=::display::PrivacyScreenState",
-]
diff --git a/chromium/ui/display/mojom/display_layout.typemap b/chromium/ui/display/mojom/display_layout.typemap
deleted file mode 100644
index 45acef4c4d6..00000000000
--- a/chromium/ui/display/mojom/display_layout.typemap
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2017 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.
-
-mojom = "//ui/display/mojom/display_layout.mojom"
-public_headers = [ "//ui/display/display_layout.h" ]
-traits_headers = [ "//ui/display/mojom/display_layout_mojom_traits.h" ]
-sources = [
- "//ui/display/mojom/display_layout_mojom_traits.cc",
-]
-public_deps = [
- "//ui/display",
-]
-
-type_mappings = [
- "display.mojom.Position=::display::DisplayPlacement::Position",
- "display.mojom.OffsetReference=::display::DisplayPlacement::OffsetReference",
- "display.mojom.DisplayPlacement=::display::DisplayPlacement",
- "display.mojom.DisplayLayout=::std::unique_ptr<::display::DisplayLayout>[move_only]",
-]
diff --git a/chromium/ui/display/mojom/display_mode.typemap b/chromium/ui/display/mojom/display_mode.typemap
deleted file mode 100644
index a8a571a71f6..00000000000
--- a/chromium/ui/display/mojom/display_mode.typemap
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2017 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.
-
-mojom = "//ui/display/mojom/display_mode.mojom"
-public_headers = [ "//ui/display/types/display_mode.h" ]
-traits_headers = [ "//ui/display/mojom/display_mode_mojom_traits.h" ]
-sources = [
- "//ui/display/mojom/display_mode_mojom_traits.cc",
-]
-public_deps = [
- "//ui/display",
-]
-deps = [
- "//ui/gfx/geometry",
-]
-type_mappings = [ "display.mojom.DisplayMode=::std::unique_ptr<::display::DisplayMode>[move_only]" ]
diff --git a/chromium/ui/display/mojom/display_mojom_traits.h b/chromium/ui/display/mojom/display_mojom_traits.h
index 303908ea785..fbd0f3086e7 100644
--- a/chromium/ui/display/mojom/display_mojom_traits.h
+++ b/chromium/ui/display/mojom/display_mojom_traits.h
@@ -5,23 +5,25 @@
#ifndef UI_DISPLAY_MOJOM_DISPLAY_MOJOM_TRAITS_H_
#define UI_DISPLAY_MOJOM_DISPLAY_MOJOM_TRAITS_H_
+#include "base/component_export.h"
#include "ui/display/display.h"
-#include "ui/display/mojom/display.mojom.h"
+#include "ui/display/mojom/display.mojom-shared.h"
#include "ui/gfx/geometry/mojom/geometry_mojom_traits.h"
#include "ui/gfx/mojom/display_color_spaces_mojom_traits.h"
namespace mojo {
template <>
-struct EnumTraits<display::mojom::Rotation, display::Display::Rotation> {
+struct COMPONENT_EXPORT(DISPLAY_SHARED_MOJOM_TRAITS)
+ EnumTraits<display::mojom::Rotation, display::Display::Rotation> {
static display::mojom::Rotation ToMojom(display::Display::Rotation type);
static bool FromMojom(display::mojom::Rotation type,
display::Display::Rotation* output);
};
template <>
-struct EnumTraits<display::mojom::TouchSupport,
- display::Display::TouchSupport> {
+struct COMPONENT_EXPORT(DISPLAY_SHARED_MOJOM_TRAITS)
+ EnumTraits<display::mojom::TouchSupport, display::Display::TouchSupport> {
static display::mojom::TouchSupport ToMojom(
display::Display::TouchSupport type);
static bool FromMojom(display::mojom::TouchSupport type,
@@ -29,8 +31,9 @@ struct EnumTraits<display::mojom::TouchSupport,
};
template <>
-struct EnumTraits<display::mojom::AccelerometerSupport,
- display::Display::AccelerometerSupport> {
+struct COMPONENT_EXPORT(DISPLAY_SHARED_MOJOM_TRAITS)
+ EnumTraits<display::mojom::AccelerometerSupport,
+ display::Display::AccelerometerSupport> {
static display::mojom::AccelerometerSupport ToMojom(
display::Display::AccelerometerSupport type);
static bool FromMojom(display::mojom::AccelerometerSupport type,
@@ -38,7 +41,8 @@ struct EnumTraits<display::mojom::AccelerometerSupport,
};
template <>
-struct StructTraits<display::mojom::DisplayDataView, display::Display> {
+struct COMPONENT_EXPORT(DISPLAY_SHARED_MOJOM_TRAITS)
+ StructTraits<display::mojom::DisplayDataView, display::Display> {
static int64_t id(const display::Display& display) { return display.id(); }
static const gfx::Rect& bounds(const display::Display& display) {
diff --git a/chromium/ui/display/mojom/display_mojom_traits_unittest.cc b/chromium/ui/display/mojom/display_mojom_traits_unittest.cc
index 5b2f09231f5..dd4e5f96469 100644
--- a/chromium/ui/display/mojom/display_mojom_traits_unittest.cc
+++ b/chromium/ui/display/mojom/display_mojom_traits_unittest.cc
@@ -12,6 +12,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/display/display.h"
#include "ui/display/display_layout.h"
+#include "ui/display/mojom/display.mojom.h"
#include "ui/display/mojom/display_layout_mojom_traits.h"
#include "ui/display/mojom/display_mode_mojom_traits.h"
#include "ui/display/mojom/display_mojom_traits.h"
diff --git a/chromium/ui/display/mojom/display_rotation_for_blink.typemap b/chromium/ui/display/mojom/display_rotation_for_blink.typemap
deleted file mode 100644
index b370d03e526..00000000000
--- a/chromium/ui/display/mojom/display_rotation_for_blink.typemap
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2018 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.
-
-mojom = "//ui/display/mojom/display.mojom"
-public_headers = [ "//ui/display/display.h" ]
-traits_headers = [ "//ui/display/mojom/display_mojom_traits.h" ]
-public_deps = [
- "//ui/display",
- "//ui/display/mojom:mojom",
-]
-type_mappings = [ "display.mojom.Rotation=::display::Display::Rotation" ]
diff --git a/chromium/ui/display/mojom/display_snapshot.typemap b/chromium/ui/display/mojom/display_snapshot.typemap
deleted file mode 100644
index eb0272c8a9d..00000000000
--- a/chromium/ui/display/mojom/display_snapshot.typemap
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2017 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.
-
-mojom = "//ui/display/mojom/display_snapshot.mojom"
-public_headers = [ "//ui/display/types/display_snapshot.h" ]
-traits_headers = [ "//ui/display/mojom/display_snapshot_mojom_traits.h" ]
-sources = [
- "//ui/display/mojom/display_snapshot_mojom_traits.cc",
-]
-public_deps = [
- "//ui/display",
-]
-deps = [
- "//ui/gfx/geometry",
-]
-type_mappings = [ "display.mojom.DisplaySnapshot=::std::unique_ptr<::display::DisplaySnapshot>[move_only]" ]
diff --git a/chromium/ui/display/mojom/gamma_ramp_rgb_entry.typemap b/chromium/ui/display/mojom/gamma_ramp_rgb_entry.typemap
deleted file mode 100644
index 045691f4bf3..00000000000
--- a/chromium/ui/display/mojom/gamma_ramp_rgb_entry.typemap
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2017 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.
-
-mojom = "//ui/display/mojom/gamma_ramp_rgb_entry.mojom"
-public_headers = [ "//ui/display/types/gamma_ramp_rgb_entry.h" ]
-traits_headers = [ "//ui/display/mojom/gamma_ramp_rgb_entry_mojom_traits.h" ]
-sources = [
- "//ui/display/mojom/gamma_ramp_rgb_entry_mojom_traits.cc",
-]
-public_deps = [
- "//ui/display",
-]
-type_mappings =
- [ "display.mojom.GammaRampRGBEntry=::display::GammaRampRGBEntry" ]
diff --git a/chromium/ui/display/mojom/typemaps.gni b/chromium/ui/display/mojom/typemaps.gni
deleted file mode 100644
index 1cbc47b18ee..00000000000
--- a/chromium/ui/display/mojom/typemaps.gni
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-typemaps = [
- "//ui/display/mojom/display.typemap",
- "//ui/display/mojom/display_constants.typemap",
- "//ui/display/mojom/display_layout.typemap",
- "//ui/display/mojom/display_mode.typemap",
- "//ui/display/mojom/display_snapshot.typemap",
- "//ui/display/mojom/gamma_ramp_rgb_entry.typemap",
-]
diff --git a/chromium/ui/display/screen.cc b/chromium/ui/display/screen.cc
index 2fd96e83321..ef1d381d9e2 100644
--- a/chromium/ui/display/screen.cc
+++ b/chromium/ui/display/screen.cc
@@ -4,6 +4,9 @@
#include "ui/display/screen.h"
+#include <utility>
+
+#include "base/logging.h"
#include "ui/display/display.h"
#include "ui/display/types/display_constants.h"
#include "ui/gfx/geometry/rect.h"
@@ -31,8 +34,8 @@ Screen* Screen::GetScreen() {
}
// static
-void Screen::SetScreenInstance(Screen* instance) {
- g_screen = instance;
+Screen* Screen::SetScreenInstance(Screen* instance) {
+ return std::exchange(g_screen, instance);
}
Display Screen::GetDisplayNearestView(gfx::NativeView view) const {
@@ -53,15 +56,15 @@ void Screen::SetDisplayForNewWindows(int64_t display_id) {
display_id_for_new_windows_ = display_id;
}
-gfx::Rect Screen::ScreenToDIPRectInWindow(gfx::NativeView view,
+gfx::Rect Screen::ScreenToDIPRectInWindow(gfx::NativeWindow window,
const gfx::Rect& screen_rect) const {
- float scale = GetDisplayNearestView(view).device_scale_factor();
+ float scale = GetDisplayNearestWindow(window).device_scale_factor();
return ScaleToEnclosingRect(screen_rect, 1.0f / scale);
}
-gfx::Rect Screen::DIPToScreenRectInWindow(gfx::NativeView view,
+gfx::Rect Screen::DIPToScreenRectInWindow(gfx::NativeWindow window,
const gfx::Rect& dip_rect) const {
- float scale = GetDisplayNearestView(view).device_scale_factor();
+ float scale = GetDisplayNearestWindow(window).device_scale_factor();
return ScaleToEnclosingRect(dip_rect, scale);
}
diff --git a/chromium/ui/display/screen.h b/chromium/ui/display/screen.h
index 53fb49afa95..2263985910f 100644
--- a/chromium/ui/display/screen.h
+++ b/chromium/ui/display/screen.h
@@ -5,6 +5,7 @@
#ifndef UI_DISPLAY_SCREEN_H_
#define UI_DISPLAY_SCREEN_H_
+#include <set>
#include <vector>
#include "base/macros.h"
@@ -37,9 +38,10 @@ class DISPLAY_EXPORT Screen {
// Retrieves the single Screen object.
static Screen* GetScreen();
- // Sets the global screen. NOTE: this does not take ownership of |screen|.
- // Tests must be sure to reset any state they install.
- static void SetScreenInstance(Screen* instance);
+ // Sets the global screen. Returns the previously installed screen, if any.
+ // NOTE: this does not take ownership of |screen|. Tests must be sure to reset
+ // any state they install.
+ static Screen* SetScreenInstance(Screen* instance);
// Returns the current absolute position of the mouse pointer.
virtual gfx::Point GetCursorScreenPoint() = 0;
@@ -50,6 +52,14 @@ class DISPLAY_EXPORT Screen {
// Returns the window at the given screen coordinate |point|.
virtual gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) = 0;
+ // Finds the topmost visible chrome window at |screen_point|. This should
+ // return nullptr if |screen_point| is in another program's window which
+ // occludes the topmost chrome window. Ignores the windows in |ignore|, which
+ // contain windows such as the tab being dragged right now.
+ virtual gfx::NativeWindow GetLocalProcessWindowAtPoint(
+ const gfx::Point& point,
+ const std::set<gfx::NativeWindow>& ignore) = 0;
+
// Returns the number of displays.
// Mirrored displays are excluded; this method is intended to return the
// number of distinct, usable displays.
@@ -90,16 +100,18 @@ class DISPLAY_EXPORT Screen {
virtual void AddObserver(DisplayObserver* observer) = 0;
virtual void RemoveObserver(DisplayObserver* observer) = 0;
- // Converts |screen_rect| to DIP coordinates in the context of |view| clamping
- // to the enclosing rect if the coordinates do not fall on pixel boundaries.
- // If |view| is null, the primary display is used as the context.
- virtual gfx::Rect ScreenToDIPRectInWindow(gfx::NativeView view,
+ // Converts |screen_rect| to DIP coordinates in the context of |window|
+ // clamping to the enclosing rect if the coordinates do not fall on pixel
+ // boundaries. If |window| is null, the primary display is used as the
+ // context.
+ virtual gfx::Rect ScreenToDIPRectInWindow(gfx::NativeWindow window,
const gfx::Rect& screen_rect) const;
- // Converts |dip_rect| to screen coordinates in the context of |view| clamping
- // to the enclosing rect if the coordinates do not fall on pixel boundaries.
- // If |view| is null, the primary display is used as the context.
- virtual gfx::Rect DIPToScreenRectInWindow(gfx::NativeView view,
+ // Converts |dip_rect| to screen coordinates in the context of |window|
+ // clamping to the enclosing rect if the coordinates do not fall on pixel
+ // boundaries. If |window| is null, the primary display is used as the
+ // context.
+ virtual gfx::Rect DIPToScreenRectInWindow(gfx::NativeWindow window,
const gfx::Rect& dip_rect) const;
// Returns true if the display with |display_id| is found and returns that
diff --git a/chromium/ui/display/screen_android.cc b/chromium/ui/display/screen_android.cc
index cfb564306f0..4f13d4e1235 100644
--- a/chromium/ui/display/screen_android.cc
+++ b/chromium/ui/display/screen_android.cc
@@ -4,7 +4,7 @@
#include "ui/display/screen.h"
-#include "base/logging.h"
+#include "base/notreached.h"
namespace display {
diff --git a/chromium/ui/display/screen_aura.cc b/chromium/ui/display/screen_aura.cc
index 3d210b1353d..81df76d9888 100644
--- a/chromium/ui/display/screen_aura.cc
+++ b/chromium/ui/display/screen_aura.cc
@@ -4,7 +4,7 @@
#include "ui/display/screen.h"
-#include "base/logging.h"
+#include "base/notreached.h"
namespace display {
diff --git a/chromium/ui/display/screen_base.cc b/chromium/ui/display/screen_base.cc
index 9d49b776699..03d89f0a4ec 100644
--- a/chromium/ui/display/screen_base.cc
+++ b/chromium/ui/display/screen_base.cc
@@ -27,6 +27,13 @@ gfx::NativeWindow ScreenBase::GetWindowAtScreenPoint(const gfx::Point& point) {
return nullptr;
}
+gfx::NativeWindow ScreenBase::GetLocalProcessWindowAtPoint(
+ const gfx::Point& screen_point,
+ const std::set<gfx::NativeWindow>& ignore) {
+ NOTIMPLEMENTED_LOG_ONCE();
+ return nullptr;
+}
+
Display ScreenBase::GetPrimaryDisplay() const {
auto iter = display_list_.GetPrimaryDisplayIterator();
if (iter == display_list_.displays().end())
diff --git a/chromium/ui/display/screen_base.h b/chromium/ui/display/screen_base.h
index 62b6e18a272..5013c0b959f 100644
--- a/chromium/ui/display/screen_base.h
+++ b/chromium/ui/display/screen_base.h
@@ -27,6 +27,9 @@ class DISPLAY_EXPORT ScreenBase : public Screen {
gfx::Point GetCursorScreenPoint() override;
bool IsWindowUnderCursor(gfx::NativeWindow window) override;
gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override;
+ gfx::NativeWindow GetLocalProcessWindowAtPoint(
+ const gfx::Point& screen_point,
+ const std::set<gfx::NativeWindow>& ignore) override;
Display GetPrimaryDisplay() const override;
Display GetDisplayNearestWindow(gfx::NativeWindow window) const override;
Display GetDisplayNearestPoint(const gfx::Point& point) const override;
diff --git a/chromium/ui/display/types/display_snapshot.cc b/chromium/ui/display/types/display_snapshot.cc
index a4c556f7224..ff90d89a8f1 100644
--- a/chromium/ui/display/types/display_snapshot.cc
+++ b/chromium/ui/display/types/display_snapshot.cc
@@ -10,6 +10,7 @@
#include <sstream>
#include <utility>
+#include "base/notreached.h"
#include "base/strings/stringprintf.h"
namespace display {
diff --git a/chromium/ui/display/util/display_util.cc b/chromium/ui/display/util/display_util.cc
index e96043238e4..f5a0ab66b71 100644
--- a/chromium/ui/display/util/display_util.cc
+++ b/chromium/ui/display/util/display_util.cc
@@ -32,6 +32,19 @@ void EmitEdidColorSpaceChecksOutcomeUma(EdidColorSpaceChecksOutcome outcome) {
outcome);
}
+// Returns true if each and all matrix values are within |epsilon| distance.
+bool NearlyEqual(const skcms_Matrix3x3& lhs,
+ const skcms_Matrix3x3& rhs,
+ float epsilon) {
+ for (int r = 0; r < 3; r++) {
+ for (int c = 0; c < 3; c++) {
+ if (std::abs(lhs.vals[r][c] - rhs.vals[r][c]) > epsilon)
+ return false;
+ }
+ }
+ return true;
+}
+
} // namespace
bool IsDisplaySizeBlackListed(const gfx::Size& physical_size) {
@@ -100,13 +113,21 @@ gfx::ColorSpace GetColorSpaceFromEdid(const display::EdidParser& edid_parser) {
return gfx::ColorSpace();
}
- skcms_Matrix3x3 color_space_as_matrix;
- if (!primaries.toXYZD50(&color_space_as_matrix)) {
+ skcms_Matrix3x3 primaries_matrix;
+ if (!primaries.toXYZD50(&primaries_matrix)) {
EmitEdidColorSpaceChecksOutcomeUma(
EdidColorSpaceChecksOutcome::kErrorCannotExtractToXYZD50);
return gfx::ColorSpace();
}
+ // Snap the primaries to those of BT.709/sRGB for performance purposes, see
+ // crbug.com/1073467. kPrimariesTolerance is an educated guess from various
+ // ChromeOS panels observations.
+ auto color_space_primaries = gfx::ColorSpace::PrimaryID::INVALID;
+ constexpr float kPrimariesTolerance = 0.025;
+ if (NearlyEqual(primaries_matrix, SkNamedGamut::kSRGB, kPrimariesTolerance))
+ color_space_primaries = gfx::ColorSpace::PrimaryID::BT709;
+
const double gamma = edid_parser.gamma();
if (gamma < 1.0) {
EmitEdidColorSpaceChecksOutcomeUma(
@@ -115,8 +136,7 @@ gfx::ColorSpace GetColorSpaceFromEdid(const display::EdidParser& edid_parser) {
}
EmitEdidColorSpaceChecksOutcomeUma(EdidColorSpaceChecksOutcome::kSuccess);
- gfx::ColorSpace::TransferID transfer_id =
- gfx::ColorSpace::TransferID::INVALID;
+ auto transfer_id = gfx::ColorSpace::TransferID::INVALID;
if (base::Contains(edid_parser.supported_color_primary_ids(),
gfx::ColorSpace::PrimaryID::BT2020)) {
if (base::Contains(edid_parser.supported_color_transfer_ids(),
@@ -132,11 +152,20 @@ gfx::ColorSpace GetColorSpaceFromEdid(const display::EdidParser& edid_parser) {
transfer_id = gfx::ColorSpace::TransferID::GAMMA24;
}
- if (transfer_id != gfx::ColorSpace::TransferID::INVALID)
- return gfx::ColorSpace::CreateCustom(color_space_as_matrix, transfer_id);
+ // Prefer to return a name-based ColorSpace to ease subsequent calculations.
+ if (transfer_id != gfx::ColorSpace::TransferID::INVALID) {
+ if (color_space_primaries != gfx::ColorSpace::PrimaryID::INVALID)
+ return gfx::ColorSpace(color_space_primaries, transfer_id);
+ return gfx::ColorSpace::CreateCustom(primaries_matrix, transfer_id);
+ }
skcms_TransferFunction transfer = {gamma, 1.f, 0.f, 0.f, 0.f, 0.f, 0.f};
- return gfx::ColorSpace::CreateCustom(color_space_as_matrix, transfer);
+ if (color_space_primaries == gfx::ColorSpace::PrimaryID::INVALID)
+ return gfx::ColorSpace::CreateCustom(primaries_matrix, transfer);
+ return gfx::ColorSpace(
+ color_space_primaries, gfx::ColorSpace::TransferID::CUSTOM,
+ gfx::ColorSpace::MatrixID::RGB, gfx::ColorSpace::RangeID::FULL,
+ /*custom_primary_matrix=*/nullptr, &transfer);
}
} // namespace display
diff --git a/chromium/ui/display/util/display_util_unittest.cc b/chromium/ui/display/util/display_util_unittest.cc
index 60b8c6bfadf..f4ab7470743 100644
--- a/chromium/ui/display/util/display_util_unittest.cc
+++ b/chromium/ui/display/util/display_util_unittest.cc
@@ -64,24 +64,24 @@ const unsigned char kEdidWithNoGamma[] =
"\x02\x12\x01\x03\x80\x34\x21\xFF\xEE\xEF\x95\xA3\x54\x4C\x9B\x26"
"\x0F\x50\x54\xA5\x6B\x80\x81\x40\x81\x80\x81\x99\x71\x00\xA9\x00";
-// A Samsung monitor that supports HDR metadata.
+// Chromebook Samsung Galaxy (kohaku) that supports HDR metadata.
constexpr unsigned char kHDR[] =
- "\x00\xff\xff\xff\xff\xff\xff\x00\x4c\x2d\xf6\x0d\x00\x0e\x00\x01"
- "\x01\x1b\x01\x03\x80\x5f\x36\x78\x0a\x23\xad\xa4\x54\x4d\x99\x26"
- "\x0f\x47\x4a\xbd\xef\x80\x71\x4f\x81\xc0\x81\x00\x81\x80\x95\x00"
- "\xa9\xc0\xb3\x00\x01\x01\x04\x74\x00\x30\xf2\x70\x5a\x80\xb0\x58"
- "\x8a\x00\x50\x1d\x74\x00\x00\x1e\x02\x3a\x80\x18\x71\x38\x2d\x40"
- "\x58\x2c\x45\x00\x50\x1d\x74\x00\x00\x1e\x00\x00\x00\xfd\x00\x18"
- "\x4b\x0f\x51\x1e\x00\x0a\x20\x20\x20\x20\x20\x20\x00\x00\x00\xfc"
- "\x00\x53\x41\x4d\x53\x55\x4e\x47\x0a\x20\x20\x20\x20\x20\x01\x5a"
- "\x02\x03\x4f\xf0\x53\x5f\x10\x1f\x04\x13\x05\x14\x20\x21\x22\x5d"
- "\x5e\x62\x63\x64\x07\x16\x03\x12\x2c\x09\x07\x07\x15\x07\x50\x3d"
- "\x04\xc0\x57\x07\x00\x83\x01\x00\x00\xe2\x00\x0f\xe3\x05\x83\x01"
- "\x6e\x03\x0c\x00\x30\x00\xb8\x3c\x20\x00\x80\x01\x02\x03\x04\xe3"
- "\x06\x0d\x01\xe5\x0e\x60\x61\x65\x66\xe5\x01\x8b\x84\x90\x01\x01"
- "\x1d\x80\xd0\x72\x1c\x16\x20\x10\x2c\x25\x80\x50\x1d\x74\x00\x00"
- "\x9e\x66\x21\x56\xaa\x51\x00\x1e\x30\x46\x8f\x33\x00\x50\x1d\x74"
- "\x00\x00\x1e\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xbd";
+ "\x00\xff\xff\xff\xff\xff\xff\x00\x4c\x83\x42\x41\x00\x00\x00\x00"
+ "\x13\x1d\x01\x04\xb5\x1d\x11\x78\x02\x38\xd1\xae\x51\x3b\xb8\x23"
+ "\x0b\x50\x54\x00\x00\x00\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01"
+ "\x01\x01\x01\x01\x01\x01\xb9\xd5\x00\x40\xf1\x70\x20\x80\x30\x20"
+ "\x88\x00\x26\xa5\x10\x00\x00\x1b\xb9\xd5\x00\x40\xf1\x70\x20\x80"
+ "\x30\x20\x88\x00\x26\xa5\x10\x00\x00\x1b\x00\x00\x00\x0f\x00\xff"
+ "\x09\x3c\xff\x09\x3c\x2c\x80\x00\x00\x00\x00\x00\x00\x00\x00\xfe"
+ "\x00\x41\x54\x4e\x41\x33\x33\x54\x50\x30\x34\x2d\x30\x20\x01\xba"
+ "\x02\x03\x0f\x00\xe3\x05\x80\x00\xe6\x06\x05\x01\x73\x6d\x07\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
+ "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xab";
// EDID collected in the wild: valid but with primaries in the wrong order.
const unsigned char kSST210[] =
@@ -185,22 +185,22 @@ TEST(DisplayUtilTest, GetColorSpaceFromEdid) {
EdidColorSpaceChecksOutcome::kSuccess),
2);
- // Test with Chromebook Eve internal display.
- constexpr SkColorSpacePrimaries expected_eve_primaries = {.fRX = 0.639648f,
- .fRY = 0.329102f,
- .fGX = 0.299805f,
- .fGY = 0.599609f,
- .fBX = 0.149414f,
- .fBY = 0.059570f,
- .fWX = 0.312500f,
- .fWY = 0.328125f};
- skcms_Matrix3x3 expected_eve_toXYZ50_matrix;
- expected_eve_primaries.toXYZD50(&expected_eve_toXYZ50_matrix);
+ // Test with Chromebook Eve internal display. The SkColorSpacePrimaries:
+ // SkColorSpacePrimaries expected_eve_primaries = {.fRX = 0.639648f,
+ // .fRY = 0.329102f,
+ // .fGX = 0.299805f,
+ // .fGY = 0.599609f,
+ // .fBX = 0.149414f,
+ // .fBY = 0.059570f,
+ // .fWX = 0.312500f,
+ // .fWY = 0.328125f};
+ // are very close to the BT.709/sRGB ones, so they'll be rounded to those.
+ const skcms_TransferFunction eve_transfer({2.2, 1, 0, 0, 0, 0, 0});
+ const gfx::ColorSpace expected_eve_color_space(
+ gfx::ColorSpace::PrimaryID::BT709, gfx::ColorSpace::TransferID::CUSTOM,
+ gfx::ColorSpace::MatrixID::RGB, gfx::ColorSpace::RangeID::FULL,
+ /*custom_primary_matrix=*/nullptr, &eve_transfer);
const std::vector<uint8_t> eve_edid(kEve, kEve + base::size(kEve) - 1);
- const gfx::ColorSpace expected_eve_color_space =
- gfx::ColorSpace::CreateCustom(
- expected_eve_toXYZ50_matrix,
- skcms_TransferFunction({2.2, 1, 0, 0, 0, 0, 0}));
EXPECT_EQ(expected_eve_color_space.ToString(),
GetColorSpaceFromEdid(display::EdidParser(eve_edid)).ToString());
histogram_tester.ExpectBucketCount(
@@ -209,15 +209,15 @@ TEST(DisplayUtilTest, GetColorSpaceFromEdid) {
EdidColorSpaceChecksOutcome::kSuccess),
3);
- // Test with a display that supports HDR.
- constexpr SkColorSpacePrimaries expected_hdr_primaries = {.fRX = 0.640625f,
- .fRY = 0.330078f,
- .fGX = 0.300781f,
- .fGY = 0.600586f,
- .fBX = 0.150391f,
- .fBY = 0.060547f,
- .fWX = 0.280273f,
- .fWY = 0.290039f};
+ // Test with a display that supports HDR: Chromebook Samsung Galaxy (kohaku).
+ constexpr SkColorSpacePrimaries expected_hdr_primaries = {.fRX = 0.67960f,
+ .fRY = 0.31930f,
+ .fGX = 0.23240f,
+ .fGY = 0.71870f,
+ .fBX = 0.13965f,
+ .fBY = 0.04400f,
+ .fWX = 0.31250f,
+ .fWY = 0.32910f};
skcms_Matrix3x3 expected_hdr_toXYZ50_matrix;
expected_hdr_primaries.toXYZD50(&expected_hdr_toXYZ50_matrix);
const std::vector<uint8_t> hdr_edid(kHDR, kHDR + base::size(kHDR) - 1);
diff --git a/chromium/ui/display/util/edid_parser.cc b/chromium/ui/display/util/edid_parser.cc
index 724532e26a2..4664a3e5332 100644
--- a/chromium/ui/display/util/edid_parser.cc
+++ b/chromium/ui/display/util/edid_parser.cc
@@ -9,7 +9,9 @@
#include <algorithm>
#include <bitset>
+#include "base/check.h"
#include "base/hash/hash.h"
+#include "base/metrics/histogram_functions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/sys_byteorder.h"
@@ -19,6 +21,25 @@
#include "ui/gfx/geometry/size.h"
namespace display {
+namespace {
+
+constexpr char kParseEdidFailureMetric[] = "Display.ParseEdidFailure";
+
+// These values are persisted to logs. Entries should not be renumbered and
+// numeric values should never be reused.
+enum class ParseEdidFailure {
+ kNoError = 0,
+ kManufacturerId = 1,
+ kProductId = 2,
+ kYearOfManufacture = 3,
+ kBitsPerChannel = 4,
+ kGamma = 5,
+ kChromaticityCoordinates = 6,
+ kDisplayName = 7,
+ kExtensions = 8,
+ kMaxValue = kExtensions,
+};
+} // namespace
EdidParser::EdidParser(const std::vector<uint8_t>& edid_blob)
: manufacturer_id_(0),
@@ -99,8 +120,8 @@ void EdidParser::ParseEdid(const std::vector<uint8_t>& edid) {
constexpr size_t kProductIdLength = 2;
if (edid.size() < kManufacturerOffset + kManufacturerLength) {
- LOG(ERROR) << "Too short EDID data: manufacturer id";
- // TODO(mcasas): add UMA, https://crbug.com/821393.
+ base::UmaHistogramEnumeration(kParseEdidFailureMetric,
+ ParseEdidFailure::kManufacturerId);
return; // Any other fields below are beyond this edid offset.
}
// ICC filename is generated based on these ids. We always read this as big
@@ -109,8 +130,8 @@ void EdidParser::ParseEdid(const std::vector<uint8_t>& edid) {
(edid[kManufacturerOffset] << 8) + edid[kManufacturerOffset + 1];
if (edid.size() < kProductIdOffset + kProductIdLength) {
- LOG(ERROR) << "Too short EDID data: product id";
- // TODO(mcasas): add UMA, https://crbug.com/821393.
+ base::UmaHistogramEnumeration(kParseEdidFailureMetric,
+ ParseEdidFailure::kProductId);
return; // Any other fields below are beyond this edid offset.
}
product_id_ = (edid[kProductIdOffset] << 8) + edid[kProductIdOffset + 1];
@@ -123,8 +144,8 @@ void EdidParser::ParseEdid(const std::vector<uint8_t>& edid) {
constexpr int32_t kYearOffset = 1990;
if (edid.size() < kYearOfManufactureOffset + 1) {
- LOG(ERROR) << "Too short EDID data: year of manufacture";
- // TODO(mcasas): add UMA, https://crbug.com/821393.
+ base::UmaHistogramEnumeration(kParseEdidFailureMetric,
+ ParseEdidFailure::kYearOfManufacture);
return; // Any other fields below are beyond this edid offset.
}
const uint8_t byte_data = edid[kYearOfManufactureOffset];
@@ -144,8 +165,8 @@ void EdidParser::ParseEdid(const std::vector<uint8_t>& edid) {
constexpr uint8_t kColorBitDepthOffset = 4;
if (edid.size() < kVideoInputDefinitionOffset + 1) {
- LOG(ERROR) << "Too short EDID data: bits per channel";
- // TODO(mcasas): add UMA, https://crbug.com/821393.
+ base::UmaHistogramEnumeration(kParseEdidFailureMetric,
+ ParseEdidFailure::kBitsPerChannel);
return; // Any other fields below are beyond this edid offset.
}
if (edid[kEDIDRevisionNumberOffset] >= kEDIDRevision4Value &&
@@ -164,8 +185,8 @@ void EdidParser::ParseEdid(const std::vector<uint8_t>& edid) {
constexpr double kGammaBias = 100.0;
if (edid.size() < kGammaOffset + 1) {
- LOG(ERROR) << "Too short EDID data: gamma";
- // TODO(mcasas): add UMA, https://crbug.com/821393.
+ base::UmaHistogramEnumeration(kParseEdidFailureMetric,
+ ParseEdidFailure::kGamma);
return; // Any other fields below are beyond this edid offset.
}
if (edid[kGammaOffset] != 0xFF) {
@@ -209,8 +230,8 @@ void EdidParser::ParseEdid(const std::vector<uint8_t>& edid) {
"EDID Parameter section length error");
if (edid.size() < kChromaticityOffset + kChromaticityLength) {
- LOG(ERROR) << "Too short EDID data: chromaticity coordinates";
- // TODO(mcasas): add UMA, https://crbug.com/821393.
+ base::UmaHistogramEnumeration(kParseEdidFailureMetric,
+ ParseEdidFailure::kChromaticityCoordinates);
return; // Any other fields below are beyond this edid offset.
}
@@ -311,8 +332,8 @@ void EdidParser::ParseEdid(const std::vector<uint8_t>& edid) {
for (const char c : display_name_) {
if (!isascii(c) || !isprint(c)) {
display_name_.clear();
- LOG(ERROR) << "invalid EDID: human unreadable char in name";
- // TODO(mcasas): add UMA, https://crbug.com/821393.
+ base::UmaHistogramEnumeration(kParseEdidFailureMetric,
+ ParseEdidFailure::kDisplayName);
}
}
@@ -365,8 +386,8 @@ void EdidParser::ParseEdid(const std::vector<uint8_t>& edid) {
constexpr uint8_t kHDRStaticMetadataDataBlockLengthMask = 0x1F;
if (edid.size() < kNumExtensionsOffset + 1) {
- LOG(ERROR) << "Too short EDID data: extensions";
- // TODO(mcasas): add UMA, https://crbug.com/821393.
+ base::UmaHistogramEnumeration(kParseEdidFailureMetric,
+ ParseEdidFailure::kExtensions);
return; // Any other fields below are beyond this edid offset.
}
const uint8_t num_extensions = edid[kNumExtensionsOffset];
@@ -471,6 +492,8 @@ void EdidParser::ParseEdid(const std::vector<uint8_t>& edid) {
data_offset += payload_length + 1;
}
}
+ base::UmaHistogramEnumeration(kParseEdidFailureMetric,
+ ParseEdidFailure::kNoError);
}
} // namespace display
diff --git a/chromium/ui/display/win/base_window_finder_win.cc b/chromium/ui/display/win/base_window_finder_win.cc
new file mode 100644
index 00000000000..70624e1cfcf
--- /dev/null
+++ b/chromium/ui/display/win/base_window_finder_win.cc
@@ -0,0 +1,30 @@
+// Copyright 2020 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 "ui/display/win/base_window_finder_win.h"
+
+#include <objbase.h>
+
+namespace display {
+namespace win {
+
+// Creates a BaseWindowFinderWin with the specified set of HWNDs to ignore.
+BaseWindowFinderWin::BaseWindowFinderWin(const std::set<HWND>& ignore)
+ : ignore_(ignore) {}
+
+BaseWindowFinderWin::~BaseWindowFinderWin() = default;
+
+// static
+BOOL CALLBACK BaseWindowFinderWin::WindowCallbackProc(HWND hwnd,
+ LPARAM lParam) {
+ // Cast must match that in as_lparam().
+ BaseWindowFinderWin* finder = reinterpret_cast<BaseWindowFinderWin*>(lParam);
+ if (finder->ignore_.find(hwnd) != finder->ignore_.end())
+ return TRUE;
+
+ return finder->ShouldStopIterating(hwnd) ? FALSE : TRUE;
+}
+
+} // namespace win
+} // namespace display \ No newline at end of file
diff --git a/chromium/ui/display/win/base_window_finder_win.h b/chromium/ui/display/win/base_window_finder_win.h
new file mode 100644
index 00000000000..7f769a2d117
--- /dev/null
+++ b/chromium/ui/display/win/base_window_finder_win.h
@@ -0,0 +1,46 @@
+// Copyright 2020 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 UI_DISPLAY_WIN_BASE_WINDOW_FINDER_WIN_H_
+#define UI_DISPLAY_WIN_BASE_WINDOW_FINDER_WIN_H_
+
+#include <set>
+
+#include "base/win/windows_types.h"
+
+namespace display {
+namespace win {
+
+// Base class used to locate a window. This is intended to be used with the
+// various win32 functions that iterate over windows.
+//
+// A subclass need only override ShouldStopIterating to determine when
+// iteration should stop.
+class BaseWindowFinderWin {
+ public:
+ // Creates a BaseWindowFinderWin with the specified set of HWNDs to ignore.
+ explicit BaseWindowFinderWin(const std::set<HWND>& ignore);
+ BaseWindowFinderWin(const BaseWindowFinderWin& finder) = delete;
+ BaseWindowFinderWin& operator=(const BaseWindowFinderWin& finder) = delete;
+ virtual ~BaseWindowFinderWin();
+
+ protected:
+ static BOOL CALLBACK WindowCallbackProc(HWND hwnd, LPARAM lParam);
+
+ LPARAM as_lparam() {
+ // Cast must match that in WindowCallbackProc().
+ return reinterpret_cast<LPARAM>(static_cast<BaseWindowFinderWin*>(this));
+ }
+
+ // Returns true if iteration should stop, false if iteration should continue.
+ virtual bool ShouldStopIterating(HWND window) = 0;
+
+ private:
+ const std::set<HWND>& ignore_;
+};
+
+} // namespace win
+} // namespace display
+
+#endif // UI_DISPLAY_WIN_BASE_WINDOW_FINDER_WIN_H_ \ No newline at end of file
diff --git a/chromium/ui/display/win/color_profile_reader.cc b/chromium/ui/display/win/color_profile_reader.cc
index 212c7fa54c0..495fb5b1b86 100644
--- a/chromium/ui/display/win/color_profile_reader.cc
+++ b/chromium/ui/display/win/color_profile_reader.cc
@@ -11,6 +11,7 @@
#include "base/files/file_util.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
+#include "base/threading/scoped_thread_priority.h"
#include "ui/display/win/display_info.h"
#include "ui/gfx/icc_profile.h"
@@ -79,6 +80,7 @@ void ColorProfileReader::UpdateIfNeeded() {
// static
ColorProfileReader::DeviceToPathMap
ColorProfileReader::BuildDeviceToPathMapOnBackgroundThread() {
+ SCOPED_MAY_LOAD_LIBRARY_AT_BACKGROUND_PRIORITY();
DeviceToPathMap device_to_path_map;
EnumDisplayMonitors(nullptr, nullptr, EnumMonitorForProfilePathCallback,
reinterpret_cast<LPARAM>(&device_to_path_map));
diff --git a/chromium/ui/display/win/display_info.cc b/chromium/ui/display/win/display_info.cc
index fe378ce87ab..91bc0872fa5 100644
--- a/chromium/ui/display/win/display_info.cc
+++ b/chromium/ui/display/win/display_info.cc
@@ -10,20 +10,23 @@
namespace display {
namespace win {
-DisplayInfo::DisplayInfo(const MONITORINFOEX& monitor_info,
- float device_scale_factor,
- float sdr_white_level,
- Display::Rotation rotation,
- int display_frequency,
- const gfx::Vector2dF& pixels_per_inch)
+DisplayInfo::DisplayInfo(
+ const MONITORINFOEX& monitor_info,
+ float device_scale_factor,
+ float sdr_white_level,
+ Display::Rotation rotation,
+ int display_frequency,
+ const gfx::Vector2dF& pixels_per_inch,
+ DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY output_technology)
: id_(DeviceIdFromDeviceName(monitor_info.szDevice)),
- rotation_(rotation),
screen_rect_(monitor_info.rcMonitor),
screen_work_rect_(monitor_info.rcWork),
device_scale_factor_(device_scale_factor),
sdr_white_level_(sdr_white_level),
+ rotation_(rotation),
display_frequency_(display_frequency),
- pixels_per_inch_(pixels_per_inch) {}
+ pixels_per_inch_(pixels_per_inch),
+ output_technology_(output_technology) {}
DisplayInfo::~DisplayInfo() = default;
diff --git a/chromium/ui/display/win/display_info.h b/chromium/ui/display/win/display_info.h
index 2507221efb5..f6c689b9a8f 100644
--- a/chromium/ui/display/win/display_info.h
+++ b/chromium/ui/display/win/display_info.h
@@ -22,31 +22,36 @@ class DISPLAY_EXPORT DisplayInfo final {
float sdr_white_level,
Display::Rotation rotation,
int display_frequency,
- const gfx::Vector2dF& pixels_per_inch);
+ const gfx::Vector2dF& pixels_per_inch,
+ DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY output_technology);
~DisplayInfo();
static int64_t DeviceIdFromDeviceName(const wchar_t* device_name);
int64_t id() const { return id_; }
- Display::Rotation rotation() const { return rotation_; }
const gfx::Rect& screen_rect() const { return screen_rect_; }
const gfx::Rect& screen_work_rect() const { return screen_work_rect_; }
float device_scale_factor() const { return device_scale_factor_; }
float sdr_white_level() const { return sdr_white_level_; }
+ Display::Rotation rotation() const { return rotation_; }
int display_frequency() const { return display_frequency_; }
const gfx::Vector2dF& pixels_per_inch() const { return pixels_per_inch_; }
+ DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY output_technology() const {
+ return output_technology_;
+ }
private:
int64_t id_;
- Display::Rotation rotation_;
gfx::Rect screen_rect_;
gfx::Rect screen_work_rect_;
float device_scale_factor_;
float sdr_white_level_;
+ Display::Rotation rotation_;
int display_frequency_;
// Pixels per inch of a display. This value will only be set for touch
// monitors. In non-touch cases, it will be set to Zero.
gfx::Vector2dF pixels_per_inch_;
+ DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY output_technology_;
};
} // namespace win
diff --git a/chromium/ui/display/win/local_process_window_finder_win.cc b/chromium/ui/display/win/local_process_window_finder_win.cc
new file mode 100644
index 00000000000..d4be1b9f346
--- /dev/null
+++ b/chromium/ui/display/win/local_process_window_finder_win.cc
@@ -0,0 +1,67 @@
+// Copyright 2020 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 "ui/display/win/local_process_window_finder_win.h"
+
+#include "base/win/windows_version.h"
+#include "ui/display/win/screen_win.h"
+#include "ui/display/win/topmost_window_finder_win.h"
+
+namespace display {
+namespace win {
+
+// static
+gfx::NativeWindow LocalProcessWindowFinder::GetProcessWindowAtPoint(
+ const gfx::Point& screen_loc,
+ const std::set<HWND>& ignore,
+ ScreenWin* screen_win) {
+ LocalProcessWindowFinder finder(screen_loc, ignore);
+ // Windows 8 has a window that appears first in the list of iterated
+ // windows, yet is not visually on top of everything.
+ // TODO(sky): figure out a better way to ignore this window.
+ if (finder.result_ && ((base::win::OSInfo::GetInstance()->version() >=
+ base::win::Version::WIN8) ||
+ TopMostFinderWin::IsTopMostWindowAtPoint(
+ finder.result_, screen_loc, ignore))) {
+ return screen_win->GetNativeWindowFromHWND(finder.result_);
+ }
+ return nullptr;
+}
+
+bool LocalProcessWindowFinder::ShouldStopIterating(HWND hwnd) {
+ RECT r;
+
+ // Make sure the window is on the same virtual desktop.
+ if (virtual_desktop_manager_) {
+ BOOL on_current_desktop;
+ if (SUCCEEDED(virtual_desktop_manager_->IsWindowOnCurrentVirtualDesktop(
+ hwnd, &on_current_desktop)) &&
+ !on_current_desktop) {
+ return false;
+ }
+ }
+
+ if (IsWindowVisible(hwnd) && GetWindowRect(hwnd, &r) &&
+ PtInRect(&r, screen_loc_.ToPOINT())) {
+ result_ = hwnd;
+ return true;
+ }
+ return false;
+}
+
+LocalProcessWindowFinder::LocalProcessWindowFinder(const gfx::Point& screen_loc,
+ const std::set<HWND>& ignore)
+ : BaseWindowFinderWin(ignore), result_(nullptr) {
+ if (base::win::GetVersion() >= base::win::Version::WIN10) {
+ ::CoCreateInstance(__uuidof(VirtualDesktopManager), nullptr, CLSCTX_ALL,
+ IID_PPV_ARGS(&virtual_desktop_manager_));
+ }
+ screen_loc_ = display::win::ScreenWin::DIPToScreenPoint(screen_loc);
+ EnumThreadWindows(GetCurrentThreadId(), WindowCallbackProc, as_lparam());
+}
+
+LocalProcessWindowFinder::~LocalProcessWindowFinder() = default;
+
+} // namespace win
+} // namespace display \ No newline at end of file
diff --git a/chromium/ui/display/win/local_process_window_finder_win.h b/chromium/ui/display/win/local_process_window_finder_win.h
new file mode 100644
index 00000000000..13f14ca70c7
--- /dev/null
+++ b/chromium/ui/display/win/local_process_window_finder_win.h
@@ -0,0 +1,55 @@
+// Copyright 2020 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 UI_DISPLAY_WIN_LOCAL_PROCESS_WINDOW_FINDER_WIN_H_
+#define UI_DISPLAY_WIN_LOCAL_PROCESS_WINDOW_FINDER_WIN_H_
+
+#include <shobjidl.h>
+#include <wrl/client.h>
+
+#include "ui/display/win/base_window_finder_win.h"
+#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/native_widget_types.h"
+
+namespace display {
+namespace win {
+
+class ScreenWin;
+
+// Helper class to determine if a particular point contains a window from our
+// process.
+class LocalProcessWindowFinder : public BaseWindowFinderWin {
+ public:
+ // Returns the hwnd from our process at screen_loc that is not obscured by
+ // another window. Returns NULL otherwise.
+ static gfx::NativeWindow GetProcessWindowAtPoint(const gfx::Point& screen_loc,
+ const std::set<HWND>& ignore,
+ ScreenWin* screen_win);
+
+ protected:
+ bool ShouldStopIterating(HWND hwnd) override;
+
+ private:
+ LocalProcessWindowFinder(const gfx::Point& screen_loc,
+ const std::set<HWND>& ignore);
+ LocalProcessWindowFinder(const LocalProcessWindowFinder& finder) = delete;
+ LocalProcessWindowFinder& operator=(const LocalProcessWindowFinder& finder) =
+ delete;
+ ~LocalProcessWindowFinder() override;
+
+ // Position of the mouse in pixel coordinates.
+ gfx::Point screen_loc_;
+
+ // The resulting window. This is initially null but set to true in
+ // ShouldStopIterating if an appropriate window is found.
+ HWND result_;
+
+ // Only used on Win10+.
+ Microsoft::WRL::ComPtr<IVirtualDesktopManager> virtual_desktop_manager_;
+};
+
+} // namespace win
+} // namespace display
+
+#endif // UI_DISPLAY_WIN_LOCAL_PROCESS_WINDOW_FINDER_WIN_H_ \ No newline at end of file
diff --git a/chromium/ui/display/win/scaling_util.cc b/chromium/ui/display/win/scaling_util.cc
index a390ad314ac..2102a7d0475 100644
--- a/chromium/ui/display/win/scaling_util.cc
+++ b/chromium/ui/display/win/scaling_util.cc
@@ -6,6 +6,8 @@
#include <algorithm>
+#include "base/check.h"
+#include "base/notreached.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/safe_integer_conversions.h"
#include "ui/gfx/geometry/size.h"
diff --git a/chromium/ui/display/win/scaling_util_unittest.cc b/chromium/ui/display/win/scaling_util_unittest.cc
index c3fc789731d..c6fd7f4c226 100644
--- a/chromium/ui/display/win/scaling_util_unittest.cc
+++ b/chromium/ui/display/win/scaling_util_unittest.cc
@@ -21,7 +21,7 @@ DisplayInfo CreateDisplayInfo(int x, int y, int width, int height,
gfx::Rect(x, y, width, height),
kFakeDisplayName);
return DisplayInfo(monitor_info, scale_factor, 1.0f, Display::ROTATE_0, 60,
- gfx::Vector2dF());
+ gfx::Vector2dF(), DISPLAYCONFIG_OUTPUT_TECHNOLOGY_OTHER);
}
::testing::AssertionResult AssertOffsetsEqual(
diff --git a/chromium/ui/display/win/screen_win.cc b/chromium/ui/display/win/screen_win.cc
index ee77605a6b0..0c789c42fa5 100644
--- a/chromium/ui/display/win/screen_win.cc
+++ b/chromium/ui/display/win/screen_win.cc
@@ -22,6 +22,7 @@
#include "ui/display/display_layout_builder.h"
#include "ui/display/win/display_info.h"
#include "ui/display/win/dpi.h"
+#include "ui/display/win/local_process_window_finder_win.h"
#include "ui/display/win/scaling_util.h"
#include "ui/display/win/screen_win_display.h"
#include "ui/gfx/geometry/point_conversions.h"
@@ -126,19 +127,39 @@ base::Optional<DISPLAYCONFIG_PATH_INFO> GetPathInfo(HMONITOR monitor) {
return base::nullopt;
}
-float GetMonitorSDRWhiteLevel(HMONITOR monitor) {
- if (auto path_info = GetPathInfo(monitor)) {
+float GetSDRWhiteLevel(const base::Optional<DISPLAYCONFIG_PATH_INFO>& path) {
+ if (path) {
DISPLAYCONFIG_SDR_WHITE_LEVEL white_level = {};
white_level.header.type = DISPLAYCONFIG_DEVICE_INFO_GET_SDR_WHITE_LEVEL;
white_level.header.size = sizeof(white_level);
- white_level.header.adapterId = path_info->targetInfo.adapterId;
- white_level.header.id = path_info->targetInfo.id;
+ white_level.header.adapterId = path->targetInfo.adapterId;
+ white_level.header.id = path->targetInfo.id;
if (DisplayConfigGetDeviceInfo(&white_level.header) == ERROR_SUCCESS)
return white_level.SDRWhiteLevel * 80.0 / 1000.0;
}
return 200.0f;
}
+DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY GetOutputTechnology(
+ const base::Optional<DISPLAYCONFIG_PATH_INFO>& path) {
+ if (path)
+ return path->targetInfo.outputTechnology;
+ return DISPLAYCONFIG_OUTPUT_TECHNOLOGY_OTHER;
+}
+
+// Returns true if |tech| represents an internal display (eg. a laptop screen).
+bool IsInternalOutputTechnology(DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY tech) {
+ switch (tech) {
+ case DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL:
+ case DISPLAYCONFIG_OUTPUT_TECHNOLOGY_DISPLAYPORT_EMBEDDED:
+ case DISPLAYCONFIG_OUTPUT_TECHNOLOGY_UDI_EMBEDDED:
+ return true;
+
+ default:
+ return false;
+ }
+}
+
Display::Rotation OrientationToRotation(DWORD orientation) {
switch (orientation) {
case DMDO_DEFAULT:
@@ -423,13 +444,14 @@ BOOL CALLBACK EnumMonitorForDisplayInfoCallback(HMONITOR monitor,
const gfx::Vector2dF pixels_per_inch =
GetMonitorPixelsPerInch(monitor).value_or(
GetDefaultMonitorPhysicalPixelsPerInch());
+ const auto path_info = GetPathInfo(monitor);
auto* display_infos = reinterpret_cast<std::vector<DisplayInfo>*>(data);
DCHECK(display_infos);
- display_infos->emplace_back(monitor_info, GetMonitorScaleFactor(monitor),
- GetMonitorSDRWhiteLevel(monitor),
- display_settings.rotation,
- display_settings.frequency, pixels_per_inch);
+ display_infos->emplace_back(
+ monitor_info, GetMonitorScaleFactor(monitor), GetSDRWhiteLevel(path_info),
+ display_settings.rotation, display_settings.frequency, pixels_per_inch,
+ GetOutputTechnology(path_info));
return TRUE;
}
@@ -635,7 +657,7 @@ void ScreenWin::SetHDREnabled(bool hdr_enabled) {
}
}
-HWND ScreenWin::GetHWNDFromNativeView(gfx::NativeView window) const {
+HWND ScreenWin::GetHWNDFromNativeWindow(gfx::NativeWindow window) const {
NOTREACHED();
return nullptr;
}
@@ -669,6 +691,20 @@ gfx::NativeWindow ScreenWin::GetWindowAtScreenPoint(const gfx::Point& point) {
return GetNativeWindowFromHWND(WindowFromPoint(screen_point.ToPOINT()));
}
+gfx::NativeWindow ScreenWin::GetLocalProcessWindowAtPoint(
+ const gfx::Point& point,
+ const std::set<gfx::NativeWindow>& ignore) {
+ std::set<HWND> hwnd_set;
+ for (auto* const window : ignore) {
+ HWND w = GetHWNDFromNativeWindow(window);
+ if (w)
+ hwnd_set.emplace(w);
+ }
+
+ return LocalProcessWindowFinder::GetProcessWindowAtPoint(point, hwnd_set,
+ this);
+}
+
int ScreenWin::GetNumDisplays() const {
return int{screen_win_displays_.size()};
}
@@ -678,7 +714,7 @@ const std::vector<Display>& ScreenWin::GetAllDisplays() const {
}
Display ScreenWin::GetDisplayNearestWindow(gfx::NativeWindow window) const {
- const HWND window_hwnd = window ? GetHWNDFromNativeView(window) : nullptr;
+ const HWND window_hwnd = window ? GetHWNDFromNativeWindow(window) : nullptr;
// When |window| isn't rooted to a display, we should just return the default
// display so we get some correct display information like the scaling factor.
return window_hwnd ? GetScreenWinDisplayNearestHWND(window_hwnd).display()
@@ -707,15 +743,15 @@ void ScreenWin::RemoveObserver(DisplayObserver* observer) {
}
gfx::Rect ScreenWin::ScreenToDIPRectInWindow(
- gfx::NativeView view,
+ gfx::NativeWindow window,
const gfx::Rect& screen_rect) const {
- const HWND hwnd = view ? GetHWNDFromNativeView(view) : nullptr;
+ const HWND hwnd = window ? GetHWNDFromNativeWindow(window) : nullptr;
return ScreenToDIPRect(hwnd, screen_rect);
}
-gfx::Rect ScreenWin::DIPToScreenRectInWindow(gfx::NativeView view,
+gfx::Rect ScreenWin::DIPToScreenRectInWindow(gfx::NativeWindow window,
const gfx::Rect& dip_rect) const {
- const HWND hwnd = view ? GetHWNDFromNativeView(view) : nullptr;
+ const HWND hwnd = window ? GetHWNDFromNativeWindow(window) : nullptr;
return DIPToScreenRect(hwnd, dip_rect);
}
@@ -724,6 +760,13 @@ void ScreenWin::UpdateFromDisplayInfos(
screen_win_displays_ = DisplayInfosToScreenWinDisplays(
display_infos, color_profile_reader_.get(), hdr_enabled_);
displays_ = ScreenWinDisplaysToDisplays(screen_win_displays_);
+ for (const auto& display_info : display_infos) {
+ if (IsInternalOutputTechnology(display_info.output_technology())) {
+ // TODO(crbug.com/1078903): Support multiple internal displays.
+ Display::SetInternalDisplayId(display_info.id());
+ break;
+ }
+ }
}
void ScreenWin::Initialize() {
diff --git a/chromium/ui/display/win/screen_win.h b/chromium/ui/display/win/screen_win.h
index 40c388cfbfd..dfffbeff3f5 100644
--- a/chromium/ui/display/win/screen_win.h
+++ b/chromium/ui/display/win/screen_win.h
@@ -148,10 +148,10 @@ class DISPLAY_EXPORT ScreenWin : public Screen,
// to return that HDR is supported.
static void SetHDREnabled(bool hdr_enabled);
- // Returns the HWND associated with the NativeView.
- virtual HWND GetHWNDFromNativeView(gfx::NativeView view) const;
+ // Returns the HWND associated with the NativeWindow.
+ virtual HWND GetHWNDFromNativeWindow(gfx::NativeWindow view) const;
- // Returns the NativeView associated with the HWND.
+ // Returns the NativeWindow associated with the HWND.
virtual gfx::NativeWindow GetNativeWindowFromHWND(HWND hwnd) const;
protected:
@@ -161,6 +161,9 @@ class DISPLAY_EXPORT ScreenWin : public Screen,
gfx::Point GetCursorScreenPoint() override;
bool IsWindowUnderCursor(gfx::NativeWindow window) override;
gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override;
+ gfx::NativeWindow GetLocalProcessWindowAtPoint(
+ const gfx::Point& point,
+ const std::set<gfx::NativeWindow>& ignore) override;
int GetNumDisplays() const override;
const std::vector<Display>& GetAllDisplays() const override;
Display GetDisplayNearestWindow(gfx::NativeWindow window) const override;
@@ -170,9 +173,10 @@ class DISPLAY_EXPORT ScreenWin : public Screen,
void AddObserver(DisplayObserver* observer) override;
void RemoveObserver(DisplayObserver* observer) override;
gfx::Rect ScreenToDIPRectInWindow(
- gfx::NativeView view, const gfx::Rect& screen_rect) const override;
- gfx::Rect DIPToScreenRectInWindow(
- gfx::NativeView view, const gfx::Rect& dip_rect) const override;
+ gfx::NativeWindow window,
+ const gfx::Rect& screen_rect) const override;
+ gfx::Rect DIPToScreenRectInWindow(gfx::NativeWindow window,
+ const gfx::Rect& dip_rect) const override;
// ColorProfileReader::Client:
void OnColorProfilesChanged() override;
diff --git a/chromium/ui/display/win/screen_win_unittest.cc b/chromium/ui/display/win/screen_win_unittest.cc
index 1b4f1543cd7..059c533c4f1 100644
--- a/chromium/ui/display/win/screen_win_unittest.cc
+++ b/chromium/ui/display/win/screen_win_unittest.cc
@@ -1,4 +1,4 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
+// 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.
@@ -43,9 +43,9 @@ class TestScreenWin : public ScreenWin {
protected:
// win::ScreenWin:
- HWND GetHWNDFromNativeView(gfx::NativeView window) const override {
- // NativeView is only used as an identifier in these tests, so interchange
- // a NativeView for an HWND for convenience.
+ HWND GetHWNDFromNativeWindow(gfx::NativeWindow window) const override {
+ // NativeWindow is only used as an identifier in these tests, so interchange
+ // a NativeWindow for an HWND for convenience.
return reinterpret_cast<HWND>(window);
}
@@ -138,7 +138,9 @@ class TestScreenWinInitializer {
virtual void AddMonitor(const gfx::Rect& pixel_bounds,
const gfx::Rect& pixel_work,
const wchar_t* device_name,
- float device_scale_factor) = 0;
+ float device_scale_factor,
+ DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY tech =
+ DISPLAYCONFIG_OUTPUT_TECHNOLOGY_OTHER) = 0;
virtual HWND CreateFakeHwnd(const gfx::Rect& bounds) = 0;
};
@@ -152,13 +154,15 @@ class TestScreenWinManager final : public TestScreenWinInitializer {
void AddMonitor(const gfx::Rect& pixel_bounds,
const gfx::Rect& pixel_work,
const wchar_t* device_name,
- float device_scale_factor) override {
+ float device_scale_factor,
+ DISPLAYCONFIG_VIDEO_OUTPUT_TECHNOLOGY tech =
+ DISPLAYCONFIG_OUTPUT_TECHNOLOGY_OTHER) override {
MONITORINFOEX monitor_info =
win::test::CreateMonitorInfo(pixel_bounds, pixel_work, device_name);
monitor_infos_.push_back(monitor_info);
display_infos_.push_back(DisplayInfo(monitor_info, device_scale_factor,
1.0f, Display::ROTATE_0, 60,
- gfx::Vector2dF()));
+ gfx::Vector2dF(), tech));
}
HWND CreateFakeHwnd(const gfx::Rect& bounds) override {
@@ -3493,5 +3497,34 @@ TEST_F(ScreenWinUninitializedForced2x, GetScaleFactorForHWND) {
EXPECT_EQ(2.0, ScreenWin::GetScaleFactorForHWND(nullptr));
}
+namespace {
+
+// Two Displays, one of which is internal (eg. a laptop screen).
+class ScreenWinTestTwoDisplaysOneInternal : public ScreenWinTest {
+ public:
+ ScreenWinTestTwoDisplaysOneInternal() = default;
+
+ void SetUpScreen(TestScreenWinInitializer* initializer) override {
+ initializer->AddMonitor(gfx::Rect(0, 0, 1920, 1200),
+ gfx::Rect(0, 0, 1920, 1100), L"primary", 1.0,
+ DISPLAYCONFIG_OUTPUT_TECHNOLOGY_INTERNAL);
+ initializer->AddMonitor(gfx::Rect(1920, 0, 800, 600),
+ gfx::Rect(1920, 0, 800, 600), L"secondary", 1.0);
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ScreenWinTestTwoDisplaysOneInternal);
+};
+
+} // namespace
+
+TEST_F(ScreenWinTestTwoDisplaysOneInternal, InternalDisplayIdSet) {
+ EXPECT_NE(Display::InternalDisplayId(), kInvalidDisplayId);
+ std::vector<Display> displays = GetScreen()->GetAllDisplays();
+ ASSERT_EQ(2u, displays.size());
+ EXPECT_EQ(Display::InternalDisplayId(), displays[0].id());
+ EXPECT_NE(Display::InternalDisplayId(), displays[1].id());
+}
+
} // namespace win
} // namespace display
diff --git a/chromium/ui/display/win/topmost_window_finder_win.cc b/chromium/ui/display/win/topmost_window_finder_win.cc
new file mode 100644
index 00000000000..a3cc87ae585
--- /dev/null
+++ b/chromium/ui/display/win/topmost_window_finder_win.cc
@@ -0,0 +1,83 @@
+// Copyright 2020 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 "ui/display/win/topmost_window_finder_win.h"
+
+#include "ui/display/win/screen_win.h"
+
+namespace display {
+namespace win {
+
+// static
+bool TopMostFinderWin::IsTopMostWindowAtPoint(HWND window,
+ const gfx::Point& screen_loc,
+ const std::set<HWND>& ignore) {
+ TopMostFinderWin finder(window, screen_loc, ignore);
+ return finder.is_top_most_;
+}
+
+bool TopMostFinderWin::ShouldStopIterating(HWND hwnd) {
+ if (hwnd == target_) {
+ // Window is topmost, stop iterating.
+ is_top_most_ = true;
+ return true;
+ }
+
+ if (!IsWindowVisible(hwnd)) {
+ // The window isn't visible, keep iterating.
+ return false;
+ }
+
+ RECT r;
+ if (!GetWindowRect(hwnd, &r) || !PtInRect(&r, screen_loc_.ToPOINT())) {
+ // The window doesn't contain the point, keep iterating.
+ return false;
+ }
+
+ LONG ex_styles = GetWindowLong(hwnd, GWL_EXSTYLE);
+ if (ex_styles & WS_EX_TRANSPARENT || ex_styles & WS_EX_LAYERED) {
+ // Mouse events fall through WS_EX_TRANSPARENT windows, so we ignore them.
+ //
+ // WS_EX_LAYERED is trickier. Apps like Switcher create a totally
+ // transparent WS_EX_LAYERED window that is always on top. If we don't
+ // ignore WS_EX_LAYERED windows and there are totally transparent
+ // WS_EX_LAYERED windows then there are effectively holes on the screen
+ // that the user can't reattach tabs to. So we ignore them. This is a bit
+ // problematic in so far as WS_EX_LAYERED windows need not be totally
+ // transparent in which case we treat chrome windows as not being obscured
+ // when they really are, but this is better than not being able to
+ // reattach tabs.
+ return false;
+ }
+
+ // hwnd is at the point. Make sure the point is within the windows region.
+ if (GetWindowRgn(hwnd, tmp_region_.get()) == ERROR) {
+ // There's no region on the window and the window contains the point. Stop
+ // iterating.
+ return true;
+ }
+
+ // The region is relative to the window's rect.
+ BOOL is_point_in_region = PtInRegion(
+ tmp_region_.get(), screen_loc_.x() - r.left, screen_loc_.y() - r.top);
+ tmp_region_.reset(CreateRectRgn(0, 0, 0, 0));
+ // Stop iterating if the region contains the point.
+ return !!is_point_in_region;
+}
+
+TopMostFinderWin::TopMostFinderWin(HWND window,
+ const gfx::Point& screen_loc,
+ const std::set<HWND>& ignore)
+ : BaseWindowFinderWin(ignore),
+ target_(window),
+ is_top_most_(false),
+ tmp_region_(CreateRectRgn(0, 0, 0, 0)) {
+ screen_loc_ = display::win::ScreenWin::DIPToScreenPoint(screen_loc);
+ EnumWindows(WindowCallbackProc, as_lparam());
+}
+
+TopMostFinderWin::~TopMostFinderWin() = default;
+
+} // namespace win
+} // namespace display \ No newline at end of file
diff --git a/chromium/ui/display/win/topmost_window_finder_win.h b/chromium/ui/display/win/topmost_window_finder_win.h
new file mode 100644
index 00000000000..95f32f6bb87
--- /dev/null
+++ b/chromium/ui/display/win/topmost_window_finder_win.h
@@ -0,0 +1,51 @@
+// Copyright 2020 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 UI_DISPLAY_WIN_TOPMOST_WINDOW_FINDER_WIN_H_
+#define UI_DISPLAY_WIN_TOPMOST_WINDOW_FINDER_WIN_H_
+
+#include "base/win/scoped_gdi_object.h"
+#include "ui/display/win/base_window_finder_win.h"
+#include "ui/gfx/geometry/point.h"
+
+namespace display {
+namespace win {
+
+// Helper class to determine if a particular point of a window is not obscured
+// by another window.
+class TopMostFinderWin : public BaseWindowFinderWin {
+ public:
+ // Returns true if |window| is the topmost window at the location
+ // |screen_loc|, not including the windows in |ignore|.
+ static bool IsTopMostWindowAtPoint(HWND window,
+ const gfx::Point& screen_loc,
+ const std::set<HWND>& ignore);
+
+ bool ShouldStopIterating(HWND hwnd) override;
+
+ private:
+ TopMostFinderWin(HWND window,
+ const gfx::Point& screen_loc,
+ const std::set<HWND>& ignore);
+ TopMostFinderWin(const TopMostFinderWin& finder) = delete;
+ TopMostFinderWin& operator=(const TopMostFinderWin& finder) = delete;
+ ~TopMostFinderWin() override;
+
+ // The window we're looking for.
+ HWND target_;
+
+ // Location of window to find in pixel coordinates.
+ gfx::Point screen_loc_;
+
+ // Is target_ the top most window? This is initially false but set to true
+ // in ShouldStopIterating if target_ is passed in.
+ bool is_top_most_;
+
+ base::win::ScopedRegion tmp_region_;
+};
+
+} // namespace win
+} // namespace display
+
+#endif // UI_DISPLAY_WIN_TOPMOST_WINDOW_FINDER_WIN_H_ \ No newline at end of file
diff --git a/chromium/ui/events/BUILD.gn b/chromium/ui/events/BUILD.gn
index 1a7e454ab14..14aa1413f80 100644
--- a/chromium/ui/events/BUILD.gn
+++ b/chromium/ui/events/BUILD.gn
@@ -166,6 +166,13 @@ jumbo_component("events_base") {
if (use_x11 || ozone_platform_x11) {
public_deps += [ "//ui/events/keycodes:x11" ]
+
+ # TODO(https://crbug.com/1076277): This dependency on //ui/gfx/x
+ # is unnecessary and should be removed. It is included for now
+ # to work around a bug in lld that introduces unnecessary
+ # nondeterminism in the DSO (see c#6 on the bug for an
+ # explanation).
+ deps += [ "//ui/gfx/x" ]
}
if (!is_ios) {
@@ -284,7 +291,6 @@ jumbo_component("events") {
if (use_x11 || ozone_platform_x11) {
public += [ "x/x11_event_translation.h" ]
sources += [ "x/x11_event_translation.cc" ]
- configs += [ "//build/config/linux:x11" ]
deps += [
"//ui/events/devices",
"//ui/events/devices/x11",
@@ -518,21 +524,6 @@ if (!is_ios) {
sources = [
"blink/blink_event_util_unittest.cc",
"blink/fling_booster_unittest.cc",
- "blink/input_handler_proxy_unittest.cc",
- "blink/input_scroll_elasticity_controller_unittest.cc",
- "blink/prediction/empty_filter_unittests.cc",
- "blink/prediction/filter_factory_unittests.cc",
- "blink/prediction/input_filter_unittest_helpers.cc",
- "blink/prediction/input_filter_unittest_helpers.h",
- "blink/prediction/input_predictor_unittest_helpers.cc",
- "blink/prediction/input_predictor_unittest_helpers.h",
- "blink/prediction/kalman_predictor_unittest.cc",
- "blink/prediction/least_squares_predictor_unittest.cc",
- "blink/prediction/linear_predictor_unittest.cc",
- "blink/prediction/linear_resampling_unittest.cc",
- "blink/prediction/one_euro_filter_unittests.cc",
- "blink/prediction/prediction_metrics_handler_unittest.cc",
- "blink/scroll_predictor_unittest.cc",
"blink/web_input_event_traits_unittest.cc",
"blink/web_input_event_unittest.cc",
"event_dispatcher_unittest.cc",
@@ -612,7 +603,6 @@ if (!is_ios) {
if (use_x11) {
sources += [ "devices/x11/device_data_manager_x11_unittest.cc" ]
- configs += [ "//build/config/linux:x11" ]
deps += [
"//ui/events/devices/x11",
"//ui/events/x:unittests",
diff --git a/chromium/ui/events/base_event_utils.cc b/chromium/ui/events/base_event_utils.cc
index 80719dcab51..3c7928ddb97 100644
--- a/chromium/ui/events/base_event_utils.cc
+++ b/chromium/ui/events/base_event_utils.cc
@@ -5,9 +5,9 @@
#include "ui/events/base_event_utils.h"
#include "base/atomic_sequence_num.h"
+#include "base/check_op.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
-#include "base/logging.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "ui/events/event_constants.h"
diff --git a/chromium/ui/events/blink/BUILD.gn b/chromium/ui/events/blink/BUILD.gn
index b4c7d5665ea..2ff0353b00c 100644
--- a/chromium/ui/events/blink/BUILD.gn
+++ b/chromium/ui/events/blink/BUILD.gn
@@ -20,48 +20,9 @@ jumbo_source_set("blink") {
sources = [
"blink_event_util.cc",
"blink_event_util.h",
- "compositor_thread_event_queue.cc",
- "compositor_thread_event_queue.h",
- "did_overscroll_params.cc",
"did_overscroll_params.h",
- "event_with_callback.cc",
- "event_with_callback.h",
"fling_booster.cc",
"fling_booster.h",
- "input_handler_proxy.cc",
- "input_handler_proxy.h",
- "input_handler_proxy_client.h",
- "input_scroll_elasticity_controller.cc",
- "input_scroll_elasticity_controller.h",
- "momentum_scroll_jank_tracker.cc",
- "momentum_scroll_jank_tracker.h",
- "prediction/empty_filter.cc",
- "prediction/empty_filter.h",
- "prediction/empty_predictor.cc",
- "prediction/empty_predictor.h",
- "prediction/filter_factory.cc",
- "prediction/filter_factory.h",
- "prediction/input_filter.h",
- "prediction/input_predictor.h",
- "prediction/kalman_filter.cc",
- "prediction/kalman_filter.h",
- "prediction/kalman_predictor.cc",
- "prediction/kalman_predictor.h",
- "prediction/least_squares_predictor.cc",
- "prediction/least_squares_predictor.h",
- "prediction/linear_predictor.cc",
- "prediction/linear_predictor.h",
- "prediction/linear_resampling.cc",
- "prediction/linear_resampling.h",
- "prediction/one_euro_filter.cc",
- "prediction/one_euro_filter.h",
- "prediction/prediction_metrics_handler.cc",
- "prediction/prediction_metrics_handler.h",
- "prediction/predictor_factory.cc",
- "prediction/predictor_factory.h",
- "scroll_predictor.cc",
- "scroll_predictor.h",
- "synchronous_input_handler_proxy.h",
"web_input_event.cc",
"web_input_event.h",
"web_input_event_traits.cc",
@@ -85,6 +46,10 @@ jumbo_source_set("blink") {
"//ui/latency",
]
+ if (use_x11) {
+ deps += [ "//ui/gfx/x" ]
+ }
+
if (is_win) {
sources += [
"web_input_event_builders_win.cc",
diff --git a/chromium/ui/events/blink/DEPS b/chromium/ui/events/blink/DEPS
index 7b0a4e8f955..b0e24303657 100644
--- a/chromium/ui/events/blink/DEPS
+++ b/chromium/ui/events/blink/DEPS
@@ -3,11 +3,11 @@ include_rules = [
"+cc/input/main_thread_scrolling_reason.h",
"+cc/input/overscroll_behavior.h",
"+cc/input/scroll_elasticity_helper.h",
- "+cc/input/scroll_input_type.h",
"+cc/input/snap_fling_controller.h",
"+cc/metrics/event_metrics.h",
"+cc/trees/swap_promise_monitor.h",
+ "+third_party/blink/public/common/features.h",
"+third_party/blink/public/common/input/web_gesture_device.h",
"+third_party/blink/public/common/input/web_gesture_event.h",
"+third_party/blink/public/common/input/web_input_event.h",
@@ -20,6 +20,7 @@ include_rules = [
"+ui/base",
"+ui/display/win",
+ "+ui/events/types/scroll_input_type.h",
"+ui/gfx",
"+ui/gfx/geometry",
diff --git a/chromium/ui/events/blink/blink_event_util.cc b/chromium/ui/events/blink/blink_event_util.cc
index e326bf76608..5f00c70ac67 100644
--- a/chromium/ui/events/blink/blink_event_util.cc
+++ b/chromium/ui/events/blink/blink_event_util.cc
@@ -39,27 +39,24 @@ using blink::WebPointerEvent;
using blink::WebPointerProperties;
using blink::WebTouchEvent;
using blink::WebTouchPoint;
-using std::numeric_limits;
namespace ui {
namespace {
-const int kInvalidTouchIndex = -1;
-
WebInputEvent::Type ToWebTouchEventType(MotionEvent::Action action) {
switch (action) {
case MotionEvent::Action::DOWN:
- return WebInputEvent::kTouchStart;
+ return WebInputEvent::Type::kTouchStart;
case MotionEvent::Action::MOVE:
- return WebInputEvent::kTouchMove;
+ return WebInputEvent::Type::kTouchMove;
case MotionEvent::Action::UP:
- return WebInputEvent::kTouchEnd;
+ return WebInputEvent::Type::kTouchEnd;
case MotionEvent::Action::CANCEL:
- return WebInputEvent::kTouchCancel;
+ return WebInputEvent::Type::kTouchCancel;
case MotionEvent::Action::POINTER_DOWN:
- return WebInputEvent::kTouchStart;
+ return WebInputEvent::Type::kTouchStart;
case MotionEvent::Action::POINTER_UP:
- return WebInputEvent::kTouchEnd;
+ return WebInputEvent::Type::kTouchEnd;
case MotionEvent::Action::NONE:
case MotionEvent::Action::HOVER_ENTER:
case MotionEvent::Action::HOVER_EXIT:
@@ -69,7 +66,7 @@ WebInputEvent::Type ToWebTouchEventType(MotionEvent::Action action) {
break;
}
NOTREACHED() << "Invalid MotionEvent::Action = " << action;
- return WebInputEvent::kUndefined;
+ return WebInputEvent::Type::kUndefined;
}
// Note that the action index is meaningful only in the context of
@@ -79,21 +76,21 @@ WebTouchPoint::State ToWebTouchPointState(const MotionEvent& event,
size_t pointer_index) {
switch (event.GetAction()) {
case MotionEvent::Action::DOWN:
- return WebTouchPoint::kStatePressed;
+ return WebTouchPoint::State::kStatePressed;
case MotionEvent::Action::MOVE:
- return WebTouchPoint::kStateMoved;
+ return WebTouchPoint::State::kStateMoved;
case MotionEvent::Action::UP:
- return WebTouchPoint::kStateReleased;
+ return WebTouchPoint::State::kStateReleased;
case MotionEvent::Action::CANCEL:
- return WebTouchPoint::kStateCancelled;
+ return WebTouchPoint::State::kStateCancelled;
case MotionEvent::Action::POINTER_DOWN:
return static_cast<int>(pointer_index) == event.GetActionIndex()
- ? WebTouchPoint::kStatePressed
- : WebTouchPoint::kStateStationary;
+ ? WebTouchPoint::State::kStatePressed
+ : WebTouchPoint::State::kStateStationary;
case MotionEvent::Action::POINTER_UP:
return static_cast<int>(pointer_index) == event.GetActionIndex()
- ? WebTouchPoint::kStateReleased
- : WebTouchPoint::kStateStationary;
+ ? WebTouchPoint::State::kStateReleased
+ : WebTouchPoint::State::kStateStationary;
case MotionEvent::Action::NONE:
case MotionEvent::Action::HOVER_ENTER:
case MotionEvent::Action::HOVER_EXIT:
@@ -103,7 +100,7 @@ WebTouchPoint::State ToWebTouchPointState(const MotionEvent& event,
break;
}
NOTREACHED() << "Invalid MotionEvent::Action.";
- return WebTouchPoint::kStateUndefined;
+ return WebTouchPoint::State::kStateUndefined;
}
WebPointerProperties::PointerType ToWebPointerType(
@@ -127,15 +124,15 @@ WebPointerProperties::PointerType ToWebPointerType(
WebPointerProperties::PointerType ToWebPointerType(
EventPointerType event_pointer_type) {
switch (event_pointer_type) {
- case EventPointerType::POINTER_TYPE_UNKNOWN:
+ case EventPointerType::kUnknown:
return WebPointerProperties::PointerType::kUnknown;
- case EventPointerType::POINTER_TYPE_MOUSE:
+ case EventPointerType::kMouse:
return WebPointerProperties::PointerType::kMouse;
- case EventPointerType::POINTER_TYPE_PEN:
+ case EventPointerType::kPen:
return WebPointerProperties::PointerType::kPen;
- case EventPointerType::POINTER_TYPE_TOUCH:
+ case EventPointerType::kTouch:
return WebPointerProperties::PointerType::kTouch;
- case EventPointerType::POINTER_TYPE_ERASER:
+ case EventPointerType::kEraser:
return WebPointerProperties::PointerType::kEraser;
default:
NOTREACHED() << "Invalid EventPointerType = "
@@ -229,409 +226,8 @@ WebTouchPoint CreateWebTouchPoint(const MotionEvent& event,
return touch;
}
-float GetUnacceleratedDelta(float accelerated_delta, float acceleration_ratio) {
- return accelerated_delta * acceleration_ratio;
-}
-
-float GetAccelerationRatio(float accelerated_delta, float unaccelerated_delta) {
- if (unaccelerated_delta == 0.f || accelerated_delta == 0.f)
- return 1.f;
- return unaccelerated_delta / accelerated_delta;
-}
-
-// Returns |kInvalidTouchIndex| iff |event| lacks a touch with an ID of |id|.
-int GetIndexOfTouchID(const WebTouchEvent& event, int id) {
- for (unsigned i = 0; i < event.touches_length; ++i) {
- if (event.touches[i].id == id)
- return i;
- }
- return kInvalidTouchIndex;
-}
-
-WebInputEvent::DispatchType MergeDispatchTypes(
- WebInputEvent::DispatchType type_1,
- WebInputEvent::DispatchType type_2) {
- static_assert(WebInputEvent::DispatchType::kBlocking <
- WebInputEvent::DispatchType::kEventNonBlocking,
- "Enum not ordered correctly");
- static_assert(WebInputEvent::DispatchType::kEventNonBlocking <
- WebInputEvent::DispatchType::kListenersNonBlockingPassive,
- "Enum not ordered correctly");
- static_assert(
- WebInputEvent::DispatchType::kListenersNonBlockingPassive <
- WebInputEvent::DispatchType::kListenersForcedNonBlockingDueToFling,
- "Enum not ordered correctly");
- return static_cast<WebInputEvent::DispatchType>(
- std::min(static_cast<int>(type_1), static_cast<int>(type_2)));
-}
-
-bool CanCoalesce(const WebPointerEvent& event_to_coalesce,
- const WebPointerEvent& event) {
- return (event.GetType() == WebInputEvent::kPointerMove ||
- event.GetType() == WebInputEvent::kPointerRawUpdate) &&
- event.GetType() == event_to_coalesce.GetType() &&
- event.GetModifiers() == event_to_coalesce.GetModifiers() &&
- event.id == event_to_coalesce.id &&
- event.pointer_type == event_to_coalesce.pointer_type;
-}
-
-void Coalesce(const WebPointerEvent& event_to_coalesce,
- WebPointerEvent* event) {
- DCHECK(CanCoalesce(event_to_coalesce, *event));
- // Accumulate movement deltas.
- int x = event->movement_x;
- int y = event->movement_y;
- *event = event_to_coalesce;
- event->movement_x += x;
- event->movement_y += y;
-}
-
-bool CanCoalesce(const WebMouseEvent& event_to_coalesce,
- const WebMouseEvent& event) {
- // Since we start supporting the stylus input and they are constructed as
- // mouse events or touch events, we should check the ID and pointer type when
- // coalescing mouse events.
- return event.GetType() == WebInputEvent::kMouseMove &&
- event.GetType() == event_to_coalesce.GetType() &&
- event.GetModifiers() == event_to_coalesce.GetModifiers() &&
- event.id == event_to_coalesce.id &&
- event.pointer_type == event_to_coalesce.pointer_type;
-}
-
-void Coalesce(const WebMouseEvent& event_to_coalesce, WebMouseEvent* event) {
- DCHECK(CanCoalesce(event_to_coalesce, *event));
- // Accumulate movement deltas.
- int x = event->movement_x;
- int y = event->movement_y;
- *event = event_to_coalesce;
- event->movement_x += x;
- event->movement_y += y;
-}
-
-bool HaveConsistentPhase(const WebMouseWheelEvent& event_to_coalesce,
- const WebMouseWheelEvent& event) {
- if (event.has_synthetic_phase != event_to_coalesce.has_synthetic_phase)
- return false;
-
- if (event.phase == event_to_coalesce.phase &&
- event.momentum_phase == event_to_coalesce.momentum_phase) {
- return true;
- }
-
- if (event.has_synthetic_phase) {
- // It is alright to coalesce a wheel event with synthetic phaseChanged to
- // its previous one with synthetic phaseBegan.
- return (event.phase == WebMouseWheelEvent::kPhaseBegan &&
- event_to_coalesce.phase == WebMouseWheelEvent::kPhaseChanged);
- }
- return false;
-}
-
-bool CanCoalesce(const WebMouseWheelEvent& event_to_coalesce,
- const WebMouseWheelEvent& event) {
- return event.GetModifiers() == event_to_coalesce.GetModifiers() &&
- event.delta_units == event_to_coalesce.delta_units &&
- HaveConsistentPhase(event_to_coalesce, event);
-}
-
-void Coalesce(const WebMouseWheelEvent& event_to_coalesce,
- WebMouseWheelEvent* event) {
- DCHECK(CanCoalesce(event_to_coalesce, *event));
- float unaccelerated_x =
- GetUnacceleratedDelta(event->delta_x, event->acceleration_ratio_x) +
- GetUnacceleratedDelta(event_to_coalesce.delta_x,
- event_to_coalesce.acceleration_ratio_x);
- float unaccelerated_y =
- GetUnacceleratedDelta(event->delta_y, event->acceleration_ratio_y) +
- GetUnacceleratedDelta(event_to_coalesce.delta_y,
- event_to_coalesce.acceleration_ratio_y);
- float old_deltaX = event->delta_x;
- float old_deltaY = event->delta_y;
- float old_wheelTicksX = event->wheel_ticks_x;
- float old_wheelTicksY = event->wheel_ticks_y;
- float old_movementX = event->movement_x;
- float old_movementY = event->movement_y;
- WebMouseWheelEvent::Phase old_phase = event->phase;
- WebInputEvent::DispatchType old_dispatch_type = event->dispatch_type;
- *event = event_to_coalesce;
- event->delta_x += old_deltaX;
- event->delta_y += old_deltaY;
- event->wheel_ticks_x += old_wheelTicksX;
- event->wheel_ticks_y += old_wheelTicksY;
- event->movement_x += old_movementX;
- event->movement_y += old_movementY;
- event->acceleration_ratio_x =
- GetAccelerationRatio(event->delta_x, unaccelerated_x);
- event->acceleration_ratio_y =
- GetAccelerationRatio(event->delta_y, unaccelerated_y);
- event->dispatch_type =
- MergeDispatchTypes(old_dispatch_type, event_to_coalesce.dispatch_type);
- if (event_to_coalesce.has_synthetic_phase &&
- event_to_coalesce.phase != old_phase) {
- // Coalesce a wheel event with synthetic phase changed to a wheel event
- // with synthetic phase began.
- DCHECK_EQ(WebMouseWheelEvent::kPhaseChanged, event_to_coalesce.phase);
- DCHECK_EQ(WebMouseWheelEvent::kPhaseBegan, old_phase);
- event->phase = WebMouseWheelEvent::kPhaseBegan;
- }
-}
-
-bool CanCoalesce(const WebTouchEvent& event_to_coalesce,
- const WebTouchEvent& event) {
- if (event.GetType() != event_to_coalesce.GetType() ||
- event.GetType() != WebInputEvent::kTouchMove ||
- event.GetModifiers() != event_to_coalesce.GetModifiers() ||
- event.touches_length != event_to_coalesce.touches_length ||
- event.touches_length > WebTouchEvent::kTouchesLengthCap)
- return false;
-
- static_assert(WebTouchEvent::kTouchesLengthCap <= sizeof(int32_t) * 8U,
- "suboptimal kTouchesLengthCap size");
- // Ensure that we have a 1-to-1 mapping of pointer ids between touches.
- std::bitset<WebTouchEvent::kTouchesLengthCap> unmatched_event_touches(
- (1 << event.touches_length) - 1);
- for (unsigned i = 0; i < event_to_coalesce.touches_length; ++i) {
- int event_touch_index =
- GetIndexOfTouchID(event, event_to_coalesce.touches[i].id);
- if (event_touch_index == kInvalidTouchIndex)
- return false;
- if (!unmatched_event_touches[event_touch_index])
- return false;
- if (event.touches[event_touch_index].pointer_type !=
- event_to_coalesce.touches[i].pointer_type)
- return false;
- unmatched_event_touches[event_touch_index] = false;
- }
- return unmatched_event_touches.none();
-}
-
-void Coalesce(const WebTouchEvent& event_to_coalesce, WebTouchEvent* event) {
- DCHECK(CanCoalesce(event_to_coalesce, *event));
- // The WebTouchPoints include absolute position information. So it is
- // sufficient to simply replace the previous event with the new event->
- // However, it is necessary to make sure that all the points have the
- // correct state, i.e. the touch-points that moved in the last event, but
- // didn't change in the current event, will have Stationary state. It is
- // necessary to change them back to Moved state.
- WebTouchEvent old_event = *event;
- *event = event_to_coalesce;
- for (unsigned i = 0; i < event->touches_length; ++i) {
- int i_old = GetIndexOfTouchID(old_event, event->touches[i].id);
- if (old_event.touches[i_old].state == blink::WebTouchPoint::kStateMoved) {
- event->touches[i].state = blink::WebTouchPoint::kStateMoved;
- event->touches[i].movement_x += old_event.touches[i_old].movement_x;
- event->touches[i].movement_y += old_event.touches[i_old].movement_y;
- }
- }
- event->moved_beyond_slop_region |= old_event.moved_beyond_slop_region;
- event->dispatch_type = MergeDispatchTypes(old_event.dispatch_type,
- event_to_coalesce.dispatch_type);
- event->unique_touch_event_id = old_event.unique_touch_event_id;
-}
-
-bool CanCoalesce(const WebGestureEvent& event_to_coalesce,
- const WebGestureEvent& event) {
- if (event.GetType() != event_to_coalesce.GetType() ||
- event.SourceDevice() != event_to_coalesce.SourceDevice() ||
- event.GetModifiers() != event_to_coalesce.GetModifiers())
- return false;
-
- if (event.GetType() == WebInputEvent::kGestureScrollUpdate)
- return true;
-
- // GesturePinchUpdate scales can be combined only if they share a focal point,
- // e.g., with double-tap drag zoom.
- // Due to the imprecision of OOPIF coordinate conversions, the positions may
- // not be exactly equal, so we only require approximate equality.
- constexpr float kAnchorTolerance = 1.f;
- if (event.GetType() == WebInputEvent::kGesturePinchUpdate &&
- (std::abs(event.PositionInWidget().x() -
- event_to_coalesce.PositionInWidget().x()) < kAnchorTolerance) &&
- (std::abs(event.PositionInWidget().y() -
- event_to_coalesce.PositionInWidget().y()) < kAnchorTolerance)) {
- return true;
- }
-
- return false;
-}
-
-void Coalesce(const WebGestureEvent& event_to_coalesce,
- WebGestureEvent* event) {
- DCHECK(CanCoalesce(event_to_coalesce, *event));
- if (event->GetType() == WebInputEvent::kGestureScrollUpdate) {
- event->data.scroll_update.delta_x +=
- event_to_coalesce.data.scroll_update.delta_x;
- event->data.scroll_update.delta_y +=
- event_to_coalesce.data.scroll_update.delta_y;
- } else if (event->GetType() == WebInputEvent::kGesturePinchUpdate) {
- event->data.pinch_update.scale *= event_to_coalesce.data.pinch_update.scale;
- // Ensure the scale remains bounded above 0 and below Infinity so that
- // we can reliably perform operations like log on the values.
- if (event->data.pinch_update.scale < numeric_limits<float>::min())
- event->data.pinch_update.scale = numeric_limits<float>::min();
- else if (event->data.pinch_update.scale > numeric_limits<float>::max())
- event->data.pinch_update.scale = numeric_limits<float>::max();
- }
-}
-
-// Returns the transform matrix corresponding to the gesture event.
-gfx::Transform GetTransformForEvent(const WebGestureEvent& gesture_event) {
- gfx::Transform gesture_transform;
- if (gesture_event.GetType() == WebInputEvent::kGestureScrollUpdate) {
- gesture_transform.Translate(gesture_event.data.scroll_update.delta_x,
- gesture_event.data.scroll_update.delta_y);
- } else if (gesture_event.GetType() == WebInputEvent::kGesturePinchUpdate) {
- float scale = gesture_event.data.pinch_update.scale;
- gesture_transform.Translate(-gesture_event.PositionInWidget().x(),
- -gesture_event.PositionInWidget().y());
- gesture_transform.Scale(scale, scale);
- gesture_transform.Translate(gesture_event.PositionInWidget().x(),
- gesture_event.PositionInWidget().y());
- } else {
- NOTREACHED() << "Invalid event type for transform retrieval: "
- << WebInputEvent::GetName(gesture_event.GetType());
- }
- return gesture_transform;
-}
-
} // namespace
-bool CanCoalesce(const blink::WebInputEvent& event_to_coalesce,
- const blink::WebInputEvent& event) {
- if (blink::WebInputEvent::IsPointerEventType(event_to_coalesce.GetType()) &&
- blink::WebInputEvent::IsPointerEventType(event.GetType())) {
- return CanCoalesce(
- static_cast<const blink::WebPointerEvent&>(event_to_coalesce),
- static_cast<const blink::WebPointerEvent&>(event));
- }
- if (blink::WebInputEvent::IsGestureEventType(event_to_coalesce.GetType()) &&
- blink::WebInputEvent::IsGestureEventType(event.GetType())) {
- return CanCoalesce(
- static_cast<const blink::WebGestureEvent&>(event_to_coalesce),
- static_cast<const blink::WebGestureEvent&>(event));
- }
- if (blink::WebInputEvent::IsMouseEventType(event_to_coalesce.GetType()) &&
- blink::WebInputEvent::IsMouseEventType(event.GetType())) {
- return CanCoalesce(
- static_cast<const blink::WebMouseEvent&>(event_to_coalesce),
- static_cast<const blink::WebMouseEvent&>(event));
- }
- if (blink::WebInputEvent::IsTouchEventType(event_to_coalesce.GetType()) &&
- blink::WebInputEvent::IsTouchEventType(event.GetType())) {
- return CanCoalesce(
- static_cast<const blink::WebTouchEvent&>(event_to_coalesce),
- static_cast<const blink::WebTouchEvent&>(event));
- }
- if (event_to_coalesce.GetType() == blink::WebInputEvent::kMouseWheel &&
- event.GetType() == blink::WebInputEvent::kMouseWheel) {
- return CanCoalesce(
- static_cast<const blink::WebMouseWheelEvent&>(event_to_coalesce),
- static_cast<const blink::WebMouseWheelEvent&>(event));
- }
- return false;
-}
-
-void Coalesce(const blink::WebInputEvent& event_to_coalesce,
- blink::WebInputEvent* event) {
- if (blink::WebInputEvent::IsPointerEventType(event_to_coalesce.GetType()) &&
- blink::WebInputEvent::IsPointerEventType(event->GetType())) {
- Coalesce(static_cast<const blink::WebPointerEvent&>(event_to_coalesce),
- static_cast<blink::WebPointerEvent*>(event));
- return;
- }
- if (blink::WebInputEvent::IsGestureEventType(event_to_coalesce.GetType()) &&
- blink::WebInputEvent::IsGestureEventType(event->GetType())) {
- Coalesce(static_cast<const blink::WebGestureEvent&>(event_to_coalesce),
- static_cast<blink::WebGestureEvent*>(event));
- return;
- }
- if (blink::WebInputEvent::IsMouseEventType(event_to_coalesce.GetType()) &&
- blink::WebInputEvent::IsMouseEventType(event->GetType())) {
- Coalesce(static_cast<const blink::WebMouseEvent&>(event_to_coalesce),
- static_cast<blink::WebMouseEvent*>(event));
- return;
- }
- if (blink::WebInputEvent::IsTouchEventType(event_to_coalesce.GetType()) &&
- blink::WebInputEvent::IsTouchEventType(event->GetType())) {
- Coalesce(static_cast<const blink::WebTouchEvent&>(event_to_coalesce),
- static_cast<blink::WebTouchEvent*>(event));
- return;
- }
- if (event_to_coalesce.GetType() == blink::WebInputEvent::kMouseWheel &&
- event->GetType() == blink::WebInputEvent::kMouseWheel) {
- Coalesce(static_cast<const blink::WebMouseWheelEvent&>(event_to_coalesce),
- static_cast<blink::WebMouseWheelEvent*>(event));
- }
-}
-
-// Whether |event_in_queue| is a touchscreen GesturePinchUpdate or
-// GestureScrollUpdate and has the same modifiers/source as the new
-// scroll/pinch event. Compatible touchscreen scroll and pinch event pairs
-// can be logically coalesced.
-bool IsCompatibleScrollorPinch(const WebGestureEvent& new_event,
- const WebGestureEvent& event_in_queue) {
- DCHECK(new_event.GetType() == WebInputEvent::kGestureScrollUpdate ||
- new_event.GetType() == WebInputEvent::kGesturePinchUpdate)
- << "Invalid event type for pinch/scroll coalescing: "
- << WebInputEvent::GetName(new_event.GetType());
- DLOG_IF(WARNING, new_event.TimeStamp() < event_in_queue.TimeStamp())
- << "Event time not monotonic?\n";
- return (event_in_queue.GetType() == WebInputEvent::kGestureScrollUpdate ||
- event_in_queue.GetType() == WebInputEvent::kGesturePinchUpdate) &&
- event_in_queue.GetModifiers() == new_event.GetModifiers() &&
- event_in_queue.SourceDevice() == WebGestureDevice::kTouchscreen &&
- new_event.SourceDevice() == WebGestureDevice::kTouchscreen;
-}
-
-std::pair<WebGestureEvent, WebGestureEvent> CoalesceScrollAndPinch(
- const WebGestureEvent* second_last_event,
- const WebGestureEvent& last_event,
- const WebGestureEvent& new_event) {
- DCHECK(!CanCoalesce(new_event, last_event))
- << "New event can't be coalesced with the last event in queue directly.";
- DCHECK(IsContinuousGestureEvent(new_event.GetType()));
- DCHECK(IsCompatibleScrollorPinch(new_event, last_event));
- DCHECK(!second_last_event ||
- IsCompatibleScrollorPinch(new_event, *second_last_event));
-
- WebGestureEvent scroll_event(WebInputEvent::kGestureScrollUpdate,
- new_event.GetModifiers(), new_event.TimeStamp(),
- new_event.SourceDevice());
- WebGestureEvent pinch_event;
- scroll_event.primary_pointer_type = new_event.primary_pointer_type;
- pinch_event = scroll_event;
- pinch_event.SetType(WebInputEvent::kGesturePinchUpdate);
- pinch_event.SetPositionInWidget(new_event.GetType() ==
- WebInputEvent::kGesturePinchUpdate
- ? new_event.PositionInWidget()
- : last_event.PositionInWidget());
-
- gfx::Transform combined_scroll_pinch = GetTransformForEvent(last_event);
- if (second_last_event) {
- combined_scroll_pinch.PreconcatTransform(
- GetTransformForEvent(*second_last_event));
- }
- combined_scroll_pinch.ConcatTransform(GetTransformForEvent(new_event));
-
- float combined_scale =
- SkScalarToFloat(combined_scroll_pinch.matrix().get(0, 0));
- float combined_scroll_pinch_x =
- SkScalarToFloat(combined_scroll_pinch.matrix().get(0, 3));
- float combined_scroll_pinch_y =
- SkScalarToFloat(combined_scroll_pinch.matrix().get(1, 3));
- scroll_event.data.scroll_update.delta_x =
- (combined_scroll_pinch_x + pinch_event.PositionInWidget().x()) /
- combined_scale -
- pinch_event.PositionInWidget().x();
- scroll_event.data.scroll_update.delta_y =
- (combined_scroll_pinch_y + pinch_event.PositionInWidget().y()) /
- combined_scale -
- pinch_event.PositionInWidget().y();
- pinch_event.data.pinch_update.scale = combined_scale;
-
- return std::make_pair(scroll_event, pinch_event);
-}
-
blink::WebTouchEvent CreateWebTouchEventFromMotionEvent(
const MotionEvent& event,
bool moved_beyond_slop_region,
@@ -643,9 +239,9 @@ blink::WebTouchEvent CreateWebTouchEventFromMotionEvent(
blink::WebTouchEvent result(ToWebTouchEventType(event.GetAction()),
EventFlagsToWebEventModifiers(event.GetFlags()),
event.GetEventTime());
- result.dispatch_type = result.GetType() == WebInputEvent::kTouchCancel
- ? WebInputEvent::kEventNonBlocking
- : WebInputEvent::kBlocking;
+ result.dispatch_type = result.GetType() == WebInputEvent::Type::kTouchCancel
+ ? WebInputEvent::DispatchType::kEventNonBlocking
+ : WebInputEvent::DispatchType::kBlocking;
result.moved_beyond_slop_region = moved_beyond_slop_region;
result.hovering = hovering;
@@ -720,7 +316,7 @@ WebGestureEvent CreateWebGestureEvent(const GestureEventDetails& details,
NOTREACHED() << "Unknown device type is not allowed";
break;
}
- WebGestureEvent gesture(WebInputEvent::kUndefined,
+ WebGestureEvent gesture(WebInputEvent::Type::kUndefined,
EventFlagsToWebEventModifiers(flags), timestamp,
source_device);
@@ -735,99 +331,123 @@ WebGestureEvent CreateWebGestureEvent(const GestureEventDetails& details,
switch (details.type()) {
case ET_GESTURE_SHOW_PRESS:
- gesture.SetType(WebInputEvent::kGestureShowPress);
- gesture.data.show_press.width = details.bounding_box_f().width();
- gesture.data.show_press.height = details.bounding_box_f().height();
+ gesture.SetType(WebInputEvent::Type::kGestureShowPress);
+ gesture.data.show_press.width =
+ IfNanUseMaxFloat(details.bounding_box_f().width());
+ gesture.data.show_press.height =
+ IfNanUseMaxFloat(details.bounding_box_f().height());
break;
case ET_GESTURE_DOUBLE_TAP:
- gesture.SetType(WebInputEvent::kGestureDoubleTap);
+ gesture.SetType(WebInputEvent::Type::kGestureDoubleTap);
DCHECK_EQ(1, details.tap_count());
gesture.data.tap.tap_count = details.tap_count();
- gesture.data.tap.width = details.bounding_box_f().width();
- gesture.data.tap.height = details.bounding_box_f().height();
+ gesture.data.tap.width =
+ IfNanUseMaxFloat(details.bounding_box_f().width());
+ gesture.data.tap.height =
+ IfNanUseMaxFloat(details.bounding_box_f().height());
gesture.SetNeedsWheelEvent(source_device == WebGestureDevice::kTouchpad);
break;
case ET_GESTURE_TAP:
- gesture.SetType(WebInputEvent::kGestureTap);
+ gesture.SetType(WebInputEvent::Type::kGestureTap);
DCHECK_GE(details.tap_count(), 1);
gesture.data.tap.tap_count = details.tap_count();
- gesture.data.tap.width = details.bounding_box_f().width();
- gesture.data.tap.height = details.bounding_box_f().height();
+ gesture.data.tap.width =
+ IfNanUseMaxFloat(details.bounding_box_f().width());
+ gesture.data.tap.height =
+ IfNanUseMaxFloat(details.bounding_box_f().height());
break;
case ET_GESTURE_TAP_UNCONFIRMED:
- gesture.SetType(WebInputEvent::kGestureTapUnconfirmed);
+ gesture.SetType(WebInputEvent::Type::kGestureTapUnconfirmed);
DCHECK_EQ(1, details.tap_count());
gesture.data.tap.tap_count = details.tap_count();
- gesture.data.tap.width = details.bounding_box_f().width();
- gesture.data.tap.height = details.bounding_box_f().height();
+ gesture.data.tap.width =
+ IfNanUseMaxFloat(details.bounding_box_f().width());
+ gesture.data.tap.height =
+ IfNanUseMaxFloat(details.bounding_box_f().height());
break;
case ET_GESTURE_LONG_PRESS:
- gesture.SetType(WebInputEvent::kGestureLongPress);
- gesture.data.long_press.width = details.bounding_box_f().width();
- gesture.data.long_press.height = details.bounding_box_f().height();
+ gesture.SetType(WebInputEvent::Type::kGestureLongPress);
+ gesture.data.long_press.width =
+ IfNanUseMaxFloat(details.bounding_box_f().width());
+ gesture.data.long_press.height =
+ IfNanUseMaxFloat(details.bounding_box_f().height());
break;
case ET_GESTURE_LONG_TAP:
- gesture.SetType(WebInputEvent::kGestureLongTap);
- gesture.data.long_press.width = details.bounding_box_f().width();
- gesture.data.long_press.height = details.bounding_box_f().height();
+ gesture.SetType(WebInputEvent::Type::kGestureLongTap);
+ gesture.data.long_press.width =
+ IfNanUseMaxFloat(details.bounding_box_f().width());
+ gesture.data.long_press.height =
+ IfNanUseMaxFloat(details.bounding_box_f().height());
break;
case ET_GESTURE_TWO_FINGER_TAP:
- gesture.SetType(blink::WebInputEvent::kGestureTwoFingerTap);
+ gesture.SetType(blink::WebInputEvent::Type::kGestureTwoFingerTap);
gesture.data.two_finger_tap.first_finger_width =
- details.first_finger_width();
+ IfNanUseMaxFloat(details.first_finger_width());
gesture.data.two_finger_tap.first_finger_height =
- details.first_finger_height();
+ IfNanUseMaxFloat(details.first_finger_height());
break;
case ET_GESTURE_SCROLL_BEGIN:
- gesture.SetType(WebInputEvent::kGestureScrollBegin);
+ gesture.SetType(WebInputEvent::Type::kGestureScrollBegin);
gesture.data.scroll_begin.pointer_count = details.touch_points();
- gesture.data.scroll_begin.delta_x_hint = details.scroll_x_hint();
- gesture.data.scroll_begin.delta_y_hint = details.scroll_y_hint();
+ gesture.data.scroll_begin.delta_x_hint =
+ IfNanUseMaxFloat(details.scroll_x_hint());
+ gesture.data.scroll_begin.delta_y_hint =
+ IfNanUseMaxFloat(details.scroll_y_hint());
gesture.data.scroll_begin.delta_hint_units = details.scroll_begin_units();
+ gesture.data.scroll_begin.inertial_phase =
+ WebGestureEvent::InertialPhaseState::kNonMomentum;
break;
case ET_GESTURE_SCROLL_UPDATE:
- gesture.SetType(WebInputEvent::kGestureScrollUpdate);
- gesture.data.scroll_update.delta_x = details.scroll_x();
- gesture.data.scroll_update.delta_y = details.scroll_y();
+ gesture.SetType(WebInputEvent::Type::kGestureScrollUpdate);
+ gesture.data.scroll_update.delta_x = IfNanUseMaxFloat(details.scroll_x());
+ gesture.data.scroll_update.delta_y = IfNanUseMaxFloat(details.scroll_y());
gesture.data.scroll_update.delta_units = details.scroll_update_units();
+ gesture.data.scroll_update.inertial_phase =
+ WebGestureEvent::InertialPhaseState::kNonMomentum;
break;
case ET_GESTURE_SCROLL_END:
- gesture.SetType(WebInputEvent::kGestureScrollEnd);
+ gesture.SetType(WebInputEvent::Type::kGestureScrollEnd);
+ gesture.data.scroll_end.inertial_phase =
+ WebGestureEvent::InertialPhaseState::kNonMomentum;
break;
case ET_SCROLL_FLING_START:
- gesture.SetType(WebInputEvent::kGestureFlingStart);
- gesture.data.fling_start.velocity_x = details.velocity_x();
- gesture.data.fling_start.velocity_y = details.velocity_y();
+ gesture.SetType(WebInputEvent::Type::kGestureFlingStart);
+ gesture.data.fling_start.velocity_x =
+ IfNanUseMaxFloat(details.velocity_x());
+ gesture.data.fling_start.velocity_y =
+ IfNanUseMaxFloat(details.velocity_y());
break;
case ET_SCROLL_FLING_CANCEL:
- gesture.SetType(WebInputEvent::kGestureFlingCancel);
+ gesture.SetType(WebInputEvent::Type::kGestureFlingCancel);
break;
case ET_GESTURE_PINCH_BEGIN:
- gesture.SetType(WebInputEvent::kGesturePinchBegin);
+ gesture.SetType(WebInputEvent::Type::kGesturePinchBegin);
gesture.SetNeedsWheelEvent(source_device == WebGestureDevice::kTouchpad);
break;
case ET_GESTURE_PINCH_UPDATE:
- gesture.SetType(WebInputEvent::kGesturePinchUpdate);
+ gesture.SetType(WebInputEvent::Type::kGesturePinchUpdate);
gesture.data.pinch_update.scale = details.scale();
gesture.SetNeedsWheelEvent(source_device == WebGestureDevice::kTouchpad);
break;
case ET_GESTURE_PINCH_END:
- gesture.SetType(WebInputEvent::kGesturePinchEnd);
+ gesture.SetType(WebInputEvent::Type::kGesturePinchEnd);
gesture.SetNeedsWheelEvent(source_device == WebGestureDevice::kTouchpad);
break;
case ET_GESTURE_TAP_CANCEL:
- gesture.SetType(WebInputEvent::kGestureTapCancel);
+ gesture.SetType(WebInputEvent::Type::kGestureTapCancel);
break;
case ET_GESTURE_TAP_DOWN:
- gesture.SetType(WebInputEvent::kGestureTapDown);
- gesture.data.tap_down.width = details.bounding_box_f().width();
- gesture.data.tap_down.height = details.bounding_box_f().height();
+ gesture.SetType(WebInputEvent::Type::kGestureTapDown);
+ gesture.data.tap_down.width =
+ IfNanUseMaxFloat(details.bounding_box_f().width());
+ gesture.data.tap_down.height =
+ IfNanUseMaxFloat(details.bounding_box_f().height());
break;
case ET_GESTURE_BEGIN:
case ET_GESTURE_END:
case ET_GESTURE_SWIPE:
// The caller is responsible for discarding these gestures appropriately.
- gesture.SetType(WebInputEvent::kUndefined);
+ gesture.SetType(WebInputEvent::Type::kUndefined);
break;
default:
NOTREACHED() << "EventType provided wasn't a valid gesture event: "
@@ -837,6 +457,12 @@ WebGestureEvent CreateWebGestureEvent(const GestureEventDetails& details,
return gesture;
}
+float IfNanUseMaxFloat(float value) {
+ if (std::isnan(value))
+ return std::numeric_limits<float>::max();
+ return value;
+}
+
WebGestureEvent CreateWebGestureEventFromGestureEventData(
const GestureEventData& data) {
return CreateWebGestureEvent(data.details, data.time,
@@ -858,7 +484,7 @@ std::unique_ptr<blink::WebInputEvent> TranslateAndScaleWebInputEvent(
std::unique_ptr<blink::WebInputEvent> scaled_event;
if (scale == 1.f && delta.IsZero())
return scaled_event;
- if (event.GetType() == blink::WebMouseEvent::kMouseWheel) {
+ if (event.GetType() == blink::WebMouseEvent::Type::kMouseWheel) {
blink::WebMouseWheelEvent* wheel_event = new blink::WebMouseWheelEvent;
scaled_event.reset(wheel_event);
*wheel_event = static_cast<const blink::WebMouseWheelEvent&>(event);
@@ -904,7 +530,7 @@ std::unique_ptr<blink::WebInputEvent> TranslateAndScaleWebInputEvent(
(gesture_event->PositionInWidget().x() + delta.x()) * scale,
(gesture_event->PositionInWidget().y() + delta.y()) * scale));
switch (gesture_event->GetType()) {
- case blink::WebInputEvent::kGestureScrollUpdate:
+ case blink::WebInputEvent::Type::kGestureScrollUpdate:
if (gesture_event->data.scroll_update.delta_units ==
ui::ScrollGranularity::kScrollByPixel ||
gesture_event->data.scroll_update.delta_units ==
@@ -913,7 +539,7 @@ std::unique_ptr<blink::WebInputEvent> TranslateAndScaleWebInputEvent(
gesture_event->data.scroll_update.delta_y *= scale;
}
break;
- case blink::WebInputEvent::kGestureScrollBegin:
+ case blink::WebInputEvent::Type::kGestureScrollBegin:
if (gesture_event->data.scroll_begin.delta_hint_units ==
ui::ScrollGranularity::kScrollByPixel ||
gesture_event->data.scroll_begin.delta_hint_units ==
@@ -923,49 +549,49 @@ std::unique_ptr<blink::WebInputEvent> TranslateAndScaleWebInputEvent(
}
break;
- case blink::WebInputEvent::kGesturePinchUpdate:
+ case blink::WebInputEvent::Type::kGesturePinchUpdate:
// Scale in pinch gesture is DSF agnostic.
break;
- case blink::WebInputEvent::kGestureDoubleTap:
- case blink::WebInputEvent::kGestureTap:
- case blink::WebInputEvent::kGestureTapUnconfirmed:
+ case blink::WebInputEvent::Type::kGestureDoubleTap:
+ case blink::WebInputEvent::Type::kGestureTap:
+ case blink::WebInputEvent::Type::kGestureTapUnconfirmed:
gesture_event->data.tap.width *= scale;
gesture_event->data.tap.height *= scale;
break;
- case blink::WebInputEvent::kGestureTapDown:
+ case blink::WebInputEvent::Type::kGestureTapDown:
gesture_event->data.tap_down.width *= scale;
gesture_event->data.tap_down.height *= scale;
break;
- case blink::WebInputEvent::kGestureShowPress:
+ case blink::WebInputEvent::Type::kGestureShowPress:
gesture_event->data.show_press.width *= scale;
gesture_event->data.show_press.height *= scale;
break;
- case blink::WebInputEvent::kGestureLongPress:
- case blink::WebInputEvent::kGestureLongTap:
+ case blink::WebInputEvent::Type::kGestureLongPress:
+ case blink::WebInputEvent::Type::kGestureLongTap:
gesture_event->data.long_press.width *= scale;
gesture_event->data.long_press.height *= scale;
break;
- case blink::WebInputEvent::kGestureTwoFingerTap:
+ case blink::WebInputEvent::Type::kGestureTwoFingerTap:
gesture_event->data.two_finger_tap.first_finger_width *= scale;
gesture_event->data.two_finger_tap.first_finger_height *= scale;
break;
- case blink::WebInputEvent::kGestureFlingStart:
+ case blink::WebInputEvent::Type::kGestureFlingStart:
gesture_event->data.fling_start.velocity_x *= scale;
gesture_event->data.fling_start.velocity_y *= scale;
break;
// These event does not have location data.
- case blink::WebInputEvent::kGesturePinchBegin:
- case blink::WebInputEvent::kGesturePinchEnd:
- case blink::WebInputEvent::kGestureTapCancel:
- case blink::WebInputEvent::kGestureFlingCancel:
- case blink::WebInputEvent::kGestureScrollEnd:
+ case blink::WebInputEvent::Type::kGesturePinchBegin:
+ case blink::WebInputEvent::Type::kGesturePinchEnd:
+ case blink::WebInputEvent::Type::kGestureTapCancel:
+ case blink::WebInputEvent::Type::kGestureFlingCancel:
+ case blink::WebInputEvent::Type::kGestureScrollEnd:
break;
// TODO(oshima): Find out if ContextMenu needs to be scaled.
@@ -980,17 +606,17 @@ WebInputEvent::Type ToWebMouseEventType(MotionEvent::Action action) {
switch (action) {
case MotionEvent::Action::DOWN:
case MotionEvent::Action::BUTTON_PRESS:
- return WebInputEvent::kMouseDown;
+ return WebInputEvent::Type::kMouseDown;
case MotionEvent::Action::MOVE:
case MotionEvent::Action::HOVER_MOVE:
- return WebInputEvent::kMouseMove;
+ return WebInputEvent::Type::kMouseMove;
case MotionEvent::Action::HOVER_ENTER:
- return WebInputEvent::kMouseEnter;
+ return WebInputEvent::Type::kMouseEnter;
case MotionEvent::Action::HOVER_EXIT:
- return WebInputEvent::kMouseLeave;
+ return WebInputEvent::Type::kMouseLeave;
case MotionEvent::Action::UP:
case MotionEvent::Action::BUTTON_RELEASE:
- return WebInputEvent::kMouseUp;
+ return WebInputEvent::Type::kMouseUp;
case MotionEvent::Action::NONE:
case MotionEvent::Action::CANCEL:
case MotionEvent::Action::POINTER_DOWN:
@@ -998,108 +624,7 @@ WebInputEvent::Type ToWebMouseEventType(MotionEvent::Action action) {
break;
}
NOTREACHED() << "Invalid MotionEvent::Action = " << action;
- return WebInputEvent::kUndefined;
-}
-
-EventType WebEventTypeToEventType(WebInputEvent::Type type) {
- switch (type) {
- case WebInputEvent::kMouseDown:
- return ET_MOUSE_PRESSED;
- case WebInputEvent::kMouseUp:
- return ET_MOUSE_RELEASED;
- case WebInputEvent::kMouseMove:
- return ET_MOUSE_MOVED;
- case WebInputEvent::kMouseEnter:
- return ET_MOUSE_ENTERED;
- case WebInputEvent::kMouseLeave:
- return ET_MOUSE_EXITED;
- case WebInputEvent::kContextMenu:
- return ET_UNKNOWN;
- case WebInputEvent::kMouseWheel:
- return ET_MOUSEWHEEL;
- case WebInputEvent::kRawKeyDown:
- return ET_UNKNOWN;
- case WebInputEvent::kKeyDown:
- return ET_KEY_PRESSED;
- case WebInputEvent::kKeyUp:
- return ET_KEY_RELEASED;
- case WebInputEvent::kChar:
- return ET_UNKNOWN;
- case WebInputEvent::kGestureScrollBegin:
- return ET_GESTURE_SCROLL_BEGIN;
- case WebInputEvent::kGestureScrollEnd:
- return ET_GESTURE_SCROLL_END;
- case WebInputEvent::kGestureScrollUpdate:
- return ET_GESTURE_SCROLL_UPDATE;
- case WebInputEvent::kGestureFlingStart:
- return ET_SCROLL_FLING_START;
- case WebInputEvent::kGestureFlingCancel:
- return ET_SCROLL_FLING_CANCEL;
- case WebInputEvent::kGesturePinchBegin:
- return ET_GESTURE_PINCH_BEGIN;
- case WebInputEvent::kGesturePinchEnd:
- return ET_GESTURE_PINCH_END;
- case WebInputEvent::kGesturePinchUpdate:
- return ET_GESTURE_PINCH_UPDATE;
- case WebInputEvent::kGestureTapDown:
- return ET_GESTURE_TAP_DOWN;
- case WebInputEvent::kGestureShowPress:
- return ET_GESTURE_SHOW_PRESS;
- case WebInputEvent::kGestureTap:
- return ET_GESTURE_TAP;
- case WebInputEvent::kGestureTapCancel:
- return ET_GESTURE_TAP_CANCEL;
- case WebInputEvent::kGestureLongPress:
- return ET_GESTURE_LONG_PRESS;
- case WebInputEvent::kGestureLongTap:
- return ET_GESTURE_LONG_TAP;
- case WebInputEvent::kGestureTwoFingerTap:
- return ET_GESTURE_TWO_FINGER_TAP;
- case WebInputEvent::kGestureTapUnconfirmed:
- return ET_GESTURE_TAP_UNCONFIRMED;
- case WebInputEvent::kGestureDoubleTap:
- return ET_GESTURE_DOUBLE_TAP;
- case WebInputEvent::kTouchStart:
- return ET_TOUCH_PRESSED;
- case WebInputEvent::kTouchMove:
- return ET_TOUCH_MOVED;
- case WebInputEvent::kTouchEnd:
- return ET_TOUCH_RELEASED;
- case WebInputEvent::kTouchCancel:
- return ET_TOUCH_CANCELLED;
- case WebInputEvent::kTouchScrollStarted:
- case WebInputEvent::kPointerDown:
- return ET_TOUCH_PRESSED;
- case WebInputEvent::kPointerUp:
- return ET_TOUCH_RELEASED;
- case WebInputEvent::kPointerMove:
- return ET_TOUCH_MOVED;
- case WebInputEvent::kPointerCancel:
- return ET_TOUCH_CANCELLED;
- default:
- return ET_UNKNOWN;
- }
-}
-
-base::Optional<cc::ScrollInputType> GetScrollInputTypeForEvent(
- const WebInputEvent& event) {
- if (event.IsGestureScroll()) {
- const auto& gesture = static_cast<const WebGestureEvent&>(event);
- switch (gesture.SourceDevice()) {
- case WebGestureDevice::kTouchpad:
- return cc::ScrollInputType::kWheel;
- case WebGestureDevice::kTouchscreen:
- return cc::ScrollInputType::kTouchscreen;
- case WebGestureDevice::kSyntheticAutoscroll:
- return cc::ScrollInputType::kAutoscroll;
- case WebGestureDevice::kScrollbar:
- return cc::ScrollInputType::kScrollbar;
- case WebGestureDevice::kUninitialized:
- break;
- }
- }
-
- return base::nullopt;
+ return WebInputEvent::Type::kUndefined;
}
void SetWebPointerPropertiesFromMotionEventData(
@@ -1182,25 +707,11 @@ blink::WebInputEvent::Modifiers DomCodeToWebInputEventModifiers(DomCode code) {
return static_cast<blink::WebInputEvent::Modifiers>(0);
}
-bool IsGestureScrollOrPinch(WebInputEvent::Type type) {
- switch (type) {
- case blink::WebGestureEvent::kGestureScrollBegin:
- case blink::WebGestureEvent::kGestureScrollUpdate:
- case blink::WebGestureEvent::kGestureScrollEnd:
- case blink::WebGestureEvent::kGesturePinchBegin:
- case blink::WebGestureEvent::kGesturePinchUpdate:
- case blink::WebGestureEvent::kGesturePinchEnd:
- return true;
- default:
- return false;
- }
-}
-
bool IsGestureScroll(WebInputEvent::Type type) {
switch (type) {
- case blink::WebGestureEvent::kGestureScrollBegin:
- case blink::WebGestureEvent::kGestureScrollUpdate:
- case blink::WebGestureEvent::kGestureScrollEnd:
+ case blink::WebGestureEvent::Type::kGestureScrollBegin:
+ case blink::WebGestureEvent::Type::kGestureScrollUpdate:
+ case blink::WebGestureEvent::Type::kGestureScrollEnd:
return true;
default:
return false;
@@ -1209,8 +720,8 @@ bool IsGestureScroll(WebInputEvent::Type type) {
bool IsContinuousGestureEvent(WebInputEvent::Type type) {
switch (type) {
- case blink::WebGestureEvent::kGestureScrollUpdate:
- case blink::WebGestureEvent::kGesturePinchUpdate:
+ case blink::WebGestureEvent::Type::kGestureScrollUpdate:
+ case blink::WebGestureEvent::Type::kGesturePinchUpdate:
return true;
default:
return false;
@@ -1221,26 +732,26 @@ EventPointerType WebPointerTypeToEventPointerType(
WebPointerProperties::PointerType type) {
switch (type) {
case WebPointerProperties::PointerType::kMouse:
- return EventPointerType::POINTER_TYPE_MOUSE;
+ return EventPointerType::kMouse;
case WebPointerProperties::PointerType::kPen:
- return EventPointerType::POINTER_TYPE_PEN;
+ return EventPointerType::kPen;
case WebPointerProperties::PointerType::kEraser:
- return EventPointerType::POINTER_TYPE_ERASER;
+ return EventPointerType::kEraser;
case WebPointerProperties::PointerType::kTouch:
- return EventPointerType::POINTER_TYPE_TOUCH;
+ return EventPointerType::kTouch;
case WebPointerProperties::PointerType::kUnknown:
- return EventPointerType::POINTER_TYPE_UNKNOWN;
+ return EventPointerType::kUnknown;
}
NOTREACHED() << "Invalid pointer type";
- return EventPointerType::POINTER_TYPE_UNKNOWN;
+ return EventPointerType::kUnknown;
}
blink::WebGestureEvent ScrollBeginFromScrollUpdate(
const blink::WebGestureEvent& gesture_update) {
- DCHECK(gesture_update.GetType() == WebInputEvent::kGestureScrollUpdate);
+ DCHECK(gesture_update.GetType() == WebInputEvent::Type::kGestureScrollUpdate);
WebGestureEvent scroll_begin(gesture_update);
- scroll_begin.SetType(WebInputEvent::kGestureScrollBegin);
+ scroll_begin.SetType(WebInputEvent::Type::kGestureScrollBegin);
scroll_begin.data.scroll_begin.delta_x_hint =
gesture_update.data.scroll_update.delta_x;
@@ -1258,39 +769,6 @@ blink::WebGestureEvent ScrollBeginFromScrollUpdate(
return scroll_begin;
}
-std::unique_ptr<blink::WebGestureEvent> GenerateInjectedScrollGesture(
- WebInputEvent::Type type,
- base::TimeTicks timestamp,
- WebGestureDevice device,
- gfx::PointF position_in_widget,
- gfx::Vector2dF scroll_delta,
- ScrollGranularity granularity) {
- DCHECK(IsGestureScroll(type));
- std::unique_ptr<WebGestureEvent> generated_gesture_event =
- std::make_unique<WebGestureEvent>(type, WebInputEvent::kNoModifiers,
- timestamp, device);
-
- if (type == WebInputEvent::Type::kGestureScrollBegin) {
- // Gesture events expect the scroll delta to be flipped. Gesture events'
- // scroll deltas are interpreted as the finger's delta in relation to the
- // screen (which is the reverse of the scrolling direction).
- generated_gesture_event->data.scroll_begin.delta_x_hint = -scroll_delta.x();
- generated_gesture_event->data.scroll_begin.delta_y_hint = -scroll_delta.y();
- generated_gesture_event->data.scroll_begin.inertial_phase =
- WebGestureEvent::InertialPhaseState::kNonMomentum;
- generated_gesture_event->data.scroll_begin.delta_hint_units = granularity;
- } else if (type == WebInputEvent::Type::kGestureScrollUpdate) {
- generated_gesture_event->data.scroll_update.delta_x = -scroll_delta.x();
- generated_gesture_event->data.scroll_update.delta_y = -scroll_delta.y();
- generated_gesture_event->data.scroll_update.inertial_phase =
- WebGestureEvent::InertialPhaseState::kNonMomentum;
- generated_gesture_event->data.scroll_update.delta_units = granularity;
- }
-
- generated_gesture_event->SetPositionInWidget(position_in_widget);
- return generated_gesture_event;
-}
-
gfx::PointF PositionInWidgetFromInputEvent(const blink::WebInputEvent& event) {
if (WebInputEvent::IsMouseEventType(event.GetType())) {
return static_cast<const WebMouseEvent&>(event).PositionInWidget();
@@ -1304,34 +782,34 @@ gfx::PointF PositionInWidgetFromInputEvent(const blink::WebInputEvent& event) {
#if defined(OS_ANDROID)
std::unique_ptr<WebGestureEvent> CreateWebGestureEventFromGestureEventAndroid(
const GestureEventAndroid& event) {
- WebInputEvent::Type event_type = WebInputEvent::kUndefined;
+ WebInputEvent::Type event_type = WebInputEvent::Type::kUndefined;
switch (event.type()) {
case GESTURE_EVENT_TYPE_PINCH_BEGIN:
- event_type = WebInputEvent::kGesturePinchBegin;
+ event_type = WebInputEvent::Type::kGesturePinchBegin;
break;
case GESTURE_EVENT_TYPE_PINCH_BY:
- event_type = WebInputEvent::kGesturePinchUpdate;
+ event_type = WebInputEvent::Type::kGesturePinchUpdate;
break;
case GESTURE_EVENT_TYPE_PINCH_END:
- event_type = WebInputEvent::kGesturePinchEnd;
+ event_type = WebInputEvent::Type::kGesturePinchEnd;
break;
case GESTURE_EVENT_TYPE_SCROLL_START:
- event_type = WebInputEvent::kGestureScrollBegin;
+ event_type = WebInputEvent::Type::kGestureScrollBegin;
break;
case GESTURE_EVENT_TYPE_SCROLL_BY:
- event_type = WebInputEvent::kGestureScrollUpdate;
+ event_type = WebInputEvent::Type::kGestureScrollUpdate;
break;
case GESTURE_EVENT_TYPE_SCROLL_END:
- event_type = WebInputEvent::kGestureScrollEnd;
+ event_type = WebInputEvent::Type::kGestureScrollEnd;
break;
case GESTURE_EVENT_TYPE_FLING_START:
- event_type = WebInputEvent::kGestureFlingStart;
+ event_type = WebInputEvent::Type::kGestureFlingStart;
break;
case GESTURE_EVENT_TYPE_FLING_CANCEL:
- event_type = WebInputEvent::kGestureFlingCancel;
+ event_type = WebInputEvent::Type::kGestureFlingCancel;
break;
case GESTURE_EVENT_TYPE_DOUBLE_TAP:
- event_type = WebInputEvent::kGestureDoubleTap;
+ event_type = WebInputEvent::Type::kGestureDoubleTap;
break;
default:
NOTREACHED() << "Unknown gesture event type";
@@ -1348,24 +826,24 @@ std::unique_ptr<WebGestureEvent> CreateWebGestureEventFromGestureEventAndroid(
web_event->SetSourceDevice(WebGestureDevice::kTouchscreen);
if (event.synthetic_scroll())
web_event->SetSourceDevice(WebGestureDevice::kSyntheticAutoscroll);
- if (event_type == WebInputEvent::kGesturePinchUpdate) {
+ if (event_type == WebInputEvent::Type::kGesturePinchUpdate) {
web_event->data.pinch_update.scale = event.scale();
- } else if (event_type == WebInputEvent::kGestureScrollBegin) {
+ } else if (event_type == WebInputEvent::Type::kGestureScrollBegin) {
web_event->data.scroll_begin.delta_x_hint = event.delta_x();
web_event->data.scroll_begin.delta_y_hint = event.delta_y();
web_event->data.scroll_begin.target_viewport = event.target_viewport();
- } else if (event_type == WebInputEvent::kGestureScrollUpdate) {
+ } else if (event_type == WebInputEvent::Type::kGestureScrollUpdate) {
web_event->data.scroll_update.delta_x = event.delta_x();
web_event->data.scroll_update.delta_y = event.delta_y();
- } else if (event_type == WebInputEvent::kGestureFlingStart) {
+ } else if (event_type == WebInputEvent::Type::kGestureFlingStart) {
web_event->data.fling_start.velocity_x = event.velocity_x();
web_event->data.fling_start.velocity_y = event.velocity_y();
web_event->data.fling_start.target_viewport = event.target_viewport();
- } else if (event_type == WebInputEvent::kGestureFlingCancel) {
+ } else if (event_type == WebInputEvent::Type::kGestureFlingCancel) {
web_event->data.fling_cancel.prevent_boosting = event.prevent_boosting();
if (event.synthetic_scroll())
web_event->data.fling_cancel.target_viewport = true;
- } else if (event_type == WebInputEvent::kGestureDoubleTap) {
+ } else if (event_type == WebInputEvent::Type::kGestureDoubleTap) {
// Set the tap count to 1 even for DoubleTap, in order to be consistent with
// double tap behavior on a mobile viewport. See https://crbug.com/234986
// for context.
diff --git a/chromium/ui/events/blink/blink_event_util.h b/chromium/ui/events/blink/blink_event_util.h
index 79c798cbff2..bc236c5f18f 100644
--- a/chromium/ui/events/blink/blink_event_util.h
+++ b/chromium/ui/events/blink/blink_event_util.h
@@ -9,13 +9,13 @@
#include "base/optional.h"
#include "build/build_config.h"
-#include "cc/input/scroll_input_type.h"
#include "third_party/blink/public/common/input/web_gesture_event.h"
#include "third_party/blink/public/common/input/web_input_event.h"
#include "third_party/blink/public/common/input/web_touch_event.h"
#include "ui/events/event_constants.h"
#include "ui/events/gesture_detection/motion_event.h"
#include "ui/events/types/event_type.h"
+#include "ui/events/types/scroll_input_type.h"
#include "ui/events/types/scroll_types.h"
namespace gfx {
@@ -30,22 +30,6 @@ struct GestureEventData;
struct GestureEventDetails;
class MotionEvent;
-bool CanCoalesce(const blink::WebInputEvent& event_to_coalesce,
- const blink::WebInputEvent& event);
-
-void Coalesce(const blink::WebInputEvent& event_to_coalesce,
- blink::WebInputEvent* event);
-
-bool IsCompatibleScrollorPinch(const blink::WebGestureEvent& new_event,
- const blink::WebGestureEvent& event_in_queue);
-
-// Coalesces 3 GestureScroll/PinchUpdate into 2 events.
-// Returns <GestureScrollUpdate, GesturePinchUpdate>.
-std::pair<blink::WebGestureEvent, blink::WebGestureEvent>
-CoalesceScrollAndPinch(const blink::WebGestureEvent* second_last_event,
- const blink::WebGestureEvent& last_event,
- const blink::WebGestureEvent& new_event);
-
blink::WebTouchEvent CreateWebTouchEventFromMotionEvent(
const MotionEvent& event,
bool may_cause_scrolling,
@@ -80,13 +64,6 @@ std::unique_ptr<blink::WebInputEvent> TranslateAndScaleWebInputEvent(
blink::WebInputEvent::Type ToWebMouseEventType(MotionEvent::Action action);
-EventType WebEventTypeToEventType(blink::WebInputEvent::Type type);
-
-// Returns the scroll input type if |event| is a scroll event; otherwise,
-// returns base::nullopt.
-base::Optional<cc::ScrollInputType> GetScrollInputTypeForEvent(
- const blink::WebInputEvent& event);
-
void SetWebPointerPropertiesFromMotionEventData(
blink::WebPointerProperties& webPointerProperties,
int pointer_id,
@@ -101,11 +78,11 @@ void SetWebPointerPropertiesFromMotionEventData(
int WebEventModifiersToEventFlags(int modifiers);
+float IfNanUseMaxFloat(float value);
+
blink::WebInputEvent::Modifiers DomCodeToWebInputEventModifiers(
ui::DomCode code);
-bool IsGestureScrollOrPinch(blink::WebInputEvent::Type);
-
bool IsGestureScroll(blink::WebInputEvent::Type);
bool IsContinuousGestureEvent(blink::WebInputEvent::Type);
@@ -122,17 +99,6 @@ inline const blink::WebGestureEvent& ToWebGestureEvent(
blink::WebGestureEvent ScrollBeginFromScrollUpdate(
const blink::WebGestureEvent& scroll_update);
-// Generate a scroll gesture event (begin, update, or end), based on the
-// parameters passed in. Populates the data field of the created
-// WebGestureEvent based on the type.
-std::unique_ptr<blink::WebGestureEvent> GenerateInjectedScrollGesture(
- blink::WebInputEvent::Type type,
- base::TimeTicks timestamp,
- blink::WebGestureDevice device,
- gfx::PointF position_in_widget,
- gfx::Vector2dF scroll_delta,
- ScrollGranularity granularity);
-
// Returns the position in the widget if it exists for the passed in event type
gfx::PointF PositionInWidgetFromInputEvent(const blink::WebInputEvent& event);
diff --git a/chromium/ui/events/blink/blink_event_util_unittest.cc b/chromium/ui/events/blink/blink_event_util_unittest.cc
index 12708bf96ed..ad0238a80f3 100644
--- a/chromium/ui/events/blink/blink_event_util_unittest.cc
+++ b/chromium/ui/events/blink/blink_event_util_unittest.cc
@@ -15,38 +15,6 @@
namespace ui {
-namespace {
-
-blink::WebMouseEvent CreateWebMouseMoveEvent() {
- blink::WebMouseEvent mouse_event;
- mouse_event.SetType(blink::WebInputEvent::kMouseMove);
- mouse_event.id = 1;
- mouse_event.pointer_type = blink::WebPointerProperties::PointerType::kMouse;
- return mouse_event;
-}
-
-blink::WebPointerEvent CreateWebPointerMoveEvent() {
- blink::WebPointerEvent pointer_event;
- pointer_event.SetType(blink::WebInputEvent::kPointerMove);
- pointer_event.id = 1;
- pointer_event.pointer_type = blink::WebPointerProperties::PointerType::kMouse;
- return pointer_event;
-}
-
-blink::WebTouchEvent CreateWebTouchMoveEvent() {
- blink::WebTouchPoint touch_point;
- touch_point.id = 1;
- touch_point.state = blink::WebTouchPoint::kStateMoved;
- touch_point.pointer_type = blink::WebPointerProperties::PointerType::kTouch;
-
- blink::WebTouchEvent touch_event;
- touch_event.SetType(blink::WebInputEvent::kTouchMove);
- touch_event.touches[touch_event.touches_length++] = touch_point;
- return touch_event;
-}
-
-} // namespace
-
using BlinkEventUtilTest = testing::Test;
TEST(BlinkEventUtilTest, NoScalingWith1DSF) {
@@ -65,7 +33,8 @@ TEST(BlinkEventUtilTest, NoScalingWith1DSF) {
TEST(BlinkEventUtilTest, NonPaginatedWebMouseWheelEvent) {
blink::WebMouseWheelEvent event(
- blink::WebInputEvent::kMouseWheel, blink::WebInputEvent::kNoModifiers,
+ blink::WebInputEvent::Type::kMouseWheel,
+ blink::WebInputEvent::kNoModifiers,
blink::WebInputEvent::GetStaticTimeStampForTests());
event.delta_units = ui::ScrollGranularity::kScrollByPixel;
event.delta_x = 1.f;
@@ -85,7 +54,8 @@ TEST(BlinkEventUtilTest, NonPaginatedWebMouseWheelEvent) {
TEST(BlinkEventUtilTest, PaginatedWebMouseWheelEvent) {
blink::WebMouseWheelEvent event(
- blink::WebInputEvent::kMouseWheel, blink::WebInputEvent::kNoModifiers,
+ blink::WebInputEvent::Type::kMouseWheel,
+ blink::WebInputEvent::kNoModifiers,
blink::WebInputEvent::GetStaticTimeStampForTests());
event.delta_units = ui::ScrollGranularity::kScrollByPage;
event.delta_x = 1.f;
@@ -134,6 +104,18 @@ TEST(BlinkEventUtilTest, PaginatedScrollBeginEvent) {
EXPECT_EQ(1.f, gestureEvent->data.scroll_begin.delta_y_hint);
}
+TEST(BlinkEventUtilTest, EnsureFlingVelocityNotNaN) {
+ float nan_number = std::nanf("");
+ ui::GestureEventDetails details(ui::ET_SCROLL_FLING_START, nan_number, 1.f);
+ details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHSCREEN);
+ auto event =
+ CreateWebGestureEvent(details, base::TimeTicks(), gfx::PointF(1.f, 1.f),
+ gfx::PointF(1.f, 1.f), 0, 0U);
+ EXPECT_EQ(std::numeric_limits<float>::max(),
+ event.data.fling_start.velocity_x);
+ EXPECT_EQ(1.f, event.data.fling_start.velocity_y);
+}
+
TEST(BlinkEventUtilTest, NonPaginatedScrollUpdateEvent) {
ui::GestureEventDetails details(ui::ET_GESTURE_SCROLL_UPDATE, 1, 1);
details.set_device_type(ui::GestureDeviceType::DEVICE_TOUCHSCREEN);
@@ -203,216 +185,6 @@ TEST(BlinkEventUtilTest, LineAndDocumentScrollEvents) {
}
}
-TEST(BlinkEventUtilTest, TouchEventCoalescing) {
- blink::WebTouchEvent coalesced_event = CreateWebTouchMoveEvent();
- coalesced_event.SetType(blink::WebInputEvent::kTouchMove);
- coalesced_event.touches[0].movement_x = 5;
- coalesced_event.touches[0].movement_y = 10;
-
- blink::WebTouchEvent event_to_be_coalesced = CreateWebTouchMoveEvent();
- event_to_be_coalesced.touches[0].movement_x = 3;
- event_to_be_coalesced.touches[0].movement_y = -4;
-
- EXPECT_TRUE(CanCoalesce(event_to_be_coalesced, coalesced_event));
- Coalesce(event_to_be_coalesced, &coalesced_event);
- EXPECT_EQ(8, coalesced_event.touches[0].movement_x);
- EXPECT_EQ(6, coalesced_event.touches[0].movement_y);
-
- coalesced_event.touches[0].pointer_type =
- blink::WebPointerProperties::PointerType::kPen;
- EXPECT_FALSE(CanCoalesce(event_to_be_coalesced, coalesced_event));
-
- coalesced_event = CreateWebTouchMoveEvent();
- event_to_be_coalesced = CreateWebTouchMoveEvent();
- event_to_be_coalesced.SetModifiers(blink::WebInputEvent::kControlKey);
- EXPECT_FALSE(CanCoalesce(event_to_be_coalesced, coalesced_event));
-}
-
-TEST(BlinkEventUtilTest, WebMouseWheelEventCoalescing) {
- blink::WebMouseWheelEvent coalesced_event(
- blink::WebInputEvent::kMouseWheel, blink::WebInputEvent::kNoModifiers,
- blink::WebInputEvent::GetStaticTimeStampForTests());
- coalesced_event.delta_x = 1;
- coalesced_event.delta_y = 1;
-
- blink::WebMouseWheelEvent event_to_be_coalesced(
- blink::WebInputEvent::kMouseWheel, blink::WebInputEvent::kNoModifiers,
- blink::WebInputEvent::GetStaticTimeStampForTests());
- event_to_be_coalesced.delta_x = 3;
- event_to_be_coalesced.delta_y = 4;
-
- EXPECT_TRUE(CanCoalesce(event_to_be_coalesced, coalesced_event));
- Coalesce(event_to_be_coalesced, &coalesced_event);
- EXPECT_EQ(4, coalesced_event.delta_x);
- EXPECT_EQ(5, coalesced_event.delta_y);
-
- event_to_be_coalesced.phase = blink::WebMouseWheelEvent::kPhaseBegan;
- coalesced_event.phase = blink::WebMouseWheelEvent::kPhaseEnded;
- EXPECT_FALSE(CanCoalesce(event_to_be_coalesced, coalesced_event));
-
- // With timer based wheel scroll latching, we break the latching sequence on
- // direction change when all prior GSU events in the current sequence are
- // ignored. To do so we dispatch the pending wheel event with phaseEnded and
- // the first wheel event in the opposite direction will have phaseBegan. The
- // GSB generated from this wheel event will cause a new hittesting. To make
- // sure that a GSB will actually get created we should not coalesce the wheel
- // event with synthetic kPhaseBegan to one with synthetic kPhaseEnded.
- event_to_be_coalesced.has_synthetic_phase = true;
- coalesced_event.has_synthetic_phase = true;
- EXPECT_FALSE(CanCoalesce(event_to_be_coalesced, coalesced_event));
-
- event_to_be_coalesced.phase = blink::WebMouseWheelEvent::kPhaseChanged;
- coalesced_event.phase = blink::WebMouseWheelEvent::kPhaseBegan;
- EXPECT_TRUE(CanCoalesce(event_to_be_coalesced, coalesced_event));
- Coalesce(event_to_be_coalesced, &coalesced_event);
- EXPECT_EQ(blink::WebMouseWheelEvent::kPhaseBegan, coalesced_event.phase);
- EXPECT_EQ(7, coalesced_event.delta_x);
- EXPECT_EQ(9, coalesced_event.delta_y);
-}
-
-TEST(BlinkEventUtilTest, WebGestureEventCoalescing) {
- blink::WebGestureEvent coalesced_event(
- blink::WebInputEvent::kGestureScrollUpdate,
- blink::WebInputEvent::kNoModifiers,
- blink::WebInputEvent::GetStaticTimeStampForTests());
- coalesced_event.data.scroll_update.delta_x = 1;
- coalesced_event.data.scroll_update.delta_y = 1;
-
- blink::WebGestureEvent event_to_be_coalesced(
- blink::WebInputEvent::kGestureScrollUpdate,
- blink::WebInputEvent::kNoModifiers,
- blink::WebInputEvent::GetStaticTimeStampForTests());
- event_to_be_coalesced.data.scroll_update.delta_x = 3;
- event_to_be_coalesced.data.scroll_update.delta_y = 4;
-
- EXPECT_TRUE(CanCoalesce(event_to_be_coalesced, coalesced_event));
- Coalesce(event_to_be_coalesced, &coalesced_event);
- EXPECT_EQ(4, coalesced_event.data.scroll_update.delta_x);
- EXPECT_EQ(5, coalesced_event.data.scroll_update.delta_y);
-}
-
-TEST(BlinkEventUtilTest, GesturePinchUpdateCoalescing) {
- gfx::PointF position(10.f, 10.f);
- blink::WebGestureEvent coalesced_event(
- blink::WebInputEvent::kGesturePinchUpdate,
- blink::WebInputEvent::kNoModifiers,
- blink::WebInputEvent::GetStaticTimeStampForTests(),
- blink::WebGestureDevice::kTouchpad);
- coalesced_event.data.pinch_update.scale = 1.1f;
- coalesced_event.SetPositionInWidget(position);
-
- blink::WebGestureEvent event_to_be_coalesced(coalesced_event);
-
- ASSERT_TRUE(CanCoalesce(event_to_be_coalesced, coalesced_event));
- Coalesce(event_to_be_coalesced, &coalesced_event);
- EXPECT_FLOAT_EQ(1.21, coalesced_event.data.pinch_update.scale);
-
- // Allow the updates to be coalesced if the anchors are nearly equal.
- position.Offset(0.1f, 0.1f);
- event_to_be_coalesced.SetPositionInWidget(position);
- coalesced_event.data.pinch_update.scale = 1.1f;
- ASSERT_TRUE(CanCoalesce(event_to_be_coalesced, coalesced_event));
- Coalesce(event_to_be_coalesced, &coalesced_event);
- EXPECT_FLOAT_EQ(1.21, coalesced_event.data.pinch_update.scale);
-
- // The anchors are no longer considered equal, so don't coalesce.
- position.Offset(1.f, 1.f);
- event_to_be_coalesced.SetPositionInWidget(position);
- EXPECT_FALSE(CanCoalesce(event_to_be_coalesced, coalesced_event));
-
- // Don't logically coalesce touchpad pinch events as touchpad pinch events
- // don't occur within a gesture scroll sequence.
- EXPECT_FALSE(
- IsCompatibleScrollorPinch(event_to_be_coalesced, coalesced_event));
-
- // Touchscreen pinch events can be logically coalesced.
- coalesced_event.SetSourceDevice(blink::WebGestureDevice::kTouchscreen);
- event_to_be_coalesced.SetSourceDevice(blink::WebGestureDevice::kTouchscreen);
- coalesced_event.data.pinch_update.scale = 1.1f;
- ASSERT_TRUE(
- IsCompatibleScrollorPinch(event_to_be_coalesced, coalesced_event));
-
- blink::WebGestureEvent logical_scroll, logical_pinch;
- std::tie(logical_scroll, logical_pinch) =
- CoalesceScrollAndPinch(nullptr, coalesced_event, event_to_be_coalesced);
- ASSERT_EQ(blink::WebInputEvent::kGestureScrollUpdate,
- logical_scroll.GetType());
- ASSERT_EQ(blink::WebInputEvent::kGesturePinchUpdate, logical_pinch.GetType());
- EXPECT_FLOAT_EQ(1.21, logical_pinch.data.pinch_update.scale);
-}
-
-TEST(BlinkEventUtilTest, MouseEventCoalescing) {
- blink::WebMouseEvent coalesced_event = CreateWebMouseMoveEvent();
- blink::WebMouseEvent event_to_be_coalesced = CreateWebMouseMoveEvent();
- EXPECT_TRUE(CanCoalesce(event_to_be_coalesced, coalesced_event));
-
- // Test coalescing movements.
- coalesced_event.movement_x = 5;
- coalesced_event.movement_y = 10;
-
- event_to_be_coalesced.movement_x = 3;
- event_to_be_coalesced.movement_y = -4;
- EXPECT_TRUE(CanCoalesce(event_to_be_coalesced, coalesced_event));
- Coalesce(event_to_be_coalesced, &coalesced_event);
- EXPECT_EQ(8, coalesced_event.movement_x);
- EXPECT_EQ(6, coalesced_event.movement_y);
-
- // Test id.
- coalesced_event = CreateWebMouseMoveEvent();
- event_to_be_coalesced = CreateWebMouseMoveEvent();
- event_to_be_coalesced.id = 3;
- EXPECT_FALSE(CanCoalesce(event_to_be_coalesced, coalesced_event));
-
- // Test pointer_type.
- coalesced_event = CreateWebMouseMoveEvent();
- event_to_be_coalesced = CreateWebMouseMoveEvent();
- event_to_be_coalesced.pointer_type =
- blink::WebPointerProperties::PointerType::kPen;
- EXPECT_FALSE(CanCoalesce(event_to_be_coalesced, coalesced_event));
-
- // Test modifiers
- coalesced_event = CreateWebMouseMoveEvent();
- event_to_be_coalesced = CreateWebMouseMoveEvent();
- event_to_be_coalesced.SetModifiers(blink::WebInputEvent::kControlKey);
- EXPECT_FALSE(CanCoalesce(event_to_be_coalesced, coalesced_event));
-}
-
-TEST(BlinkEventUtilTest, PointerEventCoalescing) {
- blink::WebPointerEvent coalesced_event = CreateWebPointerMoveEvent();
- blink::WebPointerEvent event_to_be_coalesced = CreateWebPointerMoveEvent();
- EXPECT_TRUE(CanCoalesce(event_to_be_coalesced, coalesced_event));
-
- // Test coalescing movements.
- coalesced_event.movement_x = 5;
- coalesced_event.movement_y = 10;
-
- event_to_be_coalesced.movement_x = 3;
- event_to_be_coalesced.movement_y = -4;
- EXPECT_TRUE(CanCoalesce(event_to_be_coalesced, coalesced_event));
- Coalesce(event_to_be_coalesced, &coalesced_event);
- EXPECT_EQ(8, coalesced_event.movement_x);
- EXPECT_EQ(6, coalesced_event.movement_y);
-
- // Test id.
- coalesced_event = CreateWebPointerMoveEvent();
- event_to_be_coalesced = CreateWebPointerMoveEvent();
- event_to_be_coalesced.id = 3;
- EXPECT_FALSE(CanCoalesce(event_to_be_coalesced, coalesced_event));
-
- // Test pointer_type.
- coalesced_event = CreateWebPointerMoveEvent();
- event_to_be_coalesced = CreateWebPointerMoveEvent();
- event_to_be_coalesced.pointer_type =
- blink::WebPointerProperties::PointerType::kPen;
- EXPECT_FALSE(CanCoalesce(event_to_be_coalesced, coalesced_event));
-
- // Test modifiers
- coalesced_event = CreateWebPointerMoveEvent();
- event_to_be_coalesced = CreateWebPointerMoveEvent();
- event_to_be_coalesced.SetModifiers(blink::WebInputEvent::kControlKey);
- EXPECT_FALSE(CanCoalesce(event_to_be_coalesced, coalesced_event));
-}
-
TEST(BlinkEventUtilTest, WebEventModifersAndEventFlags) {
using WebInputEvent = blink::WebInputEvent;
constexpr int kWebEventModifiersToTest[] = {WebInputEvent::kShiftKey,
diff --git a/chromium/ui/events/blink/blink_features.cc b/chromium/ui/events/blink/blink_features.cc
index 93e816c4a28..73a9903412c 100644
--- a/chromium/ui/events/blink/blink_features.cc
+++ b/chromium/ui/events/blink/blink_features.cc
@@ -6,38 +6,10 @@
namespace features {
-const base::Feature kResamplingScrollEvents{"ResamplingScrollEvents",
- base::FEATURE_ENABLED_BY_DEFAULT};
-
-const base::Feature kFilteringScrollPrediction{
- "FilteringScrollPrediction", base::FEATURE_DISABLED_BY_DEFAULT};
-
-const base::Feature kKalmanHeuristics{"KalmanHeuristics",
- base::FEATURE_DISABLED_BY_DEFAULT};
-
-const base::Feature kKalmanDirectionCutOff{"KalmanDirectionCutOff",
- base::FEATURE_DISABLED_BY_DEFAULT};
-
const base::Feature kSendMouseLeaveEvents{"SendMouseLeaveEvents",
base::FEATURE_ENABLED_BY_DEFAULT};
-const base::Feature kCompositorTouchAction{"CompositorTouchAction",
- base::FEATURE_ENABLED_BY_DEFAULT};
-
-const base::Feature kFallbackCursorMode{"FallbackCursorMode",
- base::FEATURE_DISABLED_BY_DEFAULT};
-
const base::Feature kDontSendKeyEventsToJavascript{
"DontSendKeyEventsToJavascript", base::FEATURE_DISABLED_BY_DEFAULT};
-const base::Feature kSkipTouchEventFilter{"SkipTouchEventFilter",
- base::FEATURE_ENABLED_BY_DEFAULT};
-const char kSkipTouchEventFilterTypeParamName[] = "type";
-const char kSkipTouchEventFilterTypeParamValueDiscrete[] = "discrete";
-const char kSkipTouchEventFilterTypeParamValueAll[] = "all";
-const char kSkipTouchEventFilterFilteringProcessParamName[] =
- "skip_filtering_process";
-const char kSkipTouchEventFilterFilteringProcessParamValueBrowser[] = "browser";
-const char kSkipTouchEventFilterFilteringProcessParamValueBrowserAndRenderer[] =
- "browser_and_renderer";
} // namespace features
diff --git a/chromium/ui/events/blink/blink_features.h b/chromium/ui/events/blink/blink_features.h
index c66a98247b9..f1fe50c3f44 100644
--- a/chromium/ui/events/blink/blink_features.h
+++ b/chromium/ui/events/blink/blink_features.h
@@ -10,23 +10,6 @@
namespace features {
-// Enables resampling GestureScroll events on compositor thread.
-COMPONENT_EXPORT(BLINK_FEATURES)
-extern const base::Feature kResamplingScrollEvents;
-
-// Enables filtering of predicted scroll events on compositor thread.
-COMPONENT_EXPORT(BLINK_FEATURES)
-extern const base::Feature kFilteringScrollPrediction;
-
-// Enables changing the influence of acceleration based on change of direction.
-COMPONENT_EXPORT(BLINK_FEATURES)
-extern const base::Feature kKalmanHeuristics;
-
-// Enables discarding the prediction if the predicted direction is opposite from
-// the current direction.
-COMPONENT_EXPORT(BLINK_FEATURES)
-extern const base::Feature kKalmanDirectionCutOff;
-
// This feature allows native ET_MOUSE_EXIT events to be passed
// through to blink as mouse leave events. Traditionally these events were
// converted to mouse move events due to a number of inconsistencies on
@@ -34,43 +17,11 @@ extern const base::Feature kKalmanDirectionCutOff;
COMPONENT_EXPORT(BLINK_FEATURES)
extern const base::Feature kSendMouseLeaveEvents;
-// Enables handling touch events in compositor using impl side touch action
-// knowledge.
-COMPONENT_EXPORT(BLINK_FEATURES)
-extern const base::Feature kCompositorTouchAction;
-
-// Enables fallback cursor mode for dpad devices.
-COMPONENT_EXPORT(BLINK_FEATURES)
-extern const base::Feature kFallbackCursorMode;
-
// When enabled, this feature prevent blink sending key event to web unless it
// is on installed PWA.
COMPONENT_EXPORT(BLINK_FEATURES)
extern const base::Feature kDontSendKeyEventsToJavascript;
-// Skips the browser touch event filter, ensuring that events that reach the
-// queue and would otherwise be filtered out will instead be passed onto the
-// renderer compositor process as long as the page hasn't timed out. If
-// skip_filtering_process is browser_and_renderer, also skip the renderer cc
-// touch event filter, ensuring that events will be passed onto the renderer
-// main thread. Which event types will be always forwarded is controlled by the
-// "type" FeatureParam,
-// which can be either "discrete" (default) or "all".
-COMPONENT_EXPORT(BLINK_FEATURES)
-extern const base::Feature kSkipTouchEventFilter;
-COMPONENT_EXPORT(BLINK_FEATURES)
-extern const char kSkipTouchEventFilterTypeParamName[];
-COMPONENT_EXPORT(BLINK_FEATURES)
-extern const char kSkipTouchEventFilterTypeParamValueDiscrete[];
-COMPONENT_EXPORT(BLINK_FEATURES)
-extern const char kSkipTouchEventFilterTypeParamValueAll[];
-COMPONENT_EXPORT(BLINK_FEATURES)
-extern const char kSkipTouchEventFilterFilteringProcessParamName[];
-COMPONENT_EXPORT(BLINK_FEATURES)
-extern const char kSkipTouchEventFilterFilteringProcessParamValueBrowser[];
-COMPONENT_EXPORT(BLINK_FEATURES)
-extern const char
- kSkipTouchEventFilterFilteringProcessParamValueBrowserAndRenderer[];
}
#endif // UI_EVENTS_BLINK_BLINK_FEATURES_H_
diff --git a/chromium/ui/events/blink/compositor_thread_event_queue.cc b/chromium/ui/events/blink/compositor_thread_event_queue.cc
deleted file mode 100644
index 8d4e0647587..00000000000
--- a/chromium/ui/events/blink/compositor_thread_event_queue.cc
+++ /dev/null
@@ -1,108 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/events/blink/compositor_thread_event_queue.h"
-
-#include "base/trace_event/trace_event.h"
-#include "ui/events/blink/blink_event_util.h"
-#include "ui/events/blink/web_input_event_traits.h"
-
-namespace ui {
-
-CompositorThreadEventQueue::CompositorThreadEventQueue() {}
-
-CompositorThreadEventQueue::~CompositorThreadEventQueue() {}
-
-void CompositorThreadEventQueue::Queue(
- std::unique_ptr<EventWithCallback> new_event,
- base::TimeTicks timestamp_now) {
- if (queue_.empty() ||
- !IsContinuousGestureEvent(new_event->event().GetType()) ||
- !(queue_.back()->CanCoalesceWith(*new_event) ||
- IsCompatibleScrollorPinch(ToWebGestureEvent(new_event->event()),
- ToWebGestureEvent(queue_.back()->event())))) {
- if (new_event->first_original_event()) {
- // Trace could be nested as there might be multiple events in queue.
- // e.g. |ScrollUpdate|, |ScrollEnd|, and another scroll sequence.
- TRACE_EVENT_NESTABLE_ASYNC_BEGIN0("input",
- "CompositorThreadEventQueue::Queue",
- new_event->first_original_event());
- }
- queue_.emplace_back(std::move(new_event));
- return;
- }
-
- if (queue_.back()->CanCoalesceWith(*new_event)) {
- queue_.back()->CoalesceWith(new_event.get(), timestamp_now);
- return;
- }
-
- // Extract the last event in queue.
- std::unique_ptr<EventWithCallback> last_event = std::move(queue_.back());
- queue_.pop_back();
- DCHECK_LE(last_event->latency_info().trace_id(),
- new_event->latency_info().trace_id());
- LatencyInfo oldest_latency = last_event->latency_info();
- base::TimeTicks oldest_creation_timestamp = last_event->creation_timestamp();
- auto combined_original_events =
- std::make_unique<EventWithCallback::OriginalEventList>();
- combined_original_events->splice(combined_original_events->end(),
- last_event->original_events());
- combined_original_events->splice(combined_original_events->end(),
- new_event->original_events());
-
- // Extract the second last event in queue.
- std::unique_ptr<EventWithCallback> second_last_event = nullptr;
- if (!queue_.empty() &&
- IsCompatibleScrollorPinch(ToWebGestureEvent(new_event->event()),
- ToWebGestureEvent(queue_.back()->event()))) {
- second_last_event = std::move(queue_.back());
- queue_.pop_back();
- DCHECK_LE(second_last_event->latency_info().trace_id(),
- oldest_latency.trace_id());
- oldest_latency = second_last_event->latency_info();
- oldest_creation_timestamp = second_last_event->creation_timestamp();
- combined_original_events->splice(combined_original_events->begin(),
- second_last_event->original_events());
- }
-
- std::pair<blink::WebGestureEvent, blink::WebGestureEvent> coalesced_events =
- CoalesceScrollAndPinch(
- second_last_event ? &ToWebGestureEvent(second_last_event->event())
- : nullptr,
- ToWebGestureEvent(last_event->event()),
- ToWebGestureEvent(new_event->event()));
-
- std::unique_ptr<EventWithCallback> scroll_event =
- std::make_unique<EventWithCallback>(
- coalesced_events.first.Clone(), oldest_latency,
- oldest_creation_timestamp, timestamp_now, nullptr);
-
- std::unique_ptr<EventWithCallback> pinch_event =
- std::make_unique<EventWithCallback>(
- coalesced_events.second.Clone(), oldest_latency,
- oldest_creation_timestamp, timestamp_now,
- std::move(combined_original_events));
-
- queue_.emplace_back(std::move(scroll_event));
- queue_.emplace_back(std::move(pinch_event));
-}
-
-std::unique_ptr<EventWithCallback> CompositorThreadEventQueue::Pop() {
- std::unique_ptr<EventWithCallback> result;
- if (!queue_.empty()) {
- result = std::move(queue_.front());
- queue_.pop_front();
- }
-
- if (result->first_original_event()) {
- TRACE_EVENT_NESTABLE_ASYNC_END2(
- "input", "CompositorThreadEventQueue::Queue",
- result->first_original_event(), "type", result->event().GetType(),
- "coalesced_count", result->coalesced_count());
- }
- return result;
-}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/compositor_thread_event_queue.h b/chromium/ui/events/blink/compositor_thread_event_queue.h
deleted file mode 100644
index 2c19f966222..00000000000
--- a/chromium/ui/events/blink/compositor_thread_event_queue.h
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_EVENTS_BLINK_COMPOSITOR_THREAD_EVENT_QUEUE_H_
-#define UI_EVENTS_BLINK_COMPOSITOR_THREAD_EVENT_QUEUE_H_
-
-#include <memory>
-
-#include "base/containers/circular_deque.h"
-#include "ui/events/blink/event_with_callback.h"
-
-namespace ui {
-
-namespace test {
-class InputHandlerProxyEventQueueTest;
-}
-
-// CompositorThreadEventQueue is a coalescing queue. It will examine
-// the current events in the queue and will attempt to coalesce with
-// the last event.
-class CompositorThreadEventQueue {
- public:
- CompositorThreadEventQueue();
- ~CompositorThreadEventQueue();
-
- // Adds an event to the queue. The event may be coalesced with the last event.
- void Queue(std::unique_ptr<EventWithCallback> event,
- base::TimeTicks timestamp_now);
-
- std::unique_ptr<EventWithCallback> Pop();
-
- bool empty() const { return queue_.empty(); }
-
- size_t size() const { return queue_.size(); }
-
- private:
- friend class test::InputHandlerProxyEventQueueTest;
- using EventQueue = base::circular_deque<std::unique_ptr<EventWithCallback>>;
- EventQueue queue_;
-
- DISALLOW_COPY_AND_ASSIGN(CompositorThreadEventQueue);
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_COMPOSITOR_THREAD_EVENT_QUEUE_H_
diff --git a/chromium/ui/events/blink/did_overscroll_params.cc b/chromium/ui/events/blink/did_overscroll_params.cc
deleted file mode 100644
index 9f029b4824b..00000000000
--- a/chromium/ui/events/blink/did_overscroll_params.cc
+++ /dev/null
@@ -1,13 +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 "ui/events/blink/did_overscroll_params.h"
-
-namespace ui {
-
-DidOverscrollParams::DidOverscrollParams() {}
-
-DidOverscrollParams::~DidOverscrollParams() {}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/did_overscroll_params.h b/chromium/ui/events/blink/did_overscroll_params.h
index 50e3aefded0..74344adbd76 100644
--- a/chromium/ui/events/blink/did_overscroll_params.h
+++ b/chromium/ui/events/blink/did_overscroll_params.h
@@ -12,8 +12,6 @@
namespace ui {
struct DidOverscrollParams {
- DidOverscrollParams();
- ~DidOverscrollParams();
gfx::Vector2dF accumulated_overscroll;
gfx::Vector2dF latest_overscroll_delta;
gfx::Vector2dF current_fling_velocity;
diff --git a/chromium/ui/events/blink/event_with_callback.cc b/chromium/ui/events/blink/event_with_callback.cc
deleted file mode 100644
index 70b7240f713..00000000000
--- a/chromium/ui/events/blink/event_with_callback.cc
+++ /dev/null
@@ -1,137 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/events/blink/event_with_callback.h"
-
-#include "base/time/time.h"
-#include "third_party/blink/public/common/input/web_input_event_attribution.h"
-#include "ui/events/blink/blink_event_util.h"
-#include "ui/events/blink/did_overscroll_params.h"
-#include "ui/events/blink/web_input_event_traits.h"
-
-using blink::WebInputEvent;
-using blink::WebGestureEvent;
-
-namespace ui {
-
-EventWithCallback::EventWithCallback(
- WebScopedInputEvent event,
- const LatencyInfo& latency,
- base::TimeTicks timestamp_now,
- InputHandlerProxy::EventDispositionCallback callback)
- : event_(event->Clone()),
- latency_(latency),
- creation_timestamp_(timestamp_now),
- last_coalesced_timestamp_(timestamp_now) {
- original_events_.emplace_back(std::move(event), latency, std::move(callback));
-}
-
-EventWithCallback::EventWithCallback(
- WebScopedInputEvent event,
- const LatencyInfo& latency,
- base::TimeTicks creation_timestamp,
- base::TimeTicks last_coalesced_timestamp,
- std::unique_ptr<OriginalEventList> original_events)
- : event_(std::move(event)),
- latency_(latency),
- creation_timestamp_(creation_timestamp),
- last_coalesced_timestamp_(last_coalesced_timestamp) {
- if (original_events)
- original_events_.splice(original_events_.end(), *original_events);
-}
-
-EventWithCallback::~EventWithCallback() {}
-
-bool EventWithCallback::CanCoalesceWith(const EventWithCallback& other) const {
- return CanCoalesce(other.event(), event());
-}
-
-void EventWithCallback::SetScrollbarManipulationHandledOnCompositorThread() {
- for (auto& original_event : original_events_)
- original_event.event_->SetScrollbarManipulationHandledOnCompositorThread();
-}
-
-void EventWithCallback::CoalesceWith(EventWithCallback* other,
- base::TimeTicks timestamp_now) {
- // |other| should be a newer event than |this|.
- if (other->latency_.trace_id() >= 0 && latency_.trace_id() >= 0)
- DCHECK_GT(other->latency_.trace_id(), latency_.trace_id());
-
- // New events get coalesced into older events, and the newer timestamp
- // should always be preserved.
- const base::TimeTicks time_stamp = other->event().TimeStamp();
- Coalesce(other->event(), event_.get());
- event_->SetTimeStamp(time_stamp);
-
- // When coalescing two input events, we keep the oldest LatencyInfo
- // since it will represent the longest latency. If it's a GestureScrollUpdate
- // event, also update the old event's last timestamp and scroll delta using
- // the newer event's latency info.
- if (event_->GetType() == WebInputEvent::kGestureScrollUpdate)
- latency_.CoalesceScrollUpdateWith(other->latency_);
- other->latency_ = latency_;
- other->latency_.set_coalesced();
-
- // Move original events.
- original_events_.splice(original_events_.end(), other->original_events_);
- last_coalesced_timestamp_ = timestamp_now;
-}
-
-static bool HandledOnCompositorThread(
- InputHandlerProxy::EventDisposition disposition) {
- return (disposition != InputHandlerProxy::DID_NOT_HANDLE &&
- disposition !=
- InputHandlerProxy::DID_NOT_HANDLE_NON_BLOCKING_DUE_TO_FLING &&
- disposition != InputHandlerProxy::DID_HANDLE_NON_BLOCKING);
-}
-
-void EventWithCallback::RunCallbacks(
- InputHandlerProxy::EventDisposition disposition,
- const LatencyInfo& latency,
- std::unique_ptr<DidOverscrollParams> did_overscroll_params,
- const blink::WebInputEventAttribution& attribution) {
- // |original_events_| could be empty if this is the scroll event extracted
- // from the matrix multiplication.
- if (original_events_.size() == 0)
- return;
-
- // Ack the oldest event with original latency.
- std::move(original_events_.front().callback_)
- .Run(disposition, std::move(original_events_.front().event_), latency,
- did_overscroll_params
- ? std::make_unique<DidOverscrollParams>(*did_overscroll_params)
- : nullptr,
- attribution);
- original_events_.pop_front();
-
- // If the event was handled on compositor thread, ack other events with
- // coalesced latency to avoid redundant tracking. If not, the event should
- // be handle on main thread, use the original latency instead.
- bool handled = HandledOnCompositorThread(disposition);
- for (auto& coalesced_event : original_events_) {
- if (handled) {
- coalesced_event.latency_ = latency;
- coalesced_event.latency_.set_coalesced();
- }
- std::move(coalesced_event.callback_)
- .Run(disposition, std::move(coalesced_event.event_),
- coalesced_event.latency_,
- did_overscroll_params
- ? std::make_unique<DidOverscrollParams>(*did_overscroll_params)
- : nullptr,
- attribution);
- }
-}
-
-EventWithCallback::OriginalEventWithCallback::OriginalEventWithCallback(
- WebScopedInputEvent event,
- const LatencyInfo& latency,
- InputHandlerProxy::EventDispositionCallback callback)
- : event_(std::move(event)),
- latency_(latency),
- callback_(std::move(callback)) {}
-
-EventWithCallback::OriginalEventWithCallback::~OriginalEventWithCallback() {}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/event_with_callback.h b/chromium/ui/events/blink/event_with_callback.h
deleted file mode 100644
index ea2d73ec7fd..00000000000
--- a/chromium/ui/events/blink/event_with_callback.h
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_EVENTS_BLINK_EVENT_WITH_CALLBACK_H_
-#define UI_EVENTS_BLINK_EVENT_WITH_CALLBACK_H_
-
-#include <list>
-
-#include "ui/events/blink/input_handler_proxy.h"
-#include "ui/latency/latency_info.h"
-
-namespace ui {
-
-namespace test {
-class InputHandlerProxyEventQueueTest;
-}
-
-class EventWithCallback {
- public:
- struct OriginalEventWithCallback {
- OriginalEventWithCallback(
- WebScopedInputEvent event,
- const LatencyInfo& latency,
- InputHandlerProxy::EventDispositionCallback callback);
- ~OriginalEventWithCallback();
- WebScopedInputEvent event_;
- LatencyInfo latency_;
- InputHandlerProxy::EventDispositionCallback callback_;
- };
- using OriginalEventList = std::list<OriginalEventWithCallback>;
-
- EventWithCallback(WebScopedInputEvent event,
- const LatencyInfo& latency,
- base::TimeTicks timestamp_now,
- InputHandlerProxy::EventDispositionCallback callback);
- EventWithCallback(WebScopedInputEvent event,
- const LatencyInfo& latency,
- base::TimeTicks creation_timestamp,
- base::TimeTicks last_coalesced_timestamp,
- std::unique_ptr<OriginalEventList> original_events);
- ~EventWithCallback();
-
- bool CanCoalesceWith(const EventWithCallback& other) const WARN_UNUSED_RESULT;
- void CoalesceWith(EventWithCallback* other, base::TimeTicks timestamp_now);
-
- void RunCallbacks(InputHandlerProxy::EventDisposition,
- const LatencyInfo& latency,
- std::unique_ptr<DidOverscrollParams>,
- const blink::WebInputEventAttribution&);
-
- const blink::WebInputEvent& event() const { return *event_; }
- blink::WebInputEvent* event_pointer() { return event_.get(); }
- const LatencyInfo& latency_info() const { return latency_; }
- LatencyInfo* mutable_latency_info() { return &latency_; }
- base::TimeTicks creation_timestamp() const { return creation_timestamp_; }
- base::TimeTicks last_coalesced_timestamp() const {
- return last_coalesced_timestamp_;
- }
- size_t coalesced_count() const { return original_events_.size(); }
- OriginalEventList& original_events() { return original_events_; }
- // |first_original_event()| is used as ID for tracing.
- blink::WebInputEvent* first_original_event() {
- return original_events_.empty() ? nullptr
- : original_events_.front().event_.get();
- }
- void SetScrollbarManipulationHandledOnCompositorThread();
-
- private:
- friend class test::InputHandlerProxyEventQueueTest;
-
- void SetTickClockForTesting(std::unique_ptr<base::TickClock> tick_clock);
-
- WebScopedInputEvent event_;
- LatencyInfo latency_;
- OriginalEventList original_events_;
-
- base::TimeTicks creation_timestamp_;
- base::TimeTicks last_coalesced_timestamp_;
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_EVENT_WITH_CALLBACK_H_
diff --git a/chromium/ui/events/blink/fling_booster.cc b/chromium/ui/events/blink/fling_booster.cc
index dcb79d6ae56..d0cd9fb1434 100644
--- a/chromium/ui/events/blink/fling_booster.cc
+++ b/chromium/ui/events/blink/fling_booster.cc
@@ -30,7 +30,8 @@ namespace ui {
gfx::Vector2dF FlingBooster::GetVelocityForFlingStart(
const blink::WebGestureEvent& fling_start) {
- DCHECK_EQ(blink::WebInputEvent::kGestureFlingStart, fling_start.GetType());
+ DCHECK_EQ(blink::WebInputEvent::Type::kGestureFlingStart,
+ fling_start.GetType());
gfx::Vector2dF velocity(fling_start.data.fling_start.velocity_x,
fling_start.data.fling_start.velocity_y);
TRACE_EVENT2("input", "FlingBooster::GetVelocityForFlingStart", "vx",
@@ -74,12 +75,12 @@ void FlingBooster::ObserveGestureEvent(const WebGestureEvent& gesture_event) {
}
switch (gesture_event.GetType()) {
- case WebInputEvent::kGestureScrollBegin: {
+ case WebInputEvent::Type::kGestureScrollBegin: {
cutoff_time_for_boost_ =
gesture_event.TimeStamp() + kFlingBoostTimeoutDelay;
break;
}
- case WebInputEvent::kGestureScrollUpdate: {
+ case WebInputEvent::Type::kGestureScrollUpdate: {
if (gesture_event.data.scroll_update.inertial_phase ==
WebGestureEvent::InertialPhaseState::kMomentum) {
return;
@@ -123,11 +124,11 @@ void FlingBooster::ObserveGestureEvent(const WebGestureEvent& gesture_event) {
gesture_event.TimeStamp() + kFlingBoostTimeoutDelay;
break;
}
- case WebInputEvent::kGestureScrollEnd: {
+ case WebInputEvent::Type::kGestureScrollEnd: {
previous_boosting_scroll_timestamp_ = base::TimeTicks();
break;
}
- case WebInputEvent::kGestureFlingCancel: {
+ case WebInputEvent::Type::kGestureFlingCancel: {
if (gesture_event.data.fling_cancel.prevent_boosting) {
TRACE_EVENT_INSTANT0("input", "GFC PreventBoosting",
TRACE_EVENT_SCOPE_THREAD);
@@ -155,7 +156,8 @@ void FlingBooster::ObserveProgressFling(
}
bool FlingBooster::ShouldBoostFling(const WebGestureEvent& fling_start_event) {
- DCHECK_EQ(WebInputEvent::kGestureFlingStart, fling_start_event.GetType());
+ DCHECK_EQ(WebInputEvent::Type::kGestureFlingStart,
+ fling_start_event.GetType());
if (previous_fling_starting_velocity_.IsZero()) {
TRACE_EVENT_INSTANT0("input", "No Boost - NoActiveFling",
TRACE_EVENT_SCOPE_THREAD);
diff --git a/chromium/ui/events/blink/fling_booster_unittest.cc b/chromium/ui/events/blink/fling_booster_unittest.cc
index 49da07bbbc6..1fe81c9b021 100644
--- a/chromium/ui/events/blink/fling_booster_unittest.cc
+++ b/chromium/ui/events/blink/fling_booster_unittest.cc
@@ -36,8 +36,8 @@ class FlingBoosterTest : public testing::Test {
const gfx::Vector2dF& velocity,
int modifiers = 0,
WebGestureDevice source_device = WebGestureDevice::kTouchscreen) {
- WebGestureEvent fling_start(WebInputEvent::kGestureFlingStart, modifiers,
- event_time_, source_device);
+ WebGestureEvent fling_start(WebInputEvent::Type::kGestureFlingStart,
+ modifiers, event_time_, source_device);
fling_start.data.fling_start.velocity_x = velocity.x();
fling_start.data.fling_start.velocity_y = velocity.y();
return fling_start;
@@ -45,7 +45,7 @@ class FlingBoosterTest : public testing::Test {
WebGestureEvent CreateFlingCancel(
WebGestureDevice source_device = WebGestureDevice::kTouchscreen) {
- WebGestureEvent fling_cancel(WebInputEvent::kGestureFlingCancel, 0,
+ WebGestureEvent fling_cancel(WebInputEvent::Type::kGestureFlingCancel, 0,
event_time_, source_device);
return fling_cancel;
}
@@ -53,7 +53,7 @@ class FlingBoosterTest : public testing::Test {
WebGestureEvent CreateScrollBegin(
gfx::Vector2dF delta,
WebGestureDevice source_device = WebGestureDevice::kTouchscreen) {
- WebGestureEvent scroll_begin(WebInputEvent::kGestureScrollBegin, 0,
+ WebGestureEvent scroll_begin(WebInputEvent::Type::kGestureScrollBegin, 0,
event_time_, source_device);
scroll_begin.data.scroll_begin.delta_x_hint = delta.x();
scroll_begin.data.scroll_begin.delta_y_hint = delta.y();
@@ -65,7 +65,7 @@ class FlingBoosterTest : public testing::Test {
WebGestureEvent CreateScrollUpdate(
gfx::Vector2dF delta,
WebGestureDevice source_device = WebGestureDevice::kTouchscreen) {
- WebGestureEvent scroll_update(WebInputEvent::kGestureScrollUpdate, 0,
+ WebGestureEvent scroll_update(WebInputEvent::Type::kGestureScrollUpdate, 0,
event_time_, source_device);
scroll_update.data.scroll_update.delta_x = delta.x();
scroll_update.data.scroll_update.delta_y = delta.y();
@@ -76,8 +76,8 @@ class FlingBoosterTest : public testing::Test {
WebGestureEvent CreateScrollEnd(
WebGestureDevice source_device = WebGestureDevice::kTouchscreen) {
- return WebGestureEvent(WebInputEvent::kGestureScrollEnd, 0, event_time_,
- source_device);
+ return WebGestureEvent(WebInputEvent::Type::kGestureScrollEnd, 0,
+ event_time_, source_device);
}
Vector2dF DeltaFromVelocity(Vector2dF velocity, TimeDelta delta) {
@@ -88,7 +88,7 @@ class FlingBoosterTest : public testing::Test {
}
Vector2dF SendFlingStart(WebGestureEvent event) {
- DCHECK_EQ(WebInputEvent::kGestureFlingStart, event.GetType());
+ DCHECK_EQ(WebInputEvent::Type::kGestureFlingStart, event.GetType());
// The event will first be observed, then the FlingController will request
// a possibly boosted velocity.
diff --git a/chromium/ui/events/blink/input_handler_proxy.cc b/chromium/ui/events/blink/input_handler_proxy.cc
deleted file mode 100644
index d30ac0c899b..00000000000
--- a/chromium/ui/events/blink/input_handler_proxy.cc
+++ /dev/null
@@ -1,1298 +0,0 @@
-// Copyright 2013 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 "ui/events/blink/input_handler_proxy.h"
-
-#include <stddef.h>
-
-#include <algorithm>
-
-#include "base/auto_reset.h"
-#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/location.h"
-#include "base/logging.h"
-#include "base/metrics/field_trial_params.h"
-#include "base/metrics/histogram_macros.h"
-#include "base/profiler/sample_metadata.h"
-#include "base/single_thread_task_runner.h"
-#include "base/threading/thread_task_runner_handle.h"
-#include "base/time/default_tick_clock.h"
-#include "base/trace_event/trace_event.h"
-#include "build/build_config.h"
-#include "cc/input/main_thread_scrolling_reason.h"
-#include "cc/input/scroll_input_type.h"
-#include "cc/metrics/event_metrics.h"
-#include "services/tracing/public/cpp/perfetto/flow_event_utils.h"
-#include "services/tracing/public/cpp/perfetto/macros.h"
-#include "third_party/blink/public/common/input/web_input_event.h"
-#include "third_party/blink/public/common/input/web_input_event_attribution.h"
-#include "third_party/blink/public/common/input/web_mouse_wheel_event.h"
-#include "third_party/blink/public/common/input/web_pointer_event.h"
-#include "third_party/blink/public/common/input/web_touch_event.h"
-#include "ui/events/blink/blink_event_util.h"
-#include "ui/events/blink/compositor_thread_event_queue.h"
-#include "ui/events/blink/did_overscroll_params.h"
-#include "ui/events/blink/event_with_callback.h"
-#include "ui/events/blink/input_handler_proxy_client.h"
-#include "ui/events/blink/input_scroll_elasticity_controller.h"
-#include "ui/events/blink/momentum_scroll_jank_tracker.h"
-#include "ui/events/blink/scroll_predictor.h"
-#include "ui/events/blink/web_input_event_traits.h"
-#include "ui/gfx/geometry/point_conversions.h"
-#include "ui/latency/latency_info.h"
-
-using blink::WebGestureEvent;
-using blink::WebInputEvent;
-using blink::WebMouseEvent;
-using blink::WebMouseWheelEvent;
-using blink::WebTouchEvent;
-using blink::WebTouchPoint;
-using perfetto::protos::pbzero::ChromeLatencyInfo;
-using perfetto::protos::pbzero::TrackEvent;
-
-namespace {
-
-const int32_t kEventDispositionUndefined = -1;
-
-cc::ScrollState CreateScrollStateForGesture(const WebGestureEvent& event) {
- cc::ScrollStateData scroll_state_data;
- switch (event.GetType()) {
- case WebInputEvent::kGestureScrollBegin:
- scroll_state_data.position_x = event.PositionInWidget().x();
- scroll_state_data.position_y = event.PositionInWidget().y();
- scroll_state_data.delta_x_hint = -event.data.scroll_begin.delta_x_hint;
- scroll_state_data.delta_y_hint = -event.data.scroll_begin.delta_y_hint;
- scroll_state_data.is_beginning = true;
- // On Mac, a GestureScrollBegin in the inertial phase indicates a fling
- // start.
- scroll_state_data.is_in_inertial_phase =
- (event.data.scroll_begin.inertial_phase ==
- WebGestureEvent::InertialPhaseState::kMomentum);
- scroll_state_data.delta_granularity =
- event.data.scroll_begin.delta_hint_units;
- break;
- case WebInputEvent::kGestureScrollUpdate:
- scroll_state_data.delta_x = -event.data.scroll_update.delta_x;
- scroll_state_data.delta_y = -event.data.scroll_update.delta_y;
- scroll_state_data.velocity_x = event.data.scroll_update.velocity_x;
- scroll_state_data.velocity_y = event.data.scroll_update.velocity_y;
- scroll_state_data.is_in_inertial_phase =
- event.data.scroll_update.inertial_phase ==
- WebGestureEvent::InertialPhaseState::kMomentum;
- scroll_state_data.delta_granularity =
- event.data.scroll_update.delta_units;
- break;
- case WebInputEvent::kGestureScrollEnd:
- scroll_state_data.is_ending = true;
- break;
- default:
- NOTREACHED();
- break;
- }
- scroll_state_data.is_direct_manipulation =
- event.SourceDevice() == blink::WebGestureDevice::kTouchscreen;
- return cc::ScrollState(scroll_state_data);
-}
-
-cc::ScrollState CreateScrollStateForInertialUpdate(
- const gfx::Vector2dF& delta) {
- cc::ScrollStateData scroll_state_data;
- scroll_state_data.delta_x = delta.x();
- scroll_state_data.delta_y = delta.y();
- scroll_state_data.is_in_inertial_phase = true;
- return cc::ScrollState(scroll_state_data);
-}
-
-cc::ScrollInputType GestureScrollInputType(blink::WebGestureDevice device) {
- switch (device) {
- case blink::WebGestureDevice::kTouchpad:
- return cc::ScrollInputType::kWheel;
- case blink::WebGestureDevice::kTouchscreen:
- return cc::ScrollInputType::kTouchscreen;
- case blink::WebGestureDevice::kSyntheticAutoscroll:
- return cc::ScrollInputType::kAutoscroll;
- case blink::WebGestureDevice::kScrollbar:
- return cc::ScrollInputType::kScrollbar;
- case blink::WebGestureDevice::kUninitialized:
- NOTREACHED();
- return cc::ScrollInputType::kMaxValue;
- }
-}
-
-cc::SnapFlingController::GestureScrollType GestureScrollEventType(
- WebInputEvent::Type web_event_type) {
- switch (web_event_type) {
- case WebInputEvent::kGestureScrollBegin:
- return cc::SnapFlingController::GestureScrollType::kBegin;
- case WebInputEvent::kGestureScrollUpdate:
- return cc::SnapFlingController::GestureScrollType::kUpdate;
- case WebInputEvent::kGestureScrollEnd:
- return cc::SnapFlingController::GestureScrollType::kEnd;
- default:
- NOTREACHED();
- return cc::SnapFlingController::GestureScrollType::kBegin;
- }
-}
-
-cc::SnapFlingController::GestureScrollUpdateInfo GetGestureScrollUpdateInfo(
- const WebGestureEvent& event) {
- cc::SnapFlingController::GestureScrollUpdateInfo info;
- info.delta = gfx::Vector2dF(-event.data.scroll_update.delta_x,
- -event.data.scroll_update.delta_y);
- info.is_in_inertial_phase =
- event.data.scroll_update.inertial_phase ==
- blink::WebGestureEvent::InertialPhaseState::kMomentum;
- info.event_time = event.TimeStamp();
- return info;
-}
-
-cc::ScrollBeginThreadState RecordScrollingThread(
- bool scrolling_on_compositor_thread,
- bool blocked_on_main_thread_event_handler,
- blink::WebGestureDevice device) {
- const char* kWheelHistogramName = "Renderer4.ScrollingThread.Wheel";
- const char* kTouchHistogramName = "Renderer4.ScrollingThread.Touch";
-
- auto status = cc::ScrollBeginThreadState::kScrollingOnMain;
- if (scrolling_on_compositor_thread) {
- status =
- blocked_on_main_thread_event_handler
- ? cc::ScrollBeginThreadState::kScrollingOnCompositorBlockedOnMain
- : cc::ScrollBeginThreadState::kScrollingOnCompositor;
- }
-
- if (device == blink::WebGestureDevice::kTouchscreen) {
- UMA_HISTOGRAM_ENUMERATION(kTouchHistogramName, status);
- } else if (device == blink::WebGestureDevice::kTouchpad) {
- UMA_HISTOGRAM_ENUMERATION(kWheelHistogramName, status);
- } else {
- NOTREACHED();
- }
- return status;
-}
-
-} // namespace
-
-namespace ui {
-
-InputHandlerProxy::InputHandlerProxy(cc::InputHandler* input_handler,
- InputHandlerProxyClient* client,
- bool force_input_to_main_thread)
- : client_(client),
- input_handler_(input_handler),
- synchronous_input_handler_(nullptr),
- handling_gesture_on_impl_thread_(false),
- scroll_sequence_ignored_(false),
- touch_result_(kEventDispositionUndefined),
- mouse_wheel_result_(kEventDispositionUndefined),
- current_overscroll_params_(nullptr),
- has_seen_first_gesture_scroll_update_after_begin_(false),
- last_injected_gesture_was_begin_(false),
- tick_clock_(base::DefaultTickClock::GetInstance()),
- snap_fling_controller_(std::make_unique<cc::SnapFlingController>(this)),
- compositor_touch_action_enabled_(
- base::FeatureList::IsEnabled(features::kCompositorTouchAction)),
- force_input_to_main_thread_(force_input_to_main_thread) {
- DCHECK(client);
- input_handler_->BindToClient(this);
- cc::ScrollElasticityHelper* scroll_elasticity_helper =
- input_handler_->CreateScrollElasticityHelper();
- if (scroll_elasticity_helper) {
- scroll_elasticity_controller_.reset(
- new InputScrollElasticityController(scroll_elasticity_helper));
- }
- compositor_event_queue_ = std::make_unique<CompositorThreadEventQueue>();
- scroll_predictor_ =
- base::FeatureList::IsEnabled(features::kResamplingScrollEvents)
- ? std::make_unique<ScrollPredictor>()
- : nullptr;
-
- if (base::FeatureList::IsEnabled(features::kSkipTouchEventFilter) &&
- GetFieldTrialParamValueByFeature(
- features::kSkipTouchEventFilter,
- features::kSkipTouchEventFilterFilteringProcessParamName) ==
- features::
- kSkipTouchEventFilterFilteringProcessParamValueBrowserAndRenderer) {
- // Skipping filtering for touch events on renderer process is enabled.
- // Always skip filtering discrete events.
- skip_touch_filter_discrete_ = true;
- if (GetFieldTrialParamValueByFeature(
- features::kSkipTouchEventFilter,
- features::kSkipTouchEventFilterTypeParamName) ==
- features::kSkipTouchEventFilterTypeParamValueAll) {
- // The experiment config also specifies to skip touchmove events.
- skip_touch_filter_all_ = true;
- }
- }
-}
-
-InputHandlerProxy::~InputHandlerProxy() {}
-
-void InputHandlerProxy::WillShutdown() {
- scroll_elasticity_controller_.reset();
- input_handler_ = NULL;
- client_->WillShutdown();
-}
-
-void InputHandlerProxy::HandleInputEventWithLatencyInfo(
- WebScopedInputEvent event,
- const LatencyInfo& latency_info,
- EventDispositionCallback callback) {
- DCHECK(input_handler_);
-
- TRACE_EVENT("input,benchmark", "LatencyInfo.Flow",
- [&latency_info](perfetto::EventContext ctx) {
- ChromeLatencyInfo* info =
- ctx.event()->set_chrome_latency_info();
- info->set_trace_id(latency_info.trace_id());
- info->set_step(ChromeLatencyInfo::STEP_HANDLE_INPUT_EVENT_IMPL);
- tracing::FillFlowEvent(ctx, TrackEvent::LegacyEvent::FLOW_INOUT,
- latency_info.trace_id());
- });
-
- std::unique_ptr<EventWithCallback> event_with_callback =
- std::make_unique<EventWithCallback>(std::move(event), latency_info,
- tick_clock_->NowTicks(),
- std::move(callback));
-
- enum {
- NO_SCROLL_PINCH = 0,
- ONGOING_SCROLL_PINCH = 1,
- SCROLL_PINCH = 2,
- };
- // Note: Other input can race ahead of gesture input as they don't have to go
- // through the queue, but we believe it's OK to do so.
- if (!IsGestureScrollOrPinch(event_with_callback->event().GetType())) {
- base::ScopedSampleMetadata metadata("Input.GestureScrollOrPinch",
- NO_SCROLL_PINCH);
- DispatchSingleInputEvent(std::move(event_with_callback),
- tick_clock_->NowTicks());
- return;
- }
-
- base::ScopedSampleMetadata metadata(
- "Input.GestureScrollOrPinch", currently_active_gesture_device_.has_value()
- ? ONGOING_SCROLL_PINCH
- : SCROLL_PINCH);
- const auto& gesture_event = ToWebGestureEvent(event_with_callback->event());
- const bool is_first_gesture_scroll_update =
- !has_seen_first_gesture_scroll_update_after_begin_ &&
- gesture_event.GetType() == blink::WebGestureEvent::kGestureScrollUpdate;
-
- if (gesture_event.GetType() == blink::WebGestureEvent::kGestureScrollBegin) {
- has_seen_first_gesture_scroll_update_after_begin_ = false;
- } else if (gesture_event.GetType() ==
- blink::WebGestureEvent::kGestureScrollUpdate) {
- has_seen_first_gesture_scroll_update_after_begin_ = true;
- }
-
- if (currently_active_gesture_device_.has_value()) {
- bool is_from_set_non_blocking_touch =
- gesture_event.SourceDevice() == blink::WebGestureDevice::kTouchscreen &&
- gesture_event.is_source_touch_event_set_non_blocking;
- bool is_scroll_end_from_wheel =
- gesture_event.SourceDevice() == blink::WebGestureDevice::kTouchpad &&
- gesture_event.GetType() == blink::WebGestureEvent::kGestureScrollEnd;
- bool scroll_update_has_blocking_wheel_source =
- gesture_event.SourceDevice() == blink::WebGestureDevice::kTouchpad &&
- is_first_gesture_scroll_update;
-
- if (is_from_set_non_blocking_touch || is_scroll_end_from_wheel ||
- scroll_update_has_blocking_wheel_source || synchronous_input_handler_) {
- // 1. Gesture events was already delayed by blocking events in rAF aligned
- // queue. We want to avoid additional one frame delay by flushing the
- // VSync queue immediately.
- // The first GSU latency was tracked by:
- // |smoothness.tough_scrolling_cases:first_gesture_scroll_update_latency|.
- // 2. |synchronous_input_handler_| is WebView only. WebView has different
- // mechanisms and we want to forward all events immediately.
- compositor_event_queue_->Queue(std::move(event_with_callback),
- tick_clock_->NowTicks());
- DispatchQueuedInputEvents();
- return;
- }
-
- bool needs_animate_input = compositor_event_queue_->empty();
- compositor_event_queue_->Queue(std::move(event_with_callback),
- tick_clock_->NowTicks());
- if (needs_animate_input)
- input_handler_->SetNeedsAnimateInput();
- return;
- }
-
- // We have to dispatch the event to know whether the gesture sequence will be
- // handled by the compositor or not.
- DispatchSingleInputEvent(std::move(event_with_callback),
- tick_clock_->NowTicks());
-}
-
-void InputHandlerProxy::DispatchSingleInputEvent(
- std::unique_ptr<EventWithCallback> event_with_callback,
- const base::TimeTicks now) {
- const ui::LatencyInfo& original_latency_info =
- event_with_callback->latency_info();
- ui::LatencyInfo monitored_latency_info = original_latency_info;
- std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor =
- input_handler_->CreateLatencyInfoSwapPromiseMonitor(
- &monitored_latency_info);
- auto scoped_event_metrics_monitor =
- input_handler_->GetScopedEventMetricsMonitor(
- {WebEventTypeToEventType(event_with_callback->event().GetType()),
- event_with_callback->event().TimeStamp(),
- GetScrollInputTypeForEvent(event_with_callback->event())});
-
- current_overscroll_params_.reset();
-
- blink::WebInputEventAttribution attribution =
- PerformEventAttribution(event_with_callback->event());
- InputHandlerProxy::EventDisposition disposition = RouteToTypeSpecificHandler(
- event_with_callback.get(), original_latency_info, attribution);
-
- const blink::WebInputEvent& event = event_with_callback->event();
- const blink::WebGestureEvent::Type type = event.GetType();
- switch (type) {
- case blink::WebGestureEvent::kGestureScrollBegin:
- case blink::WebGestureEvent::kGesturePinchBegin:
- if (disposition == DID_HANDLE || disposition == DID_HANDLE_SHOULD_BUBBLE)
- currently_active_gesture_device_ =
- static_cast<const WebGestureEvent&>(event).SourceDevice();
- break;
-
- case blink::WebGestureEvent::kGestureScrollEnd:
- case blink::WebGestureEvent::kGesturePinchEnd:
- if (!handling_gesture_on_impl_thread_)
- currently_active_gesture_device_ = base::nullopt;
- break;
- default:
- break;
- }
-
- // Handle jank tracking during the momentum phase of a scroll gesture. The
- // class filters non-momentum events internally.
- switch (type) {
- case blink::WebGestureEvent::kGestureScrollBegin:
- momentum_scroll_jank_tracker_ =
- std::make_unique<MomentumScrollJankTracker>();
- break;
- case blink::WebGestureEvent::kGestureScrollUpdate:
- // It's possible to get a scroll update without a begin. Ignore these
- // cases.
- if (momentum_scroll_jank_tracker_) {
- momentum_scroll_jank_tracker_->OnDispatchedInputEvent(
- event_with_callback.get(), now);
- }
- break;
- case blink::WebGestureEvent::kGestureScrollEnd:
- momentum_scroll_jank_tracker_.reset();
- break;
- default:
- break;
- }
-
- // Will run callback for every original events.
- event_with_callback->RunCallbacks(disposition, monitored_latency_info,
- std::move(current_overscroll_params_),
- attribution);
-}
-
-void InputHandlerProxy::DispatchQueuedInputEvents() {
- // Calling |NowTicks()| is expensive so we only want to do it once.
- base::TimeTicks now = tick_clock_->NowTicks();
- while (!compositor_event_queue_->empty())
- DispatchSingleInputEvent(compositor_event_queue_->Pop(), now);
-}
-
-// This function handles creating synthetic Gesture events. It is currently used
-// for creating Gesture event equivalents for mouse events on a composited
-// scrollbar. (See InputHandlerProxy::HandleInputEvent)
-void InputHandlerProxy::InjectScrollbarGestureScroll(
- const WebInputEvent::Type type,
- const gfx::PointF& position_in_widget,
- const cc::InputHandlerPointerResult& pointer_result,
- const LatencyInfo& latency_info,
- const base::TimeTicks original_timestamp) {
- gfx::Vector2dF scroll_delta(pointer_result.scroll_offset.x(),
- pointer_result.scroll_offset.y());
-
- std::unique_ptr<WebGestureEvent> synthetic_gesture_event =
- GenerateInjectedScrollGesture(
- type, original_timestamp, blink::WebGestureDevice::kScrollbar,
- position_in_widget, scroll_delta, pointer_result.scroll_units);
-
- // This will avoid hit testing and directly scroll the scroller with the
- // provided element_id.
- if (type == WebInputEvent::Type::kGestureScrollBegin)
- synthetic_gesture_event->data.scroll_begin.scrollable_area_element_id =
- pointer_result.target_scroller.GetStableId();
-
- WebScopedInputEvent web_scoped_gesture_event(
- synthetic_gesture_event.release());
-
- // Send in a LatencyInfo with SCROLLBAR type so that the end to end latency
- // is calculated specifically for scrollbars.
- LatencyInfo scrollbar_latency_info(latency_info);
- scrollbar_latency_info.set_source_event_type(ui::SourceEventType::SCROLLBAR);
-
- // This latency_info should not have already been scheduled for rendering -
- // i.e. it should be the original latency_info that was associated with the
- // input event that caused this scroll injection. If it has already been
- // scheduled it won't get queued to be shipped off with the CompositorFrame
- // when the gesture is handled.
- DCHECK(!scrollbar_latency_info.FindLatency(
- ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT, nullptr));
-
- if (type == WebInputEvent::Type::kGestureScrollBegin) {
- last_injected_gesture_was_begin_ = true;
- } else {
- if (type == WebInputEvent::Type::kGestureScrollUpdate) {
- // For injected GSUs, add a scroll update component to the latency info
- // so that it is properly classified as a scroll. If the last injected
- // gesture was a GSB, then this GSU is the first scroll update - mark
- // the LatencyInfo as such.
- scrollbar_latency_info.AddLatencyNumberWithTimestamp(
- (last_injected_gesture_was_begin_)
- ? ui::INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT
- : ui::INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT,
- original_timestamp);
- }
-
- last_injected_gesture_was_begin_ = false;
- }
-
- std::unique_ptr<EventWithCallback> gesture_event_with_callback_update =
- std::make_unique<EventWithCallback>(
- std::move(web_scoped_gesture_event), scrollbar_latency_info,
- original_timestamp, original_timestamp, nullptr);
-
- bool needs_animate_input = compositor_event_queue_->empty();
- compositor_event_queue_->Queue(std::move(gesture_event_with_callback_update),
- original_timestamp);
-
- if (needs_animate_input)
- input_handler_->SetNeedsAnimateInput();
-}
-
-bool HasModifier(const WebInputEvent& event) {
-#if defined(OS_MACOSX)
- // Mac uses the "Option" key (which is mapped to the enum "kAltKey").
- return event.GetModifiers() & WebInputEvent::kAltKey;
-#else
- return event.GetModifiers() & WebInputEvent::kShiftKey;
-#endif
-}
-
-InputHandlerProxy::EventDisposition
-InputHandlerProxy::RouteToTypeSpecificHandler(
- EventWithCallback* event_with_callback,
- const LatencyInfo& original_latency_info,
- const blink::WebInputEventAttribution& original_attribution) {
- DCHECK(input_handler_);
-
- if (force_input_to_main_thread_)
- return DID_NOT_HANDLE;
-
- const blink::WebInputEvent& event = event_with_callback->event();
- if (IsGestureScroll(event.GetType()) &&
- (snap_fling_controller_->FilterEventForSnap(
- GestureScrollEventType(event.GetType())))) {
- return DROP_EVENT;
- }
-
- switch (event.GetType()) {
- case WebInputEvent::kMouseWheel:
- return HandleMouseWheel(static_cast<const WebMouseWheelEvent&>(event));
-
- case WebInputEvent::kGestureScrollBegin:
- return HandleGestureScrollBegin(
- static_cast<const WebGestureEvent&>(event));
-
- case WebInputEvent::kGestureScrollUpdate:
- return HandleGestureScrollUpdate(
- static_cast<const WebGestureEvent&>(event), original_attribution);
-
- case WebInputEvent::kGestureScrollEnd:
- return HandleGestureScrollEnd(static_cast<const WebGestureEvent&>(event));
-
- case WebInputEvent::kGesturePinchBegin: {
- DCHECK(!gesture_pinch_in_progress_);
- input_handler_->PinchGestureBegin();
- gesture_pinch_in_progress_ = true;
- return DID_HANDLE;
- }
-
- case WebInputEvent::kGesturePinchEnd: {
- DCHECK(gesture_pinch_in_progress_);
- gesture_pinch_in_progress_ = false;
- const WebGestureEvent& gesture_event =
- static_cast<const WebGestureEvent&>(event);
- input_handler_->PinchGestureEnd(
- gfx::ToFlooredPoint(gesture_event.PositionInWidget()),
- gesture_event.SourceDevice() == blink::WebGestureDevice::kTouchpad);
- return DID_HANDLE;
- }
-
- case WebInputEvent::kGesturePinchUpdate: {
- DCHECK(gesture_pinch_in_progress_);
- const WebGestureEvent& gesture_event =
- static_cast<const WebGestureEvent&>(event);
- input_handler_->PinchGestureUpdate(
- gesture_event.data.pinch_update.scale,
- gfx::ToFlooredPoint(gesture_event.PositionInWidget()));
- return DID_HANDLE;
- }
-
- case WebInputEvent::kTouchStart:
- return HandleTouchStart(static_cast<const WebTouchEvent&>(event));
-
- case WebInputEvent::kTouchMove:
- return HandleTouchMove(static_cast<const WebTouchEvent&>(event));
-
- case WebInputEvent::kTouchEnd:
- return HandleTouchEnd(static_cast<const WebTouchEvent&>(event));
-
- case WebInputEvent::kMouseDown: {
- // Only for check scrollbar captured
- const WebMouseEvent& mouse_event =
- static_cast<const WebMouseEvent&>(event);
-
- if (mouse_event.button == blink::WebMouseEvent::Button::kLeft) {
- CHECK(input_handler_);
- // TODO(arakeri): Pass in the modifier instead of a bool once the
- // refactor (crbug.com/1022097) is done. For details, see
- // crbug.com/1016955.
- cc::InputHandlerPointerResult pointer_result =
- input_handler_->MouseDown(
- gfx::PointF(mouse_event.PositionInWidget()),
- HasModifier(event));
- if (pointer_result.type == cc::PointerResultType::kScrollbarScroll) {
- // Since a kScrollbarScroll is about to commence, ensure that any
- // existing ongoing scroll is ended.
- if (currently_active_gesture_device_.has_value()) {
- DCHECK_NE(*currently_active_gesture_device_,
- blink::WebGestureDevice::kUninitialized);
- if (gesture_pinch_in_progress_)
- input_handler_->PinchGestureEnd(
- gfx::ToFlooredPoint(mouse_event.PositionInWidget()), true);
- if (handling_gesture_on_impl_thread_) {
- input_handler_->RecordScrollEnd(
- GestureScrollInputType(*currently_active_gesture_device_));
- InputHandlerScrollEnd();
- }
- }
-
- // Generate GSB and GSU events and add them to the
- // CompositorThreadEventQueue.
- // Note that the latency info passed in to
- // InjectScrollbarGestureScroll is the original LatencyInfo, not the
- // one that may be currently monitored. The currently monitored one
- // may be modified by the call to InjectScrollbarGestureScroll, as
- // it will SetNeedsAnimateInput if the CompositorThreadEventQueue is
- // currently empty.
- InjectScrollbarGestureScroll(WebInputEvent::Type::kGestureScrollBegin,
- mouse_event.PositionInWidget(),
- pointer_result, original_latency_info,
- mouse_event.TimeStamp());
-
- // Don't need to inject GSU if the scroll offset is zero (this can
- // be the case where mouse down occurs on the thumb).
- if (!pointer_result.scroll_offset.IsZero()) {
- InjectScrollbarGestureScroll(
- WebInputEvent::Type::kGestureScrollUpdate,
- mouse_event.PositionInWidget(), pointer_result,
- original_latency_info, mouse_event.TimeStamp());
- }
-
- if (event_with_callback) {
- event_with_callback
- ->SetScrollbarManipulationHandledOnCompositorThread();
- }
- }
- }
-
- return DID_NOT_HANDLE;
- }
- case WebInputEvent::kMouseUp: {
- // Only for release scrollbar captured
- const WebMouseEvent& mouse_event =
- static_cast<const WebMouseEvent&>(event);
-
- if (mouse_event.button == blink::WebMouseEvent::Button::kLeft) {
- CHECK(input_handler_);
- cc::InputHandlerPointerResult pointer_result = input_handler_->MouseUp(
- gfx::PointF(mouse_event.PositionInWidget()));
- if (pointer_result.type == cc::PointerResultType::kScrollbarScroll) {
- // Generate a GSE and add it to the CompositorThreadEventQueue.
- InjectScrollbarGestureScroll(WebInputEvent::Type::kGestureScrollEnd,
- mouse_event.PositionInWidget(),
- pointer_result, original_latency_info,
- mouse_event.TimeStamp());
-
- if (event_with_callback) {
- event_with_callback
- ->SetScrollbarManipulationHandledOnCompositorThread();
- }
- }
- }
- return DID_NOT_HANDLE;
- }
- case WebInputEvent::kMouseMove: {
- const WebMouseEvent& mouse_event =
- static_cast<const WebMouseEvent&>(event);
- // TODO(davemoore): This should never happen, but bug #326635 showed some
- // surprising crashes.
- CHECK(input_handler_);
- cc::InputHandlerPointerResult pointer_result =
- input_handler_->MouseMoveAt(
- gfx::Point(mouse_event.PositionInWidget().x(),
- mouse_event.PositionInWidget().y()));
- if (pointer_result.type == cc::PointerResultType::kScrollbarScroll) {
- // Generate a GSU event and add it to the CompositorThreadEventQueue if
- // delta is non zero.
- if (!pointer_result.scroll_offset.IsZero()) {
- InjectScrollbarGestureScroll(
- WebInputEvent::Type::kGestureScrollUpdate,
- mouse_event.PositionInWidget(), pointer_result,
- original_latency_info, mouse_event.TimeStamp());
- }
-
- if (event_with_callback) {
- event_with_callback
- ->SetScrollbarManipulationHandledOnCompositorThread();
- }
- }
- return DID_NOT_HANDLE;
- }
- case WebInputEvent::kMouseLeave: {
- CHECK(input_handler_);
- input_handler_->MouseLeave();
- return DID_NOT_HANDLE;
- }
- // Fling gestures are handled only in the browser process and not sent to
- // the renderer.
- case WebInputEvent::kGestureFlingStart:
- case WebInputEvent::kGestureFlingCancel:
- NOTREACHED();
- break;
-
- default:
- break;
- }
-
- return DID_NOT_HANDLE;
-}
-
-blink::WebInputEventAttribution InputHandlerProxy::PerformEventAttribution(
- const blink::WebInputEvent& event) {
- if (blink::WebInputEvent::IsKeyboardEventType(event.GetType())) {
- // Keyboard events should be dispatched to the focused frame.
- return blink::WebInputEventAttribution(
- blink::WebInputEventAttribution::kFocusedFrame);
- } else if (blink::WebInputEvent::IsMouseEventType(event.GetType()) ||
- event.GetType() == WebInputEvent::kMouseWheel) {
- // Mouse events are dispatched based on their location in the DOM tree.
- // Perform frame attribution via cc.
- // TODO(acomminos): handle pointer locks, or provide a hint to the renderer
- // to check pointer lock state
- gfx::PointF point =
- static_cast<const WebMouseEvent&>(event).PositionInWidget();
- return blink::WebInputEventAttribution(
- blink::WebInputEventAttribution::kTargetedFrame,
- input_handler_->FindFrameElementIdAtPoint(point));
- } else {
- // TODO(acomminos): implement for more event types (pointer, touch)
- return blink::WebInputEventAttribution(
- blink::WebInputEventAttribution::kUnknown);
- }
-}
-
-void InputHandlerProxy::RecordMainThreadScrollingReasons(
- blink::WebGestureDevice device,
- uint32_t reasons) {
- static const char* kGestureHistogramName =
- "Renderer4.MainThreadGestureScrollReason";
- static const char* kWheelHistogramName =
- "Renderer4.MainThreadWheelScrollReason";
-
- if (device != blink::WebGestureDevice::kTouchpad &&
- device != blink::WebGestureDevice::kTouchscreen) {
- return;
- }
-
- // NonCompositedScrollReasons should only be set on the main thread.
- DCHECK(
- !cc::MainThreadScrollingReason::HasNonCompositedScrollReasons(reasons));
-
- // This records whether a scroll is handled on the main or compositor
- // threads. Note: scrolls handled on the compositor but blocked on main due
- // to event handlers are still considered compositor scrolls.
- const bool is_compositor_scroll =
- reasons == cc::MainThreadScrollingReason::kNotScrollingOnMain;
-
- int32_t disposition =
- (device == blink::WebGestureDevice::kTouchpad ? mouse_wheel_result_
- : touch_result_);
-
- // Scrolling can be handled on the compositor thread but it might be blocked
- // on the main thread waiting for non-passive event handlers to process the
- // wheel/touch events (i.e. were they preventDefaulted?).
- bool blocked_on_main_thread_handler = disposition == DID_NOT_HANDLE;
-
- auto scroll_start_state = RecordScrollingThread(
- is_compositor_scroll, blocked_on_main_thread_handler, device);
- input_handler_->RecordScrollBegin(GestureScrollInputType(device),
- scroll_start_state);
-
- if (blocked_on_main_thread_handler) {
- // We should also collect main thread scrolling reasons if a scroll event
- // scrolls on impl thread but is blocked by main thread event handlers.
- reasons |= (device == blink::WebGestureDevice::kTouchpad
- ? cc::MainThreadScrollingReason::kWheelEventHandlerRegion
- : cc::MainThreadScrollingReason::kTouchEventHandlerRegion);
- }
-
- // Note: This is slightly different from |is_compositor_scroll| above because
- // at this point, we've also included wheel handler region reasons which will
- // scroll on the compositor but require blocking on the main thread. The
- // histograms below don't consider this "not scrolling on main".
- const bool is_unblocked_compositor_scroll =
- reasons == cc::MainThreadScrollingReason::kNotScrollingOnMain;
-
- // UMA_HISTOGRAM_ENUMERATION requires that the enum_max must be strictly
- // greater than the sample value. kMainThreadScrollingReasonCount doesn't
- // include the NotScrollingOnMain enum but the histograms do so adding
- // the +1 is necessary.
- // TODO(dcheng): Fix https://crbug.com/705169 so this isn't needed.
- constexpr uint32_t kMainThreadScrollingReasonEnumMax =
- cc::MainThreadScrollingReason::kMainThreadScrollingReasonCount + 1;
- if (is_unblocked_compositor_scroll) {
- if (device == blink::WebGestureDevice::kTouchscreen) {
- UMA_HISTOGRAM_ENUMERATION(
- kGestureHistogramName,
- cc::MainThreadScrollingReason::kNotScrollingOnMain,
- kMainThreadScrollingReasonEnumMax);
- } else {
- UMA_HISTOGRAM_ENUMERATION(
- kWheelHistogramName,
- cc::MainThreadScrollingReason::kNotScrollingOnMain,
- kMainThreadScrollingReasonEnumMax);
- }
- }
-
- for (uint32_t i = 0;
- i < cc::MainThreadScrollingReason::kMainThreadScrollingReasonCount;
- ++i) {
- unsigned val = 1 << i;
- if (reasons & val) {
- if (val == cc::MainThreadScrollingReason::kHandlingScrollFromMainThread) {
- // We only want to record "Handling scroll from main thread" reason if
- // it's the only reason. If it's not the only reason, the "real" reason
- // for scrolling on main is something else, and we only want to pay
- // attention to that reason.
- if (reasons & ~val)
- continue;
- }
- if (device == blink::WebGestureDevice::kTouchscreen) {
- UMA_HISTOGRAM_ENUMERATION(kGestureHistogramName, i + 1,
- kMainThreadScrollingReasonEnumMax);
- } else {
- UMA_HISTOGRAM_ENUMERATION(kWheelHistogramName, i + 1,
- kMainThreadScrollingReasonEnumMax);
- }
- }
- }
-}
-
-InputHandlerProxy::EventDisposition InputHandlerProxy::HandleMouseWheel(
- const WebMouseWheelEvent& wheel_event) {
- InputHandlerProxy::EventDisposition result = DROP_EVENT;
-
- if (wheel_event.dispatch_type == WebInputEvent::kEventNonBlocking) {
- // The first wheel event in the sequence should be cancellable.
- DCHECK(wheel_event.phase != WebMouseWheelEvent::kPhaseBegan);
- // Noncancellable wheel events should have phase info.
- DCHECK(wheel_event.phase != WebMouseWheelEvent::kPhaseNone ||
- wheel_event.momentum_phase != WebMouseWheelEvent::kPhaseNone);
-
- result = static_cast<EventDisposition>(mouse_wheel_result_);
-
- if (wheel_event.phase == WebMouseWheelEvent::kPhaseEnded ||
- wheel_event.phase == WebMouseWheelEvent::kPhaseCancelled ||
- wheel_event.momentum_phase == WebMouseWheelEvent::kPhaseEnded ||
- wheel_event.momentum_phase == WebMouseWheelEvent::kPhaseCancelled) {
- mouse_wheel_result_ = kEventDispositionUndefined;
- }
- if (mouse_wheel_result_ != kEventDispositionUndefined)
- return result;
- }
-
- gfx::PointF position_in_widget = wheel_event.PositionInWidget();
- if (input_handler_->HasBlockingWheelEventHandlerAt(
- gfx::Point(position_in_widget.x(), position_in_widget.y()))) {
- result = DID_NOT_HANDLE;
- } else {
- cc::EventListenerProperties properties =
- input_handler_->GetEventListenerProperties(
- cc::EventListenerClass::kMouseWheel);
- switch (properties) {
- case cc::EventListenerProperties::kBlockingAndPassive:
- case cc::EventListenerProperties::kPassive:
- result = DID_HANDLE_NON_BLOCKING;
- break;
- case cc::EventListenerProperties::kNone:
- result = DROP_EVENT;
- break;
- default:
- // If properties is kBlocking, and the event falls outside wheel event
- // handler region, we should handle it the same as kNone.
- result = DROP_EVENT;
- }
- }
-
- mouse_wheel_result_ = result;
- return result;
-}
-
-InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollBegin(
- const WebGestureEvent& gesture_event) {
- TRACE_EVENT0("input", "InputHandlerProxy::HandleGestureScrollBegin");
-
- if (scroll_predictor_)
- scroll_predictor_->ResetOnGestureScrollBegin(gesture_event);
-
- cc::ScrollState scroll_state = CreateScrollStateForGesture(gesture_event);
- cc::InputHandler::ScrollStatus scroll_status;
- cc::ElementIdType element_id_type =
- gesture_event.data.scroll_begin.scrollable_area_element_id;
- if (element_id_type) {
- scroll_state.data()->set_current_native_scrolling_element(
- cc::ElementId(element_id_type));
- }
- if (gesture_event.data.scroll_begin.delta_hint_units ==
- ui::ScrollGranularity::kScrollByPage) {
- scroll_status.thread = cc::InputHandler::SCROLL_ON_MAIN_THREAD;
- scroll_status.main_thread_scrolling_reasons =
- cc::MainThreadScrollingReason::kContinuingMainThreadScroll;
- } else if (gesture_event.data.scroll_begin.target_viewport) {
- scroll_status = input_handler_->RootScrollBegin(
- &scroll_state, GestureScrollInputType(gesture_event.SourceDevice()));
- } else {
- scroll_status = input_handler_->ScrollBegin(
- &scroll_state, GestureScrollInputType(gesture_event.SourceDevice()));
- }
- RecordMainThreadScrollingReasons(gesture_event.SourceDevice(),
- scroll_status.main_thread_scrolling_reasons);
-
- InputHandlerProxy::EventDisposition result = DID_NOT_HANDLE;
- scroll_sequence_ignored_ = false;
- in_inertial_scrolling_ = false;
- switch (scroll_status.thread) {
- case cc::InputHandler::SCROLL_ON_IMPL_THREAD:
- TRACE_EVENT_INSTANT0("input", "Handle On Impl", TRACE_EVENT_SCOPE_THREAD);
- handling_gesture_on_impl_thread_ = true;
- if (input_handler_->IsCurrentlyScrollingViewport())
- client_->DidStartScrollingViewport();
-
- if (scroll_status.bubble)
- result = DID_HANDLE_SHOULD_BUBBLE;
- else
- result = DID_HANDLE;
- break;
- case cc::InputHandler::SCROLL_UNKNOWN:
- case cc::InputHandler::SCROLL_ON_MAIN_THREAD:
- TRACE_EVENT_INSTANT0("input", "Handle On Main", TRACE_EVENT_SCOPE_THREAD);
- result = DID_NOT_HANDLE;
- break;
- case cc::InputHandler::SCROLL_IGNORED:
- TRACE_EVENT_INSTANT0("input", "Ignore Scroll", TRACE_EVENT_SCOPE_THREAD);
- scroll_sequence_ignored_ = true;
- result = DROP_EVENT;
- break;
- }
- if (scroll_elasticity_controller_ && result != DID_NOT_HANDLE)
- HandleScrollElasticityOverscroll(gesture_event,
- cc::InputHandlerScrollResult());
-
- return result;
-}
-
-InputHandlerProxy::EventDisposition
-InputHandlerProxy::HandleGestureScrollUpdate(
- const WebGestureEvent& gesture_event,
- const blink::WebInputEventAttribution& original_attribution) {
- TRACE_EVENT2("input", "InputHandlerProxy::HandleGestureScrollUpdate", "dx",
- -gesture_event.data.scroll_update.delta_x, "dy",
- -gesture_event.data.scroll_update.delta_y);
-
- if (scroll_sequence_ignored_) {
- TRACE_EVENT_INSTANT0("input", "Scroll Sequence Ignored",
- TRACE_EVENT_SCOPE_THREAD);
- return DROP_EVENT;
- }
-
- if (!handling_gesture_on_impl_thread_ && !gesture_pinch_in_progress_)
- return DID_NOT_HANDLE;
-
- cc::ScrollState scroll_state = CreateScrollStateForGesture(gesture_event);
- in_inertial_scrolling_ = scroll_state.is_in_inertial_phase();
-
- TRACE_EVENT_INSTANT1(
- "input", "DeltaUnits", TRACE_EVENT_SCOPE_THREAD, "unit",
- static_cast<int>(gesture_event.data.scroll_update.delta_units));
-
- if (snap_fling_controller_->HandleGestureScrollUpdate(
- GetGestureScrollUpdateInfo(gesture_event))) {
- handling_gesture_on_impl_thread_ = false;
- return DROP_EVENT;
- }
-
- if (input_handler_->ScrollingShouldSwitchtoMainThread()) {
- TRACE_EVENT_INSTANT0("input", "Move Scroll To Main Thread",
- TRACE_EVENT_SCOPE_THREAD);
- handling_gesture_on_impl_thread_ = false;
- currently_active_gesture_device_ = base::nullopt;
- client_->GenerateScrollBeginAndSendToMainThread(gesture_event,
- original_attribution);
-
- // TODO(bokan): |!gesture_pinch_in_progress_| was put here by
- // https://crrev.com/2720903005 but it's not clear to me how this is
- // supposed to work - we already generated and sent a GSB to the main
- // thread above so it's odd to continue handling on the compositor thread
- // if a pinch was in progress. It probably makes more sense to bake this
- // condition into ScrollingShouldSwitchToMainThread().
- if (!gesture_pinch_in_progress_)
- return DID_NOT_HANDLE;
- }
-
- base::TimeTicks event_time = gesture_event.TimeStamp();
- base::TimeDelta delay = base::TimeTicks::Now() - event_time;
-
- cc::InputHandlerScrollResult scroll_result =
- input_handler_->ScrollUpdate(&scroll_state, delay);
-
- HandleOverscroll(gesture_event.PositionInWidget(), scroll_result);
-
- if (scroll_elasticity_controller_)
- HandleScrollElasticityOverscroll(gesture_event, scroll_result);
-
- return scroll_result.did_scroll ? DID_HANDLE : DROP_EVENT;
-}
-
-InputHandlerProxy::EventDisposition InputHandlerProxy::HandleGestureScrollEnd(
- const WebGestureEvent& gesture_event) {
- TRACE_EVENT0("input", "InputHandlerProxy::HandleGestureScrollEnd");
- input_handler_->RecordScrollEnd(
- GestureScrollInputType(gesture_event.SourceDevice()));
-
- if (scroll_sequence_ignored_) {
- DCHECK(!currently_active_gesture_device_.has_value());
- return DROP_EVENT;
- }
-
- if (!handling_gesture_on_impl_thread_) {
- DCHECK(!currently_active_gesture_device_.has_value());
- return DID_NOT_HANDLE;
- }
-
- if (!currently_active_gesture_device_.has_value() ||
- (currently_active_gesture_device_.value() !=
- gesture_event.SourceDevice()))
- return DROP_EVENT;
-
- InputHandlerScrollEnd();
- if (scroll_elasticity_controller_)
- HandleScrollElasticityOverscroll(gesture_event,
- cc::InputHandlerScrollResult());
-
- return DID_HANDLE;
-}
-
-void InputHandlerProxy::InputHandlerScrollEnd() {
- input_handler_->ScrollEnd(/*should_snap=*/true);
- handling_gesture_on_impl_thread_ = false;
-}
-
-InputHandlerProxy::EventDisposition InputHandlerProxy::HitTestTouchEvent(
- const blink::WebTouchEvent& touch_event,
- bool* is_touching_scrolling_layer,
- cc::TouchAction* white_listed_touch_action) {
- *is_touching_scrolling_layer = false;
- EventDisposition result = DROP_EVENT;
- for (size_t i = 0; i < touch_event.touches_length; ++i) {
- if (touch_event.touch_start_or_first_touch_move)
- DCHECK(white_listed_touch_action);
- else
- DCHECK(!white_listed_touch_action);
-
- if (touch_event.GetType() == WebInputEvent::kTouchStart &&
- touch_event.touches[i].state != WebTouchPoint::kStatePressed) {
- continue;
- }
-
- cc::TouchAction touch_action = cc::TouchAction::kAuto;
- cc::InputHandler::TouchStartOrMoveEventListenerType event_listener_type =
- input_handler_->EventListenerTypeForTouchStartOrMoveAt(
- gfx::Point(touch_event.touches[i].PositionInWidget().x(),
- touch_event.touches[i].PositionInWidget().y()),
- &touch_action);
- if (white_listed_touch_action)
- *white_listed_touch_action &= touch_action;
-
- if (event_listener_type !=
- cc::InputHandler::TouchStartOrMoveEventListenerType::NO_HANDLER) {
- *is_touching_scrolling_layer =
- event_listener_type ==
- cc::InputHandler::TouchStartOrMoveEventListenerType::
- HANDLER_ON_SCROLLING_LAYER;
- // A non-passive touch start / move will always set the whitelisted touch
- // action to TouchAction::kNone, and in that case we do not ack the event
- // from the compositor.
- if (compositor_touch_action_enabled_ && white_listed_touch_action &&
- *white_listed_touch_action != cc::TouchAction::kNone)
- result = DID_HANDLE_NON_BLOCKING;
- else
- result = DID_NOT_HANDLE;
- break;
- }
- }
-
- // If |result| is DROP_EVENT it wasn't processed above.
- if (result == DROP_EVENT) {
- switch (input_handler_->GetEventListenerProperties(
- cc::EventListenerClass::kTouchStartOrMove)) {
- case cc::EventListenerProperties::kPassive:
- result = DID_HANDLE_NON_BLOCKING;
- break;
- case cc::EventListenerProperties::kBlocking:
- // The touch area rects above already have checked whether it hits
- // a blocking region. Since it does not the event can be dropped.
- result = DROP_EVENT;
- break;
- case cc::EventListenerProperties::kBlockingAndPassive:
- // There is at least one passive listener that needs to possibly
- // be notified so it can't be dropped.
- result = DID_HANDLE_NON_BLOCKING;
- break;
- case cc::EventListenerProperties::kNone:
- result = DROP_EVENT;
- break;
- default:
- NOTREACHED();
- result = DROP_EVENT;
- break;
- }
- }
-
- // Depending on which arm of the SkipTouchEventFilter experiment we're on, we
- // may need to simulate a passive listener instead of dropping touch events.
- if (result == DROP_EVENT &&
- (skip_touch_filter_all_ ||
- (skip_touch_filter_discrete_ &&
- touch_event.GetType() == WebInputEvent::kTouchStart)))
- result = DID_HANDLE_NON_BLOCKING;
-
- // Merge |touch_result_| and |result| so the result has the highest
- // priority value according to the sequence; (DROP_EVENT,
- // DID_HANDLE_NON_BLOCKING, DID_NOT_HANDLE).
- if (touch_result_ == kEventDispositionUndefined ||
- touch_result_ == DROP_EVENT || result == DID_NOT_HANDLE)
- touch_result_ = result;
- return result;
-}
-
-InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchStart(
- const blink::WebTouchEvent& touch_event) {
- bool is_touching_scrolling_layer;
- cc::TouchAction white_listed_touch_action = cc::TouchAction::kAuto;
- EventDisposition result = HitTestTouchEvent(
- touch_event, &is_touching_scrolling_layer, &white_listed_touch_action);
-
- // If |result| is still DROP_EVENT look at the touch end handler as
- // we may not want to discard the entire touch sequence. Note this
- // code is explicitly after the assignment of the |touch_result_|
- // so the touch moves are not sent to the main thread un-necessarily.
- if (result == DROP_EVENT && input_handler_->GetEventListenerProperties(
- cc::EventListenerClass::kTouchEndOrCancel) !=
- cc::EventListenerProperties::kNone) {
- result = DID_HANDLE_NON_BLOCKING;
- }
-
- bool is_in_inertial_scrolling_on_impl =
- in_inertial_scrolling_ && handling_gesture_on_impl_thread_;
- if (is_in_inertial_scrolling_on_impl && is_touching_scrolling_layer)
- result = DID_NOT_HANDLE_NON_BLOCKING_DUE_TO_FLING;
-
- client_->SetWhiteListedTouchAction(white_listed_touch_action,
- touch_event.unique_touch_event_id, result);
-
- return result;
-}
-
-InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchMove(
- const blink::WebTouchEvent& touch_event) {
- // Hit test if this is the first touch move or we don't have any results
- // from a previous hit test.
- if (touch_result_ == kEventDispositionUndefined ||
- touch_event.touch_start_or_first_touch_move) {
- bool is_touching_scrolling_layer;
- cc::TouchAction white_listed_touch_action = cc::TouchAction::kAuto;
- EventDisposition result = HitTestTouchEvent(
- touch_event, &is_touching_scrolling_layer, &white_listed_touch_action);
- client_->SetWhiteListedTouchAction(
- white_listed_touch_action, touch_event.unique_touch_event_id, result);
- return result;
- }
- return static_cast<EventDisposition>(touch_result_);
-}
-
-InputHandlerProxy::EventDisposition InputHandlerProxy::HandleTouchEnd(
- const blink::WebTouchEvent& touch_event) {
- if (touch_event.touches_length == 1)
- touch_result_ = kEventDispositionUndefined;
- return DID_NOT_HANDLE;
-}
-
-void InputHandlerProxy::Animate(base::TimeTicks time) {
- if (scroll_elasticity_controller_)
- scroll_elasticity_controller_->Animate(time);
-
- snap_fling_controller_->Animate(time);
-}
-
-void InputHandlerProxy::ReconcileElasticOverscrollAndRootScroll() {
- if (scroll_elasticity_controller_)
- scroll_elasticity_controller_->ReconcileStretchAndScroll();
-}
-
-void InputHandlerProxy::UpdateRootLayerStateForSynchronousInputHandler(
- const gfx::ScrollOffset& total_scroll_offset,
- const gfx::ScrollOffset& max_scroll_offset,
- const gfx::SizeF& scrollable_size,
- float page_scale_factor,
- float min_page_scale_factor,
- float max_page_scale_factor) {
- if (synchronous_input_handler_) {
- synchronous_input_handler_->UpdateRootLayerState(
- total_scroll_offset, max_scroll_offset, scrollable_size,
- page_scale_factor, min_page_scale_factor, max_page_scale_factor);
- }
-}
-
-void InputHandlerProxy::DeliverInputForBeginFrame(
- const viz::BeginFrameArgs& args) {
- if (!scroll_predictor_)
- DispatchQueuedInputEvents();
-
- // Resampling GSUs and dispatch queued input events.
- while (!compositor_event_queue_->empty()) {
- std::unique_ptr<EventWithCallback> event_with_callback =
- scroll_predictor_->ResampleScrollEvents(compositor_event_queue_->Pop(),
- args.frame_time);
-
- DispatchSingleInputEvent(std::move(event_with_callback), args.frame_time);
- }
-}
-
-void InputHandlerProxy::DeliverInputForHighLatencyMode() {
- // When prediction enabled, do not handle input after commit complete.
- if (!scroll_predictor_)
- DispatchQueuedInputEvents();
-}
-
-void InputHandlerProxy::SetSynchronousInputHandler(
- SynchronousInputHandler* synchronous_input_handler) {
- synchronous_input_handler_ = synchronous_input_handler;
- if (synchronous_input_handler_)
- input_handler_->RequestUpdateForSynchronousInputHandler();
-}
-
-void InputHandlerProxy::SynchronouslySetRootScrollOffset(
- const gfx::ScrollOffset& root_offset) {
- DCHECK(synchronous_input_handler_);
- input_handler_->SetSynchronousInputHandlerRootScrollOffset(root_offset);
-}
-
-void InputHandlerProxy::SynchronouslyZoomBy(float magnify_delta,
- const gfx::Point& anchor) {
- DCHECK(synchronous_input_handler_);
- input_handler_->PinchGestureBegin();
- input_handler_->PinchGestureUpdate(magnify_delta, anchor);
- input_handler_->PinchGestureEnd(anchor, false);
-}
-
-bool InputHandlerProxy::GetSnapFlingInfoAndSetAnimatingSnapTarget(
- const gfx::Vector2dF& natural_displacement,
- gfx::Vector2dF* initial_offset,
- gfx::Vector2dF* target_offset) const {
- return input_handler_->GetSnapFlingInfoAndSetAnimatingSnapTarget(
- natural_displacement, initial_offset, target_offset);
-}
-
-gfx::Vector2dF InputHandlerProxy::ScrollByForSnapFling(
- const gfx::Vector2dF& delta) {
- cc::ScrollState scroll_state = CreateScrollStateForInertialUpdate(delta);
-
- cc::InputHandlerScrollResult scroll_result =
- input_handler_->ScrollUpdate(&scroll_state, base::TimeDelta());
- return scroll_result.current_visual_offset;
-}
-
-void InputHandlerProxy::ScrollEndForSnapFling(bool did_finish) {
- input_handler_->ScrollEndForSnapFling(did_finish);
-}
-
-void InputHandlerProxy::RequestAnimationForSnapFling() {
- RequestAnimation();
-}
-
-void InputHandlerProxy::HandleOverscroll(
- const gfx::PointF& causal_event_viewport_point,
- const cc::InputHandlerScrollResult& scroll_result) {
- DCHECK(client_);
- if (!scroll_result.did_overscroll_root)
- return;
-
- TRACE_EVENT2("input", "InputHandlerProxy::DidOverscroll", "dx",
- scroll_result.unused_scroll_delta.x(), "dy",
- scroll_result.unused_scroll_delta.y());
-
- // Bundle overscroll message with triggering event response, saving an IPC.
- current_overscroll_params_ = std::make_unique<DidOverscrollParams>();
- current_overscroll_params_->accumulated_overscroll =
- scroll_result.accumulated_root_overscroll;
- current_overscroll_params_->latest_overscroll_delta =
- scroll_result.unused_scroll_delta;
- current_overscroll_params_->causal_event_viewport_point =
- causal_event_viewport_point;
- current_overscroll_params_->overscroll_behavior =
- scroll_result.overscroll_behavior;
- return;
-}
-
-void InputHandlerProxy::RequestAnimation() {
- input_handler_->SetNeedsAnimateInput();
-}
-
-void InputHandlerProxy::HandleScrollElasticityOverscroll(
- const WebGestureEvent& gesture_event,
- const cc::InputHandlerScrollResult& scroll_result) {
- DCHECK(scroll_elasticity_controller_);
- // Send the event and its disposition to the elasticity controller to update
- // the over-scroll animation. Note that the call to the elasticity controller
- // is made asynchronously, to minimize divergence between main thread and
- // impl thread event handling paths.
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::BindOnce(
- &InputScrollElasticityController::ObserveGestureEventAndResult,
- scroll_elasticity_controller_->GetWeakPtr(), gesture_event,
- scroll_result));
-}
-
-void InputHandlerProxy::SetTickClockForTesting(
- const base::TickClock* tick_clock) {
- tick_clock_ = tick_clock;
-}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/input_handler_proxy.h b/chromium/ui/events/blink/input_handler_proxy.h
deleted file mode 100644
index 5b7ff6b7a84..00000000000
--- a/chromium/ui/events/blink/input_handler_proxy.h
+++ /dev/null
@@ -1,273 +0,0 @@
-// Copyright 2013 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 UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_
-#define UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_
-
-#include <memory>
-
-#include "base/macros.h"
-#include "cc/input/input_handler.h"
-#include "cc/input/snap_fling_controller.h"
-#include "third_party/blink/public/common/input/web_gesture_event.h"
-#include "ui/events/blink/blink_features.h"
-#include "ui/events/blink/input_scroll_elasticity_controller.h"
-#include "ui/events/blink/synchronous_input_handler_proxy.h"
-#include "ui/events/blink/web_input_event_traits.h"
-
-namespace base {
-class TickClock;
-}
-
-namespace blink {
-class WebInputEventAttribution;
-class WebMouseWheelEvent;
-class WebTouchEvent;
-} // namespace blink
-
-namespace ui {
-
-namespace test {
-class InputHandlerProxyTest;
-class InputHandlerProxyEventQueueTest;
-class InputHandlerProxyMomentumScrollJankTest;
-class TestInputHandlerProxy;
-} // namespace test
-
-class CompositorThreadEventQueue;
-class EventWithCallback;
-class InputHandlerProxyClient;
-class InputScrollElasticityController;
-class ScrollPredictor;
-class SynchronousInputHandler;
-class SynchronousInputHandlerProxy;
-class MomentumScrollJankTracker;
-struct DidOverscrollParams;
-
-// This class is a proxy between the blink web input events for a WebWidget and
-// the compositor's input handling logic. InputHandlerProxy instances live
-// entirely on the compositor thread. Each InputHandler instance handles input
-// events intended for a specific WebWidget.
-class InputHandlerProxy : public cc::InputHandlerClient,
- public SynchronousInputHandlerProxy,
- public cc::SnapFlingClient {
- public:
- InputHandlerProxy(cc::InputHandler* input_handler,
- InputHandlerProxyClient* client,
- bool force_input_to_main_thread);
- ~InputHandlerProxy() override;
-
- InputScrollElasticityController* scroll_elasticity_controller() {
- return scroll_elasticity_controller_.get();
- }
-
- enum EventDisposition {
- DID_HANDLE,
- DID_NOT_HANDLE,
- DID_NOT_HANDLE_NON_BLOCKING_DUE_TO_FLING,
- DID_HANDLE_NON_BLOCKING,
- DROP_EVENT,
- // The compositor did handle the scroll event (so it wouldn't forward the
- // event to the main thread.) but it didn't consume the scroll so it should
- // pass it to the next consumer (either overscrolling or bubbling the event
- // to the next renderer).
- DID_HANDLE_SHOULD_BUBBLE,
- };
- using EventDispositionCallback =
- base::OnceCallback<void(EventDisposition,
- WebScopedInputEvent WebInputEvent,
- const LatencyInfo&,
- std::unique_ptr<ui::DidOverscrollParams>,
- const blink::WebInputEventAttribution&)>;
- void HandleInputEventWithLatencyInfo(WebScopedInputEvent event,
- const LatencyInfo& latency_info,
- EventDispositionCallback callback);
- void InjectScrollbarGestureScroll(
- const blink::WebInputEvent::Type type,
- const gfx::PointF& position_in_widget,
- const cc::InputHandlerPointerResult& pointer_result,
- const LatencyInfo& latency_info,
- const base::TimeTicks now);
-
- // Attempts to perform attribution of the given WebInputEvent to a target
- // frame. Intended for simple impl-side hit testing.
- blink::WebInputEventAttribution PerformEventAttribution(
- const blink::WebInputEvent& event);
-
- // cc::InputHandlerClient implementation.
- void WillShutdown() override;
- void Animate(base::TimeTicks time) override;
- void ReconcileElasticOverscrollAndRootScroll() override;
- void UpdateRootLayerStateForSynchronousInputHandler(
- const gfx::ScrollOffset& total_scroll_offset,
- const gfx::ScrollOffset& max_scroll_offset,
- const gfx::SizeF& scrollable_size,
- float page_scale_factor,
- float min_page_scale_factor,
- float max_page_scale_factor) override;
- void DeliverInputForBeginFrame(const viz::BeginFrameArgs& args) override;
- void DeliverInputForHighLatencyMode() override;
-
- // SynchronousInputHandlerProxy implementation.
- void SetSynchronousInputHandler(
- SynchronousInputHandler* synchronous_input_handler) override;
- void SynchronouslySetRootScrollOffset(
- const gfx::ScrollOffset& root_offset) override;
- void SynchronouslyZoomBy(float magnify_delta,
- const gfx::Point& anchor) override;
-
- // SnapFlingClient implementation.
- bool GetSnapFlingInfoAndSetAnimatingSnapTarget(
- const gfx::Vector2dF& natural_displacement,
- gfx::Vector2dF* initial_offset,
- gfx::Vector2dF* target_offset) const override;
- gfx::Vector2dF ScrollByForSnapFling(const gfx::Vector2dF& delta) override;
- void ScrollEndForSnapFling(bool did_finish) override;
- void RequestAnimationForSnapFling() override;
-
- bool gesture_scroll_on_impl_thread_for_testing() const {
- return handling_gesture_on_impl_thread_;
- }
-
- protected:
- void RecordMainThreadScrollingReasons(blink::WebGestureDevice device,
- uint32_t reasons);
- void RecordScrollingThreadStatus(blink::WebGestureDevice device,
- uint32_t reasons);
-
- private:
- friend class test::TestInputHandlerProxy;
- friend class test::InputHandlerProxyTest;
- friend class test::InputHandlerProxyEventQueueTest;
- friend class test::InputHandlerProxyMomentumScrollJankTest;
-
- void DispatchSingleInputEvent(std::unique_ptr<EventWithCallback>,
- const base::TimeTicks);
- void DispatchQueuedInputEvents();
-
- // Helper functions for handling more complicated input events.
- EventDisposition HandleMouseWheel(const blink::WebMouseWheelEvent& event);
- EventDisposition HandleGestureScrollBegin(
- const blink::WebGestureEvent& event);
- EventDisposition HandleGestureScrollUpdate(
- const blink::WebGestureEvent& event,
- const blink::WebInputEventAttribution& original_attribution);
- EventDisposition HandleGestureScrollEnd(const blink::WebGestureEvent& event);
- EventDisposition HandleTouchStart(const blink::WebTouchEvent& event);
- EventDisposition HandleTouchMove(const blink::WebTouchEvent& event);
- EventDisposition HandleTouchEnd(const blink::WebTouchEvent& event);
-
- void InputHandlerScrollEnd();
-
- // Request a frame of animation from the InputHandler or
- // SynchronousInputHandler. They can provide that by calling Animate().
- void RequestAnimation();
-
- // Used to send overscroll messages to the browser. It bundles the overscroll
- // params with with event ack.
- void HandleOverscroll(const gfx::PointF& causal_event_viewport_point,
- const cc::InputHandlerScrollResult& scroll_result);
-
- // Update the elastic overscroll controller with |gesture_event|.
- void HandleScrollElasticityOverscroll(
- const blink::WebGestureEvent& gesture_event,
- const cc::InputHandlerScrollResult& scroll_result);
-
- // Overrides the internal clock for testing.
- // This doesn't take the ownership of the clock. |tick_clock| must outlive the
- // InputHandlerProxy instance.
- void SetTickClockForTesting(const base::TickClock* tick_clock);
-
- // |is_touching_scrolling_layer| indicates if one of the points that has
- // been touched hits a currently scrolling layer.
- // |white_listed_touch_action| is the touch_action we are sure will be
- // allowed for the given touch event.
- EventDisposition HitTestTouchEvent(
- const blink::WebTouchEvent& touch_event,
- bool* is_touching_scrolling_layer,
- cc::TouchAction* white_listed_touch_action);
-
- EventDisposition RouteToTypeSpecificHandler(
- EventWithCallback* event_with_callback,
- const LatencyInfo& original_latency_info,
- const blink::WebInputEventAttribution& original_attribution);
-
- InputHandlerProxyClient* client_;
- cc::InputHandler* input_handler_;
-
- SynchronousInputHandler* synchronous_input_handler_;
-
- // This should be true when a pinch is in progress. The sequence of events is
- // as follows: GSB GPB GSU GPU ... GPE GSE.
- bool handling_gesture_on_impl_thread_;
-
- bool gesture_pinch_in_progress_ = false;
- bool in_inertial_scrolling_ = false;
- bool scroll_sequence_ignored_;
-
- // Used to animate rubber-band over-scroll effect on Mac.
- std::unique_ptr<InputScrollElasticityController>
- scroll_elasticity_controller_;
-
- // The merged result of the last touch event with previous touch events.
- // This value will get returned for subsequent TouchMove events to allow
- // passive events not to block scrolling.
- int32_t touch_result_;
-
- // The result of the last mouse wheel event. This value is used to determine
- // whether the next wheel scroll is blocked on the Main thread or not.
- int32_t mouse_wheel_result_;
-
- // Used to record overscroll notifications while an event is being
- // dispatched. If the event causes overscroll, the overscroll metadata is
- // bundled in the event ack, saving an IPC.
- std::unique_ptr<DidOverscrollParams> current_overscroll_params_;
-
- std::unique_ptr<CompositorThreadEventQueue> compositor_event_queue_;
-
- // Set only when the compositor input handler is handling a gesture. Tells
- // which source device is currently performing a gesture based scroll.
- base::Optional<blink::WebGestureDevice> currently_active_gesture_device_;
-
- // Tracks whether the first scroll update gesture event has been seen after a
- // scroll begin. This is set/reset when scroll gestures are processed in
- // HandleInputEventWithLatencyInfo and shouldn't be used outside the scope
- // of that method.
- bool has_seen_first_gesture_scroll_update_after_begin_;
-
- // Whether the last injected scroll gesture was a GestureScrollBegin. Used to
- // determine which GestureScrollUpdate is the first in a gesture sequence for
- // latency classification. This is separate from
- // |is_first_gesture_scroll_update_| and is used to determine which type of
- // latency component should be added for injected GestureScrollUpdates.
- bool last_injected_gesture_was_begin_;
-
- const base::TickClock* tick_clock_;
-
- std::unique_ptr<cc::SnapFlingController> snap_fling_controller_;
-
- std::unique_ptr<ScrollPredictor> scroll_predictor_;
-
- bool compositor_touch_action_enabled_;
-
- // This flag can be used to force all input to be forwarded to Blink. It's
- // used in LayoutTests to preserve existing behavior for non-threaded layout
- // tests and to allow testing both Blink and CC input handling paths.
- bool force_input_to_main_thread_;
-
- // These flags are set for the SkipTouchEventFilter experiment. The
- // experiment either skips filtering discrete (touch start/end) events to the
- // main thread, or all events (touch start/end/move).
- bool skip_touch_filter_discrete_ = false;
- bool skip_touch_filter_all_ = false;
-
- // Helpers for the momentum scroll jank UMAs.
- std::unique_ptr<MomentumScrollJankTracker> momentum_scroll_jank_tracker_;
-
- DISALLOW_COPY_AND_ASSIGN(InputHandlerProxy);
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_H_
diff --git a/chromium/ui/events/blink/input_handler_proxy_client.h b/chromium/ui/events/blink/input_handler_proxy_client.h
deleted file mode 100644
index 881db53486a..00000000000
--- a/chromium/ui/events/blink/input_handler_proxy_client.h
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2013 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 UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_CLIENT_H_
-#define UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_CLIENT_H_
-
-#include "ui/events/blink/web_input_event_traits.h"
-
-namespace ui {
-
-// All callbacks invoked from the compositor thread.
-class InputHandlerProxyClient {
- public:
- // Called just before the InputHandlerProxy shuts down.
- virtual void WillShutdown() = 0;
-
- // Dispatch a non blocking event to the main thread. This is used when a
- // gesture fling from a touchpad is processed and the target only has
- // passive event listeners.
- virtual void DispatchNonBlockingEventToMainThread(
- WebScopedInputEvent event,
- const ui::LatencyInfo& latency_info,
- const blink::WebInputEventAttribution& attribution) = 0;
-
- // |HandleInputEventWithLatencyInfo/RouteToTypeSpecificHandler| will respond
- // to overscroll by calling the passed in callback. Otherwise |DidOverscroll|
- // will be fired.
- virtual void DidOverscroll(
- const gfx::Vector2dF& accumulated_overscroll,
- const gfx::Vector2dF& latest_overscroll_delta,
- const gfx::Vector2dF& current_fling_velocity,
- const gfx::PointF& causal_event_viewport_point,
- const cc::OverscrollBehavior& overscroll_behavior) = 0;
-
- virtual void DidAnimateForInput() = 0;
-
- virtual void DidStartScrollingViewport() = 0;
-
- // Used to send a GSB to the main thread when the scrolling should switch to
- // the main thread.
- virtual void GenerateScrollBeginAndSendToMainThread(
- const blink::WebGestureEvent& update_event,
- const blink::WebInputEventAttribution& attribution) = 0;
-
- virtual void SetWhiteListedTouchAction(
- cc::TouchAction touch_action,
- uint32_t unique_touch_event_id,
- InputHandlerProxy::EventDisposition event_disposition) = 0;
-
- protected:
- virtual ~InputHandlerProxyClient() {}
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_INPUT_HANDLER_PROXY_CLIENT_H_
diff --git a/chromium/ui/events/blink/input_handler_proxy_unittest.cc b/chromium/ui/events/blink/input_handler_proxy_unittest.cc
deleted file mode 100644
index 3ce359ca229..00000000000
--- a/chromium/ui/events/blink/input_handler_proxy_unittest.cc
+++ /dev/null
@@ -1,3223 +0,0 @@
-// Copyright 2013 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 "ui/events/blink/input_handler_proxy.h"
-
-#include <memory>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/containers/circular_deque.h"
-#include "base/macros.h"
-#include "base/test/bind_test_util.h"
-#include "base/test/metrics/histogram_tester.h"
-#include "base/test/scoped_feature_list.h"
-#include "base/test/simple_test_tick_clock.h"
-#include "base/test/task_environment.h"
-#include "base/test/trace_event_analyzer.h"
-#include "build/build_config.h"
-#include "cc/input/main_thread_scrolling_reason.h"
-#include "cc/input/scroll_input_type.h"
-#include "cc/trees/swap_promise_monitor.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/blink/public/common/input/web_input_event.h"
-#include "third_party/blink/public/common/input/web_input_event_attribution.h"
-#include "third_party/blink/public/common/input/web_keyboard_event.h"
-#include "third_party/blink/public/common/input/web_mouse_event.h"
-#include "third_party/blink/public/common/input/web_mouse_wheel_event.h"
-#include "third_party/blink/public/common/input/web_pointer_event.h"
-#include "third_party/blink/public/common/input/web_touch_event.h"
-#include "ui/events/blink/blink_event_util.h"
-#include "ui/events/blink/compositor_thread_event_queue.h"
-#include "ui/events/blink/did_overscroll_params.h"
-#include "ui/events/blink/event_with_callback.h"
-#include "ui/events/blink/input_handler_proxy.h"
-#include "ui/events/blink/input_handler_proxy_client.h"
-#include "ui/events/blink/scroll_predictor.h"
-#include "ui/events/blink/web_input_event_traits.h"
-#include "ui/gfx/geometry/scroll_offset.h"
-#include "ui/gfx/geometry/size_f.h"
-#include "ui/latency/latency_info.h"
-
-using blink::WebGestureDevice;
-using blink::WebGestureEvent;
-using blink::WebInputEvent;
-using blink::WebKeyboardEvent;
-using blink::WebMouseEvent;
-using blink::WebMouseWheelEvent;
-using blink::WebTouchEvent;
-using blink::WebTouchPoint;
-using testing::_;
-using testing::DoAll;
-using testing::Field;
-
-namespace ui {
-namespace test {
-
-namespace {
-
-enum InputHandlerProxyTestType {
- ROOT_SCROLL_NORMAL_HANDLER,
- ROOT_SCROLL_SYNCHRONOUS_HANDLER,
- CHILD_SCROLL_NORMAL_HANDLER,
- CHILD_SCROLL_SYNCHRONOUS_HANDLER,
- COMPOSITOR_TOUCH_ACTION_ENABLED_ROOT_NORMAL,
- COMPOSITOR_TOUCH_ACTION_ENABLED_ROOT_SYNCHRONOUS,
- COMPOSITOR_TOUCH_ACTION_ENABLED_CHILD_NORMAL,
- COMPOSITOR_TOUCH_ACTION_ENABLED_CHILD_SYNCHRONOUS,
-};
-static const InputHandlerProxyTestType test_types[] = {
- ROOT_SCROLL_NORMAL_HANDLER,
- ROOT_SCROLL_SYNCHRONOUS_HANDLER,
- CHILD_SCROLL_NORMAL_HANDLER,
- CHILD_SCROLL_SYNCHRONOUS_HANDLER,
- COMPOSITOR_TOUCH_ACTION_ENABLED_ROOT_NORMAL,
- COMPOSITOR_TOUCH_ACTION_ENABLED_ROOT_SYNCHRONOUS,
- COMPOSITOR_TOUCH_ACTION_ENABLED_CHILD_NORMAL,
- COMPOSITOR_TOUCH_ACTION_ENABLED_CHILD_SYNCHRONOUS,
-};
-
-MATCHER_P(WheelEventsMatch, expected, "") {
- return WheelEventsMatch(arg, expected);
-}
-
-WebScopedInputEvent CreateGestureScrollPinch(WebInputEvent::Type type,
- WebGestureDevice source_device,
- base::TimeTicks event_time,
- float delta_y_or_scale = 0,
- int x = 0,
- int y = 0) {
- WebGestureEvent gesture(type, WebInputEvent::kNoModifiers, event_time,
- source_device);
- if (type == WebInputEvent::kGestureScrollUpdate) {
- gesture.data.scroll_update.delta_y = delta_y_or_scale;
- } else if (type == WebInputEvent::kGesturePinchUpdate) {
- gesture.data.pinch_update.scale = delta_y_or_scale;
- gesture.SetPositionInWidget(gfx::PointF(x, y));
- }
- return gesture.Clone();
-}
-
-class MockInputHandler : public cc::InputHandler {
- public:
- MockInputHandler() {}
- ~MockInputHandler() override {}
-
- MOCK_METHOD0(PinchGestureBegin, void());
- MOCK_METHOD2(PinchGestureUpdate,
- void(float magnify_delta, const gfx::Point& anchor));
- MOCK_METHOD2(PinchGestureEnd, void(const gfx::Point& anchor, bool snap));
-
- MOCK_METHOD0(SetNeedsAnimateInput, void());
-
- MOCK_METHOD2(ScrollBegin,
- ScrollStatus(cc::ScrollState*, cc::ScrollInputType type));
- MOCK_METHOD2(RootScrollBegin,
- ScrollStatus(cc::ScrollState*, cc::ScrollInputType type));
- MOCK_METHOD2(ScrollUpdate,
- cc::InputHandlerScrollResult(cc::ScrollState*, base::TimeDelta));
- MOCK_METHOD1(ScrollEnd, void(bool));
- MOCK_METHOD2(RecordScrollBegin,
- void(cc::ScrollInputType type,
- cc::ScrollBeginThreadState state));
- MOCK_METHOD1(RecordScrollEnd, void(cc::ScrollInputType type));
- MOCK_METHOD0(ScrollingShouldSwitchtoMainThread, bool());
-
- std::unique_ptr<cc::SwapPromiseMonitor> CreateLatencyInfoSwapPromiseMonitor(
- ui::LatencyInfo* latency) override {
- return nullptr;
- }
-
- std::unique_ptr<cc::EventsMetricsManager::ScopedMonitor>
- GetScopedEventMetricsMonitor(const cc::EventMetrics& event_metrics) override {
- return nullptr;
- }
-
- cc::ScrollElasticityHelper* CreateScrollElasticityHelper() override {
- return nullptr;
- }
- bool GetScrollOffsetForLayer(cc::ElementId element_id,
- gfx::ScrollOffset* offset) override {
- return false;
- }
- bool ScrollLayerTo(cc::ElementId element_id,
- const gfx::ScrollOffset& offset) override {
- return false;
- }
-
- void BindToClient(cc::InputHandlerClient* client) override {}
-
- cc::InputHandlerPointerResult MouseDown(const gfx::PointF& mouse_position,
- const bool shift_modifier) override {
- cc::InputHandlerPointerResult pointer_result;
- pointer_result.type = cc::kScrollbarScroll;
- pointer_result.scroll_offset = gfx::ScrollOffset(0, 1);
- return pointer_result;
- }
-
- cc::InputHandlerPointerResult MouseUp(
- const gfx::PointF& mouse_position) override {
- cc::InputHandlerPointerResult pointer_result;
- pointer_result.type = cc::kScrollbarScroll;
- return pointer_result;
- }
-
- void MouseLeave() override {}
-
- cc::ElementId FindFrameElementIdAtPoint(
- const gfx::PointF& mouse_position) override {
- return cc::ElementId();
- }
-
- cc::InputHandlerPointerResult MouseMoveAt(
- const gfx::Point& mouse_position) override {
- return cc::InputHandlerPointerResult();
- }
-
- MOCK_CONST_METHOD1(IsCurrentlyScrollingLayerAt,
- bool(const gfx::Point& point));
-
- MOCK_CONST_METHOD1(
- GetEventListenerProperties,
- cc::EventListenerProperties(cc::EventListenerClass event_class));
- MOCK_METHOD2(EventListenerTypeForTouchStartOrMoveAt,
- cc::InputHandler::TouchStartOrMoveEventListenerType(
- const gfx::Point& point,
- cc::TouchAction* touch_action));
- MOCK_CONST_METHOD1(HasBlockingWheelEventHandlerAt, bool(const gfx::Point&));
-
- MOCK_METHOD0(RequestUpdateForSynchronousInputHandler, void());
- MOCK_METHOD1(SetSynchronousInputHandlerRootScrollOffset,
- void(const gfx::ScrollOffset& root_offset));
-
- bool IsCurrentlyScrollingViewport() const override {
- return is_scrolling_root_;
- }
- void set_is_scrolling_root(bool is) { is_scrolling_root_ = is; }
-
- MOCK_METHOD3(GetSnapFlingInfoAndSetAnimatingSnapTarget,
- bool(const gfx::Vector2dF& natural_displacement,
- gfx::Vector2dF* initial_offset,
- gfx::Vector2dF* target_offset));
- MOCK_METHOD1(ScrollEndForSnapFling, void(bool));
-
- private:
- bool is_scrolling_root_ = true;
- DISALLOW_COPY_AND_ASSIGN(MockInputHandler);
-};
-
-class MockSynchronousInputHandler : public SynchronousInputHandler {
- public:
- MOCK_METHOD6(UpdateRootLayerState,
- void(const gfx::ScrollOffset& total_scroll_offset,
- const gfx::ScrollOffset& max_scroll_offset,
- const gfx::SizeF& scrollable_size,
- float page_scale_factor,
- float min_page_scale_factor,
- float max_page_scale_factor));
-};
-
-class MockInputHandlerProxyClient : public InputHandlerProxyClient {
- public:
- MockInputHandlerProxyClient() {}
- ~MockInputHandlerProxyClient() override {}
-
- void WillShutdown() override {}
-
- MOCK_METHOD1(DispatchNonBlockingEventToMainThread_,
- void(const WebInputEvent&));
-
- MOCK_METHOD2(GenerateScrollBeginAndSendToMainThread,
- void(const blink::WebGestureEvent& update_event,
- const blink::WebInputEventAttribution&));
-
- void DispatchNonBlockingEventToMainThread(
- WebScopedInputEvent event,
- const ui::LatencyInfo& latency_info,
- const blink::WebInputEventAttribution&) override {
- CHECK(event.get());
- DispatchNonBlockingEventToMainThread_(*event.get());
- }
-
- MOCK_METHOD5(DidOverscroll,
- void(const gfx::Vector2dF& accumulated_overscroll,
- const gfx::Vector2dF& latest_overscroll_delta,
- const gfx::Vector2dF& current_fling_velocity,
- const gfx::PointF& causal_event_viewport_point,
- const cc::OverscrollBehavior& overscroll_behavior));
- void DidAnimateForInput() override {}
- void DidStartScrollingViewport() override {}
- MOCK_METHOD3(SetWhiteListedTouchAction,
- void(cc::TouchAction touch_action,
- uint32_t unique_touch_event_id,
- InputHandlerProxy::EventDisposition event_disposition));
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClient);
-};
-
-class MockInputHandlerProxyClientWithDidAnimateForInput
- : public MockInputHandlerProxyClient {
- public:
- MockInputHandlerProxyClientWithDidAnimateForInput() {}
- ~MockInputHandlerProxyClientWithDidAnimateForInput() override {}
-
- MOCK_METHOD0(DidAnimateForInput, void());
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MockInputHandlerProxyClientWithDidAnimateForInput);
-};
-
-WebTouchPoint CreateWebTouchPoint(WebTouchPoint::State state,
- float x,
- float y) {
- WebTouchPoint point;
- point.state = state;
- point.SetPositionInScreen(x, y);
- point.SetPositionInWidget(x, y);
- return point;
-}
-
-const cc::InputHandler::ScrollStatus kImplThreadScrollState(
- cc::InputHandler::SCROLL_ON_IMPL_THREAD,
- cc::MainThreadScrollingReason::kNotScrollingOnMain);
-
-const cc::InputHandler::ScrollStatus kMainThreadScrollState(
- cc::InputHandler::SCROLL_ON_MAIN_THREAD,
- cc::MainThreadScrollingReason::kHandlingScrollFromMainThread);
-
-const cc::InputHandler::ScrollStatus kScrollIgnoredScrollState(
- cc::InputHandler::SCROLL_IGNORED,
- cc::MainThreadScrollingReason::kNotScrollable);
-
-} // namespace
-
-class TestInputHandlerProxy : public InputHandlerProxy {
- public:
- TestInputHandlerProxy(cc::InputHandler* input_handler,
- InputHandlerProxyClient* client,
- bool force_input_to_main_thread)
- : InputHandlerProxy(input_handler, client, force_input_to_main_thread) {}
- void RecordMainThreadScrollingReasonsForTest(blink::WebGestureDevice device,
- uint32_t reasons) {
- RecordMainThreadScrollingReasons(device, reasons);
- }
-
- MOCK_METHOD0(SetNeedsAnimateInput, void());
-
- EventDisposition HitTestTouchEventForTest(
- const blink::WebTouchEvent& touch_event,
- bool* is_touching_scrolling_layer,
- cc::TouchAction* white_listed_touch_action) {
- return HitTestTouchEvent(touch_event, is_touching_scrolling_layer,
- white_listed_touch_action);
- }
-
- EventDisposition HandleMouseWheelForTest(
- const blink::WebMouseWheelEvent& wheel_event) {
- return HandleMouseWheel(wheel_event);
- }
-
- // This is needed because the tests can't directly call
- // DispatchQueuedInputEvents since it is private.
- void DispatchQueuedInputEventsHelper() { DispatchQueuedInputEvents(); }
-};
-
-class InputHandlerProxyTest
- : public testing::Test,
- public testing::WithParamInterface<InputHandlerProxyTestType> {
- public:
- InputHandlerProxyTest()
- : synchronous_root_scroll_(
- GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER ||
- GetParam() == COMPOSITOR_TOUCH_ACTION_ENABLED_ROOT_SYNCHRONOUS),
- install_synchronous_handler_(
- GetParam() == ROOT_SCROLL_SYNCHRONOUS_HANDLER ||
- GetParam() == CHILD_SCROLL_SYNCHRONOUS_HANDLER ||
- GetParam() == COMPOSITOR_TOUCH_ACTION_ENABLED_ROOT_SYNCHRONOUS ||
- GetParam() == COMPOSITOR_TOUCH_ACTION_ENABLED_CHILD_SYNCHRONOUS),
- compositor_touch_action_enabled_(
- GetParam() == COMPOSITOR_TOUCH_ACTION_ENABLED_ROOT_NORMAL ||
- GetParam() == COMPOSITOR_TOUCH_ACTION_ENABLED_ROOT_SYNCHRONOUS ||
- GetParam() == COMPOSITOR_TOUCH_ACTION_ENABLED_CHILD_NORMAL ||
- GetParam() == COMPOSITOR_TOUCH_ACTION_ENABLED_CHILD_SYNCHRONOUS),
- expected_disposition_(InputHandlerProxy::DID_HANDLE) {
- if (compositor_touch_action_enabled_)
- feature_list_.InitAndEnableFeature(features::kCompositorTouchAction);
- else
- feature_list_.InitAndDisableFeature(features::kCompositorTouchAction);
- input_handler_ = std::make_unique<TestInputHandlerProxy>(
- &mock_input_handler_, &mock_client_,
- /*force_input_to_main_thread=*/false);
- scroll_result_did_scroll_.did_scroll = true;
- scroll_result_did_not_scroll_.did_scroll = false;
-
- if (install_synchronous_handler_) {
- EXPECT_CALL(mock_input_handler_,
- RequestUpdateForSynchronousInputHandler())
- .Times(1);
- input_handler_->SetSynchronousInputHandler(
- &mock_synchronous_input_handler_);
- }
-
- mock_input_handler_.set_is_scrolling_root(synchronous_root_scroll_);
-
- // Set a default device so tests don't always have to set this.
- gesture_.SetSourceDevice(blink::WebGestureDevice::kTouchpad);
- }
-
- virtual ~InputHandlerProxyTest() = default;
-
-// This is defined as a macro so the line numbers can be traced back to the
-// correct spot when it fails.
-#define EXPECT_SET_NEEDS_ANIMATE_INPUT(times) \
- do { \
- EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(times); \
- } while (false)
-
-// This is defined as a macro because when an expectation is not satisfied the
-// only output you get out of gmock is the line number that set the expectation.
-#define VERIFY_AND_RESET_MOCKS() \
- do { \
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler_); \
- testing::Mock::VerifyAndClearExpectations( \
- &mock_synchronous_input_handler_); \
- testing::Mock::VerifyAndClearExpectations(&mock_client_); \
- } while (false)
-
- void Animate(base::TimeTicks time) { input_handler_->Animate(time); }
-
- void SetSmoothScrollEnabled(bool value) {
- }
-
- base::HistogramTester& histogram_tester() { return histogram_tester_; }
-
- protected:
- void GestureScrollStarted();
- void ScrollHandlingSwitchedToMainThread();
- void GestureScrollIgnored();
- void FlingAndSnap();
-
- const bool synchronous_root_scroll_;
- const bool install_synchronous_handler_;
- const bool compositor_touch_action_enabled_;
- testing::StrictMock<MockInputHandler> mock_input_handler_;
- testing::StrictMock<MockSynchronousInputHandler>
- mock_synchronous_input_handler_;
- std::unique_ptr<TestInputHandlerProxy> input_handler_;
- testing::StrictMock<MockInputHandlerProxyClient> mock_client_;
- WebGestureEvent gesture_;
- InputHandlerProxy::EventDisposition expected_disposition_;
- base::HistogramTester histogram_tester_;
- cc::InputHandlerScrollResult scroll_result_did_scroll_;
- cc::InputHandlerScrollResult scroll_result_did_not_scroll_;
-
- private:
- base::test::ScopedFeatureList feature_list_;
-};
-
-// The helper basically returns the EventDisposition that is returned by
-// RouteToTypeSpecificHandler. This is done by passing in a callback when
-// calling HandleInputEventWithLatencyInfo. By design, DispatchSingleInputEvent
-// will then call this callback with the disposition returned by
-// RouteToTypeSpecificHandler and that is what gets returned by this helper.
-InputHandlerProxy::EventDisposition HandleInputEventWithLatencyInfo(
- TestInputHandlerProxy* input_handler,
- const blink::WebInputEvent& event) {
- WebScopedInputEvent scoped_input_event(event.Clone());
- InputHandlerProxy::EventDisposition event_disposition =
- InputHandlerProxy::DID_NOT_HANDLE;
- input_handler->HandleInputEventWithLatencyInfo(
- std::move(scoped_input_event), ui::LatencyInfo(),
- base::BindLambdaForTesting(
- [&event_disposition](
- InputHandlerProxy::EventDisposition disposition,
- WebScopedInputEvent event, const LatencyInfo& latency_info,
- std::unique_ptr<ui::DidOverscrollParams> callback,
- const blink::WebInputEventAttribution& attribution) {
- event_disposition = disposition;
- }));
- return event_disposition;
-}
-
-// This helper forces the CompositorThreadEventQueue to be flushed.
-InputHandlerProxy::EventDisposition HandleInputEventAndFlushEventQueue(
- testing::StrictMock<MockInputHandler>& mock_input_handler,
- TestInputHandlerProxy* input_handler,
- const blink::WebInputEvent& event) {
- EXPECT_CALL(mock_input_handler, SetNeedsAnimateInput())
- .Times(testing::AnyNumber());
- WebScopedInputEvent scoped_input_event(event.Clone());
- InputHandlerProxy::EventDisposition event_disposition =
- InputHandlerProxy::DID_NOT_HANDLE;
- input_handler->HandleInputEventWithLatencyInfo(
- std::move(scoped_input_event), ui::LatencyInfo(),
- base::BindLambdaForTesting(
- [&event_disposition](
- InputHandlerProxy::EventDisposition disposition,
- WebScopedInputEvent event, const LatencyInfo& latency_info,
- std::unique_ptr<ui::DidOverscrollParams> callback,
- const blink::WebInputEventAttribution& attribution) {
- event_disposition = disposition;
- }));
-
- input_handler->DispatchQueuedInputEventsHelper();
- return event_disposition;
-}
-
-class InputHandlerProxyEventQueueTest : public testing::Test {
- public:
- InputHandlerProxyEventQueueTest()
- : input_handler_proxy_(&mock_input_handler_,
- &mock_client_,
- /*force_input_to_main_thread=*/false) {
- if (input_handler_proxy_.compositor_event_queue_)
- input_handler_proxy_.compositor_event_queue_ =
- std::make_unique<CompositorThreadEventQueue>();
- SetScrollPredictionEnabled(true);
- }
-
- ~InputHandlerProxyEventQueueTest() = default;
-
- void HandleGestureEvent(WebInputEvent::Type type,
- float delta_y_or_scale = 0,
- int x = 0,
- int y = 0) {
- HandleGestureEventWithSourceDevice(
- type, blink::WebGestureDevice::kTouchscreen, delta_y_or_scale, x, y);
- }
-
- void HandleGestureEventWithSourceDevice(WebInputEvent::Type type,
- WebGestureDevice source_device,
- float delta_y_or_scale = 0,
- int x = 0,
- int y = 0) {
- LatencyInfo latency;
- input_handler_proxy_.HandleInputEventWithLatencyInfo(
- CreateGestureScrollPinch(type, source_device,
- input_handler_proxy_.tick_clock_->NowTicks(),
- delta_y_or_scale, x, y),
- latency,
- base::BindOnce(
- &InputHandlerProxyEventQueueTest::DidHandleInputEventAndOverscroll,
- weak_ptr_factory_.GetWeakPtr()));
- }
-
- void HandleMouseEvent(WebInputEvent::Type type, int x = 0, int y = 0) {
- WebMouseEvent mouse_event(type, WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests());
-
- mouse_event.SetPositionInWidget(gfx::PointF(x, y));
- mouse_event.button = blink::WebMouseEvent::Button::kLeft;
- HandleInputEventWithLatencyInfo(&input_handler_proxy_, mouse_event);
- }
-
- void DidHandleInputEventAndOverscroll(
- InputHandlerProxy::EventDisposition event_disposition,
- WebScopedInputEvent input_event,
- const ui::LatencyInfo& latency_info,
- std::unique_ptr<ui::DidOverscrollParams> overscroll_params,
- const blink::WebInputEventAttribution& attribution) {
- event_disposition_recorder_.push_back(event_disposition);
- latency_info_recorder_.push_back(latency_info);
- }
-
- base::circular_deque<std::unique_ptr<EventWithCallback>>& event_queue() {
- return input_handler_proxy_.compositor_event_queue_->queue_;
- }
-
- void SetInputHandlerProxyTickClockForTesting(
- const base::TickClock* tick_clock) {
- input_handler_proxy_.SetTickClockForTesting(tick_clock);
- }
-
- void DeliverInputForBeginFrame() {
- constexpr base::TimeDelta interval = base::TimeDelta::FromMilliseconds(16);
- base::TimeTicks frame_time =
- WebInputEvent::GetStaticTimeStampForTests() +
- (next_begin_frame_number_ - viz::BeginFrameArgs::kStartingFrameNumber) *
- interval;
- input_handler_proxy_.DeliverInputForBeginFrame(viz::BeginFrameArgs::Create(
- BEGINFRAME_FROM_HERE, 0, next_begin_frame_number_++, frame_time,
- frame_time + interval, interval, viz::BeginFrameArgs::NORMAL));
- }
-
- void DeliverInputForHighLatencyMode() {
- input_handler_proxy_.DeliverInputForHighLatencyMode();
- }
-
- void SetScrollPredictionEnabled(bool enabled) {
- input_handler_proxy_.scroll_predictor_ =
- enabled ? std::make_unique<ScrollPredictor>() : nullptr;
- }
-
- std::unique_ptr<ui::InputPredictor::InputData>
- GestureScrollEventPredictionAvailable() {
- return input_handler_proxy_.scroll_predictor_->predictor_
- ->GeneratePrediction(WebInputEvent::GetStaticTimeStampForTests());
- }
-
- protected:
- testing::StrictMock<MockInputHandler> mock_input_handler_;
- testing::StrictMock<MockInputHandlerProxyClient> mock_client_;
- TestInputHandlerProxy input_handler_proxy_;
- std::vector<InputHandlerProxy::EventDisposition> event_disposition_recorder_;
- std::vector<ui::LatencyInfo> latency_info_recorder_;
-
- uint64_t next_begin_frame_number_ = viz::BeginFrameArgs::kStartingFrameNumber;
-
- base::test::SingleThreadTaskEnvironment task_environment_;
- base::WeakPtrFactory<InputHandlerProxyEventQueueTest> weak_ptr_factory_{this};
-};
-
-// Tests that changing source devices mid gesture scroll is handled gracefully.
-// For example, when a touch scroll is in progress and the user initiates a
-// scrollbar scroll before the touch scroll has had a chance to dispatch a GSE.
-TEST_P(InputHandlerProxyTest, NestedGestureBasedScrolls) {
- // Touchpad initiates a scroll.
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(cc::ScrollInputType::kWheel,
- cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
-
- gesture_.SetType(WebInputEvent::kGestureScrollBegin);
- gesture_.SetSourceDevice(blink::WebGestureDevice::kTouchpad);
- EXPECT_EQ(InputHandlerProxy::DID_HANDLE,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
- EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
-
- VERIFY_AND_RESET_MOCKS();
-
- // Before ScrollEnd for touchpad is fired, user starts a thumb drag. This is
- // expected to immediately end the touchpad scroll.
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(cc::ScrollInputType::kWheel))
- .Times(1);
- EXPECT_CALL(mock_input_handler_, ScrollEnd(true)).Times(1);
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- // TODO(crbug.com/1060708): This should be called once.
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(cc::ScrollInputType::kScrollbar,
- cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(0);
- EXPECT_CALL(mock_input_handler_, ScrollUpdate(_, _)).Times(1);
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillOnce(testing::Return(false));
- WebMouseEvent mouse_event(WebInputEvent::kMouseDown,
- WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests());
- mouse_event.SetPositionInWidget(gfx::PointF(0, 20));
- mouse_event.button = blink::WebMouseEvent::Button::kLeft;
- EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
- HandleInputEventAndFlushEventQueue(
- mock_input_handler_, input_handler_.get(), mouse_event));
-
- VERIFY_AND_RESET_MOCKS();
-
- // Touchpad GSE comes in while a scrollbar drag is in progress. This is
- // expected to be dropped because a scrollbar scroll is currently active.
- gesture_.SetType(WebInputEvent::kGestureScrollEnd);
- gesture_.SetSourceDevice(blink::WebGestureDevice::kTouchpad);
- gesture_.data.scroll_update.delta_y = 0;
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(cc::ScrollInputType::kWheel))
- .Times(1);
- EXPECT_EQ(InputHandlerProxy::DROP_EVENT,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
- VERIFY_AND_RESET_MOCKS();
-
- // The GSE from the scrollbar needs to be handled.
- EXPECT_CALL(mock_input_handler_,
- RecordScrollEnd(cc::ScrollInputType::kScrollbar))
- .Times(1);
- EXPECT_CALL(mock_input_handler_, ScrollEnd(true)).Times(1);
- mouse_event.SetType(WebInputEvent::kMouseUp);
- EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
- HandleInputEventAndFlushEventQueue(
- mock_input_handler_, input_handler_.get(), mouse_event));
-
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, MouseWheelNoListener) {
- expected_disposition_ = InputHandlerProxy::DROP_EVENT;
- EXPECT_CALL(mock_input_handler_, HasBlockingWheelEventHandlerAt(_))
- .WillRepeatedly(testing::Return(false));
- EXPECT_CALL(mock_input_handler_,
- GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
- .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
-
- WebMouseWheelEvent wheel(WebInputEvent::kMouseWheel,
- WebInputEvent::kControlKey,
- WebInputEvent::GetStaticTimeStampForTests());
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), wheel));
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, MouseWheelPassiveListener) {
- expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
- EXPECT_CALL(mock_input_handler_, HasBlockingWheelEventHandlerAt(_))
- .WillRepeatedly(testing::Return(false));
- EXPECT_CALL(mock_input_handler_,
- GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
- .WillOnce(testing::Return(cc::EventListenerProperties::kPassive));
-
- WebMouseWheelEvent wheel(WebInputEvent::kMouseWheel,
- WebInputEvent::kControlKey,
- WebInputEvent::GetStaticTimeStampForTests());
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), wheel));
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, MouseWheelBlockingListener) {
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- EXPECT_CALL(mock_input_handler_, HasBlockingWheelEventHandlerAt(_))
- .WillRepeatedly(testing::Return(true));
-
- WebMouseWheelEvent wheel(WebInputEvent::kMouseWheel,
- WebInputEvent::kControlKey,
- WebInputEvent::GetStaticTimeStampForTests());
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), wheel));
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, MouseWheelBlockingAndPassiveListener) {
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- EXPECT_CALL(mock_input_handler_, HasBlockingWheelEventHandlerAt(_))
- .WillRepeatedly(testing::Return(true));
- // We will not call GetEventListenerProperties because we early out when we
- // hit blocking region.
- WebMouseWheelEvent wheel(WebInputEvent::kMouseWheel,
- WebInputEvent::kControlKey,
- WebInputEvent::GetStaticTimeStampForTests());
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), wheel));
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, MouseWheelEventOutsideBlockingListener) {
- expected_disposition_ = InputHandlerProxy::DROP_EVENT;
- EXPECT_CALL(mock_input_handler_,
- HasBlockingWheelEventHandlerAt(
- testing::Property(&gfx::Point::y, testing::Gt(10))))
- .WillRepeatedly(testing::Return(true));
- EXPECT_CALL(mock_input_handler_,
- HasBlockingWheelEventHandlerAt(
- testing::Property(&gfx::Point::y, testing::Le(10))))
- .WillRepeatedly(testing::Return(false));
- EXPECT_CALL(mock_input_handler_,
- GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
- .WillRepeatedly(testing::Return(cc::EventListenerProperties::kBlocking));
-
- WebMouseWheelEvent wheel(WebInputEvent::kMouseWheel,
- WebInputEvent::kControlKey,
- WebInputEvent::GetStaticTimeStampForTests());
- wheel.SetPositionInScreen(0, 5);
- wheel.SetPositionInWidget(0, 5);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), wheel));
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest,
- MouseWheelEventOutsideBlockingListenerWithPassiveListener) {
- expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
- EXPECT_CALL(mock_input_handler_,
- HasBlockingWheelEventHandlerAt(
- testing::Property(&gfx::Point::y, testing::Gt(10))))
- .WillRepeatedly(testing::Return(true));
- EXPECT_CALL(mock_input_handler_,
- HasBlockingWheelEventHandlerAt(
- testing::Property(&gfx::Point::y, testing::Le(10))))
- .WillRepeatedly(testing::Return(false));
- EXPECT_CALL(mock_input_handler_,
- GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
- .WillRepeatedly(
- testing::Return(cc::EventListenerProperties::kBlockingAndPassive));
-
- WebMouseWheelEvent wheel(WebInputEvent::kMouseWheel,
- WebInputEvent::kControlKey,
- WebInputEvent::GetStaticTimeStampForTests());
- wheel.SetPositionInScreen(0, 5);
- wheel.SetPositionInWidget(0, 5);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), wheel));
- VERIFY_AND_RESET_MOCKS();
-}
-
-void InputHandlerProxyTest::GestureScrollStarted() {
- // We shouldn't send any events to the widget for this gesture.
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
-
- gesture_.SetType(WebInputEvent::kGestureScrollBegin);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- // The event should not be marked as handled if scrolling is not possible.
- expected_disposition_ = InputHandlerProxy::DROP_EVENT;
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGestureScrollUpdate);
- gesture_.data.scroll_update.delta_y =
- -40; // -Y means scroll down - i.e. in the +Y direction.
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillOnce(testing::Return(scroll_result_did_not_scroll_));
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillOnce(testing::Return(false));
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- // Mark the event as handled if scroll happens.
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillOnce(testing::Return(false));
- gesture_.SetType(WebInputEvent::kGestureScrollUpdate);
- gesture_.data.scroll_update.delta_y =
- -40; // -Y means scroll down - i.e. in the +Y direction.
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillOnce(testing::Return(scroll_result_did_scroll_));
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGestureScrollEnd);
- gesture_.data.scroll_update.delta_y = 0;
- EXPECT_CALL(mock_input_handler_, ScrollEnd(true));
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-}
-TEST_P(InputHandlerProxyTest, GestureScrollStarted) {
- GestureScrollStarted();
-}
-
-TEST_P(InputHandlerProxyTest, GestureScrollOnMainThread) {
- // We should send all events to the widget for this gesture.
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kMainThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnMain))
- .Times(1);
-
- gesture_.SetType(WebInputEvent::kGestureScrollBegin);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGestureScrollUpdate);
- gesture_.data.scroll_update.delta_y = 40;
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGestureScrollEnd);
- gesture_.data.scroll_update.delta_y = 0;
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, GestureScrollIgnored) {
- // We shouldn't handle the GestureScrollBegin.
- // Instead, we should get a DROP_EVENT result, indicating
- // that we could determine that there's nothing that could scroll or otherwise
- // react to this gesture sequence and thus we should drop the whole gesture
- // sequence on the floor, except for the ScrollEnd.
- expected_disposition_ = InputHandlerProxy::DROP_EVENT;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kScrollIgnoredScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnMain))
- .Times(1);
-
- gesture_.SetType(WebInputEvent::kGestureScrollBegin);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-
- // GSB is dropped and not sent to the main thread, GSE shouldn't get sent to
- // the main thread, either.
- expected_disposition_ = InputHandlerProxy::DROP_EVENT;
- gesture_.SetType(WebInputEvent::kGestureScrollEnd);
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, GestureScrollByPage) {
- // We should send all events to the widget for this gesture.
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGestureScrollBegin);
- gesture_.data.scroll_begin.delta_hint_units =
- ui::ScrollGranularity::kScrollByPage;
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnMain))
- .Times(1);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGestureScrollUpdate);
- gesture_.data.scroll_update.delta_y = 1;
- gesture_.data.scroll_update.delta_units =
- ui::ScrollGranularity::kScrollByPage;
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGestureScrollEnd);
- gesture_.data.scroll_update.delta_y = 0;
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, GestureScrollBeginThatTargetViewport) {
- // We shouldn't send any events to the widget for this gesture.
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(mock_input_handler_, RootScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
-
- gesture_.SetType(WebInputEvent::kGestureScrollBegin);
- gesture_.data.scroll_begin.target_viewport = true;
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-}
-
-void InputHandlerProxyTest::FlingAndSnap() {
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
-
- gesture_.SetType(WebInputEvent::kGestureScrollBegin);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), gesture_));
-
- // The event should be dropped if InputHandler decides to snap.
- expected_disposition_ = InputHandlerProxy::DROP_EVENT;
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGestureScrollUpdate);
- gesture_.data.scroll_update.delta_y =
- -40; // -Y means scroll down - i.e. in the +Y direction.
- gesture_.data.scroll_update.inertial_phase =
- blink::WebGestureEvent::InertialPhaseState::kMomentum;
- EXPECT_CALL(mock_input_handler_,
- GetSnapFlingInfoAndSetAnimatingSnapTarget(_, _, _))
- .WillOnce(DoAll(testing::SetArgPointee<1>(gfx::Vector2dF(0, 0)),
- testing::SetArgPointee<2>(gfx::Vector2dF(0, 100)),
- testing::Return(true)));
- EXPECT_CALL(mock_input_handler_, ScrollUpdate(_, _)).Times(1);
- EXPECT_SET_NEEDS_ANIMATE_INPUT(1);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), gesture_));
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, SnapFlingIgnoresFollowingGSUAndGSE) {
- FlingAndSnap();
- // The next GestureScrollUpdate should also be ignored, and will not ask for
- // snap position.
- expected_disposition_ = InputHandlerProxy::DROP_EVENT;
-
- EXPECT_CALL(mock_input_handler_,
- GetSnapFlingInfoAndSetAnimatingSnapTarget(_, _, _))
- .Times(0);
- EXPECT_CALL(mock_input_handler_, ScrollUpdate(_, _)).Times(0);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
- VERIFY_AND_RESET_MOCKS();
-
- // The GestureScrollEnd should also be ignored.
- expected_disposition_ = InputHandlerProxy::DROP_EVENT;
- gesture_.SetType(WebInputEvent::kGestureScrollEnd);
- gesture_.data.scroll_end.inertial_phase =
- blink::WebGestureEvent::InertialPhaseState::kMomentum;
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(0);
- EXPECT_CALL(mock_input_handler_, ScrollEnd(_)).Times(0);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, GesturePinch) {
- // We shouldn't send any events to the widget for this gesture.
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGesturePinchBegin);
- EXPECT_CALL(mock_input_handler_, PinchGestureBegin());
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGesturePinchUpdate);
- gesture_.data.pinch_update.scale = 1.5;
- gesture_.SetPositionInWidget(gfx::PointF(7, 13));
- EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13)));
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGesturePinchUpdate);
- gesture_.data.pinch_update.scale = 0.5;
- gesture_.SetPositionInWidget(gfx::PointF(9, 6));
- EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(.5, gfx::Point(9, 6)));
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGesturePinchEnd);
- EXPECT_CALL(mock_input_handler_, PinchGestureEnd(gfx::Point(9, 6), true));
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, GesturePinchAfterScrollOnMainThread) {
- // Scrolls will start by being sent to the main thread.
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kMainThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnMain))
- .Times(1);
-
- gesture_.SetType(WebInputEvent::kGestureScrollBegin);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGestureScrollUpdate);
- gesture_.data.scroll_update.delta_y = 40;
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- // However, after the pinch gesture starts, they should go to the impl
- // thread.
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGesturePinchBegin);
- EXPECT_CALL(mock_input_handler_, PinchGestureBegin());
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGesturePinchUpdate);
- gesture_.data.pinch_update.scale = 1.5;
- gesture_.SetPositionInWidget(gfx::PointF(7, 13));
- EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(1.5, gfx::Point(7, 13)));
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillOnce(testing::Return(false));
- gesture_.SetType(WebInputEvent::kGestureScrollUpdate);
- gesture_.data.scroll_update.delta_y =
- -40; // -Y means scroll down - i.e. in the +Y direction.
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillOnce(testing::Return(scroll_result_did_scroll_));
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGesturePinchUpdate);
- gesture_.data.pinch_update.scale = 0.5;
- gesture_.SetPositionInWidget(gfx::PointF(9, 6));
- EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(.5, gfx::Point(9, 6)));
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGesturePinchEnd);
- EXPECT_CALL(mock_input_handler_, PinchGestureEnd(gfx::Point(9, 6), true));
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- // After the pinch gesture ends, they should go to back to the main
- // thread.
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGestureScrollEnd);
- gesture_.data.scroll_update.delta_y = 0;
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-}
-
-void InputHandlerProxyTest::ScrollHandlingSwitchedToMainThread() {
- // We shouldn't send any events to the widget for this gesture.
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
-
- // HandleGestureScrollBegin will set gesture_scroll_on_impl_thread_.
- gesture_.SetType(WebInputEvent::kGestureScrollBegin);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
- EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
-
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGestureScrollUpdate);
- gesture_.data.scroll_update.delta_y = -40;
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillOnce(testing::Return(false));
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillOnce(testing::Return(scroll_result_did_scroll_));
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
- EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
- VERIFY_AND_RESET_MOCKS();
-
- // The scroll handling switches to the main thread, a GSB is sent to the main
- // thread to initiate the hit testing and compute the scroll chain.
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- EXPECT_CALL(mock_input_handler_, ScrollUpdate(_, _)).Times(0);
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillOnce(testing::Return(true));
- EXPECT_CALL(mock_client_, GenerateScrollBeginAndSendToMainThread(_, _));
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
- EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
-
- VERIFY_AND_RESET_MOCKS();
-
- gesture_.SetType(WebInputEvent::kGestureScrollEnd);
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(mock_input_handler_,
- input_handler_.get(), gesture_));
-
- VERIFY_AND_RESET_MOCKS();
-}
-TEST_P(InputHandlerProxyTest, WheelScrollHandlingSwitchedToMainThread) {
- gesture_.SetSourceDevice(blink::WebGestureDevice::kTouchpad);
- ScrollHandlingSwitchedToMainThread();
-}
-TEST_P(InputHandlerProxyTest, TouchScrollHandlingSwitchedToMainThread) {
- gesture_.SetSourceDevice(blink::WebGestureDevice::kTouchscreen);
- ScrollHandlingSwitchedToMainThread();
-}
-
-TEST_P(InputHandlerProxyTest,
- GestureScrollOnImplThreadFlagClearedAfterScrollEnd) {
- // We shouldn't send any events to the widget for this gesture.
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
-
- gesture_.SetType(WebInputEvent::kGestureScrollBegin);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), gesture_));
-
- // After sending a GestureScrollBegin, the member variable
- // |gesture_scroll_on_impl_thread_| should be true.
- EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
-
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(mock_input_handler_, ScrollEnd(true));
- gesture_.SetType(WebInputEvent::kGestureScrollEnd);
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), gesture_));
-
- // |gesture_scroll_on_impl_thread_| should be false once a GestureScrollEnd
- // gets handled.
- EXPECT_FALSE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
-
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest,
- BeginScrollWhenGestureScrollOnImplThreadFlagIsSet) {
- // We shouldn't send any events to the widget for this gesture.
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
-
- gesture_.SetType(WebInputEvent::kGestureScrollBegin);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), gesture_));
-
- // After sending a GestureScrollBegin, the member variable
- // |gesture_scroll_on_impl_thread_| should be true.
- EXPECT_TRUE(input_handler_->gesture_scroll_on_impl_thread_for_testing());
-
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, HitTestTouchEventNonNullTouchAction) {
- // One of the touch points is on a touch-region. So the event should be sent
- // to the main thread.
- expected_disposition_ = compositor_touch_action_enabled_
- ? InputHandlerProxy::DID_HANDLE_NON_BLOCKING
- : InputHandlerProxy::DID_NOT_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(mock_input_handler_,
- EventListenerTypeForTouchStartOrMoveAt(
- testing::Property(&gfx::Point::x, testing::Eq(0)), _))
- .WillOnce(testing::Invoke([](const gfx::Point&,
- cc::TouchAction* touch_action) {
- *touch_action = cc::TouchAction::kMax;
- return cc::InputHandler::TouchStartOrMoveEventListenerType::NO_HANDLER;
- }));
-
- EXPECT_CALL(mock_input_handler_,
- EventListenerTypeForTouchStartOrMoveAt(
- testing::Property(&gfx::Point::x, testing::Gt(0)), _))
- .WillOnce(
- testing::Invoke([](const gfx::Point&, cc::TouchAction* touch_action) {
- *touch_action = cc::TouchAction::kPanUp;
- return cc::InputHandler::TouchStartOrMoveEventListenerType::
- HANDLER_ON_SCROLLING_LAYER;
- }));
- // Since the second touch point hits a touch-region, there should be no
- // hit-testing for the third touch point.
-
- WebTouchEvent touch(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests());
-
- touch.touches_length = 3;
- touch.touch_start_or_first_touch_move = true;
- touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, 0, 0);
- touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, 10, 10);
- touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, -10, 10);
-
- bool is_touching_scrolling_layer;
- cc::TouchAction white_listed_touch_action = cc::TouchAction::kAuto;
- EXPECT_EQ(expected_disposition_, input_handler_->HitTestTouchEventForTest(
- touch, &is_touching_scrolling_layer,
- &white_listed_touch_action));
- EXPECT_TRUE(is_touching_scrolling_layer);
- EXPECT_EQ(white_listed_touch_action, cc::TouchAction::kPanUp);
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, HitTestTouchEventNullTouchAction) {
- // One of the touch points is on a touch-region. So the event should be sent
- // to the main thread.
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(mock_input_handler_,
- EventListenerTypeForTouchStartOrMoveAt(
- testing::Property(&gfx::Point::x, testing::Eq(0)), _))
- .WillOnce(testing::Return(
- cc::InputHandler::TouchStartOrMoveEventListenerType::NO_HANDLER));
-
- EXPECT_CALL(mock_input_handler_,
- EventListenerTypeForTouchStartOrMoveAt(
- testing::Property(&gfx::Point::x, testing::Gt(0)), _))
- .WillOnce(
- testing::Return(cc::InputHandler::TouchStartOrMoveEventListenerType::
- HANDLER_ON_SCROLLING_LAYER));
- // Since the second touch point hits a touch-region, there should be no
- // hit-testing for the third touch point.
-
- WebTouchEvent touch(WebInputEvent::kTouchMove, WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests());
-
- touch.touches_length = 3;
- touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, 0, 0);
- touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, 10, 10);
- touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, -10, 10);
-
- bool is_touching_scrolling_layer;
- cc::TouchAction* white_listed_touch_action = nullptr;
- EXPECT_EQ(expected_disposition_, input_handler_->HitTestTouchEventForTest(
- touch, &is_touching_scrolling_layer,
- white_listed_touch_action));
- EXPECT_TRUE(is_touching_scrolling_layer);
- EXPECT_TRUE(!white_listed_touch_action);
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestNegative) {
- // None of the three touch points fall in the touch region. So the event
- // should be dropped.
- expected_disposition_ = InputHandlerProxy::DROP_EVENT;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(
- mock_input_handler_,
- GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove))
- .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
- EXPECT_CALL(
- mock_input_handler_,
- GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel))
- .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
- EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartOrMoveAt(_, _))
- .Times(2)
- .WillRepeatedly(testing::Invoke([](const gfx::Point&,
- cc::TouchAction* touch_action) {
- *touch_action = cc::TouchAction::kPanUp;
- return cc::InputHandler::TouchStartOrMoveEventListenerType::NO_HANDLER;
- }));
- EXPECT_CALL(mock_client_,
- SetWhiteListedTouchAction(cc::TouchAction::kPanUp, 1,
- InputHandlerProxy::DROP_EVENT))
- .WillOnce(testing::Return());
-
- WebTouchEvent touch(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests());
-
- touch.unique_touch_event_id = 1;
- touch.touches_length = 3;
- touch.touch_start_or_first_touch_move = true;
- touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::kStateStationary, 0, 0);
- touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, 10, 10);
- touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, -10, 10);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), touch));
-
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPositive) {
- // One of the touch points is on a touch-region. So the event should be sent
- // to the main thread.
- expected_disposition_ = compositor_touch_action_enabled_
- ? InputHandlerProxy::DID_HANDLE_NON_BLOCKING
- : InputHandlerProxy::DID_NOT_HANDLE;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(mock_input_handler_,
- EventListenerTypeForTouchStartOrMoveAt(
- testing::Property(&gfx::Point::x, testing::Eq(0)), _))
- .WillOnce(testing::Invoke([](const gfx::Point&,
- cc::TouchAction* touch_action) {
- *touch_action = cc::TouchAction::kAuto;
- return cc::InputHandler::TouchStartOrMoveEventListenerType::NO_HANDLER;
- }));
- EXPECT_CALL(mock_input_handler_,
- EventListenerTypeForTouchStartOrMoveAt(
- testing::Property(&gfx::Point::x, testing::Gt(0)), _))
- .WillOnce(
- testing::Invoke([](const gfx::Point&, cc::TouchAction* touch_action) {
- *touch_action = cc::TouchAction::kPanY;
- return cc::InputHandler::TouchStartOrMoveEventListenerType::
- HANDLER_ON_SCROLLING_LAYER;
- }));
- EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(cc::TouchAction::kPanY, 1,
- expected_disposition_))
- .WillOnce(testing::Return());
- // Since the second touch point hits a touch-region, there should be no
- // hit-testing for the third touch point.
-
- WebTouchEvent touch(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests());
-
- touch.unique_touch_event_id = 1;
- touch.touches_length = 3;
- touch.touch_start_or_first_touch_move = true;
- touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, 0, 0);
- touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, 10, 10);
- touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, -10, 10);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), touch));
-
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, MultiTouchPointHitTestPassivePositive) {
- // One of the touch points is not on a touch-region. So the event should be
- // sent to the impl thread.
- expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(
- mock_input_handler_,
- GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove))
- .WillRepeatedly(testing::Return(cc::EventListenerProperties::kPassive));
- EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartOrMoveAt(_, _))
- .Times(3)
- .WillOnce(testing::Invoke([](const gfx::Point&,
- cc::TouchAction* touch_action) {
- *touch_action = cc::TouchAction::kPanRight;
- return cc::InputHandler::TouchStartOrMoveEventListenerType::NO_HANDLER;
- }))
- .WillRepeatedly(testing::Invoke([](const gfx::Point&,
- cc::TouchAction* touch_action) {
- *touch_action = cc::TouchAction::kPanX;
- return cc::InputHandler::TouchStartOrMoveEventListenerType::NO_HANDLER;
- }));
- EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(
- cc::TouchAction::kPanRight, 1,
- InputHandlerProxy::DID_HANDLE_NON_BLOCKING))
- .WillOnce(testing::Return());
-
- WebTouchEvent touch(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests());
-
- touch.unique_touch_event_id = 1;
- touch.touches_length = 3;
- touch.touch_start_or_first_touch_move = true;
- touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, 0, 0);
- touch.touches[1] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, 10, 10);
- touch.touches[2] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, -10, 10);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), touch));
-
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, TouchStartPassiveAndTouchEndBlocking) {
- // The touch start is not in a touch-region but there is a touch end handler
- // so to maintain targeting we need to dispatch the touch start as
- // non-blocking but drop all touch moves.
- expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(
- mock_input_handler_,
- GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove))
- .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
- EXPECT_CALL(
- mock_input_handler_,
- GetEventListenerProperties(cc::EventListenerClass::kTouchEndOrCancel))
- .WillOnce(testing::Return(cc::EventListenerProperties::kBlocking));
- EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartOrMoveAt(_, _))
- .WillOnce(testing::Invoke([](const gfx::Point&,
- cc::TouchAction* touch_action) {
- *touch_action = cc::TouchAction::kNone;
- return cc::InputHandler::TouchStartOrMoveEventListenerType::NO_HANDLER;
- }));
- EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(
- cc::TouchAction::kNone, 1,
- InputHandlerProxy::DID_HANDLE_NON_BLOCKING))
- .WillOnce(testing::Return());
-
- WebTouchEvent touch(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests());
- touch.unique_touch_event_id = 1;
- touch.touches_length = 1;
- touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, 0, 0);
- touch.touch_start_or_first_touch_move = true;
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), touch));
-
- touch.SetType(WebInputEvent::kTouchMove);
- touch.touches_length = 1;
- touch.touch_start_or_first_touch_move = false;
- touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, 10, 10);
- EXPECT_EQ(InputHandlerProxy::DROP_EVENT,
- HandleInputEventWithLatencyInfo(input_handler_.get(), touch));
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST_P(InputHandlerProxyTest, TouchMoveBlockingAddedAfterPassiveTouchStart) {
- // The touch start is not in a touch-region but there is a touch end handler
- // so to maintain targeting we need to dispatch the touch start as
- // non-blocking but drop all touch moves.
- VERIFY_AND_RESET_MOCKS();
-
- EXPECT_CALL(
- mock_input_handler_,
- GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove))
- .WillOnce(testing::Return(cc::EventListenerProperties::kPassive));
- EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartOrMoveAt(_, _))
- .WillOnce(testing::Return(
- cc::InputHandler::TouchStartOrMoveEventListenerType::NO_HANDLER));
- EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(_, _, _))
- .WillOnce(testing::Return());
-
- WebTouchEvent touch(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests());
- touch.touches_length = 1;
- touch.touch_start_or_first_touch_move = true;
- touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, 0, 0);
- EXPECT_EQ(InputHandlerProxy::DID_HANDLE_NON_BLOCKING,
- HandleInputEventWithLatencyInfo(input_handler_.get(), touch));
-
- EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartOrMoveAt(_, _))
- .WillOnce(testing::Return(
- cc::InputHandler::TouchStartOrMoveEventListenerType::HANDLER));
- EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(_, _, _))
- .WillOnce(testing::Return());
-
- touch.SetType(WebInputEvent::kTouchMove);
- touch.touches_length = 1;
- touch.touch_start_or_first_touch_move = true;
- touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::kStateMoved, 10, 10);
- EXPECT_EQ(compositor_touch_action_enabled_
- ? InputHandlerProxy::DID_HANDLE_NON_BLOCKING
- : InputHandlerProxy::DID_NOT_HANDLE,
- HandleInputEventWithLatencyInfo(input_handler_.get(), touch));
- VERIFY_AND_RESET_MOCKS();
-}
-
-TEST(SynchronousInputHandlerProxyTest, StartupShutdown) {
- testing::StrictMock<MockInputHandler> mock_input_handler;
- testing::StrictMock<MockInputHandlerProxyClient> mock_client;
- testing::StrictMock<MockSynchronousInputHandler>
- mock_synchronous_input_handler;
- ui::InputHandlerProxy proxy(&mock_input_handler, &mock_client, false);
-
- // When adding a SynchronousInputHandler, immediately request an
- // UpdateRootLayerStateForSynchronousInputHandler() call.
- EXPECT_CALL(mock_input_handler, RequestUpdateForSynchronousInputHandler())
- .Times(1);
- proxy.SetSynchronousInputHandler(&mock_synchronous_input_handler);
-
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler);
- testing::Mock::VerifyAndClearExpectations(&mock_client);
- testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler);
-
- EXPECT_CALL(mock_input_handler, RequestUpdateForSynchronousInputHandler())
- .Times(0);
- proxy.SetSynchronousInputHandler(nullptr);
-
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler);
- testing::Mock::VerifyAndClearExpectations(&mock_client);
- testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler);
-}
-
-TEST(SynchronousInputHandlerProxyTest, UpdateRootLayerState) {
- testing::NiceMock<MockInputHandler> mock_input_handler;
- testing::StrictMock<MockInputHandlerProxyClient> mock_client;
- testing::StrictMock<MockSynchronousInputHandler>
- mock_synchronous_input_handler;
- ui::InputHandlerProxy proxy(&mock_input_handler, &mock_client, false);
-
- proxy.SetSynchronousInputHandler(&mock_synchronous_input_handler);
-
- // When adding a SynchronousInputHandler, immediately request an
- // UpdateRootLayerStateForSynchronousInputHandler() call.
- EXPECT_CALL(
- mock_synchronous_input_handler,
- UpdateRootLayerState(gfx::ScrollOffset(1, 2), gfx::ScrollOffset(3, 4),
- gfx::SizeF(5, 6), 7, 8, 9))
- .Times(1);
- proxy.UpdateRootLayerStateForSynchronousInputHandler(
- gfx::ScrollOffset(1, 2), gfx::ScrollOffset(3, 4), gfx::SizeF(5, 6), 7, 8,
- 9);
-
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler);
- testing::Mock::VerifyAndClearExpectations(&mock_client);
- testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler);
-}
-
-TEST(SynchronousInputHandlerProxyTest, SetOffset) {
- testing::NiceMock<MockInputHandler> mock_input_handler;
- testing::StrictMock<MockInputHandlerProxyClient> mock_client;
- testing::StrictMock<MockSynchronousInputHandler>
- mock_synchronous_input_handler;
- ui::InputHandlerProxy proxy(&mock_input_handler, &mock_client, false);
-
- proxy.SetSynchronousInputHandler(&mock_synchronous_input_handler);
-
- EXPECT_CALL(mock_input_handler, SetSynchronousInputHandlerRootScrollOffset(
- gfx::ScrollOffset(5, 6)));
- proxy.SynchronouslySetRootScrollOffset(gfx::ScrollOffset(5, 6));
-
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler);
- testing::Mock::VerifyAndClearExpectations(&mock_client);
- testing::Mock::VerifyAndClearExpectations(&mock_synchronous_input_handler);
-}
-
-TEST_F(InputHandlerProxyEventQueueTest,
- MouseEventOnScrollbarInitiatesGestureScroll) {
- EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1);
-
- // Test mousedown on the scrollbar. Expect to get GSB and GSU.
- HandleMouseEvent(WebInputEvent::kMouseDown);
- EXPECT_EQ(2ul, event_queue().size());
- EXPECT_EQ(event_queue()[0]->event().GetType(),
- blink::WebInputEvent::Type::kGestureScrollBegin);
- EXPECT_EQ(event_queue()[1]->event().GetType(),
- blink::WebInputEvent::Type::kGestureScrollUpdate);
-
- // Test mouseup on the scrollbar. Expect to get GSE.
- HandleMouseEvent(WebInputEvent::kMouseUp);
- EXPECT_EQ(3ul, event_queue().size());
- EXPECT_EQ(event_queue()[2]->event().GetType(),
- blink::WebInputEvent::Type::kGestureScrollEnd);
-}
-
-TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedGestureScroll) {
- // Handle scroll on compositor.
- cc::InputHandlerScrollResult scroll_result_did_scroll_;
- scroll_result_did_scroll_.did_scroll = true;
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
- EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1);
-
- HandleGestureEvent(WebInputEvent::kGestureScrollBegin);
-
- // GestureScrollBegin will be processed immediately.
- EXPECT_EQ(0ul, event_queue().size());
- EXPECT_EQ(1ul, event_disposition_recorder_.size());
- EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[0]);
-
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -20);
-
- // GestureScrollUpdate will be queued.
- EXPECT_EQ(1ul, event_queue().size());
- EXPECT_EQ(-20, static_cast<const blink::WebGestureEvent&>(
- event_queue().front()->event())
- .data.scroll_update.delta_y);
- EXPECT_EQ(1ul, event_queue().front()->coalesced_count());
- EXPECT_EQ(1ul, event_disposition_recorder_.size());
-
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -40);
-
- // GestureScrollUpdate will be coalesced.
- EXPECT_EQ(1ul, event_queue().size());
- EXPECT_EQ(-60, static_cast<const blink::WebGestureEvent&>(
- event_queue().front()->event())
- .data.scroll_update.delta_y);
- EXPECT_EQ(2ul, event_queue().front()->coalesced_count());
- EXPECT_EQ(1ul, event_disposition_recorder_.size());
-
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(0);
- HandleGestureEvent(WebInputEvent::kGestureScrollEnd);
-
- // GestureScrollEnd will be queued.
- EXPECT_EQ(2ul, event_queue().size());
- EXPECT_EQ(1ul, event_disposition_recorder_.size());
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
-
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillOnce(testing::Return(false));
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillOnce(testing::Return(scroll_result_did_scroll_));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(true));
-
- // Dispatch all queued events.
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- DeliverInputForBeginFrame();
- EXPECT_EQ(0ul, event_queue().size());
- // Should run callbacks for every original events.
- EXPECT_EQ(4ul, event_disposition_recorder_.size());
- EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[1]);
- EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[2]);
- EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_[3]);
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
-}
-
-#if defined(ADDRESS_SANITIZER) || defined(THREAD_SANITIZER)
-// Flaky under sanitizers and in other "slow" bot configs:
-// https://crbug.com/1029250
-#define MAYBE_VSyncAlignedGestureScrollPinchScroll \
- DISABLED_VSyncAlignedGestureScrollPinchScroll
-#else
-#define MAYBE_VSyncAlignedGestureScrollPinchScroll \
- VSyncAlignedGestureScrollPinchScroll
-#endif
-
-TEST_F(InputHandlerProxyEventQueueTest,
- MAYBE_VSyncAlignedGestureScrollPinchScroll) {
- // Handle scroll on compositor.
- cc::InputHandlerScrollResult scroll_result_did_scroll_;
- scroll_result_did_scroll_.did_scroll = true;
-
- // Start scroll in the first frame.
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillOnce(testing::Return(false));
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillOnce(testing::Return(scroll_result_did_scroll_));
- EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1);
-
- HandleGestureEvent(WebInputEvent::kGestureScrollBegin);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -20);
-
- EXPECT_EQ(1ul, event_queue().size());
- EXPECT_EQ(1ul, event_disposition_recorder_.size());
-
- DeliverInputForBeginFrame();
-
- EXPECT_EQ(0ul, event_queue().size());
- EXPECT_EQ(2ul, event_disposition_recorder_.size());
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
-
- // Continue scroll in the second frame, pinch, then start another scroll.
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillRepeatedly(testing::Return(false));
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillRepeatedly(testing::Return(scroll_result_did_scroll_));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(true)).Times(2);
- EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1);
- EXPECT_CALL(mock_input_handler_, PinchGestureBegin());
- // Two |GesturePinchUpdate| will be coalesced.
- EXPECT_CALL(mock_input_handler_,
- PinchGestureUpdate(0.7f, gfx::Point(13, 17)));
- EXPECT_CALL(mock_input_handler_, PinchGestureEnd(gfx::Point(), false));
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(2);
-
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -30);
- HandleGestureEvent(WebInputEvent::kGestureScrollEnd);
- HandleGestureEvent(WebInputEvent::kGesturePinchBegin);
- HandleGestureEvent(WebInputEvent::kGesturePinchUpdate, 1.4f, 13, 17);
- HandleGestureEvent(WebInputEvent::kGesturePinchUpdate, 0.5f, 13, 17);
- HandleGestureEvent(WebInputEvent::kGesturePinchEnd);
- HandleGestureEvent(WebInputEvent::kGestureScrollBegin);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -70);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -5);
- HandleGestureEvent(WebInputEvent::kGestureScrollEnd);
-
- EXPECT_EQ(8ul, event_queue().size());
- EXPECT_EQ(2ul, event_disposition_recorder_.size());
-
- DeliverInputForBeginFrame();
-
- EXPECT_EQ(0ul, event_queue().size());
- EXPECT_EQ(12ul, event_disposition_recorder_.size());
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
-}
-
-TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedQueueingTime) {
- base::SimpleTestTickClock tick_clock;
- tick_clock.SetNowTicks(base::TimeTicks::Now());
- SetInputHandlerProxyTickClockForTesting(&tick_clock);
-
- // Handle scroll on compositor.
- cc::InputHandlerScrollResult scroll_result_did_scroll_;
- scroll_result_did_scroll_.did_scroll = true;
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
- EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1);
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillOnce(testing::Return(false));
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillOnce(testing::Return(scroll_result_did_scroll_));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(true));
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
-
- HandleGestureEvent(WebInputEvent::kGestureScrollBegin);
- tick_clock.Advance(base::TimeDelta::FromMicroseconds(10));
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -20);
- tick_clock.Advance(base::TimeDelta::FromMicroseconds(40));
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -40);
- tick_clock.Advance(base::TimeDelta::FromMicroseconds(20));
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -10);
- tick_clock.Advance(base::TimeDelta::FromMicroseconds(10));
- HandleGestureEvent(WebInputEvent::kGestureScrollEnd);
-
- // Dispatch all queued events.
- tick_clock.Advance(base::TimeDelta::FromMicroseconds(70));
- DeliverInputForBeginFrame();
- EXPECT_EQ(0ul, event_queue().size());
- EXPECT_EQ(5ul, event_disposition_recorder_.size());
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
-}
-
-TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedCoalesceScrollAndPinch) {
- // Start scroll in the first frame.
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
- EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1);
-
- // GSUs and GPUs in one sequence should be coalesced into 1 GSU and 1 GPU.
- HandleGestureEvent(WebInputEvent::kGestureScrollBegin);
- HandleGestureEvent(WebInputEvent::kGesturePinchBegin);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -20);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -7);
- HandleGestureEvent(WebInputEvent::kGesturePinchUpdate, 2.0f, 13, 10);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -10);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -6);
- HandleGestureEvent(WebInputEvent::kGesturePinchEnd);
- HandleGestureEvent(WebInputEvent::kGestureScrollEnd);
- HandleGestureEvent(WebInputEvent::kGestureScrollBegin);
- HandleGestureEvent(WebInputEvent::kGesturePinchBegin);
- HandleGestureEvent(WebInputEvent::kGesturePinchUpdate, 0.2f, 2, 20);
- HandleGestureEvent(WebInputEvent::kGesturePinchUpdate, 10.0f, 1, 10);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -30);
- HandleGestureEvent(WebInputEvent::kGesturePinchUpdate, 0.25f, 3, 30);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -10);
- HandleGestureEvent(WebInputEvent::kGesturePinchEnd);
- HandleGestureEvent(WebInputEvent::kGestureScrollEnd);
-
- // Only the first GSB was dispatched.
- EXPECT_EQ(11ul, event_queue().size());
- EXPECT_EQ(1ul, event_disposition_recorder_.size());
-
- EXPECT_EQ(WebInputEvent::kGesturePinchBegin,
- event_queue()[0]->event().GetType());
- EXPECT_EQ(WebInputEvent::kGestureScrollUpdate,
- event_queue()[1]->event().GetType());
- EXPECT_EQ(
- -35,
- ToWebGestureEvent(event_queue()[1]->event()).data.scroll_update.delta_y);
- EXPECT_EQ(WebInputEvent::kGesturePinchUpdate,
- event_queue()[2]->event().GetType());
- EXPECT_EQ(
- 2.0f,
- ToWebGestureEvent(event_queue()[2]->event()).data.pinch_update.scale);
- EXPECT_EQ(WebInputEvent::kGesturePinchEnd,
- event_queue()[3]->event().GetType());
- EXPECT_EQ(WebInputEvent::kGestureScrollEnd,
- event_queue()[4]->event().GetType());
- EXPECT_EQ(WebInputEvent::kGestureScrollBegin,
- event_queue()[5]->event().GetType());
- EXPECT_EQ(WebInputEvent::kGesturePinchBegin,
- event_queue()[6]->event().GetType());
- EXPECT_EQ(WebInputEvent::kGestureScrollUpdate,
- event_queue()[7]->event().GetType());
- EXPECT_EQ(
- -85,
- ToWebGestureEvent(event_queue()[7]->event()).data.scroll_update.delta_y);
- EXPECT_EQ(WebInputEvent::kGesturePinchUpdate,
- event_queue()[8]->event().GetType());
- EXPECT_EQ(
- 0.5f,
- ToWebGestureEvent(event_queue()[8]->event()).data.pinch_update.scale);
- EXPECT_EQ(WebInputEvent::kGesturePinchEnd,
- event_queue()[9]->event().GetType());
- EXPECT_EQ(WebInputEvent::kGestureScrollEnd,
- event_queue()[10]->event().GetType());
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
-}
-
-TEST_F(InputHandlerProxyEventQueueTest, VSyncAlignedCoalesceTouchpadPinch) {
- EXPECT_CALL(mock_input_handler_, PinchGestureBegin());
- EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput());
-
- HandleGestureEventWithSourceDevice(WebInputEvent::kGesturePinchBegin,
- blink::WebGestureDevice::kTouchpad);
- HandleGestureEventWithSourceDevice(WebInputEvent::kGesturePinchUpdate,
- blink::WebGestureDevice::kTouchpad, 1.1f,
- 10, 20);
- // The second update should coalesce with the first.
- HandleGestureEventWithSourceDevice(WebInputEvent::kGesturePinchUpdate,
- blink::WebGestureDevice::kTouchpad, 1.1f,
- 10, 20);
- // The third update has a different anchor so it should not be coalesced.
- HandleGestureEventWithSourceDevice(WebInputEvent::kGesturePinchUpdate,
- blink::WebGestureDevice::kTouchpad, 1.1f,
- 11, 21);
- HandleGestureEventWithSourceDevice(WebInputEvent::kGesturePinchEnd,
- blink::WebGestureDevice::kTouchpad);
-
- // Only the PinchBegin was dispatched.
- EXPECT_EQ(3ul, event_queue().size());
- EXPECT_EQ(1ul, event_disposition_recorder_.size());
-
- ASSERT_EQ(WebInputEvent::kGesturePinchUpdate,
- event_queue()[0]->event().GetType());
- EXPECT_FLOAT_EQ(
- 1.21f,
- ToWebGestureEvent(event_queue()[0]->event()).data.pinch_update.scale);
- EXPECT_EQ(WebInputEvent::kGesturePinchUpdate,
- event_queue()[1]->event().GetType());
- EXPECT_EQ(WebInputEvent::kGesturePinchEnd,
- event_queue()[2]->event().GetType());
-}
-
-TEST_F(InputHandlerProxyEventQueueTest, OriginalEventsTracing) {
- // Handle scroll on compositor.
- cc::InputHandlerScrollResult scroll_result_did_scroll_;
- scroll_result_did_scroll_.did_scroll = true;
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillRepeatedly(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(2);
- EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput())
- .Times(::testing::AtLeast(1));
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillRepeatedly(testing::Return(false));
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillRepeatedly(testing::Return(scroll_result_did_scroll_));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(true))
- .Times(::testing::AtLeast(1));
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(2);
-
- EXPECT_CALL(mock_input_handler_, PinchGestureBegin());
- EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(_, _));
- EXPECT_CALL(mock_input_handler_, PinchGestureEnd(_, _));
-
- trace_analyzer::Start("*");
- // Simulate scroll.
- HandleGestureEvent(WebInputEvent::kGestureScrollBegin);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -20);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -40);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -10);
- HandleGestureEvent(WebInputEvent::kGestureScrollEnd);
-
- // Simulate scroll and pinch.
- HandleGestureEvent(WebInputEvent::kGestureScrollBegin);
- HandleGestureEvent(WebInputEvent::kGesturePinchBegin);
- HandleGestureEvent(WebInputEvent::kGesturePinchUpdate, 10.0f, 1, 10);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -10);
- HandleGestureEvent(WebInputEvent::kGesturePinchUpdate, 2.0f, 1, 10);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -30);
- HandleGestureEvent(WebInputEvent::kGesturePinchEnd);
- HandleGestureEvent(WebInputEvent::kGestureScrollEnd);
-
- // Dispatch all events.
- DeliverInputForBeginFrame();
-
- // Retrieve tracing data.
- auto analyzer = trace_analyzer::Stop();
- trace_analyzer::TraceEventVector begin_events;
- trace_analyzer::Query begin_query = trace_analyzer::Query::EventPhaseIs(
- TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN);
- analyzer->FindEvents(begin_query, &begin_events);
-
- trace_analyzer::TraceEventVector end_events;
- trace_analyzer::Query end_query =
- trace_analyzer::Query::EventPhaseIs(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END);
- analyzer->FindEvents(end_query, &end_events);
-
- EXPECT_EQ(7ul, begin_events.size());
- EXPECT_EQ(7ul, end_events.size());
- EXPECT_EQ(WebInputEvent::kGestureScrollUpdate,
- end_events[0]->GetKnownArgAsInt("type"));
- EXPECT_EQ(3, end_events[0]->GetKnownArgAsInt("coalesced_count"));
- EXPECT_EQ(WebInputEvent::kGestureScrollEnd,
- end_events[1]->GetKnownArgAsInt("type"));
-
- EXPECT_EQ(WebInputEvent::kGestureScrollBegin,
- end_events[2]->GetKnownArgAsInt("type"));
- EXPECT_EQ(WebInputEvent::kGesturePinchBegin,
- end_events[3]->GetKnownArgAsInt("type"));
- // Original scroll and pinch updates will be stored in the coalesced
- // PinchUpdate of the <ScrollUpdate, PinchUpdate> pair.
- // The ScrollUpdate of the pair doesn't carry original events and won't be
- // traced.
- EXPECT_EQ(WebInputEvent::kGesturePinchUpdate,
- end_events[4]->GetKnownArgAsInt("type"));
- EXPECT_EQ(4, end_events[4]->GetKnownArgAsInt("coalesced_count"));
- EXPECT_EQ(WebInputEvent::kGesturePinchEnd,
- end_events[5]->GetKnownArgAsInt("type"));
- EXPECT_EQ(WebInputEvent::kGestureScrollEnd,
- end_events[6]->GetKnownArgAsInt("type"));
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
-}
-
-TEST_F(InputHandlerProxyEventQueueTest, TouchpadGestureScrollEndFlushQueue) {
- // Handle scroll on compositor.
- cc::InputHandlerScrollResult scroll_result_did_scroll_;
- scroll_result_did_scroll_.did_scroll = true;
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillRepeatedly(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(2);
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillRepeatedly(testing::Return(false));
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillRepeatedly(testing::Return(scroll_result_did_scroll_));
- EXPECT_CALL(mock_input_handler_, ScrollEnd(true))
- .Times(::testing::AtLeast(1));
-
- // Simulate scroll.
- HandleGestureEventWithSourceDevice(WebInputEvent::kGestureScrollBegin,
- blink::WebGestureDevice::kTouchpad);
- HandleGestureEventWithSourceDevice(WebInputEvent::kGestureScrollUpdate,
- blink::WebGestureDevice::kTouchpad, -20);
-
- // Both GSB and the first GSU will be dispatched immediately since the first
- // GSU has blocking wheel event source.
- EXPECT_EQ(0ul, event_queue().size());
- EXPECT_EQ(2ul, event_disposition_recorder_.size());
-
- // The rest of the GSU events will get queued since they have non-blocking
- // wheel event source.
- EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput())
- .Times(::testing::AtLeast(1));
- HandleGestureEventWithSourceDevice(WebInputEvent::kGestureScrollUpdate,
- blink::WebGestureDevice::kTouchpad, -20);
- EXPECT_EQ(1ul, event_queue().size());
- EXPECT_EQ(2ul, event_disposition_recorder_.size());
-
- // Touchpad GSE will flush the queue.
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- HandleGestureEventWithSourceDevice(WebInputEvent::kGestureScrollEnd,
- blink::WebGestureDevice::kTouchpad);
-
- EXPECT_EQ(0ul, event_queue().size());
- // GSB, GSU(with blocking wheel source), GSU(with non-blocking wheel
- // source), and GSE are the sent events.
- EXPECT_EQ(4ul, event_disposition_recorder_.size());
-
- EXPECT_FALSE(
- input_handler_proxy_.gesture_scroll_on_impl_thread_for_testing());
-
- // Starting a new scroll sequence should have the same behavior (namely that
- // the first scroll update is not queued but immediately dispatched).
- HandleGestureEventWithSourceDevice(WebInputEvent::kGestureScrollBegin,
- blink::WebGestureDevice::kTouchpad);
- HandleGestureEventWithSourceDevice(WebInputEvent::kGestureScrollUpdate,
- blink::WebGestureDevice::kTouchpad, -20);
-
- // Both GSB and the first GSU must be dispatched immediately since the first
- // GSU has blocking wheel event source.
- EXPECT_EQ(0ul, event_queue().size());
- EXPECT_EQ(6ul, event_disposition_recorder_.size());
-}
-
-TEST_F(InputHandlerProxyEventQueueTest, CoalescedLatencyInfo) {
- // Handle scroll on compositor.
- cc::InputHandlerScrollResult scroll_result_did_scroll_;
- scroll_result_did_scroll_.did_scroll = true;
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
- EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1);
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillOnce(testing::Return(false));
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillOnce(testing::Return(scroll_result_did_scroll_));
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- EXPECT_CALL(mock_input_handler_, ScrollEnd(true));
-
- HandleGestureEvent(WebInputEvent::kGestureScrollBegin);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -20);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -40);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -30);
- HandleGestureEvent(WebInputEvent::kGestureScrollEnd);
- DeliverInputForBeginFrame();
-
- EXPECT_EQ(0ul, event_queue().size());
- // Should run callbacks for every original events.
- EXPECT_EQ(5ul, event_disposition_recorder_.size());
- EXPECT_EQ(5ul, latency_info_recorder_.size());
- EXPECT_EQ(false, latency_info_recorder_[1].coalesced());
- // Coalesced events should have latency set to coalesced.
- EXPECT_EQ(true, latency_info_recorder_[2].coalesced());
- EXPECT_EQ(true, latency_info_recorder_[3].coalesced());
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
-}
-
-TEST_F(InputHandlerProxyEventQueueTest, CoalescedEventSwitchToMainThread) {
- cc::InputHandlerScrollResult scroll_result_did_scroll_;
- cc::InputHandlerScrollResult scroll_result_did_not_scroll_;
- scroll_result_did_scroll_.did_scroll = true;
- scroll_result_did_not_scroll_.did_scroll = false;
-
- // scroll begin on main thread
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kMainThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnMain))
- .Times(1);
- EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(2);
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillOnce(testing::Return(false));
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillOnce(testing::Return(scroll_result_did_not_scroll_));
-
- HandleGestureEvent(WebInputEvent::kGestureScrollBegin);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -20);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -10);
- DeliverInputForBeginFrame();
- EXPECT_EQ(3ul, event_disposition_recorder_.size());
- EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
- event_disposition_recorder_.back());
- // GSU should not be coalesced
- EXPECT_EQ(false, latency_info_recorder_[1].coalesced());
- EXPECT_EQ(false, latency_info_recorder_[2].coalesced());
-
- // pinch start, handle scroll and pinch on compositor.
- EXPECT_CALL(mock_input_handler_, PinchGestureBegin());
- EXPECT_CALL(mock_input_handler_, PinchGestureUpdate(_, _));
- EXPECT_CALL(mock_input_handler_, PinchGestureEnd(_, _));
-
- HandleGestureEvent(WebInputEvent::kGesturePinchBegin);
- HandleGestureEvent(WebInputEvent::kGesturePinchUpdate, 10.0f, 1, 10);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -10);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -30);
- EXPECT_EQ(2ul, event_queue().size());
- DeliverInputForBeginFrame();
-
- EXPECT_EQ(7ul, event_disposition_recorder_.size());
- EXPECT_EQ(false, latency_info_recorder_[4].coalesced());
- // Coalesced events should have latency set to coalesced.
- EXPECT_EQ(true, latency_info_recorder_[5].coalesced());
- EXPECT_EQ(true, latency_info_recorder_[6].coalesced());
- EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_.back());
-
- // Pinch end, handle scroll on main thread.
- HandleGestureEvent(WebInputEvent::kGesturePinchEnd);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -40);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -30);
- DeliverInputForBeginFrame();
-
- EXPECT_EQ(0ul, event_queue().size());
- // Should run callbacks for every original events.
- EXPECT_EQ(10ul, event_disposition_recorder_.size());
- EXPECT_EQ(10ul, latency_info_recorder_.size());
- // Latency should not be set to coalesced when send to main thread
- EXPECT_EQ(false, latency_info_recorder_[8].coalesced());
- EXPECT_EQ(false, latency_info_recorder_[9].coalesced());
- EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
- event_disposition_recorder_.back());
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
-}
-
-TEST_F(InputHandlerProxyEventQueueTest, ScrollPredictorTest) {
- base::SimpleTestTickClock tick_clock;
- tick_clock.SetNowTicks(base::TimeTicks());
- SetInputHandlerProxyTickClockForTesting(&tick_clock);
-
- cc::InputHandlerScrollResult scroll_result_did_scroll_;
- scroll_result_did_scroll_.did_scroll = true;
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
- EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1);
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillOnce(testing::Return(false));
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillOnce(testing::Return(scroll_result_did_scroll_));
-
- // No prediction when start with a GSB
- tick_clock.Advance(base::TimeDelta::FromMilliseconds(8));
- HandleGestureEvent(WebInputEvent::kGestureScrollBegin);
- DeliverInputForBeginFrame();
- EXPECT_FALSE(GestureScrollEventPredictionAvailable());
-
- // Test predictor returns last GSU delta.
- tick_clock.Advance(base::TimeDelta::FromMilliseconds(8));
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -20);
- tick_clock.Advance(base::TimeDelta::FromMilliseconds(8));
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -15);
- DeliverInputForBeginFrame();
- auto result = GestureScrollEventPredictionAvailable();
- EXPECT_TRUE(result);
- EXPECT_NE(0, result->pos.y());
-
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
-
- // Predictor has been reset after a new GSB.
- EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(1);
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
- tick_clock.Advance(base::TimeDelta::FromMilliseconds(8));
- HandleGestureEvent(WebInputEvent::kGestureScrollBegin);
- DeliverInputForBeginFrame();
- EXPECT_FALSE(GestureScrollEventPredictionAvailable());
-
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
-}
-
-// Test deliver input w/o prediction enabled.
-TEST_F(InputHandlerProxyEventQueueTest, DeliverInputWithHighLatencyMode) {
- SetScrollPredictionEnabled(false);
-
- cc::InputHandlerScrollResult scroll_result_did_scroll_;
- scroll_result_did_scroll_.did_scroll = true;
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
- EXPECT_CALL(mock_input_handler_, SetNeedsAnimateInput()).Times(2);
- EXPECT_CALL(mock_input_handler_, ScrollingShouldSwitchtoMainThread())
- .WillRepeatedly(testing::Return(false));
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillRepeatedly(testing::Return(scroll_result_did_scroll_));
-
- HandleGestureEvent(WebInputEvent::kGestureScrollBegin);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -20);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -10);
- DeliverInputForBeginFrame();
- // 3 queued event be delivered.
- EXPECT_EQ(3ul, event_disposition_recorder_.size());
- EXPECT_EQ(0ul, event_queue().size());
- EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_.back());
-
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -20);
- HandleGestureEvent(WebInputEvent::kGestureScrollUpdate, -10);
- DeliverInputForHighLatencyMode();
- // 2 queued event be delivered.
- EXPECT_EQ(5ul, event_disposition_recorder_.size());
- EXPECT_EQ(0ul, event_queue().size());
- EXPECT_EQ(InputHandlerProxy::DID_HANDLE, event_disposition_recorder_.back());
-
- testing::Mock::VerifyAndClearExpectations(&mock_input_handler_);
-}
-
-class InputHandlerProxyMainThreadScrollingReasonTest
- : public InputHandlerProxyTest {
- public:
- enum TestEventType {
- Touch,
- MouseWheel,
- };
-
- InputHandlerProxyMainThreadScrollingReasonTest() : InputHandlerProxyTest() {}
- ~InputHandlerProxyMainThreadScrollingReasonTest() = default;
-
- void SetupEvents(TestEventType type) {
- touch_start_ =
- WebTouchEvent(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests());
- touch_end_ =
- WebTouchEvent(WebInputEvent::kTouchEnd, WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests());
- wheel_event_ = WebMouseWheelEvent(
- WebInputEvent::kMouseWheel, WebInputEvent::kControlKey,
- WebInputEvent::GetStaticTimeStampForTests());
- gesture_scroll_begin_ = WebGestureEvent(
- WebInputEvent::kGestureScrollBegin, WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests(),
- type == TestEventType::MouseWheel
- ? blink::WebGestureDevice::kTouchpad
- : blink::WebGestureDevice::kTouchscreen);
- gesture_scroll_end_ = WebGestureEvent(
- WebInputEvent::kGestureScrollEnd, WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests(),
- type == TestEventType::MouseWheel
- ? blink::WebGestureDevice::kTouchpad
- : blink::WebGestureDevice::kTouchscreen);
- touch_start_.touches_length = 1;
- touch_start_.touch_start_or_first_touch_move = true;
- touch_start_.touches[0] =
- CreateWebTouchPoint(WebTouchPoint::kStatePressed, 10, 10);
-
- touch_end_.touches_length = 1;
- }
-
- base::HistogramBase::Sample GetBucketSample(uint32_t reason) {
- if (reason == cc::MainThreadScrollingReason::kNotScrollingOnMain)
- return 0;
-
- uint32_t bucket = 1;
- while ((reason = reason >> 1))
- bucket++;
- return bucket;
- }
-
- protected:
- WebTouchEvent touch_start_;
- WebTouchEvent touch_end_;
- WebMouseWheelEvent wheel_event_;
- WebGestureEvent gesture_scroll_begin_;
- WebGestureEvent gesture_scroll_end_;
-};
-
-TEST_P(InputHandlerProxyMainThreadScrollingReasonTest,
- GestureScrollNotScrollOnMain) {
- // Touch start with passive event listener.
- SetupEvents(TestEventType::Touch);
-
- EXPECT_CALL(mock_input_handler_,
- EventListenerTypeForTouchStartOrMoveAt(
- testing::Property(&gfx::Point::x, testing::Gt(0)), _))
- .WillOnce(testing::Return(
- cc::InputHandler::TouchStartOrMoveEventListenerType::NO_HANDLER));
- EXPECT_CALL(
- mock_input_handler_,
- GetEventListenerProperties(cc::EventListenerClass::kTouchStartOrMove))
- .WillOnce(testing::Return(cc::EventListenerProperties::kPassive));
- EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(_, _, _))
- .WillOnce(testing::Return());
-
- expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(
- mock_input_handler_, input_handler_.get(), touch_start_));
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- EXPECT_EQ(
- expected_disposition_,
- HandleInputEventAndFlushEventQueue(
- mock_input_handler_, input_handler_.get(), gesture_scroll_begin_));
- EXPECT_THAT(
- histogram_tester().GetAllSamples(
- "Renderer4.MainThreadGestureScrollReason"),
- testing::ElementsAre(base::Bucket(
- GetBucketSample(cc::MainThreadScrollingReason::kNotScrollingOnMain),
- 1)));
-
- EXPECT_CALL(mock_input_handler_, ScrollEnd(true));
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- EXPECT_EQ(
- expected_disposition_,
- HandleInputEventAndFlushEventQueue(
- mock_input_handler_, input_handler_.get(), gesture_scroll_end_));
-}
-
-TEST_P(InputHandlerProxyMainThreadScrollingReasonTest,
- GestureScrollTouchEventHandlerRegion) {
- // The touch event hits a touch event handler that is acked from the
- // compositor thread when kCompositorTouchAction is enabld.
- SetupEvents(TestEventType::Touch);
-
- EXPECT_CALL(mock_input_handler_,
- EventListenerTypeForTouchStartOrMoveAt(
- testing::Property(&gfx::Point::x, testing::Gt(0)), _))
- .WillOnce(
- testing::Return(cc::InputHandler::TouchStartOrMoveEventListenerType::
- HANDLER_ON_SCROLLING_LAYER));
- EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(_, _, _))
- .WillOnce(testing::Return());
-
- expected_disposition_ = compositor_touch_action_enabled_
- ? InputHandlerProxy::DID_HANDLE_NON_BLOCKING
- : InputHandlerProxy::DID_NOT_HANDLE;
- EXPECT_EQ(expected_disposition_,
- HandleInputEventAndFlushEventQueue(
- mock_input_handler_, input_handler_.get(), touch_start_));
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(mock_input_handler_,
- RecordScrollBegin(
- _, compositor_touch_action_enabled_
- ? cc::ScrollBeginThreadState::kScrollingOnCompositor
- : cc::ScrollBeginThreadState::
- kScrollingOnCompositorBlockedOnMain))
- .Times(1);
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- EXPECT_EQ(
- expected_disposition_,
- HandleInputEventAndFlushEventQueue(
- mock_input_handler_, input_handler_.get(), gesture_scroll_begin_));
-
- EXPECT_THAT(
- histogram_tester().GetAllSamples(
- "Renderer4.MainThreadGestureScrollReason"),
- testing::ElementsAre(base::Bucket(
- GetBucketSample(
- compositor_touch_action_enabled_
- ? cc::MainThreadScrollingReason::kNotScrollingOnMain
- : cc::MainThreadScrollingReason::kTouchEventHandlerRegion),
- 1)));
-
- EXPECT_CALL(mock_input_handler_, ScrollEnd(true));
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- EXPECT_EQ(
- expected_disposition_,
- HandleInputEventAndFlushEventQueue(
- mock_input_handler_, input_handler_.get(), gesture_scroll_end_));
-}
-
-TEST_P(InputHandlerProxyMainThreadScrollingReasonTest,
- GestureScrollTouchEventHandlerRegionAndHandlingScrollFromMainThread) {
- // The touch event hits a touch event handler and should block on main thread.
- // Since ScrollBegin doesn't allow the gesture to scroll on impl. We report
- // TouchEventHandler reason as well as HandlingScrollFromMainThread. Since we
- // do not collect HandlingScrollFromMainThread when there are other reasons
- // present, TouchEventHandler is the only reason being collected in the
- // histogram.
- SetupEvents(TestEventType::Touch);
-
- EXPECT_CALL(mock_input_handler_,
- EventListenerTypeForTouchStartOrMoveAt(
- testing::Property(&gfx::Point::x, testing::Gt(0)), _))
- .WillOnce(
- testing::Return(cc::InputHandler::TouchStartOrMoveEventListenerType::
- HANDLER_ON_SCROLLING_LAYER));
- EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(_, _, _))
- .WillOnce(testing::Return());
-
- expected_disposition_ = compositor_touch_action_enabled_
- ? InputHandlerProxy::DID_HANDLE_NON_BLOCKING
- : InputHandlerProxy::DID_NOT_HANDLE;
- EXPECT_EQ(expected_disposition_, HandleInputEventWithLatencyInfo(
- input_handler_.get(), touch_start_));
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kMainThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnMain))
- .Times(1);
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(),
- gesture_scroll_begin_));
-
- EXPECT_THAT(
- histogram_tester().GetAllSamples(
- "Renderer4.MainThreadGestureScrollReason"),
- testing::ElementsAre(base::Bucket(
- GetBucketSample(
- compositor_touch_action_enabled_
- ? cc::MainThreadScrollingReason::kHandlingScrollFromMainThread
- : cc::MainThreadScrollingReason::kTouchEventHandlerRegion),
- 1)));
-
- // Handle touch end event so that input handler proxy is out of the state of
- // DID_NOT_HANDLE.
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(),
- gesture_scroll_end_));
-
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(), touch_end_));
-}
-
-TEST_P(InputHandlerProxyMainThreadScrollingReasonTest,
- GestureScrollHandlingScrollFromMainThread) {
- // Gesture scrolling on main thread. We only record
- // HandlingScrollFromMainThread when it's the only available reason.
- SetupEvents(TestEventType::Touch);
- EXPECT_CALL(mock_input_handler_,
- EventListenerTypeForTouchStartOrMoveAt(
- testing::Property(&gfx::Point::x, testing::Gt(0)), _))
- .WillOnce(testing::Return(
- cc::InputHandler::TouchStartOrMoveEventListenerType::NO_HANDLER));
- EXPECT_CALL(mock_client_, SetWhiteListedTouchAction(_, _, _))
- .WillOnce(testing::Return());
- EXPECT_CALL(mock_input_handler_, GetEventListenerProperties(_))
- .WillRepeatedly(testing::Return(cc::EventListenerProperties::kPassive));
-
- expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
- EXPECT_EQ(expected_disposition_, HandleInputEventWithLatencyInfo(
- input_handler_.get(), touch_start_));
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kMainThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnMain))
- .Times(1);
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(),
- gesture_scroll_begin_));
-
- EXPECT_THAT(
- histogram_tester().GetAllSamples(
- "Renderer4.MainThreadGestureScrollReason"),
- testing::ElementsAre(base::Bucket(
- GetBucketSample(
- cc::MainThreadScrollingReason::kHandlingScrollFromMainThread),
- 1)));
-
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(),
- gesture_scroll_end_));
-}
-
-TEST_P(InputHandlerProxyMainThreadScrollingReasonTest, WheelScrollHistogram) {
- // Firstly check if input handler can correctly record main thread scrolling
- // reasons.
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnMain))
- .Times(1);
- input_handler_->RecordMainThreadScrollingReasonsForTest(
- blink::WebGestureDevice::kTouchpad,
- cc::MainThreadScrollingReason::kHasBackgroundAttachmentFixedObjects |
- cc::MainThreadScrollingReason::kThreadedScrollingDisabled |
- cc::MainThreadScrollingReason::kFrameOverlay |
- cc::MainThreadScrollingReason::kHandlingScrollFromMainThread);
-
- EXPECT_THAT(
- histogram_tester().GetAllSamples("Renderer4.MainThreadWheelScrollReason"),
- testing::ElementsAre(
- base::Bucket(
- GetBucketSample(cc::MainThreadScrollingReason::
- kHasBackgroundAttachmentFixedObjects),
- 1),
- base::Bucket(
- GetBucketSample(
- cc::MainThreadScrollingReason::kThreadedScrollingDisabled),
- 1),
- base::Bucket(
- GetBucketSample(cc::MainThreadScrollingReason::kFrameOverlay),
- 1)));
-
- // We only want to record "Handling scroll from main thread" reason if it's
- // the only reason. If it's not the only reason, the "real" reason for
- // scrolling on main is something else, and we only want to pay attention to
- // that reason. So we should only include this reason in the histogram when
- // its on its own.
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnMain))
- .Times(1);
- input_handler_->RecordMainThreadScrollingReasonsForTest(
- blink::WebGestureDevice::kTouchpad,
- cc::MainThreadScrollingReason::kHandlingScrollFromMainThread);
-
- EXPECT_THAT(
- histogram_tester().GetAllSamples("Renderer4.MainThreadWheelScrollReason"),
- testing::ElementsAre(
- base::Bucket(
- GetBucketSample(cc::MainThreadScrollingReason::
- kHasBackgroundAttachmentFixedObjects),
- 1),
- base::Bucket(
- GetBucketSample(
- cc::MainThreadScrollingReason::kThreadedScrollingDisabled),
- 1),
- base::Bucket(
- GetBucketSample(cc::MainThreadScrollingReason::kFrameOverlay), 1),
- base::Bucket(
- GetBucketSample(
- cc::MainThreadScrollingReason::kHandlingScrollFromMainThread),
- 1)));
-}
-
-TEST_P(InputHandlerProxyMainThreadScrollingReasonTest,
- WheelScrollNotScrollingOnMain) {
- // Even if a scroller is composited, we still need to record its main thread
- // scrolling reason if it is blocked on a main thread event handler.
- SetupEvents(TestEventType::MouseWheel);
-
- // We can scroll on impl for an wheel event with passive event listener.
- EXPECT_CALL(mock_input_handler_, HasBlockingWheelEventHandlerAt(_))
- .WillRepeatedly(testing::Return(false));
- EXPECT_CALL(mock_input_handler_,
- GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
- .WillOnce(testing::Return(cc::EventListenerProperties::kPassive));
- expected_disposition_ = InputHandlerProxy::DID_HANDLE_NON_BLOCKING;
- EXPECT_EQ(expected_disposition_, HandleInputEventWithLatencyInfo(
- input_handler_.get(), wheel_event_));
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnCompositor))
- .Times(1);
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(),
- gesture_scroll_begin_));
-
- EXPECT_THAT(
- histogram_tester().GetAllSamples("Renderer4.MainThreadWheelScrollReason"),
- testing::ElementsAre(base::Bucket(
- GetBucketSample(cc::MainThreadScrollingReason::kNotScrollingOnMain),
- 1)));
-
- EXPECT_CALL(mock_input_handler_, ScrollEnd(true));
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(),
- gesture_scroll_end_));
-}
-
-TEST_P(InputHandlerProxyMainThreadScrollingReasonTest,
- WheelScrollWheelEventHandlerRegion) {
- // Wheel event with blocking event listener. If there is a wheel event handler
- // at the point, we do not need to call GetEventListenerProperties since it
- // indicates kBlocking.
- SetupEvents(TestEventType::MouseWheel);
- EXPECT_CALL(mock_input_handler_, HasBlockingWheelEventHandlerAt(_))
- .WillRepeatedly(testing::Return(true));
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- EXPECT_EQ(expected_disposition_, HandleInputEventWithLatencyInfo(
- input_handler_.get(), wheel_event_));
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kImplThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(
- _, cc::ScrollBeginThreadState::kScrollingOnCompositorBlockedOnMain))
- .Times(1);
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(),
- gesture_scroll_begin_));
-
- EXPECT_THAT(
- histogram_tester().GetAllSamples("Renderer4.MainThreadWheelScrollReason"),
- testing::ElementsAre(base::Bucket(
- GetBucketSample(
- cc::MainThreadScrollingReason::kWheelEventHandlerRegion),
- 1)));
-
- EXPECT_CALL(mock_input_handler_, ScrollEnd(true));
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- expected_disposition_ = InputHandlerProxy::DID_HANDLE;
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(),
- gesture_scroll_end_));
-}
-
-TEST_P(InputHandlerProxyMainThreadScrollingReasonTest,
- WheelScrollWheelEventHandlerRegionAndHandlingScrollFromMainThread) {
- // Wheel scrolling on main thread. Because we also block scrolling with wheel
- // event handler, we should record that reason as well.
- SetupEvents(TestEventType::MouseWheel);
- EXPECT_CALL(mock_input_handler_, HasBlockingWheelEventHandlerAt(_))
- .WillRepeatedly(testing::Return(true));
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- EXPECT_EQ(expected_disposition_, HandleInputEventWithLatencyInfo(
- input_handler_.get(), wheel_event_));
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kMainThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnMain))
- .Times(1);
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(),
- gesture_scroll_begin_));
-
- EXPECT_THAT(
- histogram_tester().GetAllSamples("Renderer4.MainThreadWheelScrollReason"),
- testing::ElementsAre(base::Bucket(
- GetBucketSample(
- cc::MainThreadScrollingReason::kWheelEventHandlerRegion),
- 1)));
-
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(),
- gesture_scroll_end_));
-}
-
-TEST_P(InputHandlerProxyMainThreadScrollingReasonTest,
- WheelScrollHandlingScrollFromMainThread) {
- // Gesture scrolling on main thread. We only record
- // HandlingScrollFromMainThread when it's the only available reason.
- SetupEvents(TestEventType::MouseWheel);
- EXPECT_CALL(mock_input_handler_, HasBlockingWheelEventHandlerAt(_))
- .WillRepeatedly(testing::Return(false));
- EXPECT_CALL(mock_input_handler_,
- GetEventListenerProperties(cc::EventListenerClass::kMouseWheel))
- .WillOnce(testing::Return(cc::EventListenerProperties::kNone));
- expected_disposition_ = InputHandlerProxy::DROP_EVENT;
- EXPECT_EQ(expected_disposition_, HandleInputEventWithLatencyInfo(
- input_handler_.get(), wheel_event_));
-
- EXPECT_CALL(mock_input_handler_, ScrollBegin(_, _))
- .WillOnce(testing::Return(kMainThreadScrollState));
- EXPECT_CALL(
- mock_input_handler_,
- RecordScrollBegin(_, cc::ScrollBeginThreadState::kScrollingOnMain))
- .Times(1);
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(),
- gesture_scroll_begin_));
-
- EXPECT_THAT(
- histogram_tester().GetAllSamples("Renderer4.MainThreadWheelScrollReason"),
- testing::ElementsAre(base::Bucket(
- GetBucketSample(
- cc::MainThreadScrollingReason::kHandlingScrollFromMainThread),
- 1)));
-
- expected_disposition_ = InputHandlerProxy::DID_NOT_HANDLE;
- EXPECT_CALL(mock_input_handler_, RecordScrollEnd(_)).Times(1);
- EXPECT_EQ(expected_disposition_,
- HandleInputEventWithLatencyInfo(input_handler_.get(),
- gesture_scroll_end_));
-}
-
-// Tests that turning on the force_input_to_main_thread flag causes all events
-// to be return DID_NOT_HANDLE for forwarding to the main thread.
-class InputHandlerProxyForceHandlingOnMainThread : public testing::Test {
- public:
- InputHandlerProxyForceHandlingOnMainThread()
- : input_handler_proxy_(&mock_input_handler_,
- &mock_client_,
- /*force_input_to_main_thread=*/true) {}
-
- ~InputHandlerProxyForceHandlingOnMainThread() = default;
-
- protected:
- testing::StrictMock<MockInputHandler> mock_input_handler_;
- testing::StrictMock<MockInputHandlerProxyClient> mock_client_;
- TestInputHandlerProxy input_handler_proxy_;
-};
-
-TEST_F(InputHandlerProxyForceHandlingOnMainThread, MouseWheel) {
- // We shouldn't be checking the status of event handlers at all.
- EXPECT_CALL(mock_input_handler_, HasBlockingWheelEventHandlerAt(_)).Times(0);
- EXPECT_CALL(mock_input_handler_, GetEventListenerProperties(_)).Times(0);
-
- WebMouseWheelEvent wheel(WebInputEvent::kMouseWheel,
- WebInputEvent::kControlKey,
- WebInputEvent::GetStaticTimeStampForTests());
- // The input event must return DID_NOT_HANDLE, indicating it should be
- // handled on the main thread.
- EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
- HandleInputEventWithLatencyInfo(&input_handler_proxy_, wheel));
-}
-
-TEST_F(InputHandlerProxyForceHandlingOnMainThread, TouchEvents) {
- // Shouldn't query event listener state at all since we're forcing events to
- // the main thread.
- EXPECT_CALL(mock_input_handler_, EventListenerTypeForTouchStartOrMoveAt(_, _))
- .Times(0);
-
- WebTouchEvent touch(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests());
-
- touch.touches_length = 1;
- touch.touch_start_or_first_touch_move = true;
- touch.touches[0] = CreateWebTouchPoint(WebTouchPoint::kStatePressed, 0, 0);
-
- // The input event must return DID_NOT_HANDLE, indicating it should be
- // handled on the main thread.
- EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
- HandleInputEventWithLatencyInfo(&input_handler_proxy_, touch));
-
- WebTouchEvent touch_move(WebInputEvent::kTouchMove,
- WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests());
-
- touch_move.touches_length = 1;
- touch_move.touch_start_or_first_touch_move = true;
- touch_move.touches[0] =
- CreateWebTouchPoint(WebTouchPoint::kStatePressed, 0, 0);
-
- // The input event must return DID_NOT_HANDLE, indicating it should be
- // handled on the main thread.
- EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
- HandleInputEventWithLatencyInfo(&input_handler_proxy_, touch_move));
-
- touch_move.touch_start_or_first_touch_move = false;
-
- EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
- HandleInputEventWithLatencyInfo(&input_handler_proxy_, touch_move));
-}
-
-TEST_F(InputHandlerProxyForceHandlingOnMainThread, GestureEvents) {
- WebGestureEvent gesture(WebInputEvent::kGestureScrollBegin,
- WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests(),
- blink::WebGestureDevice::kTouchscreen);
-
- // The input event must return DID_NOT_HANDLE, indicating it should be
- // handled on the main thread.
- EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
- HandleInputEventWithLatencyInfo(&input_handler_proxy_, gesture));
- gesture.SetType(WebInputEvent::kGestureScrollUpdate);
- EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
- HandleInputEventWithLatencyInfo(&input_handler_proxy_, gesture));
- gesture.SetType(WebInputEvent::kGestureScrollEnd);
- EXPECT_EQ(InputHandlerProxy::DID_NOT_HANDLE,
- HandleInputEventWithLatencyInfo(&input_handler_proxy_, gesture));
-}
-
-class InputHandlerProxyMomentumScrollJankTest : public testing::Test {
- public:
- InputHandlerProxyMomentumScrollJankTest()
- : input_handler_proxy_(&mock_input_handler_,
- &mock_client_,
- /*force_input_to_main_thread=*/false) {
- tick_clock_.SetNowTicks(base::TimeTicks::Now());
- // Disable scroll predictor for this test.
- input_handler_proxy_.scroll_predictor_ = nullptr;
- input_handler_proxy_.SetTickClockForTesting(&tick_clock_);
- }
-
- ~InputHandlerProxyMomentumScrollJankTest() = default;
-
- void HandleScrollBegin() {
- WebGestureEvent gesture(WebInputEvent::kGestureScrollBegin,
- WebInputEvent::kNoModifiers, tick_clock_.NowTicks(),
- blink::WebGestureDevice::kTouchscreen);
- HandleGesture(gesture.Clone());
- }
-
- void HandleScrollEnd() {
- WebGestureEvent gesture(WebInputEvent::kGestureScrollEnd,
- WebInputEvent::kNoModifiers, tick_clock_.NowTicks(),
- blink::WebGestureDevice::kTouchscreen);
- HandleGesture(gesture.Clone());
- }
-
- void HandleScrollUpdate(bool is_momentum) {
- WebGestureEvent gesture(WebInputEvent::kGestureScrollUpdate,
- WebInputEvent::kNoModifiers, tick_clock_.NowTicks(),
- blink::WebGestureDevice::kTouchscreen);
- gesture.data.scroll_update.delta_y = -20;
- if (is_momentum) {
- gesture.data.scroll_update.inertial_phase =
- blink::WebGestureEvent::InertialPhaseState::kMomentum;
- }
- HandleGesture(gesture.Clone());
- }
-
- void AdvanceClock(uint32_t milliseconds) {
- tick_clock_.Advance(base::TimeDelta::FromMilliseconds(milliseconds));
- }
-
- void AddNonJankyEvents(uint32_t count) {
- for (uint32_t i = 0; i < count; ++i) {
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- DeliverInputForBeginFrame();
- }
- }
-
- void DeliverInputForBeginFrame() {
- constexpr base::TimeDelta interval = base::TimeDelta::FromMilliseconds(16);
- base::TimeTicks frame_time =
- base::TimeTicks() +
- (next_begin_frame_number_ - viz::BeginFrameArgs::kStartingFrameNumber) *
- interval;
- input_handler_proxy_.DeliverInputForBeginFrame(viz::BeginFrameArgs::Create(
- BEGINFRAME_FROM_HERE, 0, next_begin_frame_number_++, frame_time,
- frame_time + interval, interval, viz::BeginFrameArgs::NORMAL));
- }
-
- protected:
- void HandleGesture(WebScopedInputEvent event) {
- LatencyInfo latency;
- input_handler_proxy_.HandleInputEventWithLatencyInfo(
- std::move(event), latency, base::DoNothing());
- }
-
- uint64_t next_begin_frame_number_ = viz::BeginFrameArgs::kStartingFrameNumber;
-
- testing::NiceMock<MockInputHandler> mock_input_handler_;
- testing::NiceMock<MockInputHandlerProxyClient> mock_client_;
- TestInputHandlerProxy input_handler_proxy_;
- base::SimpleTestTickClock tick_clock_;
-};
-
-TEST_F(InputHandlerProxyMomentumScrollJankTest, TestJank) {
- cc::InputHandlerScrollResult scroll_result_did_scroll;
- scroll_result_did_scroll.did_scroll = true;
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillRepeatedly(testing::Return(scroll_result_did_scroll));
-
- base::HistogramTester histogram_tester;
- HandleScrollBegin();
-
- // Flush one update, the first update is always ignored.
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- DeliverInputForBeginFrame();
-
- // Enqueue three updates, they will be coalesced and count as two janks.
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(1);
- DeliverInputForBeginFrame();
-
- // Enqueue two updates, they will be coalesced and count as one jank
- // (https://crbug.com/952930).
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(1);
- DeliverInputForBeginFrame();
-
- // Enqueue two updates, they will be coalesced and count as one
- // jank(https://crbug.com/952930).
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(1);
- DeliverInputForBeginFrame();
-
- // Add 93 non-janky events, bringing us to a total of 100 events.
- AddNonJankyEvents(93);
-
- HandleScrollEnd();
- DeliverInputForBeginFrame();
-
- histogram_tester.ExpectUniqueSample("Renderer4.MomentumScrollJankPercentage",
- 4, 1);
-}
-
-TEST_F(InputHandlerProxyMomentumScrollJankTest, TestJankMultipleGestures) {
- cc::InputHandlerScrollResult scroll_result_did_scroll;
- scroll_result_did_scroll.did_scroll = true;
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillRepeatedly(testing::Return(scroll_result_did_scroll));
-
- base::HistogramTester histogram_tester;
-
- for (int i = 0; i < 3; ++i) {
- HandleScrollBegin();
-
- // Flush one update, the first update is always ignored.
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- DeliverInputForBeginFrame();
-
- // Enqueue two updates, they will be coalesced and count as one jank
- // (https://crbug.com/952930).
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(1);
- DeliverInputForBeginFrame();
-
- // Add 98 non-janky events, bringing us to a total of 100 events.
- AddNonJankyEvents(98);
-
- HandleScrollEnd();
- DeliverInputForBeginFrame();
-
- histogram_tester.ExpectUniqueSample(
- "Renderer4.MomentumScrollJankPercentage", 1, i + 1);
- }
-}
-
-TEST_F(InputHandlerProxyMomentumScrollJankTest, TestJankRounding) {
- cc::InputHandlerScrollResult scroll_result_did_scroll;
- scroll_result_did_scroll.did_scroll = true;
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillRepeatedly(testing::Return(scroll_result_did_scroll));
-
- base::HistogramTester histogram_tester;
-
- HandleScrollBegin();
-
- // Flush one update, the first update is always ignored.
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- DeliverInputForBeginFrame();
-
- // Enqueue two updates, they will be coalesced and count as one jank
- // (https://crbug.com/952930).
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(1);
- DeliverInputForBeginFrame();
-
- // Add 500 non-janky events. Even with this many events, our round-up logic
- // should cause us to report 1% jank.
- AddNonJankyEvents(500);
-
- HandleScrollEnd();
- DeliverInputForBeginFrame();
-
- histogram_tester.ExpectUniqueSample("Renderer4.MomentumScrollJankPercentage",
- 1, 1);
-}
-
-TEST_F(InputHandlerProxyMomentumScrollJankTest, TestSimpleNoJank) {
- cc::InputHandlerScrollResult scroll_result_did_scroll;
- scroll_result_did_scroll.did_scroll = true;
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillRepeatedly(testing::Return(scroll_result_did_scroll));
-
- base::HistogramTester histogram_tester;
- HandleScrollBegin();
-
- // Flush one update, the first update is always ignored.
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(1);
- DeliverInputForBeginFrame();
-
- // Enqueue one updates, no jank.
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(1);
- DeliverInputForBeginFrame();
-
- // Enqueue one updates, no jank.
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(1);
- DeliverInputForBeginFrame();
-
- HandleScrollEnd();
- DeliverInputForBeginFrame();
-
- histogram_tester.ExpectUniqueSample("Renderer4.MomentumScrollJankPercentage",
- 0, 1);
-}
-
-TEST_F(InputHandlerProxyMomentumScrollJankTest, TestFirstGestureNoJank) {
- cc::InputHandlerScrollResult scroll_result_did_scroll;
- scroll_result_did_scroll.did_scroll = true;
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillRepeatedly(testing::Return(scroll_result_did_scroll));
-
- base::HistogramTester histogram_tester;
- HandleScrollBegin();
-
- // Even with 3 coalesced frames, the first gesture should not trigger a jank.
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(16);
- HandleScrollUpdate(true /* is_momentum */);
- AdvanceClock(1);
- DeliverInputForBeginFrame();
-
- HandleScrollEnd();
- DeliverInputForBeginFrame();
-
- histogram_tester.ExpectTotalCount("Renderer4.MomentumScrollJankPercentage",
- 0);
-}
-
-TEST_F(InputHandlerProxyMomentumScrollJankTest, TestNonMomentumNoJank) {
- cc::InputHandlerScrollResult scroll_result_did_scroll;
- scroll_result_did_scroll.did_scroll = true;
- EXPECT_CALL(
- mock_input_handler_,
- ScrollUpdate(testing::Property(&cc::ScrollState::delta_y, testing::Gt(0)),
- _))
- .WillRepeatedly(testing::Return(scroll_result_did_scroll));
-
- base::HistogramTester histogram_tester;
- HandleScrollBegin();
-
- // Flush one update, the first update is always ignored.
- AdvanceClock(16);
- HandleScrollUpdate(false /* is_momentum */);
- AdvanceClock(1);
- DeliverInputForBeginFrame();
-
- // Enqueue three updates, these will not cause jank, as none are momentum.
- AdvanceClock(16);
- HandleScrollUpdate(false /* is_momentum */);
- AdvanceClock(16);
- HandleScrollUpdate(false /* is_momentum */);
- AdvanceClock(16);
- HandleScrollUpdate(false /* is_momentum */);
- AdvanceClock(1);
- DeliverInputForBeginFrame();
-
- HandleScrollEnd();
- DeliverInputForBeginFrame();
-
- histogram_tester.ExpectTotalCount("Renderer4.MomentumScrollJankPercentage",
- 0);
-}
-
-INSTANTIATE_TEST_SUITE_P(AnimateInput,
- InputHandlerProxyTest,
- testing::ValuesIn(test_types));
-
-INSTANTIATE_TEST_SUITE_P(AnimateInput,
- InputHandlerProxyMainThreadScrollingReasonTest,
- testing::ValuesIn(test_types));
-} // namespace test
-} // namespace ui
diff --git a/chromium/ui/events/blink/input_scroll_elasticity_controller.cc b/chromium/ui/events/blink/input_scroll_elasticity_controller.cc
deleted file mode 100644
index 8ff787e317b..00000000000
--- a/chromium/ui/events/blink/input_scroll_elasticity_controller.cc
+++ /dev/null
@@ -1,455 +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 "ui/events/blink/input_scroll_elasticity_controller.h"
-
-#include <math.h>
-
-#include <algorithm>
-
-#include "base/bind.h"
-#include "cc/input/input_handler.h"
-#include "ui/events/types/scroll_types.h"
-#include "ui/gfx/geometry/vector2d_conversions.h"
-
-// InputScrollElasticityController is based on
-// WebKit/Source/platform/mac/InputScrollElasticityController.mm
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-namespace ui {
-
-namespace {
-
-const float kScrollVelocityZeroingTimeout = 0.10f;
-const float kRubberbandMinimumRequiredDeltaBeforeStretch = 10;
-
-const float kRubberbandStiffness = 20;
-const float kRubberbandAmplitude = 0.31f;
-const float kRubberbandPeriod = 1.6f;
-
-// For these functions which compute the stretch amount, always return a
-// rounded value, instead of a floating-point value. The reason for this is
-// that Blink's scrolling can become erratic with fractional scroll amounts (in
-// particular, if you have a scroll offset of 0.5, Blink will never actually
-// bring that value back to 0, which breaks the logic used to determine if a
-// layer is pinned in a direction).
-
-gfx::Vector2d StretchAmountForTimeDelta(const gfx::Vector2dF& initial_position,
- const gfx::Vector2dF& initial_velocity,
- float elapsed_time) {
- // Compute the stretch amount at a given time after some initial conditions.
- // Do this by first computing an intermediary position given the initial
- // position, initial velocity, time elapsed, and no external forces. Then
- // take the intermediary position and damp it towards zero by multiplying
- // against a negative exponential.
- float amplitude = kRubberbandAmplitude;
- float period = kRubberbandPeriod;
- float critical_dampening_factor =
- expf((-elapsed_time * kRubberbandStiffness) / period);
-
- return gfx::ToRoundedVector2d(gfx::ScaleVector2d(
- initial_position +
- gfx::ScaleVector2d(initial_velocity, elapsed_time * amplitude),
- critical_dampening_factor));
-}
-
-gfx::Vector2d StretchAmountForReboundDelta(const gfx::Vector2dF& delta) {
- float stiffness = std::max(kRubberbandStiffness, 1.0f);
- return gfx::ToRoundedVector2d(gfx::ScaleVector2d(delta, 1.0f / stiffness));
-}
-
-gfx::Vector2d StretchScrollForceForStretchAmount(const gfx::Vector2dF& delta) {
- return gfx::ToRoundedVector2d(
- gfx::ScaleVector2d(delta, kRubberbandStiffness));
-}
-
-} // namespace
-
-InputScrollElasticityController::InputScrollElasticityController(
- cc::ScrollElasticityHelper* helper)
- : helper_(helper),
- state_(kStateInactive),
- momentum_animation_reset_at_next_frame_(false),
- received_overscroll_update_(false) {}
-
-InputScrollElasticityController::~InputScrollElasticityController() {
-}
-
-base::WeakPtr<InputScrollElasticityController>
-InputScrollElasticityController::GetWeakPtr() {
- if (helper_)
- return weak_factory_.GetWeakPtr();
- return base::WeakPtr<InputScrollElasticityController>();
-}
-
-void InputScrollElasticityController::ObserveRealScrollBegin(
- bool enter_momentum,
- bool leave_momentum) {
- if (enter_momentum) {
- if (state_ == kStateInactive)
- state_ = kStateMomentumScroll;
- } else if (leave_momentum) {
- scroll_velocity = gfx::Vector2dF();
- last_scroll_event_timestamp_ = base::TimeTicks();
- state_ = kStateActiveScroll;
- pending_overscroll_delta_ = gfx::Vector2dF();
- }
-}
-
-void InputScrollElasticityController::ObserveScrollUpdate(
- const gfx::Vector2dF& event_delta,
- const gfx::Vector2dF& unused_scroll_delta,
- const base::TimeTicks event_timestamp,
- const cc::OverscrollBehavior overscroll_behavior,
- bool has_momentum) {
- if (state_ == kStateMomentumAnimated || state_ == kStateInactive)
- return;
-
- if (!received_overscroll_update_ && !unused_scroll_delta.IsZero()) {
- overscroll_behavior_ = overscroll_behavior;
- received_overscroll_update_ = true;
- }
-
- UpdateVelocity(event_delta, event_timestamp);
- Overscroll(event_delta, unused_scroll_delta);
- if (has_momentum && !helper_->StretchAmount().IsZero())
- EnterStateMomentumAnimated(event_timestamp);
-}
-
-void InputScrollElasticityController::ObserveRealScrollEnd(
- const base::TimeTicks event_timestamp) {
- if (state_ == kStateMomentumAnimated || state_ == kStateInactive)
- return;
-
- if (helper_->StretchAmount().IsZero()) {
- EnterStateInactive();
- } else {
- EnterStateMomentumAnimated(event_timestamp);
- }
-}
-
-void InputScrollElasticityController::ObserveGestureEventAndResult(
- const blink::WebGestureEvent& gesture_event,
- const cc::InputHandlerScrollResult& scroll_result) {
- base::TimeTicks event_timestamp = gesture_event.TimeStamp();
-
- switch (gesture_event.GetType()) {
- case blink::WebInputEvent::kGestureScrollBegin: {
- received_overscroll_update_ = false;
- overscroll_behavior_ = cc::OverscrollBehavior();
- if (gesture_event.data.scroll_begin.synthetic)
- return;
-
- bool enter_momentum =
- gesture_event.data.scroll_begin.inertial_phase ==
- blink::WebGestureEvent::InertialPhaseState::kMomentum;
- bool leave_momentum =
- gesture_event.data.scroll_begin.inertial_phase ==
- blink::WebGestureEvent::InertialPhaseState::kNonMomentum &&
- gesture_event.data.scroll_begin.delta_hint_units ==
- ui::ScrollGranularity::kScrollByPrecisePixel;
- ObserveRealScrollBegin(enter_momentum, leave_momentum);
- break;
- }
- case blink::WebInputEvent::kGestureScrollUpdate: {
- gfx::Vector2dF event_delta(-gesture_event.data.scroll_update.delta_x,
- -gesture_event.data.scroll_update.delta_y);
- bool has_momentum = gesture_event.data.scroll_update.inertial_phase ==
- blink::WebGestureEvent::InertialPhaseState::kMomentum;
- ObserveScrollUpdate(event_delta, scroll_result.unused_scroll_delta,
- event_timestamp, scroll_result.overscroll_behavior,
- has_momentum);
- break;
- }
- case blink::WebInputEvent::kGestureScrollEnd: {
- if (gesture_event.data.scroll_end.synthetic)
- return;
- ObserveRealScrollEnd(event_timestamp);
- break;
- }
- default:
- break;
- }
-}
-
-void InputScrollElasticityController::UpdateVelocity(
- const gfx::Vector2dF& event_delta,
- const base::TimeTicks& event_timestamp) {
- float time_delta =
- (event_timestamp - last_scroll_event_timestamp_).InSecondsF();
- if (time_delta < kScrollVelocityZeroingTimeout && time_delta > 0) {
- scroll_velocity = gfx::Vector2dF(event_delta.x() / time_delta,
- event_delta.y() / time_delta);
- } else {
- scroll_velocity = gfx::Vector2dF();
- }
- last_scroll_event_timestamp_ = event_timestamp;
-}
-
-void InputScrollElasticityController::Overscroll(
- const gfx::Vector2dF& input_delta,
- const gfx::Vector2dF& overscroll_delta) {
- // The effect can be dynamically disabled by setting disallowing user
- // scrolling. When disabled, disallow active or momentum overscrolling, but
- // allow any current overscroll to animate back.
- if (!helper_->IsUserScrollable())
- return;
-
- gfx::Vector2dF adjusted_overscroll_delta =
- pending_overscroll_delta_ + overscroll_delta;
- pending_overscroll_delta_ = gfx::Vector2dF();
-
- // Only allow one direction to overscroll at a time, and slightly prefer
- // scrolling vertically by applying the equal case to delta_y.
- if (fabsf(input_delta.y()) >= fabsf(input_delta.x()))
- adjusted_overscroll_delta.set_x(0);
- else
- adjusted_overscroll_delta.set_y(0);
-
- // Don't allow overscrolling in a direction where scrolling is possible.
- if (!PinnedHorizontally(adjusted_overscroll_delta.x()))
- adjusted_overscroll_delta.set_x(0);
- if (!PinnedVertically(adjusted_overscroll_delta.y()))
- adjusted_overscroll_delta.set_y(0);
-
- // Don't allow overscrolling in a direction that has
- // OverscrollBehaviorTypeNone.
- if (overscroll_behavior_.x ==
- cc::OverscrollBehavior::kOverscrollBehaviorTypeNone)
- adjusted_overscroll_delta.set_x(0);
- if (overscroll_behavior_.y ==
- cc::OverscrollBehavior::kOverscrollBehaviorTypeNone)
- adjusted_overscroll_delta.set_y(0);
-
- // Require a minimum of 10 units of overscroll before starting the rubber-band
- // stretch effect, so that small stray motions don't trigger it. If that
- // minimum isn't met, save what remains in |pending_overscroll_delta_| for
- // the next event.
- gfx::Vector2dF old_stretch_amount = helper_->StretchAmount();
- gfx::Vector2dF stretch_scroll_force_delta;
- if (old_stretch_amount.x() != 0 ||
- fabsf(adjusted_overscroll_delta.x()) >=
- kRubberbandMinimumRequiredDeltaBeforeStretch) {
- stretch_scroll_force_delta.set_x(adjusted_overscroll_delta.x());
- } else {
- pending_overscroll_delta_.set_x(adjusted_overscroll_delta.x());
- }
- if (old_stretch_amount.y() != 0 ||
- fabsf(adjusted_overscroll_delta.y()) >=
- kRubberbandMinimumRequiredDeltaBeforeStretch) {
- stretch_scroll_force_delta.set_y(adjusted_overscroll_delta.y());
- } else {
- pending_overscroll_delta_.set_y(adjusted_overscroll_delta.y());
- }
-
- // Update the stretch amount according to the spring equations.
- if (stretch_scroll_force_delta.IsZero())
- return;
- stretch_scroll_force_ += stretch_scroll_force_delta;
- gfx::Vector2dF new_stretch_amount =
- StretchAmountForReboundDelta(stretch_scroll_force_);
- helper_->SetStretchAmount(new_stretch_amount);
-}
-
-void InputScrollElasticityController::EnterStateInactive() {
- DCHECK_NE(kStateInactive, state_);
- DCHECK(helper_->StretchAmount().IsZero());
- state_ = kStateInactive;
- stretch_scroll_force_ = gfx::Vector2dF();
-}
-
-void InputScrollElasticityController::EnterStateMomentumAnimated(
- const base::TimeTicks& triggering_event_timestamp) {
- DCHECK_NE(kStateMomentumAnimated, state_);
- state_ = kStateMomentumAnimated;
-
- momentum_animation_start_time_ = triggering_event_timestamp;
- momentum_animation_initial_stretch_ = helper_->StretchAmount();
- momentum_animation_initial_velocity_ = scroll_velocity;
- momentum_animation_reset_at_next_frame_ = false;
-
- // Similarly to the logic in Overscroll, prefer vertical scrolling to
- // horizontal scrolling.
- if (fabsf(momentum_animation_initial_velocity_.y()) >=
- fabsf(momentum_animation_initial_velocity_.x()))
- momentum_animation_initial_velocity_.set_x(0);
-
- if (!CanScrollHorizontally())
- momentum_animation_initial_velocity_.set_x(0);
-
- if (!CanScrollVertically())
- momentum_animation_initial_velocity_.set_y(0);
-
- // TODO(crbug.com/394562): This can go away once input is batched to the front
- // of the frame? Then Animate() would always happen after this, so it would
- // have a chance to tick the animation there and would return if any
- // animations were active.
- helper_->RequestOneBeginFrame();
-}
-
-void InputScrollElasticityController::Animate(base::TimeTicks time) {
- if (state_ != kStateMomentumAnimated)
- return;
-
- if (momentum_animation_reset_at_next_frame_) {
- momentum_animation_start_time_ = time;
- momentum_animation_initial_stretch_ = helper_->StretchAmount();
- momentum_animation_initial_velocity_ = gfx::Vector2dF();
- momentum_animation_reset_at_next_frame_ = false;
- }
-
- float time_delta =
- std::max((time - momentum_animation_start_time_).InSecondsF(), 0.0);
-
- gfx::Vector2dF old_stretch_amount = helper_->StretchAmount();
- gfx::Vector2dF new_stretch_amount = StretchAmountForTimeDelta(
- momentum_animation_initial_stretch_, momentum_animation_initial_velocity_,
- time_delta);
- gfx::Vector2dF stretch_delta = new_stretch_amount - old_stretch_amount;
-
- // If the new stretch amount is near zero, set it directly to zero and enter
- // the inactive state.
- if (fabs(new_stretch_amount.x()) < 1 && fabs(new_stretch_amount.y()) < 1) {
- helper_->SetStretchAmount(gfx::Vector2dF());
- EnterStateInactive();
- return;
- }
-
- // If we are not pinned in the direction of the delta, then the delta is only
- // allowed to decrease the existing stretch -- it cannot increase a stretch
- // until it is pinned.
- if (!PinnedHorizontally(stretch_delta.x())) {
- if (stretch_delta.x() > 0 && old_stretch_amount.x() < 0)
- stretch_delta.set_x(std::min(stretch_delta.x(), -old_stretch_amount.x()));
- else if (stretch_delta.x() < 0 && old_stretch_amount.x() > 0)
- stretch_delta.set_x(std::max(stretch_delta.x(), -old_stretch_amount.x()));
- else
- stretch_delta.set_x(0);
- }
- if (!PinnedVertically(stretch_delta.y())) {
- if (stretch_delta.y() > 0 && old_stretch_amount.y() < 0)
- stretch_delta.set_y(std::min(stretch_delta.y(), -old_stretch_amount.y()));
- else if (stretch_delta.y() < 0 && old_stretch_amount.y() > 0)
- stretch_delta.set_y(std::max(stretch_delta.y(), -old_stretch_amount.y()));
- else
- stretch_delta.set_y(0);
- }
- new_stretch_amount = old_stretch_amount + stretch_delta;
-
- stretch_scroll_force_ =
- StretchScrollForceForStretchAmount(new_stretch_amount);
- helper_->SetStretchAmount(new_stretch_amount);
- // TODO(danakj): Make this a return value back to the compositor to have it
- // schedule another frame and/or a draw. (Also, crbug.com/551138.)
- helper_->RequestOneBeginFrame();
-}
-
-bool InputScrollElasticityController::PinnedHorizontally(
- float direction) const {
- gfx::ScrollOffset scroll_offset = helper_->ScrollOffset();
- gfx::ScrollOffset max_scroll_offset = helper_->MaxScrollOffset();
- if (direction < 0)
- return scroll_offset.x() <= 0;
- if (direction > 0)
- return scroll_offset.x() >= max_scroll_offset.x();
- return false;
-}
-
-bool InputScrollElasticityController::PinnedVertically(float direction) const {
- gfx::ScrollOffset scroll_offset = helper_->ScrollOffset();
- gfx::ScrollOffset max_scroll_offset = helper_->MaxScrollOffset();
- if (direction < 0)
- return scroll_offset.y() <= 0;
- if (direction > 0)
- return scroll_offset.y() >= max_scroll_offset.y();
- return false;
-}
-
-bool InputScrollElasticityController::CanScrollHorizontally() const {
- return helper_->MaxScrollOffset().x() > 0;
-}
-
-bool InputScrollElasticityController::CanScrollVertically() const {
- return helper_->MaxScrollOffset().y() > 0;
-}
-
-void InputScrollElasticityController::ReconcileStretchAndScroll() {
- gfx::Vector2dF stretch = helper_->StretchAmount();
- if (stretch.IsZero())
- return;
-
- gfx::ScrollOffset scroll_offset = helper_->ScrollOffset();
- gfx::ScrollOffset max_scroll_offset = helper_->MaxScrollOffset();
-
- // Compute stretch_adjustment which will be added to |stretch| and subtracted
- // from the |scroll_offset|.
- gfx::Vector2dF stretch_adjustment;
- if (stretch.x() < 0 && scroll_offset.x() > 0) {
- stretch_adjustment.set_x(
- std::min(-stretch.x(), static_cast<float>(scroll_offset.x())));
- }
- if (stretch.x() > 0 && scroll_offset.x() < max_scroll_offset.x()) {
- stretch_adjustment.set_x(std::max(
- -stretch.x(),
- static_cast<float>(scroll_offset.x() - max_scroll_offset.x())));
- }
- if (stretch.y() < 0 && scroll_offset.y() > 0) {
- stretch_adjustment.set_y(
- std::min(-stretch.y(), static_cast<float>(scroll_offset.y())));
- }
- if (stretch.y() > 0 && scroll_offset.y() < max_scroll_offset.y()) {
- stretch_adjustment.set_y(std::max(
- -stretch.y(),
- static_cast<float>(scroll_offset.y() - max_scroll_offset.y())));
- }
-
- if (stretch_adjustment.IsZero())
- return;
-
- gfx::Vector2dF new_stretch_amount = stretch + stretch_adjustment;
- helper_->ScrollBy(-stretch_adjustment);
- helper_->SetStretchAmount(new_stretch_amount);
-
- // Update the internal state for the active scroll or animation to avoid
- // discontinuities.
- switch (state_) {
- case kStateActiveScroll:
- stretch_scroll_force_ =
- StretchScrollForceForStretchAmount(new_stretch_amount);
- break;
- case kStateMomentumAnimated:
- momentum_animation_reset_at_next_frame_ = true;
- break;
- default:
- // These cases should not be hit because the stretch must be zero in the
- // Inactive and MomentumScroll states.
- NOTREACHED();
- break;
- }
-}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/input_scroll_elasticity_controller.h b/chromium/ui/events/blink/input_scroll_elasticity_controller.h
deleted file mode 100644
index c80d932f84e..00000000000
--- a/chromium/ui/events/blink/input_scroll_elasticity_controller.h
+++ /dev/null
@@ -1,164 +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 UI_EVENTS_BLINK_INPUT_SCROLL_ELASTICITY_CONTROLLER_H_
-#define UI_EVENTS_BLINK_INPUT_SCROLL_ELASTICITY_CONTROLLER_H_
-
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "cc/input/overscroll_behavior.h"
-#include "cc/input/scroll_elasticity_helper.h"
-#include "third_party/blink/public/common/input/web_gesture_event.h"
-#include "third_party/blink/public/common/input/web_input_event.h"
-
-// InputScrollElasticityController is based on
-// WebKit/Source/platform/mac/ScrollElasticityController.h
-/*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-namespace cc {
-struct InputHandlerScrollResult;
-} // namespace cc
-
-namespace ui {
-
-class InputScrollElasticityController {
- public:
- explicit InputScrollElasticityController(cc::ScrollElasticityHelper* helper);
- virtual ~InputScrollElasticityController();
-
- base::WeakPtr<InputScrollElasticityController> GetWeakPtr();
-
- // These methods that are "real" should only be called if the associated
- // event is not synthetic. Otherwise, calling them will disrupt elastic
- // scrolling.
- void ObserveRealScrollBegin(bool enter_momentum, bool leave_momentum);
- void ObserveScrollUpdate(const gfx::Vector2dF& event_delta,
- const gfx::Vector2dF& unused_scroll_delta,
- const base::TimeTicks event_timestamp,
- const cc::OverscrollBehavior overscroll_behavior,
- bool has_momentum);
- void ObserveRealScrollEnd(const base::TimeTicks event_timestamp);
-
- // Update the overscroll state based a gesture event that has been processed.
- // Note that this assumes that all events are coming from a single input
- // device. If the user simultaneously uses multiple input devices, Cocoa may
- // not correctly pass all the gesture begin and end events. In this case,
- // this class may disregard some scrolls that come in at unexpected times.
- void ObserveGestureEventAndResult(
- const blink::WebGestureEvent& gesture_event,
- const cc::InputHandlerScrollResult& scroll_result);
-
- void Animate(base::TimeTicks time);
-
- void ReconcileStretchAndScroll();
-
- private:
- enum State {
- // The initial state, during which the overscroll amount is zero and
- // there are no active or momentum scroll events coming in. This state
- // is briefly returned to between the active and momentum phases of a
- // scroll (if there is no overscroll).
- kStateInactive,
- // The state between receiving PhaseBegan/MayBegin and PhaseEnd/Cancelled,
- // corresponding to the period during which the user has fingers on the
- // trackpad. The overscroll amount is updated as input events are received.
- // When PhaseEnd is received, the state transitions to Inactive if there is
- // no overscroll and MomentumAnimated if there is non-zero overscroll.
- kStateActiveScroll,
- // The state between receiving a momentum PhaseBegan and PhaseEnd, while
- // there is no overscroll. The overscroll amount is updated as input events
- // are received. If the overscroll is ever non-zero then the state
- // immediately transitions to kStateMomentumAnimated.
- kStateMomentumScroll,
- // The state while the overscroll amount is updated by an animation. If
- // the user places fingers on the trackpad (a PhaseMayBegin is received)
- // then the state transition to kStateActiveScroll. Otherwise the state
- // transitions to Inactive when the overscroll amount becomes zero.
- kStateMomentumAnimated,
- };
-
- void UpdateVelocity(const gfx::Vector2dF& event_delta,
- const base::TimeTicks& event_timestamp);
- void Overscroll(const gfx::Vector2dF& input_delta,
- const gfx::Vector2dF& overscroll_delta);
- void EnterStateMomentumAnimated(
- const base::TimeTicks& triggering_event_timestamp);
- void EnterStateInactive();
-
- // Returns true if |direction| is pointing in a direction in which it is not
- // possible to scroll any farther horizontally (or vertically). It is only in
- // this circumstance that an overscroll in that direction may begin.
- bool PinnedHorizontally(float direction) const;
- bool PinnedVertically(float direction) const;
- // Whether or not the content of the page is scrollable horizontaly (or
- // vertically).
- bool CanScrollHorizontally() const;
- bool CanScrollVertically() const;
-
- cc::ScrollElasticityHelper* helper_;
- State state_;
-
- // If there is no overscroll, require a minimum overscroll delta before
- // starting the rubber-band effect. Track the amount of scrolling that has
- // has occurred but has not yet caused rubber-band stretching in
- // |pending_overscroll_delta_|.
- gfx::Vector2dF pending_overscroll_delta_;
-
- // Maintain a calculation of the velocity of the scroll, based on the input
- // scroll delta divide by the time between input events. Track this velocity
- // in |scroll_velocity| and the previous input event timestamp for finite
- // differencing in |last_scroll_event_timestamp_|.
- gfx::Vector2dF scroll_velocity;
- base::TimeTicks last_scroll_event_timestamp_;
-
- // The force of the rubber-band spring. This is equal to the cumulative sum
- // of all overscroll offsets since entering a non-Inactive state. This is
- // reset to zero only when entering the Inactive state.
- gfx::Vector2dF stretch_scroll_force_;
-
- // Momentum animation state. This state is valid only while the state is
- // MomentumAnimated, and is initialized in EnterStateMomentumAnimated.
- base::TimeTicks momentum_animation_start_time_;
- gfx::Vector2dF momentum_animation_initial_stretch_;
- gfx::Vector2dF momentum_animation_initial_velocity_;
-
- // This is set in response to a scroll (most likely programmatic) occuring
- // while animating the momentum phase. In this case, re-set the initial
- // velocity, stretch, and start time at the next frame (this is the same
- // behavior as would happen if the scroll were caused by an active scroll).
- bool momentum_animation_reset_at_next_frame_;
-
- bool received_overscroll_update_;
- cc::OverscrollBehavior overscroll_behavior_;
-
- base::WeakPtrFactory<InputScrollElasticityController> weak_factory_{this};
- DISALLOW_COPY_AND_ASSIGN(InputScrollElasticityController);
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_INPUT_SCROLL_ELASTICITY_CONTROLLER_H_
diff --git a/chromium/ui/events/blink/input_scroll_elasticity_controller_unittest.cc b/chromium/ui/events/blink/input_scroll_elasticity_controller_unittest.cc
deleted file mode 100644
index 59c0528ef86..00000000000
--- a/chromium/ui/events/blink/input_scroll_elasticity_controller_unittest.cc
+++ /dev/null
@@ -1,500 +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 "ui/events/blink/input_scroll_elasticity_controller.h"
-
-#include "cc/input/input_handler.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/blink/public/common/input/web_input_event.h"
-#include "third_party/blink/public/common/input/web_mouse_wheel_event.h"
-
-namespace ui {
-namespace {
-
-enum Phase {
- PhaseNone = blink::WebMouseWheelEvent::kPhaseNone,
- PhaseBegan = blink::WebMouseWheelEvent::kPhaseBegan,
- PhaseStationary = blink::WebMouseWheelEvent::kPhaseStationary,
- PhaseChanged = blink::WebMouseWheelEvent::kPhaseChanged,
- PhaseEnded = blink::WebMouseWheelEvent::kPhaseEnded,
- PhaseCancelled = blink::WebMouseWheelEvent::kPhaseCancelled,
- PhaseMayBegin = blink::WebMouseWheelEvent::kPhaseMayBegin,
-};
-
-enum InertialPhaseState {
- UnknownMomentumPhase = static_cast<int>(
- blink::WebGestureEvent::InertialPhaseState::kUnknownMomentum),
- NonMomentumPhase = static_cast<int>(
- blink::WebGestureEvent::InertialPhaseState::kNonMomentum),
- MomentumPhase =
- static_cast<int>(blink::WebGestureEvent::InertialPhaseState::kMomentum),
-};
-
-class MockScrollElasticityHelper : public cc::ScrollElasticityHelper {
- public:
- MockScrollElasticityHelper()
- : is_user_scrollable_(true),
- set_stretch_amount_count_(0),
- request_begin_frame_count_(0) {}
- ~MockScrollElasticityHelper() override {}
-
- // cc::ScrollElasticityHelper implementation:
- bool IsUserScrollable() const override { return is_user_scrollable_; }
- gfx::Vector2dF StretchAmount() const override { return stretch_amount_; }
- void SetStretchAmount(const gfx::Vector2dF& stretch_amount) override {
- set_stretch_amount_count_ += 1;
- stretch_amount_ = stretch_amount;
- }
- gfx::ScrollOffset ScrollOffset() const override { return scroll_offset_; }
- gfx::ScrollOffset MaxScrollOffset() const override {
- return max_scroll_offset_;
- }
- void ScrollBy(const gfx::Vector2dF& delta) override {
- scroll_offset_ += gfx::ScrollOffset(delta);
- }
- void RequestOneBeginFrame() override { request_begin_frame_count_ += 1; }
-
- // Counters for number of times functions were called.
- int request_begin_frame_count() const { return request_begin_frame_count_; }
- int set_stretch_amount_count() const { return set_stretch_amount_count_; }
-
- void SetScrollOffsetAndMaxScrollOffset(
- const gfx::ScrollOffset& scroll_offset,
- const gfx::ScrollOffset& max_scroll_offset) {
- scroll_offset_ = scroll_offset;
- max_scroll_offset_ = max_scroll_offset;
- }
- void SetUserScrollable(bool is_user_scrollable) {
- is_user_scrollable_ = is_user_scrollable;
- }
-
- private:
- bool is_user_scrollable_;
- gfx::Vector2dF stretch_amount_;
- int set_stretch_amount_count_;
- int request_begin_frame_count_;
-
- gfx::ScrollOffset scroll_offset_;
- gfx::ScrollOffset max_scroll_offset_;
-};
-
-class ScrollElasticityControllerTest : public testing::Test {
- public:
- ScrollElasticityControllerTest()
- : controller_(&helper_),
- input_event_count_(0),
- current_time_(base::TimeTicks() +
- base::TimeDelta::FromMicroseconds(INT64_C(100000000))) {}
- ~ScrollElasticityControllerTest() override {}
-
-
- void SendGestureScrollBegin(InertialPhaseState inertialPhase) {
- TickCurrentTime();
- blink::WebGestureEvent event(blink::WebInputEvent::kGestureScrollBegin,
- blink::WebInputEvent::kNoModifiers,
- current_time_,
- blink::WebGestureDevice::kTouchpad);
- event.data.scroll_begin.inertial_phase =
- static_cast<blink::WebGestureEvent::InertialPhaseState>(inertialPhase);
-
- controller_.ObserveGestureEventAndResult(event,
- cc::InputHandlerScrollResult());
- input_event_count_ += 1;
- }
-
- void SendGestureScrollUpdate(
- InertialPhaseState inertialPhase,
- const gfx::Vector2dF& event_delta = gfx::Vector2dF(),
- const gfx::Vector2dF& overscroll_delta = gfx::Vector2dF(),
- const cc::OverscrollBehavior& overscroll_behavior =
- cc::OverscrollBehavior()) {
- TickCurrentTime();
- blink::WebGestureEvent event(blink::WebInputEvent::kGestureScrollUpdate,
- blink::WebInputEvent::kNoModifiers,
- current_time_,
- blink::WebGestureDevice::kTouchpad);
- event.data.scroll_update.inertial_phase =
- static_cast<blink::WebGestureEvent::InertialPhaseState>(inertialPhase);
- event.data.scroll_update.delta_x = -event_delta.x();
- event.data.scroll_update.delta_y = -event_delta.y();
-
- cc::InputHandlerScrollResult scroll_result;
- scroll_result.did_overscroll_root = !overscroll_delta.IsZero();
- scroll_result.unused_scroll_delta = overscroll_delta;
- scroll_result.overscroll_behavior = overscroll_behavior;
-
- controller_.ObserveGestureEventAndResult(event, scroll_result);
- input_event_count_ += 1;
- }
-
- void SendGestureScrollEnd() {
- TickCurrentTime();
- blink::WebGestureEvent event(blink::WebInputEvent::kGestureScrollEnd,
- blink::WebInputEvent::kNoModifiers,
- current_time_,
- blink::WebGestureDevice::kTouchpad);
-
- controller_.ObserveGestureEventAndResult(event,
- cc::InputHandlerScrollResult());
- input_event_count_ += 1;
- }
-
- const base::TimeTicks& TickCurrentTime() {
- current_time_ += base::TimeDelta::FromSecondsD(1 / 60.f);
- return current_time_;
- }
- void TickCurrentTimeAndAnimate() {
- TickCurrentTime();
- controller_.Animate(current_time_);
- }
-
- MockScrollElasticityHelper helper_;
- InputScrollElasticityController controller_;
- int input_event_count_;
- base::TimeTicks current_time_;
-};
-
-// Verify that stretching occurs in one axis at a time, and that it
-// is biased to the Y axis.
-TEST_F(ScrollElasticityControllerTest, Axis) {
- helper_.SetScrollOffsetAndMaxScrollOffset(gfx::ScrollOffset(0, 0),
- gfx::ScrollOffset(0, 0));
-
- // If we push equally in the X and Y directions, we should see a stretch
- // in the Y direction.
- SendGestureScrollBegin(NonMomentumPhase);
- SendGestureScrollUpdate(NonMomentumPhase, gfx::Vector2dF(10, 10),
- gfx::Vector2dF(10, 10));
- EXPECT_EQ(1, helper_.set_stretch_amount_count());
- EXPECT_EQ(0.f, helper_.StretchAmount().x());
- EXPECT_LT(0.f, helper_.StretchAmount().y());
- helper_.SetStretchAmount(gfx::Vector2dF());
- EXPECT_EQ(2, helper_.set_stretch_amount_count());
- SendGestureScrollEnd();
- EXPECT_EQ(0, helper_.request_begin_frame_count());
-
- // If we push more in the X direction than the Y direction, we should see a
- // stretch in the X direction. This decision should be based on the
- // input delta, not the actual overscroll delta.
- SendGestureScrollBegin(NonMomentumPhase);
- SendGestureScrollUpdate(NonMomentumPhase, gfx::Vector2dF(-25, 10),
- gfx::Vector2dF(-25, 40));
- EXPECT_EQ(3, helper_.set_stretch_amount_count());
- EXPECT_GT(0.f, helper_.StretchAmount().x());
- EXPECT_EQ(0.f, helper_.StretchAmount().y());
- helper_.SetStretchAmount(gfx::Vector2dF());
- EXPECT_EQ(4, helper_.set_stretch_amount_count());
- SendGestureScrollEnd();
- EXPECT_EQ(0, helper_.request_begin_frame_count());
-}
-
-// Verify that we need a total overscroll delta of at least 10 in a pinned
-// direction before we start stretching.
-TEST_F(ScrollElasticityControllerTest, MinimumDeltaBeforeStretch) {
- // We should not start stretching while we are not pinned in the direction
- // of the scroll (even if there is an overscroll delta). We have to wait for
- // the regular scroll to eat all of the events.
- helper_.SetScrollOffsetAndMaxScrollOffset(gfx::ScrollOffset(5, 5),
- gfx::ScrollOffset(10, 10));
- SendGestureScrollBegin(NonMomentumPhase);
- SendGestureScrollUpdate(NonMomentumPhase, gfx::Vector2dF(0, 10),
- gfx::Vector2dF(0, 10));
- SendGestureScrollUpdate(NonMomentumPhase, gfx::Vector2dF(0, 10),
- gfx::Vector2dF(0, 10));
- EXPECT_EQ(0, helper_.set_stretch_amount_count());
-
- // Now pin the -X and +Y direction. The first event will not generate a
- // stretch
- // because it is below the delta threshold of 10.
- helper_.SetScrollOffsetAndMaxScrollOffset(gfx::ScrollOffset(0, 10),
- gfx::ScrollOffset(10, 10));
- SendGestureScrollUpdate(NonMomentumPhase, gfx::Vector2dF(0, 10),
- gfx::Vector2dF(0, 8));
- EXPECT_EQ(0, helper_.set_stretch_amount_count());
-
- // Make the next scroll be in the -X direction more than the +Y direction,
- // which will erase the memory of the previous unused delta of 8.
- SendGestureScrollUpdate(NonMomentumPhase, gfx::Vector2dF(-10, 5),
- gfx::Vector2dF(-8, 10));
- EXPECT_EQ(0, helper_.set_stretch_amount_count());
-
- // Now push against the pinned +Y direction again by 8. We reset the
- // previous delta, so this will not generate a stretch.
- SendGestureScrollUpdate(NonMomentumPhase, gfx::Vector2dF(0, 10),
- gfx::Vector2dF(0, 8));
- EXPECT_EQ(0, helper_.set_stretch_amount_count());
-
- // Push against +Y by another 8. This gets us above the delta threshold of
- // 10, so we should now have had the stretch set, and it should be in the
- // +Y direction. The scroll in the -X direction should have been forgotten.
- SendGestureScrollUpdate(NonMomentumPhase, gfx::Vector2dF(0, 10),
- gfx::Vector2dF(0, 8));
- EXPECT_EQ(1, helper_.set_stretch_amount_count());
- EXPECT_EQ(0.f, helper_.StretchAmount().x());
- EXPECT_LT(0.f, helper_.StretchAmount().y());
-
- // End the gesture. Because there is a non-zero stretch, we should be in the
- // animated state, and should have had a frame requested.
- EXPECT_EQ(0, helper_.request_begin_frame_count());
- SendGestureScrollEnd();
- EXPECT_EQ(1, helper_.request_begin_frame_count());
-}
-
-// Verify that a stretch caused by a momentum scroll will switch to the
-// animating mode, where input events are ignored, and the stretch is updated
-// while animating.
-TEST_F(ScrollElasticityControllerTest, MomentumAnimate) {
- // Do an active scroll, then switch to the momentum phase and scroll for a
- // bit.
- helper_.SetScrollOffsetAndMaxScrollOffset(gfx::ScrollOffset(5, 5),
- gfx::ScrollOffset(10, 10));
- SendGestureScrollBegin(NonMomentumPhase);
- SendGestureScrollUpdate(NonMomentumPhase, gfx::Vector2dF(0, -80),
- gfx::Vector2dF(0, 0));
- SendGestureScrollUpdate(NonMomentumPhase, gfx::Vector2dF(0, -80),
- gfx::Vector2dF(0, 0));
- SendGestureScrollUpdate(NonMomentumPhase, gfx::Vector2dF(0, -80),
- gfx::Vector2dF(0, 0));
- SendGestureScrollEnd();
- SendGestureScrollBegin(MomentumPhase);
- SendGestureScrollUpdate(MomentumPhase, gfx::Vector2dF(0, -80),
- gfx::Vector2dF(0, 0));
- SendGestureScrollUpdate(MomentumPhase, gfx::Vector2dF(0, -80),
- gfx::Vector2dF(0, 0));
- SendGestureScrollUpdate(MomentumPhase, gfx::Vector2dF(0, -80),
- gfx::Vector2dF(0, 0));
- EXPECT_EQ(0, helper_.set_stretch_amount_count());
-
- // Hit the -Y edge and overscroll slightly, but not enough to go over the
- // threshold to cause a stretch.
- helper_.SetScrollOffsetAndMaxScrollOffset(gfx::ScrollOffset(5, 0),
- gfx::ScrollOffset(10, 10));
- SendGestureScrollUpdate(MomentumPhase, gfx::Vector2dF(0, -80),
- gfx::Vector2dF(0, -8));
- EXPECT_EQ(0, helper_.set_stretch_amount_count());
- EXPECT_EQ(0, helper_.request_begin_frame_count());
-
- // Take another step, this time going over the threshold. This should update
- // the stretch amount, and then switch to the animating mode.
- SendGestureScrollUpdate(MomentumPhase, gfx::Vector2dF(0, -80),
- gfx::Vector2dF(0, -80));
- EXPECT_EQ(1, helper_.set_stretch_amount_count());
- EXPECT_EQ(1, helper_.request_begin_frame_count());
- EXPECT_GT(-1.f, helper_.StretchAmount().y());
-
- // Subsequent momentum events should do nothing.
- SendGestureScrollUpdate(MomentumPhase, gfx::Vector2dF(0, -80),
- gfx::Vector2dF(0, -80));
- SendGestureScrollUpdate(MomentumPhase, gfx::Vector2dF(0, -80),
- gfx::Vector2dF(0, -80));
- SendGestureScrollUpdate(MomentumPhase, gfx::Vector2dF(0, -80),
- gfx::Vector2dF(0, -80));
- SendGestureScrollEnd();
- EXPECT_EQ(1, helper_.set_stretch_amount_count());
- EXPECT_EQ(1, helper_.request_begin_frame_count());
-
- // Subsequent animate events should update the stretch amount and request
- // another frame.
- TickCurrentTimeAndAnimate();
- EXPECT_EQ(2, helper_.set_stretch_amount_count());
- EXPECT_EQ(2, helper_.request_begin_frame_count());
- EXPECT_GT(-1.f, helper_.StretchAmount().y());
-
- // Touching the trackpad (a PhaseMayBegin event) should disable animation.
- SendGestureScrollBegin(NonMomentumPhase);
- TickCurrentTimeAndAnimate();
- EXPECT_EQ(2, helper_.set_stretch_amount_count());
- EXPECT_EQ(2, helper_.request_begin_frame_count());
-
- // Releasing the trackpad should re-enable animation.
- SendGestureScrollEnd();
- EXPECT_EQ(2, helper_.set_stretch_amount_count());
- EXPECT_EQ(3, helper_.request_begin_frame_count());
- TickCurrentTimeAndAnimate();
- EXPECT_EQ(3, helper_.set_stretch_amount_count());
- EXPECT_EQ(4, helper_.request_begin_frame_count());
-
- // Keep animating frames until the stretch returns to rest.
- int stretch_count = 3;
- int begin_frame_count = 4;
- while (1) {
- TickCurrentTimeAndAnimate();
- if (helper_.StretchAmount().IsZero()) {
- stretch_count += 1;
- EXPECT_EQ(stretch_count, helper_.set_stretch_amount_count());
- EXPECT_EQ(begin_frame_count, helper_.request_begin_frame_count());
- break;
- }
- stretch_count += 1;
- begin_frame_count += 1;
- EXPECT_EQ(stretch_count, helper_.set_stretch_amount_count());
- EXPECT_EQ(begin_frame_count, helper_.request_begin_frame_count());
- }
-
- // After coming to rest, no subsequent animate calls change anything.
- TickCurrentTimeAndAnimate();
- EXPECT_EQ(stretch_count, helper_.set_stretch_amount_count());
- EXPECT_EQ(begin_frame_count, helper_.request_begin_frame_count());
-}
-
-// Verify that a stretch opposing a scroll is correctly resolved.
-TEST_F(ScrollElasticityControllerTest, ReconcileStretchAndScroll) {
- SendGestureScrollBegin(NonMomentumPhase);
-
- // Verify completely knocking out the scroll in the -Y direction.
- helper_.SetScrollOffsetAndMaxScrollOffset(gfx::ScrollOffset(5, 5),
- gfx::ScrollOffset(10, 10));
- helper_.SetStretchAmount(gfx::Vector2dF(0, -10));
- controller_.ReconcileStretchAndScroll();
- EXPECT_EQ(helper_.StretchAmount(), gfx::Vector2dF(0, -5));
- EXPECT_EQ(helper_.ScrollOffset(), gfx::ScrollOffset(5, 0));
-
- // Verify partially knocking out the scroll in the -Y direction.
- helper_.SetScrollOffsetAndMaxScrollOffset(gfx::ScrollOffset(5, 8),
- gfx::ScrollOffset(10, 10));
- helper_.SetStretchAmount(gfx::Vector2dF(0, -5));
- controller_.ReconcileStretchAndScroll();
- EXPECT_EQ(helper_.StretchAmount(), gfx::Vector2dF(0, 0));
- EXPECT_EQ(helper_.ScrollOffset(), gfx::ScrollOffset(5, 3));
-
- // Verify completely knocking out the scroll in the +X direction.
- helper_.SetScrollOffsetAndMaxScrollOffset(gfx::ScrollOffset(5, 5),
- gfx::ScrollOffset(10, 10));
- helper_.SetStretchAmount(gfx::Vector2dF(10, 0));
- controller_.ReconcileStretchAndScroll();
- EXPECT_EQ(helper_.StretchAmount(), gfx::Vector2dF(5, 0));
- EXPECT_EQ(helper_.ScrollOffset(), gfx::ScrollOffset(10, 5));
-
- // Verify partially knocking out the scroll in the +X and +Y directions.
- helper_.SetScrollOffsetAndMaxScrollOffset(gfx::ScrollOffset(2, 3),
- gfx::ScrollOffset(10, 10));
- helper_.SetStretchAmount(gfx::Vector2dF(5, 5));
- controller_.ReconcileStretchAndScroll();
- EXPECT_EQ(helper_.StretchAmount(), gfx::Vector2dF(0, 0));
- EXPECT_EQ(helper_.ScrollOffset(), gfx::ScrollOffset(7, 8));
-}
-
-// Verify that stretching happens when the area is user scrollable.
-TEST_F(ScrollElasticityControllerTest,
- UserScrollableRequiredForStretch) {
- helper_.SetScrollOffsetAndMaxScrollOffset(gfx::ScrollOffset(0, 0),
- gfx::ScrollOffset(10, 10));
- gfx::Vector2dF delta(0, -15);
-
- // Do an active scroll, and ensure that the stretch amount doesn't change.
- helper_.SetUserScrollable(false);
- SendGestureScrollBegin(NonMomentumPhase);
- SendGestureScrollUpdate(NonMomentumPhase, delta, delta);
- SendGestureScrollUpdate(NonMomentumPhase, delta, delta);
- SendGestureScrollEnd();
- EXPECT_EQ(helper_.StretchAmount(), gfx::Vector2dF(0, 0));
- EXPECT_EQ(0, helper_.set_stretch_amount_count());
- SendGestureScrollBegin(MomentumPhase);
- SendGestureScrollUpdate(MomentumPhase, delta, delta);
- SendGestureScrollUpdate(MomentumPhase, delta, delta);
- SendGestureScrollEnd();
- EXPECT_EQ(helper_.StretchAmount(), gfx::Vector2dF(0, 0));
- EXPECT_EQ(0, helper_.set_stretch_amount_count());
-
- // Re-enable user scrolling and ensure that stretching is re-enabled.
- helper_.SetUserScrollable(true);
- SendGestureScrollBegin(NonMomentumPhase);
- SendGestureScrollUpdate(NonMomentumPhase, delta, delta);
- SendGestureScrollUpdate(NonMomentumPhase, delta, delta);
- SendGestureScrollEnd();
- EXPECT_NE(helper_.StretchAmount(), gfx::Vector2dF(0, 0));
- EXPECT_GT(helper_.set_stretch_amount_count(), 0);
- SendGestureScrollBegin(MomentumPhase);
- SendGestureScrollUpdate(MomentumPhase, delta, delta);
- SendGestureScrollUpdate(MomentumPhase, delta, delta);
- SendGestureScrollEnd();
- EXPECT_NE(helper_.StretchAmount(), gfx::Vector2dF(0, 0));
- EXPECT_GT(helper_.set_stretch_amount_count(), 0);
-
- // Disable user scrolling and tick the timer until the stretch goes back
- // to zero. Ensure that the return to zero doesn't happen immediately.
- helper_.SetUserScrollable(false);
- int ticks_to_zero = 0;
- while (1) {
- TickCurrentTimeAndAnimate();
- if (helper_.StretchAmount().IsZero())
- break;
- ticks_to_zero += 1;
- }
- EXPECT_GT(ticks_to_zero, 3);
-}
-
-// Verify that OverscrollBehaviorTypeNone disables the stretching on the
-// specified axis.
-TEST_F(ScrollElasticityControllerTest, OverscrollBehavior) {
- helper_.SetScrollOffsetAndMaxScrollOffset(gfx::ScrollOffset(0, 0),
- gfx::ScrollOffset(0, 0));
-
- // If we set OverscrollBehaviorTypeNone on x, we should not see a stretch
- // in the X direction.
- SendGestureScrollBegin(NonMomentumPhase);
- SendGestureScrollUpdate(
- NonMomentumPhase, gfx::Vector2dF(10, 0), gfx::Vector2dF(10, 0),
- cc::OverscrollBehavior(
- cc::OverscrollBehavior::kOverscrollBehaviorTypeNone,
- cc::OverscrollBehavior::kOverscrollBehaviorTypeAuto));
- EXPECT_EQ(0, helper_.set_stretch_amount_count());
- EXPECT_EQ(0.f, helper_.StretchAmount().x());
- EXPECT_EQ(0.f, helper_.StretchAmount().y());
- helper_.SetStretchAmount(gfx::Vector2dF());
- EXPECT_EQ(1, helper_.set_stretch_amount_count());
- SendGestureScrollEnd();
- EXPECT_EQ(0, helper_.request_begin_frame_count());
-
- // If we set OverscrollBehaviorTypeNone on x, we could still see a stretch
- // in the Y direction
- SendGestureScrollBegin(NonMomentumPhase);
- SendGestureScrollUpdate(
- NonMomentumPhase, gfx::Vector2dF(0, 10), gfx::Vector2dF(0, 10),
- cc::OverscrollBehavior(
- cc::OverscrollBehavior::kOverscrollBehaviorTypeNone,
- cc::OverscrollBehavior::kOverscrollBehaviorTypeAuto));
- EXPECT_EQ(2, helper_.set_stretch_amount_count());
- EXPECT_EQ(0.f, helper_.StretchAmount().x());
- EXPECT_LT(0.f, helper_.StretchAmount().y());
- helper_.SetStretchAmount(gfx::Vector2dF());
- EXPECT_EQ(3, helper_.set_stretch_amount_count());
- SendGestureScrollEnd();
- EXPECT_EQ(0, helper_.request_begin_frame_count());
-
- // If we set OverscrollBehaviorTypeNone on y, we should not see a stretch
- // in the Y direction.
- SendGestureScrollBegin(NonMomentumPhase);
- SendGestureScrollUpdate(
- NonMomentumPhase, gfx::Vector2dF(0, 10), gfx::Vector2dF(0, 10),
- cc::OverscrollBehavior(
- cc::OverscrollBehavior::kOverscrollBehaviorTypeAuto,
- cc::OverscrollBehavior::kOverscrollBehaviorTypeNone));
- EXPECT_EQ(3, helper_.set_stretch_amount_count());
- EXPECT_EQ(0.f, helper_.StretchAmount().x());
- EXPECT_EQ(0.f, helper_.StretchAmount().y());
- helper_.SetStretchAmount(gfx::Vector2dF());
- EXPECT_EQ(4, helper_.set_stretch_amount_count());
- SendGestureScrollEnd();
- EXPECT_EQ(0, helper_.request_begin_frame_count());
-
- // If we set OverscrollBehaviorTypeNone on y, we could still see a stretch
- // in the X direction.
- SendGestureScrollBegin(NonMomentumPhase);
- SendGestureScrollUpdate(
- NonMomentumPhase, gfx::Vector2dF(10, 0), gfx::Vector2dF(10, 0),
- cc::OverscrollBehavior(
- cc::OverscrollBehavior::kOverscrollBehaviorTypeAuto,
- cc::OverscrollBehavior::kOverscrollBehaviorTypeNone));
- EXPECT_EQ(5, helper_.set_stretch_amount_count());
- EXPECT_LT(0.f, helper_.StretchAmount().x());
- EXPECT_EQ(0.f, helper_.StretchAmount().y());
- helper_.SetStretchAmount(gfx::Vector2dF());
- EXPECT_EQ(6, helper_.set_stretch_amount_count());
- SendGestureScrollEnd();
- EXPECT_EQ(0, helper_.request_begin_frame_count());
-}
-
-} // namespace
-} // namespace ui
diff --git a/chromium/ui/events/blink/momentum_scroll_jank_tracker.cc b/chromium/ui/events/blink/momentum_scroll_jank_tracker.cc
deleted file mode 100644
index f0fede5c574..00000000000
--- a/chromium/ui/events/blink/momentum_scroll_jank_tracker.cc
+++ /dev/null
@@ -1,62 +0,0 @@
-// Copyright 2019 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 "ui/events/blink/momentum_scroll_jank_tracker.h"
-
-#include "base/metrics/histogram_functions.h"
-#include "ui/events/blink/blink_event_util.h"
-#include "ui/events/blink/event_with_callback.h"
-
-namespace ui {
-
-constexpr base::TimeDelta MomentumScrollJankTracker::kRecentEventCutoff;
-
-MomentumScrollJankTracker::~MomentumScrollJankTracker() {
- // Don't log if this scroll had no momentum input (after the first event).
- if (total_event_count_ == 0)
- return;
-
- // We want to target 0 janks, so round our percentages up so that a single
- // jank over a large number of frames doesn't get lost.
- // Don't worry about overflow as we'd need a gesture > 100hrs long to hit,
- // and the downside is an incorrect metric.
- uint32_t rounding_factor = total_event_count_ - 1;
- uint32_t jank_percentage =
- (jank_count_ * 100 + rounding_factor) / total_event_count_;
-
- base::UmaHistogramPercentage("Renderer4.MomentumScrollJankPercentage",
- jank_percentage);
-}
-
-void MomentumScrollJankTracker::OnDispatchedInputEvent(
- EventWithCallback* event_with_callback,
- const base::TimeTicks& now) {
- DCHECK_EQ(event_with_callback->event().GetType(),
- blink::WebGestureEvent::kGestureScrollUpdate);
-
- const auto& gesture_event = ToWebGestureEvent(event_with_callback->event());
-
- // If the scroll is not in the momentum phase, it's driven by user input,
- // which happens at a higher frequency. Ignore this.
- if (gesture_event.data.scroll_update.inertial_phase !=
- blink::WebGestureEvent::InertialPhaseState::kMomentum) {
- return;
- }
-
- // Ignore the first momentum input event, as this may happen out-of band
- // with BeginFrame, and may be coalesced in a non-jank scenario.
- // TODO(ericrk): Add a metric to track jank in the transition from user
- // to momentum input.
- if (!seen_first_momentum_input_) {
- seen_first_momentum_input_ = true;
- return;
- }
-
- total_event_count_ += event_with_callback->coalesced_count();
-
- jank_count_ +=
- event_with_callback->coalesced_count() - kExpectedMomentumEventsPerFrame;
-}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/momentum_scroll_jank_tracker.h b/chromium/ui/events/blink/momentum_scroll_jank_tracker.h
deleted file mode 100644
index dca70eed40e..00000000000
--- a/chromium/ui/events/blink/momentum_scroll_jank_tracker.h
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2019 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 UI_EVENTS_BLINK_MOMENTUM_SCROLL_JANK_TRACKER_H_
-#define UI_EVENTS_BLINK_MOMENTUM_SCROLL_JANK_TRACKER_H_
-
-#include "base/time/time.h"
-
-namespace ui {
-class EventWithCallback;
-
-// Class which is used during a scroll event to detect, accumulate, and log
-// jank metrics for the momentum phase.
-class MomentumScrollJankTracker {
- public:
- ~MomentumScrollJankTracker();
- void OnDispatchedInputEvent(EventWithCallback* event_with_callback,
- const base::TimeTicks& now);
-
- private:
- // The number of expected momentum events which should be coalesced in a
- // single frame.
- // If we update momentum event generation to happen more than once per frame,
- // |kExpectedMomentumEventsPerFrame| should be updated or this data plumbed
- // in from a different source.
- static constexpr uint32_t kExpectedMomentumEventsPerFrame = 1;
-
- // The amount of time elapsed between coalescing an event and dispatching the
- // event for which we consider the coalescing to be "recent" for the purposes
- // of https://crbug.com/952930.
- static constexpr base::TimeDelta kRecentEventCutoff =
- base::TimeDelta::FromMilliseconds(2);
-
- // |jank_count_| is the number of coalesced momentum input events above
- // kExptectedMomentumEventsPerFrame.
- uint32_t jank_count_ = 0;
-
- // The number of events processed during a gesture.
- uint32_t total_event_count_ = 0;
-
- // Used to avoid tracking jank in the first momentum event, as this may be
- // unreliable.
- bool seen_first_momentum_input_ = false;
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_MOMENTUM_SCROLL_JANK_TRACKER_H_
diff --git a/chromium/ui/events/blink/prediction/empty_filter.cc b/chromium/ui/events/blink/prediction/empty_filter.cc
deleted file mode 100644
index 66a505612da..00000000000
--- a/chromium/ui/events/blink/prediction/empty_filter.cc
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2019 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 "ui/events/blink/prediction/empty_filter.h"
-#include "ui/events/blink/prediction/filter_factory.h"
-
-namespace ui {
-
-EmptyFilter::EmptyFilter() {}
-EmptyFilter::~EmptyFilter() {}
-
-bool EmptyFilter::Filter(const base::TimeTicks& timestamp,
- gfx::PointF* position) const {
- return position != nullptr;
-}
-
-const char* EmptyFilter::GetName() const {
- return input_prediction::kFilterNameEmpty;
-}
-
-InputFilter* EmptyFilter::Clone() {
- return new EmptyFilter();
-}
-
-void EmptyFilter::Reset() {}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/empty_filter.h b/chromium/ui/events/blink/prediction/empty_filter.h
deleted file mode 100644
index ed661d02169..00000000000
--- a/chromium/ui/events/blink/prediction/empty_filter.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2019 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 UI_EVENTS_BLINK_PREDICTION_EMPTY_FILTER_H_
-#define UI_EVENTS_BLINK_PREDICTION_EMPTY_FILTER_H_
-
-#include "ui/events/blink/prediction/input_filter.h"
-
-namespace ui {
-
-// Empty filter is a fake filter. Always returns the same input position as
-// the filtered position. Mainly used for testing purpose.
-class EmptyFilter : public InputFilter {
- public:
- explicit EmptyFilter();
- ~EmptyFilter() override;
-
- // Filters the position sent to the filter at a specific timestamp.
- // Returns true if the value is filtered, false otherwise.
- bool Filter(const base::TimeTicks& timestamp,
- gfx::PointF* position) const override;
-
- // Returns the name of the filter
- const char* GetName() const override;
-
- // Returns a copy of the filter.
- InputFilter* Clone() override;
-
- // Reset the filter to its initial state
- void Reset() override;
-
- DISALLOW_COPY_AND_ASSIGN(EmptyFilter);
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_PREDICTION_EMPTY_FILTER_H_
diff --git a/chromium/ui/events/blink/prediction/empty_filter_unittests.cc b/chromium/ui/events/blink/prediction/empty_filter_unittests.cc
deleted file mode 100644
index a8b3c36d0b7..00000000000
--- a/chromium/ui/events/blink/prediction/empty_filter_unittests.cc
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright 2019 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/rand_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/events/blink/prediction/empty_filter.h"
-#include "ui/events/blink/prediction/filter_factory.h"
-#include "ui/events/blink/prediction/input_filter_unittest_helpers.h"
-
-namespace ui {
-namespace test {
-
-class EmptyFilterTest : public InputFilterTest {
- public:
- explicit EmptyFilterTest() {}
-
- void SetUp() override { filter_ = std::make_unique<ui::EmptyFilter>(); }
-
- DISALLOW_COPY_AND_ASSIGN(EmptyFilterTest);
-};
-
-// Test the Clone function of the filter
-TEST_F(EmptyFilterTest, TestClone) {
- TestCloneFilter();
-}
-
-// Test the Reset function of the filter
-TEST_F(EmptyFilterTest, TestReset) {
- TestResetFilter();
-}
-
-// Test the empty filter gives the same values
-TEST_F(EmptyFilterTest, filteringValues) {
- base::TimeTicks ts = blink::WebInputEvent::GetStaticTimeStampForTests();
- gfx::PointF point, filtered_point;
- for (int i = 0; i < 100; i++) {
- point.SetPoint(base::RandDouble(), base::RandDouble());
- filtered_point = point;
- EXPECT_TRUE(filter_->Filter(ts, &filtered_point));
- EXPECT_EQ(point.x(), filtered_point.x());
- EXPECT_EQ(point.y(), filtered_point.y());
- }
-}
-
-} // namespace test
-} // namespace ui \ No newline at end of file
diff --git a/chromium/ui/events/blink/prediction/empty_predictor.cc b/chromium/ui/events/blink/prediction/empty_predictor.cc
deleted file mode 100644
index c429407f6fd..00000000000
--- a/chromium/ui/events/blink/prediction/empty_predictor.cc
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2018 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 "ui/events/blink/prediction/empty_predictor.h"
-#include "ui/events/blink/prediction/predictor_factory.h"
-
-namespace ui {
-
-EmptyPredictor::EmptyPredictor() {
- Reset();
-}
-
-EmptyPredictor::~EmptyPredictor() = default;
-
-const char* EmptyPredictor::GetName() const {
- return input_prediction::kScrollPredictorNameEmpty;
-}
-
-void EmptyPredictor::Reset() {
- last_input_ = base::nullopt;
-}
-
-void EmptyPredictor::Update(const InputData& cur_input) {
- last_input_ = cur_input;
-}
-
-bool EmptyPredictor::HasPrediction() const {
- return last_input_.has_value();
-}
-
-std::unique_ptr<InputPredictor::InputData> EmptyPredictor::GeneratePrediction(
- base::TimeTicks predict_time) const {
- if (!HasPrediction())
- return nullptr;
- return std::make_unique<InputData>(last_input_.value());
-}
-
-base::TimeDelta EmptyPredictor::TimeInterval() const {
- return kTimeInterval;
-}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/empty_predictor.h b/chromium/ui/events/blink/prediction/empty_predictor.h
deleted file mode 100644
index 2ef6d264e2a..00000000000
--- a/chromium/ui/events/blink/prediction/empty_predictor.h
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright 2018 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 UI_EVENTS_BLINK_PREDICTION_EMPTY_PREDICTOR_H_
-#define UI_EVENTS_BLINK_PREDICTION_EMPTY_PREDICTOR_H_
-
-#include "base/optional.h"
-#include "ui/events/blink/prediction/input_predictor.h"
-
-namespace ui {
-
-// An empty predictor class. This will not generate any prediction.
-class EmptyPredictor : public InputPredictor {
- public:
- EmptyPredictor();
- ~EmptyPredictor() override;
-
- const char* GetName() const override;
-
- void Reset() override;
-
- // store the cur_input in last_input_
- void Update(const InputData& cur_input) override;
-
- // Always returns false;
- bool HasPrediction() const override;
-
- // Returns the last_input_ for testing.
- std::unique_ptr<InputData> GeneratePrediction(
- base::TimeTicks predict_time) const override;
-
- // Returns kTimeInterval for testing.
- base::TimeDelta TimeInterval() const override;
-
- private:
- // store the last_input_ point for testing
- base::Optional<InputData> last_input_;
-
- DISALLOW_COPY_AND_ASSIGN(EmptyPredictor);
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_PREDICTION_EMPTY_PREDICTOR_H_
diff --git a/chromium/ui/events/blink/prediction/filter_factory.cc b/chromium/ui/events/blink/prediction/filter_factory.cc
deleted file mode 100644
index 7e86e8b23c3..00000000000
--- a/chromium/ui/events/blink/prediction/filter_factory.cc
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright 2019 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 "ui/events/blink/prediction/filter_factory.h"
-#include "base/metrics/field_trial.h"
-#include "base/metrics/field_trial_params.h"
-#include "base/strings/string_number_conversions.h"
-#include "ui/events/blink/prediction/empty_filter.h"
-#include "ui/events/blink/prediction/one_euro_filter.h"
-#include "ui/events/blink/prediction/predictor_factory.h"
-
-namespace ui {
-
-namespace input_prediction {
-
-const char kFilterNameEmpty[] = "empty_filter";
-const char kFilterNameOneEuro[] = "one_euro_filter";
-
-} // namespace input_prediction
-
-namespace {
-using input_prediction::FilterType;
-using input_prediction::PredictorType;
-} // namespace
-
-FilterFactory::FilterFactory(
- const base::Feature& feature,
- const input_prediction::PredictorType predictor_type,
- const input_prediction::FilterType filter_type) {
- LoadFilterParams(feature, predictor_type, filter_type);
-}
-
-FilterFactory::~FilterFactory() {}
-
-void FilterFactory::LoadFilterParams(
- const base::Feature& feature,
- const input_prediction::PredictorType predictor_type,
- const input_prediction::FilterType filter_type) {
- if (filter_type == FilterType::kOneEuro) {
- base::FieldTrialParams one_euro_filter_param = {
- {OneEuroFilter::kParamBeta, ""}, {OneEuroFilter::kParamMincutoff, ""}};
- double beta, mincutoff;
- // Only save the params if they are given in the fieldtrials params
- if (base::GetFieldTrialParamsByFeature(feature, &one_euro_filter_param) &&
- base::StringToDouble(one_euro_filter_param[OneEuroFilter::kParamBeta],
- &beta) &&
- base::StringToDouble(
- one_euro_filter_param[OneEuroFilter::kParamMincutoff],
- &mincutoff)) {
- FilterParamMapKey param_key = {FilterType::kOneEuro, predictor_type};
- FilterParams param_value = {{OneEuroFilter::kParamMincutoff, mincutoff},
- {OneEuroFilter::kParamBeta, beta}};
- filter_params_map_.emplace(param_key, param_value);
- }
- }
-}
-
-FilterType FilterFactory::GetFilterTypeFromName(
- const std::string& filter_name) {
- if (filter_name == input_prediction::kFilterNameOneEuro)
- return FilterType::kOneEuro;
- else
- return FilterType::kEmpty;
-}
-
-std::unique_ptr<InputFilter> FilterFactory::CreateFilter(
- const FilterType filter_type,
- const PredictorType predictor_type) {
- FilterParams filter_params;
- GetFilterParams(filter_type, predictor_type, &filter_params);
- if (filter_type == FilterType::kOneEuro) {
- if (filter_params.empty())
- return std::make_unique<OneEuroFilter>();
- else
- return std::make_unique<OneEuroFilter>(
- filter_params.find(OneEuroFilter::kParamMincutoff)->second,
- filter_params.find(OneEuroFilter::kParamBeta)->second);
- } else
- return std::make_unique<EmptyFilter>();
-}
-
-void FilterFactory::GetFilterParams(const FilterType filter_type,
- const PredictorType predictor_type,
- FilterParams* filter_params) {
- FilterParamMapKey key = {filter_type, predictor_type};
- auto params = filter_params_map_.find(key);
- if (params != filter_params_map_.end()) {
- *filter_params = params->second;
- }
-}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/filter_factory.h b/chromium/ui/events/blink/prediction/filter_factory.h
deleted file mode 100644
index 8892cef23e6..00000000000
--- a/chromium/ui/events/blink/prediction/filter_factory.h
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright 2019 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 UI_EVENTS_BLINK_PREDICTION_FILTER_FACTORY_H_
-#define UI_EVENTS_BLINK_PREDICTION_FILTER_FACTORY_H_
-
-#include "base/feature_list.h"
-#include "ui/events/blink/prediction/input_filter.h"
-#include "ui/events/blink/prediction/predictor_factory.h"
-
-namespace ui {
-
-namespace test {
-class FilterFactoryTest;
-} // namespace test
-
-namespace input_prediction {
-extern const char kFilterNameEmpty[];
-extern const char kFilterNameOneEuro[];
-
-enum class FilterType {
- kEmpty,
- kOneEuro,
-};
-} // namespace input_prediction
-
-// Structure used as key in the unordered_map to store different filter params
-// in function of a trio {Filter, Predictor, Feature}
-struct FilterParamMapKey {
- bool operator==(const FilterParamMapKey& other) const {
- return filter_type == other.filter_type &&
- predictor_type == other.predictor_type;
- }
- input_prediction::FilterType filter_type;
- input_prediction::PredictorType predictor_type;
-};
-
-// Used to compute a hash value for FilterParamMapKey so it can be used as key
-// in a hashmap
-struct FilterParamMapKeyHash {
- std::size_t operator()(const FilterParamMapKey& k) const {
- return std::hash<input_prediction::FilterType>{}(k.filter_type) ^
- std::hash<input_prediction::PredictorType>{}(k.predictor_type);
- }
-};
-
-using FilterParams = std::unordered_map<std::string, double>;
-using FilterParamsMap =
- std::unordered_map<FilterParamMapKey, FilterParams, FilterParamMapKeyHash>;
-
-// FilterFactory is a class containing methods to create filters.
-// It defines filters name and type constants. It also reads filter settings
-// from fieldtrials if needed.
-class FilterFactory {
- public:
- FilterFactory(const base::Feature& feature,
- const input_prediction::PredictorType predictor_type,
- const input_prediction::FilterType filter_type);
- ~FilterFactory();
-
- // Returns the FilterType associated to the given filter
- // name if found, otherwise returns kFilterTypeEmpty
- input_prediction::FilterType GetFilterTypeFromName(
- const std::string& filter_name);
-
- // Returns the filter designed by its type.
- // Since filters can have different parameters in function of the current
- // predictor used, it also needs to be given as parameter.
- std::unique_ptr<InputFilter> CreateFilter(
- const input_prediction::FilterType filter_type,
- const input_prediction::PredictorType predictor_type);
-
- private:
- friend class test::FilterFactoryTest;
-
- // Map storing filter parameters for a pair {FilterType, PredictorType}.
- // Currently the map is only storing values from fieldtrials params, but
- // default parameters might be added for a specific predictor/filter pair
- // in the future.
- FilterParamsMap filter_params_map_;
-
- // Initialize the filter_params_map_ with values from fieldtrials params for
- // a given feature, predictor and filter.
- // Might initialize some default values for specific predictor/filter pair in
- // the future.
- void LoadFilterParams(const base::Feature& feature,
- const input_prediction::PredictorType predictor_type,
- const input_prediction::FilterType filter_type);
-
- // Gets filter params for a specific key couple {FilterType, PredictorType}
- // If params are found, update the given filter_params map.
- void GetFilterParams(const input_prediction::FilterType filter_type,
- const input_prediction::PredictorType predictor_type,
- FilterParams* filter_params);
-};
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_PREDICTION_FILTER_FACTORY_H_ \ No newline at end of file
diff --git a/chromium/ui/events/blink/prediction/filter_factory_unittests.cc b/chromium/ui/events/blink/prediction/filter_factory_unittests.cc
deleted file mode 100644
index 41e8aadfa8c..00000000000
--- a/chromium/ui/events/blink/prediction/filter_factory_unittests.cc
+++ /dev/null
@@ -1,138 +0,0 @@
-// Copyright 2019 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/test/scoped_feature_list.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/events/blink/blink_features.h"
-#include "ui/events/blink/prediction/filter_factory.h"
-#include "ui/events/blink/prediction/one_euro_filter.h"
-
-namespace ui {
-namespace test {
-
-namespace {
-using base::Feature;
-using input_prediction::FilterType;
-using input_prediction::PredictorType;
-} // namespace
-
-class FilterFactoryTest : public testing::Test {
- public:
- FilterFactoryTest() {
- CreateNewFactory(features::kFilteringScrollPrediction,
- PredictorType::kScrollPredictorTypeKalman,
- FilterType::kEmpty);
- }
-
- void GetFilterParams(const FilterType& filter_type,
- const PredictorType& predictor_type,
- FilterParams* filter_params) {
- factory_->GetFilterParams(filter_type, predictor_type, filter_params);
- }
-
- FilterType GetFilterTypeFromName(const std::string& filter_name) {
- return factory_->GetFilterTypeFromName(filter_name);
- }
-
- std::unique_ptr<InputFilter> CreateFilter(
- const input_prediction::FilterType filter_type,
- const input_prediction::PredictorType predictor_type) {
- return factory_->CreateFilter(filter_type, predictor_type);
- }
-
- void CreateNewFactory(const base::Feature& feature,
- const input_prediction::PredictorType predictor_type,
- const input_prediction::FilterType filter_type) {
- factory_ =
- std::make_unique<FilterFactory>(feature, predictor_type, filter_type);
- }
-
- private:
- std::unique_ptr<FilterFactory> factory_;
-
- DISALLOW_COPY_AND_ASSIGN(FilterFactoryTest);
-};
-
-// Check if the FilterType returned is correct
-TEST_F(FilterFactoryTest, TestGetFilterType) {
- EXPECT_EQ(input_prediction::FilterType::kEmpty,
- GetFilterTypeFromName(input_prediction::kFilterNameEmpty));
-
- EXPECT_EQ(input_prediction::FilterType::kOneEuro,
- GetFilterTypeFromName(input_prediction::kFilterNameOneEuro));
-
- // Default type Empty
- EXPECT_EQ(input_prediction::FilterType::kEmpty, GetFilterTypeFromName(""));
-}
-
-TEST_F(FilterFactoryTest, TestCreateFilter) {
- EXPECT_STREQ(
- input_prediction::kFilterNameEmpty,
- CreateFilter(input_prediction::FilterType::kEmpty,
- input_prediction::PredictorType::kScrollPredictorTypeEmpty)
- ->GetName());
-
- EXPECT_STREQ(
- input_prediction::kFilterNameOneEuro,
- CreateFilter(input_prediction::FilterType::kOneEuro,
- input_prediction::PredictorType::kScrollPredictorTypeEmpty)
- ->GetName());
-}
-
-// Test there is no params available for OneEuro filter
-TEST_F(FilterFactoryTest, TestOneEuroNoParams) {
- FilterParams filter_params;
-
- GetFilterParams(FilterType::kOneEuro,
- PredictorType::kScrollPredictorTypeKalman, &filter_params);
- EXPECT_TRUE(filter_params.empty());
-}
-
-// Test we get the params sent via fieldtrials params
-TEST_F(FilterFactoryTest, TestOneEuroParams) {
- FilterParams filter_params;
-
- base::test::ScopedFeatureList scoped_feature_list;
- base::FieldTrialParams field_trial_params;
-
- field_trial_params[OneEuroFilter::kParamMincutoff] = "33";
- field_trial_params[OneEuroFilter::kParamBeta] = "42";
- scoped_feature_list.Reset();
- scoped_feature_list.InitAndEnableFeatureWithParameters(
- features::kFilteringScrollPrediction, field_trial_params);
-
- // Create a new factory to load fieldtrials params values
- CreateNewFactory(features::kFilteringScrollPrediction,
- PredictorType::kScrollPredictorTypeKalman,
- FilterType::kOneEuro);
-
- GetFilterParams(FilterType::kOneEuro,
- PredictorType::kScrollPredictorTypeKalman, &filter_params);
-
- EXPECT_EQ((int)filter_params.size(), 2);
- EXPECT_EQ(filter_params.find(OneEuroFilter::kParamMincutoff)->second, 33);
- EXPECT_EQ(filter_params.find(OneEuroFilter::kParamBeta)->second, 42);
-
- // fieldtrials params shouldn't be available for another predictor
- filter_params.clear();
- GetFilterParams(FilterType::kOneEuro, PredictorType::kScrollPredictorTypeLsq,
- &filter_params);
-
- EXPECT_TRUE(filter_params.empty());
-}
-
-TEST_F(FilterFactoryTest, TestGetFilter) {
- EXPECT_STREQ(
- input_prediction::kFilterNameEmpty,
- CreateFilter(FilterType::kEmpty, PredictorType::kScrollPredictorTypeEmpty)
- ->GetName());
-
- EXPECT_STREQ(input_prediction::kFilterNameOneEuro,
- CreateFilter(FilterType::kOneEuro,
- PredictorType::kScrollPredictorTypeEmpty)
- ->GetName());
-}
-
-} // namespace test
-} // namespace ui \ No newline at end of file
diff --git a/chromium/ui/events/blink/prediction/input_filter.h b/chromium/ui/events/blink/prediction/input_filter.h
deleted file mode 100644
index 264d58dc7e1..00000000000
--- a/chromium/ui/events/blink/prediction/input_filter.h
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2019 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 UI_EVENTS_BLINK_PREDICTION_INPUT_FILTER_H_
-#define UI_EVENTS_BLINK_PREDICTION_INPUT_FILTER_H_
-
-#include "ui/events/base_event_utils.h"
-#include "ui/gfx/geometry/point_f.h"
-
-namespace ui {
-
-// This class expects a sequence of inputs with coordinates and timestamps to
-// return a smooth path from the sent coordinates.
-class InputFilter {
- public:
- virtual ~InputFilter() = default;
-
- // Filters the position sent to the filter at a specific timestamp.
- // Returns true if the value is filtered, false otherwise.
- virtual bool Filter(const base::TimeTicks& timestamp,
- gfx::PointF* position) const = 0;
-
- // Returns the name of the filter
- virtual const char* GetName() const = 0;
-
- // Returns a copy of the filter.
- virtual InputFilter* Clone() = 0;
-
- // Reset the filter to its initial state
- virtual void Reset() = 0;
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_PREDICTION_INPUT_FILTER_H_ \ No newline at end of file
diff --git a/chromium/ui/events/blink/prediction/input_filter_unittest_helpers.cc b/chromium/ui/events/blink/prediction/input_filter_unittest_helpers.cc
deleted file mode 100644
index 0cd6be47821..00000000000
--- a/chromium/ui/events/blink/prediction/input_filter_unittest_helpers.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-// Copyright 2019 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 "ui/events/blink/prediction/input_filter_unittest_helpers.h"
-
-#include "base/rand_util.h"
-
-namespace ui {
-namespace test {
-
-InputFilterTest::InputFilterTest() = default;
-InputFilterTest::~InputFilterTest() = default;
-
-// Check if the filter is well cloned. We send random values to the filter and
-// then we clone it. If we send the same new random values to both filters,
-// we should have the same filtered results
-void InputFilterTest::TestCloneFilter() {
- gfx::PointF point;
- base::TimeTicks ts = blink::WebInputEvent::GetStaticTimeStampForTests();
- base::TimeDelta delta = base::TimeDelta::FromMilliseconds(8);
-
- for (int i = 0; i < 100; i++) {
- point.SetPoint(base::RandDouble(), base::RandDouble());
- EXPECT_TRUE(filter_->Filter(ts, &point)); // We just feed the filter
- ts += delta;
- }
-
- std::unique_ptr<InputFilter> fork_filter;
- fork_filter.reset(filter_->Clone());
-
- gfx::PointF filtered_point, fork_filtered_point;
- for (int i = 0; i < 100; i++) {
- point.SetPoint(base::RandDouble(), base::RandDouble());
- filtered_point = point;
- fork_filtered_point = point;
- EXPECT_TRUE(filter_->Filter(ts, &filtered_point));
- EXPECT_TRUE(fork_filter->Filter(ts, &fork_filtered_point));
- EXPECT_NEAR(filtered_point.x(), fork_filtered_point.x(), kEpsilon);
- EXPECT_NEAR(filtered_point.y(), fork_filtered_point.y(), kEpsilon);
- ts += delta;
- }
-}
-
-// Check if the filter is well reset. We send random values, save the values and
-// results, then we reset the filter. We send again the same values and see if
-// we have the same results, which would be statistically impossible with 100
-// random without a proper resetting.
-void InputFilterTest::TestResetFilter() {
- std::vector<gfx::PointF> points;
- std::vector<base::TimeTicks> timestamps;
- std::vector<gfx::PointF> results;
- gfx::PointF point;
- base::TimeTicks ts = blink::WebInputEvent::GetStaticTimeStampForTests();
- base::TimeDelta delta = base::TimeDelta::FromMilliseconds(8);
-
- for (int i = 0; i < 100; i++) {
- point.SetPoint(base::RandDouble(), base::RandDouble());
- points.push_back(point);
- timestamps.push_back(ts);
- EXPECT_TRUE(filter_->Filter(ts, &point));
- results.push_back(point);
- ts += delta;
- }
-
- filter_->Reset();
-
- EXPECT_EQ((int)points.size(), 100);
- EXPECT_EQ((int)timestamps.size(), 100);
- EXPECT_EQ((int)results.size(), 100);
-
- for (int i = 0; i < 100; i++) {
- point = points[i];
- EXPECT_TRUE(filter_->Filter(timestamps[i], &point));
- EXPECT_NEAR(results[i].x(), point.x(), kEpsilon);
- EXPECT_NEAR(results[i].y(), point.y(), kEpsilon);
- }
-}
-
-} // namespace test
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/input_filter_unittest_helpers.h b/chromium/ui/events/blink/prediction/input_filter_unittest_helpers.h
deleted file mode 100644
index fef5b10133d..00000000000
--- a/chromium/ui/events/blink/prediction/input_filter_unittest_helpers.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2019 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 UI_EVENTS_BLINK_PREDICTION_INPUT_FILTER_UNITTEST_HELPERS_H_
-#define UI_EVENTS_BLINK_PREDICTION_INPUT_FILTER_UNITTEST_HELPERS_H_
-
-#include "ui/events/blink/prediction/input_filter.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/events/blink/blink_event_util.h"
-
-namespace ui {
-namespace test {
-
-constexpr double kEpsilon = 0.0001;
-
-// Base class for predictor unit tests
-class InputFilterTest : public testing::Test {
- public:
- InputFilterTest();
- ~InputFilterTest() override;
-
- void TestCloneFilter();
-
- void TestResetFilter();
-
- protected:
- std::unique_ptr<InputFilter> filter_;
-
- DISALLOW_COPY_AND_ASSIGN(InputFilterTest);
-};
-
-} // namespace test
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_PREDICTION_INPUT_FILTER_UNITTEST_HELPERS_H_
diff --git a/chromium/ui/events/blink/prediction/input_predictor.h b/chromium/ui/events/blink/prediction/input_predictor.h
deleted file mode 100644
index 255b8536d8e..00000000000
--- a/chromium/ui/events/blink/prediction/input_predictor.h
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2018 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 UI_EVENTS_BLINK_PREDICTION_INPUT_PREDICTOR_H_
-#define UI_EVENTS_BLINK_PREDICTION_INPUT_PREDICTOR_H_
-
-#include <memory>
-
-#include "base/macros.h"
-#include "ui/events/base_event_utils.h"
-#include "ui/gfx/geometry/point_f.h"
-
-namespace ui {
-
-// This class expects a sequence of inputs with their coordinates and timestamps
-// and models the input path. It then can predict the coordinates at any given
-// time.
-class InputPredictor {
- public:
- virtual ~InputPredictor() = default;
-
- struct InputData {
- gfx::PointF pos;
- base::TimeTicks time_stamp;
- InputData() {
- pos = gfx::PointF();
- time_stamp = base::TimeTicks();
- }
- InputData(const gfx::PointF& event_pos, const base::TimeTicks& event_time) {
- pos = event_pos;
- time_stamp = event_time;
- }
- };
-
- // Returns the name of the predictor.
- virtual const char* GetName() const = 0;
-
- // Reset should be called each time when a new line start.
- virtual void Reset() = 0;
-
- // Update the predictor with new input points.
- virtual void Update(const InputData& new_input) = 0;
-
- // Return true if the predictor is able to predict points.
- virtual bool HasPrediction() const = 0;
-
- // Generate the prediction based on current points.
- virtual std::unique_ptr<InputData> GeneratePrediction(
- base::TimeTicks predict_time) const = 0;
-
- // Returns the maximum of prediction available for resampling
- // before having side effects (jitter, wrong orientation, etc..)
- const base::TimeDelta MaxResampleTime() const { return kMaxResampleTime; }
-
- // Returns the maximum prediction time available for the predictor
- // before having side effects (jitter, wrong orientation, etc..)
- const base::TimeDelta MaxPredictionTime() const { return kMaxPredictionTime; }
-
- // Return the time interval based on current points.
- virtual base::TimeDelta TimeInterval() const = 0;
-
- protected:
- static constexpr base::TimeDelta kMaxTimeDelta =
- base::TimeDelta::FromMilliseconds(20);
-
- // Default time interval between events.
- static constexpr base::TimeDelta kTimeInterval =
- base::TimeDelta::FromMilliseconds(8);
- // Minimum time interval between events.
- static constexpr base::TimeDelta kMinTimeInterval =
- base::TimeDelta::FromMillisecondsD(2.5);
-
- // Maximum amount of prediction when resampling.
- static constexpr base::TimeDelta kMaxResampleTime =
- base::TimeDelta::FromMilliseconds(20);
- // Maximum time delta for prediction.
- static constexpr base::TimeDelta kMaxPredictionTime =
- base::TimeDelta::FromMilliseconds(25);
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_PREDICTION_INPUT_PREDICTOR_H_
diff --git a/chromium/ui/events/blink/prediction/input_predictor_unittest_helpers.cc b/chromium/ui/events/blink/prediction/input_predictor_unittest_helpers.cc
deleted file mode 100644
index 0c9079f74b5..00000000000
--- a/chromium/ui/events/blink/prediction/input_predictor_unittest_helpers.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-// Copyright 2018 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 "ui/events/blink/prediction/input_predictor_unittest_helpers.h"
-
-namespace ui {
-
-InputPredictorTest::InputPredictorTest() = default;
-InputPredictorTest::~InputPredictorTest() = default;
-
-void InputPredictorTest::ValidatePredictor(
- const std::vector<double>& x,
- const std::vector<double>& y,
- const std::vector<double>& timestamp_ms) {
- predictor_->Reset();
- for (size_t i = 0; i < timestamp_ms.size(); i++) {
- if (predictor_->HasPrediction()) {
- auto result =
- predictor_->GeneratePrediction(FromMilliseconds(timestamp_ms[i]));
- EXPECT_TRUE(result);
- EXPECT_NEAR(result->pos.x(), x[i], kEpsilon);
- EXPECT_NEAR(result->pos.y(), y[i], kEpsilon);
- }
- InputPredictor::InputData data = {gfx::PointF(x[i], y[i]),
- FromMilliseconds(timestamp_ms[i])};
- predictor_->Update(data);
- }
-}
-
-void InputPredictorTest::ValidatePredictor(
- const std::vector<double>& events_x,
- const std::vector<double>& events_y,
- const std::vector<double>& events_time_ms,
- const std::vector<double>& prediction_time_ms,
- const std::vector<double>& predicted_x,
- const std::vector<double>& predicted_y) {
- predictor_->Reset();
- std::vector<double> computed_x;
- std::vector<double> computed_y;
- size_t current_prediction_index = 0;
- for (size_t i = 0; i < events_time_ms.size(); i++) {
- InputPredictor::InputData data = {gfx::PointF(events_x[i], events_y[i]),
- FromMilliseconds(events_time_ms[i])};
- predictor_->Update(data);
-
- if (predictor_->HasPrediction()) {
- auto result = predictor_->GeneratePrediction(
- FromMilliseconds(prediction_time_ms[current_prediction_index]));
- EXPECT_TRUE(result);
- computed_x.push_back(result->pos.x());
- computed_y.push_back(result->pos.y());
- EXPECT_GT(result->time_stamp, base::TimeTicks());
- current_prediction_index++;
- }
- }
-
- EXPECT_TRUE(computed_x.size() == predicted_x.size());
- if (computed_x.size() == predicted_x.size()) {
- for (size_t i = 0; i < predicted_x.size(); i++) {
- EXPECT_NEAR(computed_x[i], predicted_x[i], kEpsilon);
- EXPECT_NEAR(computed_y[i], predicted_y[i], kEpsilon);
- }
- }
-}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/input_predictor_unittest_helpers.h b/chromium/ui/events/blink/prediction/input_predictor_unittest_helpers.h
deleted file mode 100644
index f6b30f4c189..00000000000
--- a/chromium/ui/events/blink/prediction/input_predictor_unittest_helpers.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2018 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 UI_EVENTS_BLINK_PREDICTION_INPUT_PREDICTOR_UNITTEST_HELPERS_H_
-#define UI_EVENTS_BLINK_PREDICTION_INPUT_PREDICTOR_UNITTEST_HELPERS_H_
-
-#include "ui/events/blink/prediction/input_predictor.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/events/blink/blink_event_util.h"
-
-namespace ui {
-
-constexpr base::TimeDelta kExpectedDefaultTimeInterval =
- base::TimeDelta::FromMilliseconds(8);
-
-// Base class for predictor unit tests
-class InputPredictorTest : public testing::Test {
- public:
- InputPredictorTest();
- ~InputPredictorTest() override;
-
- static base::TimeTicks FromMilliseconds(int64_t ms) {
- return blink::WebInputEvent::GetStaticTimeStampForTests() +
- base::TimeDelta::FromMilliseconds(ms);
- }
-
- void ValidatePredictor(const std::vector<double>& x,
- const std::vector<double>& y,
- const std::vector<double>& timestamp_ms);
-
- void ValidatePredictor(const std::vector<double>& events_x,
- const std::vector<double>& events_y,
- const std::vector<double>& events_ts_ms,
- const std::vector<double>& prediction_ts_ms,
- const std::vector<double>& predicted_x,
- const std::vector<double>& predicted_y);
-
- protected:
- static constexpr double kEpsilon = 0.1;
-
- std::unique_ptr<InputPredictor> predictor_;
-
- DISALLOW_COPY_AND_ASSIGN(InputPredictorTest);
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_PREDICTION_INPUT_PREDICTOR_UNITTEST_HELPERS_H_
diff --git a/chromium/ui/events/blink/prediction/kalman_filter.cc b/chromium/ui/events/blink/prediction/kalman_filter.cc
deleted file mode 100644
index 966df972660..00000000000
--- a/chromium/ui/events/blink/prediction/kalman_filter.cc
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright 2018 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 "ui/events/blink/prediction/kalman_filter.h"
-
-namespace {
-constexpr uint32_t kStableIterNum = 4;
-
-constexpr double kSigmaProcess = 0.01;
-constexpr double kSigmaMeasurement = 1.0;
-
-gfx::Matrix3F GetStateTransition(double kDt) {
- gfx::Matrix3F state_transition = gfx::Matrix3F::Zeros();
- // State translation matrix is basic physics.
- // new_pos = pre_pos + v * dt + 1/2 * a * dt^2.
- // new_v = v + a * dt.
- // new_a = a .
- state_transition.set(1.0, kDt, 0.5 * kDt * kDt, 0.0, 1.0, kDt, 0.0, 0.0, 1.0);
- return state_transition;
-}
-
-gfx::Matrix3F GetProcessNoise(double kDt) {
- gfx::Vector3dF process_noise(0.5 * kDt * kDt, kDt, 1.0);
- // We model the system noise as noisy force on the pointer.
- // The following matrix describes the impact of that noise on each state.
- gfx::Matrix3F process_noise_covariance = gfx::Matrix3F::FromOuterProduct(
- process_noise, gfx::ScaleVector3d(process_noise, kSigmaProcess));
- return process_noise_covariance;
-}
-
-} // namespace
-
-namespace ui {
-
-KalmanFilter::KalmanFilter()
- : state_estimation_(gfx::Vector3dF()),
- error_covariance_matrix_(gfx::Matrix3F::Identity()),
- state_transition_matrix_(GetStateTransition(1.0)),
- process_noise_covariance_matrix_(GetProcessNoise(1.0)),
- measurement_vector_(gfx::Vector3dF(1.0, 0.0, 0.0)),
- measurement_noise_variance_(kSigmaMeasurement),
- iteration_count_(0) {}
-
-KalmanFilter::~KalmanFilter() = default;
-
-const gfx::Vector3dF& KalmanFilter::GetStateEstimation() const {
- return state_estimation_;
-}
-
-bool KalmanFilter::Stable() const {
- return iteration_count_ >= kStableIterNum;
-}
-
-void KalmanFilter::Update(double observation, double dt) {
- if (iteration_count_++ == 0) {
- // We only update the state estimation in the first iteration.
- state_estimation_ = gfx::Vector3dF(observation, 0, 0);
- return;
- }
- Predict(dt);
- // Y = z - H * X
- double y =
- observation - gfx::DotProduct(measurement_vector_, state_estimation_);
- // S = H * P * H' + R
- double S = gfx::DotProduct(measurement_vector_,
- gfx::MatrixProduct(error_covariance_matrix_,
- measurement_vector_)) +
- measurement_noise_variance_;
- // K = P * H' * inv(S)
- gfx::Vector3dF kalman_gain = gfx::ScaleVector3d(
- gfx::MatrixProduct(error_covariance_matrix_, measurement_vector_),
- 1.0 / S);
- // X = X + K * Y
- state_estimation_ += gfx::ScaleVector3d(kalman_gain, y);
- // I_HK = eye(P) - K * H
- gfx::Matrix3F I_KH =
- gfx::Matrix3F::Identity() -
- gfx::Matrix3F::FromOuterProduct(kalman_gain, measurement_vector_);
-
- // P = I_KH * P * I_KH' + K * R * K'
- error_covariance_matrix_ =
- gfx::MatrixProduct(gfx::MatrixProduct(I_KH, error_covariance_matrix_),
- I_KH.Transpose()) +
- gfx::Matrix3F::FromOuterProduct(
- gfx::ScaleVector3d(kalman_gain, measurement_noise_variance_),
- kalman_gain);
-}
-
-void KalmanFilter::Reset() {
- state_estimation_ = gfx::Vector3dF();
- error_covariance_matrix_ = gfx::Matrix3F::Identity();
- iteration_count_ = 0;
-}
-
-double KalmanFilter::GetPosition() const {
- return GetStateEstimation().x();
-}
-
-double KalmanFilter::GetVelocity() const {
- return GetStateEstimation().y();
-}
-
-double KalmanFilter::GetAcceleration() const {
- return GetStateEstimation().z();
-}
-
-void KalmanFilter::Predict(double dt) {
- DCHECK_GT(iteration_count_, 0u);
- state_transition_matrix_ = GetStateTransition(dt);
- // X = F * X
- state_estimation_ =
- gfx::MatrixProduct(state_transition_matrix_, state_estimation_);
- // P = F * P * F' + Q
- error_covariance_matrix_ =
- gfx::MatrixProduct(gfx::MatrixProduct(state_transition_matrix_,
- error_covariance_matrix_),
- state_transition_matrix_.Transpose()) +
- GetProcessNoise(dt);
-}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/kalman_filter.h b/chromium/ui/events/blink/prediction/kalman_filter.h
deleted file mode 100644
index 50ce719cd83..00000000000
--- a/chromium/ui/events/blink/prediction/kalman_filter.h
+++ /dev/null
@@ -1,84 +0,0 @@
-// Copyright 2018 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 UI_EVENTS_BLINK_PREDICTION_KALMAN_FILTER_H_
-#define UI_EVENTS_BLINK_PREDICTION_KALMAN_FILTER_H_
-
-#include "ui/gfx/geometry/matrix3_f.h"
-
-namespace ui {
-
-// This Kalman filter is used to predict state in one axles.
-class KalmanFilter {
- public:
- KalmanFilter();
- ~KalmanFilter();
-
- // Get the estimation of current state.
- const gfx::Vector3dF& GetStateEstimation() const;
-
- // Will return true only if the kalman filter has seen enough data and is
- // considered as stable.
- bool Stable() const;
-
- // Update the observation of the system.
- void Update(double observation, double dt);
-
- void Reset();
-
- // Get the predicted values from the kalman filter.
- double GetPosition() const;
- double GetVelocity() const;
- double GetAcceleration() const;
-
- private:
- void Predict(double dt);
-
- // Estimate of the latent state
- // Symbol: X
- // Dimension: state_vector_dim_
- gfx::Vector3dF state_estimation_;
-
- // The covariance of the difference between prior predicted latent
- // state and posterior estimated latent state (the so-called "innovation".
- // Symbol: P
- // Dimension: state_vector_dim_, state_vector_dim_
- gfx::Matrix3F error_covariance_matrix_;
-
- // For position, state transition matrix is derived from basic physics:
- // new_x = x + v * dt + 1/2 * a * dt^2
- // new_v = v + a * dt
- // ...
- // Matrix that transforms current state to next state
- // Symbol: F
- // Dimension: state_vector_dim_, state_vector_dim_
- gfx::Matrix3F state_transition_matrix_;
-
- // A time-varying noise parameter that will be estimated as part of the
- // kalman filter process.
- // Symbol: Q
- // Dimension: state_vector_dim_, state_vector_dim_
- gfx::Matrix3F process_noise_covariance_matrix_;
-
- // Vector to transform estimate to measurement.
- // Symbol: H
- // Dimension: state_vector_dim_
- const gfx::Vector3dF measurement_vector_;
-
- // A time-varying noise parameter that will be estimated as part of the
- // kalman filter process.
- // Symbol: R
- double measurement_noise_variance_;
-
- // Tracks number of update iteration happened at this kalman filter. At the
- // 1st iteration, the state estimate will be updated to the measured value.
- // After a few iterations, the KalmanFilter is considered stable.
- uint32_t iteration_count_;
-
- DISALLOW_COPY_AND_ASSIGN(KalmanFilter);
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_PREDICTION_KALMAN_FILTER_H_
diff --git a/chromium/ui/events/blink/prediction/kalman_predictor.cc b/chromium/ui/events/blink/prediction/kalman_predictor.cc
deleted file mode 100644
index cfd978e35b5..00000000000
--- a/chromium/ui/events/blink/prediction/kalman_predictor.cc
+++ /dev/null
@@ -1,139 +0,0 @@
-// Copyright 2018 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 "ui/events/blink/prediction/kalman_predictor.h"
-
-#include <algorithm>
-#include <cmath>
-
-#include "base/numerics/math_constants.h"
-#include "ui/events/blink/prediction/predictor_factory.h"
-
-namespace {
-
-// Influence of acceleration during each prediction sample
-constexpr float kAccelerationInfluence = 0.5f;
-// Influence of velocity during each prediction sample
-constexpr float kVelocityInfluence = 1.0f;
-
-} // namespace
-
-namespace ui {
-
-constexpr base::TimeDelta InputPredictor::kMaxTimeDelta;
-constexpr base::TimeDelta InputPredictor::kMaxResampleTime;
-constexpr base::TimeDelta InputPredictor::kMaxPredictionTime;
-constexpr base::TimeDelta InputPredictor::kTimeInterval;
-constexpr base::TimeDelta InputPredictor::kMinTimeInterval;
-constexpr base::TimeDelta KalmanPredictor::kMaxTimeInQueue;
-
-KalmanPredictor::KalmanPredictor(unsigned int prediction_options)
- : prediction_options_(prediction_options) {}
-
-KalmanPredictor::~KalmanPredictor() = default;
-
-const char* KalmanPredictor::GetName() const {
- return input_prediction::kScrollPredictorNameKalman;
-}
-
-void KalmanPredictor::Reset() {
- x_predictor_.Reset();
- y_predictor_.Reset();
- last_points_.clear();
- time_filter_.Reset();
-}
-
-void KalmanPredictor::Update(const InputData& cur_input) {
- base::TimeDelta dt;
- if (last_points_.size()) {
- // When last point is kMaxTimeDelta away, consider it is incontinuous.
- dt = cur_input.time_stamp - last_points_.back().time_stamp;
- if (dt > kMaxTimeDelta)
- Reset();
- else
- time_filter_.Update(dt.InMillisecondsF(), 0);
- }
-
- double dt_ms = time_filter_.GetPosition();
- last_points_.push_back(cur_input);
- x_predictor_.Update(cur_input.pos.x(), dt_ms);
- y_predictor_.Update(cur_input.pos.y(), dt_ms);
-
- while (last_points_.back().time_stamp - last_points_.front().time_stamp >
- kMaxTimeInQueue) {
- last_points_.pop_front();
- }
-}
-
-bool KalmanPredictor::HasPrediction() const {
- return x_predictor_.Stable() && y_predictor_.Stable();
-}
-
-std::unique_ptr<InputPredictor::InputData> KalmanPredictor::GeneratePrediction(
- base::TimeTicks predict_time) const {
- if (!HasPrediction())
- return nullptr;
-
- DCHECK(last_points_.size());
- float pred_dt =
- (predict_time - last_points_.back().time_stamp).InMillisecondsF();
-
- gfx::PointF position(last_points_.back().pos.x(),
- last_points_.back().pos.y());
- gfx::Vector2dF velocity = PredictVelocity();
- gfx::Vector2dF acceleration = PredictAcceleration();
-
- if (prediction_options_ & kDirectionCutOffEnabled) {
- gfx::Vector2dF future_velocity =
- velocity + ScaleVector2d(acceleration, pred_dt);
- if (gfx::DotProduct(velocity, future_velocity) <= 0)
- return nullptr;
- }
-
- position += ScaleVector2d(velocity, kVelocityInfluence * pred_dt);
-
- if (prediction_options_ & kHeuristicsEnabled) {
- float points_angle = 0.0f;
- for (size_t i = 2; i < last_points_.size(); i++) {
- gfx::Vector2dF first_dir =
- last_points_[i - 1].pos - last_points_[i - 2].pos;
- gfx::Vector2dF second_dir = last_points_[i].pos - last_points_[i - 1].pos;
- if (first_dir.Length() && second_dir.Length()) {
- points_angle += atan2(first_dir.x(), first_dir.y()) -
- atan2(second_dir.x(), second_dir.y());
- }
- }
- if (fabsf(points_angle) * 180 / base::kPiDouble > 15) {
- position += ScaleVector2d(acceleration,
- kAccelerationInfluence * pred_dt * pred_dt);
- }
- } else {
- position +=
- ScaleVector2d(acceleration, kAccelerationInfluence * pred_dt * pred_dt);
- }
-
- return std::make_unique<InputData>(position, predict_time);
-}
-
-base::TimeDelta KalmanPredictor::TimeInterval() const {
- return time_filter_.GetPosition()
- ? std::max(kMinTimeInterval, base::TimeDelta::FromMilliseconds(
- time_filter_.GetPosition()))
- : kTimeInterval;
-}
-
-gfx::Vector2dF KalmanPredictor::PredictPosition() const {
- return gfx::Vector2dF(x_predictor_.GetPosition(), y_predictor_.GetPosition());
-}
-
-gfx::Vector2dF KalmanPredictor::PredictVelocity() const {
- return gfx::Vector2dF(x_predictor_.GetVelocity(), y_predictor_.GetVelocity());
-}
-
-gfx::Vector2dF KalmanPredictor::PredictAcceleration() const {
- return gfx::Vector2dF(x_predictor_.GetAcceleration(),
- y_predictor_.GetAcceleration());
-}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/kalman_predictor.h b/chromium/ui/events/blink/prediction/kalman_predictor.h
deleted file mode 100644
index 68919e68070..00000000000
--- a/chromium/ui/events/blink/prediction/kalman_predictor.h
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2018 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 UI_EVENTS_BLINK_PREDICTION_KALMAN_PREDICTOR_H_
-#define UI_EVENTS_BLINK_PREDICTION_KALMAN_PREDICTOR_H_
-
-#include <deque>
-#include <vector>
-
-#include "ui/events/blink/prediction/input_predictor.h"
-#include "ui/events/blink/prediction/kalman_filter.h"
-
-namespace ui {
-
-// Class to perform kalman filter prediction inherited from InputPredictor.
-// This predictor uses kalman filters to predict the current status of the
-// motion. Then it predict the future points using <current_position,
-// predicted_velocity, predicted_acceleration>. Each kalman_filter will only
-// be used to predict one dimension (x, y).
-class KalmanPredictor : public InputPredictor {
- public:
- // Heuristic option enables changing the influence of acceleration based on
- // change of direction. Direction cut off enables discarding the prediction if
- // the predicted direction is opposite from the current direction.
- enum PredictionOptions {
- kNone = 0x0,
- kHeuristicsEnabled = 0x1,
- kDirectionCutOffEnabled = 0x2
- };
-
- explicit KalmanPredictor(unsigned int prediction_options);
- ~KalmanPredictor() override;
-
- const char* GetName() const override;
-
- // Reset the predictor to initial state.
- void Reset() override;
-
- // Store current input in queue.
- void Update(const InputData& cur_input) override;
-
- // Return if there is enough data in the queue to generate prediction.
- bool HasPrediction() const override;
-
- // Generate the prediction based on stored points and given time_stamp.
- // Return false if no prediction available.
- std::unique_ptr<InputData> GeneratePrediction(
- base::TimeTicks predict_time) const override;
-
- // Return the filtered value of time intervals.
- base::TimeDelta TimeInterval() const override;
-
- private:
- // The following functions get the predicted values from kalman filters.
- gfx::Vector2dF PredictPosition() const;
- gfx::Vector2dF PredictVelocity() const;
- gfx::Vector2dF PredictAcceleration() const;
-
- // Predictor for each axis.
- KalmanFilter x_predictor_;
- KalmanFilter y_predictor_;
-
- // Filter to smooth time intervals.
- KalmanFilter time_filter_;
-
- // Most recent input data.
- std::deque<InputData> last_points_;
-
- // Maximum time interval between first and last events in last points queue.
- static constexpr base::TimeDelta kMaxTimeInQueue =
- base::TimeDelta::FromMilliseconds(40);
-
- // Flags to determine the enabled prediction options.
- const unsigned int prediction_options_;
-
- DISALLOW_COPY_AND_ASSIGN(KalmanPredictor);
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_PREDICTION_KALMAN_PREDICTOR_H_
diff --git a/chromium/ui/events/blink/prediction/kalman_predictor_unittest.cc b/chromium/ui/events/blink/prediction/kalman_predictor_unittest.cc
deleted file mode 100644
index 8e96eb4d608..00000000000
--- a/chromium/ui/events/blink/prediction/kalman_predictor_unittest.cc
+++ /dev/null
@@ -1,204 +0,0 @@
-// Copyright 2018 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 <vector>
-
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/events/blink/prediction/input_predictor_unittest_helpers.h"
-#include "ui/events/blink/prediction/kalman_predictor.h"
-
-namespace ui {
-namespace test {
-namespace {
-
-constexpr uint32_t kExpectedStableIterNum = 4;
-
-struct DataSet {
- double initial_observation;
- std::vector<double> observation;
- std::vector<double> position;
- std::vector<double> velocity;
- std::vector<double> acceleration;
-};
-
-void ValidateSingleKalmanFilter(const DataSet& data) {
- std::unique_ptr<KalmanFilter> kalman_filter =
- std::make_unique<KalmanFilter>();
- constexpr double kEpsilon = 0.001;
- constexpr double kDtMillisecond = 8;
- kalman_filter->Update(data.initial_observation, kDtMillisecond);
- for (size_t i = 0; i < data.observation.size(); i++) {
- kalman_filter->Update(data.observation[i], kDtMillisecond);
- EXPECT_NEAR(data.position[i], kalman_filter->GetPosition(), kEpsilon);
- EXPECT_NEAR(data.velocity[i], kalman_filter->GetVelocity(), kEpsilon);
- EXPECT_NEAR(data.acceleration[i], kalman_filter->GetAcceleration(),
- kEpsilon);
- }
-}
-
-} // namespace
-
-class KalmanPredictorTest : public InputPredictorTest {
- public:
- explicit KalmanPredictorTest() {}
-
- void SetUp() override {
- predictor_ = std::make_unique<ui::KalmanPredictor>(
- ui::KalmanPredictor::PredictionOptions::kNone);
- }
-
- DISALLOW_COPY_AND_ASSIGN(KalmanPredictorTest);
-};
-
-// Test the a single axle kalman filter behavior with preset datas.
-TEST_F(KalmanPredictorTest, KalmanFilterPredictedValue) {
- DataSet data;
- data.initial_observation = 0;
- data.observation = {1, 2, 3, 4, 5, 6};
- data.position = {0.999, 2.007, 3.001, 3.999, 5.000, 6.000};
- data.velocity = {0.242, 0.130, 0.122, 0.124, 0.125, 0.125};
- data.acceleration = {0.029, 0.000, 0.000, 0.000, 0.000, 0.000};
- ValidateSingleKalmanFilter(data);
-
- data.initial_observation = 0;
- data.observation = {1, 2, 4, 8, 16, 32};
- data.position = {0.999, 2.007, 3.976, 7.970, 15.950, 31.896};
- data.velocity = {0.242, 0.130, 0.298, 0.623, 1.240, 2.475};
- data.acceleration = {0.029, 0.000, 0.015, 0.034, 0.065, 0.130};
- ValidateSingleKalmanFilter(data);
-}
-
-TEST_F(KalmanPredictorTest, ShouldHasPrediction) {
- for (uint32_t i = 0; i < kExpectedStableIterNum; i++) {
- EXPECT_FALSE(predictor_->HasPrediction());
- InputPredictor::InputData data = {gfx::PointF(1, 1),
- FromMilliseconds(8 * i)};
- predictor_->Update(data);
- }
- EXPECT_TRUE(predictor_->HasPrediction());
-
- predictor_->Reset();
- EXPECT_FALSE(predictor_->HasPrediction());
-}
-
-// Tests the kalman predictor constant position.
-TEST_F(KalmanPredictorTest, PredictConstantValue) {
- std::vector<double> x = {50, 50, 50, 50, 50, 50};
- std::vector<double> y = {-50, -50, -50, -50, -50, -50};
- std::vector<double> t = {8, 16, 24, 32, 40, 48};
- ValidatePredictor(x, y, t);
-}
-
-// Tests the kalman predictor predict constant velocity.
-TEST_F(KalmanPredictorTest, PredictLinearValue) {
- // The kalman filter is initialized with a velocity of zero. The change of
- // velocity from zero to the constant value will be attributed to
- // acceleration. Given how the filter works, it will take a few updates for it
- // to get accustomed to a constant velocity.
- std::vector<double> x_stabilizer = {-40, -32, -24, -16, -8};
- std::vector<double> y_stabilizer = {-10, -2, 6, 14, 22};
- std::vector<double> t_stabilizer = {-40, -32, -24, -16, -8};
- for (size_t i = 0; i < t_stabilizer.size(); i++) {
- InputPredictor::InputData data = {
- gfx::PointF(x_stabilizer[i], y_stabilizer[i]),
- FromMilliseconds(t_stabilizer[i])};
- predictor_->Update(data);
- }
-
- std::vector<double> x = {0, 8, 16, 24, 32, 40, 48, 60};
- std::vector<double> y = {30, 38, 46, 54, 62, 70, 78, 90};
- std::vector<double> t = {0, 8, 16, 24, 32, 40, 48, 60};
- for (size_t i = 0; i < t.size(); i++) {
- if (predictor_->HasPrediction()) {
- auto result = predictor_->GeneratePrediction(FromMilliseconds(t[i]));
- EXPECT_TRUE(result);
- EXPECT_NEAR(result->pos.x(), x[i], kEpsilon);
- EXPECT_NEAR(result->pos.y(), y[i], kEpsilon);
- }
- InputPredictor::InputData data = {gfx::PointF(x[i], y[i]),
- FromMilliseconds(t[i])};
- predictor_->Update(data);
- }
-}
-
-// Tests the kalman predictor predict constant acceleration.
-TEST_F(KalmanPredictorTest, PredictQuadraticValue) {
- std::vector<double> x = {0, 2, 8, 18, 32, 50, 72, 98};
- std::vector<double> y = {10, 11, 14, 19, 26, 35, 46, 59};
- std::vector<double> t = {8, 16, 24, 32, 40, 48, 56, 64};
- ValidatePredictor(x, y, t);
-}
-
-// Tests the kalman predictor time interval filter.
-TEST_F(KalmanPredictorTest, TimeInterval) {
- EXPECT_EQ(predictor_->TimeInterval(), kExpectedDefaultTimeInterval);
- std::vector<double> x = {0, 2, 8, 18};
- std::vector<double> y = {10, 11, 14, 19};
- std::vector<double> t = {7, 14, 21, 28};
- for (size_t i = 0; i < t.size(); i++) {
- InputPredictor::InputData data = {gfx::PointF(x[i], y[i]),
- FromMilliseconds(t[i])};
- predictor_->Update(data);
- }
- EXPECT_EQ(predictor_->TimeInterval().InMillisecondsF(),
- base::TimeDelta::FromMilliseconds(7).InMillisecondsF());
-}
-
-// Test the benefit from the heuristic approach on noisy data.
-TEST_F(KalmanPredictorTest, HeuristicApproach) {
- std::unique_ptr<InputPredictor> heuristic_predictor =
- std::make_unique<ui::KalmanPredictor>(
- ui::KalmanPredictor::PredictionOptions::kHeuristicsEnabled);
- std::vector<double> x_stabilizer = {-40, -32, -24, -16, -8, 0};
- std::vector<double> y_stabilizer = {-40, -32, -24, -16, -8, 0};
- std::vector<double> t_stabilizer = {-40, -32, -24, -16, -8, 0};
- for (size_t i = 0; i < t_stabilizer.size(); i++) {
- InputPredictor::InputData data = {
- gfx::PointF(x_stabilizer[i], y_stabilizer[i]),
- FromMilliseconds(t_stabilizer[i])};
- predictor_->Update(data);
- heuristic_predictor->Update(data);
- }
-
- std::vector<double> x = {7, 17, 23, 33, 39, 49, 60};
- std::vector<double> y = {9, 15, 25, 31, 41, 47, 60};
- std::vector<double> t = {8, 16, 24, 32, 40, 48, 60};
- for (size_t i = 0; i < t.size(); i++) {
- gfx::PointF point(x[i], y[i]);
- if (heuristic_predictor->HasPrediction() && predictor_->HasPrediction()) {
- auto heuristic_result =
- heuristic_predictor->GeneratePrediction(FromMilliseconds(t[i]));
- auto result = predictor_->GeneratePrediction(FromMilliseconds(t[i]));
- EXPECT_TRUE(heuristic_result);
- EXPECT_TRUE(result);
- EXPECT_LE((heuristic_result->pos - point).Length(),
- (result->pos - point).Length());
- }
- InputPredictor::InputData data = {point, FromMilliseconds(t[i])};
- heuristic_predictor->Update(data);
- predictor_->Update(data);
- }
-}
-
-// Test the kalman predictor prevention of rubber-banding.
-TEST_F(KalmanPredictorTest, DirectionalCutOff) {
- predictor_ = std::make_unique<ui::KalmanPredictor>(
- ui::KalmanPredictor::PredictionOptions::kDirectionCutOffEnabled);
- std::vector<double> x = {98, 72, 50, 32, 18, 8, 2};
- std::vector<double> y = {49, 36, 25, 16, 9, 4, 1};
- std::vector<double> t = {8, 16, 24, 32, 40, 48, 56};
- for (size_t i = 0; i < t.size(); i++) {
- InputPredictor::InputData data = {gfx::PointF(x[i], y[i]),
- FromMilliseconds(t[i])};
- predictor_->Update(data);
- }
- // On t=64, position is (0,0), and in t=72 it is (2,1) again which means that
- // direction has shifted in the opposite direction and prediction should be
- // cut off.
- auto result = predictor_->GeneratePrediction(FromMilliseconds(72));
- EXPECT_FALSE(result);
-}
-
-} // namespace test
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/least_squares_predictor.cc b/chromium/ui/events/blink/prediction/least_squares_predictor.cc
deleted file mode 100644
index 8a95e17d083..00000000000
--- a/chromium/ui/events/blink/prediction/least_squares_predictor.cc
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright 2018 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 "ui/events/blink/prediction/least_squares_predictor.h"
-#include "ui/events/blink/prediction/predictor_factory.h"
-
-#include <algorithm>
-
-namespace ui {
-
-namespace {
-
-// Solve XB = y.
-static bool SolveLeastSquares(const gfx::Matrix3F& x,
- const std::deque<double>& y,
- gfx::Vector3dF& result) {
- constexpr double kEpsilon = std::numeric_limits<double>::epsilon();
-
- // return last point if y didn't change.
- if (std::abs(y[0] - y[1]) < kEpsilon && std::abs(y[1] - y[2]) < kEpsilon) {
- result = gfx::Vector3dF(y[2], 0, 0);
- return true;
- }
-
- gfx::Matrix3F x_transpose = x.Transpose();
- gfx::Matrix3F temp = gfx::MatrixProduct(x_transpose, x).Inverse();
-
- // Return false if x is singular.
- if (temp == gfx::Matrix3F::Zeros())
- return false;
-
- result = gfx::MatrixProduct(gfx::MatrixProduct(temp, x_transpose),
- gfx::Vector3dF(y[0], y[1], y[2]));
- return true;
-}
-
-} // namespace
-
-LeastSquaresPredictor::LeastSquaresPredictor() {}
-
-LeastSquaresPredictor::~LeastSquaresPredictor() {}
-
-const char* LeastSquaresPredictor::GetName() const {
- return input_prediction::kScrollPredictorNameLsq;
-}
-
-void LeastSquaresPredictor::Reset() {
- x_queue_.clear();
- y_queue_.clear();
- time_.clear();
-}
-
-void LeastSquaresPredictor::Update(const InputData& cur_input) {
- if (!time_.empty()) {
- // When last point is kMaxTimeDelta away, consider it is incontinuous.
- if (cur_input.time_stamp - time_.back() > kMaxTimeDelta)
- Reset();
- }
-
- x_queue_.push_back(cur_input.pos.x());
- y_queue_.push_back(cur_input.pos.y());
- time_.push_back(cur_input.time_stamp);
- if (time_.size() > kSize) {
- x_queue_.pop_front();
- y_queue_.pop_front();
- time_.pop_front();
- }
-}
-
-bool LeastSquaresPredictor::HasPrediction() const {
- return time_.size() >= kSize;
-}
-
-gfx::Matrix3F LeastSquaresPredictor::GetXMatrix() const {
- gfx::Matrix3F x = gfx::Matrix3F::Zeros();
- double t1 = (time_[1] - time_[0]).InMillisecondsF();
- double t2 = (time_[2] - time_[0]).InMillisecondsF();
- x.set(1, 0, 0, 1, t1, t1 * t1, 1, t2, t2 * t2);
- return x;
-}
-
-std::unique_ptr<InputPredictor::InputData>
-LeastSquaresPredictor::GeneratePrediction(base::TimeTicks predict_time) const {
- if (!HasPrediction())
- return nullptr;
-
- float pred_dt = (predict_time - time_[0]).InMillisecondsF();
-
- gfx::Vector3dF b1, b2;
- gfx::Matrix3F time_matrix = GetXMatrix();
- if (SolveLeastSquares(time_matrix, x_queue_, b1) &&
- SolveLeastSquares(time_matrix, y_queue_, b2)) {
- gfx::Vector3dF prediction_time(1, pred_dt, pred_dt * pred_dt);
-
- return std::make_unique<InputData>(
- gfx::PointF(gfx::DotProduct(prediction_time, b1),
- gfx::DotProduct(prediction_time, b2)),
- predict_time);
- }
- return nullptr;
-}
-
-base::TimeDelta LeastSquaresPredictor::TimeInterval() const {
- if (time_.size() > 1) {
- return std::max(kMinTimeInterval,
- (time_.back() - time_.front()) / (time_.size() - 1));
- }
- return kTimeInterval;
-}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/least_squares_predictor.h b/chromium/ui/events/blink/prediction/least_squares_predictor.h
deleted file mode 100644
index a44f4f17ba5..00000000000
--- a/chromium/ui/events/blink/prediction/least_squares_predictor.h
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright 2018 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 UI_EVENTS_BLINK_PREDICTION_LEAST_SQUARES_PREDICTOR_H_
-#define UI_EVENTS_BLINK_PREDICTION_LEAST_SQUARES_PREDICTOR_H_
-
-#include <deque>
-
-#include "ui/events/blink/prediction/input_predictor.h"
-#include "ui/gfx/geometry/matrix3_f.h"
-
-namespace ui {
-
-// This class use a quadratic least square regression model:
-// y = b0 + b1 * x + b2 * x ^ 2.
-// See https://en.wikipedia.org/wiki/Linear_least_squares_(mathematics)
-class LeastSquaresPredictor : public InputPredictor {
- public:
- static constexpr size_t kSize = 3;
-
- explicit LeastSquaresPredictor();
- ~LeastSquaresPredictor() override;
-
- const char* GetName() const override;
-
- // Reset the predictor to initial state.
- void Reset() override;
-
- // Store current input in queue.
- void Update(const InputData& cur_input) override;
-
- // Return if there is enough data in the queue to generate prediction.
- bool HasPrediction() const override;
-
- // Generate the prediction based on stored points and given time_stamp.
- // Return false if no prediction available.
- std::unique_ptr<InputData> GeneratePrediction(
- base::TimeTicks predict_time) const override;
-
- // Return the averaged value of time intervals.
- base::TimeDelta TimeInterval() const override;
-
- private:
- // Generate X matrix from time_ queue.
- gfx::Matrix3F GetXMatrix() const;
-
- std::deque<double> x_queue_;
- std::deque<double> y_queue_;
- std::deque<base::TimeTicks> time_;
-
- DISALLOW_COPY_AND_ASSIGN(LeastSquaresPredictor);
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_PREDICTION_LEAST_SQUARES_PREDICTOR_H_
diff --git a/chromium/ui/events/blink/prediction/least_squares_predictor_unittest.cc b/chromium/ui/events/blink/prediction/least_squares_predictor_unittest.cc
deleted file mode 100644
index c33380a4a6c..00000000000
--- a/chromium/ui/events/blink/prediction/least_squares_predictor_unittest.cc
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2018 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 "ui/events/blink/prediction/least_squares_predictor.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/events/blink/prediction/input_predictor_unittest_helpers.h"
-
-namespace ui {
-namespace test {
-
-class LSQPredictorTest : public InputPredictorTest {
- public:
- explicit LSQPredictorTest() {}
-
- void SetUp() override {
- predictor_ = std::make_unique<ui::LeastSquaresPredictor>();
- }
-
- DISALLOW_COPY_AND_ASSIGN(LSQPredictorTest);
-};
-
-TEST_F(LSQPredictorTest, ShouldHasPrediction) {
- LeastSquaresPredictor predictor;
- for (size_t i = 0; i < LeastSquaresPredictor::kSize; i++) {
- // First |kSize| point do not have prediction available.
- EXPECT_FALSE(predictor.HasPrediction());
- InputPredictor::InputData data = {gfx::PointF(1, 1),
- FromMilliseconds(8 * i)};
- predictor.Update(data);
- }
- EXPECT_TRUE(predictor.HasPrediction());
-}
-
-// Tests the lest squares filter behavior.
-// The data set is generated by a "known to work" quadratic fit.
-TEST_F(LSQPredictorTest, PredictedValue) {
- std::vector<double> x = {22, 58, 102, 108.094};
- std::vector<double> y = {100, 100, 100, 100};
- std::vector<double> t = {13, 21, 37, 42};
- ValidatePredictor(x, y, t);
-
- x = {100, 100, 101, 104.126};
- y = {120, 280, 600, 1364.93};
- t = {101, 126, 148, 180};
- ValidatePredictor(x, y, t);
-}
-
-// Tests the LSQ predictor predict constant velocity.
-TEST_F(LSQPredictorTest, PredictLinearValue) {
- std::vector<double> x = {0, 4, 10, 15, 20, 28, 30, 38};
- std::vector<double> y = {30, 34, 40, 45, 50, 58, 60, 68};
- std::vector<double> t = {0, 4, 10, 15, 20, 28, 30, 38};
- ValidatePredictor(x, y, t);
-}
-
-// Tests the LSQ predictor predict quadratic value correctly.
-TEST_F(LSQPredictorTest, PredictQuadraticValue) {
- std::vector<double> x = {2, 8, 18, 32, 50};
- std::vector<double> y = {100, 400, 900, 1600, 2500};
- std::vector<double> t = {8, 16, 24, 32, 40};
- ValidatePredictor(x, y, t);
-}
-
-// Tests that lsq predictor will not crash when given constant time stamp.
-TEST_F(LSQPredictorTest, ConstantTimeStampNotCrash) {
- std::vector<double> x = {100, 101, 102};
- std::vector<double> y = {101, 102, 103};
- std::vector<double> t = {0, 0, 0};
- for (size_t i = 0; i < t.size(); i++) {
- InputPredictor::InputData data = {gfx::PointF(x[i], y[i]),
- FromMilliseconds(t[i])};
- predictor_->Update(data);
- }
- // Expect false because the matrix is singular
- // and the predictor cannot compute a prediction
- EXPECT_FALSE(predictor_->GeneratePrediction(FromMilliseconds(42)));
-
- x = {100, 100, 100};
- y = {100, 100, 100};
- t = {100, 100, 100};
- for (size_t i = 0; i < t.size(); i++) {
- InputPredictor::InputData data = {gfx::PointF(x[i], y[i]),
- FromMilliseconds(t[i])};
- predictor_->Update(data);
- }
- EXPECT_TRUE(predictor_->GeneratePrediction(FromMilliseconds(142)));
-}
-
-// Tests the LSQ predictor produce the time interval correctly.
-TEST_F(LSQPredictorTest, TimeInterval) {
- EXPECT_EQ(predictor_->TimeInterval(), kExpectedDefaultTimeInterval);
- std::vector<double> x = {0, 4, 10};
- std::vector<double> y = {30, 34, 40};
- std::vector<double> t = {0, 4, 10};
- for (size_t i = 0; i < t.size(); i++) {
- InputPredictor::InputData data = {gfx::PointF(x[i], y[i]),
- FromMilliseconds(t[i])};
- predictor_->Update(data);
- }
- EXPECT_EQ(predictor_->TimeInterval(),
- base::TimeDelta::FromMillisecondsD((t[2] - t[0]) / 2));
-}
-
-} // namespace test
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/linear_predictor.cc b/chromium/ui/events/blink/prediction/linear_predictor.cc
deleted file mode 100644
index 190fa1b3894..00000000000
--- a/chromium/ui/events/blink/prediction/linear_predictor.cc
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright 2019 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 "ui/events/blink/prediction/linear_predictor.h"
-#include "ui/events/blink/prediction/predictor_factory.h"
-
-#include <algorithm>
-
-namespace ui {
-
-LinearPredictor::LinearPredictor(EquationOrder order) {
- equation_order_ = order;
-}
-
-LinearPredictor::~LinearPredictor() {}
-
-const char* LinearPredictor::GetName() const {
- return equation_order_ == EquationOrder::kFirstOrder
- ? input_prediction::kScrollPredictorNameLinearFirst
- : input_prediction::kScrollPredictorNameLinearSecond;
-}
-
-void LinearPredictor::Reset() {
- events_queue_.clear();
-}
-
-size_t LinearPredictor::NumberOfEventsNeeded() {
- return static_cast<size_t>(equation_order_);
-}
-
-void LinearPredictor::Update(const InputData& new_input) {
- // The last input received is at least kMaxDeltaTime away, we consider it
- // is a new trajectory
- if (!events_queue_.empty() &&
- new_input.time_stamp - events_queue_.back().time_stamp > kMaxTimeDelta) {
- Reset();
- }
-
- // Queue the new event and keep only the number of last events needed
- events_queue_.push_back(new_input);
- if (events_queue_.size() > static_cast<size_t>(equation_order_)) {
- events_queue_.pop_front();
- }
-
- // Compute the current velocity
- if (events_queue_.size() >= static_cast<size_t>(EquationOrder::kFirstOrder)) {
- // Even if cur_velocity is empty the first time, last_velocity is only
- // used when 3 events are in the queue, so it will be initialized
- last_velocity_.set_x(cur_velocity_.x());
- last_velocity_.set_y(cur_velocity_.y());
-
- // We have at least 2 events to compute the current velocity
- // Get delta time between the last 2 events
- // Note: this delta time is also used to compute the acceleration term
- events_dt_ = (events_queue_.at(events_queue_.size() - 1).time_stamp -
- events_queue_.at(events_queue_.size() - 2).time_stamp)
- .InMillisecondsF();
-
- // Get delta pos between the last 2 events
- gfx::Vector2dF delta_pos = events_queue_.at(events_queue_.size() - 1).pos -
- events_queue_.at(events_queue_.size() - 2).pos;
-
- // Get the velocity
- if (events_dt_ > 0) {
- cur_velocity_.set_x(ScaleVector2d(delta_pos, 1.0 / events_dt_).x());
- cur_velocity_.set_y(ScaleVector2d(delta_pos, 1.0 / events_dt_).y());
- } else {
- cur_velocity_.set_x(0);
- cur_velocity_.set_y(0);
- }
- }
-}
-
-bool LinearPredictor::HasPrediction() const {
- // Even if the current equation is second order, we still can predict a
- // first order
- return events_queue_.size() >=
- static_cast<size_t>(EquationOrder::kFirstOrder);
-}
-
-std::unique_ptr<InputPredictor::InputData> LinearPredictor::GeneratePrediction(
- base::TimeTicks predict_time) const {
- if (!HasPrediction())
- return nullptr;
-
- float pred_dt =
- (predict_time - events_queue_.back().time_stamp).InMillisecondsF();
-
- // Compute the prediction
- // Note : a first order prediction is computed when only 2 events are
- // available in the second order predictor
- if (equation_order_ == EquationOrder::kSecondOrder && events_dt_ > 0 &&
- events_queue_.size() ==
- static_cast<size_t>(EquationOrder::kSecondOrder)) {
- // Add the acceleration term to the current result
- return std::make_unique<InputData>(GeneratePredictionSecondOrder(pred_dt),
- predict_time);
- }
- return std::make_unique<InputData>(GeneratePredictionFirstOrder(pred_dt),
- predict_time);
-}
-
-gfx::PointF LinearPredictor::GeneratePredictionFirstOrder(float pred_dt) const {
- return events_queue_.back().pos + ScaleVector2d(cur_velocity_, pred_dt);
-}
-
-gfx::PointF LinearPredictor::GeneratePredictionSecondOrder(
- float pred_dt) const {
- DCHECK(equation_order_ == EquationOrder::kSecondOrder);
-
- gfx::Vector2dF acceleration =
- ScaleVector2d(cur_velocity_ - last_velocity_, 1.0 / events_dt_);
- return events_queue_.back().pos + ScaleVector2d(cur_velocity_, pred_dt) +
- ScaleVector2d(acceleration, 0.5 * pred_dt * pred_dt);
-}
-
-base::TimeDelta LinearPredictor::TimeInterval() const {
- if (events_queue_.size() > 1) {
- return std::max(kMinTimeInterval, (events_queue_.back().time_stamp -
- events_queue_.front().time_stamp) /
- (events_queue_.size() - 1));
- }
- return kTimeInterval;
-}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/linear_predictor.h b/chromium/ui/events/blink/prediction/linear_predictor.h
deleted file mode 100644
index 3f81890614b..00000000000
--- a/chromium/ui/events/blink/prediction/linear_predictor.h
+++ /dev/null
@@ -1,78 +0,0 @@
-// Copyright 2019 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 UI_EVENTS_BLINK_PREDICTION_LINEAR_PREDICTOR_H_
-#define UI_EVENTS_BLINK_PREDICTION_LINEAR_PREDICTOR_H_
-
-#include <deque>
-
-#include "ui/events/blink/prediction/input_predictor.h"
-
-namespace ui {
-
-// This class use a linear model for prediction
-// You can choose between a first order equation:
-// pred_p = last_p + velocity*pred_time
-// and a second order equation:
-// pred_p = last_p + velocity*pred_dt + 0.5*acceleration*pred_dt^2
-
-class LinearPredictor : public InputPredictor {
- public:
- // Used to dissociate the order of the equation used but also used to
- // define the number of events needed by each model
- enum class EquationOrder : size_t { kFirstOrder = 2, kSecondOrder = 3 };
-
- explicit LinearPredictor(EquationOrder order);
- ~LinearPredictor() override;
-
- const char* GetName() const override;
-
- // Reset the predictor to initial state.
- void Reset() override;
-
- // Store current input in queue.
- void Update(const InputData& new_input) override;
-
- // Return if there is enough data in the queue to generate prediction.
- bool HasPrediction() const override;
-
- // Generate the prediction based on stored points and given time_stamp.
- // Return false if no prediction available.
- std::unique_ptr<InputData> GeneratePrediction(
- base::TimeTicks predict_time) const override;
-
- // Return the average time delta in the event queue.
- base::TimeDelta TimeInterval() const override;
-
- // Return the number of events needed to compute a prediction
- size_t NumberOfEventsNeeded();
-
- private:
- gfx::PointF GeneratePredictionFirstOrder(float pred_dt) const;
-
- gfx::PointF GeneratePredictionSecondOrder(float pred_dt) const;
-
- // Store the last events received
- std::deque<InputData> events_queue_;
-
- // Store the equation order of the predictor
- // The enum value also represents the number of events needed to compute the
- // prediction
- EquationOrder equation_order_;
-
- // Store the current velocity of the 2 last events
- gfx::Vector2dF cur_velocity_;
-
- // Store the last velocity of the 2 last past events
- gfx::Vector2dF last_velocity_;
-
- // Store the current delta time between the last 2 events
- float events_dt_;
-
- DISALLOW_COPY_AND_ASSIGN(LinearPredictor);
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_PREDICTION_LINEAR_PREDICTOR_H_
diff --git a/chromium/ui/events/blink/prediction/linear_predictor_unittest.cc b/chromium/ui/events/blink/prediction/linear_predictor_unittest.cc
deleted file mode 100644
index 2a12001a990..00000000000
--- a/chromium/ui/events/blink/prediction/linear_predictor_unittest.cc
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright 2019 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 "ui/events/blink/prediction/linear_predictor.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/events/blink/prediction/input_predictor_unittest_helpers.h"
-#include "ui/events/blink/prediction/predictor_factory.h"
-
-namespace ui {
-namespace test {
-
-class LinearPredictorFirstOrderTest : public InputPredictorTest {
- public:
- explicit LinearPredictorFirstOrderTest() {}
-
- void SetUp() override {
- predictor_ = std::make_unique<ui::LinearPredictor>(
- LinearPredictor::EquationOrder::kFirstOrder);
- }
-
- DISALLOW_COPY_AND_ASSIGN(LinearPredictorFirstOrderTest);
-};
-
-class LinearPredictorSecondOrderTest : public InputPredictorTest {
- public:
- explicit LinearPredictorSecondOrderTest() {}
-
- void SetUp() override {
- predictor_ = std::make_unique<ui::LinearPredictor>(
- LinearPredictor::EquationOrder::kSecondOrder);
- }
-
- DISALLOW_COPY_AND_ASSIGN(LinearPredictorSecondOrderTest);
-};
-
-// Test if the output name of the predictor is taking account of the
-// equation order
-TEST_F(LinearPredictorFirstOrderTest, GetName) {
- EXPECT_EQ(predictor_->GetName(),
- input_prediction::kScrollPredictorNameLinearFirst);
-}
-
-// Test if the output name of the predictor is taking account of the
-// equation order
-TEST_F(LinearPredictorSecondOrderTest, GetName) {
- EXPECT_EQ(predictor_->GetName(),
- input_prediction::kScrollPredictorNameLinearSecond);
-}
-
-// Test that the number of events required to compute a prediction is correct
-TEST_F(LinearPredictorFirstOrderTest, ShouldHavePrediction) {
- LinearPredictor predictor(LinearPredictor::EquationOrder::kFirstOrder);
- size_t n = static_cast<size_t>(LinearPredictor::EquationOrder::kFirstOrder);
- for (size_t i = 0; i < n; i++) {
- EXPECT_FALSE(predictor.HasPrediction());
- predictor.Update(InputPredictor::InputData());
- }
- EXPECT_TRUE(predictor.HasPrediction());
- predictor.Reset();
- EXPECT_FALSE(predictor.HasPrediction());
-}
-
-// Test that the number of events required to compute a prediction is correct
-TEST_F(LinearPredictorSecondOrderTest, ShouldHavePrediction) {
- LinearPredictor predictor(LinearPredictor::EquationOrder::kSecondOrder);
- size_t n1 = static_cast<size_t>(LinearPredictor::EquationOrder::kFirstOrder);
- size_t n2 = static_cast<size_t>(LinearPredictor::EquationOrder::kSecondOrder);
- for (size_t i = 0; i < n2; i++) {
- if (i < n1)
- EXPECT_FALSE(predictor.HasPrediction());
- else
- EXPECT_TRUE(predictor.HasPrediction());
- predictor.Update(InputPredictor::InputData());
- }
- EXPECT_TRUE(predictor.HasPrediction());
- predictor.Reset();
- EXPECT_FALSE(predictor.HasPrediction());
-}
-
-TEST_F(LinearPredictorFirstOrderTest, PredictedValue) {
- std::vector<double> x = {10, 20};
- std::vector<double> y = {5, 25};
- std::vector<double> t = {17, 33};
- // Compensating 23 ms
- // 1st order prediction at 33 + 23 = 56 ms
-
- std::vector<double> pred_ts = {56};
- std::vector<double> pred_x = {34.37};
- std::vector<double> pred_y = {53.75};
- ValidatePredictor(x, y, t, pred_ts, pred_x, pred_y);
-}
-
-TEST_F(LinearPredictorSecondOrderTest, PredictedValue) {
- std::vector<double> x = {0, 10, 20};
- std::vector<double> y = {0, 5, 25};
- std::vector<double> t = {0, 17, 33};
- // Compensating 23 ms in both results
- // 1st order prediction at 17 + 23 = 40 ms
- // 2nd order prediction at 33 + 23 = 56 ms
- std::vector<double> pred_ts = {40, 56};
- std::vector<double> pred_x = {23.52, 34.98};
- std::vector<double> pred_y = {11.76, 69.55};
- ValidatePredictor(x, y, t, pred_ts, pred_x, pred_y);
-}
-
-// Test constant position and constant velocity
-TEST_F(LinearPredictorSecondOrderTest, ConstantPositionAndVelocity) {
- std::vector<double> x = {10, 10, 10, 10, 10}; // constant position
- std::vector<double> y = {0, 5, 10, 15, 20}; // constant velocity
- std::vector<double> t = {0, 7, 14, 21, 28}; // regular interval
- // since velocity is constant, acceleration should be 0 which simplifies
- // computations
- // Compensating 10 ms in all results
- std::vector<double> pred_ts = {17, 24, 31, 38};
- std::vector<double> pred_x = {10, 10, 10, 10};
- std::vector<double> pred_y = {12.14, 17.14, 22.14, 27.14};
- ValidatePredictor(x, y, t, pred_ts, pred_x, pred_y);
-}
-
-// Test time interval in first order
-TEST_F(LinearPredictorFirstOrderTest, TimeInterval) {
- EXPECT_EQ(predictor_->TimeInterval(), kExpectedDefaultTimeInterval);
- std::vector<double> x = {10, 20};
- std::vector<double> y = {5, 25};
- std::vector<double> t = {17, 33};
- size_t n = static_cast<size_t>(LinearPredictor::EquationOrder::kFirstOrder);
- for (size_t i = 0; i < n; i++) {
- predictor_->Update({gfx::PointF(x[i], y[i]), FromMilliseconds(t[i])});
- }
- EXPECT_EQ(predictor_->TimeInterval(),
- base::TimeDelta::FromMilliseconds(t[1] - t[0]));
-}
-
-// Test time interval in second order
-TEST_F(LinearPredictorSecondOrderTest, TimeInterval) {
- EXPECT_EQ(predictor_->TimeInterval(), kExpectedDefaultTimeInterval);
- std::vector<double> x = {0, 10, 20};
- std::vector<double> y = {0, 5, 25};
- std::vector<double> t = {0, 17, 33};
- size_t n = static_cast<size_t>(LinearPredictor::EquationOrder::kSecondOrder);
- for (size_t i = 0; i < n; i++) {
- predictor_->Update({gfx::PointF(x[i], y[i]), FromMilliseconds(t[i])});
- }
- EXPECT_EQ(predictor_->TimeInterval(),
- base::TimeDelta::FromMillisecondsD((t[2] - t[0]) / 2));
-}
-
-} // namespace test
-} // namespace ui \ No newline at end of file
diff --git a/chromium/ui/events/blink/prediction/linear_resampling.cc b/chromium/ui/events/blink/prediction/linear_resampling.cc
deleted file mode 100644
index 2b2efe7f132..00000000000
--- a/chromium/ui/events/blink/prediction/linear_resampling.cc
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2019 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 "ui/events/blink/prediction/linear_resampling.h"
-
-#include <algorithm>
-
-#include "ui/events/blink/prediction/predictor_factory.h"
-
-namespace ui {
-
-namespace {
-// Minimum time difference between last two consecutive events before attempting
-// to resample.
-constexpr base::TimeDelta kResampleMinDelta =
- base::TimeDelta::FromMilliseconds(2);
-// Maximum time to predict forward from the last event, to avoid predicting too
-// far into the future. This time is further bounded by 50% of the last time
-// delta.
-constexpr base::TimeDelta kResampleMaxPrediction =
- base::TimeDelta::FromMilliseconds(8);
-// Align events to a few milliseconds before frame_time. This is to make the
-// resampling either doing interpolation or extrapolating a closer future time
-// so that resampled result is more accurate and has less noise. This adds some
-// latency during resampling but a few ms should be fine.
-constexpr base::TimeDelta kResampleLatency =
- base::TimeDelta::FromMilliseconds(5);
-
-// Get position at |sample_time| by linear interpolate/extrapolate a and b.
-inline gfx::PointF lerp(const InputPredictor::InputData& a,
- const InputPredictor::InputData& b,
- base::TimeTicks sample_time) {
- float alpha = (sample_time - a.time_stamp).InMillisecondsF() /
- (a.time_stamp - b.time_stamp).InMillisecondsF();
- return a.pos + gfx::ScaleVector2d(a.pos - b.pos, alpha);
-}
-
-} // namespace
-
-LinearResampling::LinearResampling() {}
-
-LinearResampling::~LinearResampling() {}
-
-const char* LinearResampling::GetName() const {
- return input_prediction::kScrollPredictorNameLinearResampling;
-}
-
-void LinearResampling::Reset() {
- events_queue_.clear();
-}
-
-void LinearResampling::Update(const InputData& new_input) {
- // The last input received is at least kMaxDeltaTime away, we consider it
- // is a new trajectory
- if (!events_queue_.empty() &&
- new_input.time_stamp - events_queue_.front().time_stamp > kMaxTimeDelta) {
- Reset();
- }
-
- // Queue the new event.
- events_queue_.push_front(new_input);
- if (events_queue_.size() > kNumEventsForResampling)
- events_queue_.pop_back();
- DCHECK(events_queue_.size() <= kNumEventsForResampling);
-
- if (events_queue_.size() == kNumEventsForResampling)
- events_dt_ = events_queue_[0].time_stamp - events_queue_[1].time_stamp;
-}
-
-bool LinearResampling::HasPrediction() const {
- return events_queue_.size() == kNumEventsForResampling &&
- events_dt_ >= kResampleMinDelta;
-}
-
-std::unique_ptr<InputPredictor::InputData> LinearResampling::GeneratePrediction(
- base::TimeTicks frame_time) const {
- if (!HasPrediction())
- return nullptr;
-
- base::TimeTicks sample_time = frame_time - kResampleLatency;
-
- base::TimeDelta max_prediction =
- std::min(kResampleMaxPrediction, events_dt_ / 2.0);
-
- sample_time =
- std::min(sample_time, events_queue_[0].time_stamp + max_prediction);
-
- return std::make_unique<InputData>(
- lerp(events_queue_[0], events_queue_[1], sample_time), sample_time);
-}
-
-base::TimeDelta LinearResampling::TimeInterval() const {
- if (events_queue_.size() == kNumEventsForResampling) {
- return events_dt_;
- }
- return kTimeInterval;
-}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/linear_resampling.h b/chromium/ui/events/blink/prediction/linear_resampling.h
deleted file mode 100644
index e3431c273cc..00000000000
--- a/chromium/ui/events/blink/prediction/linear_resampling.h
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright 2019 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 UI_EVENTS_BLINK_PREDICTION_LINEAR_RESAMPLING_H_
-#define UI_EVENTS_BLINK_PREDICTION_LINEAR_RESAMPLING_H_
-
-#include <deque>
-
-#include "ui/events/blink/prediction/input_predictor.h"
-
-namespace ui {
-
-// This class use linear extrapolates / interpolates to resample events to
-// frame_time - kResampleLatency. This resampling logic is to match the
-// resampling behavior on Android. It's not designed for pointerevent's
-// PredictedEvent and should not be used for that purpose.
-// Resampling on Android see:
-// https://android.googlesource.com/platform/frameworks/native/+/master/libs/input/InputTransport.cpp
-class LinearResampling : public InputPredictor {
- public:
- explicit LinearResampling();
- ~LinearResampling() override;
-
- const char* GetName() const override;
-
- // Reset the predictor to initial state.
- void Reset() override;
-
- // Store current input in queue.
- void Update(const InputData& new_input) override;
-
- // Return if there is enough data in the queue to generate prediction.
- bool HasPrediction() const override;
-
- // Generate the prediction based on stored points and given frame_time.
- // Return false if no prediction available.
- std::unique_ptr<InputData> GeneratePrediction(
- base::TimeTicks frame_time) const override;
-
- // Return the average time delta in the event queue.
- base::TimeDelta TimeInterval() const override;
-
- private:
- static constexpr size_t kNumEventsForResampling = 2;
-
- // Store the last events received
- std::deque<InputData> events_queue_;
-
- // Store the current delta time between the last 2 events
- base::TimeDelta events_dt_;
-
- DISALLOW_COPY_AND_ASSIGN(LinearResampling);
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_PREDICTION_LINEAR_RESAMPLING_H_
diff --git a/chromium/ui/events/blink/prediction/linear_resampling_unittest.cc b/chromium/ui/events/blink/prediction/linear_resampling_unittest.cc
deleted file mode 100644
index 7e0eb9c4782..00000000000
--- a/chromium/ui/events/blink/prediction/linear_resampling_unittest.cc
+++ /dev/null
@@ -1,126 +0,0 @@
-// Copyright 2019 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 "ui/events/blink/prediction/linear_resampling.h"
-
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/events/blink/prediction/input_predictor_unittest_helpers.h"
-#include "ui/events/blink/prediction/predictor_factory.h"
-
-namespace ui {
-namespace test {
-
-class LinearResamplingTest : public InputPredictorTest {
- public:
- explicit LinearResamplingTest() {}
-
- void SetUp() override {
- predictor_ = std::make_unique<ui::LinearResampling>();
- }
-
- DISALLOW_COPY_AND_ASSIGN(LinearResamplingTest);
-};
-
-// Test if the output name of the predictor is taking account of the
-// equation order
-TEST_F(LinearResamplingTest, GetName) {
- EXPECT_EQ(predictor_->GetName(),
- input_prediction::kScrollPredictorNameLinearResampling);
-}
-
-// Test that the number of events required to compute a prediction is correct
-TEST_F(LinearResamplingTest, ShouldHavePrediction) {
- LinearResampling predictor;
- EXPECT_FALSE(predictor.HasPrediction());
-
- // 1st event.
- predictor.Update(
- InputPredictor::InputData({gfx::PointF(0, 0), FromMilliseconds(0)}));
- EXPECT_FALSE(predictor.HasPrediction());
-
- // 2nd event.
- predictor.Update(
- InputPredictor::InputData({gfx::PointF(0, 0), FromMilliseconds(8)}));
- EXPECT_TRUE(predictor.HasPrediction());
-
- predictor.Reset();
- EXPECT_FALSE(predictor.HasPrediction());
-}
-
-TEST_F(LinearResamplingTest, ResampleMinDelta) {
- EXPECT_FALSE(predictor_->HasPrediction());
- predictor_->Update(
- InputPredictor::InputData({gfx::PointF(0, 0), FromMilliseconds(0)}));
- predictor_->Update(
- InputPredictor::InputData({gfx::PointF(0, 0), FromMilliseconds(1)}));
- // No prediction when last_dt < kResampleMinDelta.
- EXPECT_FALSE(predictor_->HasPrediction());
-
- // Has prediction when last_dt >= kResampleMinDelta.
- predictor_->Update(
- InputPredictor::InputData({gfx::PointF(0, 0), FromMilliseconds(3)}));
- EXPECT_TRUE(predictor_->HasPrediction());
-
- predictor_->Update(
- InputPredictor::InputData({gfx::PointF(0, 0), FromMilliseconds(15)}));
- EXPECT_TRUE(predictor_->HasPrediction());
-
- // Predictor is reset when dt > kMaxTimeDelta.
- predictor_->Update(
- InputPredictor::InputData({gfx::PointF(0, 0), FromMilliseconds(36)}));
- EXPECT_FALSE(predictor_->HasPrediction());
-}
-
-TEST_F(LinearResamplingTest, ResamplingValue) {
- std::vector<double> x = {10, 20, 30};
- std::vector<double> y = {5, 25, 35};
- std::vector<double> t = {15, 24, 32};
-
- // Resample at frame_time = 33 ms, sample_time = 33-5 = 28ms.
- // Resample at frame_time = 41 ms, sample_time = 41-5 = 36ms.
- std::vector<double> pred_ts = {33, 41};
- std::vector<double> pred_x = {24.44, 35};
- std::vector<double> pred_y = {33.89, 40};
- ValidatePredictor(x, y, t, pred_ts, pred_x, pred_y);
-}
-
-TEST_F(LinearResamplingTest, ResamplingMaxPrediction) {
- std::vector<double> x = {10, 20};
- std::vector<double> y = {5, 10};
- std::vector<double> t = {10, 30};
- // Resample at frame_time = 45 ms, with max_prediction =
- // kResampleMaxPrediction, sample_time = 30 + 8ms = 38ms.
- std::vector<double> pred_ts = {45};
- std::vector<double> pred_x = {24};
- std::vector<double> pred_y = {12};
- ValidatePredictor(x, y, t, pred_ts, pred_x, pred_y);
-}
-
-TEST_F(LinearResamplingTest, ResamplingBoundLastDelta) {
- std::vector<double> x = {10, 20};
- std::vector<double> y = {5, 10};
- std::vector<double> t = {10, 14};
- // Resample at frame_time = 20 ms, sample time is bounded by 50% of the
- // last time delta, result in 14 + 2ms = 16ms.
- std::vector<double> pred_ts = {20};
- std::vector<double> pred_x = {22.5};
- std::vector<double> pred_y = {11.25};
- ValidatePredictor(x, y, t, pred_ts, pred_x, pred_y);
-}
-
-// Test time interval in first order
-TEST_F(LinearResamplingTest, TimeInterval) {
- EXPECT_EQ(predictor_->TimeInterval(), kExpectedDefaultTimeInterval);
- std::vector<double> x = {10, 20};
- std::vector<double> y = {5, 25};
- std::vector<double> t = {17, 33};
- for (size_t i = 0; i < t.size(); i++) {
- predictor_->Update({gfx::PointF(x[i], y[i]), FromMilliseconds(t[i])});
- }
- EXPECT_EQ(predictor_->TimeInterval(),
- base::TimeDelta::FromMilliseconds(t[1] - t[0]));
-}
-
-} // namespace test
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/one_euro_filter.cc b/chromium/ui/events/blink/prediction/one_euro_filter.cc
deleted file mode 100644
index 8e14dbe7dff..00000000000
--- a/chromium/ui/events/blink/prediction/one_euro_filter.cc
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright 2019 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 "ui/events/blink/prediction/one_euro_filter.h"
-#include "ui/events/blink/prediction/filter_factory.h"
-
-namespace ui {
-
-const double OneEuroFilter::kDefaultFrequency;
-const double OneEuroFilter::kDefaultMincutoff;
-const double OneEuroFilter::kDefaultBeta;
-const double OneEuroFilter::kDefaultDcutoff;
-
-const char OneEuroFilter::kParamBeta[];
-const char OneEuroFilter::kParamMincutoff[];
-
-OneEuroFilter::OneEuroFilter(double mincutoff, double beta) {
- x_filter_ = std::make_unique<one_euro_filter::OneEuroFilter>(
- kDefaultFrequency, mincutoff, beta, kDefaultDcutoff);
- y_filter_ = std::make_unique<one_euro_filter::OneEuroFilter>(
- kDefaultFrequency, mincutoff, beta, kDefaultDcutoff);
-}
-
-OneEuroFilter::~OneEuroFilter() {}
-
-bool OneEuroFilter::Filter(const base::TimeTicks& timestamp,
- gfx::PointF* position) const {
- if (position == nullptr)
- return false;
- one_euro_filter::TimeStamp ts = (timestamp - base::TimeTicks()).InSecondsF();
- position->set_x(x_filter_->Filter(position->x(), ts));
- position->set_y(y_filter_->Filter(position->y(), ts));
- return true;
-}
-
-const char* OneEuroFilter::GetName() const {
- return input_prediction::kFilterNameOneEuro;
-}
-
-InputFilter* OneEuroFilter::Clone() {
- OneEuroFilter* new_filter = new OneEuroFilter();
- new_filter->x_filter_.reset(x_filter_->Clone());
- new_filter->y_filter_.reset(y_filter_->Clone());
- return new_filter;
-}
-
-void OneEuroFilter::Reset() {
- x_filter_->Reset();
- y_filter_->Reset();
-}
-
-} // namespace ui \ No newline at end of file
diff --git a/chromium/ui/events/blink/prediction/one_euro_filter.h b/chromium/ui/events/blink/prediction/one_euro_filter.h
deleted file mode 100644
index 480b0b69a4d..00000000000
--- a/chromium/ui/events/blink/prediction/one_euro_filter.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright 2019 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 UI_EVENTS_BLINK_PREDICTION_ONE_EURO_FILTER_H_
-#define UI_EVENTS_BLINK_PREDICTION_ONE_EURO_FILTER_H_
-
-#include "third_party/one_euro_filter/src/one_euro_filter.h"
-#include "ui/events/blink/prediction/input_filter.h"
-
-namespace ui {
-
-// This class uses the 1€ filter from third party.
-// See this page : http://cristal.univ-lille.fr/~casiez/1euro/
-// to know how the filter works and how to tune it
-class OneEuroFilter : public InputFilter {
- public:
- OneEuroFilter(double mincutoff = kDefaultMincutoff,
- double beta = kDefaultBeta);
- ~OneEuroFilter() override;
-
- bool Filter(const base::TimeTicks& timestamp,
- gfx::PointF* position) const override;
-
- const char* GetName() const override;
-
- InputFilter* Clone() override;
-
- void Reset() override;
-
- // Default parameters values for the filter
- static constexpr double kDefaultFrequency = 60;
- static constexpr double kDefaultMincutoff = 1.0;
- static constexpr double kDefaultBeta = 0.001;
- static constexpr double kDefaultDcutoff = 1.0;
-
- // Names of the fieldtrials used to tune the filter
- static constexpr char kParamBeta[] = "beta";
- static constexpr char kParamMincutoff[] = "mincutoff";
-
- private:
- std::unique_ptr<one_euro_filter::OneEuroFilter> x_filter_;
- std::unique_ptr<one_euro_filter::OneEuroFilter> y_filter_;
-
- DISALLOW_COPY_AND_ASSIGN(OneEuroFilter);
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_PREDICTION_ONE_EURO_FILTER_H_ \ No newline at end of file
diff --git a/chromium/ui/events/blink/prediction/one_euro_filter_unittests.cc b/chromium/ui/events/blink/prediction/one_euro_filter_unittests.cc
deleted file mode 100644
index 7131a71a8a3..00000000000
--- a/chromium/ui/events/blink/prediction/one_euro_filter_unittests.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright 2019 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/rand_util.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/events/blink/prediction/filter_factory.h"
-#include "ui/events/blink/prediction/input_filter_unittest_helpers.h"
-#include "ui/events/blink/prediction/one_euro_filter.h"
-
-namespace ui {
-namespace test {
-
-class OneEuroFilterTest : public InputFilterTest {
- public:
- explicit OneEuroFilterTest() {}
-
- void SetUp() override { filter_ = std::make_unique<ui::OneEuroFilter>(1, 1); }
-
- DISALLOW_COPY_AND_ASSIGN(OneEuroFilterTest);
-};
-
-TEST_F(OneEuroFilterTest, TestClone) {
- TestCloneFilter();
-}
-
-TEST_F(OneEuroFilterTest, TestReset) {
- TestResetFilter();
-}
-
-// Check if sending values between 0 and 1 keeps filtered values between 0 and 1
-TEST_F(OneEuroFilterTest, filteringValues) {
- base::TimeTicks ts = blink::WebInputEvent::GetStaticTimeStampForTests();
- gfx::PointF point;
- for (int i = 0; i < 100; i++) {
- point.SetPoint(base::RandDouble(), base::RandDouble());
- EXPECT_TRUE(filter_->Filter(ts, &point));
- EXPECT_LT(point.x(), 1.0);
- EXPECT_LT(point.y(), 1.0);
- EXPECT_GT(point.x(), 0.0);
- EXPECT_GT(point.y(), 0.0);
- }
-}
-
-} // namespace test
-} // namespace ui \ No newline at end of file
diff --git a/chromium/ui/events/blink/prediction/prediction_metrics_handler.cc b/chromium/ui/events/blink/prediction/prediction_metrics_handler.cc
deleted file mode 100644
index adc7491738b..00000000000
--- a/chromium/ui/events/blink/prediction/prediction_metrics_handler.cc
+++ /dev/null
@@ -1,187 +0,0 @@
-// Copyright 2019 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 "ui/events/blink/prediction/prediction_metrics_handler.h"
-
-#include "base/metrics/histogram_functions.h"
-
-namespace ui {
-
-PredictionMetricsHandler::PredictionMetricsHandler() {}
-PredictionMetricsHandler::~PredictionMetricsHandler() {}
-
-void PredictionMetricsHandler::AddRealEvent(const gfx::PointF& pos,
- const base::TimeTicks& time_stamp,
- const base::TimeTicks& frame_time,
- bool scrolling) {
- // Be sure real events are ordered over time
- DCHECK(events_queue_.empty() ||
- time_stamp >= events_queue_.back().time_stamp);
- EventData e;
- if (scrolling)
- e.pos = gfx::PointF(0, pos.y());
- else
- e.pos = pos;
- e.time_stamp = time_stamp;
- e.frame_time = frame_time;
- events_queue_.push_back(e);
-}
-
-void PredictionMetricsHandler::AddPredictedEvent(
- const gfx::PointF& pos,
- const base::TimeTicks& time_stamp,
- const base::TimeTicks& frame_time,
- bool scrolling) {
- DCHECK(!events_queue_.empty());
- // If the predicted event is prior to the first real event, ignore it as we
- // don't have enough data for interpolation.
- if (time_stamp < events_queue_.front().time_stamp)
- return;
- // TODO(nzolghadr): The following DCHECK is commented out due to
- // crbug.com/1017661. More investigation needs to be done as why this happens.
- // DCHECK(predicted_events_queue_.empty() ||
- // time_stamp >= predicted_events_queue_.back().time_stamp);
- bool needs_sorting = false;
- if (!predicted_events_queue_.empty() &&
- time_stamp < predicted_events_queue_.back().time_stamp)
- needs_sorting = true;
-
- EventData e;
- if (scrolling)
- e.pos = gfx::PointF(0, pos.y());
- else
- e.pos = pos;
- e.time_stamp = time_stamp;
- e.frame_time = frame_time;
- predicted_events_queue_.push_back(e);
-
- // TODO(nzolghadr): This should never be needed. Something seems to be wrong
- // in the tests. See crbug.com/1017661.
- if (needs_sorting) {
- std::sort(predicted_events_queue_.begin(), predicted_events_queue_.end(),
- [](const EventData& a, const EventData& b) {
- return a.time_stamp < b.time_stamp;
- });
- }
-}
-
-void PredictionMetricsHandler::EvaluatePrediction() {
- while (!predicted_events_queue_.empty()) {
- // Not enough events to compute the metrics, do not compute for now.
- if (events_queue_.size() < 2 ||
- events_queue_.back().time_stamp <=
- predicted_events_queue_.front().time_stamp ||
- events_queue_.back().time_stamp <=
- predicted_events_queue_.front().frame_time) {
- return;
- }
-
- ComputeMetrics();
-
- last_predicted_ = predicted_events_queue_.front().pos;
- last_interpolated_ = interpolated_;
- last_frame_interpolated_ = frame_interpolated_;
- predicted_events_queue_.pop_front();
- }
-}
-
-void PredictionMetricsHandler::Reset() {
- events_queue_.clear();
- predicted_events_queue_.clear();
- last_predicted_ = base::nullopt;
-}
-
-int PredictionMetricsHandler::GetInterpolatedEventForPredictedEvent(
- const base::TimeTicks& interpolation_timestamp,
- gfx::PointF* interpolated) {
- size_t idx = 0;
- while (idx < events_queue_.size() &&
- interpolation_timestamp >= events_queue_[idx].time_stamp)
- idx++;
-
- if (idx == 0 || idx == events_queue_.size())
- return -1;
-
- float alpha =
- (interpolation_timestamp - events_queue_[idx - 1].time_stamp)
- .InMillisecondsF() /
- (events_queue_[idx].time_stamp - events_queue_[idx - 1].time_stamp)
- .InMillisecondsF();
- *interpolated =
- events_queue_[idx - 1].pos +
- ScaleVector2d(events_queue_[idx].pos - events_queue_[idx - 1].pos, alpha);
- return idx - 1;
-}
-
-void PredictionMetricsHandler::ComputeMetrics() {
- // Compute interpolations at predicted time and frame time.
- int low_idx_interpolated = GetInterpolatedEventForPredictedEvent(
- predicted_events_queue_.front().time_stamp, &interpolated_);
- int low_idx_frame_interpolated = GetInterpolatedEventForPredictedEvent(
- predicted_events_queue_.front().frame_time, &frame_interpolated_);
-
- next_real_ = events_queue_[low_idx_interpolated + 1].pos;
-
- int first_needed_event =
- std::min(low_idx_interpolated, low_idx_frame_interpolated);
- // Return if any of the interpolation is not found.
- if (first_needed_event == -1)
- return;
- // Clean real events queue.
- for (int i = 0; i < first_needed_event - 1; i++)
- events_queue_.pop_front();
-
- std::string kPredictionMetrics = "Event.InputEventPrediction.Scroll.";
-
- double score = ComputeOverUnderPredictionMetric();
- if (score >= 0)
- base::UmaHistogramCounts1000(kPredictionMetrics + "OverPrediction", score);
- else
- base::UmaHistogramCounts1000(kPredictionMetrics + "UnderPrediction",
- -score);
-
- // Need |last_predicted_| to compute WrongDirection and Jitter metrics.
- if (!last_predicted_.has_value())
- return;
-
- base::UmaHistogramBoolean(kPredictionMetrics + "WrongDirection",
- ComputeWrongDirectionMetric());
- base::UmaHistogramCounts1000(kPredictionMetrics + "PredictionJitter",
- ComputePredictionJitterMetric());
- base::UmaHistogramCounts1000(kPredictionMetrics + "VisualJitter",
- ComputeVisualJitterMetric());
-}
-
-double PredictionMetricsHandler::ComputeOverUnderPredictionMetric() {
- gfx::Vector2dF real_direction = next_real_ - interpolated_;
- gfx::Vector2dF relative_direction =
- predicted_events_queue_.front().pos - interpolated_;
- if (gfx::DotProduct(real_direction, relative_direction) >= 0)
- return relative_direction.Length();
- else
- return -relative_direction.Length();
-}
-
-bool PredictionMetricsHandler::ComputeWrongDirectionMetric() {
- gfx::Vector2dF real_direction = next_real_ - interpolated_;
- gfx::Vector2dF predicted_direction =
- predicted_events_queue_.front().pos - last_predicted_.value();
- return gfx::DotProduct(real_direction, predicted_direction) < 0;
-}
-
-double PredictionMetricsHandler::ComputePredictionJitterMetric() {
- gfx::Vector2dF delta = interpolated_ - predicted_events_queue_.front().pos;
- gfx::Vector2dF last_delta = last_interpolated_ - last_predicted_.value();
- return (delta - last_delta).Length();
-}
-
-double PredictionMetricsHandler::ComputeVisualJitterMetric() {
- gfx::Vector2dF delta =
- frame_interpolated_ - predicted_events_queue_.front().pos;
- gfx::Vector2dF last_delta =
- last_frame_interpolated_ - last_predicted_.value();
- return (delta - last_delta).Length();
-}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/prediction_metrics_handler.h b/chromium/ui/events/blink/prediction/prediction_metrics_handler.h
deleted file mode 100644
index 61fe8aea6b9..00000000000
--- a/chromium/ui/events/blink/prediction/prediction_metrics_handler.h
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright 2019 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 UI_EVENTS_BLINK_PREDICTION_PREDICTION_METRICS_HANDLER_H_
-#define UI_EVENTS_BLINK_PREDICTION_PREDICTION_METRICS_HANDLER_H_
-
-#include <deque>
-#include <unordered_map>
-
-#include "base/optional.h"
-#include "ui/events/base_event_utils.h"
-#include "ui/gfx/geometry/point_f.h"
-
-namespace ui {
-
-namespace test {
-class PredictionMetricsHandlerTest;
-}
-
-// Class used for evaluating input prediction.
-// The basic idea is to buffer predicted and real events to be able to compare
-// a predicted position to its corresponding interpolated real position with
-// few metrics.
-class PredictionMetricsHandler {
- public:
- explicit PredictionMetricsHandler();
- ~PredictionMetricsHandler();
-
- // Struct used to store predicted and real event information.
- struct EventData {
- // Position of the event
- gfx::PointF pos;
- // Timestamp of the event
- base::TimeTicks time_stamp;
- // frame_time of the event
- base::TimeTicks frame_time;
- };
-
- // Buffers a real event.
- void AddRealEvent(const gfx::PointF& pos,
- const base::TimeTicks& time_stamp,
- const base::TimeTicks& frame_time,
- bool scrolling = false);
-
- // Buffers a predicted event.
- void AddPredictedEvent(const gfx::PointF& pos,
- const base::TimeTicks& time_stamp,
- const base::TimeTicks& frame_time,
- bool scrolling = false);
-
- void EvaluatePrediction();
-
- // Cleans all events buffers
- void Reset();
-
- private:
- friend class test::PredictionMetricsHandlerTest;
-
- // Computes necessary interpolations used for computing the metrics
- void ComputeMetrics();
-
- // Compute the OverUnderPredictionMetric score.
- // The score is the amount of pixels the predicted point is ahead of
- // the real point. If the score is positive, the prediction is OverPredicting,
- // otherwise UnderPredicting.
- double ComputeOverUnderPredictionMetric();
-
- // Compute the PredictionJitterMetric score.
- // The score is the euclidean distance between 2 successive variation of
- // prediction and the corresponding real events at the same timestamp. It is
- // an indicator of smoothness.
- double ComputePredictionJitterMetric();
-
- // Compute the WrongDirectionMetric score.
- // The score is a boolean (as double) indicating whether the prediction is
- // in the same direction as the real trajectory..
- bool ComputeWrongDirectionMetric();
-
- // Compute the VisualJitterMetric score.
- // The score is the euclidean distance between 2 successive variation of
- // prediction and the corresponding real events at frame time. It is
- // an indicator of smoothness.
- double ComputeVisualJitterMetric();
-
- // Get the interpolated position from the real events at a given timestamp.
- // Returns the index of the last real event which timestamp is smaller than
- // the |interpolation_timestamp|. Returns -1 if not found.
- int GetInterpolatedEventForPredictedEvent(
- const base::TimeTicks& interpolation_timestamp,
- gfx::PointF* interpolated);
-
- // Queues used for buffering real and predicted events.
- std::deque<EventData> events_queue_;
- std::deque<EventData> predicted_events_queue_;
-
- // Interpolated points of real events.
- gfx::PointF interpolated_, frame_interpolated_;
- gfx::PointF last_interpolated_, last_frame_interpolated_;
- // Last predicted point that pop from predicted_event_queue_. Use for
- // computing Jitter metrics.
- base::Optional<gfx::PointF> last_predicted_ = base::nullopt;
- // The first real event position which time is later than the predicted time.
- gfx::PointF next_real_;
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_PREDICTION_PREDICTION_METRICS_HANDLER_H_
diff --git a/chromium/ui/events/blink/prediction/prediction_metrics_handler_unittest.cc b/chromium/ui/events/blink/prediction/prediction_metrics_handler_unittest.cc
deleted file mode 100644
index 9cca5754434..00000000000
--- a/chromium/ui/events/blink/prediction/prediction_metrics_handler_unittest.cc
+++ /dev/null
@@ -1,231 +0,0 @@
-// Copyright 2019 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 "ui/events/blink/prediction/prediction_metrics_handler.h"
-
-#include "base/metrics/metrics_hashes.h"
-#include "base/test/metrics/histogram_tester.h"
-#include "testing/gmock/include/gmock/gmock.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/events/blink/blink_event_util.h"
-
-using base::Bucket;
-using testing::ElementsAre;
-
-namespace ui {
-namespace test {
-namespace {
-
-base::TimeTicks MillisecondsToTestTimeTicks(int64_t ms) {
- return blink::WebInputEvent::GetStaticTimeStampForTests() +
- base::TimeDelta::FromMilliseconds(ms);
-}
-
-} // namespace
-
-class PredictionMetricsHandlerTest : public testing::Test {
- public:
- explicit PredictionMetricsHandlerTest() {}
-
- void SetUp() override {
- metrics_handler_ = std::make_unique<PredictionMetricsHandler>();
- histogram_tester_ = std::make_unique<base::HistogramTester>();
- }
-
- DISALLOW_COPY_AND_ASSIGN(PredictionMetricsHandlerTest);
-
- int GetInterpolatedEventForPredictedEvent(const base::TimeTicks& timestamp,
- gfx::PointF* interpolated) {
- return metrics_handler_->GetInterpolatedEventForPredictedEvent(
- timestamp, interpolated);
- }
-
- ::testing::AssertionResult HistogramSizeEq(const char* histogram_name,
- int size) {
- uint64_t histogram_size =
- histogram_tester_->GetAllSamples(histogram_name).size();
- if (static_cast<uint64_t>(size) == histogram_size) {
- return ::testing::AssertionSuccess();
- } else {
- return ::testing::AssertionFailure()
- << histogram_name << " expected " << size << " entries, but had "
- << histogram_size;
- }
- }
-
- bool HasPredictionHistograms() {
- uint64_t histogram_size =
- histogram_tester_
- ->GetAllSamples("Event.InputEventPrediction.Scroll.WrongDirection")
- .size();
- return histogram_size > 0u;
- }
-
- void Reset() {
- histogram_tester_.reset(new base::HistogramTester());
- metrics_handler_->Reset();
- }
-
- const base::HistogramTester& histogram_tester() { return *histogram_tester_; }
-
- protected:
- std::unique_ptr<PredictionMetricsHandler> metrics_handler_;
- std::unique_ptr<base::HistogramTester> histogram_tester_;
-};
-
-TEST_F(PredictionMetricsHandlerTest, CanComputeMetricsTest) {
- base::TimeTicks start_time = EventTimeForNow();
- base::TimeDelta dt = base::TimeDelta::FromMilliseconds(8);
-
- // Need at least 2 real events to start comput metrics.
- {
- metrics_handler_->AddRealEvent(gfx::PointF(0, 0), start_time + 3 * dt,
- start_time);
- metrics_handler_->AddPredictedEvent(gfx::PointF(0, 0), start_time + 3 * dt,
- start_time);
- metrics_handler_->EvaluatePrediction();
- EXPECT_FALSE(HasPredictionHistograms());
- }
-
- // Need at least a real event strictly after the second predicted event.
- Reset();
- {
- metrics_handler_->AddRealEvent(gfx::PointF(0, 0), start_time, start_time);
- metrics_handler_->AddRealEvent(gfx::PointF(0, 0), start_time + dt,
- start_time);
- metrics_handler_->AddPredictedEvent(gfx::PointF(0, 0), start_time + 2 * dt,
- start_time);
- metrics_handler_->AddPredictedEvent(gfx::PointF(0, 0), start_time + 3 * dt,
- start_time);
- metrics_handler_->EvaluatePrediction();
- EXPECT_FALSE(HasPredictionHistograms());
-
- metrics_handler_->AddRealEvent(gfx::PointF(0, 0), start_time + 3 * dt,
- start_time);
- metrics_handler_->EvaluatePrediction();
- EXPECT_FALSE(HasPredictionHistograms());
-
- metrics_handler_->AddRealEvent(gfx::PointF(0, 0), start_time + 3.1 * dt,
- start_time);
- metrics_handler_->EvaluatePrediction();
- EXPECT_TRUE(HasPredictionHistograms());
- }
-}
-
-TEST_F(PredictionMetricsHandlerTest, InterpolationTest) {
- base::TimeTicks start_time = EventTimeForNow();
- base::TimeDelta dt = base::TimeDelta::FromMilliseconds(8);
- gfx::PointF interpolated;
-
- metrics_handler_->AddRealEvent(gfx::PointF(2, 2), start_time + 1 * dt,
- start_time);
- metrics_handler_->AddRealEvent(gfx::PointF(3, 3), start_time + 2 * dt,
- start_time);
- metrics_handler_->AddRealEvent(gfx::PointF(5, 5), start_time + 3 * dt,
- start_time);
- metrics_handler_->AddRealEvent(gfx::PointF(8, 8), start_time + 4 * dt,
- start_time);
-
- EXPECT_EQ(0, GetInterpolatedEventForPredictedEvent(start_time + 1.5 * dt,
- &interpolated));
- EXPECT_EQ(interpolated, gfx::PointF(2.5, 2.5));
-
- EXPECT_EQ(2, GetInterpolatedEventForPredictedEvent(start_time + 3.5 * dt,
- &interpolated));
- EXPECT_EQ(interpolated, gfx::PointF(6.5, 6.5));
-}
-// For test purpose and simplify, we are predicted in the middle of 2 real
-// events, which is also the frame time (i.e. a prediction of 4 ms)
-void AddEvents(PredictionMetricsHandler* metrics_handler) {
- metrics_handler->AddRealEvent(gfx::PointF(1, 1),
- MillisecondsToTestTimeTicks(8),
- MillisecondsToTestTimeTicks(12)); // R0
- metrics_handler->AddRealEvent(gfx::PointF(2, 2),
- MillisecondsToTestTimeTicks(16),
- MillisecondsToTestTimeTicks(20)); // R1
- metrics_handler->AddRealEvent(gfx::PointF(4, 4),
- MillisecondsToTestTimeTicks(24),
- MillisecondsToTestTimeTicks(28)); // R2
- metrics_handler->AddRealEvent(gfx::PointF(7, 7),
- MillisecondsToTestTimeTicks(32),
- MillisecondsToTestTimeTicks(36)); // R3
- metrics_handler->AddRealEvent(gfx::PointF(5, 5),
- MillisecondsToTestTimeTicks(40),
- MillisecondsToTestTimeTicks(44)); // R4
- metrics_handler->AddRealEvent(gfx::PointF(3, 3),
- MillisecondsToTestTimeTicks(48),
- MillisecondsToTestTimeTicks(54)); // R5
-
- // P0 | Interpolation from R0-R1 is (1.5,1.5)
- // UnderPrediction
- metrics_handler->AddPredictedEvent(gfx::PointF(1, 1),
- MillisecondsToTestTimeTicks(12),
- MillisecondsToTestTimeTicks(12));
- // P1 | Interpolation from R1-R2 is (3,3)
- // OverPrediction | RightDirection
- metrics_handler->AddPredictedEvent(gfx::PointF(3.5, 3.5),
- MillisecondsToTestTimeTicks(20),
- MillisecondsToTestTimeTicks(20));
- // P2 | Interpolation from R2-R3 is (5.5,5.5)
- // UnderPrediction | RightDirection
- metrics_handler->AddPredictedEvent(gfx::PointF(5, 5),
- MillisecondsToTestTimeTicks(28),
- MillisecondsToTestTimeTicks(28));
- // P3 | Interpolation from R3-R4 is (6,6)
- // UnderPrediction | WrongDirection
- metrics_handler->AddPredictedEvent(gfx::PointF(7, 7),
- MillisecondsToTestTimeTicks(36),
- MillisecondsToTestTimeTicks(36));
- // P4 | Interpolation from R4-R5 is (4,4)
- // OverPrediction | RightDirection
- metrics_handler->AddPredictedEvent(gfx::PointF(3, 3),
- MillisecondsToTestTimeTicks(44),
- MillisecondsToTestTimeTicks(44));
-}
-
-TEST_F(PredictionMetricsHandlerTest, PredictionMetricTest) {
- AddEvents(metrics_handler_.get());
- metrics_handler_->EvaluatePrediction();
-
- EXPECT_THAT(histogram_tester().GetAllSamples(
- "Event.InputEventPrediction.Scroll.OverPrediction"),
- ElementsAre(Bucket(0, 1), Bucket(1, 1)));
-
- EXPECT_THAT(histogram_tester().GetAllSamples(
- "Event.InputEventPrediction.Scroll.UnderPrediction"),
- ElementsAre(Bucket(0, 2), Bucket(1, 1)));
-
- EXPECT_THAT(histogram_tester().GetAllSamples(
- "Event.InputEventPrediction.Scroll.WrongDirection"),
- ElementsAre(Bucket(0, 3), Bucket(1, 1)));
-
- EXPECT_THAT(histogram_tester().GetAllSamples(
- "Event.InputEventPrediction.Scroll.PredictionJitter"),
- ElementsAre(Bucket(1, 2), Bucket(2, 2)));
-
- EXPECT_THAT(histogram_tester().GetAllSamples(
- "Event.InputEventPrediction.Scroll.VisualJitter"),
- ElementsAre(Bucket(1, 2), Bucket(2, 2)));
-}
-
-// Test that it doesn't crash when predicted event is prior to first real event.
-TEST_F(PredictionMetricsHandlerTest, PredictedTimePriorToReal) {
- metrics_handler_->AddRealEvent(gfx::PointF(1, 1),
- MillisecondsToTestTimeTicks(8),
- MillisecondsToTestTimeTicks(12));
- metrics_handler_->AddRealEvent(gfx::PointF(2, 2),
- MillisecondsToTestTimeTicks(10),
- MillisecondsToTestTimeTicks(12));
-
- metrics_handler_->AddPredictedEvent(gfx::PointF(0, 0),
- MillisecondsToTestTimeTicks(7),
- MillisecondsToTestTimeTicks(12));
- metrics_handler_->EvaluatePrediction();
- // No prediction metrics result.
- EXPECT_TRUE(
- HistogramSizeEq("Event.InputEventPrediction.Scroll.PredictionJitter", 0));
-}
-
-} // namespace test
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/predictor_factory.cc b/chromium/ui/events/blink/prediction/predictor_factory.cc
deleted file mode 100644
index 61f6f276bd4..00000000000
--- a/chromium/ui/events/blink/prediction/predictor_factory.cc
+++ /dev/null
@@ -1,80 +0,0 @@
-// Copyright 2019 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 "ui/events/blink/prediction/predictor_factory.h"
-#include "ui/events/blink/blink_features.h"
-#include "ui/events/blink/prediction/empty_predictor.h"
-#include "ui/events/blink/prediction/kalman_predictor.h"
-#include "ui/events/blink/prediction/least_squares_predictor.h"
-#include "ui/events/blink/prediction/linear_predictor.h"
-#include "ui/events/blink/prediction/linear_resampling.h"
-
-namespace ui {
-
-namespace input_prediction {
-
-const char kScrollPredictorNameLsq[] = "lsq";
-const char kScrollPredictorNameKalman[] = "kalman";
-const char kScrollPredictorNameLinearFirst[] = "linear_first";
-const char kScrollPredictorNameLinearSecond[] = "linear_second";
-const char kScrollPredictorNameLinearResampling[] = "linear_resampling";
-const char kScrollPredictorNameEmpty[] = "empty";
-
-} // namespace input_prediction
-
-namespace {
-using input_prediction::PredictorType;
-}
-
-// Set to UINT_MAX to trigger querying feature flags.
-unsigned int PredictorFactory::predictor_options_ = UINT_MAX;
-
-PredictorType PredictorFactory::GetPredictorTypeFromName(
- const std::string& predictor_name) {
- if (predictor_name == input_prediction::kScrollPredictorNameLinearResampling)
- return PredictorType::kScrollPredictorTypeLinearResampling;
- else if (predictor_name == input_prediction::kScrollPredictorNameLsq)
- return PredictorType::kScrollPredictorTypeLsq;
- else if (predictor_name == input_prediction::kScrollPredictorNameKalman)
- return PredictorType::kScrollPredictorTypeKalman;
- else if (predictor_name == input_prediction::kScrollPredictorNameLinearFirst)
- return PredictorType::kScrollPredictorTypeLinearFirst;
- else if (predictor_name == input_prediction::kScrollPredictorNameLinearSecond)
- return PredictorType::kScrollPredictorTypeLinearSecond;
- else
- return PredictorType::kScrollPredictorTypeEmpty;
-}
-
-std::unique_ptr<InputPredictor> PredictorFactory::GetPredictor(
- PredictorType predictor_type) {
- if (predictor_type == PredictorType::kScrollPredictorTypeLinearResampling)
- return std::make_unique<LinearResampling>();
- else if (predictor_type == PredictorType::kScrollPredictorTypeLsq)
- return std::make_unique<LeastSquaresPredictor>();
- else if (predictor_type == PredictorType::kScrollPredictorTypeKalman)
- return std::make_unique<KalmanPredictor>(GetKalmanPredictorOptions());
- else if (predictor_type == PredictorType::kScrollPredictorTypeLinearFirst)
- return std::make_unique<LinearPredictor>(
- LinearPredictor::EquationOrder::kFirstOrder);
- else if (predictor_type == PredictorType::kScrollPredictorTypeLinearSecond)
- return std::make_unique<LinearPredictor>(
- LinearPredictor::EquationOrder::kSecondOrder);
- else
- return std::make_unique<EmptyPredictor>();
-}
-
-unsigned int PredictorFactory::GetKalmanPredictorOptions() {
- if (predictor_options_ == UINT_MAX) {
- predictor_options_ =
- (base::FeatureList::IsEnabled(features::kKalmanHeuristics)
- ? KalmanPredictor::PredictionOptions::kHeuristicsEnabled
- : 0) |
- (base::FeatureList::IsEnabled(features::kKalmanDirectionCutOff)
- ? KalmanPredictor::PredictionOptions::kDirectionCutOffEnabled
- : 0);
- }
- return predictor_options_;
-}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/prediction/predictor_factory.h b/chromium/ui/events/blink/prediction/predictor_factory.h
deleted file mode 100644
index f36c9aebb21..00000000000
--- a/chromium/ui/events/blink/prediction/predictor_factory.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2019 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 UI_EVENTS_BLINK_PREDICTION_PREDICTOR_FACTORY_H_
-#define UI_EVENTS_BLINK_PREDICTION_PREDICTOR_FACTORY_H_
-
-#include "ui/events/blink/prediction/input_predictor.h"
-
-namespace ui {
-
-namespace input_prediction {
-
-extern const char kScrollPredictorNameLsq[];
-extern const char kScrollPredictorNameKalman[];
-extern const char kScrollPredictorNameLinearFirst[];
-extern const char kScrollPredictorNameLinearSecond[];
-extern const char kScrollPredictorNameLinearResampling[];
-extern const char kScrollPredictorNameEmpty[];
-
-enum class PredictorType {
- kScrollPredictorTypeLsq,
- kScrollPredictorTypeKalman,
- kScrollPredictorTypeLinearFirst,
- kScrollPredictorTypeLinearSecond,
- kScrollPredictorTypeLinearResampling,
- kScrollPredictorTypeEmpty
-};
-} // namespace input_prediction
-
-class PredictorFactory {
- public:
- // Returns the PredictorType associated to the given predictor
- // name if found, otherwise returns kScrollPredictorTypeEmpty
- static input_prediction::PredictorType GetPredictorTypeFromName(
- const std::string& predictor_name);
-
- // Returns the predictor designed by its type if found, otherwise returns
- // PredictorEmpty
- static std::unique_ptr<InputPredictor> GetPredictor(
- input_prediction::PredictorType predictor_type);
-
- // Returns the feature enabled kalman predictor options
- static unsigned int GetKalmanPredictorOptions();
-
- // Predictor options cache
- static unsigned int predictor_options_;
-
- private:
- PredictorFactory() = delete;
- ~PredictorFactory() = delete;
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_PREDICTION_PREDICTOR_FACTORY_H_
diff --git a/chromium/ui/events/blink/scroll_predictor.cc b/chromium/ui/events/blink/scroll_predictor.cc
deleted file mode 100644
index 499cefc5b53..00000000000
--- a/chromium/ui/events/blink/scroll_predictor.cc
+++ /dev/null
@@ -1,200 +0,0 @@
-// Copyright 2018 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 "ui/events/blink/scroll_predictor.h"
-
-#include "base/metrics/field_trial.h"
-#include "base/metrics/field_trial_params.h"
-#include "base/metrics/histogram_functions.h"
-#include "base/trace_event/trace_event.h"
-#include "ui/events/blink/prediction/predictor_factory.h"
-
-using blink::WebInputEvent;
-using blink::WebGestureEvent;
-
-namespace ui {
-
-ScrollPredictor::ScrollPredictor() {
- // Get the predictor from feature flags
- std::string predictor_name = GetFieldTrialParamValueByFeature(
- features::kResamplingScrollEvents, "predictor");
-
- if (predictor_name.empty())
- predictor_name = ui::input_prediction::kScrollPredictorNameLinearResampling;
-
- input_prediction::PredictorType predictor_type =
- ui::PredictorFactory::GetPredictorTypeFromName(predictor_name);
- predictor_ = ui::PredictorFactory::GetPredictor(predictor_type);
-
- filtering_enabled_ =
- base::FeatureList::IsEnabled(features::kFilteringScrollPrediction);
-
- if (filtering_enabled_) {
- // Get the filter from feature flags
- std::string filter_name = GetFieldTrialParamValueByFeature(
- features::kFilteringScrollPrediction, "filter");
-
- input_prediction::FilterType filter_type =
- filter_factory_->GetFilterTypeFromName(filter_name);
-
- filter_factory_ = std::make_unique<FilterFactory>(
- features::kFilteringScrollPrediction, predictor_type, filter_type);
-
- filter_ = filter_factory_->CreateFilter(filter_type, predictor_type);
- }
-}
-
-ScrollPredictor::~ScrollPredictor() = default;
-
-void ScrollPredictor::ResetOnGestureScrollBegin(const WebGestureEvent& event) {
- DCHECK(event.GetType() == WebInputEvent::kGestureScrollBegin);
- // Only do resampling for scroll on touchscreen.
- if (event.SourceDevice() == blink::WebGestureDevice::kTouchscreen) {
- should_resample_scroll_events_ = true;
- Reset();
- }
-}
-
-std::unique_ptr<EventWithCallback> ScrollPredictor::ResampleScrollEvents(
- std::unique_ptr<EventWithCallback> event_with_callback,
- base::TimeTicks frame_time) {
- if (!should_resample_scroll_events_)
- return event_with_callback;
-
- const EventWithCallback::OriginalEventList& original_events =
- event_with_callback->original_events();
-
- if (event_with_callback->event().GetType() ==
- WebInputEvent::kGestureScrollUpdate) {
- // TODO(eirage): When scroll events are coalesced with pinch, we can have
- // empty original event list. In that case, we can't use the original events
- // to update the prediction. We don't want to use the aggregated event to
- // update because of the event time stamp, so skip the prediction for now.
- if (original_events.empty())
- return event_with_callback;
-
- for (auto& coalesced_event : original_events)
- UpdatePrediction(coalesced_event.event_, frame_time);
-
- if (should_resample_scroll_events_)
- ResampleEvent(frame_time, event_with_callback->event_pointer(),
- event_with_callback->mutable_latency_info());
-
- metrics_handler_.EvaluatePrediction();
-
- } else if (event_with_callback->event().GetType() ==
- WebInputEvent::kGestureScrollEnd) {
- should_resample_scroll_events_ = false;
- }
-
- return event_with_callback;
-}
-
-void ScrollPredictor::Reset() {
- predictor_->Reset();
- if (filtering_enabled_)
- filter_->Reset();
- current_event_accumulated_delta_ = gfx::PointF();
- last_predicted_accumulated_delta_ = gfx::PointF();
- metrics_handler_.Reset();
-}
-
-void ScrollPredictor::UpdatePrediction(const WebScopedInputEvent& event,
- base::TimeTicks frame_time) {
- DCHECK(event->GetType() == WebInputEvent::kGestureScrollUpdate);
- const WebGestureEvent& gesture_event =
- static_cast<const WebGestureEvent&>(*event);
- // When fling, GSU is sending per frame, resampling is not needed.
- if (gesture_event.data.scroll_update.inertial_phase ==
- WebGestureEvent::InertialPhaseState::kMomentum) {
- should_resample_scroll_events_ = false;
- return;
- }
-
- current_event_accumulated_delta_.Offset(
- gesture_event.data.scroll_update.delta_x,
- gesture_event.data.scroll_update.delta_y);
- InputPredictor::InputData data = {current_event_accumulated_delta_,
- gesture_event.TimeStamp()};
-
- predictor_->Update(data);
-
- metrics_handler_.AddRealEvent(current_event_accumulated_delta_,
- gesture_event.TimeStamp(), frame_time,
- true /* Scrolling */);
-}
-
-void ScrollPredictor::ResampleEvent(base::TimeTicks frame_time,
- WebInputEvent* event,
- LatencyInfo* latency_info) {
- DCHECK(event->GetType() == WebInputEvent::kGestureScrollUpdate);
- WebGestureEvent* gesture_event = static_cast<WebGestureEvent*>(event);
-
- TRACE_EVENT_BEGIN1("input", "ScrollPredictor::ResampleScrollEvents",
- "OriginalDelta",
- gfx::PointF(gesture_event->data.scroll_update.delta_x,
- gesture_event->data.scroll_update.delta_y)
- .ToString());
- gfx::PointF predicted_accumulated_delta = current_event_accumulated_delta_;
-
- base::TimeDelta prediction_delta = frame_time - gesture_event->TimeStamp();
- bool predicted = false;
-
- // For resampling, we don't want to predict too far away because the result
- // will likely be inaccurate in that case. We cut off the prediction to the
- // maximum available for the current predictor
- prediction_delta = std::min(prediction_delta, predictor_->MaxResampleTime());
-
- base::TimeTicks prediction_time =
- gesture_event->TimeStamp() + prediction_delta;
-
- auto result = predictor_->GeneratePrediction(prediction_time);
- if (result) {
- predicted_accumulated_delta = result->pos;
- gesture_event->SetTimeStamp(result->time_stamp);
- predicted = true;
- }
-
- // Feed the filter with the first non-predicted events but only apply
- // filtering on predicted events
- gfx::PointF filtered_pos = predicted_accumulated_delta;
- if (filtering_enabled_ && filter_->Filter(prediction_time, &filtered_pos) &&
- predicted)
- predicted_accumulated_delta = filtered_pos;
-
- // If the last resampled GSU over predict the delta, new GSU might try to
- // scroll back to make up the difference, which cause the scroll to jump
- // back. So we set the new delta to 0 when predicted delta is in different
- // direction to the original event.
- gfx::Vector2dF new_delta =
- predicted_accumulated_delta - last_predicted_accumulated_delta_;
- gesture_event->data.scroll_update.delta_x =
- (new_delta.x() * gesture_event->data.scroll_update.delta_x < 0)
- ? 0
- : new_delta.x();
- gesture_event->data.scroll_update.delta_y =
- (new_delta.y() * gesture_event->data.scroll_update.delta_y < 0)
- ? 0
- : new_delta.y();
-
- // Sync the predicted delta_y to latency_info for AverageLag metric.
- latency_info->set_predicted_scroll_update_delta(new_delta.y());
-
- TRACE_EVENT_END1("input", "ScrollPredictor::ResampleScrollEvents",
- "PredictedDelta",
- gfx::PointF(gesture_event->data.scroll_update.delta_x,
- gesture_event->data.scroll_update.delta_y)
- .ToString());
- last_predicted_accumulated_delta_.Offset(
- gesture_event->data.scroll_update.delta_x,
- gesture_event->data.scroll_update.delta_y);
-
- if (predicted) {
- metrics_handler_.AddPredictedEvent(predicted_accumulated_delta,
- result->time_stamp, frame_time,
- true /* Scrolling */);
- }
-}
-
-} // namespace ui
diff --git a/chromium/ui/events/blink/scroll_predictor.h b/chromium/ui/events/blink/scroll_predictor.h
deleted file mode 100644
index 5cfdd9e5b02..00000000000
--- a/chromium/ui/events/blink/scroll_predictor.h
+++ /dev/null
@@ -1,90 +0,0 @@
-// Copyright 2018 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 UI_EVENTS_BLINK_SCROLL_PREDICTOR_H_
-#define UI_EVENTS_BLINK_SCROLL_PREDICTOR_H_
-
-#include <vector>
-
-#include "ui/events/base_event_utils.h"
-#include "ui/events/blink/event_with_callback.h"
-#include "ui/events/blink/prediction/filter_factory.h"
-#include "ui/events/blink/prediction/input_predictor.h"
-#include "ui/events/blink/prediction/prediction_metrics_handler.h"
-
-namespace ui {
-
-namespace test {
-class ScrollPredictorTest;
-}
-
-// This class handles resampling GestureScrollUpdate events on InputHandlerProxy
-// at |BeginFrame| signal, before events been dispatched. The predictor use
-// original events to update the prediction and align the aggregated event
-// timestamp and delta_x/y to the VSync time.
-class ScrollPredictor {
- public:
- // Select the predictor type from field trial params and initialize the
- // predictor.
- explicit ScrollPredictor();
- ~ScrollPredictor();
-
- // Reset the predictors on each GSB.
- void ResetOnGestureScrollBegin(const blink::WebGestureEvent& event);
-
- // Resampling GestureScrollUpdate events. Updates the prediction with events
- // in original events list, and apply the prediction to the aggregated GSU
- // event if enable_resampling is true.
- std::unique_ptr<EventWithCallback> ResampleScrollEvents(
- std::unique_ptr<EventWithCallback> event_with_callback,
- base::TimeTicks frame_time);
-
- private:
- friend class test::InputHandlerProxyEventQueueTest;
- friend class test::ScrollPredictorTest;
-
- // Reset predictor and clear accumulated delta. This should be called on
- // GestureScrollBegin.
- void Reset();
-
- // Update the prediction with GestureScrollUpdate deltaX and deltaY
- void UpdatePrediction(const WebScopedInputEvent& event,
- base::TimeTicks frame_time);
-
- // Apply resampled deltaX/deltaY to gesture events
- void ResampleEvent(base::TimeTicks frame_time,
- blink::WebInputEvent* event,
- LatencyInfo* latency_info);
-
- // Reports metrics scores UMA histogram based on the metrics defined
- // in |PredictionMetricsHandler|
- void EvaluatePrediction();
-
- std::unique_ptr<InputPredictor> predictor_;
- std::unique_ptr<InputFilter> filter_;
-
- std::unique_ptr<FilterFactory> filter_factory_;
-
- // Whether predicted scroll events should be filtered or not
- bool filtering_enabled_ = false;
-
- // Total scroll delta from original scroll update events, used for calculating
- // predictions. Reset on GestureScrollBegin.
- gfx::PointF current_event_accumulated_delta_;
- // Predicted accumulated delta from last vsync, use for calculating delta_x
- // and delta_y for the resampled/predicted event.
- gfx::PointF last_predicted_accumulated_delta_;
-
- // Whether current scroll event should be resampled.
- bool should_resample_scroll_events_ = false;
-
- // Handler used for evaluating the prediction
- PredictionMetricsHandler metrics_handler_;
-
- DISALLOW_COPY_AND_ASSIGN(ScrollPredictor);
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_SCROLL_PREDICTOR_H_
diff --git a/chromium/ui/events/blink/scroll_predictor_unittest.cc b/chromium/ui/events/blink/scroll_predictor_unittest.cc
deleted file mode 100644
index e8409d23eb4..00000000000
--- a/chromium/ui/events/blink/scroll_predictor_unittest.cc
+++ /dev/null
@@ -1,510 +0,0 @@
-// Copyright 2018 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 "ui/events/blink/scroll_predictor.h"
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/test/scoped_feature_list.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/events/blink/blink_event_util.h"
-#include "ui/events/blink/blink_features.h"
-#include "ui/events/blink/prediction/empty_filter.h"
-#include "ui/events/blink/prediction/empty_predictor.h"
-#include "ui/events/blink/prediction/filter_factory.h"
-#include "ui/events/blink/prediction/kalman_predictor.h"
-#include "ui/events/blink/prediction/least_squares_predictor.h"
-#include "ui/events/blink/prediction/linear_predictor.h"
-#include "ui/events/blink/prediction/predictor_factory.h"
-
-namespace ui {
-namespace test {
-namespace {
-
-using blink::WebGestureEvent;
-using blink::WebInputEvent;
-
-constexpr double kEpsilon = 0.001;
-
-} // namespace
-
-class ScrollPredictorTest : public testing::Test {
- public:
- ScrollPredictorTest() {}
-
- void SetUp() override {
- original_events_.clear();
- scroll_predictor_ = std::make_unique<ScrollPredictor>();
- scroll_predictor_->predictor_ = std::make_unique<EmptyPredictor>();
- }
-
- void SetUpLSQPredictor() {
- scroll_predictor_->predictor_ = std::make_unique<LeastSquaresPredictor>();
- }
-
- WebScopedInputEvent CreateGestureScrollUpdate(
- float delta_x = 0,
- float delta_y = 0,
- double time_delta_in_milliseconds = 0,
- WebGestureEvent::InertialPhaseState phase =
- WebGestureEvent::InertialPhaseState::kNonMomentum) {
- WebGestureEvent gesture(
- WebInputEvent::kGestureScrollUpdate, WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests() +
- base::TimeDelta::FromMillisecondsD(time_delta_in_milliseconds),
- blink::WebGestureDevice::kTouchscreen);
- gesture.data.scroll_update.delta_x = delta_x;
- gesture.data.scroll_update.delta_y = delta_y;
- gesture.data.scroll_update.inertial_phase = phase;
-
- original_events_.emplace_back(gesture.Clone(), LatencyInfo(),
- base::NullCallback());
-
- return gesture.Clone();
- }
-
- void CoalesceWith(const WebScopedInputEvent& new_event,
- WebScopedInputEvent& old_event) {
- Coalesce(*new_event, old_event.get());
- }
-
- void SendGestureScrollBegin() {
- WebGestureEvent gesture_begin(WebInputEvent::kGestureScrollBegin,
- WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests(),
- blink::WebGestureDevice::kTouchscreen);
- scroll_predictor_->ResetOnGestureScrollBegin(gesture_begin);
- }
-
- void HandleResampleScrollEvents(WebScopedInputEvent& event,
- double time_delta_in_milliseconds = 0) {
- std::unique_ptr<EventWithCallback> event_with_callback =
- std::make_unique<EventWithCallback>(std::move(event), LatencyInfo(),
- base::TimeTicks(),
- base::NullCallback());
- event_with_callback->original_events() = std::move(original_events_);
-
- event_with_callback = scroll_predictor_->ResampleScrollEvents(
- std::move(event_with_callback),
- WebInputEvent::GetStaticTimeStampForTests() +
- base::TimeDelta::FromMillisecondsD(time_delta_in_milliseconds));
-
- event = event_with_callback->event().Clone();
- }
-
- std::unique_ptr<ui::InputPredictor::InputData> PredictionAvailable(
- double time_delta_in_milliseconds = 0) {
- return scroll_predictor_->predictor_->GeneratePrediction(
- WebInputEvent::GetStaticTimeStampForTests() +
- base::TimeDelta::FromMillisecondsD(time_delta_in_milliseconds));
- }
-
- gfx::PointF GetLastAccumulatedDelta() {
- return scroll_predictor_->last_predicted_accumulated_delta_;
- }
-
- bool GetResamplingState() {
- return scroll_predictor_->should_resample_scroll_events_;
- }
-
- bool isFilteringEnabled() { return scroll_predictor_->filtering_enabled_; }
-
- void ConfigurePredictorFieldTrialAndInitialize(
- const base::Feature& feature,
- const std::string& predictor_type) {
- base::FieldTrialParams params;
- params["predictor"] = predictor_type;
- scoped_feature_list_.Reset();
- scoped_feature_list_.InitAndEnableFeatureWithParameters(feature, params);
- EXPECT_EQ(params["predictor"],
- GetFieldTrialParamValueByFeature(feature, "predictor"));
- scroll_predictor_ = std::make_unique<ScrollPredictor>();
- }
-
- void ConfigureFilterFieldTrialAndInitialize(const base::Feature& feature,
- const std::string& filter_name) {
- base::FieldTrialParams params;
- params["filter"] = filter_name;
-
- scoped_feature_list_.Reset();
- scoped_feature_list_.InitAndEnableFeatureWithParameters(feature, params);
- EXPECT_EQ(params["filter"],
- GetFieldTrialParamValueByFeature(feature, "filter"));
- scroll_predictor_ = std::make_unique<ScrollPredictor>();
- }
-
- void ConfigurePredictorAndFilterFieldTrialAndInitialize(
- const base::Feature& pred_feature,
- const std::string& predictor_type,
- const base::Feature& filter_feature,
- const std::string& filter_type) {
- base::FieldTrialParams pred_field_params;
- pred_field_params["predictor"] = predictor_type;
- base::test::ScopedFeatureList::FeatureAndParams prediction_params = {
- pred_feature, pred_field_params};
-
- base::FieldTrialParams filter_field_params;
- filter_field_params["filter"] = filter_type;
- base::test::ScopedFeatureList::FeatureAndParams filter_params = {
- filter_feature, filter_field_params};
-
- scoped_feature_list_.Reset();
- scoped_feature_list_.InitWithFeaturesAndParameters(
- {prediction_params, filter_params}, {});
-
- EXPECT_EQ(pred_field_params["predictor"],
- GetFieldTrialParamValueByFeature(pred_feature, "predictor"));
- EXPECT_EQ(filter_field_params["filter"],
- GetFieldTrialParamValueByFeature(filter_feature, "filter"));
-
- scroll_predictor_ = std::make_unique<ScrollPredictor>();
- }
-
- void VerifyPredictorType(const char* expected_type) {
- EXPECT_EQ(expected_type, scroll_predictor_->predictor_->GetName());
- }
-
- void VerifyFilterType(const char* expected_type) {
- EXPECT_EQ(expected_type, scroll_predictor_->filter_->GetName());
- }
-
- protected:
- EventWithCallback::OriginalEventList original_events_;
- std::unique_ptr<ScrollPredictor> scroll_predictor_;
-
- base::test::ScopedFeatureList scoped_feature_list_;
-
- DISALLOW_COPY_AND_ASSIGN(ScrollPredictorTest);
-};
-
-TEST_F(ScrollPredictorTest, ScrollResamplingStates) {
- // initial
- EXPECT_FALSE(GetResamplingState());
-
- // after GSB
- SendGestureScrollBegin();
- EXPECT_TRUE(GetResamplingState());
-
- // after GSU with no phase
- WebScopedInputEvent gesture_update =
- CreateGestureScrollUpdate(0, 10, 10 /* ms */);
- HandleResampleScrollEvents(gesture_update, 15 /* ms */);
- EXPECT_TRUE(GetResamplingState());
-
- // after GSU with momentum phase
- gesture_update = CreateGestureScrollUpdate(
- 0, 10, 10 /* ms */, WebGestureEvent::InertialPhaseState::kMomentum);
- HandleResampleScrollEvents(gesture_update, 15 /* ms */);
- EXPECT_FALSE(GetResamplingState());
-
- // after GSE
- WebGestureEvent gesture_end(WebInputEvent::kGestureScrollEnd,
- WebInputEvent::kNoModifiers,
- WebInputEvent::GetStaticTimeStampForTests(),
- blink::WebGestureDevice::kTouchscreen);
- WebScopedInputEvent event = gesture_end.Clone();
- HandleResampleScrollEvents(event);
- EXPECT_FALSE(GetResamplingState());
-}
-
-TEST_F(ScrollPredictorTest, ResampleGestureScrollEvents) {
- SendGestureScrollBegin();
- EXPECT_FALSE(PredictionAvailable());
-
- WebScopedInputEvent gesture_update = CreateGestureScrollUpdate(0, -20);
- HandleResampleScrollEvents(gesture_update);
- EXPECT_EQ(-20,
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y);
-
- // Aggregated event delta doesn't change with empty predictor applied.
- gesture_update = CreateGestureScrollUpdate(0, -20);
- CoalesceWith(CreateGestureScrollUpdate(0, -40), gesture_update);
- EXPECT_EQ(-60,
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y);
- HandleResampleScrollEvents(gesture_update);
- EXPECT_EQ(-60,
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y);
-
- // Cumulative amount of scroll from the GSB is stored in the empty predictor.
- auto result = PredictionAvailable();
- EXPECT_TRUE(result);
- EXPECT_EQ(-80, result->pos.y());
-
- // Send another GSB, Prediction will be reset.
- SendGestureScrollBegin();
- EXPECT_FALSE(PredictionAvailable());
-
- // Sent another GSU.
- gesture_update = CreateGestureScrollUpdate(0, -35);
- HandleResampleScrollEvents(gesture_update);
- EXPECT_EQ(-35,
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y);
- // Total amount of scroll is track from the last GSB.
- result = PredictionAvailable();
- EXPECT_TRUE(result);
- EXPECT_EQ(-35, result->pos.y());
-}
-
-TEST_F(ScrollPredictorTest, ScrollInDifferentDirection) {
- SendGestureScrollBegin();
-
- // Scroll down.
- WebScopedInputEvent gesture_update = CreateGestureScrollUpdate(0, -20);
- HandleResampleScrollEvents(gesture_update);
- EXPECT_EQ(-20,
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y);
- auto result = PredictionAvailable();
- EXPECT_TRUE(result);
- EXPECT_EQ(-20, result->pos.y());
-
- // Scroll up.
- gesture_update = CreateGestureScrollUpdate(0, 25);
- HandleResampleScrollEvents(gesture_update);
- EXPECT_EQ(0, static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_x);
- EXPECT_EQ(25, static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y);
- result = PredictionAvailable();
- EXPECT_TRUE(result);
- EXPECT_EQ(0, result->pos.x());
- EXPECT_EQ(5, result->pos.y());
-
- // Scroll left + right.
- gesture_update = CreateGestureScrollUpdate(-35, 0);
- CoalesceWith(CreateGestureScrollUpdate(60, 0), gesture_update);
- HandleResampleScrollEvents(gesture_update);
- EXPECT_EQ(25, static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_x);
- EXPECT_EQ(0, static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y);
- result = PredictionAvailable();
- EXPECT_TRUE(result);
- EXPECT_EQ(25, result->pos.x());
- EXPECT_EQ(5, result->pos.y());
-}
-
-TEST_F(ScrollPredictorTest, ScrollUpdateWithEmptyOriginalEventList) {
- SendGestureScrollBegin();
-
- // Send a GSU with empty original event list.
- WebScopedInputEvent gesture_update = CreateGestureScrollUpdate(0, -20);
- original_events_.clear();
- HandleResampleScrollEvents(gesture_update);
- EXPECT_EQ(-20,
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y);
-
- // No prediction available because the event is skipped.
- EXPECT_FALSE(PredictionAvailable());
-
- // Send a GSU with original event.
- gesture_update = CreateGestureScrollUpdate(0, -30);
- HandleResampleScrollEvents(gesture_update);
- EXPECT_EQ(-30,
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y);
-
- // Send another GSU with empty original event list.
- gesture_update = CreateGestureScrollUpdate(0, -40);
- original_events_.clear();
- HandleResampleScrollEvents(gesture_update);
- EXPECT_EQ(-40,
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y);
-
- // Prediction only track GSU with original event list.
- auto result = PredictionAvailable();
- EXPECT_TRUE(result);
- EXPECT_EQ(-30, result->pos.y());
-}
-
-TEST_F(ScrollPredictorTest, LSQPredictorTest) {
- SetUpLSQPredictor();
- SendGestureScrollBegin();
-
- // Send 1st GSU, no prediction available.
- WebScopedInputEvent gesture_update =
- CreateGestureScrollUpdate(0, -30, 8 /* ms */);
- HandleResampleScrollEvents(gesture_update, 16 /* ms */);
- EXPECT_FALSE(PredictionAvailable(16 /* ms */));
- EXPECT_EQ(-30,
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y);
- EXPECT_EQ(WebInputEvent::GetStaticTimeStampForTests() +
- base::TimeDelta::FromMillisecondsD(8 /* ms */),
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->TimeStamp());
-
- // Send 2nd GSU, no prediction available, event aligned at original timestamp.
- gesture_update = CreateGestureScrollUpdate(0, -30, 16 /* ms */);
- HandleResampleScrollEvents(gesture_update, 24 /* ms */);
- EXPECT_EQ(-30,
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y);
- EXPECT_EQ(WebInputEvent::GetStaticTimeStampForTests() +
- base::TimeDelta::FromMillisecondsD(16 /* ms */),
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->TimeStamp());
- EXPECT_FALSE(PredictionAvailable(24 /* ms */));
-
- // Send 3rd and 4th GSU, prediction result returns the sum of delta_y, event
- // aligned at frame time.
- gesture_update = CreateGestureScrollUpdate(0, -30, 24 /* ms */);
- HandleResampleScrollEvents(gesture_update, 32 /* ms */);
- EXPECT_EQ(-60,
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y);
- EXPECT_EQ(WebInputEvent::GetStaticTimeStampForTests() +
- base::TimeDelta::FromMillisecondsD(32 /* ms */),
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->TimeStamp());
- auto result = PredictionAvailable(32 /* ms */);
- EXPECT_TRUE(result);
- EXPECT_EQ(-120, result->pos.y());
-
- gesture_update = CreateGestureScrollUpdate(0, -30, 32 /* ms */);
- HandleResampleScrollEvents(gesture_update, 40 /* ms */);
- EXPECT_EQ(-30,
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y);
- EXPECT_EQ(WebInputEvent::GetStaticTimeStampForTests() +
- base::TimeDelta::FromMillisecondsD(40 /* ms */),
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->TimeStamp());
- result = PredictionAvailable(40 /* ms */);
- EXPECT_TRUE(result);
- EXPECT_EQ(-150, result->pos.y());
-}
-
-TEST_F(ScrollPredictorTest, ScrollPredictorNotChangeScrollDirection) {
- SetUpLSQPredictor();
- SendGestureScrollBegin();
-
- // Send 4 GSUs with delta_y = 10
- WebScopedInputEvent gesture_update =
- CreateGestureScrollUpdate(0, 10, 10 /* ms */);
- HandleResampleScrollEvents(gesture_update, 15 /* ms */);
- gesture_update = CreateGestureScrollUpdate(0, 10, 20 /* ms */);
- HandleResampleScrollEvents(gesture_update, 25 /* ms */);
- gesture_update = CreateGestureScrollUpdate(0, 10, 30 /* ms */);
- HandleResampleScrollEvents(gesture_update, 35 /* ms */);
- gesture_update = CreateGestureScrollUpdate(0, 10, 40 /* ms */);
- HandleResampleScrollEvents(gesture_update, 45 /* ms */);
- EXPECT_NEAR(10,
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y,
- kEpsilon);
- EXPECT_NEAR(45, GetLastAccumulatedDelta().y(), kEpsilon);
-
- // Send a GSU with delta_y = 2. So last resampled GSU we calculated is
- // overhead. No scroll back in this case.
- gesture_update = CreateGestureScrollUpdate(0, 2, 50 /* ms */);
- HandleResampleScrollEvents(gesture_update, 55 /* ms */);
- EXPECT_EQ(0, static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y);
- EXPECT_NEAR(45, GetLastAccumulatedDelta().y(), kEpsilon);
-
- // Send a GSU with different scroll direction. Resampled GSU is in the new
- // direction.
- gesture_update = CreateGestureScrollUpdate(0, -6, 60 /* ms */);
- HandleResampleScrollEvents(gesture_update, 60 /* ms */);
- EXPECT_NEAR(-9,
- static_cast<const blink::WebGestureEvent*>(gesture_update.get())
- ->data.scroll_update.delta_y,
- kEpsilon);
- EXPECT_NEAR(36, GetLastAccumulatedDelta().y(), kEpsilon);
-}
-
-TEST_F(ScrollPredictorTest, ScrollPredictorTypeSelection) {
- // Use LinearResampling predictor by default.
- scroll_predictor_ = std::make_unique<ScrollPredictor>();
- VerifyPredictorType(input_prediction::kScrollPredictorNameLinearResampling);
-
- // When resampling is enabled, predictor type is set from
- // kResamplingScrollEvents.
- ConfigurePredictorFieldTrialAndInitialize(
- features::kResamplingScrollEvents,
- input_prediction::kScrollPredictorNameEmpty);
- VerifyPredictorType(input_prediction::kScrollPredictorNameEmpty);
-
- ConfigurePredictorFieldTrialAndInitialize(
- features::kResamplingScrollEvents,
- input_prediction::kScrollPredictorNameLsq);
- VerifyPredictorType(input_prediction::kScrollPredictorNameLsq);
-
- ConfigurePredictorFieldTrialAndInitialize(
- features::kResamplingScrollEvents,
- input_prediction::kScrollPredictorNameKalman);
- VerifyPredictorType(input_prediction::kScrollPredictorNameKalman);
-
- ConfigurePredictorFieldTrialAndInitialize(
- features::kResamplingScrollEvents,
- input_prediction::kScrollPredictorNameLinearFirst);
- VerifyPredictorType(input_prediction::kScrollPredictorNameLinearFirst);
-}
-
-// Check the right filter is selected
-TEST_F(ScrollPredictorTest, DefaultFilter) {
- ConfigureFilterFieldTrialAndInitialize(features::kFilteringScrollPrediction,
- "");
- VerifyFilterType(input_prediction::kFilterNameEmpty);
- EXPECT_TRUE(isFilteringEnabled());
-
- ConfigureFilterFieldTrialAndInitialize(features::kFilteringScrollPrediction,
- input_prediction::kFilterNameEmpty);
- VerifyFilterType(input_prediction::kFilterNameEmpty);
- EXPECT_TRUE(isFilteringEnabled());
-
- ConfigureFilterFieldTrialAndInitialize(features::kFilteringScrollPrediction,
- input_prediction::kFilterNameOneEuro);
- VerifyFilterType(input_prediction::kFilterNameOneEuro);
- EXPECT_TRUE(isFilteringEnabled());
-}
-
-// We first send 100 events to the scroll predictor with kalman predictor
-// enabled and filetring disable and save the results.
-// We then send the same events with kalman and the empty filter, we should
-// expect the same results.
-TEST_F(ScrollPredictorTest, FilteringPrediction) {
- ConfigurePredictorFieldTrialAndInitialize(
- features::kResamplingScrollEvents,
- input_prediction::kScrollPredictorNameKalman);
-
- std::vector<double> accumulated_deltas;
- WebScopedInputEvent gesture_update;
-
- for (int i = 0; i < 100; i++) {
- // Create event at time 8*i
- gesture_update = CreateGestureScrollUpdate(0, 3 * i, 8 * i /* ms */);
- // Handle the event 5 ms later
- HandleResampleScrollEvents(gesture_update, 8 * i + 5 /* ms */);
- EXPECT_FALSE(isFilteringEnabled());
- accumulated_deltas.push_back(GetLastAccumulatedDelta().y());
- }
- EXPECT_EQ((int)accumulated_deltas.size(), 100);
-
- // Now we enable filtering and compare the deltas
- ConfigurePredictorAndFilterFieldTrialAndInitialize(
- features::kResamplingScrollEvents,
- input_prediction::kScrollPredictorNameKalman,
- features::kFilteringScrollPrediction, input_prediction::kFilterNameEmpty);
- scroll_predictor_ = std::make_unique<ScrollPredictor>();
-
- for (int i = 0; i < 100; i++) {
- // Create event at time 8*i
- gesture_update = CreateGestureScrollUpdate(0, 3 * i, 8 * i /* ms */);
- // Handle the event 5 ms later
- HandleResampleScrollEvents(gesture_update, 8 * i + 5 /* ms */);
- EXPECT_TRUE(isFilteringEnabled());
- EXPECT_NEAR(accumulated_deltas[i], GetLastAccumulatedDelta().y(), 0.00001);
- }
-}
-
-} // namespace test
-} // namespace ui
diff --git a/chromium/ui/events/blink/synchronous_input_handler_proxy.h b/chromium/ui/events/blink/synchronous_input_handler_proxy.h
deleted file mode 100644
index f5a2679f36b..00000000000
--- a/chromium/ui/events/blink/synchronous_input_handler_proxy.h
+++ /dev/null
@@ -1,62 +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 UI_EVENTS_BLINK_SYNCHRONOUS_INPUT_HANDLER_PROXY_H_
-#define UI_EVENTS_BLINK_SYNCHRONOUS_INPUT_HANDLER_PROXY_H_
-
-#include "base/time/time.h"
-
-namespace gfx {
-class Point;
-class ScrollOffset;
-class SizeF;
-}
-
-namespace ui {
-
-class SynchronousInputHandler {
- public:
- virtual ~SynchronousInputHandler() {}
-
- // Informs the Android WebView embedder of the current root scroll and page
- // scale state.
- virtual void UpdateRootLayerState(
- const gfx::ScrollOffset& total_scroll_offset,
- const gfx::ScrollOffset& max_scroll_offset,
- const gfx::SizeF& scrollable_size,
- float page_scale_factor,
- float min_page_scale_factor,
- float max_page_scale_factor) = 0;
-};
-
-// Android WebView requires synchronous scrolling from the WebView application.
-// This interface provides support for that behaviour. The WebView embedder will
-// act as the InputHandler for controlling the timing of input (fling)
-// animations.
-class SynchronousInputHandlerProxy {
- public:
- virtual ~SynchronousInputHandlerProxy() {}
-
- // SynchronousInputHandler needs to be informed of root layer updates.
- virtual void SetSynchronousInputHandler(
- SynchronousInputHandler* synchronous_input_handler) = 0;
-
- // Called when the synchronous input handler wants to change the root scroll
- // offset. Since it has the final say, this overrides values from compositor-
- // controlled behaviour. After the offset is applied, the
- // SynchronousInputHandler should be given back the result in case it differs
- // from what was sent.
- virtual void SynchronouslySetRootScrollOffset(
- const gfx::ScrollOffset& root_offset) = 0;
-
- // Similar to SetRootScrollOffset above, to control the zoom level, ie scale
- // factor. Note |magnify_delta| is an incremental rather than absolute value.
- // SynchronousInputHandler should be given back the resulting absolute value.
- virtual void SynchronouslyZoomBy(float magnify_delta,
- const gfx::Point& anchor) = 0;
-};
-
-} // namespace ui
-
-#endif // UI_EVENTS_BLINK_SYNCHRONOUS_INPUT_HANDLER_PROXY_H_
diff --git a/chromium/ui/events/blink/web_input_event.cc b/chromium/ui/events/blink/web_input_event.cc
index 4bb5c1aefdd..31834100d46 100644
--- a/chromium/ui/events/blink/web_input_event.cc
+++ b/chromium/ui/events/blink/web_input_event.cc
@@ -17,7 +17,7 @@
#endif
#if defined(USE_X11)
-#include "ui/gfx/x/x11.h"
+#include "ui/gfx/x/x11.h" // nogncheck
#endif
namespace ui {
@@ -29,24 +29,6 @@ gfx::PointF GetScreenLocationFromEvent(const LocatedEvent& event) {
: event.root_location_f();
}
-blink::WebPointerProperties::PointerType EventPointerTypeToWebPointerType(
- EventPointerType pointer_type) {
- switch (pointer_type) {
- case EventPointerType::POINTER_TYPE_UNKNOWN:
- return blink::WebPointerProperties::PointerType::kUnknown;
- case EventPointerType::POINTER_TYPE_MOUSE:
- return blink::WebPointerProperties::PointerType::kMouse;
- case EventPointerType::POINTER_TYPE_PEN:
- return blink::WebPointerProperties::PointerType::kPen;
- case EventPointerType::POINTER_TYPE_ERASER:
- return blink::WebPointerProperties::PointerType::kEraser;
- case EventPointerType::POINTER_TYPE_TOUCH:
- return blink::WebPointerProperties::PointerType::kTouch;
- }
- NOTREACHED() << "Unexpected EventPointerType";
- return blink::WebPointerProperties::PointerType::kUnknown;
-}
-
// Creates a WebGestureEvent from a GestureEvent. Note that it does not
// populate the event coordinates (i.e. |x|, |y|, |globalX|, and |globalY|). So
// the caller must populate these fields.
@@ -83,14 +65,14 @@ blink::WebMouseWheelEvent MakeUntranslatedWebMouseWheelEventFromNativeEvent(
#endif // defined(OS_WIN)
blink::WebKeyboardEvent MakeWebKeyboardEventFromUiEvent(const KeyEvent& event) {
- blink::WebInputEvent::Type type = blink::WebInputEvent::kUndefined;
+ blink::WebInputEvent::Type type = blink::WebInputEvent::Type::kUndefined;
switch (event.type()) {
case ET_KEY_PRESSED:
- type = event.is_char() ? blink::WebInputEvent::kChar
- : blink::WebInputEvent::kRawKeyDown;
+ type = event.is_char() ? blink::WebInputEvent::Type::kChar
+ : blink::WebInputEvent::Type::kRawKeyDown;
break;
case ET_KEY_RELEASED:
- type = blink::WebInputEvent::kKeyUp;
+ type = blink::WebInputEvent::Type::kKeyUp;
break;
default:
NOTREACHED();
@@ -118,7 +100,7 @@ blink::WebKeyboardEvent MakeWebKeyboardEventFromUiEvent(const KeyEvent& event) {
blink::WebMouseWheelEvent MakeWebMouseWheelEventFromUiEvent(
const ScrollEvent& event) {
blink::WebMouseWheelEvent webkit_event(
- blink::WebInputEvent::kMouseWheel,
+ blink::WebInputEvent::Type::kMouseWheel,
EventFlagsToWebEventModifiers(event.flags()), event.time_stamp());
webkit_event.button = blink::WebMouseEvent::Button::kNoButton;
@@ -138,8 +120,7 @@ blink::WebMouseWheelEvent MakeWebMouseWheelEventFromUiEvent(
if (offset_ordinal_y != 0.f && webkit_event.delta_y != 0.f)
webkit_event.acceleration_ratio_y = offset_ordinal_y / webkit_event.delta_y;
- webkit_event.pointer_type =
- EventPointerTypeToWebPointerType(event.pointer_details().pointer_type);
+ webkit_event.pointer_type = event.pointer_details().pointer_type;
switch (event.scroll_event_phase()) {
case ui::ScrollEventPhase::kNone:
@@ -186,13 +167,13 @@ blink::WebMouseWheelEvent MakeWebMouseWheelEventFromUiEvent(
blink::WebGestureEvent MakeWebGestureEventFromUiEvent(
const ScrollEvent& event) {
- blink::WebInputEvent::Type type = blink::WebInputEvent::kUndefined;
+ blink::WebInputEvent::Type type = blink::WebInputEvent::Type::kUndefined;
switch (event.type()) {
case ET_SCROLL_FLING_START:
- type = blink::WebInputEvent::kGestureFlingStart;
+ type = blink::WebInputEvent::Type::kGestureFlingStart;
break;
case ET_SCROLL_FLING_CANCEL:
- type = blink::WebInputEvent::kGestureFlingCancel;
+ type = blink::WebInputEvent::Type::kGestureFlingCancel;
break;
case ET_SCROLL:
NOTREACHED() << "Invalid gesture type: " << event.type();
@@ -248,8 +229,7 @@ blink::WebMouseEvent MakeWebMouseEvent(const MouseEvent& event) {
event.native_event().message && (event.type() != ET_MOUSE_EXITED)
? MakeUntranslatedWebMouseEventFromNativeEvent(
event.native_event(), event.time_stamp(),
- EventPointerTypeToWebPointerType(
- event.pointer_details().pointer_type))
+ event.pointer_details().pointer_type)
: MakeWebMouseEventFromUiEvent(event);
#else
MakeWebMouseEventFromUiEvent(event);
@@ -281,8 +261,7 @@ blink::WebMouseWheelEvent MakeWebMouseWheelEvent(const MouseWheelEvent& event) {
event.native_event().message
? MakeUntranslatedWebMouseWheelEventFromNativeEvent(
event.native_event(), event.time_stamp(),
- EventPointerTypeToWebPointerType(
- event.pointer_details().pointer_type))
+ event.pointer_details().pointer_type)
: MakeWebMouseWheelEventFromUiEvent(event);
#else
blink::WebMouseWheelEvent webkit_event =
@@ -306,8 +285,7 @@ blink::WebMouseWheelEvent MakeWebMouseWheelEvent(const ScrollEvent& event) {
event.native_event().message
? MakeUntranslatedWebMouseWheelEventFromNativeEvent(
event.native_event(), event.time_stamp(),
- EventPointerTypeToWebPointerType(
- event.pointer_details().pointer_type))
+ event.pointer_details().pointer_type)
: MakeWebMouseWheelEventFromUiEvent(event);
#else
blink::WebMouseWheelEvent webkit_event =
@@ -373,7 +351,7 @@ blink::WebGestureEvent MakeWebGestureEvent(const ScrollEvent& event) {
blink::WebGestureEvent MakeWebGestureEventFlingCancel(
const blink::WebMouseWheelEvent& wheel_event) {
blink::WebGestureEvent gesture_event(
- blink::WebInputEvent::kGestureFlingCancel,
+ blink::WebInputEvent::Type::kGestureFlingCancel,
blink::WebInputEvent::kNoModifiers, wheel_event.TimeStamp(),
blink::WebGestureDevice::kTouchpad);
// Coordinates need to be transferred to the fling cancel gesture only
@@ -386,15 +364,15 @@ blink::WebGestureEvent MakeWebGestureEventFlingCancel(
}
blink::WebMouseEvent MakeWebMouseEventFromUiEvent(const MouseEvent& event) {
- blink::WebInputEvent::Type type = blink::WebInputEvent::kUndefined;
+ blink::WebInputEvent::Type type = blink::WebInputEvent::Type::kUndefined;
int click_count = 0;
switch (event.type()) {
case ET_MOUSE_PRESSED:
- type = blink::WebInputEvent::kMouseDown;
+ type = blink::WebInputEvent::Type::kMouseDown;
click_count = event.GetClickCount();
break;
case ET_MOUSE_RELEASED:
- type = blink::WebInputEvent::kMouseUp;
+ type = blink::WebInputEvent::Type::kMouseUp;
click_count = event.GetClickCount();
break;
case ET_MOUSE_EXITED: {
@@ -402,19 +380,19 @@ blink::WebMouseEvent MakeWebMouseEventFromUiEvent(const MouseEvent& event) {
// pointer crosses through, change these into mouse move events.
const Event::Properties* props = event.properties();
if (props && props->contains(kPropertyMouseCrossedIntermediateWindow)) {
- type = blink::WebInputEvent::kMouseMove;
+ type = blink::WebInputEvent::Type::kMouseMove;
} else {
static bool s_send_leave =
base::FeatureList::IsEnabled(features::kSendMouseLeaveEvents);
- type = s_send_leave ? blink::WebInputEvent::kMouseLeave
- : blink::WebInputEvent::kMouseMove;
+ type = s_send_leave ? blink::WebInputEvent::Type::kMouseLeave
+ : blink::WebInputEvent::Type::kMouseMove;
}
break;
}
case ET_MOUSE_ENTERED:
case ET_MOUSE_MOVED:
case ET_MOUSE_DRAGGED:
- type = blink::WebInputEvent::kMouseMove;
+ type = blink::WebInputEvent::Type::kMouseMove;
break;
default:
NOTIMPLEMENTED() << "Received unexpected event: " << event.type();
@@ -456,8 +434,7 @@ blink::WebMouseEvent MakeWebMouseEventFromUiEvent(const MouseEvent& event) {
event.pointer_details().tangential_pressure;
webkit_event.twist = event.pointer_details().twist;
webkit_event.id = event.pointer_details().id;
- webkit_event.pointer_type =
- EventPointerTypeToWebPointerType(event.pointer_details().pointer_type);
+ webkit_event.pointer_type = event.pointer_details().pointer_type;
return webkit_event;
}
@@ -465,7 +442,7 @@ blink::WebMouseEvent MakeWebMouseEventFromUiEvent(const MouseEvent& event) {
blink::WebMouseWheelEvent MakeWebMouseWheelEventFromUiEvent(
const MouseWheelEvent& event) {
blink::WebMouseWheelEvent webkit_event(
- blink::WebInputEvent::kMouseWheel,
+ blink::WebInputEvent::Type::kMouseWheel,
EventFlagsToWebEventModifiers(event.flags()), event.time_stamp());
webkit_event.button = blink::WebMouseEvent::Button::kNoButton;
@@ -490,8 +467,7 @@ blink::WebMouseWheelEvent MakeWebMouseWheelEventFromUiEvent(
webkit_event.tilt_x = roundf(event.pointer_details().tilt_x);
webkit_event.tilt_y = roundf(event.pointer_details().tilt_y);
webkit_event.force = event.pointer_details().force;
- webkit_event.pointer_type =
- EventPointerTypeToWebPointerType(event.pointer_details().pointer_type);
+ webkit_event.pointer_type = event.pointer_details().pointer_type;
return webkit_event;
}
diff --git a/chromium/ui/events/blink/web_input_event_builders_win.cc b/chromium/ui/events/blink/web_input_event_builders_win.cc
index 34a2ee73d34..619602f3fb6 100644
--- a/chromium/ui/events/blink/web_input_event_builders_win.cc
+++ b/chromium/ui/events/blink/web_input_event_builders_win.cc
@@ -44,7 +44,7 @@ WebMouseEvent WebMouseEventBuilder::Build(
WebMouseEvent::Button button = WebMouseEvent::Button::kNoButton;
switch (message) {
case WM_MOUSEMOVE:
- type = WebInputEvent::kMouseMove;
+ type = WebInputEvent::Type::kMouseMove;
if (wparam & MK_LBUTTON)
button = WebMouseEvent::Button::kLeft;
else if (wparam & MK_MBUTTON)
@@ -58,7 +58,7 @@ WebMouseEvent WebMouseEventBuilder::Build(
case WM_NCMOUSELEAVE:
// TODO(rbyers): This should be MouseLeave but is disabled temporarily.
// See http://crbug.com/450631
- type = WebInputEvent::kMouseMove;
+ type = WebInputEvent::Type::kMouseMove;
button = WebMouseEvent::Button::kNoButton;
// set the current mouse position (relative to the client area of the
// current window) since none is specified for this event
@@ -66,41 +66,41 @@ WebMouseEvent WebMouseEventBuilder::Build(
break;
case WM_LBUTTONDOWN:
case WM_LBUTTONDBLCLK:
- type = WebInputEvent::kMouseDown;
+ type = WebInputEvent::Type::kMouseDown;
button = WebMouseEvent::Button::kLeft;
break;
case WM_MBUTTONDOWN:
case WM_MBUTTONDBLCLK:
- type = WebInputEvent::kMouseDown;
+ type = WebInputEvent::Type::kMouseDown;
button = WebMouseEvent::Button::kMiddle;
break;
case WM_RBUTTONDOWN:
case WM_RBUTTONDBLCLK:
- type = WebInputEvent::kMouseDown;
+ type = WebInputEvent::Type::kMouseDown;
button = WebMouseEvent::Button::kRight;
break;
case WM_XBUTTONDOWN:
case WM_XBUTTONDBLCLK:
- type = WebInputEvent::kMouseDown;
+ type = WebInputEvent::Type::kMouseDown;
if ((HIWORD(wparam) & XBUTTON1))
button = WebMouseEvent::Button::kBack;
else if ((HIWORD(wparam) & XBUTTON2))
button = WebMouseEvent::Button::kForward;
break;
case WM_LBUTTONUP:
- type = WebInputEvent::kMouseUp;
+ type = WebInputEvent::Type::kMouseUp;
button = WebMouseEvent::Button::kLeft;
break;
case WM_MBUTTONUP:
- type = WebInputEvent::kMouseUp;
+ type = WebInputEvent::Type::kMouseUp;
button = WebMouseEvent::Button::kMiddle;
break;
case WM_RBUTTONUP:
- type = WebInputEvent::kMouseUp;
+ type = WebInputEvent::Type::kMouseUp;
button = WebMouseEvent::Button::kRight;
break;
case WM_XBUTTONUP:
- type = WebInputEvent::kMouseUp;
+ type = WebInputEvent::Type::kMouseUp;
if ((HIWORD(wparam) & XBUTTON1))
button = WebMouseEvent::Button::kBack;
else if ((HIWORD(wparam) & XBUTTON2))
@@ -162,7 +162,7 @@ WebMouseEvent WebMouseEventBuilder::Build(
((current_time - g_last_click_time).InMilliseconds() >
::GetDoubleClickTime());
- if (result.GetType() == WebInputEvent::kMouseDown) {
+ if (result.GetType() == WebInputEvent::Type::kMouseDown) {
if (!cancel_previous_click && (result.button == last_click_button)) {
++g_last_click_count;
} else {
@@ -172,8 +172,8 @@ WebMouseEvent WebMouseEventBuilder::Build(
}
g_last_click_time = current_time;
last_click_button = result.button;
- } else if (result.GetType() == WebInputEvent::kMouseMove ||
- result.GetType() == WebInputEvent::kMouseLeave) {
+ } else if (result.GetType() == WebInputEvent::Type::kMouseMove ||
+ result.GetType() == WebInputEvent::Type::kMouseLeave) {
if (cancel_previous_click) {
g_last_click_count = 0;
last_click_position_x = 0;
@@ -196,7 +196,7 @@ WebMouseWheelEvent WebMouseWheelEventBuilder::Build(
base::TimeTicks time_stamp,
blink::WebPointerProperties::PointerType pointer_type) {
WebMouseWheelEvent result(
- WebInputEvent::kMouseWheel,
+ WebInputEvent::Type::kMouseWheel,
ui::EventFlagsToWebEventModifiers(ui::GetModifiersFromKeyState()),
time_stamp);
diff --git a/chromium/ui/events/blink/web_input_event_traits.cc b/chromium/ui/events/blink/web_input_event_traits.cc
index 19bd615be35..218cb7b1f1b 100644
--- a/chromium/ui/events/blink/web_input_event_traits.cc
+++ b/chromium/ui/events/blink/web_input_event_traits.cc
@@ -4,7 +4,8 @@
#include "ui/events/blink/web_input_event_traits.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/strings/stringprintf.h"
#include "third_party/blink/public/common/input/web_gesture_event.h"
#include "third_party/blink/public/common/input/web_keyboard_event.h"
@@ -127,7 +128,7 @@ bool Apply(Operator op,
return op.template Execute<WebPointerEvent>(arg_in, arg_out);
else if (WebInputEvent::IsMouseEventType(type))
return op.template Execute<WebMouseEvent>(arg_in, arg_out);
- else if (type == WebInputEvent::kMouseWheel)
+ else if (type == WebInputEvent::Type::kMouseWheel)
return op.template Execute<WebMouseWheelEvent>(arg_in, arg_out);
else if (WebInputEvent::IsKeyboardEventType(type))
return op.template Execute<WebKeyboardEvent>(arg_in, arg_out);
@@ -150,42 +151,42 @@ std::string WebInputEventTraits::ToString(const WebInputEvent& event) {
bool WebInputEventTraits::ShouldBlockEventStream(const WebInputEvent& event) {
switch (event.GetType()) {
- case WebInputEvent::kContextMenu:
- case WebInputEvent::kGestureScrollEnd:
- case WebInputEvent::kGestureShowPress:
- case WebInputEvent::kGestureTapUnconfirmed:
- case WebInputEvent::kGestureTapDown:
- case WebInputEvent::kGestureTapCancel:
- case WebInputEvent::kGesturePinchBegin:
- case WebInputEvent::kGesturePinchUpdate:
- case WebInputEvent::kGesturePinchEnd:
+ case WebInputEvent::Type::kContextMenu:
+ case WebInputEvent::Type::kGestureScrollEnd:
+ case WebInputEvent::Type::kGestureShowPress:
+ case WebInputEvent::Type::kGestureTapUnconfirmed:
+ case WebInputEvent::Type::kGestureTapDown:
+ case WebInputEvent::Type::kGestureTapCancel:
+ case WebInputEvent::Type::kGesturePinchBegin:
+ case WebInputEvent::Type::kGesturePinchUpdate:
+ case WebInputEvent::Type::kGesturePinchEnd:
return false;
- case WebInputEvent::kGestureScrollBegin:
+ case WebInputEvent::Type::kGestureScrollBegin:
return true;
// TouchCancel and TouchScrollStarted should always be non-blocking.
- case WebInputEvent::kTouchCancel:
- case WebInputEvent::kTouchScrollStarted:
- DCHECK_NE(WebInputEvent::kBlocking,
+ case WebInputEvent::Type::kTouchCancel:
+ case WebInputEvent::Type::kTouchScrollStarted:
+ DCHECK_NE(WebInputEvent::DispatchType::kBlocking,
static_cast<const WebTouchEvent&>(event).dispatch_type);
return false;
// Touch start and touch end indicate whether they are non-blocking
// (aka uncancelable) on the event.
- case WebInputEvent::kTouchStart:
- case WebInputEvent::kTouchEnd:
+ case WebInputEvent::Type::kTouchStart:
+ case WebInputEvent::Type::kTouchEnd:
return static_cast<const WebTouchEvent&>(event).dispatch_type ==
- WebInputEvent::kBlocking;
+ WebInputEvent::DispatchType::kBlocking;
- case WebInputEvent::kTouchMove:
+ case WebInputEvent::Type::kTouchMove:
// Non-blocking touch moves can be ack'd right away.
return static_cast<const WebTouchEvent&>(event).dispatch_type ==
- WebInputEvent::kBlocking;
+ WebInputEvent::DispatchType::kBlocking;
- case WebInputEvent::kMouseWheel:
+ case WebInputEvent::Type::kMouseWheel:
return static_cast<const WebMouseWheelEvent&>(event).dispatch_type ==
- WebInputEvent::kBlocking;
+ WebInputEvent::DispatchType::kBlocking;
default:
return true;
@@ -206,8 +207,8 @@ LatencyInfo WebInputEventTraits::CreateLatencyInfoForWebGestureEvent(
SourceEventType source_event_type = SourceEventType::UNKNOWN;
if (event.SourceDevice() == blink::WebGestureDevice::kTouchpad) {
source_event_type = SourceEventType::WHEEL;
- if (event.GetType() >= blink::WebInputEvent::kGesturePinchTypeFirst &&
- event.GetType() <= blink::WebInputEvent::kGesturePinchTypeLast) {
+ if (event.GetType() >= blink::WebInputEvent::Type::kGesturePinchTypeFirst &&
+ event.GetType() <= blink::WebInputEvent::Type::kGesturePinchTypeLast) {
source_event_type = SourceEventType::TOUCHPAD;
}
} else if (event.SourceDevice() == blink::WebGestureDevice::kTouchscreen) {
@@ -215,13 +216,13 @@ LatencyInfo WebInputEventTraits::CreateLatencyInfoForWebGestureEvent(
blink::WebGestureEvent::InertialPhaseState::kUnknownMomentum;
switch (event.GetType()) {
- case blink::WebInputEvent::kGestureScrollBegin:
+ case blink::WebInputEvent::Type::kGestureScrollBegin:
inertial_phase_state = event.data.scroll_begin.inertial_phase;
break;
- case blink::WebInputEvent::kGestureScrollUpdate:
+ case blink::WebInputEvent::Type::kGestureScrollUpdate:
inertial_phase_state = event.data.scroll_update.inertial_phase;
break;
- case blink::WebInputEvent::kGestureScrollEnd:
+ case blink::WebInputEvent::Type::kGestureScrollEnd:
inertial_phase_state = event.data.scroll_end.inertial_phase;
break;
default:
diff --git a/chromium/ui/events/blink/web_input_event_traits_unittest.cc b/chromium/ui/events/blink/web_input_event_traits_unittest.cc
index 0311039198e..6a81db95c0a 100644
--- a/chromium/ui/events/blink/web_input_event_traits_unittest.cc
+++ b/chromium/ui/events/blink/web_input_event_traits_unittest.cc
@@ -25,26 +25,29 @@ using WebInputEventTraitsTest = testing::Test;
// Very basic smoke test to ensure stringification doesn't explode.
TEST_F(WebInputEventTraitsTest, ToString) {
- WebKeyboardEvent key(WebInputEvent::kRawKeyDown, WebInputEvent::kNoModifiers,
+ WebKeyboardEvent key(WebInputEvent::Type::kRawKeyDown,
+ WebInputEvent::kNoModifiers,
WebInputEvent::GetStaticTimeStampForTests());
EXPECT_FALSE(WebInputEventTraits::ToString(key).empty());
- WebMouseEvent mouse(WebInputEvent::kMouseMove, WebInputEvent::kNoModifiers,
+ WebMouseEvent mouse(WebInputEvent::Type::kMouseMove,
+ WebInputEvent::kNoModifiers,
WebInputEvent::GetStaticTimeStampForTests());
EXPECT_FALSE(WebInputEventTraits::ToString(mouse).empty());
- WebMouseWheelEvent mouse_wheel(WebInputEvent::kMouseWheel,
+ WebMouseWheelEvent mouse_wheel(WebInputEvent::Type::kMouseWheel,
WebInputEvent::kNoModifiers,
WebInputEvent::GetStaticTimeStampForTests());
EXPECT_FALSE(WebInputEventTraits::ToString(mouse_wheel).empty());
- WebGestureEvent gesture(WebInputEvent::kGesturePinchBegin,
+ WebGestureEvent gesture(WebInputEvent::Type::kGesturePinchBegin,
WebInputEvent::kNoModifiers,
WebInputEvent::GetStaticTimeStampForTests());
gesture.SetPositionInWidget(gfx::PointF(1, 1));
EXPECT_FALSE(WebInputEventTraits::ToString(gesture).empty());
- WebTouchEvent touch(WebInputEvent::kTouchStart, WebInputEvent::kNoModifiers,
+ WebTouchEvent touch(WebInputEvent::Type::kTouchStart,
+ WebInputEvent::kNoModifiers,
WebInputEvent::GetStaticTimeStampForTests());
touch.touches_length = 1;
EXPECT_FALSE(WebInputEventTraits::ToString(touch).empty());
diff --git a/chromium/ui/events/blink/web_input_event_unittest.cc b/chromium/ui/events/blink/web_input_event_unittest.cc
index fdc1ff3c581..177e0c7c82f 100644
--- a/chromium/ui/events/blink/web_input_event_unittest.cc
+++ b/chromium/ui/events/blink/web_input_event_unittest.cc
@@ -252,7 +252,7 @@ TEST(WebInputEventTest, TestMakeWebMouseEvent) {
webkit_event.GetModifiers());
EXPECT_EQ(timestamp, webkit_event.TimeStamp());
EXPECT_EQ(blink::WebMouseEvent::Button::kLeft, webkit_event.button);
- EXPECT_EQ(blink::WebInputEvent::kMouseDown, webkit_event.GetType());
+ EXPECT_EQ(blink::WebInputEvent::Type::kMouseDown, webkit_event.GetType());
EXPECT_EQ(ui_event.GetClickCount(), webkit_event.click_count);
EXPECT_EQ(123, webkit_event.PositionInWidget().x());
EXPECT_EQ(321, webkit_event.PositionInWidget().y());
@@ -268,7 +268,7 @@ TEST(WebInputEventTest, TestMakeWebMouseEvent) {
webkit_event.GetModifiers());
EXPECT_EQ(timestamp, webkit_event.TimeStamp());
EXPECT_EQ(blink::WebMouseEvent::Button::kLeft, webkit_event.button);
- EXPECT_EQ(blink::WebInputEvent::kMouseUp, webkit_event.GetType());
+ EXPECT_EQ(blink::WebInputEvent::Type::kMouseUp, webkit_event.GetType());
EXPECT_EQ(ui_event.GetClickCount(), webkit_event.click_count);
EXPECT_EQ(123, webkit_event.PositionInWidget().x());
EXPECT_EQ(321, webkit_event.PositionInWidget().y());
@@ -284,7 +284,7 @@ TEST(WebInputEventTest, TestMakeWebMouseEvent) {
webkit_event.GetModifiers());
EXPECT_EQ(timestamp, webkit_event.TimeStamp());
EXPECT_EQ(blink::WebMouseEvent::Button::kMiddle, webkit_event.button);
- EXPECT_EQ(blink::WebInputEvent::kMouseDown, webkit_event.GetType());
+ EXPECT_EQ(blink::WebInputEvent::Type::kMouseDown, webkit_event.GetType());
EXPECT_EQ(ui_event.GetClickCount(), webkit_event.click_count);
EXPECT_EQ(123, webkit_event.PositionInWidget().x());
EXPECT_EQ(321, webkit_event.PositionInWidget().y());
@@ -300,7 +300,7 @@ TEST(WebInputEventTest, TestMakeWebMouseEvent) {
webkit_event.GetModifiers());
EXPECT_EQ(timestamp, webkit_event.TimeStamp());
EXPECT_EQ(blink::WebMouseEvent::Button::kMiddle, webkit_event.button);
- EXPECT_EQ(blink::WebInputEvent::kMouseUp, webkit_event.GetType());
+ EXPECT_EQ(blink::WebInputEvent::Type::kMouseUp, webkit_event.GetType());
EXPECT_EQ(ui_event.GetClickCount(), webkit_event.click_count);
EXPECT_EQ(123, webkit_event.PositionInWidget().x());
EXPECT_EQ(321, webkit_event.PositionInWidget().y());
@@ -316,7 +316,7 @@ TEST(WebInputEventTest, TestMakeWebMouseEvent) {
webkit_event.GetModifiers());
EXPECT_EQ(timestamp, webkit_event.TimeStamp());
EXPECT_EQ(blink::WebMouseEvent::Button::kRight, webkit_event.button);
- EXPECT_EQ(blink::WebInputEvent::kMouseDown, webkit_event.GetType());
+ EXPECT_EQ(blink::WebInputEvent::Type::kMouseDown, webkit_event.GetType());
EXPECT_EQ(ui_event.GetClickCount(), webkit_event.click_count);
EXPECT_EQ(123, webkit_event.PositionInWidget().x());
EXPECT_EQ(321, webkit_event.PositionInWidget().y());
@@ -332,7 +332,7 @@ TEST(WebInputEventTest, TestMakeWebMouseEvent) {
webkit_event.GetModifiers());
EXPECT_EQ(timestamp, webkit_event.TimeStamp());
EXPECT_EQ(blink::WebMouseEvent::Button::kRight, webkit_event.button);
- EXPECT_EQ(blink::WebInputEvent::kMouseUp, webkit_event.GetType());
+ EXPECT_EQ(blink::WebInputEvent::Type::kMouseUp, webkit_event.GetType());
EXPECT_EQ(ui_event.GetClickCount(), webkit_event.click_count);
EXPECT_EQ(123, webkit_event.PositionInWidget().x());
EXPECT_EQ(321, webkit_event.PositionInWidget().y());
@@ -347,7 +347,7 @@ TEST(WebInputEventTest, TestMakeWebMouseEvent) {
webkit_event.GetModifiers());
EXPECT_EQ(timestamp, webkit_event.TimeStamp());
EXPECT_EQ(blink::WebMouseEvent::Button::kNoButton, webkit_event.button);
- EXPECT_EQ(blink::WebInputEvent::kMouseMove, webkit_event.GetType());
+ EXPECT_EQ(blink::WebInputEvent::Type::kMouseMove, webkit_event.GetType());
EXPECT_EQ(ui_event.GetClickCount(), webkit_event.click_count);
EXPECT_EQ(123, webkit_event.PositionInWidget().x());
EXPECT_EQ(321, webkit_event.PositionInWidget().y());
@@ -363,7 +363,7 @@ TEST(WebInputEventTest, TestMakeWebMouseEvent) {
webkit_event.GetModifiers());
EXPECT_EQ(timestamp, webkit_event.TimeStamp());
EXPECT_EQ(blink::WebMouseEvent::Button::kLeft, webkit_event.button);
- EXPECT_EQ(blink::WebInputEvent::kMouseMove, webkit_event.GetType());
+ EXPECT_EQ(blink::WebInputEvent::Type::kMouseMove, webkit_event.GetType());
EXPECT_EQ(ui_event.GetClickCount(), webkit_event.click_count);
EXPECT_EQ(123, webkit_event.PositionInWidget().x());
EXPECT_EQ(321, webkit_event.PositionInWidget().y());
@@ -379,7 +379,7 @@ TEST(WebInputEventTest, TestMakeWebMouseEvent) {
webkit_event.GetModifiers());
EXPECT_EQ(timestamp, webkit_event.TimeStamp());
EXPECT_EQ(blink::WebMouseEvent::Button::kLeft, webkit_event.button);
- EXPECT_EQ(blink::WebInputEvent::kMouseDown, webkit_event.GetType());
+ EXPECT_EQ(blink::WebInputEvent::Type::kMouseDown, webkit_event.GetType());
EXPECT_EQ(ui_event.GetClickCount(), webkit_event.click_count);
EXPECT_EQ(123, webkit_event.PositionInWidget().x());
EXPECT_EQ(321, webkit_event.PositionInWidget().y());
@@ -405,7 +405,7 @@ TEST(WebInputEventTest, TestMakeWebMouseEvent) {
{
// Stylus values for PointerDetails.
base::TimeTicks timestamp = EventTimeForNow();
- PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN,
+ PointerDetails pointer_details(EventPointerType::kPen,
/* id */ 63,
/* radius_x */ 0.0f,
/* radius_y */ 0.0f,
@@ -445,7 +445,7 @@ TEST(WebInputEventTest, TestMakeWebMouseWheelEvent) {
webkit_event.GetModifiers());
EXPECT_EQ(timestamp, webkit_event.TimeStamp());
EXPECT_EQ(blink::WebMouseEvent::Button::kNoButton, webkit_event.button);
- EXPECT_EQ(blink::WebInputEvent::kMouseWheel, webkit_event.GetType());
+ EXPECT_EQ(blink::WebInputEvent::Type::kMouseWheel, webkit_event.GetType());
EXPECT_FLOAT_EQ(ui_event.x_offset() / MouseWheelEvent::kWheelDelta,
webkit_event.wheel_ticks_x);
EXPECT_FLOAT_EQ(ui_event.y_offset() / MouseWheelEvent::kWheelDelta,
@@ -471,13 +471,13 @@ TEST(WebInputEventTest, KeyEvent) {
int web_modifiers;
} tests[] = {
{ui::KeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE),
- blink::WebInputEvent::kRawKeyDown, 0x0},
+ blink::WebInputEvent::Type::kRawKeyDown, 0x0},
{ui::KeyEvent(L'B', ui::VKEY_B, ui::DomCode::NONE,
ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN),
- blink::WebInputEvent::kChar,
+ blink::WebInputEvent::Type::kChar,
blink::WebInputEvent::kShiftKey | blink::WebInputEvent::kControlKey},
{ui::KeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_C, ui::EF_ALT_DOWN),
- blink::WebInputEvent::kKeyUp, blink::WebInputEvent::kAltKey}};
+ blink::WebInputEvent::Type::kKeyUp, blink::WebInputEvent::kAltKey}};
for (size_t i = 0; i < base::size(tests); i++) {
blink::WebKeyboardEvent web_event = MakeWebKeyboardEvent(tests[i].event);
@@ -497,7 +497,7 @@ TEST(WebInputEventTest, WheelEvent) {
base::TimeTicks(), 0, 0),
kDeltaX, kDeltaY);
blink::WebMouseWheelEvent web_event = MakeWebMouseWheelEvent(ui_event);
- ASSERT_EQ(blink::WebInputEvent::kMouseWheel, web_event.GetType());
+ ASSERT_EQ(blink::WebInputEvent::Type::kMouseWheel, web_event.GetType());
ASSERT_EQ(0, web_event.GetModifiers());
ASSERT_EQ(kDeltaX, web_event.delta_x);
ASSERT_EQ(kDeltaY, web_event.delta_y);
@@ -512,12 +512,12 @@ TEST(WebInputEventTest, MousePointerEvent) {
gfx::Point location;
gfx::Point screen_location;
} tests[] = {
- {ui::ET_MOUSE_PRESSED, blink::WebInputEvent::kMouseDown, 0x0, 0x0,
+ {ui::ET_MOUSE_PRESSED, blink::WebInputEvent::Type::kMouseDown, 0x0, 0x0,
gfx::Point(3, 5), gfx::Point(113, 125)},
- {ui::ET_MOUSE_RELEASED, blink::WebInputEvent::kMouseUp,
+ {ui::ET_MOUSE_RELEASED, blink::WebInputEvent::Type::kMouseUp,
ui::EF_LEFT_MOUSE_BUTTON, blink::WebInputEvent::kLeftButtonDown,
gfx::Point(100, 1), gfx::Point(50, 1)},
- {ui::ET_MOUSE_MOVED, blink::WebInputEvent::kMouseMove,
+ {ui::ET_MOUSE_MOVED, blink::WebInputEvent::Type::kMouseMove,
ui::EF_MIDDLE_MOUSE_BUTTON | ui::EF_RIGHT_MOUSE_BUTTON,
blink::WebInputEvent::kMiddleButtonDown |
blink::WebInputEvent::kRightButtonDown,
@@ -546,7 +546,7 @@ TEST(WebInputEventTest, MouseLeaveScreenCoordinate) {
ui::MouseEvent ui_event(msg_event);
blink::WebMouseEvent web_event = MakeWebMouseEvent(ui_event);
- ASSERT_EQ(blink::WebInputEvent::kMouseLeave, web_event.GetType());
+ ASSERT_EQ(blink::WebInputEvent::Type::kMouseLeave, web_event.GetType());
// WM_MOUSELEAVE events take coordinates from cursor position instead of
// LPARAM.
diff --git a/chromium/ui/events/cocoa/events_mac.mm b/chromium/ui/events/cocoa/events_mac.mm
index efa34e74399..cfcc7bd96cc 100644
--- a/chromium/ui/events/cocoa/events_mac.mm
+++ b/chromium/ui/events/cocoa/events_mac.mm
@@ -7,8 +7,9 @@
#include <Cocoa/Cocoa.h>
#include <stdint.h>
-#include "base/logging.h"
+#include "base/check_op.h"
#import "base/mac/mac_util.h"
+#include "base/notreached.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "ui/events/base_event_utils.h"
@@ -126,7 +127,7 @@ int GetChangedMouseButtonFlagsFromNative(const PlatformEvent& native_event) {
PointerDetails GetMousePointerDetailsFromNative(
const PlatformEvent& native_event) {
- return PointerDetails(EventPointerType::POINTER_TYPE_MOUSE);
+ return PointerDetails(EventPointerType::kMouse);
}
gfx::Vector2d GetMouseWheelOffset(const PlatformEvent& event) {
@@ -165,7 +166,7 @@ void ClearTouchIdIfReleased(const PlatformEvent& native_event) {
PointerDetails GetTouchPointerDetailsFromNative(
const PlatformEvent& native_event) {
NOTIMPLEMENTED();
- return PointerDetails(EventPointerType::POINTER_TYPE_UNKNOWN,
+ return PointerDetails(EventPointerType::kUnknown,
/* pointer_id*/ 0,
/* radius_x */ 1.0,
/* radius_y */ 1.0,
diff --git a/chromium/ui/events/devices/device_data_manager.cc b/chromium/ui/events/devices/device_data_manager.cc
index 90a53491178..cf43bedaca8 100644
--- a/chromium/ui/events/devices/device_data_manager.cc
+++ b/chromium/ui/events/devices/device_data_manager.cc
@@ -8,7 +8,7 @@
#include "base/at_exit.h"
#include "base/bind.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "ui/display/types/display_constants.h"
#include "ui/events/devices/input_device_event_observer.h"
#include "ui/events/devices/touch_device_transform.h"
diff --git a/chromium/ui/events/devices/x11/BUILD.gn b/chromium/ui/events/devices/x11/BUILD.gn
index b95e1cc08ce..b6f246c6039 100644
--- a/chromium/ui/events/devices/x11/BUILD.gn
+++ b/chromium/ui/events/devices/x11/BUILD.gn
@@ -21,8 +21,6 @@ jumbo_component("x11") {
"touch_factory_x11.h",
]
- configs += [ "//build/config/linux:x11" ]
-
defines = [ "EVENTS_DEVICES_X11_IMPLEMENTATION" ]
deps = [
diff --git a/chromium/ui/events/devices/x11/device_data_manager_x11.cc b/chromium/ui/events/devices/x11/device_data_manager_x11.cc
index 91abd2bb04f..6a55ee3ac19 100644
--- a/chromium/ui/events/devices/x11/device_data_manager_x11.cc
+++ b/chromium/ui/events/devices/x11/device_data_manager_x11.cc
@@ -781,16 +781,6 @@ void DeviceDataManagerX11::UpdateScrollClassDevice(
DCHECK(deviceid >= 0 && deviceid < kMaxDeviceNum);
ScrollInfo& info = scroll_data_[deviceid];
-
- bool legacy_scroll_available =
- (scroll_class_info->flags & XIScrollFlagNoEmulation) == 0;
- // If the device's highest resolution is lower than the resolution of xinput1
- // then use xinput1's events instead (ie. don't configure smooth scrolling).
- if (legacy_scroll_available &&
- std::abs(scroll_class_info->increment) <= 1.0) {
- return;
- }
-
switch (scroll_class_info->scroll_type) {
case XIScrollTypeVertical:
info.vertical.number = scroll_class_info->number;
diff --git a/chromium/ui/events/devices/x11/touch_factory_x11.cc b/chromium/ui/events/devices/x11/touch_factory_x11.cc
index e4995f79e52..96abfc60208 100644
--- a/chromium/ui/events/devices/x11/touch_factory_x11.cc
+++ b/chromium/ui/events/devices/x11/touch_factory_x11.cc
@@ -72,10 +72,10 @@ void TouchFactory::SetTouchDeviceListFromCommandLine() {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
AddPointerDevicesFromString(
command_line->GetSwitchValueASCII(switches::kTouchDevices),
- EventPointerType::POINTER_TYPE_TOUCH, &devices);
+ EventPointerType::kTouch, &devices);
AddPointerDevicesFromString(
command_line->GetSwitchValueASCII(switches::kPenDevices),
- EventPointerType::POINTER_TYPE_PEN, &devices);
+ EventPointerType::kPen, &devices);
if (!devices.empty())
ui::TouchFactory::GetInstance()->SetTouchDeviceList(devices);
}
@@ -126,8 +126,7 @@ void TouchFactory::UpdateDeviceList(XDisplay* display) {
continue;
touch_device_lookup_[master_id] = true;
- touch_device_list_[master_id] = {true,
- EventPointerType::POINTER_TYPE_TOUCH};
+ touch_device_list_[master_id] = {true, EventPointerType::kTouch};
if (devinfo.use != XIMasterPointer)
CacheTouchscreenIds(devinfo.deviceid);
@@ -135,8 +134,8 @@ void TouchFactory::UpdateDeviceList(XDisplay* display) {
if (devinfo.use == XISlavePointer) {
device_master_id_list_[devinfo.deviceid] = master_id;
touch_device_lookup_[devinfo.deviceid] = true;
- touch_device_list_[devinfo.deviceid] = {
- false, EventPointerType::POINTER_TYPE_TOUCH};
+ touch_device_list_[devinfo.deviceid] = {false,
+ EventPointerType::kTouch};
}
}
pointer_device_lookup_[devinfo.deviceid] =
@@ -318,7 +317,7 @@ void TouchFactory::SetTouchDeviceForTest(
for (auto iter = devices.begin(); iter != devices.end(); ++iter) {
DCHECK(IsValidDevice(*iter));
touch_device_lookup_[*iter] = true;
- touch_device_list_[*iter] = {true, EventPointerType::POINTER_TYPE_TOUCH};
+ touch_device_list_[*iter] = {true, EventPointerType::kTouch};
}
SetTouchscreensEnabled(true);
}
diff --git a/chromium/ui/events/devices/x11/touch_factory_x11.h b/chromium/ui/events/devices/x11/touch_factory_x11.h
index fccee24f988..88d1c8389b4 100644
--- a/chromium/ui/events/devices/x11/touch_factory_x11.h
+++ b/chromium/ui/events/devices/x11/touch_factory_x11.h
@@ -136,7 +136,7 @@ class EVENTS_DEVICES_X11_EXPORT TouchFactory {
// device is master and multi-touch capable).
struct TouchDeviceDetails {
bool is_master = false;
- EventPointerType pointer_type = EventPointerType::POINTER_TYPE_TOUCH;
+ EventPointerType pointer_type = EventPointerType::kTouch;
};
std::map<int, TouchDeviceDetails> touch_device_list_;
diff --git a/chromium/ui/events/event.cc b/chromium/ui/events/event.cc
index 8f6c9a745bc..219c9c42080 100644
--- a/chromium/ui/events/event.cc
+++ b/chromium/ui/events/event.cc
@@ -8,6 +8,7 @@
#include <cstring>
#include <utility>
+#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram.h"
#include "base/metrics/histogram_macros.h"
@@ -138,6 +139,14 @@ std::string ScrollEventPhaseToString(ScrollEventPhase phase) {
}
}
+#if defined(USE_OZONE)
+uint32_t ScanCodeFromNative(const PlatformEvent& native_event) {
+ const ui::KeyEvent* event = static_cast<const ui::KeyEvent*>(native_event);
+ DCHECK(event->IsKeyEvent());
+ return event->scan_code();
+}
+#endif // defined(USE_OZONE)
+
} // namespace
////////////////////////////////////////////////////////////////////////////////
@@ -784,6 +793,9 @@ KeyEvent::KeyEvent(const PlatformEvent& native_event)
KeyEvent::KeyEvent(const PlatformEvent& native_event, int event_flags)
: Event(native_event, EventTypeFromNative(native_event), event_flags),
key_code_(KeyboardCodeFromNative(native_event)),
+#if defined(USE_OZONE)
+ scan_code_(ScanCodeFromNative(native_event)),
+#endif // defined(USE_OZONE)
code_(CodeFromNative(native_event)),
is_char_(IsCharFromNative(native_event)) {
InitializeNative();
@@ -837,14 +849,21 @@ KeyEvent::KeyEvent(base::char16 character,
KeyEvent::KeyEvent(const KeyEvent& rhs)
: Event(rhs),
key_code_(rhs.key_code_),
+#if defined(USE_OZONE)
+ scan_code_(rhs.scan_code_),
+#endif // defined(USE_OZONE)
code_(rhs.code_),
is_char_(rhs.is_char_),
- key_(rhs.key_) {}
+ key_(rhs.key_) {
+}
KeyEvent& KeyEvent::operator=(const KeyEvent& rhs) {
if (this != &rhs) {
Event::operator=(rhs);
key_code_ = rhs.key_code_;
+#if defined(USE_OZONE)
+ scan_code_ = rhs.scan_code_;
+#endif // defined(USE_OZONE)
code_ = rhs.code_;
key_ = rhs.key_;
is_char_ = rhs.is_char_;
@@ -859,16 +878,12 @@ void KeyEvent::InitializeNative() {
INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, time_stamp());
latency()->AddLatencyNumber(INPUT_EVENT_LATENCY_UI_COMPONENT);
- KeyEvent** last_key_event = &last_key_event_;
+ // Check if this is a key repeat. This must be called before initial flags
+ // processing, e.g: NormalizeFlags(), to avoid issues like crbug.com/1069690.
+ if (IsRepeated(GetLastKeyEvent()))
+ set_flags(flags() | ui::EF_IS_REPEAT);
#if defined(USE_X11)
- // Use a different static variable for key events that have non standard
- // state masks as it may be reposted by an IME. IBUS-GTK uses this field
- // to detect the re-posted event for example. crbug.com/385873.
- if (properties() && properties()->contains(kPropertyKeyboardIBusFlag)) {
- last_key_event = &last_ibus_key_event_;
- }
-
NormalizeFlags();
#elif defined(OS_WIN)
// Only Windows has native character events.
@@ -881,9 +896,6 @@ void KeyEvent::InitializeNative() {
set_flags(adjusted_flags);
}
#endif
-
- if (IsRepeated(last_key_event))
- set_flags(flags() | ui::EF_IS_REPEAT);
}
void KeyEvent::ApplyLayout() const {
@@ -976,6 +988,19 @@ bool KeyEvent::IsRepeated(KeyEvent** last_key_event) {
return false;
}
+KeyEvent** KeyEvent::GetLastKeyEvent() {
+#if defined(USE_X11)
+ // Use a different static variable for key events that have non standard
+ // state masks as it may be reposted by an IME. IBUS-GTK uses this field
+ // to detect the re-posted event for example. crbug.com/385873.
+ return properties() && properties()->contains(kPropertyKeyboardIBusFlag)
+ ? &last_ibus_key_event_
+ : &last_key_event_;
+#else
+ return &last_key_event_;
+#endif
+}
+
DomKey KeyEvent::GetDomKey() const {
// Determination of key_ may be done lazily.
if (key_ == DomKey::NONE)
diff --git a/chromium/ui/events/event.h b/chromium/ui/events/event.h
index 126ec0b3a9a..21fbd51da74 100644
--- a/chromium/ui/events/event.h
+++ b/chromium/ui/events/event.h
@@ -470,8 +470,7 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
int flags,
int changed_button_flags,
const PointerDetails& pointer_details =
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE,
- kPointerIdMouse));
+ PointerDetails(EventPointerType::kMouse, kPointerIdMouse));
// DEPRECATED: Prefer constructor that takes gfx::PointF.
MouseEvent(EventType type,
@@ -481,8 +480,7 @@ class EVENTS_EXPORT MouseEvent : public LocatedEvent {
int flags,
int changed_button_flags,
const PointerDetails& pointer_details =
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE,
- kPointerIdMouse));
+ PointerDetails(EventPointerType::kMouse, kPointerIdMouse));
MouseEvent(const MouseEvent& copy);
~MouseEvent() override;
@@ -641,7 +639,7 @@ class EVENTS_EXPORT MouseWheelEvent : public MouseEvent {
gfx::Vector2d offset_;
};
-// NOTE: Pen (stylus) events use TouchEvent with POINTER_TYPE_PEN. They were
+// NOTE: Pen (stylus) events use TouchEvent with kPen. They were
// originally implemented as MouseEvent but switched to TouchEvent when UX
// decided not to show hover effects for pen.
class EVENTS_EXPORT TouchEvent : public LocatedEvent {
@@ -751,6 +749,11 @@ class EVENTS_EXPORT TouchEvent : public LocatedEvent {
// Japanese, etc. all use VKEY_Q for the key beside Tab, while French uses
// VKEY_A. The stored key_code_ is non-located (e.g. VKEY_SHIFT rather than
// VKEY_LSHIFT, VKEY_1 rather than VKEY_NUMPAD1).
+// -- |uint32_t scan_code_| [USE_OZONE only] supports remapping of the top
+// function row based on a sysfs attribute provided by the kernel. This
+// allows devices to have a custom top row layout and still be able to
+// perform translation back and forth between F-Key and Action-Key. The
+// value of this scan code is device specific.
//
// For a character event,
// -- |bool is_char_| is true.
@@ -846,6 +849,14 @@ class EVENTS_EXPORT KeyEvent : public Event {
// events in an EventRewriter.
void set_key_code(KeyboardCode key_code) { key_code_ = key_code; }
+#if defined(USE_OZONE)
+ // The scan code of the physical key. This is used to perform the mapping
+ // of top row keys from Actions back to F-Keys on new Chrome OS keyboards
+ // that supply the mapping via the kernel.
+ uint32_t scan_code() const { return scan_code_; }
+ void set_scan_code(uint32_t scan_code) { scan_code_ = scan_code; }
+#endif // defined(USE_OZONE)
+
// Returns the same value as key_code(), except that located codes are
// returned in place of non-located ones (e.g. VKEY_LSHIFT or VKEY_RSHIFT
// instead of VKEY_SHIFT). This is a hybrid of semantic and physical
@@ -886,8 +897,16 @@ class EVENTS_EXPORT KeyEvent : public Event {
// then updated with the new last KeyEvent address.
bool IsRepeated(KeyEvent** last_key_event);
+ // Returns the pointer for the last processed KeyEvent.
+ KeyEvent** GetLastKeyEvent();
+
KeyboardCode key_code_;
+#if defined(USE_OZONE)
+ // The scan code of the physical key on Chrome OS.
+ uint32_t scan_code_ = 0;
+#endif // defined(USE_OZONE)
+
// DOM KeyboardEvent |code| (e.g. DomCode::US_A, DomCode::SPACE).
// http://www.w3.org/TR/DOM-Level-3-Events-code/
//
diff --git a/chromium/ui/events/event_constants.h b/chromium/ui/events/event_constants.h
index ad4ac4d4f2a..89ae83d5fea 100644
--- a/chromium/ui/events/event_constants.h
+++ b/chromium/ui/events/event_constants.h
@@ -174,11 +174,12 @@ enum EventDeviceId {
// Pointing device type.
enum class EventPointerType : int {
- POINTER_TYPE_UNKNOWN = 0,
- POINTER_TYPE_MOUSE,
- POINTER_TYPE_PEN,
- POINTER_TYPE_TOUCH,
- POINTER_TYPE_ERASER,
+ kUnknown,
+ kMouse,
+ kPen,
+ kTouch,
+ kEraser,
+ kMaxValue = kEraser,
};
// Device type for gesture events.
diff --git a/chromium/ui/events/event_dispatcher_unittest.cc b/chromium/ui/events/event_dispatcher_unittest.cc
index f3d080f1179..6b67cb30e5c 100644
--- a/chromium/ui/events/event_dispatcher_unittest.cc
+++ b/chromium/ui/events/event_dispatcher_unittest.cc
@@ -4,7 +4,9 @@
#include "ui/events/event_dispatcher.h"
+#include "base/check.h"
#include "base/macros.h"
+#include "base/notreached.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/event.h"
#include "ui/events/event_dispatcher.h"
diff --git a/chromium/ui/events/event_rewriter.cc b/chromium/ui/events/event_rewriter.cc
index d3752be88ba..0c2e0f5b0cf 100644
--- a/chromium/ui/events/event_rewriter.cc
+++ b/chromium/ui/events/event_rewriter.cc
@@ -6,6 +6,8 @@
#include <utility>
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "ui/events/event_rewriter_continuation.h"
#include "ui/events/event_source.h"
diff --git a/chromium/ui/events/event_rewriter_unittest.cc b/chromium/ui/events/event_rewriter_unittest.cc
index f69a1f2c027..3a5f088b81a 100644
--- a/chromium/ui/events/event_rewriter_unittest.cc
+++ b/chromium/ui/events/event_rewriter_unittest.cc
@@ -9,7 +9,9 @@
#include <set>
#include <utility>
+#include "base/check_op.h"
#include "base/macros.h"
+#include "base/notreached.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/keyboard_codes.h"
diff --git a/chromium/ui/events/event_source.cc b/chromium/ui/events/event_source.cc
index 79885e4f124..bcbfcfa5bab 100644
--- a/chromium/ui/events/event_source.cc
+++ b/chromium/ui/events/event_source.cc
@@ -4,6 +4,7 @@
#include "ui/events/event_source.h"
+#include "base/logging.h"
#include "ui/events/event_rewriter_continuation.h"
#include "ui/events/event_sink.h"
diff --git a/chromium/ui/events/event_target.cc b/chromium/ui/events/event_target.cc
index 187e9bd1912..9ce28b23711 100644
--- a/chromium/ui/events/event_target.cc
+++ b/chromium/ui/events/event_target.cc
@@ -6,7 +6,8 @@
#include <algorithm>
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "ui/events/event.h"
#include "ui/gfx/geometry/point_conversions.h"
diff --git a/chromium/ui/events/event_unittest.cc b/chromium/ui/events/event_unittest.cc
index 998c8cefc99..f13f74a1944 100644
--- a/chromium/ui/events/event_unittest.cc
+++ b/chromium/ui/events/event_unittest.cc
@@ -560,7 +560,7 @@ TEST(EventTest, TouchEventRadiusDefaultsToOtherAxis) {
const float non_zero_length2 = 46;
TouchEvent event1(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
+ PointerDetails(ui::EventPointerType::kTouch,
/* pointer_id*/ 0,
/* radius_x */ non_zero_length1,
/* radius_y */ 0.0f,
@@ -569,7 +569,7 @@ TEST(EventTest, TouchEventRadiusDefaultsToOtherAxis) {
EXPECT_EQ(non_zero_length1, event1.pointer_details().radius_y);
TouchEvent event2(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
+ PointerDetails(ui::EventPointerType::kTouch,
/* pointer_id*/ 0,
/* radius_x */ 0.0f,
/* radius_y */ non_zero_length2,
@@ -586,7 +586,7 @@ TEST(EventTest, TouchEventRotationAngleFixing) {
{
const float angle_in_range = 0;
TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
+ PointerDetails(ui::EventPointerType::kTouch,
/* pointer_id*/ 0, radius_x, radius_y,
/* force */ 0, angle_in_range),
0);
@@ -596,7 +596,7 @@ TEST(EventTest, TouchEventRotationAngleFixing) {
{
const float angle_in_range = 179.9f;
TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
+ PointerDetails(ui::EventPointerType::kTouch,
/* pointer_id*/ 0, radius_x, radius_y,
/* force */ 0, angle_in_range),
0);
@@ -606,7 +606,7 @@ TEST(EventTest, TouchEventRotationAngleFixing) {
{
const float angle_negative = -0.1f;
TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
+ PointerDetails(ui::EventPointerType::kTouch,
/* pointer_id*/ 0, radius_x, radius_y,
/* force */ 0, angle_negative),
0);
@@ -616,7 +616,7 @@ TEST(EventTest, TouchEventRotationAngleFixing) {
{
const float angle_negative = -200;
TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
+ PointerDetails(ui::EventPointerType::kTouch,
/* pointer_id*/ 0, radius_x, radius_y,
/* force */ 0, angle_negative),
0);
@@ -626,7 +626,7 @@ TEST(EventTest, TouchEventRotationAngleFixing) {
{
const float angle_too_big = 180;
TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
+ PointerDetails(ui::EventPointerType::kTouch,
/* pointer_id*/ 0, radius_x, radius_y,
/* force */ 0, angle_too_big),
0);
@@ -636,7 +636,7 @@ TEST(EventTest, TouchEventRotationAngleFixing) {
{
const float angle_too_big = 400;
TouchEvent event(ui::ET_TOUCH_PRESSED, gfx::Point(0, 0), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
+ PointerDetails(ui::EventPointerType::kTouch,
/* pointer_id*/ 0, radius_x, radius_y,
/* force */ 0, angle_too_big),
0);
@@ -647,9 +647,9 @@ TEST(EventTest, TouchEventRotationAngleFixing) {
TEST(EventTest, PointerDetailsTouch) {
ui::TouchEvent touch_event_plain(
ET_TOUCH_PRESSED, gfx::Point(0, 0), ui::EventTimeForNow(),
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ PointerDetails(ui::EventPointerType::kTouch, 0));
- EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH,
+ EXPECT_EQ(EventPointerType::kTouch,
touch_event_plain.pointer_details().pointer_type);
EXPECT_EQ(0.0f, touch_event_plain.pointer_details().radius_x);
EXPECT_EQ(0.0f, touch_event_plain.pointer_details().radius_y);
@@ -659,13 +659,13 @@ TEST(EventTest, PointerDetailsTouch) {
ui::TouchEvent touch_event_with_details(
ET_TOUCH_PRESSED, gfx::Point(0, 0), ui::EventTimeForNow(),
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
+ PointerDetails(ui::EventPointerType::kTouch,
/* pointer_id*/ 0,
/* radius_x */ 10.0f,
/* radius_y */ 5.0f,
/* force */ 15.0f));
- EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH,
+ EXPECT_EQ(EventPointerType::kTouch,
touch_event_with_details.pointer_details().pointer_type);
EXPECT_EQ(10.0f, touch_event_with_details.pointer_details().radius_x);
EXPECT_EQ(5.0f, touch_event_with_details.pointer_details().radius_y);
@@ -682,7 +682,7 @@ TEST(EventTest, PointerDetailsMouse) {
ui::MouseEvent mouse_event(ET_MOUSE_PRESSED, gfx::Point(0, 0),
gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_MOUSE,
+ EXPECT_EQ(EventPointerType::kMouse,
mouse_event.pointer_details().pointer_type);
EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_x);
EXPECT_EQ(0.0f, mouse_event.pointer_details().radius_y);
@@ -695,7 +695,7 @@ TEST(EventTest, PointerDetailsMouse) {
}
TEST(EventTest, PointerDetailsStylus) {
- ui::PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN,
+ ui::PointerDetails pointer_details(EventPointerType::kPen,
/* pointer_id*/ 0,
/* radius_x */ 0.0f,
/* radius_y */ 0.0f,
@@ -708,7 +708,7 @@ TEST(EventTest, PointerDetailsStylus) {
ui::MouseEvent stylus_event(ET_MOUSE_PRESSED, gfx::Point(0, 0),
gfx::Point(0, 0), ui::EventTimeForNow(), 0, 0,
pointer_details);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
+ EXPECT_EQ(EventPointerType::kPen,
stylus_event.pointer_details().pointer_type);
EXPECT_EQ(21.0f, stylus_event.pointer_details().force);
EXPECT_EQ(45.0f, stylus_event.pointer_details().tilt_x);
@@ -724,11 +724,11 @@ TEST(EventTest, PointerDetailsStylus) {
}
TEST(EventTest, PointerDetailsCustomTouch) {
- ui::TouchEvent touch_event(
- ET_TOUCH_PRESSED, gfx::Point(0, 0), ui::EventTimeForNow(),
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent touch_event(ET_TOUCH_PRESSED, gfx::Point(0, 0),
+ ui::EventTimeForNow(),
+ PointerDetails(ui::EventPointerType::kTouch, 0));
- EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH,
+ EXPECT_EQ(EventPointerType::kTouch,
touch_event.pointer_details().pointer_type);
EXPECT_EQ(0.0f, touch_event.pointer_details().radius_x);
EXPECT_EQ(0.0f, touch_event.pointer_details().radius_y);
@@ -736,7 +736,7 @@ TEST(EventTest, PointerDetailsCustomTouch) {
EXPECT_EQ(0.0f, touch_event.pointer_details().tilt_x);
EXPECT_EQ(0.0f, touch_event.pointer_details().tilt_y);
- ui::PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN,
+ ui::PointerDetails pointer_details(EventPointerType::kPen,
/* pointer_id*/ 0,
/* radius_x */ 5.0f,
/* radius_y */ 6.0f,
@@ -747,8 +747,7 @@ TEST(EventTest, PointerDetailsCustomTouch) {
/* tangential_pressure */ 0.7f);
touch_event.SetPointerDetailsForTest(pointer_details);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
- touch_event.pointer_details().pointer_type);
+ EXPECT_EQ(EventPointerType::kPen, touch_event.pointer_details().pointer_type);
EXPECT_EQ(21.0f, touch_event.pointer_details().force);
EXPECT_EQ(45.0f, touch_event.pointer_details().tilt_x);
EXPECT_EQ(-45.0f, touch_event.pointer_details().tilt_y);
diff --git a/chromium/ui/events/event_utils.cc b/chromium/ui/events/event_utils.cc
index 7e4286764e2..a6be130c6aa 100644
--- a/chromium/ui/events/event_utils.cc
+++ b/chromium/ui/events/event_utils.cc
@@ -6,7 +6,9 @@
#include <vector>
+#include "base/check.h"
#include "base/metrics/histogram_macros.h"
+#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
@@ -143,7 +145,6 @@ void ConvertEventLocationToTargetWindowLocation(
gfx::PointF location_in_pixel_in_host =
located_event->location_f() + gfx::Vector2dF(offset);
located_event->set_location_f(location_in_pixel_in_host);
- located_event->set_root_location_f(location_in_pixel_in_host);
}
const char* EventTypeName(EventType type) {
diff --git a/chromium/ui/events/events_stub.cc b/chromium/ui/events/events_stub.cc
index aa7865648e6..ff5364e5563 100644
--- a/chromium/ui/events/events_stub.cc
+++ b/chromium/ui/events/events_stub.cc
@@ -4,7 +4,7 @@
#include <stdint.h>
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "ui/events/event_utils.h"
@@ -54,7 +54,7 @@ int GetChangedMouseButtonFlagsFromNative(const PlatformEvent& native_event) {
PointerDetails GetMousePointerDetailsFromNative(
const PlatformEvent& native_event) {
- return PointerDetails(EventPointerType::POINTER_TYPE_MOUSE);
+ return PointerDetails(EventPointerType::kMouse);
}
gfx::Vector2d GetMouseWheelOffset(const PlatformEvent& native_event) {
@@ -72,7 +72,7 @@ void ReleaseCopiedNativeEvent(const PlatformEvent& event) {}
PointerDetails GetTouchPointerDetailsFromNative(
const PlatformEvent& native_event) {
NOTIMPLEMENTED();
- return PointerDetails(EventPointerType::POINTER_TYPE_UNKNOWN,
+ return PointerDetails(EventPointerType::kUnknown,
/* radius_x */ 1.0,
/* radius_y */ 1.0,
/* force */ 0.f,
diff --git a/chromium/ui/events/fuchsia/input_event_dispatcher.cc b/chromium/ui/events/fuchsia/input_event_dispatcher.cc
index bd329a418d6..a0450ee04e2 100644
--- a/chromium/ui/events/fuchsia/input_event_dispatcher.cc
+++ b/chromium/ui/events/fuchsia/input_event_dispatcher.cc
@@ -133,7 +133,7 @@ bool InputEventDispatcher::ProcessTouchEvent(
// TODO(crbug.com/876933): Add more detailed fields such as
// force/orientation/tilt once they are added to PointerEvent.
- ui::PointerDetails pointer_details(ui::EventPointerType::POINTER_TYPE_TOUCH,
+ ui::PointerDetails pointer_details(ui::EventPointerType::kTouch,
event.pointer_id);
ui::TouchEvent touch_event(event_type, gfx::Point(),
diff --git a/chromium/ui/events/gesture_detection/filtered_gesture_provider.cc b/chromium/ui/events/gesture_detection/filtered_gesture_provider.cc
index b44f953463d..8a449deddca 100644
--- a/chromium/ui/events/gesture_detection/filtered_gesture_provider.cc
+++ b/chromium/ui/events/gesture_detection/filtered_gesture_provider.cc
@@ -5,7 +5,8 @@
#include "ui/events/gesture_detection/filtered_gesture_provider.h"
#include "base/auto_reset.h"
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "ui/events/gesture_detection/motion_event.h"
namespace ui {
diff --git a/chromium/ui/events/gesture_detection/gesture_event_data.cc b/chromium/ui/events/gesture_detection/gesture_event_data.cc
index e72d2104814..d32d1265f86 100644
--- a/chromium/ui/events/gesture_detection/gesture_event_data.cc
+++ b/chromium/ui/events/gesture_detection/gesture_event_data.cc
@@ -4,7 +4,8 @@
#include "ui/events/gesture_detection/gesture_event_data.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
namespace ui {
@@ -13,18 +14,18 @@ namespace {
EventPointerType ToEventPointerType(MotionEvent::ToolType tool_type) {
switch (tool_type) {
case MotionEvent::ToolType::UNKNOWN:
- return EventPointerType::POINTER_TYPE_UNKNOWN;
+ return EventPointerType::kUnknown;
case MotionEvent::ToolType::FINGER:
- return EventPointerType::POINTER_TYPE_TOUCH;
+ return EventPointerType::kTouch;
case MotionEvent::ToolType::STYLUS:
- return EventPointerType::POINTER_TYPE_PEN;
+ return EventPointerType::kPen;
case MotionEvent::ToolType::MOUSE:
- return EventPointerType::POINTER_TYPE_MOUSE;
+ return EventPointerType::kMouse;
case MotionEvent::ToolType::ERASER:
- return EventPointerType::POINTER_TYPE_ERASER;
+ return EventPointerType::kEraser;
default:
NOTREACHED() << "Invalid ToolType = " << tool_type;
- return EventPointerType::POINTER_TYPE_UNKNOWN;
+ return EventPointerType::kUnknown;
}
}
diff --git a/chromium/ui/events/gesture_detection/gesture_event_data_packet.cc b/chromium/ui/events/gesture_detection/gesture_event_data_packet.cc
index a72c0894b18..8f17e254d0a 100644
--- a/chromium/ui/events/gesture_detection/gesture_event_data_packet.cc
+++ b/chromium/ui/events/gesture_detection/gesture_event_data_packet.cc
@@ -4,7 +4,8 @@
#include "ui/events/gesture_detection/gesture_event_data_packet.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "ui/events/gesture_detection/motion_event.h"
namespace ui {
diff --git a/chromium/ui/events/gesture_detection/gesture_provider_unittest.cc b/chromium/ui/events/gesture_detection/gesture_provider_unittest.cc
index 9c0b37bb253..bbeb855a2f3 100644
--- a/chromium/ui/events/gesture_detection/gesture_provider_unittest.cc
+++ b/chromium/ui/events/gesture_detection/gesture_provider_unittest.cc
@@ -8,8 +8,8 @@
#include <memory>
+#include "base/check.h"
#include "base/location.h"
-#include "base/logging.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
#include "base/test/metrics/histogram_tester.h"
diff --git a/chromium/ui/events/gesture_detection/gesture_touch_uma_histogram.cc b/chromium/ui/events/gesture_detection/gesture_touch_uma_histogram.cc
index 7afcbf49bd3..95295a0ebe1 100644
--- a/chromium/ui/events/gesture_detection/gesture_touch_uma_histogram.cc
+++ b/chromium/ui/events/gesture_detection/gesture_touch_uma_histogram.cc
@@ -5,6 +5,7 @@
#include "ui/events/gesture_detection/gesture_touch_uma_histogram.h"
#include "base/metrics/histogram_macros.h"
+#include "base/notreached.h"
namespace ui {
diff --git a/chromium/ui/events/gesture_detection/motion_event.cc b/chromium/ui/events/gesture_detection/motion_event.cc
index a5c083b0782..2d75ceacb1f 100644
--- a/chromium/ui/events/gesture_detection/motion_event.cc
+++ b/chromium/ui/events/gesture_detection/motion_event.cc
@@ -4,7 +4,7 @@
#include "ui/events/gesture_detection/motion_event.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "ui/events/gesture_detection/motion_event_generic.h"
namespace ui {
diff --git a/chromium/ui/events/gesture_detection/motion_event_buffer_unittest.cc b/chromium/ui/events/gesture_detection/motion_event_buffer_unittest.cc
index a6f78436309..4645758c092 100644
--- a/chromium/ui/events/gesture_detection/motion_event_buffer_unittest.cc
+++ b/chromium/ui/events/gesture_detection/motion_event_buffer_unittest.cc
@@ -4,7 +4,6 @@
#include <stddef.h>
-#include "base/logging.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/gesture_detection/motion_event_buffer.h"
diff --git a/chromium/ui/events/gesture_detection/motion_event_generic.cc b/chromium/ui/events/gesture_detection/motion_event_generic.cc
index b8539a7cf53..fbfd6b93e8c 100644
--- a/chromium/ui/events/gesture_detection/motion_event_generic.cc
+++ b/chromium/ui/events/gesture_detection/motion_event_generic.cc
@@ -6,7 +6,7 @@
#include <utility>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/memory/ptr_util.h"
#include "base/numerics/math_constants.h"
#include "ui/events/base_event_utils.h"
diff --git a/chromium/ui/events/gesture_detection/scale_gesture_detector.cc b/chromium/ui/events/gesture_detection/scale_gesture_detector.cc
index eace042b698..262a49542a0 100644
--- a/chromium/ui/events/gesture_detection/scale_gesture_detector.cc
+++ b/chromium/ui/events/gesture_detection/scale_gesture_detector.cc
@@ -9,7 +9,7 @@
#include <algorithm>
#include <cmath>
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/events/gesture_detection/motion_event.h"
#include "ui/events/gesture_detection/scale_gesture_listeners.h"
diff --git a/chromium/ui/events/gesture_detection/touch_disposition_gesture_filter.cc b/chromium/ui/events/gesture_detection/touch_disposition_gesture_filter.cc
index 687dfa542fc..c240bbdc4c1 100644
--- a/chromium/ui/events/gesture_detection/touch_disposition_gesture_filter.cc
+++ b/chromium/ui/events/gesture_detection/touch_disposition_gesture_filter.cc
@@ -7,7 +7,8 @@
#include <stddef.h>
#include "base/auto_reset.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "ui/events/gesture_event_details.h"
namespace ui {
diff --git a/chromium/ui/events/gesture_detection/velocity_tracker.cc b/chromium/ui/events/gesture_detection/velocity_tracker.cc
index 0f2cffc1455..77f7d9c387f 100644
--- a/chromium/ui/events/gesture_detection/velocity_tracker.cc
+++ b/chromium/ui/events/gesture_detection/velocity_tracker.cc
@@ -8,7 +8,8 @@
#include <cmath>
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "ui/events/gesture_detection/motion_event.h"
using base::TimeDelta;
diff --git a/chromium/ui/events/gesture_detection/velocity_tracker_state.cc b/chromium/ui/events/gesture_detection/velocity_tracker_state.cc
index fdae25f85e6..fb01e77216b 100644
--- a/chromium/ui/events/gesture_detection/velocity_tracker_state.cc
+++ b/chromium/ui/events/gesture_detection/velocity_tracker_state.cc
@@ -4,7 +4,7 @@
#include "ui/events/gesture_detection/velocity_tracker_state.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "ui/events/gesture_detection/motion_event.h"
namespace ui {
diff --git a/chromium/ui/events/gesture_detection/velocity_tracker_unittest.cc b/chromium/ui/events/gesture_detection/velocity_tracker_unittest.cc
index e828d351afa..a9dd69fe3d8 100644
--- a/chromium/ui/events/gesture_detection/velocity_tracker_unittest.cc
+++ b/chromium/ui/events/gesture_detection/velocity_tracker_unittest.cc
@@ -6,7 +6,7 @@
#include <memory>
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/time/time.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/gesture_detection/velocity_tracker_state.h"
diff --git a/chromium/ui/events/gesture_event_details.cc b/chromium/ui/events/gesture_event_details.cc
index a32e1d2ac28..46cdb39f877 100644
--- a/chromium/ui/events/gesture_event_details.cc
+++ b/chromium/ui/events/gesture_event_details.cc
@@ -3,6 +3,8 @@
// found in the LICENSE file.
#include "ui/events/gesture_event_details.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
namespace ui {
diff --git a/chromium/ui/events/gesture_event_details.h b/chromium/ui/events/gesture_event_details.h
index 7382077ed52..f1a7c446aa7 100644
--- a/chromium/ui/events/gesture_event_details.h
+++ b/chromium/ui/events/gesture_event_details.h
@@ -227,8 +227,7 @@ struct EVENTS_BASE_EXPORT GestureEventDetails {
bool is_source_touch_event_set_non_blocking_ = false;
// The pointer type for the first touch point in the gesture.
- EventPointerType primary_pointer_type_ =
- EventPointerType::POINTER_TYPE_UNKNOWN;
+ EventPointerType primary_pointer_type_ = EventPointerType::kUnknown;
int touch_points_; // Number of active touch points in the gesture.
diff --git a/chromium/ui/events/gestures/blink/web_gesture_curve_impl.cc b/chromium/ui/events/gestures/blink/web_gesture_curve_impl.cc
index a02f80bab99..4037df3ba7e 100644
--- a/chromium/ui/events/gestures/blink/web_gesture_curve_impl.cc
+++ b/chromium/ui/events/gestures/blink/web_gesture_curve_impl.cc
@@ -8,7 +8,6 @@
#include <utility>
-#include "base/logging.h"
#include "base/metrics/histogram_macros.h"
#include "build/build_config.h"
#include "ui/base/ui_base_features.h"
@@ -33,7 +32,8 @@ std::unique_ptr<GestureCurve> CreateDefaultPlatformCurve(
const gfx::Vector2dF& initial_velocity,
bool use_mobile_fling_curve,
const gfx::PointF& position_in_screen,
- const gfx::Size& viewport_size) {
+ const float boost_multiplier,
+ const gfx::Size& bounding_size) {
if (device_source == blink::WebGestureDevice::kSyntheticAutoscroll) {
return std::make_unique<FixedVelocityCurve>(initial_velocity,
base::TimeTicks());
@@ -62,7 +62,8 @@ std::unique_ptr<GestureCurve> CreateDefaultPlatformCurve(
display::win::ScreenWin::GetPixelsPerInch(position_in_screen);
#endif // define(OS_WIN)
return std::make_unique<PhysicsBasedFlingCurve>(
- initial_velocity, base::TimeTicks(), pixels_per_inch, viewport_size);
+ initial_velocity, base::TimeTicks(), pixels_per_inch, boost_multiplier,
+ bounding_size);
}
return std::make_unique<FlingCurve>(initial_velocity, base::TimeTicks());
@@ -79,11 +80,12 @@ WebGestureCurveImpl::CreateFromDefaultPlatformCurve(
bool on_main_thread,
bool use_mobile_fling_curve,
const gfx::PointF& position_in_screen,
+ const float boost_multiplier,
const gfx::Size& viewport_size) {
return std::unique_ptr<WebGestureCurve>(new WebGestureCurveImpl(
CreateDefaultPlatformCurve(device_source, initial_velocity,
use_mobile_fling_curve, position_in_screen,
- viewport_size),
+ boost_multiplier, viewport_size),
initial_offset, on_main_thread ? ThreadType::MAIN : ThreadType::IMPL));
}
diff --git a/chromium/ui/events/gestures/blink/web_gesture_curve_impl.h b/chromium/ui/events/gestures/blink/web_gesture_curve_impl.h
index 5d97c0476dd..a5bfc61dd85 100644
--- a/chromium/ui/events/gestures/blink/web_gesture_curve_impl.h
+++ b/chromium/ui/events/gestures/blink/web_gesture_curve_impl.h
@@ -24,12 +24,19 @@ class WebGestureCurveImpl : public blink::WebGestureCurve {
public:
static std::unique_ptr<blink::WebGestureCurve> CreateFromDefaultPlatformCurve(
blink::WebGestureDevice device_source,
+ // Initial velocity has boost_multiplier from fling booster already
+ // applied
const gfx::Vector2dF& initial_velocity,
const gfx::Vector2dF& initial_offset,
bool on_main_thread,
bool use_mobile_fling_curve,
const gfx::PointF& position_in_screen,
- const gfx::Size& viewport_szie);
+ // Multiplier for fling distance based on fling boosting. Used in physics
+ // based fling curve
+ const float boost_multiplier,
+ // Maximum fling distance subject to boost_multiplier and default
+ // bounds multiplier. Used in physics based fling curve
+ const gfx::Size& bounding_size);
static std::unique_ptr<blink::WebGestureCurve> CreateFromUICurveForTesting(
std::unique_ptr<GestureCurve> curve,
const gfx::Vector2dF& initial_offset);
diff --git a/chromium/ui/events/gestures/fling_curve.cc b/chromium/ui/events/gestures/fling_curve.cc
index 00d29a46fd5..5d435cfbf65 100644
--- a/chromium/ui/events/gestures/fling_curve.cc
+++ b/chromium/ui/events/gestures/fling_curve.cc
@@ -7,7 +7,7 @@
#include <algorithm>
#include <cmath>
-#include "base/logging.h"
+#include "base/check_op.h"
namespace {
diff --git a/chromium/ui/events/gestures/gesture_provider_aura.cc b/chromium/ui/events/gestures/gesture_provider_aura.cc
index 83f085a1cae..297c4c2a3e1 100644
--- a/chromium/ui/events/gestures/gesture_provider_aura.cc
+++ b/chromium/ui/events/gestures/gesture_provider_aura.cc
@@ -7,7 +7,7 @@
#include <utility>
#include "base/auto_reset.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/events/gesture_detection/gesture_configuration.h"
@@ -98,7 +98,7 @@ GestureProviderAura::GetAndResetPendingGestures() {
void GestureProviderAura::OnTouchEnter(int pointer_id, float x, float y) {
auto touch_event = std::make_unique<TouchEvent>(
ET_TOUCH_PRESSED, gfx::Point(), ui::EventTimeForNow(),
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, pointer_id),
+ PointerDetails(ui::EventPointerType::kTouch, pointer_id),
EF_IS_SYNTHESIZED);
gfx::PointF point(x, y);
touch_event->set_location_f(point);
diff --git a/chromium/ui/events/gestures/gesture_provider_aura_unittest.cc b/chromium/ui/events/gestures/gesture_provider_aura_unittest.cc
index 1e0aeea5d14..180c48227dd 100644
--- a/chromium/ui/events/gestures/gesture_provider_aura_unittest.cc
+++ b/chromium/ui/events/gestures/gesture_provider_aura_unittest.cc
@@ -42,40 +42,35 @@ class GestureProviderAuraTest : public testing::Test,
TEST_F(GestureProviderAuraTest, IgnoresExtraPressEvents) {
base::TimeTicks time = ui::EventTimeForNow();
- TouchEvent press1(
- ET_TOUCH_PRESSED, gfx::Point(10, 10), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent press1(ET_TOUCH_PRESSED, gfx::Point(10, 10), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&press1));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent press2(
- ET_TOUCH_PRESSED, gfx::Point(30, 40), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent press2(ET_TOUCH_PRESSED, gfx::Point(30, 40), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_FALSE(provider()->OnTouchEvent(&press2));
}
TEST_F(GestureProviderAuraTest, IgnoresExtraMoveOrReleaseEvents) {
base::TimeTicks time = ui::EventTimeForNow();
- TouchEvent press1(
- ET_TOUCH_PRESSED, gfx::Point(10, 10), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent press1(ET_TOUCH_PRESSED, gfx::Point(10, 10), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&press1));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent release1(
- ET_TOUCH_RELEASED, gfx::Point(30, 40), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent release1(ET_TOUCH_RELEASED, gfx::Point(30, 40), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&release1));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent release2(
- ET_TOUCH_RELEASED, gfx::Point(30, 45), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent release2(ET_TOUCH_RELEASED, gfx::Point(30, 45), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_FALSE(provider()->OnTouchEvent(&release1));
time += base::TimeDelta::FromMilliseconds(10);
TouchEvent move1(ET_TOUCH_MOVED, gfx::Point(70, 75), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_FALSE(provider()->OnTouchEvent(&move1));
}
@@ -83,39 +78,33 @@ TEST_F(GestureProviderAuraTest, DoesntStallOnCancelAndRelease) {
GestureConfiguration::GetInstance()->set_single_pointer_cancel_enabled(false);
base::TimeTicks time = ui::EventTimeForNow();
- TouchEvent touch_press(
- ET_TOUCH_PRESSED, gfx::Point(10, 10), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent touch_press(ET_TOUCH_PRESSED, gfx::Point(10, 10), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_press));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent pen_press1(
- ET_TOUCH_PRESSED, gfx::Point(20, 20), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_PEN, 1));
+ TouchEvent pen_press1(ET_TOUCH_PRESSED, gfx::Point(20, 20), time,
+ PointerDetails(ui::EventPointerType::kPen, 1));
EXPECT_TRUE(provider()->OnTouchEvent(&pen_press1));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_cancel(
- ET_TOUCH_CANCELLED, gfx::Point(30, 30), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent touch_cancel(ET_TOUCH_CANCELLED, gfx::Point(30, 30), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_cancel));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent pen_release1(
- ET_TOUCH_RELEASED, gfx::Point(40, 40), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_PEN, 1));
+ TouchEvent pen_release1(ET_TOUCH_RELEASED, gfx::Point(40, 40), time,
+ PointerDetails(ui::EventPointerType::kPen, 1));
EXPECT_FALSE(provider()->OnTouchEvent(&pen_release1));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent pen_press2(
- ET_TOUCH_PRESSED, gfx::Point(10, 10), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_PEN, 0));
+ TouchEvent pen_press2(ET_TOUCH_PRESSED, gfx::Point(10, 10), time,
+ PointerDetails(ui::EventPointerType::kPen, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&pen_press2));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent pen_release2(
- ET_TOUCH_RELEASED, gfx::Point(10, 10), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_PEN, 0));
+ TouchEvent pen_release2(ET_TOUCH_RELEASED, gfx::Point(10, 10), time,
+ PointerDetails(ui::EventPointerType::kPen, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&pen_release2));
}
@@ -123,45 +112,38 @@ TEST_F(GestureProviderAuraTest, ContinueGestureDetectionAfterCancel) {
GestureConfiguration::GetInstance()->set_single_pointer_cancel_enabled(true);
base::TimeTicks time = ui::EventTimeForNow();
- TouchEvent touch_press1(
- ET_TOUCH_PRESSED, gfx::Point(10, 10), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent touch_press1(ET_TOUCH_PRESSED, gfx::Point(10, 10), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_press1));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_press2(
- ET_TOUCH_PRESSED, gfx::Point(20, 20), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ TouchEvent touch_press2(ET_TOUCH_PRESSED, gfx::Point(20, 20), time,
+ PointerDetails(ui::EventPointerType::kTouch, 1));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_press2));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_move1(
- ET_TOUCH_MOVED, gfx::Point(30, 30), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent touch_move1(ET_TOUCH_MOVED, gfx::Point(30, 30), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_move1));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_move2(
- ET_TOUCH_MOVED, gfx::Point(40, 40), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ TouchEvent touch_move2(ET_TOUCH_MOVED, gfx::Point(40, 40), time,
+ PointerDetails(ui::EventPointerType::kTouch, 1));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_move2));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_cancel(
- ET_TOUCH_CANCELLED, gfx::Point(50, 50), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ TouchEvent touch_cancel(ET_TOUCH_CANCELLED, gfx::Point(50, 50), time,
+ PointerDetails(ui::EventPointerType::kTouch, 1));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_cancel));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_move3(
- ET_TOUCH_MOVED, gfx::Point(60, 60), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent touch_move3(ET_TOUCH_MOVED, gfx::Point(60, 60), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_move3));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_release(
- ET_TOUCH_RELEASED, gfx::Point(70, 70), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent touch_release(ET_TOUCH_RELEASED, gfx::Point(70, 70), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_release));
time += base::TimeDelta::FromMilliseconds(10);
}
@@ -170,75 +152,63 @@ TEST_F(GestureProviderAuraTest, ContinueGestureDetectionAfterMultipleCancel) {
GestureConfiguration::GetInstance()->set_single_pointer_cancel_enabled(true);
base::TimeTicks time = ui::EventTimeForNow();
- TouchEvent touch_press1(
- ET_TOUCH_PRESSED, gfx::Point(10, 10), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent touch_press1(ET_TOUCH_PRESSED, gfx::Point(10, 10), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_press1));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_press2(
- ET_TOUCH_PRESSED, gfx::Point(20, 20), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ TouchEvent touch_press2(ET_TOUCH_PRESSED, gfx::Point(20, 20), time,
+ PointerDetails(ui::EventPointerType::kTouch, 1));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_press2));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_press3(
- ET_TOUCH_PRESSED, gfx::Point(30, 30), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2));
+ TouchEvent touch_press3(ET_TOUCH_PRESSED, gfx::Point(30, 30), time,
+ PointerDetails(ui::EventPointerType::kTouch, 2));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_press3));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_move1(
- ET_TOUCH_MOVED, gfx::Point(40, 40), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent touch_move1(ET_TOUCH_MOVED, gfx::Point(40, 40), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_move1));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_move2(
- ET_TOUCH_MOVED, gfx::Point(50, 50), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ TouchEvent touch_move2(ET_TOUCH_MOVED, gfx::Point(50, 50), time,
+ PointerDetails(ui::EventPointerType::kTouch, 1));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_move2));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_move3(
- ET_TOUCH_MOVED, gfx::Point(60, 60), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2));
+ TouchEvent touch_move3(ET_TOUCH_MOVED, gfx::Point(60, 60), time,
+ PointerDetails(ui::EventPointerType::kTouch, 2));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_move3));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_cancel1(
- ET_TOUCH_CANCELLED, gfx::Point(70, 70), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ TouchEvent touch_cancel1(ET_TOUCH_CANCELLED, gfx::Point(70, 70), time,
+ PointerDetails(ui::EventPointerType::kTouch, 1));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_cancel1));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_move4(
- ET_TOUCH_MOVED, gfx::Point(80, 80), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent touch_move4(ET_TOUCH_MOVED, gfx::Point(80, 80), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_move4));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_move5(
- ET_TOUCH_MOVED, gfx::Point(90, 90), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2));
+ TouchEvent touch_move5(ET_TOUCH_MOVED, gfx::Point(90, 90), time,
+ PointerDetails(ui::EventPointerType::kTouch, 2));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_move5));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_cancel2(
- ET_TOUCH_CANCELLED, gfx::Point(100, 100), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2));
+ TouchEvent touch_cancel2(ET_TOUCH_CANCELLED, gfx::Point(100, 100), time,
+ PointerDetails(ui::EventPointerType::kTouch, 2));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_cancel2));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_move6(
- ET_TOUCH_MOVED, gfx::Point(110, 110), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent touch_move6(ET_TOUCH_MOVED, gfx::Point(110, 110), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_move6));
time += base::TimeDelta::FromMilliseconds(10);
- TouchEvent touch_release(
- ET_TOUCH_RELEASED, gfx::Point(120, 120), time,
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ TouchEvent touch_release(ET_TOUCH_RELEASED, gfx::Point(120, 120), time,
+ PointerDetails(ui::EventPointerType::kTouch, 0));
EXPECT_TRUE(provider()->OnTouchEvent(&touch_release));
time += base::TimeDelta::FromMilliseconds(10);
}
@@ -251,30 +221,26 @@ TEST_F(GestureProviderAuraTest, IgnoresIdenticalMoveEvents) {
const int kTouchId0 = 5;
const int kTouchId1 = 3;
- PointerDetails pointer_details1(EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId0);
+ PointerDetails pointer_details1(EventPointerType::kTouch, kTouchId0);
base::TimeTicks time = ui::EventTimeForNow();
TouchEvent press0_1(ET_TOUCH_PRESSED, gfx::Point(9, 10), time,
pointer_details1);
EXPECT_TRUE(provider()->OnTouchEvent(&press0_1));
- PointerDetails pointer_details2(EventPointerType::POINTER_TYPE_TOUCH,
- kTouchId1);
+ PointerDetails pointer_details2(EventPointerType::kTouch, kTouchId1);
TouchEvent press1_1(ET_TOUCH_PRESSED, gfx::Point(40, 40), time,
pointer_details2);
EXPECT_TRUE(provider()->OnTouchEvent(&press1_1));
time += base::TimeDelta::FromMilliseconds(10);
- pointer_details1 =
- PointerDetails(EventPointerType::POINTER_TYPE_TOUCH, kTouchId0, kRadiusX,
- kRadiusY, kForce, kAngle);
+ pointer_details1 = PointerDetails(EventPointerType::kTouch, kTouchId0,
+ kRadiusX, kRadiusY, kForce, kAngle);
TouchEvent move0_1(ET_TOUCH_MOVED, gfx::Point(10, 10), time, pointer_details1,
0);
EXPECT_TRUE(provider()->OnTouchEvent(&move0_1));
- pointer_details2 =
- PointerDetails(EventPointerType::POINTER_TYPE_TOUCH, kTouchId1, kRadiusX,
- kRadiusY, kForce, kAngle);
+ pointer_details2 = PointerDetails(EventPointerType::kTouch, kTouchId1,
+ kRadiusX, kRadiusY, kForce, kAngle);
TouchEvent move1_1(ET_TOUCH_MOVED, gfx::Point(100, 200), time,
pointer_details2, 0);
EXPECT_TRUE(provider()->OnTouchEvent(&move1_1));
diff --git a/chromium/ui/events/gestures/gesture_recognizer_impl.cc b/chromium/ui/events/gestures/gesture_recognizer_impl.cc
index 5c9c6c358cf..0539a81a4ca 100644
--- a/chromium/ui/events/gestures/gesture_recognizer_impl.cc
+++ b/chromium/ui/events/gestures/gesture_recognizer_impl.cc
@@ -9,8 +9,8 @@
#include <limits>
#include <memory>
+#include "base/check.h"
#include "base/command_line.h"
-#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "base/time/time.h"
@@ -230,7 +230,7 @@ GestureRecognizerImpl::GetEventPerPointForConsumer(GestureConsumer* consumer,
for (size_t i = 0; i < pointer_state.GetPointerCount(); ++i) {
auto touch_event = std::make_unique<TouchEvent>(
type, gfx::Point(), EventTimeForNow(),
- PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
+ PointerDetails(ui::EventPointerType::kTouch,
pointer_state.GetPointerId(i)),
EF_IS_SYNTHESIZED);
gfx::PointF point(pointer_state.GetX(i), pointer_state.GetY(i));
diff --git a/chromium/ui/events/gestures/motion_event_aura.cc b/chromium/ui/events/gestures/motion_event_aura.cc
index 496718a9f2f..2ac40177014 100644
--- a/chromium/ui/events/gestures/motion_event_aura.cc
+++ b/chromium/ui/events/gestures/motion_event_aura.cc
@@ -4,7 +4,8 @@
#include "ui/events/gestures/motion_event_aura.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "ui/events/gesture_detection/gesture_configuration.h"
namespace ui {
@@ -13,15 +14,15 @@ namespace {
MotionEvent::ToolType EventPointerTypeToMotionEventToolType(
EventPointerType type) {
switch (type) {
- case EventPointerType::POINTER_TYPE_UNKNOWN:
+ case EventPointerType::kUnknown:
return MotionEvent::ToolType::UNKNOWN;
- case EventPointerType::POINTER_TYPE_MOUSE:
+ case EventPointerType::kMouse:
return MotionEvent::ToolType::MOUSE;
- case EventPointerType::POINTER_TYPE_PEN:
+ case EventPointerType::kPen:
return MotionEvent::ToolType::STYLUS;
- case EventPointerType::POINTER_TYPE_TOUCH:
+ case EventPointerType::kTouch:
return MotionEvent::ToolType::FINGER;
- case EventPointerType::POINTER_TYPE_ERASER:
+ case EventPointerType::kEraser:
return MotionEvent::ToolType::ERASER;
}
@@ -49,8 +50,8 @@ PointerProperties GetPointerPropertiesFromTouchEvent(const TouchEvent& touch) {
if (!pointer_properties.touch_major) {
float default_size;
switch (touch.pointer_details().pointer_type) {
- case EventPointerType::POINTER_TYPE_PEN:
- case EventPointerType::POINTER_TYPE_ERASER:
+ case EventPointerType::kPen:
+ case EventPointerType::kEraser:
// Default size for stylus events is 1x1.
default_size = 1;
break;
diff --git a/chromium/ui/events/gestures/motion_event_aura_unittest.cc b/chromium/ui/events/gestures/motion_event_aura_unittest.cc
index 5fb665b71cd..ebe607bc426 100644
--- a/chromium/ui/events/gestures/motion_event_aura_unittest.cc
+++ b/chromium/ui/events/gestures/motion_event_aura_unittest.cc
@@ -12,9 +12,8 @@
namespace {
ui::TouchEvent TouchWithType(ui::EventType type, int id) {
- return ui::TouchEvent(
- type, gfx::Point(0, 0), base::TimeTicks(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, id));
+ return ui::TouchEvent(type, gfx::Point(0, 0), base::TimeTicks(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, id));
}
ui::TouchEvent TouchWithPosition(ui::EventType type,
@@ -23,9 +22,8 @@ ui::TouchEvent TouchWithPosition(ui::EventType type,
float y,
float raw_x,
float raw_y) {
- ui::TouchEvent event(
- type, gfx::Point(), base::TimeTicks(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, id));
+ ui::TouchEvent event(type, gfx::Point(), base::TimeTicks(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, id));
event.set_location_f(gfx::PointF(x, y));
event.set_root_location_f(gfx::PointF(raw_x, raw_y));
return event;
@@ -39,8 +37,8 @@ ui::TouchEvent TouchWithTapParams(ui::EventType type,
float pressure) {
ui::TouchEvent event(
type, gfx::Point(1, 1), base::TimeTicks(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, id, radius_x,
- radius_y, pressure, rotation_angle),
+ ui::PointerDetails(ui::EventPointerType::kTouch, id, radius_x, radius_y,
+ pressure, rotation_angle),
0);
return event;
}
@@ -50,9 +48,8 @@ base::TimeTicks MsToTicks(int ms) {
}
ui::TouchEvent TouchWithTime(ui::EventType type, int id, int ms) {
- return ui::TouchEvent(
- type, gfx::Point(0, 0), MsToTicks(ms),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, id));
+ return ui::TouchEvent(type, gfx::Point(0, 0), MsToTicks(ms),
+ ui::PointerDetails(ui::EventPointerType::kTouch, id));
}
} // namespace
@@ -434,7 +431,7 @@ TEST(MotionEventAuraTest, ToolType) {
EXPECT_EQ(MotionEvent::ToolType::FINGER, event.GetToolType(0));
touch_event = TouchWithType(ET_TOUCH_RELEASED, 7);
- PointerDetails pointer_details(EventPointerType::POINTER_TYPE_PEN,
+ PointerDetails pointer_details(EventPointerType::kPen,
/* pointer_id*/ 7,
/* radius_x */ 5.0f,
/* radius_y */ 5.0f,
@@ -539,9 +536,9 @@ TEST(MotionEventAuraTest, IgnoresTouchesOverCapacity) {
TEST(MotionEventAuraTest, PenRadiusDefault) {
MotionEventAura event;
- TouchEvent touch_event = ui::TouchEvent(
- ET_TOUCH_PRESSED, gfx::Point(0, 0), base::TimeTicks(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_PEN, 7));
+ TouchEvent touch_event =
+ ui::TouchEvent(ET_TOUCH_PRESSED, gfx::Point(0, 0), base::TimeTicks(),
+ ui::PointerDetails(ui::EventPointerType::kPen, 7));
EXPECT_TRUE(event.OnTouch(touch_event));
EXPECT_EQ(MotionEvent::ToolType::STYLUS, event.GetToolType(0));
EXPECT_EQ(1u, event.GetTouchMajor(0));
diff --git a/chromium/ui/events/gestures/physics_based_fling_curve.cc b/chromium/ui/events/gestures/physics_based_fling_curve.cc
index a46f783ffae..9a715080918 100644
--- a/chromium/ui/events/gestures/physics_based_fling_curve.cc
+++ b/chromium/ui/events/gestures/physics_based_fling_curve.cc
@@ -54,7 +54,7 @@ gfx::Vector2dF GetDuration(const gfx::Vector2dF& velocity,
// generate fling animation curve.
gfx::Vector2dF CalculateEndPoint(const gfx::Vector2dF& pixels_per_inch,
const gfx::Vector2dF& velocity_pixels_per_ms,
- const gfx::Size& viewport) {
+ const gfx::Size& bounding_size) {
// deceleration is in pixels/ ms^2.
gfx::Vector2dF deceleration = GetDecelerationInPixelsPerMs2(pixels_per_inch);
@@ -66,18 +66,14 @@ gfx::Vector2dF CalculateEndPoint(const gfx::Vector2dF& pixels_per_inch,
GetOffset(velocity_pixels_per_ms.x(), deceleration.x(), duration.x()),
GetOffset(velocity_pixels_per_ms.y(), deceleration.y(), duration.y()));
- // Upper bound for the scroll distance for a fling
- gfx::Vector2dF max_end_point =
- gfx::Vector2dF(3 * viewport.width(), 3 * viewport.height());
-
- if (std::abs(offset_in_screen_coord_space.x()) > max_end_point.x()) {
+ if (std::abs(offset_in_screen_coord_space.x()) > bounding_size.width()) {
float sign = offset_in_screen_coord_space.x() > 0 ? 1 : -1;
- offset_in_screen_coord_space.set_x(max_end_point.x() * sign);
+ offset_in_screen_coord_space.set_x(bounding_size.width() * sign);
}
- if (std::abs(offset_in_screen_coord_space.y()) > max_end_point.y()) {
+ if (std::abs(offset_in_screen_coord_space.y()) > bounding_size.height()) {
float sign = offset_in_screen_coord_space.y() > 0 ? 1 : -1;
- offset_in_screen_coord_space.set_y(max_end_point.y() * sign);
+ offset_in_screen_coord_space.set_y(bounding_size.height() * sign);
}
return offset_in_screen_coord_space;
@@ -91,17 +87,21 @@ PhysicsBasedFlingCurve::PhysicsBasedFlingCurve(
const gfx::Vector2dF& velocity,
base::TimeTicks start_timestamp,
const gfx::Vector2dF& pixels_per_inch,
- const gfx::Size& viewport)
+ const float boost_multiplier,
+ const gfx::Size& bounding_size)
: start_timestamp_(start_timestamp),
p1_(gfx::PointF(kDefaultP1X, kDefaultP1Y)),
p2_(gfx::PointF(kDefaultP2X, kDefaultP2Y)),
- distance_(CalculateEndPoint(pixels_per_inch,
- gfx::ScaleVector2d(velocity, 1 / 1000.0f),
- viewport)),
+ distance_(CalculateEndPoint(
+ pixels_per_inch,
+ gfx::ScaleVector2d(velocity, 1 / 1000.0f),
+ ScaleToFlooredSize(bounding_size,
+ boost_multiplier * kDefaultBoundsMultiplier))),
curve_duration_(CalculateDurationAndConfigureControlPoints(velocity)),
bezier_(p1_.x(), p1_.y(), p2_.x(), p2_.y()),
previous_time_delta_(base::TimeDelta()) {
DCHECK(!velocity.IsZero());
+ CHECK(!std::isnan(velocity.x()) && !std::isnan(velocity.y()));
}
PhysicsBasedFlingCurve::~PhysicsBasedFlingCurve() = default;
diff --git a/chromium/ui/events/gestures/physics_based_fling_curve.h b/chromium/ui/events/gestures/physics_based_fling_curve.h
index 38af2bf7aab..4d4bfc7b0c4 100644
--- a/chromium/ui/events/gestures/physics_based_fling_curve.h
+++ b/chromium/ui/events/gestures/physics_based_fling_curve.h
@@ -21,10 +21,15 @@ namespace ui {
// suitable for touch screen-based flings.
class EVENTS_BASE_EXPORT PhysicsBasedFlingCurve : public GestureCurve {
public:
- PhysicsBasedFlingCurve(const gfx::Vector2dF& velocity,
- base::TimeTicks start_timestamp,
- const gfx::Vector2dF& pixels_per_inch,
- const gfx::Size& viewport);
+ PhysicsBasedFlingCurve(
+ const gfx::Vector2dF& velocity,
+ base::TimeTicks start_timestamp,
+ const gfx::Vector2dF& pixels_per_inch,
+ // Multiplier for fling distance based on fling boosting
+ const float boost_multiplier,
+ // Maximum fling distance subject to boost_multiplier and default
+ // bounds multiplier
+ const gfx::Size& bounding_size);
~PhysicsBasedFlingCurve() override;
// GestureCurve implementation.
@@ -35,6 +40,9 @@ class EVENTS_BASE_EXPORT PhysicsBasedFlingCurve : public GestureCurve {
float curve_duration() const { return curve_duration_; }
const gfx::PointF& p1_for_testing() const { return p1_; }
const gfx::PointF& p2_for_testing() const { return p2_; }
+ static int default_bounds_multiplier_for_testing() {
+ return kDefaultBoundsMultiplier;
+ }
private:
// Time when fling curve is generated.
@@ -50,6 +58,12 @@ class EVENTS_BASE_EXPORT PhysicsBasedFlingCurve : public GestureCurve {
// crrev.com/c/1865928 is merged.
// crbug.com/1028501
const float curve_duration_;
+
+ // Default value used to scale the viewport when it is passed in as a
+ // parameter in the generation of a physics based fling curve. This value
+ // increases the upper bound of the scroll distance for a fling.
+ constexpr static int kDefaultBoundsMultiplier = 3;
+
const gfx::CubicBezier bezier_;
base::TimeDelta previous_time_delta_;
gfx::Vector2dF cumulative_scroll_;
diff --git a/chromium/ui/events/gestures/physics_based_fling_curve_unittest.cc b/chromium/ui/events/gestures/physics_based_fling_curve_unittest.cc
index f954d6d029b..010da57d12e 100644
--- a/chromium/ui/events/gestures/physics_based_fling_curve_unittest.cc
+++ b/chromium/ui/events/gestures/physics_based_fling_curve_unittest.cc
@@ -9,6 +9,7 @@
namespace ui {
const float kDefaultPixelsPerInch = 96.f;
+const float kBoostMultiplierUnboosted = 1.f;
TEST(PhysicsBasedFlingCurveTest, BasicFlingTestVelocityY) {
const gfx::Vector2dF fling_velocity(0, 5000);
@@ -17,7 +18,8 @@ TEST(PhysicsBasedFlingCurveTest, BasicFlingTestVelocityY) {
kDefaultPixelsPerInch);
const gfx::Size viewport(1920, 1080);
- PhysicsBasedFlingCurve curve(fling_velocity, now, pixels_per_inch, viewport);
+ PhysicsBasedFlingCurve curve(fling_velocity, now, pixels_per_inch,
+ kBoostMultiplierUnboosted, viewport);
gfx::Vector2dF offset;
gfx::Vector2dF velocity;
@@ -66,7 +68,8 @@ TEST(PhysicsBasedFlingCurveTest, BasicFlingTestVelocityX) {
kDefaultPixelsPerInch);
const gfx::Size viewport(1920, 1080);
- PhysicsBasedFlingCurve curve(fling_velocity, now, pixels_per_inch, viewport);
+ PhysicsBasedFlingCurve curve(fling_velocity, now, pixels_per_inch,
+ kBoostMultiplierUnboosted, viewport);
gfx::Vector2dF offset;
gfx::Vector2dF velocity;
@@ -114,7 +117,8 @@ TEST(PhysicsBasedFlingCurveTest, BasicFlingTestVelocityXAndY) {
kDefaultPixelsPerInch);
const gfx::Size viewport(1920, 1080);
- PhysicsBasedFlingCurve curve(fling_velocity, now, pixels_per_inch, viewport);
+ PhysicsBasedFlingCurve curve(fling_velocity, now, pixels_per_inch,
+ kBoostMultiplierUnboosted, viewport);
gfx::Vector2dF offset;
gfx::Vector2dF velocity;
@@ -162,7 +166,8 @@ TEST(PhysicsBasedFlingCurveTest, ControlPointsWithSlopeLessThan1) {
kDefaultPixelsPerInch);
const gfx::Size viewport(1920, 1080);
- PhysicsBasedFlingCurve curve(velocity, now, pixels_per_inch, viewport);
+ PhysicsBasedFlingCurve curve(velocity, now, pixels_per_inch,
+ kBoostMultiplierUnboosted, viewport);
EXPECT_EQ(0.20f, curve.p1_for_testing().x());
EXPECT_NEAR(curve.p1_for_testing().y(), 0.43f, 0.01f);
@@ -177,7 +182,8 @@ TEST(PhysicsBasedFlingCurveTest, ControlPointsWithSlopeGreaterThan1) {
kDefaultPixelsPerInch);
const gfx::Size viewport(1920, 1080);
- PhysicsBasedFlingCurve curve(velocity, now, pixels_per_inch, viewport);
+ PhysicsBasedFlingCurve curve(velocity, now, pixels_per_inch,
+ kBoostMultiplierUnboosted, viewport);
EXPECT_NEAR(curve.p1_for_testing().x(), 0.19f, 0.01f);
EXPECT_EQ(curve.p1_for_testing().y(), 1.0f);
diff --git a/chromium/ui/events/ipc/BUILD.gn b/chromium/ui/events/ipc/BUILD.gn
index 2abfe9c1bf0..378eca46614 100644
--- a/chromium/ui/events/ipc/BUILD.gn
+++ b/chromium/ui/events/ipc/BUILD.gn
@@ -17,6 +17,7 @@ jumbo_component("ipc") {
public_deps = [
"//base",
"//ipc",
+ "//ui/events:event_constants",
"//ui/events/types:headers",
]
}
diff --git a/chromium/ui/events/ipc/ui_events_param_traits_macros.h b/chromium/ui/events/ipc/ui_events_param_traits_macros.h
index fb2b6722bac..f80ed17f0f3 100644
--- a/chromium/ui/events/ipc/ui_events_param_traits_macros.h
+++ b/chromium/ui/events/ipc/ui_events_param_traits_macros.h
@@ -7,11 +7,13 @@
#include "base/component_export.h"
#include "ipc/ipc_message_macros.h"
+#include "ui/events/event_constants.h"
#include "ui/events/types/scroll_types.h"
#undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT COMPONENT_EXPORT(UI_EVENTS_IPC)
+IPC_ENUM_TRAITS_MAX_VALUE(ui::EventPointerType, ui::EventPointerType::kMaxValue)
IPC_ENUM_TRAITS_MIN_MAX_VALUE(ui::ScrollGranularity,
ui::ScrollGranularity::kFirstScrollGranularity,
ui::ScrollGranularity::kMaxValue)
diff --git a/chromium/ui/events/keycodes/BUILD.gn b/chromium/ui/events/keycodes/BUILD.gn
index 772d0ef90e0..0068238c9f9 100644
--- a/chromium/ui/events/keycodes/BUILD.gn
+++ b/chromium/ui/events/keycodes/BUILD.gn
@@ -4,6 +4,7 @@
import("//build/config/jumbo.gni")
import("//build/config/ui.gni")
+import("//ui/base/ui_features.gni")
import("//ui/ozone/ozone.gni")
jumbo_source_set("xkb") {
@@ -20,6 +21,10 @@ jumbo_source_set("xkb") {
"//base",
"//ui/events:dom_keycode_converter",
]
+
+ if (!use_xkbcommon) {
+ public_deps += [ "//ui/gfx/x" ]
+ }
}
if (use_x11 || ozone_platform_x11) {
@@ -42,7 +47,5 @@ if (use_x11 || ozone_platform_x11) {
"//ui/events:dom_keycode_converter",
"//ui/gfx/x",
]
-
- configs += [ "//build/config/linux:x11" ]
}
}
diff --git a/chromium/ui/events/keycodes/dom/dom_code_data.inc b/chromium/ui/events/keycodes/dom/dom_code_data.inc
index a454f1dec01..056c0576f80 100644
--- a/chromium/ui/events/keycodes/dom/dom_code_data.inc
+++ b/chromium/ui/events/keycodes/dom/dom_code_data.inc
@@ -463,6 +463,9 @@ DOM_CODE_DECLARATION {
// KEY_BRIGHTNESS* added in Linux 3.16
// http://www.usb.org/developers/hidpage/HUTRR41.pdf
+ //
+ // Keyboard backlight/illumination spec update.
+ // https://www.usb.org/sites/default/files/hutrr73_-_fn_key_and_keyboard_backlight_brightness_0.pdf
// USB evdev XKB Win Mac Code
DOM_CODE(0x0c0060, 0x0166, 0x016e, 0x0000, 0xffff, NULL, INFO),
DOM_CODE(0x0c0061, 0x0172, 0x017a, 0x0000, 0xffff, NULL, CLOSED_CAPTION_TOGGLE),
@@ -473,6 +476,8 @@ DOM_CODE_DECLARATION {
DOM_CODE(0x0c0073, 0x0250, 0x0258, 0x0000, 0xffff, NULL, BRIGHTNESS_MINIMIUM),
DOM_CODE(0x0c0074, 0x0251, 0x0259, 0x0000, 0xffff, NULL, BRIGHTNESS_MAXIMUM),
DOM_CODE(0x0c0075, 0x00f4, 0x00fc, 0x0000, 0xffff, NULL, BRIGHTNESS_AUTO),
+ DOM_CODE(0x0c0079, 0x00e6, 0x00ee, 0x0000, 0xffff, NULL, KBD_ILLUM_UP),
+ DOM_CODE(0x0c007a, 0x00e5, 0x00ed, 0x0000, 0xffff, NULL, KBD_ILLUM_DOWN),
DOM_CODE(0x0c0083, 0x0195, 0x019d, 0x0000, 0xffff, NULL, MEDIA_LAST),
DOM_CODE(0x0c008c, 0x00a9, 0x00b1, 0x0000, 0xffff, NULL, LAUNCH_PHONE),
DOM_CODE(0x0c008d, 0x016a, 0x0172, 0x0000, 0xffff, NULL, PROGRAM_GUIDE),
diff --git a/chromium/ui/events/keycodes/dom/dom_keyboard_layout.cc b/chromium/ui/events/keycodes/dom/dom_keyboard_layout.cc
index 6f311cce105..4ddac90e4e9 100644
--- a/chromium/ui/events/keycodes/dom/dom_keyboard_layout.cc
+++ b/chromium/ui/events/keycodes/dom/dom_keyboard_layout.cc
@@ -4,7 +4,6 @@
#include "ui/events/keycodes/dom/dom_keyboard_layout.h"
-#include "base/logging.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversion_utils.h"
#include "ui/events/keycodes/dom/dom_code.h"
diff --git a/chromium/ui/events/keycodes/dom/dom_keyboard_layout_manager.cc b/chromium/ui/events/keycodes/dom/dom_keyboard_layout_manager.cc
index 4af192804a0..412a48e98db 100644
--- a/chromium/ui/events/keycodes/dom/dom_keyboard_layout_manager.cc
+++ b/chromium/ui/events/keycodes/dom/dom_keyboard_layout_manager.cc
@@ -6,7 +6,6 @@
#include <utility>
-#include "base/logging.h"
namespace ui {
diff --git a/chromium/ui/events/keycodes/dom/dom_keyboard_layout_map_base.cc b/chromium/ui/events/keycodes/dom/dom_keyboard_layout_map_base.cc
index f695bf08a6e..e5d6653a28a 100644
--- a/chromium/ui/events/keycodes/dom/dom_keyboard_layout_map_base.cc
+++ b/chromium/ui/events/keycodes/dom/dom_keyboard_layout_map_base.cc
@@ -8,7 +8,7 @@
#include <memory>
#include <string>
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/events/keycodes/dom/dom_key.h"
#include "ui/events/keycodes/dom/dom_keyboard_layout.h"
#include "ui/events/keycodes/dom/dom_keyboard_layout_manager.h"
diff --git a/chromium/ui/events/keycodes/dom/dom_keyboard_layout_map_ozone.cc b/chromium/ui/events/keycodes/dom/dom_keyboard_layout_map_ozone.cc
index e8ab6115c75..58f5c62329e 100644
--- a/chromium/ui/events/keycodes/dom/dom_keyboard_layout_map_ozone.cc
+++ b/chromium/ui/events/keycodes/dom/dom_keyboard_layout_map_ozone.cc
@@ -5,6 +5,7 @@
#include <cstdint>
#include <string>
+#include "base/check_op.h"
#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "ui/events/keycodes/dom/dom_code.h"
diff --git a/chromium/ui/events/keycodes/dom/dom_keyboard_layout_map_unittest.cc b/chromium/ui/events/keycodes/dom/dom_keyboard_layout_map_unittest.cc
index d2234d23842..0e7592c1336 100644
--- a/chromium/ui/events/keycodes/dom/dom_keyboard_layout_map_unittest.cc
+++ b/chromium/ui/events/keycodes/dom/dom_keyboard_layout_map_unittest.cc
@@ -5,8 +5,10 @@
#include <string>
#include <vector>
+#include "base/check_op.h"
#include "base/containers/flat_map.h"
#include "base/macros.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/keycodes/dom/dom_key.h"
diff --git a/chromium/ui/events/keycodes/dom/keycode_converter_unittest.cc b/chromium/ui/events/keycodes/dom/keycode_converter_unittest.cc
index 19780ad29d8..8080b1862df 100644
--- a/chromium/ui/events/keycodes/dom/keycode_converter_unittest.cc
+++ b/chromium/ui/events/keycodes/dom/keycode_converter_unittest.cc
@@ -24,10 +24,10 @@ namespace {
// These are in the same order as the columns in dom_code_data.inc
// as reflected in the DOM_CODE() macro below.
const size_t expected_mapped_key_count[] = {
- 214, // evdev
- 214, // xkb
- 157, // windows
- 119, // mac
+ 216, // evdev
+ 216, // xkb
+ 157, // windows
+ 119, // mac
};
const size_t kNativeColumns = base::size(expected_mapped_key_count);
diff --git a/chromium/ui/events/keycodes/dom_us_layout_data.h b/chromium/ui/events/keycodes/dom_us_layout_data.h
index aa40c3a0e5d..fca30ec7702 100644
--- a/chromium/ui/events/keycodes/dom_us_layout_data.h
+++ b/chromium/ui/events/keycodes/dom_us_layout_data.h
@@ -580,7 +580,10 @@ const struct DomCodeToKeyboardCodeEntry {
#if defined(OS_POSIX)
{DomCode::BRIGHTNESS_UP, VKEY_BRIGHTNESS_UP}, // 0x0C006F BrightnessUp
{DomCode::BRIGHTNESS_DOWN,
- VKEY_BRIGHTNESS_DOWN}, // 0x0C0070 BrightnessDown
+ VKEY_BRIGHTNESS_DOWN}, // 0x0C0070 BrightnessDown
+ {DomCode::KBD_ILLUM_UP, VKEY_KBD_BRIGHTNESS_UP}, // 0x0C0079 KbdIllumUp
+ {DomCode::KBD_ILLUM_DOWN,
+ VKEY_KBD_BRIGHTNESS_DOWN}, // 0x0C007a KbdIllumDown
#endif
{DomCode::MEDIA_TRACK_NEXT,
VKEY_MEDIA_NEXT_TRACK}, // 0x0C00B5 MediaTrackNext
@@ -642,8 +645,6 @@ const DomCodeToKeyboardCodeEntry kFallbackKeyboardCodeToDomCodeMap[] = {
// VKEY_OEM_104 // 0x0C00B3 MediaFastForward
//
// VKEYs with no corresponding DomCode, but a Linux evdev usage code:
- // VKEY_KBD_BRIGHTNESS_DOWN // evdev KEY_KBDILLUMDOWN
- // VKEY_KBD_BRIGHTNESS_UP // evdev KEY_KBDILLUMUP
// VKEY_WLAN // evdev KEY_WLAN
//
// VKEYs with no corresponding DomCode and no obvious USB usage code:
diff --git a/chromium/ui/events/keycodes/keyboard_code_conversion_mac.mm b/chromium/ui/events/keycodes/keyboard_code_conversion_mac.mm
index d6b01cc1f50..e6384ac4314 100644
--- a/chromium/ui/events/keycodes/keyboard_code_conversion_mac.mm
+++ b/chromium/ui/events/keycodes/keyboard_code_conversion_mac.mm
@@ -8,7 +8,7 @@
#import <Carbon/Carbon.h>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/mac/mac_logging.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/memory/scoped_policy.h"
diff --git a/chromium/ui/events/keycodes/keyboard_code_conversion_x.cc b/chromium/ui/events/keycodes/keyboard_code_conversion_x.cc
index 9ff13d960b9..7b12d1aac1d 100644
--- a/chromium/ui/events/keycodes/keyboard_code_conversion_x.cc
+++ b/chromium/ui/events/keycodes/keyboard_code_conversion_x.cc
@@ -15,6 +15,7 @@
#include "base/strings/utf_string_conversions.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/keycodes/keyboard_code_conversion_xkb.h"
+#include "ui/events/keycodes/keyboard_codes_posix.h"
#include "ui/events/keycodes/keysym_to_unicode.h"
#include "ui/gfx/x/x11.h"
@@ -1217,7 +1218,10 @@ int XKeysymForWindowsKeyCode(KeyboardCode keycode, bool shift) {
case VKEY_RETURN:
return XK_Return;
case VKEY_SHIFT:
+ case VKEY_LSHIFT:
return XK_Shift_L;
+ case VKEY_RSHIFT:
+ return XK_Shift_R;
case VKEY_CONTROL:
return XK_Control_L;
case VKEY_MENU:
diff --git a/chromium/ui/events/keycodes/platform_key_map_win.cc b/chromium/ui/events/keycodes/platform_key_map_win.cc
index 3382d350de9..ecc42cbe0f9 100644
--- a/chromium/ui/events/keycodes/platform_key_map_win.cc
+++ b/chromium/ui/events/keycodes/platform_key_map_win.cc
@@ -7,9 +7,9 @@
#include <algorithm>
#include <utility>
+#include "base/check_op.h"
#include "base/feature_list.h"
#include "base/lazy_instance.h"
-#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/stl_util.h"
#include "base/threading/thread_local.h"
diff --git a/chromium/ui/events/keycodes/xkb_keysym.h b/chromium/ui/events/keycodes/xkb_keysym.h
index 88e83c5e62c..c2baef311b1 100644
--- a/chromium/ui/events/keycodes/xkb_keysym.h
+++ b/chromium/ui/events/keycodes/xkb_keysym.h
@@ -17,7 +17,7 @@
#else // !BUILDFLAG(USE_XKBCOMMON)
-#include "ui/gfx/x/x11.h"
+#include "ui/gfx/x/x11.h" // nogncheck
using xkb_keysym_t = uint32_t;
diff --git a/chromium/ui/events/mobile_scroller.cc b/chromium/ui/events/mobile_scroller.cc
index 01002876618..19bcc5ce7b9 100644
--- a/chromium/ui/events/mobile_scroller.cc
+++ b/chromium/ui/events/mobile_scroller.cc
@@ -6,8 +6,10 @@
#include <cmath>
+#include "base/check_op.h"
#include "base/lazy_instance.h"
#include "base/macros.h"
+#include "base/notreached.h"
#include "base/numerics/math_constants.h"
namespace ui {
diff --git a/chromium/ui/events/mojom/BUILD.gn b/chromium/ui/events/mojom/BUILD.gn
index c281273dda8..63650aef411 100644
--- a/chromium/ui/events/mojom/BUILD.gn
+++ b/chromium/ui/events/mojom/BUILD.gn
@@ -18,4 +18,64 @@ mojom("mojom") {
"//ui/gfx/geometry/mojom",
"//ui/latency/mojom",
]
+
+ shared_cpp_typemaps = [
+ {
+ types = [
+ {
+ mojom = "ui.mojom.EventPointerType"
+ cpp = "::ui::EventPointerType"
+ },
+ {
+ mojom = "ui.mojom.ScrollGranularity"
+ cpp = "::ui::ScrollGranularity"
+ },
+ ]
+ traits_headers = [ "//ui/events/ipc/ui_events_param_traits_macros.h" ]
+ traits_public_deps = [ "//ui/events/ipc" ]
+ },
+ ]
+
+ cpp_typemaps = shared_cpp_typemaps
+ cpp_typemaps += [
+ {
+ types = [
+ # TODO(crbug.com/617167): Map directly to ui::Event.
+ {
+ mojom = "ui.mojom.Event"
+ cpp = "::std::unique_ptr<::ui::Event>"
+ move_only = true
+ },
+ {
+ mojom = "ui.mojom.EventMomentumPhase"
+ cpp = "::ui::EventMomentumPhase"
+ },
+ {
+ mojom = "ui.mojom.PointerDetails"
+ cpp = "::ui::PointerDetails"
+ },
+ {
+ mojom = "ui.mojom.ScrollEventPhase"
+ cpp = "::ui::ScrollEventPhase"
+ },
+ {
+ mojom = "ui.mojom.GestureDeviceType"
+ cpp = "::ui::GestureDeviceType"
+ },
+ ]
+
+ traits_sources = [ "event_mojom_traits.cc" ]
+ traits_headers = [ "//ui/events/event.h" ]
+ traits_private_headers = [ "event_mojom_traits.h" ]
+ traits_public_deps = [
+ "//ui/events",
+ "//ui/events:dom_keycode_converter",
+ "//ui/gfx/geometry/mojom",
+ "//ui/latency/mojom",
+ ]
+ traits_deps = [ "//ipc:param_traits" ]
+ },
+ ]
+
+ blink_cpp_typemaps = shared_cpp_typemaps
}
diff --git a/chromium/ui/events/mojom/OWNERS b/chromium/ui/events/mojom/OWNERS
index 743855d259f..1feb5149750 100644
--- a/chromium/ui/events/mojom/OWNERS
+++ b/chromium/ui/events/mojom/OWNERS
@@ -1,8 +1,4 @@
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-per-file *.typemap=set noparent
-per-file *.typemap=file://ipc/SECURITY_OWNERS
-
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
diff --git a/chromium/ui/events/mojom/blink_typemaps.gni b/chromium/ui/events/mojom/blink_typemaps.gni
deleted file mode 100644
index 4f4e185f003..00000000000
--- a/chromium/ui/events/mojom/blink_typemaps.gni
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2019 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.
-
-typemaps = [ "//ui/events/mojom/scroll_granularity.typemap" ]
diff --git a/chromium/ui/events/mojom/event.mojom b/chromium/ui/events/mojom/event.mojom
index 7cdb0422ef4..d8f206abcf2 100644
--- a/chromium/ui/events/mojom/event.mojom
+++ b/chromium/ui/events/mojom/event.mojom
@@ -64,7 +64,7 @@ struct ScrollData {
// This mirrors the C++ class of the same name, see it for details.
struct PointerDetails {
- PointerKind pointer_type;
+ EventPointerType pointer_type;
float radius_x;
float radius_y;
float force;
diff --git a/chromium/ui/events/mojom/event.typemap b/chromium/ui/events/mojom/event.typemap
deleted file mode 100644
index 74fa31b5ad7..00000000000
--- a/chromium/ui/events/mojom/event.typemap
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-mojom = "//ui/events/mojom/event.mojom"
-public_headers = [ "//ui/events/event.h" ]
-traits_headers = [ "//ui/events/mojom/event_mojom_traits.h" ]
-public_deps = [
- "//ui/events",
- "//ui/events:dom_keycode_converter",
- "//ui/gfx/geometry/mojom",
- "//ui/latency/mojom",
-]
-deps = [
- "//ipc:param_traits",
-]
-sources = [
- "//ui/events/mojom/event_mojom_traits.cc",
- "//ui/events/mojom/event_mojom_traits.h",
-]
-
-# TODO(moshayedi): crbug.com/617167. Map mojom.Event directly to ui::Event.
-type_mappings = [
- "ui.mojom.Event=::std::unique_ptr<::ui::Event>[move_only]",
- "ui.mojom.EventMomentumPhase=::ui::EventMomentumPhase",
- "ui.mojom.PointerDetails=::ui::PointerDetails",
- "ui.mojom.ScrollEventPhase=::ui::ScrollEventPhase",
- "ui.mojom.GestureDeviceType=::ui::GestureDeviceType",
-]
diff --git a/chromium/ui/events/mojom/event_constants.mojom b/chromium/ui/events/mojom/event_constants.mojom
index 4470dfe94e8..0107d7a554f 100644
--- a/chromium/ui/events/mojom/event_constants.mojom
+++ b/chromium/ui/events/mojom/event_constants.mojom
@@ -66,15 +66,8 @@ const int32 kMouseEventFlagIsTripleClick = 0x10000;
const int32 kMouseEventFlagIsNonClient = 0x20000;
// TODO(erg): Move accessibility flags and maybe synthetic touch events here.
-
-// TODO(sky): rename EventPointerType.
-enum PointerKind {
- UNKNOWN,
- MOUSE,
- PEN,
- TOUCH,
- ERASER,
-};
+[Native]
+enum EventPointerType;
// Phase information used for a ScrollEvent.
// These values match ui::ScrollEventPhase in ui/events/event_constants.h
diff --git a/chromium/ui/events/mojom/event_mojom_traits.cc b/chromium/ui/events/mojom/event_mojom_traits.cc
index 9c49a894229..0f6ecab04a2 100644
--- a/chromium/ui/events/mojom/event_mojom_traits.cc
+++ b/chromium/ui/events/mojom/event_mojom_traits.cc
@@ -8,6 +8,7 @@
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/events/gesture_event_details.h"
+#include "ui/events/ipc/ui_events_param_traits_macros.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/mojom/event_constants.mojom.h"
diff --git a/chromium/ui/events/mojom/event_mojom_traits.h b/chromium/ui/events/mojom/event_mojom_traits.h
index 561218d6ba9..9e84ab54b64 100644
--- a/chromium/ui/events/mojom/event_mojom_traits.h
+++ b/chromium/ui/events/mojom/event_mojom_traits.h
@@ -14,12 +14,12 @@
#include "ui/events/event_constants.h"
#include "ui/events/mojom/event.mojom.h"
#include "ui/events/mojom/event_constants.mojom.h"
+#include "ui/events/pointer_details.h"
#include "ui/events/types/event_type.h"
namespace ui {
class Event;
class LatencyInfo;
-struct PointerDetails;
}
namespace mojo {
@@ -101,49 +101,6 @@ struct EnumTraits<ui::mojom::EventMomentumPhase, ui::EventMomentumPhase> {
};
template <>
-struct EnumTraits<ui::mojom::PointerKind, ui::EventPointerType> {
- static ui::mojom::PointerKind ToMojom(ui::EventPointerType input) {
- switch (input) {
- case ui::EventPointerType::POINTER_TYPE_UNKNOWN:
- return ui::mojom::PointerKind::UNKNOWN;
- case ui::EventPointerType::POINTER_TYPE_MOUSE:
- return ui::mojom::PointerKind::MOUSE;
- case ui::EventPointerType::POINTER_TYPE_PEN:
- return ui::mojom::PointerKind::PEN;
- case ui::EventPointerType::POINTER_TYPE_TOUCH:
- return ui::mojom::PointerKind::TOUCH;
- case ui::EventPointerType::POINTER_TYPE_ERASER:
- return ui::mojom::PointerKind::ERASER;
- }
- NOTREACHED();
- return ui::mojom::PointerKind::UNKNOWN;
- }
-
- static bool FromMojom(ui::mojom::PointerKind input,
- ui::EventPointerType* out) {
- switch (input) {
- case ui::mojom::PointerKind::UNKNOWN:
- *out = ui::EventPointerType::POINTER_TYPE_UNKNOWN;
- return true;
- case ui::mojom::PointerKind::MOUSE:
- *out = ui::EventPointerType::POINTER_TYPE_MOUSE;
- return true;
- case ui::mojom::PointerKind::PEN:
- *out = ui::EventPointerType::POINTER_TYPE_PEN;
- return true;
- case ui::mojom::PointerKind::TOUCH:
- *out = ui::EventPointerType::POINTER_TYPE_TOUCH;
- return true;
- case ui::mojom::PointerKind::ERASER:
- *out = ui::EventPointerType::POINTER_TYPE_ERASER;
- return true;
- }
- NOTREACHED();
- return false;
- }
-};
-
-template <>
struct StructTraits<ui::mojom::PointerDetailsDataView, ui::PointerDetails> {
static ui::EventPointerType pointer_type(const ui::PointerDetails& i) {
return i.pointer_type;
diff --git a/chromium/ui/events/mojom/mojom_traits_unittest.cc b/chromium/ui/events/mojom/mojom_traits_unittest.cc
index e1bb65f32bc..f378e0de322 100644
--- a/chromium/ui/events/mojom/mojom_traits_unittest.cc
+++ b/chromium/ui/events/mojom/mojom_traits_unittest.cc
@@ -9,6 +9,7 @@
#include "mojo/public/cpp/test_support/test_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/event.h"
+#include "ui/events/ipc/ui_events_param_traits_macros.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/mojom/event.mojom.h"
#include "ui/events/mojom/event_mojom_traits.h"
@@ -125,30 +126,29 @@ TEST(StructTraitsTest, MouseEvent) {
const MouseEvent kTestData[] = {
{ET_MOUSE_PRESSED, gfx::Point(10, 10), gfx::Point(20, 30),
base::TimeTicks() + base::TimeDelta::FromMicroseconds(201), EF_NONE, 0,
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE, kPointerIdMouse)},
+ PointerDetails(EventPointerType::kMouse, kPointerIdMouse)},
{ET_MOUSE_DRAGGED, gfx::Point(1, 5), gfx::Point(5, 1),
base::TimeTicks() + base::TimeDelta::FromMicroseconds(202),
EF_LEFT_MOUSE_BUTTON, EF_LEFT_MOUSE_BUTTON,
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE, kPointerIdMouse)},
+ PointerDetails(EventPointerType::kMouse, kPointerIdMouse)},
{ET_MOUSE_RELEASED, gfx::Point(411, 130), gfx::Point(20, 30),
base::TimeTicks() + base::TimeDelta::FromMicroseconds(203),
EF_MIDDLE_MOUSE_BUTTON | EF_RIGHT_MOUSE_BUTTON, EF_RIGHT_MOUSE_BUTTON,
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE, kPointerIdMouse)},
+ PointerDetails(EventPointerType::kMouse, kPointerIdMouse)},
{ET_MOUSE_MOVED, gfx::Point(0, 1), gfx::Point(2, 3),
base::TimeTicks() + base::TimeDelta::FromMicroseconds(204), EF_ALT_DOWN,
- 0,
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE, kPointerIdMouse)},
+ 0, PointerDetails(EventPointerType::kMouse, kPointerIdMouse)},
{ET_MOUSE_ENTERED, gfx::Point(6, 7), gfx::Point(8, 9),
base::TimeTicks() + base::TimeDelta::FromMicroseconds(205), EF_NONE, 0,
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE, kPointerIdMouse)},
+ PointerDetails(EventPointerType::kMouse, kPointerIdMouse)},
{ET_MOUSE_EXITED, gfx::Point(10, 10), gfx::Point(20, 30),
base::TimeTicks() + base::TimeDelta::FromMicroseconds(206),
EF_BACK_MOUSE_BUTTON, 0,
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE, kPointerIdMouse)},
+ PointerDetails(EventPointerType::kMouse, kPointerIdMouse)},
{ET_MOUSE_CAPTURE_CHANGED, gfx::Point(99, 99), gfx::Point(99, 99),
base::TimeTicks() + base::TimeDelta::FromMicroseconds(207),
EF_CONTROL_DOWN, 0,
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE, kPointerIdMouse)},
+ PointerDetails(EventPointerType::kMouse, kPointerIdMouse)},
};
for (size_t i = 0; i < base::size(kTestData); i++) {
@@ -332,13 +332,11 @@ TEST(StructTraitsTest, ScrollEvent) {
TEST(StructTraitsTest, PointerDetails) {
const PointerDetails kTestData[] = {
- {EventPointerType::POINTER_TYPE_UNKNOWN, 1, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f},
- {EventPointerType::POINTER_TYPE_MOUSE, 1, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f},
- {EventPointerType::POINTER_TYPE_PEN, 11, 12.f, 13.f, 14.f, 15.f, 16.f,
- 17.f},
- {EventPointerType::POINTER_TYPE_TOUCH, 1, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f},
- {EventPointerType::POINTER_TYPE_ERASER, 21, 22.f, 23.f, 24.f, 25.f, 26.f,
- 27.f},
+ {EventPointerType::kUnknown, 1, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f},
+ {EventPointerType::kMouse, 1, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f},
+ {EventPointerType::kPen, 11, 12.f, 13.f, 14.f, 15.f, 16.f, 17.f},
+ {EventPointerType::kTouch, 1, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f},
+ {EventPointerType::kEraser, 21, 22.f, 23.f, 24.f, 25.f, 26.f, 27.f},
};
for (size_t i = 0; i < base::size(kTestData); i++) {
// Set |offset| as the constructor used above does not modify it.
@@ -358,8 +356,7 @@ TEST(StructTraitsTest, TouchEvent) {
{ET_TOUCH_RELEASED,
{1, 2},
base::TimeTicks::Now(),
- {EventPointerType::POINTER_TYPE_UNKNOWN, 1, 2.f, 3.f, 4.f, 5.f, 6.f,
- 7.f},
+ {EventPointerType::kUnknown, 1, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f},
EF_SHIFT_DOWN},
{ET_TOUCH_PRESSED, {1, 2}, base::TimeTicks::Now(), {}, EF_CONTROL_DOWN},
{ET_TOUCH_MOVED, {1, 2}, base::TimeTicks::Now(), {}, EF_NONE},
diff --git a/chromium/ui/events/mojom/scroll_granularity.typemap b/chromium/ui/events/mojom/scroll_granularity.typemap
deleted file mode 100644
index 0fc41abe11f..00000000000
--- a/chromium/ui/events/mojom/scroll_granularity.typemap
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2019 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.
-
-mojom = "//ui/events/mojom/scroll_granularity.mojom"
-public_headers = [ "//ui/events/types/scroll_types.h" ]
-traits_headers = [ "//ui/events/ipc/ui_events_param_traits_macros.h" ]
-public_deps = [ "//ui/events/ipc" ]
-type_mappings = [ "ui.mojom.ScrollGranularity=::ui::ScrollGranularity" ]
diff --git a/chromium/ui/events/mojom/typemaps.gni b/chromium/ui/events/mojom/typemaps.gni
deleted file mode 100644
index 14cd946e0d4..00000000000
--- a/chromium/ui/events/mojom/typemaps.gni
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-typemaps = [
- "//ui/events/mojom/event.typemap",
- "//ui/events/mojom/scroll_granularity.typemap",
-]
diff --git a/chromium/ui/events/null_event_targeter.cc b/chromium/ui/events/null_event_targeter.cc
index a08270c0da3..fb1126e8a86 100644
--- a/chromium/ui/events/null_event_targeter.cc
+++ b/chromium/ui/events/null_event_targeter.cc
@@ -4,7 +4,7 @@
#include "ui/events/null_event_targeter.h"
-#include "base/logging.h"
+#include "base/notreached.h"
namespace ui {
diff --git a/chromium/ui/events/ozone/evdev/device_event_dispatcher_evdev.cc b/chromium/ui/events/ozone/evdev/device_event_dispatcher_evdev.cc
index 9c425001a61..49f475ed791 100644
--- a/chromium/ui/events/ozone/evdev/device_event_dispatcher_evdev.cc
+++ b/chromium/ui/events/ozone/evdev/device_event_dispatcher_evdev.cc
@@ -9,12 +9,14 @@ namespace ui {
KeyEventParams::KeyEventParams(int device_id,
int flags,
unsigned int code,
+ unsigned int scan_code,
bool down,
bool suppress_auto_repeat,
base::TimeTicks timestamp)
: device_id(device_id),
flags(flags),
code(code),
+ scan_code(scan_code),
down(down),
suppress_auto_repeat(suppress_auto_repeat),
timestamp(timestamp) {}
diff --git a/chromium/ui/events/ozone/evdev/device_event_dispatcher_evdev.h b/chromium/ui/events/ozone/evdev/device_event_dispatcher_evdev.h
index 64441cf437b..a10bb0312b1 100644
--- a/chromium/ui/events/ozone/evdev/device_event_dispatcher_evdev.h
+++ b/chromium/ui/events/ozone/evdev/device_event_dispatcher_evdev.h
@@ -27,6 +27,7 @@ struct COMPONENT_EXPORT(EVDEV) KeyEventParams {
KeyEventParams(int device_id,
int flags,
unsigned int code,
+ unsigned int scan_code,
bool down,
bool suppress_auto_repeat,
base::TimeTicks timestamp);
@@ -37,6 +38,7 @@ struct COMPONENT_EXPORT(EVDEV) KeyEventParams {
int device_id;
int flags;
unsigned int code;
+ unsigned int scan_code;
bool down;
bool suppress_auto_repeat;
base::TimeTicks timestamp;
diff --git a/chromium/ui/events/ozone/evdev/event_converter_evdev_impl.cc b/chromium/ui/events/ozone/evdev/event_converter_evdev_impl.cc
index be580873cb4..941a0464af0 100644
--- a/chromium/ui/events/ozone/evdev/event_converter_evdev_impl.cc
+++ b/chromium/ui/events/ozone/evdev/event_converter_evdev_impl.cc
@@ -122,8 +122,13 @@ void EventConverterEvdevImpl::ProcessEvents(const input_event* inputs,
for (int i = 0; i < count; ++i) {
const input_event& input = inputs[i];
switch (input.type) {
+ case EV_MSC:
+ if (input.code == MSC_SCAN)
+ last_scan_code_ = input.value;
+ break;
case EV_KEY:
ConvertKeyEvent(input);
+ last_scan_code_ = 0;
break;
case EV_REL:
ConvertMouseMoveEvent(input);
@@ -133,6 +138,7 @@ void EventConverterEvdevImpl::ProcessEvents(const input_event* inputs,
OnLostSync();
else if (input.code == SYN_REPORT)
FlushEvents(input);
+ last_scan_code_ = 0;
break;
case EV_SW:
if (input.code == kSwitchStylusInserted) {
@@ -191,7 +197,7 @@ void EventConverterEvdevImpl::OnKeyChange(unsigned int key,
key_state_.set(key, down);
dispatcher_->DispatchKeyEvent(
- KeyEventParams(input_device_.id, ui::EF_NONE, key, down,
+ KeyEventParams(input_device_.id, ui::EF_NONE, key, last_scan_code_, down,
false /* suppress_auto_repeat */, timestamp));
}
@@ -239,8 +245,8 @@ void EventConverterEvdevImpl::OnButtonChange(int code,
dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams(
input_device_.id, EF_NONE, cursor_->GetLocation(), code, down,
- /* allow_remap */ true,
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE), timestamp));
+ /* allow_remap */ true, PointerDetails(EventPointerType::kMouse),
+ timestamp));
}
void EventConverterEvdevImpl::FlushEvents(const input_event& input) {
@@ -251,7 +257,7 @@ void EventConverterEvdevImpl::FlushEvents(const input_event& input) {
dispatcher_->DispatchMouseMoveEvent(
MouseMoveEventParams(input_device_.id, EF_NONE, cursor_->GetLocation(),
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE),
+ PointerDetails(EventPointerType::kMouse),
TimeTicksFromInputEvent(input)));
x_offset_ = 0;
diff --git a/chromium/ui/events/ozone/evdev/event_converter_evdev_impl.h b/chromium/ui/events/ozone/evdev/event_converter_evdev_impl.h
index 9f1be6c3491..63c5218a22f 100644
--- a/chromium/ui/events/ozone/evdev/event_converter_evdev_impl.h
+++ b/chromium/ui/events/ozone/evdev/event_converter_evdev_impl.h
@@ -81,6 +81,11 @@ class COMPONENT_EXPORT(EVDEV) EventConverterEvdevImpl
// Save y-axis events of relative devices to be flushed at EV_SYN time.
int y_offset_ = 0;
+ // Saves the last scan code seen in order to attach it to the next key event.
+ // The scan code is sent as a separate event message EV_MSC with subtype
+ // MSC_SCAN prior to the EV_KEY message that contains the key code.
+ unsigned int last_scan_code_ = 0;
+
// Controller for watching the input fd.
base::MessagePumpLibevent::FdWatchController controller_;
diff --git a/chromium/ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc b/chromium/ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc
index f15052dd146..1e268e8acfe 100644
--- a/chromium/ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc
+++ b/chromium/ui/events/ozone/evdev/event_converter_evdev_impl_unittest.cc
@@ -166,11 +166,13 @@ TEST_F(EventConverterEvdevImplTest, KeyPress) {
event = dispatched_event(0);
EXPECT_EQ(ui::ET_KEY_PRESSED, event->type());
EXPECT_EQ(ui::VKEY_BACK, event->key_code());
+ EXPECT_EQ(0x7002au, event->scan_code());
EXPECT_EQ(0, event->flags());
event = dispatched_event(1);
EXPECT_EQ(ui::ET_KEY_RELEASED, event->type());
EXPECT_EQ(ui::VKEY_BACK, event->key_code());
+ EXPECT_EQ(0x7002au, event->scan_code());
EXPECT_EQ(0, event->flags());
}
@@ -203,11 +205,13 @@ TEST_F(EventConverterEvdevImplTest, KeyRepeat) {
event = dispatched_event(0);
EXPECT_EQ(ui::ET_KEY_PRESSED, event->type());
EXPECT_EQ(ui::VKEY_BACK, event->key_code());
+ EXPECT_EQ(0x7002au, event->scan_code());
EXPECT_EQ(0, event->flags());
event = dispatched_event(1);
EXPECT_EQ(ui::ET_KEY_RELEASED, event->type());
EXPECT_EQ(ui::VKEY_BACK, event->key_code());
+ EXPECT_EQ(0x7002au, event->scan_code());
EXPECT_EQ(0, event->flags());
}
@@ -246,21 +250,25 @@ TEST_F(EventConverterEvdevImplTest, KeyWithModifier) {
event = dispatched_event(0);
EXPECT_EQ(ui::ET_KEY_PRESSED, event->type());
EXPECT_EQ(ui::VKEY_SHIFT, event->key_code());
+ EXPECT_EQ(0x700e1u, event->scan_code());
EXPECT_EQ(ui::EF_SHIFT_DOWN, event->flags());
event = dispatched_event(1);
EXPECT_EQ(ui::ET_KEY_PRESSED, event->type());
EXPECT_EQ(ui::VKEY_A, event->key_code());
+ EXPECT_EQ(0x70004u, event->scan_code());
EXPECT_EQ(ui::EF_SHIFT_DOWN, event->flags());
event = dispatched_event(2);
EXPECT_EQ(ui::ET_KEY_RELEASED, event->type());
EXPECT_EQ(ui::VKEY_A, event->key_code());
+ EXPECT_EQ(0x70004u, event->scan_code());
EXPECT_EQ(ui::EF_SHIFT_DOWN, event->flags());
event = dispatched_event(3);
EXPECT_EQ(ui::ET_KEY_RELEASED, event->type());
EXPECT_EQ(ui::VKEY_SHIFT, event->key_code());
+ EXPECT_EQ(0x700e1u, event->scan_code());
EXPECT_EQ(0, event->flags());
}
@@ -301,31 +309,37 @@ TEST_F(EventConverterEvdevImplTest, KeyWithDuplicateModifier) {
event = dispatched_event(0);
EXPECT_EQ(ui::ET_KEY_PRESSED, event->type());
EXPECT_EQ(ui::VKEY_CONTROL, event->key_code());
+ EXPECT_EQ(0x700e1u, event->scan_code());
EXPECT_EQ(ui::EF_CONTROL_DOWN, event->flags());
event = dispatched_event(1);
EXPECT_EQ(ui::ET_KEY_PRESSED, event->type());
EXPECT_EQ(ui::VKEY_CONTROL, event->key_code());
+ EXPECT_EQ(0x700e5u, event->scan_code());
EXPECT_EQ(ui::EF_CONTROL_DOWN, event->flags());
event = dispatched_event(2);
EXPECT_EQ(ui::ET_KEY_PRESSED, event->type());
EXPECT_EQ(ui::VKEY_Z, event->key_code());
+ EXPECT_EQ(0x7001du, event->scan_code());
EXPECT_EQ(ui::EF_CONTROL_DOWN, event->flags());
event = dispatched_event(3);
EXPECT_EQ(ui::ET_KEY_RELEASED, event->type());
EXPECT_EQ(ui::VKEY_Z, event->key_code());
+ EXPECT_EQ(0x7001du, event->scan_code());
EXPECT_EQ(ui::EF_CONTROL_DOWN, event->flags());
event = dispatched_event(4);
EXPECT_EQ(ui::ET_KEY_RELEASED, event->type());
EXPECT_EQ(ui::VKEY_CONTROL, event->key_code());
+ EXPECT_EQ(0x700e1u, event->scan_code());
EXPECT_EQ(ui::EF_CONTROL_DOWN, event->flags());
event = dispatched_event(5);
EXPECT_EQ(ui::ET_KEY_RELEASED, event->type());
EXPECT_EQ(ui::VKEY_CONTROL, event->key_code());
+ EXPECT_EQ(0x700e5u, event->scan_code());
EXPECT_EQ(0, event->flags());
}
@@ -350,11 +364,13 @@ TEST_F(EventConverterEvdevImplTest, KeyWithLock) {
event = dispatched_event(0);
EXPECT_EQ(ui::ET_KEY_PRESSED, event->type());
EXPECT_EQ(ui::VKEY_CAPITAL, event->key_code());
+ EXPECT_EQ(0x70039u, event->scan_code());
EXPECT_EQ(ui::EF_MOD3_DOWN, event->flags());
event = dispatched_event(1);
EXPECT_EQ(ui::ET_KEY_RELEASED, event->type());
EXPECT_EQ(ui::VKEY_CAPITAL, event->key_code());
+ EXPECT_EQ(0x70039u, event->scan_code());
EXPECT_EQ(ui::EF_NONE, event->flags());
}
diff --git a/chromium/ui/events/ozone/evdev/event_factory_evdev.cc b/chromium/ui/events/ozone/evdev/event_factory_evdev.cc
index 73fe30694bb..30679f99ca4 100644
--- a/chromium/ui/events/ozone/evdev/event_factory_evdev.cc
+++ b/chromium/ui/events/ozone/evdev/event_factory_evdev.cc
@@ -222,8 +222,9 @@ EventFactoryEvdev::CreateSystemInputInjector() {
void EventFactoryEvdev::DispatchKeyEvent(const KeyEventParams& params) {
TRACE_EVENT1("evdev", "EventFactoryEvdev::DispatchKeyEvent", "device",
params.device_id);
- keyboard_.OnKeyChange(params.code, params.down, params.suppress_auto_repeat,
- params.timestamp, params.device_id, params.flags);
+ keyboard_.OnKeyChange(params.code, params.scan_code, params.down,
+ params.suppress_auto_repeat, params.timestamp,
+ params.device_id, params.flags);
}
void EventFactoryEvdev::DispatchMouseMoveEvent(
@@ -465,12 +466,12 @@ void EventFactoryEvdev::WarpCursorTo(gfx::AcceleratedWidget widget,
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
- base::BindOnce(&EventFactoryEvdev::DispatchMouseMoveEvent,
- weak_ptr_factory_.GetWeakPtr(),
- MouseMoveEventParams(
- -1 /* device_id */, EF_NONE, cursor_->GetLocation(),
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE),
- EventTimeForNow())));
+ base::BindOnce(
+ &EventFactoryEvdev::DispatchMouseMoveEvent,
+ weak_ptr_factory_.GetWeakPtr(),
+ MouseMoveEventParams(
+ -1 /* device_id */, EF_NONE, cursor_->GetLocation(),
+ PointerDetails(EventPointerType::kMouse), EventTimeForNow())));
}
int EventFactoryEvdev::NextDeviceId() {
diff --git a/chromium/ui/events/ozone/evdev/input_device_factory_evdev.cc b/chromium/ui/events/ozone/evdev/input_device_factory_evdev.cc
index ce41f93ae54..bf9ac94b72b 100644
--- a/chromium/ui/events/ozone/evdev/input_device_factory_evdev.cc
+++ b/chromium/ui/events/ozone/evdev/input_device_factory_evdev.cc
@@ -11,6 +11,7 @@
#include <utility>
#include "base/bind.h"
+#include "base/feature_list.h"
#include "base/files/scoped_file.h"
#include "base/memory/ptr_util.h"
#include "base/threading/thread_task_runner_handle.h"
@@ -25,6 +26,7 @@
#include "ui/events/ozone/evdev/stylus_button_event_converter_evdev.h"
#include "ui/events/ozone/evdev/tablet_event_converter_evdev.h"
#include "ui/events/ozone/evdev/touch_event_converter_evdev.h"
+#include "ui/events/ozone/features.h"
#include "ui/events/ozone/gamepad/gamepad_provider_ozone.h"
#if defined(USE_EVDEV_GESTURES)
@@ -234,7 +236,8 @@ void InputDeviceFactoryEvdev::AttachInputDevice(
DetachInputDevice(path);
if (converter->type() == InputDeviceType::INPUT_DEVICE_INTERNAL &&
- converter->HasPen()) {
+ converter->HasPen() &&
+ base::FeatureList::IsEnabled(kEnablePalmSuppression)) {
converter->SetPalmSuppressionCallback(
base::BindRepeating(&InputDeviceFactoryEvdev::EnablePalmSuppression,
base::Unretained(this)));
@@ -353,6 +356,9 @@ void InputDeviceFactoryEvdev::ApplyInputDeviceSettings() {
SetBoolPropertyForOneType(
DT_MOUSE, "Mouse Reverse Scrolling",
input_device_settings_.mouse_reverse_scroll_enabled);
+ SetBoolPropertyForOneType(
+ DT_MOUSE, "Mouse High Resolution Scrolling",
+ base::FeatureList::IsEnabled(ui::kEnableHighResolutionMouseScrolling));
SetBoolPropertyForOneType(DT_TOUCHPAD, "Tap Paused",
input_device_settings_.tap_to_click_paused);
diff --git a/chromium/ui/events/ozone/evdev/input_injector_evdev.cc b/chromium/ui/events/ozone/evdev/input_injector_evdev.cc
index f9d747f57aa..fb08e6bb298 100644
--- a/chromium/ui/events/ozone/evdev/input_injector_evdev.cc
+++ b/chromium/ui/events/ozone/evdev/input_injector_evdev.cc
@@ -50,8 +50,8 @@ void InputInjectorEvdev::InjectMouseButton(EventFlags button, bool down) {
dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams(
kDeviceIdForInjection, EF_NONE, cursor_->GetLocation(), code, down,
- false /* allow_remap */,
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE), EventTimeForNow()));
+ false /* allow_remap */, PointerDetails(EventPointerType::kMouse),
+ EventTimeForNow()));
}
void InputInjectorEvdev::InjectMouseWheel(int delta_x, int delta_y) {
@@ -68,7 +68,7 @@ void InputInjectorEvdev::MoveCursorTo(const gfx::PointF& location) {
dispatcher_->DispatchMouseMoveEvent(MouseMoveEventParams(
kDeviceIdForInjection, EF_NONE, cursor_->GetLocation(),
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE), EventTimeForNow()));
+ PointerDetails(EventPointerType::kMouse), EventTimeForNow()));
}
void InputInjectorEvdev::InjectKeyEvent(DomCode physical_key,
@@ -80,9 +80,9 @@ void InputInjectorEvdev::InjectKeyEvent(DomCode physical_key,
int native_keycode = KeycodeConverter::DomCodeToNativeKeycode(physical_key);
int evdev_code = NativeCodeToEvdevCode(native_keycode);
- dispatcher_->DispatchKeyEvent(
- KeyEventParams(kDeviceIdForInjection, ui::EF_NONE, evdev_code, down,
- suppress_auto_repeat, EventTimeForNow()));
+ dispatcher_->DispatchKeyEvent(KeyEventParams(
+ kDeviceIdForInjection, ui::EF_NONE, evdev_code, 0 /*scan_code*/, down,
+ suppress_auto_repeat, EventTimeForNow()));
}
} // namespace ui
diff --git a/chromium/ui/events/ozone/evdev/keyboard_evdev.cc b/chromium/ui/events/ozone/evdev/keyboard_evdev.cc
index b17c36b061a..e89821d64e7 100644
--- a/chromium/ui/events/ozone/evdev/keyboard_evdev.cc
+++ b/chromium/ui/events/ozone/evdev/keyboard_evdev.cc
@@ -32,6 +32,7 @@ KeyboardEvdev::~KeyboardEvdev() {
}
void KeyboardEvdev::OnKeyChange(unsigned int key,
+ unsigned int scan_code,
bool down,
bool suppress_auto_repeat,
base::TimeTicks timestamp,
@@ -46,9 +47,9 @@ void KeyboardEvdev::OnKeyChange(unsigned int key,
return; // Key already released.
key_state_.set(key, down);
- auto_repeat_handler_.UpdateKeyRepeat(key, down, suppress_auto_repeat,
- device_id);
- DispatchKey(key, down, is_repeat, timestamp, device_id, flags);
+ auto_repeat_handler_.UpdateKeyRepeat(key, scan_code, down,
+ suppress_auto_repeat, device_id);
+ DispatchKey(key, scan_code, down, is_repeat, timestamp, device_id, flags);
}
void KeyboardEvdev::SetCapsLockEnabled(bool enabled) {
@@ -134,6 +135,7 @@ void KeyboardEvdev::RefreshModifiers() {
}
void KeyboardEvdev::DispatchKey(unsigned int key,
+ unsigned int scan_code,
bool down,
bool repeat,
base::TimeTicks timestamp,
@@ -156,6 +158,7 @@ void KeyboardEvdev::DispatchKey(unsigned int key,
KeyEvent event(down ? ET_KEY_PRESSED : ET_KEY_RELEASED, key_code, dom_code,
flags | modifiers_->GetModifierFlags(), dom_key, timestamp);
+ event.set_scan_code(scan_code);
event.set_source_device_id(device_id);
callback_.Run(&event);
}
diff --git a/chromium/ui/events/ozone/evdev/keyboard_evdev.h b/chromium/ui/events/ozone/evdev/keyboard_evdev.h
index 8c2ea9c18f5..89f6f55e333 100644
--- a/chromium/ui/events/ozone/evdev/keyboard_evdev.h
+++ b/chromium/ui/events/ozone/evdev/keyboard_evdev.h
@@ -39,11 +39,14 @@ class COMPONENT_EXPORT(EVDEV) KeyboardEvdev
// Handlers for raw key presses & releases.
//
- // |code| is a Linux key code (from <linux/input.h>). |down| represents the
+ // |code| is a Linux key code (from <linux/input.h>). |scan_code| is a
+ // device dependent code that identifies the physical location of the key
+ // independent of it's mapping to a linux key code. |down| represents the
// key state. |suppress_auto_repeat| prevents the event from triggering
// auto-repeat, if enabled. |device_id| uniquely identifies the source
// keyboard device.
void OnKeyChange(unsigned int code,
+ unsigned int scan_code,
bool down,
bool suppress_auto_repeat,
base::TimeTicks timestamp,
@@ -72,6 +75,7 @@ class COMPONENT_EXPORT(EVDEV) KeyboardEvdev
// EventAutoRepeatHandler::Delegate
void FlushInput(base::OnceClosure closure) override;
void DispatchKey(unsigned int key,
+ unsigned int scan_code,
bool down,
bool repeat,
base::TimeTicks timestamp,
diff --git a/chromium/ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc b/chromium/ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc
index 33faf34a27b..2e890c0bdfe 100644
--- a/chromium/ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc
+++ b/chromium/ui/events/ozone/evdev/libgestures_glue/gesture_interpreter_libevdev_cros.cc
@@ -295,7 +295,7 @@ void GestureInterpreterLibevdevCros::OnGestureMove(const Gesture* gesture,
// TODO(spang): Use move->ordinal_dx, move->ordinal_dy
dispatcher_->DispatchMouseMoveEvent(
MouseMoveEventParams(id_, EF_NONE, cursor_->GetLocation(),
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE),
+ PointerDetails(EventPointerType::kMouse),
StimeToTimeTicks(gesture->end_time)));
}
@@ -500,8 +500,7 @@ void GestureInterpreterLibevdevCros::DispatchMouseButton(unsigned int button,
bool allow_remap = is_mouse_;
dispatcher_->DispatchMouseButtonEvent(MouseButtonEventParams(
id_, EF_NONE, cursor_->GetLocation(), button, down, allow_remap,
- PointerDetails(EventPointerType::POINTER_TYPE_MOUSE),
- StimeToTimeTicks(time)));
+ PointerDetails(EventPointerType::kMouse), StimeToTimeTicks(time)));
}
void GestureInterpreterLibevdevCros::DispatchChangedKeys(
@@ -528,8 +527,8 @@ void GestureInterpreterLibevdevCros::DispatchChangedKeys(
// Dispatch key press or release to keyboard.
dispatcher_->DispatchKeyEvent(KeyEventParams(
- id_, ui::EF_NONE, key, value, false /* suppress_auto_repeat */,
- StimeToTimeTicks(timestamp)));
+ id_, ui::EF_NONE, key, 0 /* scan_code */, value,
+ false /* suppress_auto_repeat */, StimeToTimeTicks(timestamp)));
}
}
diff --git a/chromium/ui/events/ozone/evdev/mouse_button_map_evdev.cc b/chromium/ui/events/ozone/evdev/mouse_button_map_evdev.cc
index 622c71d01c2..aaa663327cf 100644
--- a/chromium/ui/events/ozone/evdev/mouse_button_map_evdev.cc
+++ b/chromium/ui/events/ozone/evdev/mouse_button_map_evdev.cc
@@ -6,7 +6,6 @@
#include <linux/input.h>
-#include "base/logging.h"
namespace ui {
diff --git a/chromium/ui/events/ozone/evdev/stylus_button_event_converter_evdev.cc b/chromium/ui/events/ozone/evdev/stylus_button_event_converter_evdev.cc
index cd4636a7289..39d263f25ab 100644
--- a/chromium/ui/events/ozone/evdev/stylus_button_event_converter_evdev.cc
+++ b/chromium/ui/events/ozone/evdev/stylus_button_event_converter_evdev.cc
@@ -63,9 +63,10 @@ void StylusButtonEventConverterEvdev::OnFileCanReadWithoutBlocking(int fd) {
void StylusButtonEventConverterEvdev::ProcessEvent(const input_event& input) {
if (input.type == EV_KEY && input.code == KEY_F19) {
bool down = input.value != kKeyReleaseValue;
- dispatcher_->DispatchKeyEvent(KeyEventParams(
- input_device_.id, ui::EF_IS_STYLUS_BUTTON, input.code, down,
- true /* suppress_auto_repeat */, TimeTicksFromInputEvent(input)));
+ dispatcher_->DispatchKeyEvent(
+ KeyEventParams(input_device_.id, ui::EF_IS_STYLUS_BUTTON, input.code,
+ 0 /* scan_code */, down, true /* suppress_auto_repeat */,
+ TimeTicksFromInputEvent(input)));
}
}
diff --git a/chromium/ui/events/ozone/evdev/tablet_event_converter_evdev.cc b/chromium/ui/events/ozone/evdev/tablet_event_converter_evdev.cc
index 73028b5b9d7..bf00990d0d8 100644
--- a/chromium/ui/events/ozone/evdev/tablet_event_converter_evdev.cc
+++ b/chromium/ui/events/ozone/evdev/tablet_event_converter_evdev.cc
@@ -23,8 +23,8 @@ float ScaleTilt(int value, int min_value, int num_values) {
EventPointerType GetToolType(int button_tool) {
if (button_tool == BTN_TOOL_RUBBER)
- return EventPointerType::POINTER_TYPE_ERASER;
- return EventPointerType::POINTER_TYPE_PEN;
+ return EventPointerType::kEraser;
+ return EventPointerType::kPen;
}
} // namespace
diff --git a/chromium/ui/events/ozone/evdev/tablet_event_converter_evdev_unittest.cc b/chromium/ui/events/ozone/evdev/tablet_event_converter_evdev_unittest.cc
index 49062b2f909..b548a203199 100644
--- a/chromium/ui/events/ozone/evdev/tablet_event_converter_evdev_unittest.cc
+++ b/chromium/ui/events/ozone/evdev/tablet_event_converter_evdev_unittest.cc
@@ -458,19 +458,16 @@ TEST_F(TabletEventConverterEvdevTest, Tap) {
ui::MouseEvent* event = dispatched_event(0);
EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
- EXPECT_EQ(ui::EventPointerType::POINTER_TYPE_PEN,
- event->pointer_details().pointer_type);
+ EXPECT_EQ(ui::EventPointerType::kPen, event->pointer_details().pointer_type);
EXPECT_FLOAT_EQ(5.625f, event->pointer_details().tilt_x);
EXPECT_FLOAT_EQ(0.f, event->pointer_details().tilt_y);
event = dispatched_event(1);
EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->type());
- EXPECT_EQ(ui::EventPointerType::POINTER_TYPE_PEN,
- event->pointer_details().pointer_type);
+ EXPECT_EQ(ui::EventPointerType::kPen, event->pointer_details().pointer_type);
EXPECT_FLOAT_EQ((float)992 / 2047, event->pointer_details().force);
EXPECT_EQ(true, event->IsLeftMouseButton());
event = dispatched_event(2);
- EXPECT_EQ(ui::EventPointerType::POINTER_TYPE_PEN,
- event->pointer_details().pointer_type);
+ EXPECT_EQ(ui::EventPointerType::kPen, event->pointer_details().pointer_type);
EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->type());
EXPECT_FLOAT_EQ(0.0f, event->pointer_details().force);
EXPECT_EQ(true, event->IsLeftMouseButton());
diff --git a/chromium/ui/events/ozone/evdev/touch_evdev_debug_buffer.cc b/chromium/ui/events/ozone/evdev/touch_evdev_debug_buffer.cc
index 01e49b7bbfd..b8d089f7381 100644
--- a/chromium/ui/events/ozone/evdev/touch_evdev_debug_buffer.cc
+++ b/chromium/ui/events/ozone/evdev/touch_evdev_debug_buffer.cc
@@ -8,7 +8,6 @@
#include "base/files/file.h"
#include "base/files/file_util.h"
-#include "base/logging.h"
#include "base/strings/stringprintf.h"
#include "ui/events/ozone/evdev/event_device_info.h"
diff --git a/chromium/ui/events/ozone/evdev/touch_evdev_types.h b/chromium/ui/events/ozone/evdev/touch_evdev_types.h
index d8e93827138..97224442dfb 100644
--- a/chromium/ui/events/ozone/evdev/touch_evdev_types.h
+++ b/chromium/ui/events/ozone/evdev/touch_evdev_types.h
@@ -65,8 +65,7 @@ struct COMPONENT_EXPORT(EVDEV) InProgressTouchEvdev {
int tool_code = 0;
float tilt_x = 0;
float tilt_y = 0;
- ui::EventPointerType reported_tool_type =
- ui::EventPointerType::POINTER_TYPE_TOUCH;
+ ui::EventPointerType reported_tool_type = ui::EventPointerType::kTouch;
bool stylus_button = false;
};
diff --git a/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.cc b/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.cc
index e52172bda54..afab037632d 100644
--- a/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.cc
+++ b/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.cc
@@ -35,6 +35,7 @@
#include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h"
#include "ui/events/ozone/evdev/touch_evdev_types.h"
#include "ui/events/ozone/evdev/touch_filter/false_touch_finder.h"
+#include "ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.h"
#include "ui/events/ozone/evdev/touch_filter/palm_detection_filter.h"
#include "ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory.h"
#include "ui/events/ozone/features.h"
@@ -68,11 +69,11 @@ int32_t AbsCodeToMtCode(int32_t code) {
ui::EventPointerType GetEventPointerType(int tool_code) {
switch (tool_code) {
case BTN_TOOL_PEN:
- return ui::EventPointerType::POINTER_TYPE_PEN;
+ return ui::EventPointerType::kPen;
case BTN_TOOL_RUBBER:
- return ui::EventPointerType::POINTER_TYPE_ERASER;
+ return ui::EventPointerType::kEraser;
default:
- return ui::EventPointerType::POINTER_TYPE_TOUCH;
+ return ui::EventPointerType::kTouch;
}
}
@@ -123,6 +124,14 @@ TouchEventConverterEvdev::TouchEventConverterEvdev(
base::FeatureList::IsEnabled(kEnablePalmOnMaxTouchMajor)),
palm_on_tool_type_palm_(
base::FeatureList::IsEnabled(kEnablePalmOnToolTypePalm)) {
+ if (base::FeatureList::IsEnabled(kEnableNeuralPalmDetectionFilter) &&
+ NeuralStylusPalmDetectionFilter::
+ CompatibleWithNeuralStylusPalmDetectionFilter(devinfo)) {
+ // When a neural net palm detector is enabled, we do not look at tool_type
+ // nor the max size of the touch as indicators of palm, merely the NN
+ // system.
+ palm_on_tool_type_palm_ = palm_on_touch_major_max_ = false;
+ }
touch_evdev_debug_buffer_.Initialize(devinfo);
}
diff --git a/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.h b/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.h
index e23c36566b3..82da9b0f875 100644
--- a/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.h
+++ b/chromium/ui/events/ozone/evdev/touch_event_converter_evdev.h
@@ -190,10 +190,10 @@ class COMPONENT_EXPORT(EVDEV) TouchEventConverterEvdev
base::RepeatingCallback<void(bool)> enable_palm_suppression_callback_;
// Do we mark a touch as palm when touch_major is the max?
- const bool palm_on_touch_major_max_;
+ bool palm_on_touch_major_max_;
// Do we mark a touch as palm when the tool type is marked as TOOL_TYPE_PALM ?
- const bool palm_on_tool_type_palm_;
+ bool palm_on_tool_type_palm_;
DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdev);
};
diff --git a/chromium/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc b/chromium/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc
index 2a928fd1b03..5d59d97117c 100644
--- a/chromium/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc
+++ b/chromium/ui/events/ozone/evdev/touch_event_converter_evdev_unittest.cc
@@ -391,8 +391,7 @@ TEST_F(TouchEventConverterEvdevTest, TouchMove) {
EXPECT_EQ(295, event.location.x());
EXPECT_EQ(421, event.location.y());
EXPECT_EQ(0, event.slot);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH,
- event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kTouch, event.pointer_details.pointer_type);
EXPECT_FLOAT_EQ(58.f, event.pointer_details.radius_x);
EXPECT_FLOAT_EQ(0.13333334f, event.pointer_details.force);
@@ -407,8 +406,7 @@ TEST_F(TouchEventConverterEvdevTest, TouchMove) {
EXPECT_EQ(312, event.location.x());
EXPECT_EQ(432, event.location.y());
EXPECT_EQ(0, event.slot);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH,
- event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kTouch, event.pointer_details.pointer_type);
EXPECT_FLOAT_EQ(50.f, event.pointer_details.radius_x);
EXPECT_FLOAT_EQ(0.16862745f, event.pointer_details.force);
@@ -423,8 +421,7 @@ TEST_F(TouchEventConverterEvdevTest, TouchMove) {
EXPECT_EQ(312, event.location.x());
EXPECT_EQ(432, event.location.y());
EXPECT_EQ(0, event.slot);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH,
- event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kTouch, event.pointer_details.pointer_type);
EXPECT_FLOAT_EQ(50.f, event.pointer_details.radius_x);
EXPECT_FLOAT_EQ(0.16862745f, event.pointer_details.force);
}
@@ -1725,16 +1722,14 @@ TEST_F(TouchEventConverterEvdevTest, ActiveStylusTouchAndRelease) {
EXPECT_EQ(ET_TOUCH_PRESSED, down_event.type);
EXPECT_EQ(9170, down_event.location.x());
EXPECT_EQ(3658, down_event.location.y());
- EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
- down_event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kPen, down_event.pointer_details.pointer_type);
EXPECT_EQ(60.f / 1024, down_event.pointer_details.force);
auto up_event = dispatched_touch_event(1);
EXPECT_EQ(ET_TOUCH_RELEASED, up_event.type);
EXPECT_EQ(9173, up_event.location.x());
EXPECT_EQ(3906, up_event.location.y());
- EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
- up_event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kPen, up_event.pointer_details.pointer_type);
EXPECT_EQ(0.f, up_event.pointer_details.force);
}
@@ -1775,32 +1770,28 @@ TEST_F(TouchEventConverterEvdevTest, ActiveStylusMotion) {
EXPECT_EQ(ET_TOUCH_PRESSED, event.type);
EXPECT_EQ(8921, event.location.x());
EXPECT_EQ(1072, event.location.y());
- EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
- event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kPen, event.pointer_details.pointer_type);
EXPECT_EQ(35.f / 1024, event.pointer_details.force);
event = dispatched_touch_event(1);
EXPECT_EQ(ET_TOUCH_MOVED, event.type);
EXPECT_EQ(8934, event.location.x());
EXPECT_EQ(981, event.location.y());
- EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
- event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kPen, event.pointer_details.pointer_type);
EXPECT_EQ(184.f / 1024, event.pointer_details.force);
event = dispatched_touch_event(2);
EXPECT_EQ(ET_TOUCH_MOVED, event.type);
EXPECT_EQ(8930, event.location.x());
EXPECT_EQ(980, event.location.y());
- EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
- event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kPen, event.pointer_details.pointer_type);
EXPECT_EQ(348.f / 1024, event.pointer_details.force);
event = dispatched_touch_event(3);
EXPECT_EQ(ET_TOUCH_RELEASED, event.type);
EXPECT_EQ(8930, event.location.x());
EXPECT_EQ(980, event.location.y());
- EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
- event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kPen, event.pointer_details.pointer_type);
EXPECT_EQ(0.f / 1024, event.pointer_details.force);
}
@@ -1834,23 +1825,19 @@ TEST_F(TouchEventConverterEvdevTest, ActiveStylusDrallionRubberSequence) {
ui::TouchEventParams event = dispatched_touch_event(0);
EXPECT_EQ(ET_TOUCH_PRESSED, event.type);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_ERASER,
- event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kEraser, event.pointer_details.pointer_type);
event = dispatched_touch_event(1);
EXPECT_EQ(ET_TOUCH_MOVED, event.type);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_ERASER,
- event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kEraser, event.pointer_details.pointer_type);
event = dispatched_touch_event(2);
EXPECT_EQ(ET_TOUCH_MOVED, event.type);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_ERASER,
- event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kEraser, event.pointer_details.pointer_type);
event = dispatched_touch_event(3);
EXPECT_EQ(ET_TOUCH_RELEASED, event.type);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_ERASER,
- event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kEraser, event.pointer_details.pointer_type);
}
TEST_F(TouchEventConverterEvdevTest, ActiveStylusBarrelButtonWhileHovering) {
@@ -1892,14 +1879,12 @@ TEST_F(TouchEventConverterEvdevTest, ActiveStylusBarrelButtonWhileHovering) {
auto down_event = dispatched_touch_event(0);
EXPECT_EQ(ET_TOUCH_PRESSED, down_event.type);
EXPECT_TRUE(down_event.flags & ui::EventFlags::EF_LEFT_MOUSE_BUTTON);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
- down_event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kPen, down_event.pointer_details.pointer_type);
auto up_event = dispatched_touch_event(1);
EXPECT_EQ(ET_TOUCH_RELEASED, up_event.type);
EXPECT_TRUE(down_event.flags & ui::EventFlags::EF_LEFT_MOUSE_BUTTON);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
- up_event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kPen, up_event.pointer_details.pointer_type);
}
TEST_F(TouchEventConverterEvdevTest, ActiveStylusBarrelButton) {
@@ -1941,26 +1926,24 @@ TEST_F(TouchEventConverterEvdevTest, ActiveStylusBarrelButton) {
auto down_event = dispatched_touch_event(0);
EXPECT_EQ(ET_TOUCH_PRESSED, down_event.type);
EXPECT_FALSE(down_event.flags & ui::EventFlags::EF_LEFT_MOUSE_BUTTON);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
- down_event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kPen, down_event.pointer_details.pointer_type);
auto button_down_event = dispatched_touch_event(1);
EXPECT_EQ(ET_TOUCH_MOVED, button_down_event.type);
EXPECT_TRUE(button_down_event.flags & ui::EventFlags::EF_LEFT_MOUSE_BUTTON);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
+ EXPECT_EQ(EventPointerType::kPen,
button_down_event.pointer_details.pointer_type);
auto button_up_event = dispatched_touch_event(2);
EXPECT_EQ(ET_TOUCH_MOVED, button_up_event.type);
EXPECT_FALSE(button_up_event.flags & ui::EventFlags::EF_LEFT_MOUSE_BUTTON);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
+ EXPECT_EQ(EventPointerType::kPen,
button_up_event.pointer_details.pointer_type);
auto up_event = dispatched_touch_event(3);
EXPECT_EQ(ET_TOUCH_RELEASED, up_event.type);
EXPECT_FALSE(down_event.flags & ui::EventFlags::EF_LEFT_MOUSE_BUTTON);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_PEN,
- up_event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kPen, up_event.pointer_details.pointer_type);
}
TEST_F(TouchEventConverterEvdevTest, HeldEventNotSent) {
@@ -2300,8 +2283,7 @@ TEST_F(TouchEventConverterEvdevTest, FingerSizeWithResolution) {
EXPECT_EQ(0, event.slot);
EXPECT_FLOAT_EQ(217.0 / devinfo.GetAbsMaximum(ABS_MT_PRESSURE),
event.pointer_details.force);
- EXPECT_EQ(EventPointerType::POINTER_TYPE_TOUCH,
- event.pointer_details.pointer_type);
+ EXPECT_EQ(EventPointerType::kTouch, event.pointer_details.pointer_type);
EXPECT_FLOAT_EQ(280.f, event.pointer_details.radius_x);
EXPECT_FLOAT_EQ(220.f, event.pointer_details.radius_y);
const ui::InProgressTouchEvdev& in_progress_event = dev->event(0);
diff --git a/chromium/ui/events/ozone/evdev/touch_filter/edge_touch_filter.cc b/chromium/ui/events/ozone/evdev/touch_filter/edge_touch_filter.cc
index 981e81725d7..249515233d8 100644
--- a/chromium/ui/events/ozone/evdev/touch_filter/edge_touch_filter.cc
+++ b/chromium/ui/events/ozone/evdev/touch_filter/edge_touch_filter.cc
@@ -8,7 +8,6 @@
#include <cmath>
-#include "base/logging.h"
#include "base/macros.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/stringprintf.h"
diff --git a/chromium/ui/events/ozone/evdev/touch_filter/heuristic_stylus_palm_detection_filter.h b/chromium/ui/events/ozone/evdev/touch_filter/heuristic_stylus_palm_detection_filter.h
index 49bba4052e8..39a1203a4b2 100644
--- a/chromium/ui/events/ozone/evdev/touch_filter/heuristic_stylus_palm_detection_filter.h
+++ b/chromium/ui/events/ozone/evdev/touch_filter/heuristic_stylus_palm_detection_filter.h
@@ -8,6 +8,7 @@
#include <bitset>
#include <vector>
+#include "base/macros.h"
#include "base/time/time.h"
#include "ui/events/ozone/evdev/touch_evdev_types.h"
#include "ui/events/ozone/evdev/touch_filter/palm_detection_filter.h"
diff --git a/chromium/ui/events/ozone/evdev/touch_filter/heuristic_stylus_palm_detection_filter_unittest.cc b/chromium/ui/events/ozone/evdev/touch_filter/heuristic_stylus_palm_detection_filter_unittest.cc
index 07689c3e8f0..b720ee418ce 100644
--- a/chromium/ui/events/ozone/evdev/touch_filter/heuristic_stylus_palm_detection_filter_unittest.cc
+++ b/chromium/ui/events/ozone/evdev/touch_filter/heuristic_stylus_palm_detection_filter_unittest.cc
@@ -6,6 +6,7 @@
#include <linux/input.h>
+#include "base/macros.h"
#include "base/test/gtest_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/ozone/evdev/touch_filter/palm_detection_filter.h"
diff --git a/chromium/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.cc b/chromium/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.cc
index ff149d10a55..2449b059ab2 100644
--- a/chromium/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.cc
+++ b/chromium/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter.cc
@@ -14,6 +14,7 @@
#include <utility>
#include <vector>
+#include "base/logging.h"
#include "ui/events/ozone/evdev/event_device_info.h"
#include "ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_model.h"
#include "ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_util.h"
@@ -398,6 +399,10 @@ bool NeuralStylusPalmDetectionFilter::
!code_check(ABS_MT_TOUCH_MINOR)) {
return false;
}
+ // Only work with internal touchscreens.
+ if (devinfo.device_type() != INPUT_DEVICE_INTERNAL) {
+ return false;
+ }
return true;
}
diff --git a/chromium/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_unittest.cc b/chromium/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_unittest.cc
index d2954a158ab..0b5ba7f3afc 100644
--- a/chromium/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_unittest.cc
+++ b/chromium/ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_unittest.cc
@@ -74,7 +74,9 @@ TEST_F(NeuralStylusPalmDetectionFilterTest, EventDeviceSimpleTest) {
{kEveTouchScreen, true},
{kLinkTouchscreen, true}, // No ABS_MT_TOOL_TYPE
{kNocturneStylus, false},
- {kKohakuTouchscreen, true}};
+ {kKohakuTouchscreen, true},
+ // The Wacom Intuos is external.
+ {kWacomIntuosPtS_Finger, false}};
for (const auto& it : devices) {
EXPECT_TRUE(CapabilitiesToDeviceInfo(it.first, &devinfo));
EXPECT_EQ(it.second,
diff --git a/chromium/ui/events/ozone/evdev/touch_filter/open_palm_detection_filter.h b/chromium/ui/events/ozone/evdev/touch_filter/open_palm_detection_filter.h
index 9cef99cea43..0280dcb6ecd 100644
--- a/chromium/ui/events/ozone/evdev/touch_filter/open_palm_detection_filter.h
+++ b/chromium/ui/events/ozone/evdev/touch_filter/open_palm_detection_filter.h
@@ -8,6 +8,7 @@
#include <bitset>
#include <vector>
+#include "base/macros.h"
#include "base/time/time.h"
#include "ui/events/ozone/evdev/touch_evdev_types.h"
#include "ui/events/ozone/evdev/touch_filter/palm_detection_filter.h"
diff --git a/chromium/ui/events/ozone/evdev/touch_filter/open_palm_detection_filter_unittest.cc b/chromium/ui/events/ozone/evdev/touch_filter/open_palm_detection_filter_unittest.cc
index 30b479d6b53..0d72b10ecd1 100644
--- a/chromium/ui/events/ozone/evdev/touch_filter/open_palm_detection_filter_unittest.cc
+++ b/chromium/ui/events/ozone/evdev/touch_filter/open_palm_detection_filter_unittest.cc
@@ -4,6 +4,7 @@
#include "ui/events/ozone/evdev/touch_filter/open_palm_detection_filter.h"
+#include "base/macros.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/ozone/evdev/touch_filter/palm_detection_filter.h"
#include "ui/events/ozone/evdev/touch_filter/shared_palm_detection_filter_state.h"
diff --git a/chromium/ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory.cc b/chromium/ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory.cc
index 888e4b09624..9e90f038e6b 100644
--- a/chromium/ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory.cc
+++ b/chromium/ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory.cc
@@ -10,6 +10,7 @@
#include "base/feature_list.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
+#include "base/system/sys_info.h"
#include "base/time/time.h"
#include "ui/events/ozone/evdev/event_device_info.h"
#include "ui/events/ozone/evdev/touch_filter/heuristic_stylus_palm_detection_filter.h"
@@ -40,14 +41,25 @@ std::vector<float> ParseRadiusPolynomial(const std::string& radius_string) {
return return_value;
}
-} // namespace internal
-
-namespace {
std::string FetchNeuralPalmRadiusPolynomial(const EventDeviceInfo& devinfo,
const std::string param_string) {
if (!param_string.empty()) {
return param_string;
}
+
+#if defined(OS_CHROMEOS)
+ // We should really only be running in chromeos anyway; We do a check here
+ // temporarily for hatch and reef. These numbers should live in config on
+ // chromeos side but for now during experiment are hard-coded here.
+ // TODO(robsc): Investigate a better way of doing this configuration.
+ std::string release_board = base::SysInfo::GetLsbReleaseBoard();
+ if ("hatch" == release_board) {
+ return "0.090477715, 3.9225964";
+ } else if ("reef" == release_board) {
+ return "0.17889799, 4.22584412";
+ }
+#endif
+
// Basking. Does not report vendor_id / product_id
if (devinfo.name() == "Elan Touchscreen") {
return "0.17889799,4.22584412";
@@ -56,7 +68,7 @@ std::string FetchNeuralPalmRadiusPolynomial(const EventDeviceInfo& devinfo,
// By default, return the original.
return param_string;
}
-} // namespace
+} // namespace internal
std::unique_ptr<PalmDetectionFilter> CreatePalmDetectionFilter(
const EventDeviceInfo& devinfo,
@@ -64,8 +76,8 @@ std::unique_ptr<PalmDetectionFilter> CreatePalmDetectionFilter(
if (base::FeatureList::IsEnabled(kEnableNeuralPalmDetectionFilter) &&
NeuralStylusPalmDetectionFilter::
CompatibleWithNeuralStylusPalmDetectionFilter(devinfo)) {
- std::vector<float> radius_polynomial =
- internal::ParseRadiusPolynomial(FetchNeuralPalmRadiusPolynomial(
+ std::vector<float> radius_polynomial = internal::ParseRadiusPolynomial(
+ internal::FetchNeuralPalmRadiusPolynomial(
devinfo, kNeuralPalmRadiusPolynomial.Get()));
// Theres only one model right now.
std::unique_ptr<NeuralStylusPalmDetectionFilterModel> model =
diff --git a/chromium/ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory.h b/chromium/ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory.h
index 6972fe0e0b3..4dc9a3db41f 100644
--- a/chromium/ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory.h
+++ b/chromium/ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory.h
@@ -28,6 +28,14 @@ namespace internal {
COMPONENT_EXPORT(EVDEV)
std::vector<float> ParseRadiusPolynomial(const std::string& radius_string);
+
+// Returns either an empty string or a comma separated floating point numbers,
+// used in transforming touch_major/touch_minor radius. The parsed numbers are
+// used as described in:
+// https://source.chromium.org/chromium/chromium/src/+/master:ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_model.h;l=63
+COMPONENT_EXPORT(EVDEV)
+std::string FetchNeuralPalmRadiusPolynomial(const EventDeviceInfo& devinfo,
+ const std::string param_string);
} // namespace internal
} // namespace ui
diff --git a/chromium/ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory_unittest.cc b/chromium/ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory_unittest.cc
index 3d0d7ebb4cc..793ab1cafd1 100644
--- a/chromium/ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory_unittest.cc
+++ b/chromium/ui/events/ozone/evdev/touch_filter/palm_detection_filter_factory_unittest.cc
@@ -6,6 +6,7 @@
#include <linux/input.h>
+#include "base/system/sys_info.h"
#include "base/test/scoped_feature_list.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/ozone/evdev/event_device_info.h"
@@ -32,13 +33,16 @@ class PalmDetectionFilterFactoryTest : public testing::Test {
EXPECT_TRUE(
CapabilitiesToDeviceInfo(kNocturneStylus, &nocturne_stylus_info_));
EXPECT_TRUE(CapabilitiesToDeviceInfo(kEveStylus, &eve_stylus_info_));
+ EXPECT_TRUE(CapabilitiesToDeviceInfo(kKohakuTouchscreen,
+ &kohaku_touchscreen_info_));
scoped_feature_list_ = std::make_unique<base::test::ScopedFeatureList>();
}
protected:
std::unique_ptr<base::test::ScopedFeatureList> scoped_feature_list_;
EventDeviceInfo eve_touchscreen_info_, eve_stylus_info_,
- nocturne_touchscreen_info_, nocturne_stylus_info_;
+ nocturne_touchscreen_info_, nocturne_stylus_info_,
+ kohaku_touchscreen_info_;
SharedPalmDetectionFilterState shared_palm_state_;
DISALLOW_COPY_AND_ASSIGN(PalmDetectionFilterFactoryTest);
@@ -47,6 +51,25 @@ class PalmDetectionFilterFactoryTest : public testing::Test {
class PalmDetectionFilterFactoryDeathTest
: public PalmDetectionFilterFactoryTest {};
+#if defined(OS_CHROMEOS)
+TEST_F(PalmDetectionFilterFactoryTest, Radiuses) {
+ std::string lsb_release = "CHROMEOS_RELEASE_BOARD=hatch\n";
+ base::SysInfo::SetChromeOSVersionInfoForTest(lsb_release, base::Time());
+ EXPECT_EQ("0.090477715, 3.9225964", internal::FetchNeuralPalmRadiusPolynomial(
+ kohaku_touchscreen_info_, ""));
+
+ lsb_release = "CHROMEOS_RELEASE_BOARD=reef\n";
+ base::SysInfo::SetChromeOSVersionInfoForTest(lsb_release, base::Time());
+ EXPECT_EQ("0.17889799, 4.22584412", internal::FetchNeuralPalmRadiusPolynomial(
+ kohaku_touchscreen_info_, ""));
+
+ lsb_release = "CHROMEOS_RELEASE_BOARD=octopus\n";
+ base::SysInfo::SetChromeOSVersionInfoForTest(lsb_release, base::Time());
+ EXPECT_EQ("", internal::FetchNeuralPalmRadiusPolynomial(
+ kohaku_touchscreen_info_, ""));
+}
+#endif
+
TEST_F(PalmDetectionFilterFactoryTest, AllDisabled) {
scoped_feature_list_->InitWithFeatures(
{}, {ui::kEnableHeuristicPalmDetectionFilter,
@@ -55,7 +78,6 @@ TEST_F(PalmDetectionFilterFactoryTest, AllDisabled) {
CreatePalmDetectionFilter(eve_touchscreen_info_, &shared_palm_state_);
EXPECT_EQ(OpenPalmDetectionFilter::kFilterName,
palm_filter->FilterNameForTesting());
-
palm_filter = CreatePalmDetectionFilter(nocturne_touchscreen_info_,
&shared_palm_state_);
EXPECT_EQ(OpenPalmDetectionFilter::kFilterName,
diff --git a/chromium/ui/events/ozone/evdev/touch_filter/palm_model/onedevice_train_palm_detection_filter_model.cc b/chromium/ui/events/ozone/evdev/touch_filter/palm_model/onedevice_train_palm_detection_filter_model.cc
index 5fb01f1d0c1..9cc21624e39 100644
--- a/chromium/ui/events/ozone/evdev/touch_filter/palm_model/onedevice_train_palm_detection_filter_model.cc
+++ b/chromium/ui/events/ozone/evdev/touch_filter/palm_model/onedevice_train_palm_detection_filter_model.cc
@@ -16,6 +16,7 @@
#include <utility>
#include <vector>
+#include "base/logging.h"
#include "ui/events/ozone/evdev/touch_filter/palm_model/onedevice_train_palm_detection_filter_inference.h"
#define USE_EIGEN 0
diff --git a/chromium/ui/events/ozone/evdev/touch_filter/palm_model/onedevice_train_palm_detection_filter_model.h b/chromium/ui/events/ozone/evdev/touch_filter/palm_model/onedevice_train_palm_detection_filter_model.h
index 9759cf64ee4..d4c98728a18 100644
--- a/chromium/ui/events/ozone/evdev/touch_filter/palm_model/onedevice_train_palm_detection_filter_model.h
+++ b/chromium/ui/events/ozone/evdev/touch_filter/palm_model/onedevice_train_palm_detection_filter_model.h
@@ -8,6 +8,7 @@
#include <cstdint>
#include <vector>
+#include "base/macros.h"
#include "ui/events/ozone/evdev/touch_filter/neural_stylus_palm_detection_filter_model.h"
namespace ui {
diff --git a/chromium/ui/events/ozone/features.cc b/chromium/ui/events/ozone/features.cc
index 536ac8f4a2c..85a406afab8 100644
--- a/chromium/ui/events/ozone/features.cc
+++ b/chromium/ui/events/ozone/features.cc
@@ -9,6 +9,9 @@ namespace ui {
const base::Feature kEnableHeuristicPalmDetectionFilter{
"EnableHeuristicPalmDetectionFilter", base::FEATURE_DISABLED_BY_DEFAULT};
+const base::Feature kEnableHighResolutionMouseScrolling{
+ "EnableHighResolutionMouseScrolling", base::FEATURE_ENABLED_BY_DEFAULT};
+
const base::Feature kEnableNeuralPalmDetectionFilter{
"EnableNeuralPalmDetectionFilter", base::FEATURE_DISABLED_BY_DEFAULT};
@@ -21,6 +24,9 @@ const base::Feature kEnablePalmOnMaxTouchMajor{
const base::Feature kEnablePalmOnToolTypePalm{"EnablePalmOnToolTypePalm",
base::FEATURE_ENABLED_BY_DEFAULT};
+const base::Feature kEnablePalmSuppression{"EnablePalmSuppression",
+ base::FEATURE_ENABLED_BY_DEFAULT};
+
extern const base::FeatureParam<std::string> kNeuralPalmRadiusPolynomial{
&kEnableNeuralPalmDetectionFilter, "neural_palm_radius_polynomial", ""};
diff --git a/chromium/ui/events/ozone/features.h b/chromium/ui/events/ozone/features.h
index 761e91403a6..41938a3ba86 100644
--- a/chromium/ui/events/ozone/features.h
+++ b/chromium/ui/events/ozone/features.h
@@ -10,11 +10,13 @@
#include "base/metrics/field_trial_params.h"
namespace ui {
-
COMPONENT_EXPORT(EVENTS_OZONE)
extern const base::Feature kEnableHeuristicPalmDetectionFilter;
COMPONENT_EXPORT(EVENTS_OZONE)
+extern const base::Feature kEnableHighResolutionMouseScrolling;
+
+COMPONENT_EXPORT(EVENTS_OZONE)
extern const base::Feature kEnableNeuralPalmDetectionFilter;
COMPONENT_EXPORT(EVENTS_OZONE)
@@ -30,6 +32,9 @@ COMPONENT_EXPORT(EVENTS_OZONE)
extern const base::FeatureParam<std::string> kNeuralPalmRadiusPolynomial;
COMPONENT_EXPORT(EVENTS_OZONE)
+extern const base::Feature kEnablePalmSuppression;
+
+COMPONENT_EXPORT(EVENTS_OZONE)
extern const base::FeatureParam<double> kHeuristicCancelThresholdSeconds;
COMPONENT_EXPORT(EVENTS_OZONE)
diff --git a/chromium/ui/events/ozone/keyboard/event_auto_repeat_handler.cc b/chromium/ui/events/ozone/keyboard/event_auto_repeat_handler.cc
index 9304b80a001..14a1de58dd1 100644
--- a/chromium/ui/events/ozone/keyboard/event_auto_repeat_handler.cc
+++ b/chromium/ui/events/ozone/keyboard/event_auto_repeat_handler.cc
@@ -49,19 +49,23 @@ void EventAutoRepeatHandler::GetAutoRepeatRate(base::TimeDelta* delay,
}
void EventAutoRepeatHandler::UpdateKeyRepeat(unsigned int key,
+ unsigned int scan_code,
bool down,
bool suppress_auto_repeat,
int device_id) {
if (!auto_repeat_enabled_ || suppress_auto_repeat)
StopKeyRepeat();
else if (key != repeat_key_ && down)
- StartKeyRepeat(key, device_id);
+ StartKeyRepeat(key, scan_code, device_id);
else if (key == repeat_key_ && !down)
StopKeyRepeat();
}
-void EventAutoRepeatHandler::StartKeyRepeat(unsigned int key, int device_id) {
+void EventAutoRepeatHandler::StartKeyRepeat(unsigned int key,
+ unsigned int scan_code,
+ int device_id) {
repeat_key_ = key;
+ repeat_scan_code_ = scan_code;
repeat_device_id_ = device_id;
repeat_sequence_++;
@@ -70,6 +74,7 @@ void EventAutoRepeatHandler::StartKeyRepeat(unsigned int key, int device_id) {
void EventAutoRepeatHandler::StopKeyRepeat() {
repeat_key_ = kInvalidKey;
+ repeat_scan_code_ = 0;
repeat_sequence_++;
}
@@ -95,8 +100,9 @@ void EventAutoRepeatHandler::OnRepeatCommit(unsigned int sequence) {
if (repeat_sequence_ != sequence)
return;
- delegate_->DispatchKey(repeat_key_, true /* down */, true /* repeat */,
- EventTimeForNow(), repeat_device_id_, ui::EF_NONE);
+ delegate_->DispatchKey(repeat_key_, repeat_scan_code_, true /* down */,
+ true /* repeat */, EventTimeForNow(),
+ repeat_device_id_, ui::EF_NONE);
ScheduleKeyRepeat(repeat_interval_);
}
diff --git a/chromium/ui/events/ozone/keyboard/event_auto_repeat_handler.h b/chromium/ui/events/ozone/keyboard/event_auto_repeat_handler.h
index eb10aa20d8b..39c3239c5b2 100644
--- a/chromium/ui/events/ozone/keyboard/event_auto_repeat_handler.h
+++ b/chromium/ui/events/ozone/keyboard/event_auto_repeat_handler.h
@@ -21,6 +21,7 @@ class COMPONENT_EXPORT(EVENTS_OZONE) EventAutoRepeatHandler {
// Useful under janky situations.
virtual void FlushInput(base::OnceClosure closure) = 0;
virtual void DispatchKey(unsigned int key,
+ unsigned int scan_code,
bool down,
bool repeat,
base::TimeTicks timestamp,
@@ -32,6 +33,7 @@ class COMPONENT_EXPORT(EVENTS_OZONE) EventAutoRepeatHandler {
~EventAutoRepeatHandler();
void UpdateKeyRepeat(unsigned int key,
+ unsigned int scan_code,
bool down,
bool suppress_auto_repeat,
int device_id);
@@ -47,7 +49,7 @@ class COMPONENT_EXPORT(EVENTS_OZONE) EventAutoRepeatHandler {
private:
static constexpr unsigned int kInvalidKey = 0;
- void StartKeyRepeat(unsigned int key, int device_id);
+ void StartKeyRepeat(unsigned int key, unsigned int scan_code, int device_id);
void ScheduleKeyRepeat(const base::TimeDelta& delay);
void OnRepeatTimeout(unsigned int sequence);
void OnRepeatCommit(unsigned int sequence);
@@ -55,6 +57,7 @@ class COMPONENT_EXPORT(EVENTS_OZONE) EventAutoRepeatHandler {
// Key repeat state.
bool auto_repeat_enabled_ = true;
unsigned int repeat_key_ = kInvalidKey;
+ unsigned int repeat_scan_code_ = 0;
unsigned int repeat_sequence_ = 0;
int repeat_device_id_ = 0;
base::TimeDelta repeat_delay_;
diff --git a/chromium/ui/events/ozone/layout/keyboard_layout_engine_manager.cc b/chromium/ui/events/ozone/layout/keyboard_layout_engine_manager.cc
index 018d95d5f13..c766903c079 100644
--- a/chromium/ui/events/ozone/layout/keyboard_layout_engine_manager.cc
+++ b/chromium/ui/events/ozone/layout/keyboard_layout_engine_manager.cc
@@ -4,7 +4,7 @@
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h"
namespace ui {
diff --git a/chromium/ui/events/ozone/layout/scoped_keyboard_layout_engine.cc b/chromium/ui/events/ozone/layout/scoped_keyboard_layout_engine.cc
index 3a7939b585a..b1b252ee94b 100644
--- a/chromium/ui/events/ozone/layout/scoped_keyboard_layout_engine.cc
+++ b/chromium/ui/events/ozone/layout/scoped_keyboard_layout_engine.cc
@@ -4,6 +4,7 @@
#include "ui/events/ozone/layout/scoped_keyboard_layout_engine.h"
+#include "base/check_op.h"
#include "ui/events/ozone/layout/keyboard_layout_engine.h"
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
#include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h"
diff --git a/chromium/ui/events/platform/x11/BUILD.gn b/chromium/ui/events/platform/x11/BUILD.gn
index ae2bab9559f..20ea6d8a4d9 100644
--- a/chromium/ui/events/platform/x11/BUILD.gn
+++ b/chromium/ui/events/platform/x11/BUILD.gn
@@ -20,8 +20,6 @@ jumbo_component("x11") {
defines = [ "EVENTS_IMPLEMENTATION" ]
- configs += [ "//build/config/linux:x11" ]
-
public_deps = [
"//ui/events",
"//ui/events:events_base",
diff --git a/chromium/ui/events/platform/x11/x11_event_source.cc b/chromium/ui/events/platform/x11/x11_event_source.cc
index e0b96ca9bfd..91df6daefd9 100644
--- a/chromium/ui/events/platform/x11/x11_event_source.cc
+++ b/chromium/ui/events/platform/x11/x11_event_source.cc
@@ -4,7 +4,14 @@
#include "ui/events/platform/x11/x11_event_source.h"
+#include <X11/Xlib-xcb.h>
+#include <xcb/xcb.h>
+#include <xcb/xcbext.h>
+
+#include <type_traits>
+
#include "base/logging.h"
+#include "base/memory/free_deleter.h"
#include "base/metrics/histogram_macros.h"
#include "ui/events/devices/x11/device_data_manager_x11.h"
#include "ui/events/devices/x11/touch_factory_x11.h"
@@ -32,6 +39,27 @@ namespace ui {
namespace {
+// On the wire, sequence IDs are 16 bits. In xcb, they're usually extended to
+// 32 and sometimes 64 bits. In Xlib, they're extended to unsigned long, which
+// may be 32 or 64 bits depending on the platform. This function is intended to
+// prevent bugs caused by comparing two differently sized sequences. Also
+// handles rollover. To use, compare the result of this function with 0. For
+// example, to compare seq1 <= seq2, use CompareSequenceIds(seq1, seq2) <= 0.
+template <typename T, typename U>
+auto CompareSequenceIds(T t, U u) {
+ static_assert(std::is_unsigned<T>::value, "");
+ static_assert(std::is_unsigned<U>::value, "");
+ // Cast to the smaller of the two types so that comparisons will always work.
+ // If we casted to the larger type, then the smaller type will be zero-padded
+ // and may incorrectly compare less than the other value.
+ using SmallerType =
+ typename std::conditional<sizeof(T) <= sizeof(U), T, U>::type;
+ SmallerType t0 = static_cast<SmallerType>(t);
+ SmallerType u0 = static_cast<SmallerType>(u);
+ using SignedType = typename std::make_signed<SmallerType>::type;
+ return static_cast<SignedType>(t0 - u0);
+}
+
bool InitializeXkb(XDisplay* display) {
if (!display)
return false;
@@ -101,6 +129,18 @@ x11::Bool IsPropertyNotifyForTimestamp(Display* display,
} // namespace
+X11EventSource::Request::Request(bool is_void,
+ unsigned int sequence,
+ ResponseCallback callback)
+ : is_void(is_void), sequence(sequence), callback(std::move(callback)) {}
+
+X11EventSource::Request::Request(Request&& other)
+ : is_void(other.is_void),
+ sequence(other.sequence),
+ callback(std::move(other.callback)) {}
+
+X11EventSource::Request::~Request() = default;
+
#if defined(USE_GLIB)
using X11EventWatcherImpl = X11EventWatcherGlib;
#else
@@ -148,14 +188,57 @@ X11EventSource* X11EventSource::GetInstance() {
void X11EventSource::DispatchXEvents() {
DCHECK(display_);
- // Handle all pending events.
- // It may be useful to eventually align this event dispatch with vsync, but
- // not yet.
- continue_stream_ = true;
- while (XPending(display_) && continue_stream_) {
+
+ auto process_next_response = [&]() {
+ xcb_connection_t* connection = XGetXCBConnection(display_);
+ auto request = std::move(requests_.front());
+ requests_.pop();
+
+ void* raw_reply = nullptr;
+ xcb_generic_error_t* raw_error = nullptr;
+ xcb_poll_for_reply(connection, request.sequence, &raw_reply, &raw_error);
+ DCHECK(request.is_void || raw_reply || raw_error);
+
+ std::move(request.callback)
+ .Run(Reply{reinterpret_cast<uint8_t*>(raw_reply)}, Error{raw_error});
+ };
+
+ auto process_next_event = [&]() {
XEvent xevent;
XNextEvent(display_, &xevent);
ExtractCookieDataDispatchEvent(&xevent);
+ };
+
+ // Handle all pending events.
+ continue_stream_ = true;
+ while (continue_stream_) {
+ bool has_next_response =
+ !requests_.empty() &&
+ CompareSequenceIds(XLastKnownRequestProcessed(display_),
+ requests_.front().sequence) >= 0;
+ bool has_next_event = XPending(display_);
+
+ if (has_next_response && has_next_event) {
+ auto next_response_sequence = requests_.front().sequence;
+
+ XEvent event;
+ XPeekEvent(display_, &event);
+ auto next_event_sequence = event.xany.serial;
+
+ // All events have the sequence number of the last processed request
+ // included in them. So if a reply and an event have the same sequence,
+ // the reply must have been received first.
+ if (CompareSequenceIds(next_event_sequence, next_response_sequence) <= 0)
+ process_next_response();
+ else
+ process_next_event();
+ } else if (has_next_response) {
+ process_next_response();
+ } else if (has_next_event) {
+ process_next_event();
+ } else {
+ break;
+ }
}
}
@@ -430,6 +513,15 @@ void X11EventSource::OnDispatcherListChanged() {
}
}
+void X11EventSource::AddRequest(bool is_void,
+ unsigned int sequence,
+ ResponseCallback callback) {
+ DCHECK(requests_.empty() ||
+ CompareSequenceIds(requests_.back().sequence, sequence) < 0);
+
+ requests_.emplace(is_void, sequence, std::move(callback));
+}
+
// ScopedXEventDispatcher implementation
ScopedXEventDispatcher::ScopedXEventDispatcher(
XEventDispatcher** scoped_dispatcher,
diff --git a/chromium/ui/events/platform/x11/x11_event_source.h b/chromium/ui/events/platform/x11/x11_event_source.h
index c53731d9580..e1673c2a44c 100644
--- a/chromium/ui/events/platform/x11/x11_event_source.h
+++ b/chromium/ui/events/platform/x11/x11_event_source.h
@@ -8,13 +8,16 @@
#include <stdint.h>
#include <memory>
+#include <queue>
#include <random>
#include "base/auto_reset.h"
+#include "base/callback.h"
#include "base/macros.h"
#include "base/optional.h"
#include "ui/events/events_export.h"
#include "ui/events/platform/platform_event_source.h"
+#include "ui/gfx/x/request_queue.h"
#include "ui/gfx/x/x11_types.h"
using Time = unsigned long;
@@ -120,7 +123,8 @@ class EVENTS_EXPORT ScopedXEventDispatcher {
// Receives X11 events from X11EventWatcher and sends them to registered
// {Platform,X}EventDispatchers. Handles receiving, pre-process, translation
// and post-processing of XEvents.
-class EVENTS_EXPORT X11EventSource : public PlatformEventSource {
+class EVENTS_EXPORT X11EventSource : public PlatformEventSource,
+ x11::RequestQueue {
public:
explicit X11EventSource(XDisplay* display);
~X11EventSource() override;
@@ -194,6 +198,16 @@ class EVENTS_EXPORT X11EventSource : public PlatformEventSource {
private:
friend class ScopedXEventDispatcher;
+ struct Request {
+ Request(bool is_void, unsigned int sequence, ResponseCallback callback);
+ Request(Request&& other);
+ ~Request();
+
+ const bool is_void;
+ const unsigned int sequence;
+ ResponseCallback callback;
+ };
+
// Tells XEventDispatchers, which can also have PlatformEventDispatchers, that
// a translated event is going to be sent next, then dispatches the event and
// notifies XEventDispatchers the event has been sent out and, most probably,
@@ -207,6 +221,11 @@ class EVENTS_EXPORT X11EventSource : public PlatformEventSource {
void StopCurrentEventStream() override;
void OnDispatcherListChanged() override;
+ // x11::RequestQueue
+ void AddRequest(bool is_void,
+ unsigned int sequence,
+ ResponseCallback callback) override;
+
void RestoreOverridenXEventDispatcher();
static X11EventSource* instance_;
@@ -243,6 +262,8 @@ class EVENTS_EXPORT X11EventSource : public PlatformEventSource {
XEventDispatcher* overridden_dispatcher_ = nullptr;
bool overridden_dispatcher_restored_ = false;
+ std::queue<Request> requests_;
+
DISALLOW_COPY_AND_ASSIGN(X11EventSource);
};
diff --git a/chromium/ui/events/platform/x11/x11_hotplug_event_handler.cc b/chromium/ui/events/platform/x11/x11_hotplug_event_handler.cc
index 750181a638c..80487ce53b3 100644
--- a/chromium/ui/events/platform/x11/x11_hotplug_event_handler.cc
+++ b/chromium/ui/events/platform/x11/x11_hotplug_event_handler.cc
@@ -13,9 +13,9 @@
#include <vector>
#include "base/bind.h"
+#include "base/check.h"
#include "base/command_line.h"
#include "base/location.h"
-#include "base/logging.h"
#include "base/process/launch.h"
#include "base/single_thread_task_runner.h"
#include "base/strings/string_util.h"
diff --git a/chromium/ui/events/pointer_details.cc b/chromium/ui/events/pointer_details.cc
index e2dedfd7588..b83926f7988 100644
--- a/chromium/ui/events/pointer_details.cc
+++ b/chromium/ui/events/pointer_details.cc
@@ -39,9 +39,7 @@ PointerDetails::PointerDetails(EventPointerType pointer_type,
twist(twist),
id(pointer_id) {
if (pointer_id == kPointerIdUnknown) {
- id = (pointer_type == EventPointerType::POINTER_TYPE_MOUSE)
- ? kPointerIdMouse
- : 0;
+ id = (pointer_type == EventPointerType::kMouse) ? kPointerIdMouse : 0;
}
}
diff --git a/chromium/ui/events/pointer_details.h b/chromium/ui/events/pointer_details.h
index f274a81a929..d03db11d10e 100644
--- a/chromium/ui/events/pointer_details.h
+++ b/chromium/ui/events/pointer_details.h
@@ -45,7 +45,7 @@ struct EVENTS_BASE_EXPORT PointerDetails {
bool operator==(const PointerDetails& other) const;
// The type of pointer device.
- EventPointerType pointer_type = EventPointerType::POINTER_TYPE_UNKNOWN;
+ EventPointerType pointer_type = EventPointerType::kUnknown;
// Radius of the X (major) axis of the touch ellipse. 0.0 if unknown.
float radius_x = 0.0;
diff --git a/chromium/ui/events/types/BUILD.gn b/chromium/ui/events/types/BUILD.gn
index 6b897c25c33..f30523584ee 100644
--- a/chromium/ui/events/types/BUILD.gn
+++ b/chromium/ui/events/types/BUILD.gn
@@ -5,6 +5,7 @@
source_set("headers") {
sources = [
"event_type.h",
+ "scroll_input_type.h",
"scroll_types.h",
]
}
diff --git a/chromium/ui/events/types/scroll_input_type.h b/chromium/ui/events/types/scroll_input_type.h
new file mode 100644
index 00000000000..0b1e9f40b7b
--- /dev/null
+++ b/chromium/ui/events/types/scroll_input_type.h
@@ -0,0 +1,20 @@
+// Copyright 2020 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 UI_EVENTS_TYPES_SCROLL_INPUT_TYPE_H_
+#define UI_EVENTS_TYPES_SCROLL_INPUT_TYPE_H_
+
+namespace ui {
+
+enum class ScrollInputType {
+ kTouchscreen = 0,
+ kWheel,
+ kAutoscroll,
+ kScrollbar,
+ kMaxValue = kScrollbar,
+};
+
+} // namespace ui
+
+#endif // UI_EVENTS_TYPES_SCROLL_INPUT_TYPE_H_
diff --git a/chromium/ui/events/win/events_win.cc b/chromium/ui/events/win/events_win.cc
index ea616c72938..c8cd2a8c75a 100644
--- a/chromium/ui/events/win/events_win.cc
+++ b/chromium/ui/events/win/events_win.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/notreached.h"
#include "ui/events/event_utils.h"
#include "ui/events/win/events_win_utils.h"
@@ -59,7 +60,7 @@ void ReleaseCopiedNativeEvent(const MSG& event) {}
PointerDetails GetTouchPointerDetailsFromNative(const MSG& native_event) {
NOTIMPLEMENTED();
- return PointerDetails(EventPointerType::POINTER_TYPE_TOUCH,
+ return PointerDetails(EventPointerType::kTouch,
/* pointer_id*/ 0,
/* radius_x */ 1.0,
/* radius_y */ 1.0,
diff --git a/chromium/ui/events/win/events_win_utils.cc b/chromium/ui/events/win/events_win_utils.cc
index 26924ca32e8..655e113dd4e 100644
--- a/chromium/ui/events/win/events_win_utils.cc
+++ b/chromium/ui/events/win/events_win_utils.cc
@@ -4,7 +4,8 @@
#include <stdint.h>
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "base/time/time.h"
#include "base/win/windowsx_shim.h"
#include "ui/events/event_constants.h"
@@ -322,9 +323,9 @@ PointerDetails GetMousePointerDetailsFromMSG(const MSG& native_event) {
// We should filter out all the mouse events Synthesized from touch events.
// TODO(lanwei): Will set the pointer ID, see https://crbug.com/616771.
if ((GetMessageExtraInfo() & SIGNATURE_MASK) != MOUSEEVENTF_FROMTOUCHPEN)
- return PointerDetails(EventPointerType::POINTER_TYPE_MOUSE);
+ return PointerDetails(EventPointerType::kMouse);
- return PointerDetails(EventPointerType::POINTER_TYPE_PEN);
+ return PointerDetails(EventPointerType::kPen);
}
gfx::Vector2d GetMouseWheelOffsetFromMSG(const MSG& native_event) {
@@ -352,7 +353,7 @@ int GetTouchIdFromMSG(const MSG& xev) {
PointerDetails GetTouchPointerDetailsFromMSG(const MSG& native_event) {
NOTIMPLEMENTED();
- return PointerDetails(EventPointerType::POINTER_TYPE_TOUCH,
+ return PointerDetails(EventPointerType::kTouch,
/* pointer_id*/ 0,
/* radius_x */ 1.0,
/* radius_y */ 1.0,
diff --git a/chromium/ui/events/x/BUILD.gn b/chromium/ui/events/x/BUILD.gn
index a1daab6ef3e..05d291d5981 100644
--- a/chromium/ui/events/x/BUILD.gn
+++ b/chromium/ui/events/x/BUILD.gn
@@ -27,7 +27,6 @@ component("x") {
"//ui/events/keycodes:x11",
"//ui/gfx/x",
]
- configs += [ "//build/config/linux:x11" ]
}
# XEvent translation tests are kept in a separate source_set so that both
@@ -44,7 +43,6 @@ source_set("unittests") {
"events_x_unittest.cc",
"x11_event_translation_unittest.cc",
]
- configs += [ "//build/config/linux:x11" ]
deps = [
"//base/test:test_support",
"//testing/gtest",
diff --git a/chromium/ui/events/x/events_x_utils.cc b/chromium/ui/events/x/events_x_utils.cc
index 6c069918dbf..e07b8b2c1ce 100644
--- a/chromium/ui/events/x/events_x_utils.cc
+++ b/chromium/ui/events/x/events_x_utils.cc
@@ -353,14 +353,11 @@ base::TimeTicks TimeTicksFromXEvent(const XEvent& xev) {
case ButtonPress:
case ButtonRelease:
return TimeTicksFromXEventTime(xev.xbutton.time);
- break;
case MotionNotify:
return TimeTicksFromXEventTime(xev.xmotion.time);
- break;
case EnterNotify:
case LeaveNotify:
return TimeTicksFromXEventTime(xev.xcrossing.time);
- break;
case GenericEvent: {
double start, end;
double touch_timestamp;
@@ -371,11 +368,9 @@ base::TimeTicks TimeTicksFromXEvent(const XEvent& xev) {
xev, ui::DeviceDataManagerX11::DT_TOUCH_RAW_TIMESTAMP,
&touch_timestamp)) {
return ui::EventTimeStampFromSeconds(touch_timestamp);
- } else {
- XIDeviceEvent* xide = static_cast<XIDeviceEvent*>(xev.xcookie.data);
- return TimeTicksFromXEventTime(xide->time);
}
- break;
+ XIDeviceEvent* xide = static_cast<XIDeviceEvent*>(xev.xcookie.data);
+ return TimeTicksFromXEventTime(xide->time);
}
}
NOTREACHED();
@@ -529,7 +524,6 @@ int EventFlagsFromXEvent(const XEvent& xev) {
GetEventFlagsFromXState(xievent->mods.effective) |
GetEventFlagsFromXState(
XModifierStateWatcher::GetInstance()->state());
- break;
case XI_ButtonPress:
case XI_ButtonRelease: {
const bool touch =
@@ -745,7 +739,7 @@ EventPointerType GetTouchPointerTypeFromXEvent(const XEvent& xev) {
PointerDetails GetTouchPointerDetailsFromXEvent(const XEvent& xev) {
return PointerDetails(
- EventPointerType::POINTER_TYPE_TOUCH, GetTouchIdFromXEvent(xev),
+ EventPointerType::kTouch, GetTouchIdFromXEvent(xev),
GetTouchRadiusXFromXEvent(xev), GetTouchRadiusYFromXEvent(xev),
GetTouchForceFromXEvent(xev), GetTouchAngleFromXEvent(xev));
}
diff --git a/chromium/ui/events/x/keyboard_hook_x11.cc b/chromium/ui/events/x/keyboard_hook_x11.cc
index 0df8bcb474e..fb2bccea047 100644
--- a/chromium/ui/events/x/keyboard_hook_x11.cc
+++ b/chromium/ui/events/x/keyboard_hook_x11.cc
@@ -7,8 +7,8 @@
#include <vector>
#include "base/callback.h"
+#include "base/check_op.h"
#include "base/containers/flat_set.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/optional.h"
#include "base/stl_util.h"
diff --git a/chromium/ui/events/x/x11_event_translation.cc b/chromium/ui/events/x/x11_event_translation.cc
index f1b2c391346..6bb5a30376e 100644
--- a/chromium/ui/events/x/x11_event_translation.cc
+++ b/chromium/ui/events/x/x11_event_translation.cc
@@ -6,6 +6,8 @@
#include <vector>
+#include "base/check.h"
+#include "base/notreached.h"
#include "base/time/time.h"
#include "ui/events/devices/x11/touch_factory_x11.h"
#include "ui/events/event.h"
@@ -112,7 +114,7 @@ std::unique_ptr<MouseEvent> CreateMouseEvent(EventType type,
if (enter_or_leave && xev.xcrossing.detail == NotifyInferior)
return nullptr;
- PointerDetails details{EventPointerType::POINTER_TYPE_MOUSE};
+ PointerDetails details{EventPointerType::kMouse};
auto event = std::make_unique<MouseEvent>(
type, EventLocationFromXEvent(xev), EventSystemLocationFromXEvent(xev),
EventTimeFromXEvent(xev), EventFlagsFromXEvent(xev),
diff --git a/chromium/ui/events/x/x11_event_translation_unittest.cc b/chromium/ui/events/x/x11_event_translation_unittest.cc
index 0f922a243a0..88bfc404a99 100644
--- a/chromium/ui/events/x/x11_event_translation_unittest.cc
+++ b/chromium/ui/events/x/x11_event_translation_unittest.cc
@@ -10,7 +10,10 @@
#include "ui/events/event.h"
#include "ui/events/event_constants.h"
#include "ui/events/event_utils.h"
+#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/dom_key.h"
+#include "ui/events/keycodes/dom/keycode_converter.h"
+#include "ui/events/keycodes/keyboard_codes_posix.h"
#include "ui/events/test/events_test_utils.h"
#include "ui/events/test/events_test_utils_x11.h"
#include "ui/events/test/keyboard_layout.h"
@@ -154,4 +157,55 @@ TEST(XEventTranslationTest, ChangedMouseButtonFlags) {
EXPECT_EQ(0, mouseev3->changed_button_flags());
}
+// Verifies 'repeat' flag is properly set when key events for modifiers and
+// their counterparts are mixed. Ensures regressions like crbug.com/1069690
+// are not reintroduced in the future.
+TEST(XEventTranslationTest, KeyModifiersCounterpartRepeat) {
+ using base::TimeDelta;
+
+ // Use a TestTickClock so we have the power to control the time :)
+ test::ScopedEventTestTickClock test_clock;
+
+ // Create and init a XEvent for ShiftLeft key.
+ ui::ScopedXI2Event shift_l_pressed;
+ shift_l_pressed.InitKeyEvent(ET_KEY_PRESSED, VKEY_LSHIFT, EF_NONE);
+
+ // Press ShiftLeft a first time and hold it.
+ auto keyev_shift_l_pressed = BuildKeyEventFromXEvent(*shift_l_pressed);
+ EXPECT_FALSE(keyev_shift_l_pressed->is_repeat());
+
+ // Create a few more ShiftLeft key events and ensure 'repeat' flag is set.
+ test_clock.Advance(TimeDelta::FromMilliseconds(100));
+ keyev_shift_l_pressed = BuildKeyEventFromXEvent(*shift_l_pressed);
+ EXPECT_TRUE(keyev_shift_l_pressed->is_repeat());
+
+ test_clock.Advance(TimeDelta::FromMilliseconds(200));
+ keyev_shift_l_pressed = BuildKeyEventFromXEvent(*shift_l_pressed);
+ EXPECT_TRUE(keyev_shift_l_pressed->is_repeat());
+
+ test_clock.Advance(TimeDelta::FromMilliseconds(500));
+ keyev_shift_l_pressed = BuildKeyEventFromXEvent(*shift_l_pressed);
+ EXPECT_TRUE(keyev_shift_l_pressed->is_repeat());
+
+ // Press and release ShiftRight and verify 'repeat' flag is not set.
+
+ // Create and init XEvent for emulating a ShiftRight key press.
+ ui::ScopedXI2Event shift_r_pressed;
+ shift_r_pressed.InitKeyEvent(ET_KEY_PRESSED, VKEY_RSHIFT, EF_SHIFT_DOWN);
+
+ test_clock.Advance(TimeDelta::FromSeconds(1));
+ auto keyev_shift_r_pressed = BuildKeyEventFromXEvent(*shift_r_pressed);
+ EXPECT_FALSE(keyev_shift_r_pressed->is_repeat());
+ EXPECT_EQ(ET_KEY_PRESSED, keyev_shift_r_pressed->type());
+
+ // Create and init XEvent for emulating a ShiftRight key release.
+ ui::ScopedXI2Event shift_r_released;
+ shift_r_released.InitKeyEvent(ET_KEY_RELEASED, VKEY_RSHIFT, EF_SHIFT_DOWN);
+
+ test_clock.Advance(TimeDelta::FromMilliseconds(300));
+ auto keyev_shift_r_released = BuildKeyEventFromXEvent(*shift_r_released);
+ EXPECT_FALSE(keyev_shift_r_released->is_repeat());
+ EXPECT_EQ(ET_KEY_RELEASED, keyev_shift_r_released->type());
+}
+
} // namespace ui
diff --git a/chromium/ui/file_manager/file_manager/foreground/elements/BUILD.gn b/chromium/ui/file_manager/file_manager/foreground/elements/BUILD.gn
index 85ef4bc6cbf..ff2352ac56e 100644
--- a/chromium/ui/file_manager/file_manager/foreground/elements/BUILD.gn
+++ b/chromium/ui/file_manager/file_manager/foreground/elements/BUILD.gn
@@ -28,6 +28,7 @@ js_type_check("closure_compile_module") {
":files_ripple",
":files_safe_media",
":files_safe_media_webview_content",
+ ":files_spinner",
":files_toast",
":files_toggle_ripple",
":files_tooltip",
@@ -96,6 +97,9 @@ js_library("files_safe_media") {
js_library("files_safe_media_webview_content") {
}
+js_library("files_spinner") {
+}
+
# TODO(tapted): Move this to //ui/file_manager/base.
js_library("files_toast") {
visibility += [ "//ui/file_manager/gallery/*" ]
@@ -109,6 +113,7 @@ js_library("files_toggle_ripple") {
# TODO(tapted): Move this to //ui/file_manager/base.
js_library("files_tooltip") {
visibility += [ "//ui/file_manager/gallery/*" ]
+ deps = [ "//ui/file_manager/file_manager/common/js:util" ]
}
js_unittest("files_tooltip_unittest") {
diff --git a/chromium/ui/file_manager/file_manager/foreground/js/BUILD.gn b/chromium/ui/file_manager/file_manager/foreground/js/BUILD.gn
index a01b496d227..17706b170b7 100644
--- a/chromium/ui/file_manager/file_manager/foreground/js/BUILD.gn
+++ b/chromium/ui/file_manager/file_manager/foreground/js/BUILD.gn
@@ -383,6 +383,15 @@ js_library("file_manager_commands") {
externs_list = [ "//ui/file_manager/externs/command_handler_deps.js" ]
}
+js_unittest("file_manager_commands_unittest") {
+ deps = [
+ ":file_manager_commands",
+ ":file_tasks",
+ "//ui/file_manager/file_manager/background/js:mock_volume_manager",
+ "//ui/webui/resources/js:webui_resource_test",
+ ]
+}
+
js_library("file_selection") {
deps = [
":constants",
@@ -798,6 +807,7 @@ js_test_gen_html("js_test_gen_html") {
deps = [
":actions_model_unittest",
":file_list_model_unittest",
+ ":file_manager_commands_unittest",
":file_tasks_unittest",
":file_transfer_controller_unittest",
":import_controller_unittest",
diff --git a/chromium/ui/file_manager/file_manager/foreground/js/ui/BUILD.gn b/chromium/ui/file_manager/file_manager/foreground/js/ui/BUILD.gn
index 14e72e22b2e..2d16ed8d869 100644
--- a/chromium/ui/file_manager/file_manager/foreground/js/ui/BUILD.gn
+++ b/chromium/ui/file_manager/file_manager/foreground/js/ui/BUILD.gn
@@ -123,9 +123,14 @@ js_library("banners") {
}
js_library("breadcrumb") {
+ deps = [ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu" ]
+}
+
+js_unittest("breadcrumb_unittest") {
deps = [
- "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
+ ":breadcrumb",
"//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:webui_resource_test",
]
}
@@ -234,6 +239,7 @@ js_unittest("file_list_selection_model_unittest") {
js_library("file_manager_dialog_base") {
deps = [
+ "//ui/file_manager/file_manager/common/js:util",
"//ui/webui/resources/js:cr",
"//ui/webui/resources/js/cr:ui",
"//ui/webui/resources/js/cr/ui:dialogs",
@@ -277,6 +283,7 @@ js_library("file_manager_ui") {
":suggest_apps_dialog",
"//ui/file_manager/file_manager/common/js:util",
"//ui/file_manager/file_manager/foreground/elements:files_message",
+ "//ui/file_manager/file_manager/foreground/elements:files_spinner",
"//ui/file_manager/file_manager/foreground/elements:files_toast",
"//ui/file_manager/file_manager/foreground/elements:files_toggle_ripple",
"//ui/file_manager/file_manager/foreground/elements:files_tooltip",
@@ -408,6 +415,7 @@ js_library("list_container") {
deps = [
":file_grid",
":file_table",
+ "//ui/file_manager/file_manager/common/js:util",
"//ui/webui/resources/js/cr/ui:list_item",
]
}
@@ -506,6 +514,7 @@ js_library("suggest_apps_dialog") {
js_test_gen_html("js_test_gen_html") {
deps = [
":actions_submenu_unittest",
+ ":breadcrumb_unittest",
":directory_tree_unittest",
":file_list_selection_model_unittest",
":file_manager_dialog_base_unittest",
diff --git a/chromium/ui/gfx/BUILD.gn b/chromium/ui/gfx/BUILD.gn
index bf1466eac97..31f3b93e51b 100644
--- a/chromium/ui/gfx/BUILD.gn
+++ b/chromium/ui/gfx/BUILD.gn
@@ -410,7 +410,6 @@ jumbo_component("gfx") {
if (use_x11) {
deps += [ "//ui/gfx/x" ]
- configs += [ "//build/config/linux:x11" ]
}
}
@@ -452,7 +451,6 @@ jumbo_component("color_space") {
}
if (use_x11) {
deps += [ "//ui/gfx/x" ]
- configs += [ "//build/config/linux:x11" ]
}
defines = [ "COLOR_SPACE_IMPLEMENTATION" ]
}
@@ -750,6 +748,7 @@ test("gfx_unittests") {
"paint_vector_icon_unittest.cc",
"range/range_unittest.cc",
"selection_bound_unittest.cc",
+ "selection_model_unittest.cc",
"sequential_id_generator_unittest.cc",
"shadow_value_unittest.cc",
"skbitmap_operations_unittest.cc",
diff --git a/chromium/ui/gfx/android/java_bitmap.cc b/chromium/ui/gfx/android/java_bitmap.cc
index 9e5f2c417fd..2a5d5883e7c 100644
--- a/chromium/ui/gfx/android/java_bitmap.cc
+++ b/chromium/ui/gfx/android/java_bitmap.cc
@@ -8,7 +8,8 @@
#include "base/android/jni_string.h"
#include "base/bits.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/gfx_jni_headers/BitmapHelper_jni.h"
@@ -59,22 +60,29 @@ static int SkColorTypeToBitmapFormat(SkColorType color_type) {
ScopedJavaLocalRef<jobject> CreateJavaBitmap(int width,
int height,
- SkColorType color_type) {
+ SkColorType color_type,
+ OomBehavior reaction) {
DCHECK_GT(width, 0);
DCHECK_GT(height, 0);
int java_bitmap_config = SkColorTypeToBitmapFormat(color_type);
return Java_BitmapHelper_createBitmap(
- AttachCurrentThread(), width, height, java_bitmap_config);
+ AttachCurrentThread(), width, height, java_bitmap_config,
+ reaction == OomBehavior::kReturnNullOnOom);
}
-ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap) {
+ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(const SkBitmap* skbitmap,
+ OomBehavior reaction) {
DCHECK(skbitmap);
DCHECK(!skbitmap->isNull());
SkColorType color_type = skbitmap->colorType();
DCHECK((color_type == kRGB_565_SkColorType) ||
(color_type == kN32_SkColorType));
ScopedJavaLocalRef<jobject> jbitmap = CreateJavaBitmap(
- skbitmap->width(), skbitmap->height(), color_type);
+ skbitmap->width(), skbitmap->height(), color_type, reaction);
+ if (!jbitmap) {
+ DCHECK_EQ(OomBehavior::kReturnNullOnOom, reaction);
+ return jbitmap;
+ }
JavaBitmap dst_lock(jbitmap);
void* src_pixels = skbitmap->getPixels();
void* dst_pixels = dst_lock.pixels();
diff --git a/chromium/ui/gfx/android/java_bitmap.h b/chromium/ui/gfx/android/java_bitmap.h
index 950509164a6..9e36dfc223e 100644
--- a/chromium/ui/gfx/android/java_bitmap.h
+++ b/chromium/ui/gfx/android/java_bitmap.h
@@ -53,18 +53,25 @@ class GFX_EXPORT JavaBitmap {
DISALLOW_COPY_AND_ASSIGN(JavaBitmap);
};
+enum class OomBehavior {
+ kCrashOnOom,
+ kReturnNullOnOom,
+};
+
// Allocates a Java-backed bitmap (android.graphics.Bitmap) with the given
// (non-empty!) size and color type.
GFX_EXPORT base::android::ScopedJavaLocalRef<jobject> CreateJavaBitmap(
int width,
int height,
- SkColorType color_type);
+ SkColorType color_type,
+ OomBehavior reaction = OomBehavior::kCrashOnOom);
// Converts |skbitmap| to a Java-backed bitmap (android.graphics.Bitmap).
// Note: |skbitmap| is assumed to be non-null, non-empty and one of RGBA_8888 or
// RGB_565 formats.
GFX_EXPORT base::android::ScopedJavaLocalRef<jobject> ConvertToJavaBitmap(
- const SkBitmap* skbitmap);
+ const SkBitmap* skbitmap,
+ OomBehavior reaction = OomBehavior::kCrashOnOom);
// Converts |bitmap| to an SkBitmap of the same size and format.
// Note: |jbitmap| is assumed to be non-null, non-empty and of format RGBA_8888.
diff --git a/chromium/ui/gfx/animation/animation_settings_provider_linux.cc b/chromium/ui/gfx/animation/animation_settings_provider_linux.cc
index a2e135974d3..e4d4c6c2b67 100644
--- a/chromium/ui/gfx/animation/animation_settings_provider_linux.cc
+++ b/chromium/ui/gfx/animation/animation_settings_provider_linux.cc
@@ -4,7 +4,7 @@
#include "ui/gfx/animation/animation_settings_provider_linux.h"
-#include "base/logging.h"
+#include "base/check_op.h"
namespace gfx {
diff --git a/chromium/ui/gfx/animation/multi_animation.cc b/chromium/ui/gfx/animation/multi_animation.cc
index 0a146fafa47..ec00449a724 100644
--- a/chromium/ui/gfx/animation/multi_animation.cc
+++ b/chromium/ui/gfx/animation/multi_animation.cc
@@ -6,7 +6,8 @@
#include <numeric>
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "ui/gfx/animation/animation_delegate.h"
namespace gfx {
diff --git a/chromium/ui/gfx/animation/tween.cc b/chromium/ui/gfx/animation/tween.cc
index c3ce04dedfc..d53879fb14c 100644
--- a/chromium/ui/gfx/animation/tween.cc
+++ b/chromium/ui/gfx/animation/tween.cc
@@ -9,7 +9,8 @@
#include <algorithm>
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/time/time.h"
#include "build/build_config.h"
diff --git a/chromium/ui/gfx/bidi_line_iterator.cc b/chromium/ui/gfx/bidi_line_iterator.cc
index f37c4f61ef4..976d33ff16d 100644
--- a/chromium/ui/gfx/bidi_line_iterator.cc
+++ b/chromium/ui/gfx/bidi_line_iterator.cc
@@ -4,7 +4,8 @@
#include "ui/gfx/bidi_line_iterator.h"
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
namespace ui {
namespace gfx {
@@ -15,13 +16,10 @@ UBiDiLevel GetParagraphLevelForDirection(base::i18n::TextDirection direction) {
switch (direction) {
case base::i18n::UNKNOWN_DIRECTION:
return UBIDI_DEFAULT_LTR;
- break;
case base::i18n::RIGHT_TO_LEFT:
return 1; // Highest RTL level.
- break;
case base::i18n::LEFT_TO_RIGHT:
return 0; // Highest LTR level.
- break;
default:
NOTREACHED();
return 0;
diff --git a/chromium/ui/gfx/blit.cc b/chromium/ui/gfx/blit.cc
index 5626206987e..d7d74a5e52f 100644
--- a/chromium/ui/gfx/blit.cc
+++ b/chromium/ui/gfx/blit.cc
@@ -6,7 +6,7 @@
#include <stddef.h>
-#include "base/logging.h"
+#include "base/check.h"
#include "build/build_config.h"
#include "skia/ext/platform_canvas.h"
#include "third_party/skia/include/core/SkPixmap.h"
diff --git a/chromium/ui/gfx/buffer_format_util.cc b/chromium/ui/gfx/buffer_format_util.cc
index b530a6bb8fa..85d13030ad4 100644
--- a/chromium/ui/gfx/buffer_format_util.cc
+++ b/chromium/ui/gfx/buffer_format_util.cc
@@ -4,7 +4,8 @@
#include "ui/gfx/buffer_format_util.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/numerics/safe_math.h"
#include "base/stl_util.h"
diff --git a/chromium/ui/gfx/canvas.cc b/chromium/ui/gfx/canvas.cc
index 6c5bb46784e..303aeca726f 100644
--- a/chromium/ui/gfx/canvas.cc
+++ b/chromium/ui/gfx/canvas.cc
@@ -98,34 +98,6 @@ int Canvas::DefaultCanvasTextAlignment() {
return base::i18n::IsRTL() ? TEXT_ALIGN_RIGHT : TEXT_ALIGN_LEFT;
}
-void Canvas::DrawDashedRect(const RectF& inrect, SkColor color) {
- if (inrect.IsEmpty())
- return;
- RectF rect = inrect;
-
- cc::PaintFlags flags;
- flags.setColor(color);
- SkScalar intervals[] = {1.f, 1.f};
- flags.setStrokeWidth(1.f);
- flags.setStyle(cc::PaintFlags::kStroke_Style);
- rect.Inset(gfx::InsetsF(0.5f));
-
- flags.setPathEffect(SkDashPathEffect::Make(intervals, 2, 0));
-
- // Top-left to top-right.
- canvas_->drawLine(rect.x() - 0.5f, rect.y(), rect.right() + 0.5f, rect.y(),
- flags);
- // Top-left to bottom-left.
- canvas_->drawLine(rect.right() + 0.5f, rect.bottom(), rect.x() - 0.5f,
- rect.bottom(), flags);
- // Bottom-right to bottom-left.
- canvas_->drawLine(rect.x(), rect.y() - 0.5f, rect.x(), rect.bottom() + 0.5f,
- flags);
- // Bottom-right to top-right.
- canvas_->drawLine(rect.right(), rect.bottom() + 0.5f, rect.right(),
- rect.y() - 0.5f, flags);
-}
-
float Canvas::UndoDeviceScaleFactor() {
SkScalar scale_factor = 1.0f / image_scale_;
canvas_->scale(scale_factor, scale_factor);
@@ -309,14 +281,6 @@ void Canvas::DrawPath(const SkPath& path, const cc::PaintFlags& flags) {
canvas_->drawPath(path, flags);
}
-void Canvas::DrawFocusRect(const Rect& rect) {
- DrawFocusRect(RectF(rect));
-}
-
-void Canvas::DrawFocusRect(const RectF& rect) {
- DrawDashedRect(rect, SK_ColorGRAY);
-}
-
void Canvas::DrawSolidFocusRect(RectF rect, SkColor color, int thickness) {
cc::PaintFlags flags;
flags.setColor(color);
diff --git a/chromium/ui/gfx/canvas.h b/chromium/ui/gfx/canvas.h
index 16ac9b350e6..abad2e6ce7b 100644
--- a/chromium/ui/gfx/canvas.h
+++ b/chromium/ui/gfx/canvas.h
@@ -151,9 +151,6 @@ class GFX_EXPORT Canvas {
// Canvas::TEXT_ALIGN_RIGHT.
static int DefaultCanvasTextAlignment();
- // Draws a dashed rectangle of the specified color.
- void DrawDashedRect(const RectF& rect, SkColor color);
-
// Unscales by the image scale factor (aka device scale factor), and returns
// that factor. This is useful when callers want to draw directly in the
// native scale.
@@ -381,14 +378,6 @@ class GFX_EXPORT Canvas {
const Rect& display_rect,
int flags);
- // Draws a dotted gray rectangle used for focus purposes.
- // DEPRECATED in favor of the RectF version below.
- // TODO(funkysidd): Remove this (http://crbug.com/553726)
- void DrawFocusRect(const Rect& rect);
-
- // Draws a dotted gray rectangle used for focus purposes.
- void DrawFocusRect(const RectF& rect);
-
// Draws a |rect| in the specified region with the specified |color|. The
// width of the stroke is |thickness| dip, but the actual pixel width will be
// floored to ensure an integral value.
diff --git a/chromium/ui/gfx/codec/jpeg_codec.cc b/chromium/ui/gfx/codec/jpeg_codec.cc
index b03dc8f9368..ea7c0dcab69 100644
--- a/chromium/ui/gfx/codec/jpeg_codec.cc
+++ b/chromium/ui/gfx/codec/jpeg_codec.cc
@@ -8,7 +8,7 @@
#include <memory>
-#include "base/logging.h"
+#include "base/notreached.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkColorPriv.h"
#include "ui/gfx/codec/vector_wstream.h"
diff --git a/chromium/ui/gfx/color_analysis.cc b/chromium/ui/gfx/color_analysis.cc
index 5ecc56691b4..5033a77232e 100644
--- a/chromium/ui/gfx/color_analysis.cc
+++ b/chromium/ui/gfx/color_analysis.cc
@@ -17,7 +17,8 @@
#include "base/bind.h"
#include "base/callback.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/numerics/ranges.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkUnPreMultiply.h"
diff --git a/chromium/ui/gfx/color_analysis.h b/chromium/ui/gfx/color_analysis.h
index 9fbe174260b..92c185fa43c 100644
--- a/chromium/ui/gfx/color_analysis.h
+++ b/chromium/ui/gfx/color_analysis.h
@@ -7,6 +7,7 @@
#include <stdint.h>
+#include "base/callback_forward.h"
#include "base/compiler_specific.h"
#include "base/memory/ref_counted.h"
#include "base/memory/ref_counted_memory.h"
diff --git a/chromium/ui/gfx/color_space.cc b/chromium/ui/gfx/color_space.cc
index d5f8e3daa20..dab693d3d0a 100644
--- a/chromium/ui/gfx/color_space.cc
+++ b/chromium/ui/gfx/color_space.cc
@@ -11,6 +11,7 @@
#include "base/atomic_sequence_num.h"
#include "base/lazy_instance.h"
+#include "base/logging.h"
#include "base/synchronization/lock.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/core/SkData.h"
diff --git a/chromium/ui/gfx/color_space.h b/chromium/ui/gfx/color_space.h
index 43be18e6f6f..6c123f494e8 100644
--- a/chromium/ui/gfx/color_space.h
+++ b/chromium/ui/gfx/color_space.h
@@ -285,7 +285,8 @@ class COLOR_SPACE_EXPORT ColorSpace {
const _GLcolorSpace* AsGLColorSpace() const;
// For YUV color spaces, return the closest SkYUVColorSpace.
- // Returns true if a close match is found.
+ // Returns true if a close match is found. Otherwise, leaves *out unchanged
+ // and returns false.
bool ToSkYUVColorSpace(SkYUVColorSpace* out) const;
void GetPrimaryMatrix(skcms_Matrix3x3* to_XYZD50) const;
diff --git a/chromium/ui/gfx/color_space_unittest.cc b/chromium/ui/gfx/color_space_unittest.cc
index e5a7f9d4e83..b73880861bc 100644
--- a/chromium/ui/gfx/color_space_unittest.cc
+++ b/chromium/ui/gfx/color_space_unittest.cc
@@ -6,7 +6,6 @@
#include <cmath>
#include <tuple>
-#include "base/logging.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/skia_color_space_util.h"
diff --git a/chromium/ui/gfx/color_utils.cc b/chromium/ui/gfx/color_utils.cc
index eb757cd076d..92752de2378 100644
--- a/chromium/ui/gfx/color_utils.cc
+++ b/chromium/ui/gfx/color_utils.cc
@@ -9,7 +9,8 @@
#include <algorithm>
#include <cmath>
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
diff --git a/chromium/ui/gfx/font_list_impl.cc b/chromium/ui/gfx/font_list_impl.cc
index a3b7de3dac6..d805ee18b28 100644
--- a/chromium/ui/gfx/font_list_impl.cc
+++ b/chromium/ui/gfx/font_list_impl.cc
@@ -8,7 +8,7 @@
#include <algorithm>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "ui/gfx/font_list.h"
diff --git a/chromium/ui/gfx/font_render_params.cc b/chromium/ui/gfx/font_render_params.cc
index dbaa9b5f0d8..3a03ffcc9f6 100644
--- a/chromium/ui/gfx/font_render_params.cc
+++ b/chromium/ui/gfx/font_render_params.cc
@@ -4,7 +4,7 @@
#include "ui/gfx/font_render_params.h"
-#include "base/logging.h"
+#include "base/notreached.h"
namespace gfx {
diff --git a/chromium/ui/gfx/font_render_params.h b/chromium/ui/gfx/font_render_params.h
index 29d81b9fb8b..6564b08a70a 100644
--- a/chromium/ui/gfx/font_render_params.h
+++ b/chromium/ui/gfx/font_render_params.h
@@ -117,11 +117,11 @@ GFX_EXPORT FontRenderParams GetFontRenderParams(
GFX_EXPORT void ClearFontRenderParamsCacheForTest();
#endif
-#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID) || \
- defined(OS_FUCHSIA)
// Gets the device scale factor to query the FontRenderParams.
GFX_EXPORT float GetFontRenderParamsDeviceScaleFactor();
+#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_ANDROID) || \
+ defined(OS_FUCHSIA)
// Sets the device scale factor for FontRenderParams to decide
// if it should enable subpixel positioning.
GFX_EXPORT void SetFontRenderParamsDeviceScaleFactor(
diff --git a/chromium/ui/gfx/font_render_params_linux_unittest.cc b/chromium/ui/gfx/font_render_params_linux_unittest.cc
index fc210b2e3fb..b3236a323cc 100644
--- a/chromium/ui/gfx/font_render_params_linux_unittest.cc
+++ b/chromium/ui/gfx/font_render_params_linux_unittest.cc
@@ -6,10 +6,11 @@
#include <fontconfig/fontconfig.h>
+#include "base/check_op.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
-#include "base/logging.h"
#include "base/macros.h"
+#include "base/notreached.h"
#include "base/strings/stringprintf.h"
#include "base/test/fontconfig_util_linux.h"
#include "build/build_config.h"
diff --git a/chromium/ui/gfx/font_render_params_mac.cc b/chromium/ui/gfx/font_render_params_mac.cc
index 80b46daadfc..071e7868ca4 100644
--- a/chromium/ui/gfx/font_render_params_mac.cc
+++ b/chromium/ui/gfx/font_render_params_mac.cc
@@ -4,9 +4,9 @@
#include "ui/gfx/font_render_params.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/no_destructor.h"
+#include "base/notreached.h"
namespace gfx {
@@ -36,4 +36,8 @@ FontRenderParams GetFontRenderParams(const FontRenderParamsQuery& query,
return *params;
}
+float GetFontRenderParamsDeviceScaleFactor() {
+ return 1.0;
+}
+
} // namespace gfx
diff --git a/chromium/ui/gfx/font_render_params_skia.cc b/chromium/ui/gfx/font_render_params_skia.cc
index 4657d6a5e42..01c90244881 100644
--- a/chromium/ui/gfx/font_render_params_skia.cc
+++ b/chromium/ui/gfx/font_render_params_skia.cc
@@ -4,9 +4,9 @@
#include "ui/gfx/font_render_params.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/no_destructor.h"
+#include "base/notreached.h"
namespace gfx {
diff --git a/chromium/ui/gfx/gdi_util.cc b/chromium/ui/gfx/gdi_util.cc
index e3156958737..32ef65db985 100644
--- a/chromium/ui/gfx/gdi_util.cc
+++ b/chromium/ui/gfx/gdi_util.cc
@@ -9,7 +9,6 @@
#include <algorithm>
#include <memory>
-#include "base/logging.h"
#include "skia/ext/skia_utils_win.h"
namespace gfx {
diff --git a/chromium/ui/gfx/geometry/box_f.cc b/chromium/ui/gfx/geometry/box_f.cc
index 674bb509c88..d942b70eb5f 100644
--- a/chromium/ui/gfx/geometry/box_f.cc
+++ b/chromium/ui/gfx/geometry/box_f.cc
@@ -6,7 +6,7 @@
#include <algorithm>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/strings/stringprintf.h"
namespace gfx {
diff --git a/chromium/ui/gfx/geometry/cubic_bezier.cc b/chromium/ui/gfx/geometry/cubic_bezier.cc
index 9cacf01c6c8..0e78b1e967f 100644
--- a/chromium/ui/gfx/geometry/cubic_bezier.cc
+++ b/chromium/ui/gfx/geometry/cubic_bezier.cc
@@ -7,7 +7,7 @@
#include <algorithm>
#include <cmath>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/numerics/ranges.h"
namespace gfx {
diff --git a/chromium/ui/gfx/geometry/matrix3_f.cc b/chromium/ui/gfx/geometry/matrix3_f.cc
index ab0ea9f2184..afacbeabe17 100644
--- a/chromium/ui/gfx/geometry/matrix3_f.cc
+++ b/chromium/ui/gfx/geometry/matrix3_f.cc
@@ -4,6 +4,8 @@
#include "ui/gfx/geometry/matrix3_f.h"
+#include <string.h>
+
#include <algorithm>
#include <cmath>
#include <limits>
diff --git a/chromium/ui/gfx/geometry/mojom/BUILD.gn b/chromium/ui/gfx/geometry/mojom/BUILD.gn
index 4731f084d1e..5bb37818fc2 100644
--- a/chromium/ui/gfx/geometry/mojom/BUILD.gn
+++ b/chromium/ui/gfx/geometry/mojom/BUILD.gn
@@ -11,6 +11,72 @@ mojom("mojom") {
sources = [ "geometry.mojom" ]
check_includes_blink = false
+
+ shared_cpp_typemap = {
+ types = [
+ {
+ mojom = "gfx.mojom.Point"
+ cpp = "::gfx::Point"
+ },
+ {
+ mojom = "gfx.mojom.PointF"
+ cpp = "::gfx::PointF"
+ },
+ {
+ mojom = "gfx.mojom.Point3F"
+ cpp = "::gfx::Point3F"
+ },
+ {
+ mojom = "gfx.mojom.Size"
+ cpp = "::gfx::Size"
+ },
+ {
+ mojom = "gfx.mojom.SizeF"
+ cpp = "::gfx::SizeF"
+ },
+ {
+ mojom = "gfx.mojom.Rect"
+ cpp = "::gfx::Rect"
+ },
+ {
+ mojom = "gfx.mojom.RectF"
+ cpp = "::gfx::RectF"
+ },
+ {
+ mojom = "gfx.mojom.Insets"
+ cpp = "::gfx::Insets"
+ },
+ {
+ mojom = "gfx.mojom.InsetsF"
+ cpp = "::gfx::InsetsF"
+ },
+ {
+ mojom = "gfx.mojom.Quaternion"
+ cpp = "::gfx::Quaternion"
+ },
+ {
+ mojom = "gfx.mojom.Vector2d"
+ cpp = "::gfx::Vector2d"
+ },
+ {
+ mojom = "gfx.mojom.Vector2dF"
+ cpp = "::gfx::Vector2dF"
+ },
+ {
+ mojom = "gfx.mojom.Vector3dF"
+ cpp = "::gfx::Vector3dF"
+ },
+ {
+ mojom = "gfx.mojom.ScrollOffset"
+ cpp = "::gfx::ScrollOffset"
+ },
+ ]
+
+ traits_headers = [ "geometry_mojom_traits.h" ]
+ traits_public_deps = [ ":mojom_traits" ]
+ }
+ cpp_typemaps = [ shared_cpp_typemap ]
+ blink_cpp_typemaps = [ shared_cpp_typemap ]
}
mojom("test_interfaces") {
@@ -37,7 +103,7 @@ source_set("unit_test") {
source_set("mojom_traits") {
sources = [ "geometry_mojom_traits.h" ]
public_deps = [
- ":mojom_shared_cpp_sources",
+ ":mojom_shared",
"//ui/gfx/geometry",
]
}
diff --git a/chromium/ui/gfx/geometry/mojom/geometry.typemap b/chromium/ui/gfx/geometry/mojom/geometry.typemap
deleted file mode 100644
index 7897c9205f4..00000000000
--- a/chromium/ui/gfx/geometry/mojom/geometry.typemap
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-mojom = "//ui/gfx/geometry/mojom/geometry.mojom"
-public_headers = [
- "//ui/gfx/geometry/point.h",
- "//ui/gfx/geometry/point_f.h",
- "//ui/gfx/geometry/point3_f.h",
- "//ui/gfx/geometry/size.h",
- "//ui/gfx/geometry/rect.h",
- "//ui/gfx/geometry/rect_f.h",
- "//ui/gfx/geometry/safe_integer_conversions.h",
- "//ui/gfx/geometry/scroll_offset.h",
- "//ui/gfx/geometry/insets.h",
- "//ui/gfx/geometry/quaternion.h",
- "//ui/gfx/geometry/vector2d.h",
- "//ui/gfx/geometry/vector2d_f.h",
- "//ui/gfx/geometry/vector3d_f.h",
-]
-traits_headers = [ "//ui/gfx/geometry/mojom/geometry_mojom_traits.h" ]
-public_deps = [
- "//ui/gfx/geometry/mojom:mojom_traits",
-]
-type_mappings = [
- "gfx.mojom.Point=::gfx::Point",
- "gfx.mojom.PointF=::gfx::PointF",
- "gfx.mojom.Point3F=::gfx::Point3F",
- "gfx.mojom.Size=::gfx::Size",
- "gfx.mojom.SizeF=::gfx::SizeF",
- "gfx.mojom.Rect=::gfx::Rect",
- "gfx.mojom.RectF=::gfx::RectF",
- "gfx.mojom.Insets=::gfx::Insets",
- "gfx.mojom.InsetsF=::gfx::InsetsF",
- "gfx.mojom.Quaternion=::gfx::Quaternion",
- "gfx.mojom.Vector2d=::gfx::Vector2d",
- "gfx.mojom.Vector2dF=::gfx::Vector2dF",
- "gfx.mojom.Vector3dF=::gfx::Vector3dF",
- "gfx.mojom.ScrollOffset=::gfx::ScrollOffset",
-]
diff --git a/chromium/ui/gfx/geometry/rect.cc b/chromium/ui/gfx/geometry/rect.cc
index 635e1695268..e58746c83e9 100644
--- a/chromium/ui/gfx/geometry/rect.cc
+++ b/chromium/ui/gfx/geometry/rect.cc
@@ -14,7 +14,7 @@
#include <ApplicationServices/ApplicationServices.h>
#endif
-#include "base/logging.h"
+#include "base/check.h"
#include "base/numerics/clamped_math.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
diff --git a/chromium/ui/gfx/geometry/rect_conversions.cc b/chromium/ui/gfx/geometry/rect_conversions.cc
index 8fb882cd622..4958ef3160b 100644
--- a/chromium/ui/gfx/geometry/rect_conversions.cc
+++ b/chromium/ui/gfx/geometry/rect_conversions.cc
@@ -7,7 +7,7 @@
#include <algorithm>
#include <cmath>
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/gfx/geometry/safe_integer_conversions.h"
namespace gfx {
diff --git a/chromium/ui/gfx/geometry/rect_f.cc b/chromium/ui/gfx/geometry/rect_f.cc
index 9159bb19a2a..129e89fad80 100644
--- a/chromium/ui/gfx/geometry/rect_f.cc
+++ b/chromium/ui/gfx/geometry/rect_f.cc
@@ -7,7 +7,7 @@
#include <algorithm>
#include <limits>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/strings/stringprintf.h"
#include "build/build_config.h"
#include "ui/gfx/geometry/insets_f.h"
diff --git a/chromium/ui/gfx/gpu_fence_handle.cc b/chromium/ui/gfx/gpu_fence_handle.cc
index 3df7647fcb2..f8cce06cd0c 100644
--- a/chromium/ui/gfx/gpu_fence_handle.cc
+++ b/chromium/ui/gfx/gpu_fence_handle.cc
@@ -4,7 +4,7 @@
#include "ui/gfx/gpu_fence_handle.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#if defined(OS_POSIX)
#include <unistd.h>
diff --git a/chromium/ui/gfx/harfbuzz_font_skia.cc b/chromium/ui/gfx/harfbuzz_font_skia.cc
index e0bcaa629ff..6ee856c11ba 100644
--- a/chromium/ui/gfx/harfbuzz_font_skia.cc
+++ b/chromium/ui/gfx/harfbuzz_font_skia.cc
@@ -10,9 +10,9 @@
#include <limits>
#include <map>
+#include "base/check_op.h"
#include "base/containers/mru_cache.h"
#include "base/lazy_instance.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/no_destructor.h"
#include "build/build_config.h"
diff --git a/chromium/ui/gfx/icc_profile.cc b/chromium/ui/gfx/icc_profile.cc
index 9fb66a9a243..94f0e7c8961 100644
--- a/chromium/ui/gfx/icc_profile.cc
+++ b/chromium/ui/gfx/icc_profile.cc
@@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/containers/mru_cache.h"
#include "base/lazy_instance.h"
+#include "base/logging.h"
#include "base/synchronization/lock.h"
#include "third_party/skia/include/core/SkColorSpace.h"
#include "third_party/skia/include/third_party/skcms/skcms.h"
diff --git a/chromium/ui/gfx/icc_profile_unittest.cc b/chromium/ui/gfx/icc_profile_unittest.cc
index f5b83636d67..11b925b9900 100644
--- a/chromium/ui/gfx/icc_profile_unittest.cc
+++ b/chromium/ui/gfx/icc_profile_unittest.cc
@@ -3,7 +3,6 @@
// found in the LICENSE file.
#include "ui/gfx/icc_profile.h"
-#include "base/logging.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/color_space.h"
#include "ui/gfx/skia_color_space_util.h"
diff --git a/chromium/ui/gfx/icon_util.cc b/chromium/ui/gfx/icon_util.cc
index 800a2bb0120..b9681af099f 100644
--- a/chromium/ui/gfx/icon_util.cc
+++ b/chromium/ui/gfx/icon_util.cc
@@ -4,9 +4,10 @@
#include "ui/gfx/icon_util.h"
+#include "base/check_op.h"
#include "base/files/file_util.h"
#include "base/files/important_file_writer.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
#include "base/trace_event/trace_event.h"
#include "base/win/resource_util.h"
@@ -523,18 +524,15 @@ bool IconUtil::CreateIconFileFromImageFamily(
DCHECK_EQ(offset, buffer_size);
if (write_type == NORMAL_WRITE) {
- auto saved_size =
- base::WriteFile(icon_path, reinterpret_cast<const char*>(&buffer[0]),
- static_cast<int>(buffer.size()));
- if (saved_size == static_cast<int>(buffer.size()))
+ if (base::WriteFile(icon_path, buffer))
return true;
bool delete_success = base::DeleteFile(icon_path, false);
DCHECK(delete_success);
return false;
- } else {
- std::string data(buffer.begin(), buffer.end());
- return base::ImportantFileWriter::WriteFileAtomically(icon_path, data);
}
+
+ std::string data(buffer.begin(), buffer.end());
+ return base::ImportantFileWriter::WriteFileAtomically(icon_path, data);
}
bool IconUtil::PixelsHaveAlpha(const uint32_t* pixels, size_t num_pixels) {
diff --git a/chromium/ui/gfx/image/canvas_image_source.cc b/chromium/ui/gfx/image/canvas_image_source.cc
index a5c81775b46..a1e3e9b32f1 100644
--- a/chromium/ui/gfx/image/canvas_image_source.cc
+++ b/chromium/ui/gfx/image/canvas_image_source.cc
@@ -4,7 +4,7 @@
#include "ui/gfx/image/canvas_image_source.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "cc/paint/display_item_list.h"
#include "cc/paint/record_paint_canvas.h"
#include "ui/gfx/canvas.h"
diff --git a/chromium/ui/gfx/image/image.cc b/chromium/ui/gfx/image/image.cc
index a4dfee35a23..363b940a676 100644
--- a/chromium/ui/gfx/image/image.cc
+++ b/chromium/ui/gfx/image/image.cc
@@ -8,9 +8,10 @@
#include <utility>
#include <vector>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
+#include "base/notreached.h"
#include "build/build_config.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/gfx/geometry/size.h"
diff --git a/chromium/ui/gfx/image/image_ios_unittest.mm b/chromium/ui/gfx/image/image_ios_unittest.mm
index 2ad17170c25..4df71ce62e3 100644
--- a/chromium/ui/gfx/image/image_ios_unittest.mm
+++ b/chromium/ui/gfx/image/image_ios_unittest.mm
@@ -6,7 +6,6 @@
#include <stddef.h>
#import <UIKit/UIKit.h>
-#include "base/logging.h"
#include "base/mac/scoped_cftyperef.h"
#include "base/stl_util.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/chromium/ui/gfx/image/image_mac_unittest.mm b/chromium/ui/gfx/image/image_mac_unittest.mm
index 4b782f032ef..95aa6134921 100644
--- a/chromium/ui/gfx/image/image_mac_unittest.mm
+++ b/chromium/ui/gfx/image/image_mac_unittest.mm
@@ -5,7 +5,6 @@
#include <Cocoa/Cocoa.h>
#include <stddef.h>
-#include "base/logging.h"
#include "base/mac/scoped_nsobject.h"
#include "base/macros.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/chromium/ui/gfx/image/image_skia.cc b/chromium/ui/gfx/image/image_skia.cc
index 58aee69d227..06ad22fc1d7 100644
--- a/chromium/ui/gfx/image/image_skia.cc
+++ b/chromium/ui/gfx/image/image_skia.cc
@@ -11,8 +11,8 @@
#include <limits>
#include <memory>
+#include "base/check_op.h"
#include "base/command_line.h"
-#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/no_destructor.h"
#include "base/sequence_checker.h"
diff --git a/chromium/ui/gfx/image/image_skia_operations.cc b/chromium/ui/gfx/image/image_skia_operations.cc
index 5ed1336ce53..0de914b9d8f 100644
--- a/chromium/ui/gfx/image/image_skia_operations.cc
+++ b/chromium/ui/gfx/image/image_skia_operations.cc
@@ -15,6 +15,7 @@
#include "third_party/skia/include/core/SkClipOp.h"
#include "third_party/skia/include/core/SkDrawLooper.h"
#include "ui/gfx/canvas.h"
+#include "ui/gfx/color_palette.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_conversions.h"
@@ -47,7 +48,7 @@ gfx::Rect DIPToPixelBounds(gfx::Rect dip_bounds, float scale) {
ImageSkiaRep GetErrorImageRep(float scale, const gfx::Size& pixel_size) {
SkBitmap bitmap;
bitmap.allocN32Pixels(pixel_size.width(), pixel_size.height());
- bitmap.eraseColor(SK_ColorRED);
+ bitmap.eraseColor(kPlaceholderColor);
return gfx::ImageSkiaRep(bitmap, scale);
}
diff --git a/chromium/ui/gfx/image/image_skia_rep_default.cc b/chromium/ui/gfx/image/image_skia_rep_default.cc
index bee88848ac5..8819dd4e13a 100644
--- a/chromium/ui/gfx/image/image_skia_rep_default.cc
+++ b/chromium/ui/gfx/image/image_skia_rep_default.cc
@@ -4,11 +4,13 @@
#include "ui/gfx/image/image_skia_rep_default.h"
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "cc/paint/display_item_list.h"
#include "cc/paint/record_paint_canvas.h"
#include "cc/paint/skia_paint_canvas.h"
#include "third_party/skia/include/core/SkCanvas.h"
+#include "ui/gfx/color_palette.h"
namespace gfx {
@@ -19,7 +21,7 @@ ImageSkiaRep::ImageSkiaRep(const gfx::Size& size, float scale)
: type_(ImageRepType::kImageTypeBitmap), scale_(scale) {
bitmap_.allocN32Pixels(static_cast<int>(size.width() * this->scale()),
static_cast<int>(size.height() * this->scale()));
- bitmap_.eraseColor(SK_ColorRED);
+ bitmap_.eraseColor(kPlaceholderColor);
bitmap_.setImmutable();
pixel_size_.SetSize(bitmap_.width(), bitmap_.height());
paint_image_ = cc::PaintImage::CreateFromBitmap(bitmap_);
diff --git a/chromium/ui/gfx/image/image_skia_rep_ios.cc b/chromium/ui/gfx/image/image_skia_rep_ios.cc
index 5e389f5c75d..c28b5edfabb 100644
--- a/chromium/ui/gfx/image/image_skia_rep_ios.cc
+++ b/chromium/ui/gfx/image/image_skia_rep_ios.cc
@@ -4,7 +4,7 @@
#include "ui/gfx/image/image_skia_rep_ios.h"
-#include "base/logging.h"
+#include "ui/gfx/color_palette.h"
namespace gfx {
@@ -13,7 +13,7 @@ ImageSkiaRep::ImageSkiaRep() : scale_(0.0f) {}
ImageSkiaRep::ImageSkiaRep(const gfx::Size& size, float scale) : scale_(scale) {
bitmap_.allocN32Pixels(static_cast<int>(size.width() * this->scale()),
static_cast<int>(size.height() * this->scale()));
- bitmap_.eraseColor(SK_ColorRED);
+ bitmap_.eraseColor(kPlaceholderColor);
bitmap_.setImmutable();
pixel_size_.SetSize(bitmap_.width(), bitmap_.height());
}
diff --git a/chromium/ui/gfx/image/image_skia_unittest.cc b/chromium/ui/gfx/image/image_skia_unittest.cc
index c21399626cd..854a0638726 100644
--- a/chromium/ui/gfx/image/image_skia_unittest.cc
+++ b/chromium/ui/gfx/image/image_skia_unittest.cc
@@ -6,8 +6,8 @@
#include <stddef.h>
+#include "base/check_op.h"
#include "base/command_line.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/threading/simple_thread.h"
diff --git a/chromium/ui/gfx/image/image_skia_util_ios.mm b/chromium/ui/gfx/image/image_skia_util_ios.mm
index e7ac3b490e5..4ecbfdcda32 100644
--- a/chromium/ui/gfx/image/image_skia_util_ios.mm
+++ b/chromium/ui/gfx/image/image_skia_util_ios.mm
@@ -6,7 +6,6 @@
#import <UIKit/UIKit.h>
-#include "base/logging.h"
#include "base/mac/scoped_cftyperef.h"
#include "skia/ext/skia_utils_ios.h"
#include "third_party/skia/include/core/SkBitmap.h"
diff --git a/chromium/ui/gfx/image/image_util_ios.mm b/chromium/ui/gfx/image/image_util_ios.mm
index 86d5b9e5629..81ac792c075 100644
--- a/chromium/ui/gfx/image/image_util_ios.mm
+++ b/chromium/ui/gfx/image/image_util_ios.mm
@@ -8,7 +8,6 @@
#include "ui/gfx/image/image_util.h"
#include "ui/gfx/image/resize_image_dimensions.h"
-#include "base/logging.h"
namespace {
// Copied from GTMUIImage+Resize in //third_party/google_toolbox_for_mac to
diff --git a/chromium/ui/gfx/image/mojom/BUILD.gn b/chromium/ui/gfx/image/mojom/BUILD.gn
index 3e4b3656f1f..d4536428e5a 100644
--- a/chromium/ui/gfx/image/mojom/BUILD.gn
+++ b/chromium/ui/gfx/image/mojom/BUILD.gn
@@ -8,6 +8,25 @@ mojom("mojom") {
sources = [ "image.mojom" ]
public_deps = [ "//skia/public/mojom" ]
+
+ cpp_typemaps = [
+ {
+ types = [
+ {
+ mojom = "gfx.mojom.ImageSkia"
+ cpp = "::gfx::ImageSkia"
+ nullable_is_same_type = true
+ },
+ {
+ mojom = "gfx.mojom.ImageSkiaRep"
+ cpp = "::gfx::ImageSkiaRep"
+ nullable_is_same_type = true
+ },
+ ]
+ traits_headers = [ "image_skia_mojom_traits.h" ]
+ traits_public_deps = [ ":mojom_traits" ]
+ },
+ ]
}
source_set("mojom_traits") {
diff --git a/chromium/ui/gfx/image/mojom/image.typemap b/chromium/ui/gfx/image/mojom/image.typemap
deleted file mode 100644
index 276aa81daea..00000000000
--- a/chromium/ui/gfx/image/mojom/image.typemap
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2017 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.
-
-mojom = "//ui/gfx/image/mojom/image.mojom"
-public_headers = [
- "//third_party/skia/include/core/SkBitmap.h",
- "//ui/gfx/image/image_skia_rep.h",
- "//ui/gfx/image/image_skia.h",
-]
-traits_headers = [ "//ui/gfx/image/mojom/image_skia_mojom_traits.h" ]
-public_deps = [
- "//ui/gfx/image/mojom:mojom_traits",
-]
-type_mappings = [
- "gfx.mojom.ImageSkia=::gfx::ImageSkia[nullable_is_same_type]",
- "gfx.mojom.ImageSkiaRep=::gfx::ImageSkiaRep[nullable_is_same_type]",
-]
diff --git a/chromium/ui/gfx/image/mojom/image_skia_mojom_traits.cc b/chromium/ui/gfx/image/mojom/image_skia_mojom_traits.cc
index 87f9e1c396b..c45c063870b 100644
--- a/chromium/ui/gfx/image/mojom/image_skia_mojom_traits.cc
+++ b/chromium/ui/gfx/image/mojom/image_skia_mojom_traits.cc
@@ -6,7 +6,7 @@
#include <string.h>
-#include "base/logging.h"
+#include "base/check_op.h"
namespace mojo {
diff --git a/chromium/ui/gfx/interpolated_transform.cc b/chromium/ui/gfx/interpolated_transform.cc
index 057ff54eb24..fcbbdff9081 100644
--- a/chromium/ui/gfx/interpolated_transform.cc
+++ b/chromium/ui/gfx/interpolated_transform.cc
@@ -6,8 +6,7 @@
#include <cmath>
-
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/gfx/animation/tween.h"
#include "ui/gfx/geometry/safe_integer_conversions.h"
diff --git a/chromium/ui/gfx/ios/NSString+CrStringDrawing.mm b/chromium/ui/gfx/ios/NSString+CrStringDrawing.mm
index f7a684d51a1..f482ea13b72 100644
--- a/chromium/ui/gfx/ios/NSString+CrStringDrawing.mm
+++ b/chromium/ui/gfx/ios/NSString+CrStringDrawing.mm
@@ -4,9 +4,11 @@
#import "ui/gfx/ios/NSString+CrStringDrawing.h"
+#include <ostream>
+
#include <stddef.h>
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/gfx/ios/uikit_util.h"
@implementation NSString (CrStringDrawing)
diff --git a/chromium/ui/gfx/linux/BUILD.gn b/chromium/ui/gfx/linux/BUILD.gn
index 05833fcaf83..c54b85f70f3 100644
--- a/chromium/ui/gfx/linux/BUILD.gn
+++ b/chromium/ui/gfx/linux/BUILD.gn
@@ -47,7 +47,6 @@ source_set("gbm") {
if (use_x11) {
component("gpu_memory_buffer_support_x11") {
- configs += [ "//build/config/linux:x11" ]
sources = [
"gpu_memory_buffer_support_x11.cc",
"gpu_memory_buffer_support_x11.h",
diff --git a/chromium/ui/gfx/linux/client_native_pixmap_dmabuf.cc b/chromium/ui/gfx/linux/client_native_pixmap_dmabuf.cc
index 2ba91d10cb0..88c16776abd 100644
--- a/chromium/ui/gfx/linux/client_native_pixmap_dmabuf.cc
+++ b/chromium/ui/gfx/linux/client_native_pixmap_dmabuf.cc
@@ -187,6 +187,8 @@ ClientNativePixmapDmaBuf::ImportFromDmabuf(gfx::NativePixmapHandle handle,
for (size_t i = 0; i < handle.planes.size(); ++i) {
// Verify that the plane buffer has appropriate size.
+ const size_t plane_stride =
+ base::strict_cast<size_t>(handle.planes[i].stride);
size_t min_stride = 0;
size_t subsample_factor = SubsamplingFactorForBufferFormat(format, i);
base::CheckedNumeric<size_t> plane_height =
@@ -194,14 +196,20 @@ ClientNativePixmapDmaBuf::ImportFromDmabuf(gfx::NativePixmapHandle handle,
subsample_factor;
if (!gfx::RowSizeForBufferFormatChecked(size.width(), format, i,
&min_stride) ||
- handle.planes[i].stride < min_stride) {
+ plane_stride < min_stride) {
return nullptr;
}
base::CheckedNumeric<size_t> min_size =
- base::CheckedNumeric<size_t>(handle.planes[i].stride) * plane_height;
+ base::CheckedNumeric<size_t>(plane_stride) * plane_height;
if (!min_size.IsValid() || handle.planes[i].size < min_size.ValueOrDie())
return nullptr;
+ // The stride must be a valid integer in order to be consistent with the
+ // GpuMemoryBuffer::stride() API. Also, refer to http://crbug.com/1093644#c1
+ // for some comments on this check and others in this method.
+ if (!base::IsValueInRangeForNumericType<int>(plane_stride))
+ return nullptr;
+
const size_t map_size = base::checked_cast<size_t>(handle.planes[i].size);
plane_info[i].offset = handle.planes[i].offset;
plane_info[i].size = map_size;
diff --git a/chromium/ui/gfx/linux/drm_util_linux.cc b/chromium/ui/gfx/linux/drm_util_linux.cc
index 7858b8b30d9..7482722b128 100644
--- a/chromium/ui/gfx/linux/drm_util_linux.cc
+++ b/chromium/ui/gfx/linux/drm_util_linux.cc
@@ -6,7 +6,7 @@
#include <drm_fourcc.h>
-#include "base/logging.h"
+#include "base/notreached.h"
#ifndef DRM_FORMAT_INVALID
// TODO(mcasas): Remove when uprevving //third_party/libdrm.
diff --git a/chromium/ui/gfx/linux/drm_util_linux.h b/chromium/ui/gfx/linux/drm_util_linux.h
index 86ff2eb2061..25aa65f417f 100644
--- a/chromium/ui/gfx/linux/drm_util_linux.h
+++ b/chromium/ui/gfx/linux/drm_util_linux.h
@@ -5,6 +5,8 @@
#ifndef UI_GFX_LINUX_DRM_UTIL_LINUX_H_
#define UI_GFX_LINUX_DRM_UTIL_LINUX_H_
+#include <cstdint>
+
#include "ui/gfx/buffer_types.h"
namespace ui {
diff --git a/chromium/ui/gfx/linux/gbm_util.cc b/chromium/ui/gfx/linux/gbm_util.cc
index 2b4a134677e..cd9d13b55df 100644
--- a/chromium/ui/gfx/linux/gbm_util.cc
+++ b/chromium/ui/gfx/linux/gbm_util.cc
@@ -4,7 +4,7 @@
#include "ui/gfx/linux/gbm_util.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "ui/gfx/linux/gbm_defines.h"
namespace ui {
diff --git a/chromium/ui/gfx/linux/gbm_wrapper.cc b/chromium/ui/gfx/linux/gbm_wrapper.cc
index c17a31a696c..71f9ffc4128 100644
--- a/chromium/ui/gfx/linux/gbm_wrapper.cc
+++ b/chromium/ui/gfx/linux/gbm_wrapper.cc
@@ -8,6 +8,7 @@
#include <memory>
#include <utility>
+#include "base/logging.h"
#include "base/posix/eintr_wrapper.h"
#include "third_party/skia/include/core/SkSurface.h"
#include "ui/gfx/buffer_format_util.h"
diff --git a/chromium/ui/gfx/mojom/BUILD.gn b/chromium/ui/gfx/mojom/BUILD.gn
index f6fffd395f3..eec21020c9c 100644
--- a/chromium/ui/gfx/mojom/BUILD.gn
+++ b/chromium/ui/gfx/mojom/BUILD.gn
@@ -29,43 +29,185 @@ mojom("mojom") {
"//ui/gfx/geometry/mojom",
]
- buffer_types_shared_cpp_typemap = {
- types = [
- {
- mojom = "gfx.mojom.BufferFormat"
- cpp = "::gfx::BufferFormat"
- },
- {
- mojom = "gfx.mojom.BufferUsage"
- cpp = "::gfx::BufferUsage"
- },
- {
- mojom = "gfx.mojom.BufferUsageAndFormat"
- cpp = "::gfx::BufferUsageAndFormat"
- },
- {
- mojom = "gfx.mojom.GpuMemoryBufferHandle"
- cpp = "::gfx::GpuMemoryBufferHandle"
- move_only = true
- nullable_is_same_type = true
- },
- {
- mojom = "gfx.mojom.GpuMemoryBufferId"
- cpp = "::gfx::GpuMemoryBufferId"
- copyable_pass_by_value = true
- },
- {
- mojom = "gfx.mojom.GpuMemoryBufferType"
- cpp = "::gfx::GpuMemoryBufferType"
- },
- ]
+ shared_cpp_typemaps = [
+ {
+ types = [
+ {
+ mojom = "gfx.mojom.BufferFormat"
+ cpp = "::gfx::BufferFormat"
+ },
+ {
+ mojom = "gfx.mojom.BufferUsage"
+ cpp = "::gfx::BufferUsage"
+ },
+ {
+ mojom = "gfx.mojom.BufferUsageAndFormat"
+ cpp = "::gfx::BufferUsageAndFormat"
+ },
+ {
+ mojom = "gfx.mojom.GpuMemoryBufferHandle"
+ cpp = "::gfx::GpuMemoryBufferHandle"
+ move_only = true
+ nullable_is_same_type = true
+ },
+ {
+ mojom = "gfx.mojom.GpuMemoryBufferId"
+ cpp = "::gfx::GpuMemoryBufferId"
+ copyable_pass_by_value = true
+ },
+ {
+ mojom = "gfx.mojom.GpuMemoryBufferType"
+ cpp = "::gfx::GpuMemoryBufferType"
+ },
+ ]
- traits_headers = [ "buffer_types_mojom_traits.h" ]
- traits_public_deps = [ ":shared_mojom_traits" ]
- }
+ traits_headers = [ "buffer_types_mojom_traits.h" ]
+ traits_public_deps = [ ":shared_mojom_traits" ]
+ },
+ {
+ types = [
+ {
+ mojom = "gfx.mojom.ColorSpace"
+ cpp = "::gfx::ColorSpace"
+ },
+ ]
+ traits_headers = [ "color_space_mojom_traits.h" ]
+ traits_public_deps = [ ":color_space_mojom_support" ]
+ },
+ {
+ types = [
+ {
+ mojom = "gfx.mojom.GpuFenceHandle"
+ cpp = "::gfx::GpuFenceHandle"
+ },
+ ]
+ traits_headers = [ "gpu_fence_handle_mojom_traits.h" ]
+ traits_public_deps = [ ":shared_mojom_traits" ]
+ },
+ {
+ types = [
+ {
+ mojom = "gfx.mojom.Transform"
+ cpp = "::gfx::Transform"
+ },
+ ]
+ traits_headers = [ "transform_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/gfx" ]
+ },
+ ]
+
+ cpp_typemaps = [
+ {
+ types = [
+ {
+ mojom = "gfx.mojom.AcceleratedWidget"
+ cpp = "::gfx::AcceleratedWidget"
+ copyable_pass_by_value = true
+ },
+ ]
+ traits_headers = [ "accelerated_widget_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/gfx" ]
+ },
+ {
+ types = [
+ {
+ mojom = "gfx.mojom.CALayerParams"
+ cpp = "::gfx::CALayerParams"
+ },
+ ]
+ traits_sources = [ "ca_layer_params_mojom_traits.cc" ]
+ traits_headers = [ "ca_layer_params_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/gfx" ]
+ },
+ {
+ types = [
+ {
+ mojom = "gfx.mojom.DisplayColorSpaces"
+ cpp = "::gfx::DisplayColorSpaces"
+ },
+ ]
+ traits_sources = [ "display_color_spaces_mojom_traits.cc" ]
+ traits_headers = [ "display_color_spaces_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/gfx" ]
+ },
+ {
+ types = [
+ {
+ mojom = "gfx.mojom.Hinting"
+ cpp = "::gfx::FontRenderParams::Hinting"
+ },
+ {
+ mojom = "gfx.mojom.SubpixelRendering"
+ cpp = "::gfx::FontRenderParams::SubpixelRendering"
+ },
+ ]
+ traits_headers = [ "font_render_params_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/gfx" ]
+ },
+ {
+ types = [
+ {
+ mojom = "gfx.mojom.OverlayTransform"
+ cpp = "::gfx::OverlayTransform"
+ },
+ ]
+ traits_headers = [ "overlay_transform_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/gfx" ]
+ },
+ {
+ types = [
+ {
+ mojom = "gfx.mojom.PresentationFeedback"
+ cpp = "::gfx::PresentationFeedback"
+ },
+ ]
+ traits_headers = [ "presentation_feedback_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/gfx" ]
+ },
+ {
+ types = [
+ {
+ mojom = "gfx.mojom.RRectF"
+ cpp = "::gfx::RRectF"
+ },
+ ]
+ traits_headers = [ "rrect_f_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/gfx/geometry/mojom:mojom_traits" ]
+ },
+ {
+ types = [
+ {
+ mojom = "gfx.mojom.SelectionBound"
+ cpp = "::gfx::SelectionBound"
+ },
+ ]
+ traits_headers = [ "selection_bound_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/gfx/geometry/mojom:mojom_traits" ]
+ },
+ {
+ types = [
+ {
+ mojom = "gfx.mojom.SwapResult"
+ cpp = "::gfx::SwapResult"
+ },
+ ]
+ traits_headers = [ "swap_result_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/gfx" ]
+ },
+ {
+ types = [
+ {
+ mojom = "gfx.mojom.SwapTimings"
+ cpp = "::gfx::SwapTimings"
+ },
+ ]
+ traits_headers = [ "swap_timings_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/gfx" ]
+ },
+ ]
- cpp_typemaps = [ buffer_types_shared_cpp_typemap ]
- blink_cpp_typemaps = [ buffer_types_shared_cpp_typemap ]
+ cpp_typemaps += shared_cpp_typemaps
+ blink_cpp_typemaps = shared_cpp_typemaps
}
mojom("native_handle_types") {
@@ -136,6 +278,8 @@ component("shared_mojom_traits") {
sources = [
"buffer_types_mojom_traits.cc",
"buffer_types_mojom_traits.h",
+ "gpu_fence_handle_mojom_traits.cc",
+ "gpu_fence_handle_mojom_traits.h",
]
public_deps = [
":mojom_shared",
diff --git a/chromium/ui/gfx/mojom/accelerated_widget.typemap b/chromium/ui/gfx/mojom/accelerated_widget.typemap
deleted file mode 100644
index d51e424200d..00000000000
--- a/chromium/ui/gfx/mojom/accelerated_widget.typemap
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-mojom = "//ui/gfx/mojom/accelerated_widget.mojom"
-public_headers = [ "//ui/gfx/native_widget_types.h" ]
-traits_headers = [ "//ui/gfx/mojom/accelerated_widget_mojom_traits.h" ]
-public_deps = [
- "//ui/gfx",
-]
-type_mappings = [ "gfx.mojom.AcceleratedWidget=::gfx::AcceleratedWidget[copyable_pass_by_value]" ]
diff --git a/chromium/ui/gfx/mojom/ca_layer_params.typemap b/chromium/ui/gfx/mojom/ca_layer_params.typemap
deleted file mode 100644
index 11a0daeca37..00000000000
--- a/chromium/ui/gfx/mojom/ca_layer_params.typemap
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright 2017 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.
-
-mojom = "//ui/gfx/mojom/ca_layer_params.mojom"
-public_headers = [ "//ui/gfx/ca_layer_params.h" ]
-traits_headers = [ "//ui/gfx/mojom/ca_layer_params_mojom_traits.h" ]
-sources = [
- "//ui/gfx/mojom/ca_layer_params_mojom_traits.cc",
-]
-public_deps = [
- "//ui/gfx",
-]
-deps = [
- "//ui/gfx/geometry/mojom:mojom_traits",
-]
-type_mappings = [ "gfx.mojom.CALayerParams=::gfx::CALayerParams" ]
diff --git a/chromium/ui/gfx/mojom/ca_layer_params_mojom_traits.cc b/chromium/ui/gfx/mojom/ca_layer_params_mojom_traits.cc
index 3f050fcf52e..d6ec9ef087f 100644
--- a/chromium/ui/gfx/mojom/ca_layer_params_mojom_traits.cc
+++ b/chromium/ui/gfx/mojom/ca_layer_params_mojom_traits.cc
@@ -43,10 +43,10 @@ bool StructTraits<gfx::mojom::CALayerParamsDataView, gfx::CALayerParams>::Read(
if (!platform_handle.is_mach_send())
return false;
out->io_surface_mach_port.reset(platform_handle.ReleaseMachSendRight());
+ break;
#else
return false;
#endif
- break;
}
if (!data.ReadPixelSize(&out->pixel_size))
diff --git a/chromium/ui/gfx/mojom/color_space.typemap b/chromium/ui/gfx/mojom/color_space.typemap
deleted file mode 100644
index 79ec50a294c..00000000000
--- a/chromium/ui/gfx/mojom/color_space.typemap
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-mojom = "//ui/gfx/mojom/color_space.mojom"
-public_headers = [ "//ui/gfx/color_space.h" ]
-traits_headers = [ "//ui/gfx/mojom/color_space_mojom_traits.h" ]
-public_deps = [ "//ui/gfx/mojom:color_space_mojom_support" ]
-type_mappings = [ "gfx.mojom.ColorSpace=::gfx::ColorSpace" ]
diff --git a/chromium/ui/gfx/mojom/display_color_spaces.typemap b/chromium/ui/gfx/mojom/display_color_spaces.typemap
deleted file mode 100644
index 1e1d6cc7e01..00000000000
--- a/chromium/ui/gfx/mojom/display_color_spaces.typemap
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2020 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.
-
-mojom = "//ui/gfx/mojom/display_color_spaces.mojom"
-public_headers = [ "//ui/gfx/display_color_spaces.h" ]
-traits_headers = [ "//ui/gfx/mojom/display_color_spaces_mojom_traits.h" ]
-sources = [ "//ui/gfx/mojom/display_color_spaces_mojom_traits.cc" ]
-public_deps = [ "//ui/gfx" ]
-type_mappings = [ "gfx.mojom.DisplayColorSpaces=::gfx::DisplayColorSpaces" ]
diff --git a/chromium/ui/gfx/mojom/font_render_params.typemap b/chromium/ui/gfx/mojom/font_render_params.typemap
deleted file mode 100644
index 31cb4c868f3..00000000000
--- a/chromium/ui/gfx/mojom/font_render_params.typemap
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2018 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.
-
-mojom = "//ui/gfx/mojom/font_render_params.mojom"
-public_headers = [ "//ui/gfx/font_render_params.h" ]
-traits_headers = [ "//ui/gfx/mojom/font_render_params_mojom_traits.h" ]
-public_deps = [
- "//ui/gfx",
-]
-type_mappings = [
- "gfx.mojom.Hinting=::gfx::FontRenderParams::Hinting",
- "gfx.mojom.SubpixelRendering=::gfx::FontRenderParams::SubpixelRendering",
-]
diff --git a/chromium/ui/gfx/mojom/gpu_fence_handle.typemap b/chromium/ui/gfx/mojom/gpu_fence_handle.typemap
deleted file mode 100644
index ef97ab51303..00000000000
--- a/chromium/ui/gfx/mojom/gpu_fence_handle.typemap
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2017 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.
-
-mojom = "//ui/gfx/mojom/gpu_fence_handle.mojom"
-public_headers = [ "//ui/gfx/gpu_fence_handle.h" ]
-traits_headers = [ "//ui/gfx/mojom/gpu_fence_handle_mojom_traits.h" ]
-sources = [
- "//ui/gfx/mojom/gpu_fence_handle_mojom_traits.cc",
-]
-deps = [
- "//ui/gfx",
-]
-type_mappings = [ "gfx.mojom.GpuFenceHandle=::gfx::GpuFenceHandle" ]
diff --git a/chromium/ui/gfx/mojom/gpu_fence_handle_for_blink.typemap b/chromium/ui/gfx/mojom/gpu_fence_handle_for_blink.typemap
deleted file mode 100644
index c6540e8f6bb..00000000000
--- a/chromium/ui/gfx/mojom/gpu_fence_handle_for_blink.typemap
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2017 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.
-
-mojom = "//ui/gfx/mojom/gpu_fence_handle.mojom"
-public_headers = [ "//ui/gfx/gpu_fence_handle.h" ]
-traits_headers = [ "//ui/gfx/mojom/gpu_fence_handle_mojom_traits.h" ]
-public_deps = [
- "//mojo/public/cpp/bindings",
- "//ui/gfx/mojom",
-]
-type_mappings = [ "gfx.mojom.GpuFenceHandle=::gfx::GpuFenceHandle" ]
diff --git a/chromium/ui/gfx/mojom/gpu_fence_handle_mojom_traits.h b/chromium/ui/gfx/mojom/gpu_fence_handle_mojom_traits.h
index 74ef6032698..f688b2cb743 100644
--- a/chromium/ui/gfx/mojom/gpu_fence_handle_mojom_traits.h
+++ b/chromium/ui/gfx/mojom/gpu_fence_handle_mojom_traits.h
@@ -5,13 +5,15 @@
#ifndef UI_GFX_MOJOM_GPU_FENCE_HANDLE_MOJOM_TRAITS_H_
#define UI_GFX_MOJOM_GPU_FENCE_HANDLE_MOJOM_TRAITS_H_
+#include "base/component_export.h"
#include "ui/gfx/gpu_fence_handle.h"
-#include "ui/gfx/mojom/gpu_fence_handle.mojom.h"
+#include "ui/gfx/mojom/gpu_fence_handle.mojom-shared.h"
namespace mojo {
template <>
-struct EnumTraits<gfx::mojom::GpuFenceHandleType, gfx::GpuFenceHandleType> {
+struct COMPONENT_EXPORT(GFX_SHARED_MOJOM_TRAITS)
+ EnumTraits<gfx::mojom::GpuFenceHandleType, gfx::GpuFenceHandleType> {
static gfx::mojom::GpuFenceHandleType ToMojom(gfx::GpuFenceHandleType type) {
switch (type) {
case gfx::GpuFenceHandleType::kEmpty:
@@ -38,7 +40,8 @@ struct EnumTraits<gfx::mojom::GpuFenceHandleType, gfx::GpuFenceHandleType> {
};
template <>
-struct StructTraits<gfx::mojom::GpuFenceHandleDataView, gfx::GpuFenceHandle> {
+struct COMPONENT_EXPORT(GFX_SHARED_MOJOM_TRAITS)
+ StructTraits<gfx::mojom::GpuFenceHandleDataView, gfx::GpuFenceHandle> {
static gfx::GpuFenceHandleType type(const gfx::GpuFenceHandle& handle) {
return handle.type;
}
diff --git a/chromium/ui/gfx/mojom/overlay_transform.typemap b/chromium/ui/gfx/mojom/overlay_transform.typemap
deleted file mode 100644
index da986325fb3..00000000000
--- a/chromium/ui/gfx/mojom/overlay_transform.typemap
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright 2017 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.
-
-mojom = "//ui/gfx/mojom/overlay_transform.mojom"
-public_headers = [ "//ui/gfx/overlay_transform.h" ]
-traits_headers = [ "//ui/gfx/mojom/overlay_transform_mojom_traits.h" ]
-public_deps = [
- "//ui/gfx",
-]
-type_mappings = [ "gfx.mojom.OverlayTransform=::gfx::OverlayTransform" ]
diff --git a/chromium/ui/gfx/mojom/presentation_feedback.typemap b/chromium/ui/gfx/mojom/presentation_feedback.typemap
deleted file mode 100644
index f439a6ed416..00000000000
--- a/chromium/ui/gfx/mojom/presentation_feedback.typemap
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2018 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.
-
-mojom = "//ui/gfx/mojom/presentation_feedback.mojom"
-public_headers = [ "//ui/gfx/presentation_feedback.h" ]
-traits_headers = [ "//ui/gfx/mojom/presentation_feedback_mojom_traits.h" ]
-type_mappings = [ "gfx.mojom.PresentationFeedback=::gfx::PresentationFeedback" ]
diff --git a/chromium/ui/gfx/mojom/rrect_f.typemap b/chromium/ui/gfx/mojom/rrect_f.typemap
deleted file mode 100644
index 7e2dd639dff..00000000000
--- a/chromium/ui/gfx/mojom/rrect_f.typemap
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright 2018 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.
-
-mojom = "//ui/gfx/mojom/rrect_f.mojom"
-public_headers = [ "//ui/gfx/rrect_f.h" ]
-traits_headers = [ "//ui/gfx/mojom/rrect_f_mojom_traits.h" ]
-type_mappings = [ "gfx.mojom.RRectF=::gfx::RRectF" ]
-deps = [
- "//ui/gfx/geometry/mojom:mojom_traits",
-]
diff --git a/chromium/ui/gfx/mojom/selection_bound.typemap b/chromium/ui/gfx/mojom/selection_bound.typemap
deleted file mode 100644
index 6da919c2774..00000000000
--- a/chromium/ui/gfx/mojom/selection_bound.typemap
+++ /dev/null
@@ -1,11 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-mojom = "//ui/gfx/mojom/selection_bound.mojom"
-public_headers = [ "//ui/gfx/selection_bound.h" ]
-traits_headers = [ "//ui/gfx/mojom/selection_bound_mojom_traits.h" ]
-type_mappings = [ "gfx.mojom.SelectionBound=::gfx::SelectionBound" ]
-deps = [
- "//ui/gfx/geometry/mojom:mojom_traits",
-]
diff --git a/chromium/ui/gfx/mojom/swap_result.typemap b/chromium/ui/gfx/mojom/swap_result.typemap
deleted file mode 100644
index 192e5d5cf87..00000000000
--- a/chromium/ui/gfx/mojom/swap_result.typemap
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2018 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.
-
-mojom = "//ui/gfx/mojom/swap_result.mojom"
-public_headers = [ "//ui/gfx/swap_result.h" ]
-traits_headers = [ "//ui/gfx/mojom/swap_result_mojom_traits.h" ]
-type_mappings = [ "gfx.mojom.SwapResult=::gfx::SwapResult" ]
diff --git a/chromium/ui/gfx/mojom/swap_timings.typemap b/chromium/ui/gfx/mojom/swap_timings.typemap
deleted file mode 100644
index 52d385a6464..00000000000
--- a/chromium/ui/gfx/mojom/swap_timings.typemap
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2019 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.
-
-mojom = "//ui/gfx/mojom/swap_timings.mojom"
-public_headers = [ "//ui/gfx/swap_result.h" ]
-traits_headers = [ "//ui/gfx/mojom/swap_timings_mojom_traits.h" ]
-type_mappings = [ "gfx.mojom.SwapTimings=::gfx::SwapTimings" ]
diff --git a/chromium/ui/gfx/mojom/transform.typemap b/chromium/ui/gfx/mojom/transform.typemap
deleted file mode 100644
index ff2bf8ac29d..00000000000
--- a/chromium/ui/gfx/mojom/transform.typemap
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-mojom = "//ui/gfx/mojom/transform.mojom"
-public_headers = [ "//ui/gfx/transform.h" ]
-traits_headers = [ "//ui/gfx/mojom/transform_mojom_traits.h" ]
-type_mappings = [ "gfx.mojom.Transform=::gfx::Transform" ]
diff --git a/chromium/ui/gfx/native_pixmap_handle.cc b/chromium/ui/gfx/native_pixmap_handle.cc
index 0d5c59c5994..fa41b717ea7 100644
--- a/chromium/ui/gfx/native_pixmap_handle.cc
+++ b/chromium/ui/gfx/native_pixmap_handle.cc
@@ -6,6 +6,7 @@
#include <utility>
+#include "base/logging.h"
#include "build/build_config.h"
#if defined(OS_LINUX)
diff --git a/chromium/ui/gfx/overlay_transform_utils.cc b/chromium/ui/gfx/overlay_transform_utils.cc
index f7df8997221..c39345ee7b3 100644
--- a/chromium/ui/gfx/overlay_transform_utils.cc
+++ b/chromium/ui/gfx/overlay_transform_utils.cc
@@ -4,6 +4,7 @@
#include "ui/gfx/overlay_transform_utils.h"
+#include "base/notreached.h"
#include "ui/gfx/geometry/rect_conversions.h"
namespace gfx {
diff --git a/chromium/ui/gfx/paint_vector_icon.cc b/chromium/ui/gfx/paint_vector_icon.cc
index cb7497b7bbd..01c19741433 100644
--- a/chromium/ui/gfx/paint_vector_icon.cc
+++ b/chromium/ui/gfx/paint_vector_icon.cc
@@ -116,6 +116,8 @@ class PathParser {
case R_MOVE_TO:
case LINE_TO:
case R_LINE_TO:
+ case QUADRATIC_TO_SHORTHAND:
+ case R_QUADRATIC_TO_SHORTHAND:
return 2;
case CIRCLE:
@@ -124,6 +126,9 @@ class PathParser {
case PATH_COLOR_ARGB:
case CUBIC_TO_SHORTHAND:
case CLIP:
+ case QUADRATIC_TO:
+ case R_QUADRATIC_TO:
+ case OVAL:
return 4;
case ROUND_RECT:
@@ -182,7 +187,12 @@ CommandType CommandFromString(const std::string& source) {
RETURN_IF_IS(CUBIC_TO);
RETURN_IF_IS(R_CUBIC_TO);
RETURN_IF_IS(CUBIC_TO_SHORTHAND);
+ RETURN_IF_IS(QUADRATIC_TO);
+ RETURN_IF_IS(R_QUADRATIC_TO);
+ RETURN_IF_IS(QUADRATIC_TO_SHORTHAND);
+ RETURN_IF_IS(R_QUADRATIC_TO_SHORTHAND);
RETURN_IF_IS(CIRCLE);
+ RETURN_IF_IS(OVAL);
RETURN_IF_IS(ROUND_RECT);
RETURN_IF_IS(CLOSE);
RETURN_IF_IS(CANVAS_DIMENSIONS);
@@ -212,6 +222,13 @@ std::vector<PathElement> PathFromSource(const std::string& source) {
return path;
}
+bool IsCommandTypeCurve(CommandType command) {
+ return command == CUBIC_TO || command == R_CUBIC_TO ||
+ command == CUBIC_TO_SHORTHAND || command == QUADRATIC_TO ||
+ command == R_QUADRATIC_TO || command == QUADRATIC_TO_SHORTHAND ||
+ command == R_QUADRATIC_TO_SHORTHAND;
+}
+
void PaintPath(Canvas* canvas,
const PathElement* path_elements,
size_t path_size,
@@ -348,28 +365,55 @@ void PaintPath(Canvas* canvas,
path.rCubicTo(arg(0), arg(1), arg(2), arg(3), arg(4), arg(5));
break;
- case CUBIC_TO_SHORTHAND: {
- // Compute the first control point (|x1| and |y1|) as the reflection
- // of the second control point on the previous command relative to
- // the current point. If there is no previous command or if the
- // previous command is not a cubic Bezier curve, the first control
- // point is coincident with the current point. Refer to the SVG
- // path specs for further details.
+ case CUBIC_TO_SHORTHAND:
+ case QUADRATIC_TO_SHORTHAND:
+ case R_QUADRATIC_TO_SHORTHAND: {
+ // Compute the first control point (|x1| and |y1|) as the reflection of
+ // the last control point on the previous command relative to the
+ // current point. If there is no previous command or if the previous
+ // command is not a Bezier curve, the first control point is coincident
+ // with the current point. Refer to the SVG path specs for further
+ // details.
+ // Note that |x1| and |y1| will correspond to the sole control point if
+ // calculating a quadratic curve.
SkPoint last_point;
path.getLastPt(&last_point);
SkScalar delta_x = 0;
SkScalar delta_y = 0;
- if (previous_command_type == CUBIC_TO ||
- previous_command_type == R_CUBIC_TO ||
- previous_command_type == CUBIC_TO_SHORTHAND) {
+ if (IsCommandTypeCurve(previous_command_type)) {
SkPoint last_control_point = path.getPoint(path.countPoints() - 2);
+ // We find what the delta was between the last curve's starting point
+ // and the control point. This difference is what we will reflect on
+ // the current point, creating our new control point.
delta_x = last_point.fX - last_control_point.fX;
delta_y = last_point.fY - last_control_point.fY;
}
SkScalar x1 = last_point.fX + delta_x;
SkScalar y1 = last_point.fY + delta_y;
- path.cubicTo(x1, y1, arg(0), arg(1), arg(2), arg(3));
+ if (command_type == CUBIC_TO_SHORTHAND)
+ path.cubicTo(x1, y1, arg(0), arg(1), arg(2), arg(3));
+ else if (command_type == QUADRATIC_TO_SHORTHAND)
+ path.quadTo(x1, y1, arg(0), arg(1));
+ else if (command_type == R_QUADRATIC_TO_SHORTHAND)
+ path.rQuadTo(x1, y1, arg(0), arg(1));
+ break;
+ }
+
+ case QUADRATIC_TO:
+ path.quadTo(arg(0), arg(1), arg(2), arg(3));
+ break;
+
+ case R_QUADRATIC_TO:
+ path.rQuadTo(arg(0), arg(1), arg(2), arg(3));
+ break;
+
+ case OVAL: {
+ SkScalar x = arg(0);
+ SkScalar y = arg(1);
+ SkScalar rx = arg(2);
+ SkScalar ry = arg(3);
+ path.addOval(SkRect::MakeLTRB(x - rx, y - ry, x + rx, y + ry));
break;
}
diff --git a/chromium/ui/gfx/path_win_unittest.cc b/chromium/ui/gfx/path_win_unittest.cc
index dc7982392c4..4ebbf27d042 100644
--- a/chromium/ui/gfx/path_win_unittest.cc
+++ b/chromium/ui/gfx/path_win_unittest.cc
@@ -9,6 +9,7 @@
#include <algorithm>
#include <vector>
+#include "base/check_op.h"
#include "base/stl_util.h"
#include "base/win/scoped_gdi_object.h"
#include "skia/ext/skia_utils_win.h"
diff --git a/chromium/ui/gfx/platform_font_skia_unittest.cc b/chromium/ui/gfx/platform_font_skia_unittest.cc
index a7548a35367..06a80cec66d 100644
--- a/chromium/ui/gfx/platform_font_skia_unittest.cc
+++ b/chromium/ui/gfx/platform_font_skia_unittest.cc
@@ -6,8 +6,10 @@
#include <string>
+#include "base/check_op.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "base/notreached.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/font.h"
diff --git a/chromium/ui/gfx/range/mojom/BUILD.gn b/chromium/ui/gfx/range/mojom/BUILD.gn
index ad23e10d5bf..497acbc59cb 100644
--- a/chromium/ui/gfx/range/mojom/BUILD.gn
+++ b/chromium/ui/gfx/range/mojom/BUILD.gn
@@ -8,6 +8,24 @@ import("//mojo/public/tools/bindings/mojom.gni")
# picking up a dependency on skia.
mojom("mojom") {
sources = [ "range.mojom" ]
+
+ shared_cpp_typemap = {
+ types = [
+ {
+ mojom = "gfx.mojom.Range"
+ cpp = "::gfx::Range"
+ },
+ {
+ mojom = "gfx.mojom.RangeF"
+ cpp = "::gfx::RangeF"
+ },
+ ]
+
+ traits_headers = [ "range_mojom_traits.h" ]
+ traits_public_deps = [ ":mojom_traits" ]
+ }
+ cpp_typemaps = [ shared_cpp_typemap ]
+ blink_cpp_typemaps = [ shared_cpp_typemap ]
}
mojom("test_interfaces") {
@@ -30,3 +48,11 @@ source_set("unit_test") {
"//ui/gfx/range",
]
}
+
+source_set("mojom_traits") {
+ sources = [ "range_mojom_traits.h" ]
+ public_deps = [
+ ":mojom_shared",
+ "//ui/gfx/range",
+ ]
+}
diff --git a/chromium/ui/gfx/range/mojom/range.typemap b/chromium/ui/gfx/range/mojom/range.typemap
deleted file mode 100644
index c49856e2e4f..00000000000
--- a/chromium/ui/gfx/range/mojom/range.typemap
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-mojom = "//ui/gfx/range/mojom/range.mojom"
-public_headers = [
- "//ui/gfx/range/range.h",
- "//ui/gfx/range/range_f.h",
-]
-traits_headers = [ "//ui/gfx/range/mojom/range_mojom_traits.h" ]
-type_mappings = [
- "gfx.mojom.Range=::gfx::Range",
- "gfx.mojom.RangeF=::gfx::RangeF",
-]
-sources = [
- "range_mojom_traits.h",
-]
-deps = [
- "//ui/gfx/range",
-]
diff --git a/chromium/ui/gfx/range/range.cc b/chromium/ui/gfx/range/range.cc
index ec37bda6448..2776f3d75ef 100644
--- a/chromium/ui/gfx/range/range.cc
+++ b/chromium/ui/gfx/range/range.cc
@@ -8,7 +8,6 @@
#include <algorithm>
-#include "base/logging.h"
#include "base/strings/stringprintf.h"
namespace gfx {
diff --git a/chromium/ui/gfx/range/range_mac.mm b/chromium/ui/gfx/range/range_mac.mm
index ad7ea6a85de..cc1aa1ee4e2 100644
--- a/chromium/ui/gfx/range/range_mac.mm
+++ b/chromium/ui/gfx/range/range_mac.mm
@@ -8,7 +8,7 @@
#include <limits>
-#include "base/logging.h"
+#include "base/check_op.h"
namespace gfx {
diff --git a/chromium/ui/gfx/render_text.cc b/chromium/ui/gfx/render_text.cc
index 7d5fb0c4d6e..ddbad437878 100644
--- a/chromium/ui/gfx/render_text.cc
+++ b/chromium/ui/gfx/render_text.cc
@@ -9,10 +9,11 @@
#include <algorithm>
#include <climits>
+#include "base/check_op.h"
#include "base/command_line.h"
#include "base/i18n/break_iterator.h"
#include "base/i18n/char_iterator.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/numerics/ranges.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
@@ -618,6 +619,10 @@ void RenderText::SetDisplayRect(const Rect& r) {
}
}
+const std::vector<Range> RenderText::GetAllSelections() const {
+ return selection_model_.GetAllSelections();
+}
+
void RenderText::SetCursorPosition(size_t position) {
size_t cursor = std::min(position, text().length());
if (IsValidCursorIndex(cursor)) {
@@ -724,14 +729,16 @@ void RenderText::MoveCursor(BreakType break_type,
bool RenderText::SetSelection(const SelectionModel& model) {
// Enforce valid selection model components.
- size_t text_length = text().length();
- Range range(
- std::min(model.selection().start(), static_cast<uint32_t>(text_length)),
- std::min(model.caret_pos(), text_length));
- // The current model only supports caret positions at valid cursor indices.
- if (!IsValidCursorIndex(range.start()) || !IsValidCursorIndex(range.end()))
- return false;
- SelectionModel sel(range, model.caret_affinity());
+ uint32_t text_length = static_cast<uint32_t>(text().length());
+ std::vector<Range> ranges = model.GetAllSelections();
+ for (auto& range : ranges) {
+ range = {std::min(range.start(), text_length),
+ std::min(range.end(), text_length)};
+ // The current model only supports caret positions at valid cursor indices.
+ if (!IsValidCursorIndex(range.start()) || !IsValidCursorIndex(range.end()))
+ return false;
+ }
+ SelectionModel sel = SelectionModel(ranges, model.caret_affinity());
bool changed = sel != selection_model_;
SetSelectionModel(sel);
return changed;
@@ -747,16 +754,21 @@ bool RenderText::MoveCursorToPoint(const gfx::Point& point,
return SetSelection(model);
}
-bool RenderText::SelectRange(const Range& range) {
+bool RenderText::SelectRange(const Range& range, bool primary) {
uint32_t text_length = static_cast<uint32_t>(text().length());
Range sel(std::min(range.start(), text_length),
std::min(range.end(), text_length));
// Allow selection bounds at valid indices amid multi-character graphemes.
if (!IsValidLogicalIndex(sel.start()) || !IsValidLogicalIndex(sel.end()))
return false;
- LogicalCursorDirection affinity =
- (sel.is_reversed() || sel.is_empty()) ? CURSOR_FORWARD : CURSOR_BACKWARD;
- SetSelectionModel(SelectionModel(sel, affinity));
+ if (primary) {
+ LogicalCursorDirection affinity = (sel.is_reversed() || sel.is_empty())
+ ? CURSOR_FORWARD
+ : CURSOR_BACKWARD;
+ SetSelectionModel(SelectionModel(sel, affinity));
+ } else {
+ AddSecondarySelection(sel);
+ }
return true;
}
@@ -922,15 +934,15 @@ void RenderText::Draw(Canvas* canvas, bool select_all) {
}
if (!text().empty()) {
- Range draw_selection;
+ std::vector<Range> draw_selections;
if (select_all)
- draw_selection = Range(0, text().length());
+ draw_selections = {Range(0, text().length())};
else if (focused())
- draw_selection = selection();
+ draw_selections = GetAllSelections();
- DrawSelection(canvas, draw_selection);
+ DrawSelections(canvas, draw_selections);
internal::SkiaTextRenderer renderer(canvas);
- DrawVisualText(&renderer, draw_selection);
+ DrawVisualText(&renderer, draw_selections);
}
if (clip_to_display_rect())
@@ -1438,6 +1450,11 @@ void RenderText::SetSelectionModel(const SelectionModel& model) {
has_directed_selection_ = kSelectionIsAlwaysDirected;
}
+void RenderText::AddSecondarySelection(const Range selection) {
+ DCHECK_LE(selection.GetMax(), text().length());
+ selection_model_.AddSecondarySelection(selection);
+}
+
size_t RenderText::TextIndexToDisplayIndex(size_t index) const {
return GetDisplayTextIndex(GetGraphemeIteratorAtTextIndex(index));
}
@@ -2219,12 +2236,15 @@ internal::GraphemeIterator RenderText::GetGraphemeIteratorAtIndex(
return iter;
}
-void RenderText::DrawSelection(Canvas* canvas, const Range& selection) {
- if (!selection.is_empty()) {
- for (Rect s : GetSubstringBounds(selection)) {
- if (symmetric_selection_visual_bounds() && !multiline())
- s = ExpandToBeVerticallySymmetric(s, display_rect());
- canvas->FillRect(s, selection_background_focused_color_);
+void RenderText::DrawSelections(Canvas* canvas,
+ const std::vector<Range> selections) {
+ for (auto selection : selections) {
+ if (!selection.is_empty()) {
+ for (Rect s : GetSubstringBounds(selection)) {
+ if (symmetric_selection_visual_bounds() && !multiline())
+ s = ExpandToBeVerticallySymmetric(s, display_rect());
+ canvas->FillRect(s, selection_background_focused_color_);
+ }
}
}
}
diff --git a/chromium/ui/gfx/render_text.h b/chromium/ui/gfx/render_text.h
index 892b32910b7..8cfbd5c5c4a 100644
--- a/chromium/ui/gfx/render_text.h
+++ b/chromium/ui/gfx/render_text.h
@@ -200,7 +200,7 @@ void ApplyRenderParams(const FontRenderParams& params,
} // namespace internal
// RenderText represents an abstract model of styled text and its corresponding
-// visual layout. Support is built in for a cursor, a selection, simple styling,
+// visual layout. Support is built in for a cursor, selections, simple styling,
// complex scripts, and bi-directional text. Implementations provide mechanisms
// for rendering and translation between logical and visual data.
class GFX_EXPORT RenderText {
@@ -337,6 +337,10 @@ class GFX_EXPORT RenderText {
const SelectionModel& selection_model() const { return selection_model_; }
const Range& selection() const { return selection_model_.selection(); }
size_t cursor_position() const { return selection_model_.caret_pos(); }
+ const std::vector<Range>& secondary_selections() const {
+ return selection_model_.secondary_selections();
+ }
+ const std::vector<Range> GetAllSelections() const;
// Set the cursor to |position|, with the caret affinity trailing the previous
// grapheme, or if there is no previous grapheme, leading the cursor position.
@@ -369,12 +373,14 @@ class GFX_EXPORT RenderText {
bool select,
const gfx::Point& drag_origin = gfx::Point());
- // Set the selection_model_ based on |range|.
- // If the |range| start or end is greater than text length, it is modified
- // to be the text length.
- // If the |range| start or end is not a cursorable position (not on grapheme
- // boundary), it is a NO-OP and returns false. Otherwise, returns true.
- bool SelectRange(const Range& range);
+ // Set the |selection_model_| based on |range|. If the |range| start or end is
+ // greater than text length, it is modified to be the text length. If the
+ // |range| start or end is not a cursorable position (not on grapheme
+ // boundary), it is a NO-OP and returns false. Otherwise, returns true. If
+ // |primary| is true, secondary selections are cleared; otherwise, the range
+ // will be added as a secondary selection not associated with the cursor. In
+ // the latter case, |range| should not overlap with existing selections.
+ bool SelectRange(const Range& range, bool primary = true);
// Returns true if the local point is over selected text.
bool IsPointInSelection(const Point& point);
@@ -426,7 +432,7 @@ class GFX_EXPORT RenderText {
// Set or get the text directionality mode and get the text direction yielded.
void SetDirectionalityMode(DirectionalityMode mode);
DirectionalityMode directionality_mode() const {
- return directionality_mode_;
+ return directionality_mode_;
}
base::i18n::TextDirection GetDisplayTextDirection();
@@ -626,7 +632,7 @@ class GFX_EXPORT RenderText {
return font_size_overrides_;
}
const BreakList<Font::Weight>& weights() const { return weights_; }
- const std::vector<BreakList<bool> >& styles() const { return styles_; }
+ const std::vector<BreakList<bool>>& styles() const { return styles_; }
SkScalar strike_thickness_factor() const { return strike_thickness_factor_; }
const BreakList<SkColor>& layout_colors() const { return layout_colors_; }
@@ -699,8 +705,11 @@ class GFX_EXPORT RenderText {
SelectionModel LineSelectionModel(size_t line_index,
gfx::VisualCursorDirection direction);
- // Sets the selection model, |model| is assumed to be valid.
+ // Sets the selection model. |model| should be valid.
void SetSelectionModel(const SelectionModel& model);
+ // Adds a secondary selection. |selection| should not overlap with existing
+ // selections.
+ void AddSecondarySelection(const Range selection);
// Convert between indices into |text_| and indices into
// GetDisplayText(), which differ when the text is obscured,
@@ -719,9 +728,9 @@ class GFX_EXPORT RenderText {
// Ensure the text is laid out, lines are computed, and |lines_| is valid.
virtual void EnsureLayout() = 0;
- // Draw all text and make the given range appear selected.
+ // Draw all text and make the given ranges appear selected.
virtual void DrawVisualText(internal::SkiaTextRenderer* renderer,
- const Range& selection) = 0;
+ const std::vector<Range> selections) = 0;
// Update the display text.
void UpdateDisplayText(float text_width);
@@ -811,8 +820,8 @@ class GFX_EXPORT RenderText {
// cursor is within the visible display area.
void UpdateCachedBoundsAndOffset();
- // Draws the specified range of text with a selected appearance.
- void DrawSelection(Canvas* canvas, const Range& selection);
+ // Draws the specified ranges of text with a selected appearance.
+ void DrawSelections(Canvas* canvas, const std::vector<Range> selections);
// Returns a grapheme iterator that contains the codepoint at |index|.
internal::GraphemeIterator GetGraphemeIteratorAtIndex(
@@ -864,7 +873,7 @@ class GFX_EXPORT RenderText {
// A list of fonts used to render |text_|.
FontList font_list_;
- // Logical selection range and visual cursor position.
+ // Logical selection ranges and visual cursor position.
SelectionModel selection_model_;
// The cached cursor bounds; get these bounds with GetUpdatedCursorBounds.
@@ -904,7 +913,7 @@ class GFX_EXPORT RenderText {
BreakList<BaselineStyle> baselines_;
BreakList<int> font_size_overrides_;
BreakList<Font::Weight> weights_;
- std::vector<BreakList<bool> > styles_;
+ std::vector<BreakList<bool>> styles_;
mutable BreakList<SkColor> layout_colors_;
mutable BreakList<BaselineStyle> layout_baselines_;
diff --git a/chromium/ui/gfx/render_text_harfbuzz.cc b/chromium/ui/gfx/render_text_harfbuzz.cc
index 23ab1193bff..540c1fc200f 100644
--- a/chromium/ui/gfx/render_text_harfbuzz.cc
+++ b/chromium/ui/gfx/render_text_harfbuzz.cc
@@ -1685,7 +1685,7 @@ void RenderTextHarfBuzz::EnsureLayout() {
}
void RenderTextHarfBuzz::DrawVisualText(internal::SkiaTextRenderer* renderer,
- const Range& selection) {
+ const std::vector<Range> selections) {
DCHECK(!update_layout_run_list_);
DCHECK(!update_display_run_list_);
DCHECK(!update_display_text_);
@@ -1699,11 +1699,14 @@ void RenderTextHarfBuzz::DrawVisualText(internal::SkiaTextRenderer* renderer,
// Apply the selected text color to the [un-reversed] selection range.
BreakList<SkColor> colors = layout_colors();
- if (!selection.is_empty()) {
- const Range grapheme_range = ExpandRangeToGraphemeBoundary(selection);
- colors.ApplyValue(selection_color(),
- Range(TextIndexToDisplayIndex(grapheme_range.GetMin()),
- TextIndexToDisplayIndex(grapheme_range.GetMax())));
+ for (auto selection : selections) {
+ if (!selection.is_empty()) {
+ const Range grapheme_range = ExpandRangeToGraphemeBoundary(selection);
+ colors.ApplyValue(
+ selection_color(),
+ Range(TextIndexToDisplayIndex(grapheme_range.GetMin()),
+ TextIndexToDisplayIndex(grapheme_range.GetMax())));
+ }
}
internal::TextRunList* run_list = GetRunList();
@@ -2170,7 +2173,13 @@ void RenderTextHarfBuzz::ShapeRunsWithFont(
}
void RenderTextHarfBuzz::EnsureLayoutRunList() {
- if (update_layout_run_list_) {
+ // Update layout run list if the device scale factor has changed since the
+ // layout run list was last updated, as changes in device scale factor change
+ // subpixel positioning, at least on Linux and Chrome OS.
+ const float device_scale_factor = GetFontRenderParamsDeviceScaleFactor();
+
+ if (update_layout_run_list_ || device_scale_factor_ != device_scale_factor) {
+ device_scale_factor_ = device_scale_factor;
layout_run_list_.Reset();
const base::string16& text = GetLayoutText();
diff --git a/chromium/ui/gfx/render_text_harfbuzz.h b/chromium/ui/gfx/render_text_harfbuzz.h
index 3204328d9fa..d6ae49ec29b 100644
--- a/chromium/ui/gfx/render_text_harfbuzz.h
+++ b/chromium/ui/gfx/render_text_harfbuzz.h
@@ -229,7 +229,7 @@ class GFX_EXPORT RenderTextHarfBuzz : public RenderText {
void OnDisplayTextAttributeChanged() override;
void EnsureLayout() override;
void DrawVisualText(internal::SkiaTextRenderer* renderer,
- const Range& selection) override;
+ const std::vector<Range> selections) override;
private:
friend class test::RenderTextTestApi;
@@ -301,6 +301,9 @@ class GFX_EXPORT RenderTextHarfBuzz : public RenderText {
bool update_display_run_list_ : 1;
bool update_display_text_ : 1;
+ // The device scale factor for which the text was laid out.
+ float device_scale_factor_ = 1.0f;
+
// The total size of the layouted text.
SizeF total_size_;
diff --git a/chromium/ui/gfx/render_text_test_api.h b/chromium/ui/gfx/render_text_test_api.h
index 63b019cde71..1bffccea4a9 100644
--- a/chromium/ui/gfx/render_text_test_api.h
+++ b/chromium/ui/gfx/render_text_test_api.h
@@ -33,7 +33,8 @@ class RenderTextTestApi {
return render_text_->GetRunList();
}
- void DrawVisualText(internal::SkiaTextRenderer* renderer, Range selection) {
+ void DrawVisualText(internal::SkiaTextRenderer* renderer,
+ const std::vector<Range> selection) {
render_text_->DrawVisualText(renderer, selection);
}
diff --git a/chromium/ui/gfx/render_text_unittest.cc b/chromium/ui/gfx/render_text_unittest.cc
index 6796016d97a..092e40ae6e9 100644
--- a/chromium/ui/gfx/render_text_unittest.cc
+++ b/chromium/ui/gfx/render_text_unittest.cc
@@ -431,9 +431,9 @@ class RenderTextTest : public testing::Test {
return test::RenderTextTestApi::GetRendererFont(renderer());
}
- void DrawVisualText(Range selection = {}) {
+ void DrawVisualText(const std::vector<Range> selections = {}) {
test_api()->EnsureLayout();
- test_api()->DrawVisualText(renderer(), selection);
+ test_api()->DrawVisualText(renderer(), selections);
renderer()->GetTextLogAndReset(&text_log_);
}
@@ -630,6 +630,8 @@ class RenderTextTest : public testing::Test {
EXPECT_EQ(runs.size(), text_log_.size());
const size_t min_size = std::min(runs.size(), text_log_.size());
for (size_t i = 0; i < min_size; ++i) {
+ SCOPED_TRACE(testing::Message()
+ << "ExpectTextLog, run " << i << " of " << runs.size());
EXPECT_EQ(runs[i].color, text_log_[i].color());
EXPECT_EQ(runs[i].glyph_count, text_log_[i].glyphs().size());
}
@@ -995,6 +997,29 @@ TEST_F(RenderTextTest, AppendTextKeepsStyles) {
test_api()->font_size_overrides().EqualsForTesting(expected_font_size));
}
+TEST_F(RenderTextTest, SetSelection) {
+ RenderText* render_text = GetRenderText();
+ render_text->set_selection_color(SK_ColorRED);
+ render_text->SetText(ASCIIToUTF16("abcdef"));
+ render_text->set_focused(true);
+
+ // Single selection
+ render_text->SetSelection(
+ {{{4, 100}}, LogicalCursorDirection::CURSOR_FORWARD});
+ Draw();
+ ExpectTextLog({{4}, {2, SK_ColorRED}});
+
+ // Multiple selections
+ render_text->SetSelection(
+ {{{0, 1}, {4, 100}}, LogicalCursorDirection::CURSOR_FORWARD});
+ Draw();
+ ExpectTextLog({{1, SK_ColorRED}, {3}, {2, SK_ColorRED}});
+
+ render_text->ClearSelection();
+ Draw();
+ ExpectTextLog({{6}});
+}
+
TEST_F(RenderTextTest, SelectRangeColored) {
RenderText* render_text = GetRenderText();
render_text->SetText(ASCIIToUTF16("abcdef"));
@@ -1039,6 +1064,28 @@ TEST_F(RenderTextTest, SelectRangeColoredGrapheme) {
ExpectTextLog({{1, SK_ColorBLACK}, {2, SK_ColorRED}});
}
+TEST_F(RenderTextTest, SelectRangeMultiple) {
+ RenderText* render_text = GetRenderText();
+ render_text->set_selection_color(SK_ColorRED);
+ render_text->SetText(ASCIIToUTF16("abcdef"));
+ render_text->set_focused(true);
+
+ // Multiple selections
+ render_text->SelectRange(Range(0, 1));
+ render_text->SelectRange(Range(4, 2), false);
+ Draw();
+ ExpectTextLog({{1, SK_ColorRED}, {1}, {2, SK_ColorRED}, {2}});
+
+ // Setting a primary selection should override secondary selections
+ render_text->SelectRange(Range(5, 6));
+ Draw();
+ ExpectTextLog({{5}, {1, SK_ColorRED}});
+
+ render_text->ClearSelection();
+ Draw();
+ ExpectTextLog({{6}});
+}
+
TEST_F(RenderTextTest, SetCompositionRangeColored) {
RenderText* render_text = GetRenderText();
render_text->SetText(ASCIIToUTF16("abcdef"));
@@ -7394,7 +7441,7 @@ TEST_F(RenderTextTest, DrawVisualText_WithSelection) {
render_text->SetText(ASCIIToUTF16("TheRedElephantIsEatingMyPumpkin"));
// Ensure selected text is drawn differently than unselected text.
render_text->set_selection_color(SK_ColorRED);
- DrawVisualText({3, 14});
+ DrawVisualText({{3, 14}});
ExpectTextLog({{3, SK_ColorBLACK}, {11, SK_ColorRED}, {17, SK_ColorBLACK}});
}
@@ -7403,7 +7450,7 @@ TEST_F(RenderTextTest, DrawVisualText_WithSelectionOnObcuredEmoji) {
render_text->SetText(WideToUTF16(L"\U0001F628\U0001F628\U0001F628"));
render_text->SetObscured(true);
render_text->set_selection_color(SK_ColorRED);
- DrawVisualText({4, 6});
+ DrawVisualText({{4, 6}});
ExpectTextLog({{2, SK_ColorBLACK}, {1, SK_ColorRED}});
}
@@ -7440,4 +7487,29 @@ TEST_F(RenderTextTest, DrawSelectAll) {
ExpectTextLog(kUnselected);
}
+#if defined(OS_LINUX)
+TEST_F(RenderTextTest, StringSizeUpdatedWhenDeviceScaleFactorChanges) {
+ RenderText* render_text = GetRenderText();
+ render_text->SetText(ASCIIToUTF16("Test - 1"));
+ const gfx::SizeF initial_size = render_text->GetStringSizeF();
+
+ // Non-integer device scale factor enables subpixel positioning on Linux and
+ // Chrome OS, which should update text size.
+ SetFontRenderParamsDeviceScaleFactor(1.5);
+
+ const gfx::SizeF scaled_size = render_text->GetStringSizeF();
+
+ // Create render text with scale factor set from the beginning, and use is as
+ // a baseline to which compare the original render text string size.
+ ResetRenderTextInstance();
+ RenderText* scaled_render_text = GetRenderText();
+ scaled_render_text->SetText(ASCIIToUTF16("Test - 1"));
+
+ // Verify that original render text string size got updated after device scale
+ // factor changed.
+ EXPECT_NE(initial_size.width(), scaled_size.width());
+ EXPECT_EQ(scaled_render_text->GetStringSizeF(), scaled_size);
+}
+#endif
+
} // namespace gfx
diff --git a/chromium/ui/gfx/rrect_f.cc b/chromium/ui/gfx/rrect_f.cc
index ca363ecf62a..c9b643ca2f9 100644
--- a/chromium/ui/gfx/rrect_f.cc
+++ b/chromium/ui/gfx/rrect_f.cc
@@ -6,6 +6,7 @@
#include <iomanip>
#include <iostream>
+#include <sstream>
#include "base/strings/stringprintf.h"
#include "base/values.h"
diff --git a/chromium/ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm b/chromium/ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm
index 6b19d8cf85e..658f4c680d4 100644
--- a/chromium/ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm
+++ b/chromium/ui/gfx/scoped_ns_graphics_context_save_gstate_mac.mm
@@ -6,7 +6,7 @@
#import <AppKit/AppKit.h>
-#include "base/logging.h"
+#include "base/check_op.h"
namespace gfx {
diff --git a/chromium/ui/gfx/scoped_ui_graphics_push_context_ios.mm b/chromium/ui/gfx/scoped_ui_graphics_push_context_ios.mm
index 93cfde57d50..a5b9b951fb0 100644
--- a/chromium/ui/gfx/scoped_ui_graphics_push_context_ios.mm
+++ b/chromium/ui/gfx/scoped_ui_graphics_push_context_ios.mm
@@ -6,7 +6,7 @@
#import <UIKit/UIKit.h>
-#include "base/logging.h"
+#include "base/check_op.h"
namespace gfx {
diff --git a/chromium/ui/gfx/selection_model.cc b/chromium/ui/gfx/selection_model.cc
index 813bf2110ac..e91342bda1e 100644
--- a/chromium/ui/gfx/selection_model.cc
+++ b/chromium/ui/gfx/selection_model.cc
@@ -7,6 +7,7 @@
#include <ostream>
#include "base/format_macros.h"
+#include "base/logging.h"
#include "base/strings/stringprintf.h"
namespace gfx {
@@ -24,9 +25,34 @@ SelectionModel::SelectionModel(const Range& selection,
: selection_(selection),
caret_affinity_(affinity) {}
+SelectionModel::SelectionModel(const std::vector<Range>& selections,
+ LogicalCursorDirection affinity)
+ : selection_(selections[0]), caret_affinity_(affinity) {
+ for (size_t i = 1; i < selections.size(); ++i)
+ AddSecondarySelection(selections[i]);
+}
+
+SelectionModel::SelectionModel(const SelectionModel& selection_model) = default;
+
+SelectionModel::~SelectionModel() = default;
+
+void SelectionModel::AddSecondarySelection(const Range& selection) {
+ for (auto s : GetAllSelections())
+ DCHECK(!selection.Intersects(s));
+ secondary_selections_.push_back(selection);
+}
+
+std::vector<Range> SelectionModel::GetAllSelections() const {
+ std::vector<Range> selections = {selection()};
+ selections.insert(selections.end(), secondary_selections_.begin(),
+ secondary_selections_.end());
+ return selections;
+}
+
bool SelectionModel::operator==(const SelectionModel& sel) const {
- return selection_ == sel.selection() &&
- caret_affinity_ == sel.caret_affinity();
+ return selection() == sel.selection() &&
+ caret_affinity() == sel.caret_affinity() &&
+ secondary_selections() == sel.secondary_selections();
}
std::string SelectionModel::ToString() const {
@@ -36,7 +62,15 @@ std::string SelectionModel::ToString() const {
else
str += selection().ToString();
const bool backward = caret_affinity() == CURSOR_BACKWARD;
- return str + (backward ? ",BACKWARD}" : ",FORWARD}");
+ str += (backward ? ",BACKWARD" : ",FORWARD");
+ for (auto selection : secondary_selections()) {
+ str += ",";
+ if (selection.is_empty())
+ base::StringAppendF(&str, "%" PRIu32, selection.end());
+ else
+ str += selection.ToString();
+ }
+ return str + "}";
}
std::ostream& operator<<(std::ostream& out, const SelectionModel& model) {
diff --git a/chromium/ui/gfx/selection_model.h b/chromium/ui/gfx/selection_model.h
index b5cf6c6efc4..150b38ca129 100644
--- a/chromium/ui/gfx/selection_model.h
+++ b/chromium/ui/gfx/selection_model.h
@@ -6,6 +6,7 @@
#define UI_GFX_SELECTION_MODEL_H_
#include <stddef.h>
+#include <vector>
#include <iosfwd>
#include <string>
@@ -73,10 +74,25 @@ class GFX_EXPORT SelectionModel {
// Create a SelectionModel representing a selection (which may be empty).
// The caret position is the end of the range.
SelectionModel(const Range& selection, LogicalCursorDirection affinity);
+ // Create a SelectionModel representing multiple selections (which may be
+ // empty but not overlapping). The end of the first range determines the caret
+ // position.
+ SelectionModel(const std::vector<Range>& selections,
+ LogicalCursorDirection affinity);
+ SelectionModel(const SelectionModel& selection_model);
+ ~SelectionModel();
+
+ // |selection| should overlap with neither |selection_| nor
+ // |secondary_selections_|.
+ void AddSecondarySelection(const Range& selection);
const Range& selection() const { return selection_; }
size_t caret_pos() const { return selection_.end(); }
LogicalCursorDirection caret_affinity() const { return caret_affinity_; }
+ const std::vector<Range>& secondary_selections() const {
+ return secondary_selections_;
+ }
+ std::vector<Range> GetAllSelections() const;
// WARNING: Generally the selection start should not be changed without
// considering the effect on the caret affinity.
@@ -90,6 +106,8 @@ class GFX_EXPORT SelectionModel {
private:
// Logical selection. The logical caret position is the end of the selection.
Range selection_;
+ // Secondary selections not associated with the cursor. Do not overlap.
+ std::vector<Range> secondary_selections_;
// The logical direction from the caret position (selection_.end()) to the
// character it is attached to for display purposes. This matters only when
diff --git a/chromium/ui/gfx/selection_model_unittest.cc b/chromium/ui/gfx/selection_model_unittest.cc
new file mode 100644
index 00000000000..2147b2d12e1
--- /dev/null
+++ b/chromium/ui/gfx/selection_model_unittest.cc
@@ -0,0 +1,90 @@
+// Copyright (c) 2020 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 <vector>
+
+#include "ui/gfx/selection_model.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/range/range.h"
+
+namespace gfx {
+
+TEST(SelectionModelTest, Construction) {
+ {
+ SelectionModel selection_model;
+ EXPECT_EQ(selection_model.selection(), Range(0));
+ EXPECT_EQ(selection_model.caret_pos(), 0u);
+ EXPECT_EQ(selection_model.secondary_selections(), std::vector<Range>());
+ }
+ {
+ SelectionModel selection_model{5, CURSOR_FORWARD};
+ EXPECT_EQ(selection_model.selection(), Range(5));
+ EXPECT_EQ(selection_model.caret_pos(), 5u);
+ EXPECT_EQ(selection_model.secondary_selections(), std::vector<Range>());
+ }
+ {
+ SelectionModel selection_model{{3, 2}, CURSOR_BACKWARD};
+ EXPECT_EQ(selection_model.selection(), Range(3, 2));
+ EXPECT_EQ(selection_model.caret_pos(), 2u);
+ EXPECT_EQ(selection_model.secondary_selections(), std::vector<Range>());
+ }
+ {
+ SelectionModel selection_model{{{2, 3}, {5, 5}, {1, 0}}, CURSOR_BACKWARD};
+ EXPECT_EQ(selection_model.selection(), Range(2, 3));
+ EXPECT_EQ(selection_model.caret_pos(), 3u);
+ EXPECT_EQ(selection_model.secondary_selections(),
+ std::vector<Range>({{5, 5}, {1, 0}}));
+ }
+}
+
+TEST(SelectionModelTest, AddSecondarySelection) {
+ SelectionModel selection_model;
+ selection_model.AddSecondarySelection({5, 6});
+ selection_model.AddSecondarySelection({7, 6});
+ selection_model.AddSecondarySelection({8, 8});
+ EXPECT_EQ(selection_model.selection(), Range(0));
+ EXPECT_EQ(selection_model.caret_pos(), 0u);
+ EXPECT_EQ(selection_model.secondary_selections(),
+ std::vector<Range>({{5, 6}, {7, 6}, {8, 8}}));
+}
+
+TEST(SelectionModelTest, GetAllSelections) {
+ SelectionModel selection_model{{3, 2}, CURSOR_BACKWARD};
+ selection_model.AddSecondarySelection({5, 6});
+ selection_model.AddSecondarySelection({7, 6});
+ selection_model.AddSecondarySelection({8, 8});
+ EXPECT_EQ(selection_model.GetAllSelections(),
+ std::vector<Range>({{3, 2}, {5, 6}, {7, 6}, {8, 8}}));
+}
+
+TEST(SelectionModelTest, EqualityOperators) {
+ SelectionModel selection_model{{3, 2}, CURSOR_BACKWARD};
+ selection_model.AddSecondarySelection({5, 6});
+ selection_model.AddSecondarySelection({7, 6});
+ selection_model.AddSecondarySelection({8, 8});
+
+ // Equal
+ EXPECT_EQ(selection_model,
+ SelectionModel({{3, 2}, {5, 6}, {7, 6}, {8, 8}}, CURSOR_BACKWARD));
+ // Unequal selection
+ EXPECT_NE(selection_model,
+ SelectionModel({{3, 3}, {5, 6}, {7, 6}, {8, 8}}, CURSOR_BACKWARD));
+ // Unequal secondary selections
+ EXPECT_NE(selection_model,
+ SelectionModel({{3, 2}, {5, 6}, {7, 6}, {9, 8}}, CURSOR_BACKWARD));
+ // Unequal cursor affinity
+ EXPECT_NE(selection_model,
+ SelectionModel({{3, 2}, {5, 6}, {7, 6}, {8, 8}}, CURSOR_FORWARD));
+}
+
+TEST(SelectionModelTest, ToString) {
+ SelectionModel selection_model{{3, 2}, CURSOR_BACKWARD};
+ selection_model.AddSecondarySelection({5, 6});
+ selection_model.AddSecondarySelection({7, 6});
+ selection_model.AddSecondarySelection({8, 8});
+ EXPECT_EQ(selection_model.ToString(), "{{3,2},BACKWARD,{5,6},{7,6},8}");
+}
+
+} // namespace gfx
diff --git a/chromium/ui/gfx/sequential_id_generator.cc b/chromium/ui/gfx/sequential_id_generator.cc
index 86b9359580a..d8e7efb6862 100644
--- a/chromium/ui/gfx/sequential_id_generator.cc
+++ b/chromium/ui/gfx/sequential_id_generator.cc
@@ -4,7 +4,7 @@
#include "ui/gfx/sequential_id_generator.h"
-#include "base/logging.h"
+#include "base/check_op.h"
namespace {
diff --git a/chromium/ui/gfx/sequential_id_generator_unittest.cc b/chromium/ui/gfx/sequential_id_generator_unittest.cc
index c4f98b795b6..f36aa984023 100644
--- a/chromium/ui/gfx/sequential_id_generator_unittest.cc
+++ b/chromium/ui/gfx/sequential_id_generator_unittest.cc
@@ -6,7 +6,6 @@
#include <stdint.h>
-#include "base/logging.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace ui {
diff --git a/chromium/ui/gfx/skbitmap_operations.cc b/chromium/ui/gfx/skbitmap_operations.cc
index 5a370b68429..c08079f585b 100644
--- a/chromium/ui/gfx/skbitmap_operations.cc
+++ b/chromium/ui/gfx/skbitmap_operations.cc
@@ -9,7 +9,7 @@
#include <string.h>
#include <algorithm>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColorFilter.h"
diff --git a/chromium/ui/gfx/skia_color_space_util.cc b/chromium/ui/gfx/skia_color_space_util.cc
index 8eecdd61aa5..33e76c7e441 100644
--- a/chromium/ui/gfx/skia_color_space_util.cc
+++ b/chromium/ui/gfx/skia_color_space_util.cc
@@ -8,7 +8,6 @@
#include <cmath>
#include <vector>
-#include "base/logging.h"
#include "base/numerics/ranges.h"
namespace gfx {
diff --git a/chromium/ui/gfx/text_elider.cc b/chromium/ui/gfx/text_elider.cc
index 11a432aad1d..7d5574b4c47 100644
--- a/chromium/ui/gfx/text_elider.cc
+++ b/chromium/ui/gfx/text_elider.cc
@@ -16,11 +16,13 @@
#include <string>
#include <vector>
+#include "base/check_op.h"
#include "base/files/file_path.h"
#include "base/i18n/break_iterator.h"
#include "base/i18n/char_iterator.h"
#include "base/i18n/rtl.h"
#include "base/macros.h"
+#include "base/notreached.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/sys_string_conversions.h"
diff --git a/chromium/ui/gfx/text_utils.cc b/chromium/ui/gfx/text_utils.cc
index f78ae639d2a..fa062ea8972 100644
--- a/chromium/ui/gfx/text_utils.cc
+++ b/chromium/ui/gfx/text_utils.cc
@@ -8,7 +8,6 @@
#include "base/i18n/char_iterator.h"
#include "base/i18n/rtl.h"
-#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "third_party/icu/source/common/unicode/uchar.h"
#include "third_party/icu/source/common/unicode/utf16.h"
diff --git a/chromium/ui/gfx/text_utils_unittest.cc b/chromium/ui/gfx/text_utils_unittest.cc
index 1e01c908e72..564ec40bd0f 100644
--- a/chromium/ui/gfx/text_utils_unittest.cc
+++ b/chromium/ui/gfx/text_utils_unittest.cc
@@ -6,6 +6,7 @@
#include <stddef.h>
+#include "base/logging.h"
#include "base/stl_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
diff --git a/chromium/ui/gfx/transform.cc b/chromium/ui/gfx/transform.cc
index 95478ffe41e..e0f0b4a3925 100644
--- a/chromium/ui/gfx/transform.cc
+++ b/chromium/ui/gfx/transform.cc
@@ -4,7 +4,7 @@
#include "ui/gfx/transform.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/strings/stringprintf.h"
#include "ui/gfx/geometry/angle_conversions.h"
#include "ui/gfx/geometry/box_f.h"
diff --git a/chromium/ui/gfx/transform_unittest.cc b/chromium/ui/gfx/transform_unittest.cc
index fc68c9ca203..ee8406500b6 100644
--- a/chromium/ui/gfx/transform_unittest.cc
+++ b/chromium/ui/gfx/transform_unittest.cc
@@ -9,7 +9,6 @@
#include <limits>
#include <ostream>
-#include "base/logging.h"
#include "base/stl_util.h"
#include "build/build_config.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/chromium/ui/gfx/transform_util.cc b/chromium/ui/gfx/transform_util.cc
index 4f2cd393e08..17886ee1027 100644
--- a/chromium/ui/gfx/transform_util.cc
+++ b/chromium/ui/gfx/transform_util.cc
@@ -8,7 +8,7 @@
#include <cmath>
#include <string>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/strings/stringprintf.h"
#include "ui/gfx/geometry/point3_f.h"
#include "ui/gfx/geometry/rect.h"
diff --git a/chromium/ui/gfx/typemaps.gni b/chromium/ui/gfx/typemaps.gni
deleted file mode 100644
index 4646e0cb5a4..00000000000
--- a/chromium/ui/gfx/typemaps.gni
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-typemaps = [
- "//ui/gfx/geometry/mojom/geometry.typemap",
- "//ui/gfx/image/mojom/image.typemap",
- "//ui/gfx/mojom/accelerated_widget.typemap",
- "//ui/gfx/mojom/ca_layer_params.typemap",
- "//ui/gfx/mojom/color_space.typemap",
- "//ui/gfx/mojom/display_color_spaces.typemap",
- "//ui/gfx/mojom/font_render_params.typemap",
- "//ui/gfx/mojom/gpu_fence_handle.typemap",
- "//ui/gfx/mojom/overlay_transform.typemap",
- "//ui/gfx/mojom/presentation_feedback.typemap",
- "//ui/gfx/mojom/rrect_f.typemap",
- "//ui/gfx/mojom/selection_bound.typemap",
- "//ui/gfx/mojom/swap_result.typemap",
- "//ui/gfx/mojom/swap_timings.typemap",
- "//ui/gfx/mojom/transform.typemap",
- "//ui/gfx/range/mojom/range.typemap",
-]
diff --git a/chromium/ui/gfx/utf16_indexing.cc b/chromium/ui/gfx/utf16_indexing.cc
index c7f38de0d11..4515ff6a8bf 100644
--- a/chromium/ui/gfx/utf16_indexing.cc
+++ b/chromium/ui/gfx/utf16_indexing.cc
@@ -4,7 +4,7 @@
#include "ui/gfx/utf16_indexing.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/third_party/icu/icu_utf.h"
namespace gfx {
diff --git a/chromium/ui/gfx/vector_icon_types.h b/chromium/ui/gfx/vector_icon_types.h
index 39ac66407e5..6dc9842f254 100644
--- a/chromium/ui/gfx/vector_icon_types.h
+++ b/chromium/ui/gfx/vector_icon_types.h
@@ -46,7 +46,12 @@ namespace gfx {
DECLARE_VECTOR_COMMAND(CUBIC_TO) \
DECLARE_VECTOR_COMMAND(R_CUBIC_TO) \
DECLARE_VECTOR_COMMAND(CUBIC_TO_SHORTHAND) \
+ DECLARE_VECTOR_COMMAND(QUADRATIC_TO) \
+ DECLARE_VECTOR_COMMAND(R_QUADRATIC_TO) \
+ DECLARE_VECTOR_COMMAND(QUADRATIC_TO_SHORTHAND) \
+ DECLARE_VECTOR_COMMAND(R_QUADRATIC_TO_SHORTHAND) \
DECLARE_VECTOR_COMMAND(CIRCLE) \
+ DECLARE_VECTOR_COMMAND(OVAL) \
DECLARE_VECTOR_COMMAND(ROUND_RECT) \
DECLARE_VECTOR_COMMAND(CLOSE) \
/* Sets the dimensions of the canvas in dip. */ \
diff --git a/chromium/ui/gfx/win/direct_write.cc b/chromium/ui/gfx/win/direct_write.cc
index d0cfe585cfa..4f531c9f362 100644
--- a/chromium/ui/gfx/win/direct_write.cc
+++ b/chromium/ui/gfx/win/direct_write.cc
@@ -38,7 +38,7 @@ void CreateDWriteFactory(IDWriteFactory** factory) {
Microsoft::WRL::ComPtr<IUnknown> factory_unknown;
HRESULT hr =
DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory),
- factory_unknown.GetAddressOf());
+ &factory_unknown);
if (FAILED(hr)) {
base::debug::Alias(&hr);
CHECK(false);
@@ -55,7 +55,7 @@ void InitializeDirectWrite() {
TRACE_EVENT0("fonts", "gfx::InitializeDirectWrite");
Microsoft::WRL::ComPtr<IDWriteFactory> factory;
- CreateDWriteFactory(factory.GetAddressOf());
+ CreateDWriteFactory(&factory);
CHECK(!!factory);
SetDirectWriteFactory(factory.Get());
diff --git a/chromium/ui/gfx/win/hwnd_util.cc b/chromium/ui/gfx/win/hwnd_util.cc
index 2851da7dc6e..069968c3b24 100644
--- a/chromium/ui/gfx/win/hwnd_util.cc
+++ b/chromium/ui/gfx/win/hwnd_util.cc
@@ -4,6 +4,7 @@
#include "ui/gfx/win/hwnd_util.h"
+#include "base/logging.h"
#include "base/strings/string_util.h"
#include "base/win/win_util.h"
#include "ui/gfx/geometry/rect.h"
diff --git a/chromium/ui/gfx/win/physical_size.cc b/chromium/ui/gfx/win/physical_size.cc
index dcdee562e89..39978f73939 100644
--- a/chromium/ui/gfx/win/physical_size.cc
+++ b/chromium/ui/gfx/win/physical_size.cc
@@ -10,7 +10,7 @@
#include <iostream>
#include <memory>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/memory/free_deleter.h"
#include "base/scoped_generic.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chromium/ui/gfx/win/text_analysis_source.cc b/chromium/ui/gfx/win/text_analysis_source.cc
index 0f9779e0756..567f54538d8 100644
--- a/chromium/ui/gfx/win/text_analysis_source.cc
+++ b/chromium/ui/gfx/win/text_analysis_source.cc
@@ -4,7 +4,7 @@
#include "ui/gfx/win/text_analysis_source.h"
-#include "base/logging.h"
+#include "base/check.h"
namespace gfx {
namespace win {
diff --git a/chromium/ui/gfx/win/window_impl.cc b/chromium/ui/gfx/win/window_impl.cc
index c041be9ce53..8df35cdc651 100644
--- a/chromium/ui/gfx/win/window_impl.cc
+++ b/chromium/ui/gfx/win/window_impl.cc
@@ -10,7 +10,9 @@
#include "base/debug/alias.h"
#include "base/macros.h"
#include "base/memory/singleton.h"
+#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_util.h"
#include "base/synchronization/lock.h"
#include "base/win/win_util.h"
#include "base/win/wrapped_window_proc.h"
@@ -135,7 +137,16 @@ ATOM ClassRegistrar::RetrieveClassAtom(const ClassInfo& class_info) {
class_info.icon, class_info.small_icon, &window_class);
HMODULE instance = window_class.hInstance;
ATOM atom = RegisterClassEx(&window_class);
- CHECK(atom) << GetLastError();
+ if (!atom) {
+ // Perhaps the Window session has run out of atoms; see
+ // https://crbug.com/653493.
+ auto last_error = ::GetLastError();
+ base::debug::Alias(&last_error);
+ wchar_t name_copy[64];
+ base::wcslcpy(name_copy, name.c_str(), base::size(name_copy));
+ base::debug::Alias(name_copy);
+ PCHECK(atom);
+ }
registered_classes_.push_back(RegisteredClass(
class_info, name, atom, instance));
diff --git a/chromium/ui/gfx/x/.style.yapf b/chromium/ui/gfx/x/.style.yapf
new file mode 100644
index 00000000000..557fa7bf84c
--- /dev/null
+++ b/chromium/ui/gfx/x/.style.yapf
@@ -0,0 +1,2 @@
+[style]
+based_on_style = pep8
diff --git a/chromium/ui/gfx/x/BUILD.gn b/chromium/ui/gfx/x/BUILD.gn
index f6ecc758ab8..5369e38efed 100644
--- a/chromium/ui/gfx/x/BUILD.gn
+++ b/chromium/ui/gfx/x/BUILD.gn
@@ -3,36 +3,131 @@
# found in the LICENSE file.
import("//build/config/jumbo.gni")
+import("//build/config/sysroot.gni")
import("//build/config/ui.gni")
import("//ui/ozone/ozone.gni")
assert(use_x11 || ozone_platform_x11)
+declare_args() {
+ xcbproto_path = ""
+}
+
+if (xcbproto_path == "") {
+ if (use_sysroot) {
+ xcbproto_path = "$sysroot/usr/share/xcb"
+ } else {
+ xcbproto_path = "/usr/share/xcb"
+ }
+}
+
+config("x11_private_config") {
+ cflags = [
+ # Generated proto files pull all fields from a struct into scope
+ # even if they aren't used. Rather than adding logic in the
+ # generator to determine which fields are used and keeping only
+ # those, simply ignore unused variable warnings.
+ "-Wno-unused-variable",
+ ]
+ defines = [ "IS_X11_IMPL" ]
+}
+
+action_foreach("gen_xprotos") {
+ visibility = [ ":xprotos" ]
+ script = "gen_xproto.py"
+ sources = [
+ "$xcbproto_path/bigreq.xml",
+ "$xcbproto_path/composite.xml",
+ "$xcbproto_path/damage.xml",
+ "$xcbproto_path/dpms.xml",
+ "$xcbproto_path/dri2.xml",
+ "$xcbproto_path/dri3.xml",
+ "$xcbproto_path/ge.xml",
+ "$xcbproto_path/glx.xml",
+ "$xcbproto_path/present.xml",
+ "$xcbproto_path/randr.xml",
+ "$xcbproto_path/record.xml",
+ "$xcbproto_path/render.xml",
+ "$xcbproto_path/res.xml",
+ "$xcbproto_path/screensaver.xml",
+ "$xcbproto_path/shape.xml",
+ "$xcbproto_path/shm.xml",
+ "$xcbproto_path/sync.xml",
+ "$xcbproto_path/xc_misc.xml",
+ "$xcbproto_path/xevie.xml",
+ "$xcbproto_path/xf86dri.xml",
+ "$xcbproto_path/xf86vidmode.xml",
+ "$xcbproto_path/xfixes.xml",
+ "$xcbproto_path/xinerama.xml",
+ "$xcbproto_path/xinput.xml",
+ "$xcbproto_path/xkb.xml",
+ "$xcbproto_path/xprint.xml",
+ "$xcbproto_path/xproto.xml",
+ "$xcbproto_path/xselinux.xml",
+ "$xcbproto_path/xtest.xml",
+ "$xcbproto_path/xv.xml",
+ "$xcbproto_path/xvmc.xml",
+ ]
+ outputs = [
+ "$target_gen_dir/{{source_name_part}}_undef.h",
+ "$target_gen_dir/{{source_name_part}}.h",
+ "$target_gen_dir/{{source_name_part}}.cc",
+ ]
+ args = [ "{{source}}" ] + rebase_path(outputs, root_build_dir)
+ if (use_sysroot) {
+ args += [
+ "--sysroot",
+ rebase_path(sysroot, root_build_dir),
+ ]
+ }
+}
+
+component("xprotos") {
+ deps = [
+ ":gen_xprotos",
+ "//base",
+ ]
+ sources = get_target_outputs(":gen_xprotos") + [
+ "xproto_internal.h",
+ "xproto_types.h",
+ "request_queue.h",
+ "request_queue.cc",
+ "xproto_util.h",
+ "xproto_util.cc",
+ "connection.h",
+ "connection.cc",
+ "x11_switches.cc",
+ "x11_switches.h",
+ ]
+ configs += [
+ ":x11_private_config",
+ "//build/config/linux:x11",
+ ]
+}
+
jumbo_component("x") {
output_name = "gfx_x11"
sources = [
"../gfx_export.h",
+ "x11.h",
"x11_atom_cache.cc",
"x11_atom_cache.h",
- "x11_connection.cc",
- "x11_connection.h",
"x11_error_tracker.cc",
"x11_error_tracker.h",
"x11_path.cc",
"x11_path.h",
- "x11_switches.cc",
- "x11_switches.h",
"x11_types.cc",
"x11_types.h",
]
defines = [ "GFX_IMPLEMENTATION" ]
- configs += [ "//build/config/linux:x11" ]
+ public_configs = [ "//build/config/linux:x11" ]
deps = [
"//base",
"//skia",
]
+ public_deps = [ ":xprotos" ]
}
diff --git a/chromium/ui/gfx/x/connection.cc b/chromium/ui/gfx/x/connection.cc
new file mode 100644
index 00000000000..6dd336cac57
--- /dev/null
+++ b/chromium/ui/gfx/x/connection.cc
@@ -0,0 +1,32 @@
+// Copyright 2020 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 "ui/gfx/x/connection.h"
+
+#include "base/command_line.h"
+#include "ui/gfx/x/x11_switches.h"
+
+namespace x11 {
+
+namespace {
+
+XDisplay* OpenNewXDisplay() {
+ if (!XInitThreads())
+ return nullptr;
+ std::string display_str =
+ base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
+ switches::kX11Display);
+ return XOpenDisplay(display_str.empty() ? nullptr : display_str.c_str());
+}
+
+} // namespace
+
+Connection* Connection::Get() {
+ static Connection* instance = new Connection(OpenNewXDisplay());
+ return instance;
+}
+
+Connection::Connection(XDisplay* display) : XProto(display) {}
+
+} // namespace x11
diff --git a/chromium/ui/gfx/x/connection.h b/chromium/ui/gfx/x/connection.h
new file mode 100644
index 00000000000..2e9baf64464
--- /dev/null
+++ b/chromium/ui/gfx/x/connection.h
@@ -0,0 +1,31 @@
+// Copyright 2020 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 UI_GFX_X_CONNECTION_H_
+#define UI_GFX_X_CONNECTION_H_
+
+#include "base/component_export.h"
+#include "ui/gfx/x/xproto.h"
+
+namespace x11 {
+
+using Atom = XProto::Atom;
+using Window = XProto::Window;
+
+// Represents a socket to the X11 server.
+class COMPONENT_EXPORT(X11) Connection : public XProto {
+ public:
+ // Gets or creates the singeton connection.
+ static Connection* Get();
+
+ Connection(const Connection&) = delete;
+ Connection(Connection&&) = delete;
+
+ private:
+ explicit Connection(XDisplay* display);
+};
+
+} // namespace x11
+
+#endif // UI_GFX_X_CONNECTION_H_
diff --git a/chromium/ui/gfx/x/gen_xproto.py b/chromium/ui/gfx/x/gen_xproto.py
new file mode 100644
index 00000000000..4a34901012d
--- /dev/null
+++ b/chromium/ui/gfx/x/gen_xproto.py
@@ -0,0 +1,1028 @@
+# Copyright 2020 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.
+
+# This script generates header/source files with C++ language bindings
+# for the X11 protocol and its extensions. The protocol information
+# is obtained from xcbproto which provides XML files describing the
+# wire format. However, we don't parse the XML here; xcbproto ships
+# with xcbgen, a python library that parses the files into python data
+# structures for us.
+#
+# The generated header and source files will look like this:
+
+# #ifndef GEN_UI_GFX_X_XPROTO_H_
+# #define GEN_UI_GFX_X_XPROTO_H_
+#
+# #include <array>
+# #include <cstddef>
+# #include <cstdint>
+# #include <cstring>
+# #include <vector>
+#
+# #include "base/component_export.h"
+# #include "ui/gfx/x/xproto_types.h"
+#
+# typedef struct _XDisplay XDisplay;
+#
+# namespace x11 {
+#
+# class COMPONENT_EXPORT(X11) XProto {
+# public:
+# explicit XProto(XDisplay* display);
+#
+# XDisplay* display() { return display_; }
+#
+# struct RGB {
+# uint16_t red{};
+# uint16_t green{};
+# uint16_t blue{};
+# };
+#
+# struct QueryColorsRequest {
+# uint32_t cmap{};
+# std::vector<uint32_t> pixels{};
+# };
+#
+# struct QueryColorsReply {
+# uint16_t colors_len{};
+# std::vector<RGB> colors{};
+# };
+#
+# using QueryColorsResponse = Response<QueryColorsReply>;
+#
+# Future<QueryColorsReply> QueryColors(const QueryColorsRequest& request);
+#
+# private:
+# XDisplay* display_;
+# };
+#
+# } // namespace x11
+#
+# #endif // GEN_UI_GFX_X_XPROTO_H_
+
+# #include "xproto.h"
+#
+# #include <xcb/xcb.h>
+# #include <xcb/xcbext.h>
+#
+# #include "base/logging.h"
+# #include "ui/gfx/x/xproto_internal.h"
+#
+# namespace x11 {
+#
+# XProto::XProto(XDisplay* display) : display_(display) {}
+#
+# Future<XProto::QueryColorsReply>
+# XProto::QueryColors(
+# const XProto::QueryColorsRequest& request) {
+# WriteBuffer buf;
+#
+# auto& cmap = request.cmap;
+# auto& pixels = request.pixels;
+# size_t pixels_len = pixels.size();
+#
+# // major_opcode
+# uint8_t major_opcode = 91;
+# Write(&major_opcode, &buf);
+#
+# // pad0
+# Pad(&buf, 1);
+#
+# // length
+# // Caller fills in length for writes.
+# Pad(&buf, sizeof(uint16_t));
+#
+# // cmap
+# Write(&cmap, &buf);
+#
+# // pixels
+# DCHECK_EQ(static_cast<size_t>(pixels_len), pixels.size());
+# for (auto& pixels_elem : pixels) {
+# Write(&pixels_elem, &buf);
+# }
+#
+# return x11::SendRequest<XProto::QueryColorsReply>(display_, &buf);
+# }
+#
+# template<> COMPONENT_EXPORT(X11)
+# std::unique_ptr<XProto::QueryColorsReply>
+# detail::ReadReply<XProto::QueryColorsReply>(const uint8_t* buffer) {
+# ReadBuffer buf{buffer, 0UL};
+# auto reply = std::make_unique<XProto::QueryColorsReply>();
+#
+# auto& colors_len = (*reply).colors_len;
+# auto& colors = (*reply).colors;
+#
+# // response_type
+# uint8_t response_type;
+# Read(&response_type, &buf);
+#
+# // pad0
+# Pad(&buf, 1);
+#
+# // sequence
+# uint16_t sequence;
+# Read(&sequence, &buf);
+#
+# // length
+# uint32_t length;
+# Read(&length, &buf);
+#
+# // colors_len
+# Read(&colors_len, &buf);
+#
+# // pad1
+# Pad(&buf, 22);
+#
+# // colors
+# colors.resize(colors_len);
+# for (auto& colors_elem : colors) {
+# auto& red = colors_elem.red;
+# auto& green = colors_elem.green;
+# auto& blue = colors_elem.blue;
+#
+# // red
+# Read(&red, &buf);
+#
+# // green
+# Read(&green, &buf);
+#
+# // blue
+# Read(&blue, &buf);
+#
+# // pad0
+# Pad(&buf, 2);
+#
+# }
+#
+# Align(&buf, 4);
+# DCHECK_EQ(buf.offset < 32 ? 0 : buf.offset - 32, 4 * length);
+#
+# return reply;
+# }
+#
+# } // namespace x11
+
+from __future__ import print_function
+
+import argparse
+import collections
+import os
+import re
+import sys
+import types
+
+# __main__.output must be defined before importing xcbgen,
+# so this global is unavoidable.
+output = collections.defaultdict(int)
+
+UPPER_CASE_PATTERN = re.compile(r'^[A-Z0-9_]+$')
+
+
+def adjust_type_case(name):
+ if UPPER_CASE_PATTERN.match(name):
+ SPECIAL = {
+ 'ANIMCURSORELT': 'AnimationCursorElement',
+ 'CA': 'ChangeAlarmAttribute',
+ 'CHAR2B': 'Char16',
+ 'CHARINFO': 'CharInfo',
+ 'COLORITEM': 'ColorItem',
+ 'COLORMAP': 'ColorMap',
+ 'CP': 'CreatePictureAttribute',
+ 'CW': 'CreateWindowAttribute',
+ 'DAMAGE': 'DamageId',
+ 'DIRECTFORMAT': 'DirectFormat',
+ 'DOTCLOCK': 'DotClock',
+ 'FBCONFIG': 'FbConfig',
+ 'FLOAT32': 'float',
+ 'FLOAT64': 'double',
+ 'FONTPROP': 'FontProperty',
+ 'GC': 'GraphicsContextAttribute',
+ 'GCONTEXT': 'GraphicsContext',
+ 'GLYPHINFO': 'GlyphInfo',
+ 'GLYPHSET': 'GlyphSet',
+ 'INDEXVALUE': 'IndexValue',
+ 'KB': 'Keyboard',
+ 'KEYCODE': 'KeyCode',
+ 'KEYCODE32': 'KeyCode32',
+ 'KEYSYM': 'KeySym',
+ 'LINEFIX': 'LineFix',
+ 'OP': 'Operation',
+ 'PBUFFER': 'PBuffer',
+ 'PCONTEXT': 'PContext',
+ 'PICTDEPTH': 'PictDepth',
+ 'PICTFORMAT': 'PictFormat',
+ 'PICTFORMINFO': 'PictFormInfo',
+ 'PICTSCREEN': 'PictScreen',
+ 'PICTVISUAL': 'PictVisual',
+ 'POINTFIX': 'PointFix',
+ 'SEGMENT': 'SEGMENT',
+ 'SPANFIX': 'SpanFix',
+ 'SUBPICTURE': 'SubPicture',
+ 'SYSTEMCOUNTER': 'SystemCounter',
+ 'TIMECOORD': 'TimeCoord',
+ 'TIMESTAMP': 'TimeStamp',
+ 'VISUALID': 'VisualId',
+ 'VISUALTYPE': 'VisualType',
+ 'WAITCONDITION': 'WaitCondition',
+ }
+ if name in SPECIAL:
+ return SPECIAL[name]
+ return ''.join([
+ token[0].upper() + token[1:].lower() for token in name.split('_')
+ ])
+ return name
+
+
+# Left-pad with 2 spaces while this class is alive.
+class Indent:
+ def __init__(self, xproto, opening_line, closing_line):
+ self.xproto = xproto
+ self.opening_line = opening_line
+ self.closing_line = closing_line
+
+ def __enter__(self):
+ self.xproto.write(self.opening_line)
+ self.xproto.indent += 1
+
+ def __exit__(self, exc_type, exc_value, exc_traceback):
+ self.xproto.indent -= 1
+ self.xproto.write(self.closing_line)
+
+
+class NullContext:
+ def __init__(self):
+ pass
+
+ def __enter__(self):
+ pass
+
+ def __exit__(self, exc_type, exc_value, exc_traceback):
+ pass
+
+
+# Make all members of |obj|, given by |fields|, visible in
+# the local scope while this class is alive.
+class ScopedFields:
+ def __init__(self, xproto, obj, fields):
+ self.xproto = xproto
+ self.obj = obj
+ self.fields = fields
+ self.n_pushed = 0
+
+ def __enter__(self):
+ for field in self.fields:
+ self.n_pushed += self.xproto.add_field_to_scope(field, self.obj)
+
+ if self.n_pushed:
+ self.xproto.write()
+
+ def __exit__(self, exc_type, exc_value, exc_traceback):
+ for _ in range(self.n_pushed):
+ self.xproto.scope.pop()
+
+
+# Ensures |name| is usable as a C++ field by avoiding keywords and
+# symbols that start with numbers.
+def safe_name(name):
+ RESERVED = [
+ 'and',
+ 'xor',
+ 'or',
+ 'class',
+ 'explicit',
+ 'new',
+ 'delete',
+ 'default',
+ 'private',
+ ]
+ if name[0].isdigit() or name in RESERVED:
+ return 'c_' + name
+ return name
+
+
+class GenXproto:
+ def __init__(self, args, xcbgen):
+ # Command line arguments
+ self.args = args
+
+ # Top-level xcbgen python module
+ self.xcbgen = xcbgen
+
+ # The last used UID for making unique names
+ self.prev_id = -1
+
+ # Current indentation level
+ self.indent = 0
+
+ # Current file to write to
+ self.file = None
+
+ # Flag to indicate if we're generating code to serialize or
+ # deserialize data.
+ self.is_read = False
+
+ # List of the fields in scope
+ self.scope = []
+
+ # Current place in C++ namespace hierarchy (including classes)
+ self.namespace = []
+
+ # Map from type names to a set of types. Certain types
+ # like enums and simple types can alias each other.
+ self.types = collections.defaultdict(set)
+
+ # Set of names of simple types to be replaced with enums
+ self.replace_with_enum = set()
+
+ # Map of enums to their underlying types
+ self.enum_types = collections.defaultdict(set)
+
+ # Write a line to the current file.
+ def write(self, line=''):
+ indent = self.indent if line and not line.startswith('#') else 0
+ print((' ' * indent) + line, file=self.file)
+
+ # Geenerate an ID suitable for use in temporary variable names.
+ def new_uid(self, ):
+ self.prev_id += 1
+ return self.prev_id
+
+ def type_suffix(self, t):
+ if isinstance(t, self.xcbgen.xtypes.Error):
+ return 'Error'
+ elif isinstance(t, self.xcbgen.xtypes.Request):
+ return 'Request'
+ elif t.is_reply:
+ return 'Reply'
+ elif t.is_event:
+ return 'Event'
+ return ''
+
+ def rename_type(self, t, name):
+ name = list(name)
+ for i in range(1, len(name)):
+ name[i] = adjust_type_case(name[i])
+ name[-1] += self.type_suffix(t)
+ return name
+
+ # Given an xcbgen.xtypes.Type, returns a C++-namespace-qualified
+ # string that looks like Input::InputClass::Key.
+ def qualtype(self, t, name):
+ # Work around a bug in xcbgen: ('int') should have been ('int',)
+ if name == 'int':
+ name = ('int', )
+
+ name = self.rename_type(t, name)
+
+ if name[0] == 'xcb':
+ # Use namespace x11 instead of xcb.
+ name[0] = 'x11'
+
+ # We want the non-extension X11 structures to live in a class too.
+ if len(name) == 2:
+ name[1:1] = ['XProto']
+
+ # Try to avoid adding namespace qualifiers if they're not necessary.
+ chop = 0
+ for t1, t2 in zip(name, self.namespace):
+ if t1 != t2:
+ break
+ chop += 1
+ return '::'.join(name[chop:])
+
+ def fieldtype(self, field):
+ return self.qualtype(field.type, field.field_type)
+
+ def add_field_to_scope(self, field, obj):
+ if not field.visible or not field.wire:
+ return 0
+
+ self.scope.append(field)
+
+ field_name = safe_name(field.field_name)
+ # There's one case where we would have generated:
+ # auto& enable = enable.enable;
+ # To prevent a compiler error from trying to use the variable
+ # in its own definition, save to a temporary variable first.
+ if field_name == obj:
+ tmp_id = self.new_uid()
+ self.write('auto& tmp%d = %s.%s;' % (tmp_id, obj, field_name))
+ self.write('auto& %s = tmp%d;' % (field_name, tmp_id))
+ elif field.for_list:
+ self.write('%s %s;' % (self.fieldtype(field), field_name))
+ else:
+ self.write('auto& %s = %s.%s;' % (field_name, obj, field_name))
+
+ if field.type.is_list:
+ len_name = field_name + '_len'
+ if not self.field_from_scope(len_name):
+ self.write('size_t %s = %s.size();' % (len_name, field_name))
+
+ return 1
+
+ # Lookup |name| in the current scope. Returns the deepest
+ # (most local) occurrence of |name|.
+ def field_from_scope(self, name):
+ for field in reversed(self.scope):
+ if field.field_name == name:
+ return field
+ return None
+
+ # Work around conflicts caused by Xlib's liberal use of macros.
+ def undef(self, name):
+ print('#ifdef %s' % name, file=self.args.undeffile)
+ print('#undef %s' % name, file=self.args.undeffile)
+ print('#endif', file=self.args.undeffile)
+
+ def expr(self, expr):
+ if expr.op == 'popcount':
+ return 'PopCount(%s)' % self.expr(expr.rhs)
+ if expr.op == '~':
+ return 'BitNot(%s)' % self.expr(expr.rhs)
+ if expr.op == '&':
+ return 'BitAnd(%s, %s)' % (self.expr(expr.lhs), self.expr(
+ expr.rhs))
+ if expr.op in ('+', '-', '*', '/', '|'):
+ return ('(%s) %s (%s)' %
+ (self.expr(expr.lhs), expr.op, self.expr(expr.rhs)))
+ if expr.op == 'calculate_len':
+ return expr.lenfield_name
+ if expr.op == 'sumof':
+ tmp_id = self.new_uid()
+ lenfield = self.field_from_scope(expr.lenfield_name)
+ elem_type = lenfield.type.member
+ fields = elem_type.fields if elem_type.is_container else []
+ header = 'auto sum%d_ = SumOf([](%sauto& listelem_ref) {' % (
+ tmp_id, '' if self.is_read else 'const ')
+ footer = '}, %s);' % expr.lenfield_name
+ with Indent(self, header,
+ footer), ScopedFields(self, 'listelem_ref', fields):
+ body = self.expr(expr.rhs) if expr.rhs else 'listelem_ref'
+ self.write('return %s;' % body)
+ return 'sum%d_' % tmp_id
+ if expr.op == 'listelement-ref':
+ return 'listelem_ref'
+ if expr.op == 'enumref':
+ return '%s::%s' % (self.qualtype(
+ expr.lenfield_type,
+ expr.lenfield_type.name), safe_name(expr.lenfield_name))
+
+ assert expr.op == None
+ if expr.nmemb:
+ return str(expr.nmemb)
+
+ assert expr.lenfield_name
+ return expr.lenfield_name
+
+ def declare_simple(self, item, name):
+ # The underlying type of an enum must be integral, so avoid defining
+ # FLOAT32 or FLOAT64. Usages are renamed to float and double instead.
+ renamed = tuple(self.rename_type(item, name))
+ if name[-1] not in ('FLOAT32', 'FLOAT64'
+ ) and renamed not in self.replace_with_enum:
+ self.write(
+ 'enum class %s : %s {};' %
+ (adjust_type_case(name[-1]), self.qualtype(item, item.name)))
+ self.write()
+
+ def copy_primitive(self, name):
+ self.write('%s(&%s, &buf);' %
+ ('Read' if self.is_read else 'Write', name))
+
+ def copy_special_field(self, field):
+ type_name = self.fieldtype(field)
+ name = safe_name(field.field_name)
+
+ if name in ('major_opcode', 'minor_opcode'):
+ assert not self.is_read
+ is_ext = any(
+ [f.field_name == 'minor_opcode' for f in field.parent.fields])
+ if is_ext and name == 'major_opcode':
+ self.write('// Caller fills in extension major opcode.')
+ self.write('Pad(&buf, sizeof(%s));' % type_name)
+ else:
+ self.write('%s %s = %s;' %
+ (type_name, name, field.parent.opcode))
+ self.copy_primitive(name)
+ elif name in ('response_type', 'sequence', 'extension'):
+ assert self.is_read
+ self.write('%s %s;' % (type_name, name))
+ self.copy_primitive(name)
+ elif name == 'length':
+ if not self.is_read:
+ self.write('// Caller fills in length for writes.')
+ self.write('Pad(&buf, sizeof(%s));' % type_name)
+ else:
+ self.write('%s %s;' % (type_name, name))
+ self.copy_primitive(name)
+ else:
+ assert field.type.is_expr
+ assert (not isinstance(field.type, self.xcbgen.xtypes.Enum))
+ self.write('%s %s = %s;' %
+ (type_name, name, self.expr(field.type.expr)))
+ self.copy_primitive(name)
+
+ def declare_case(self, case):
+ assert case.type.is_case != case.type.is_bitcase
+
+ with (Indent(self, 'struct {', '} %s;' % safe_name(case.field_name))
+ if case.field_name else NullContext()):
+ for case_field in case.type.fields:
+ self.declare_field(case_field)
+
+ def copy_case(self, case, switch_var):
+ op = 'CaseEq' if case.type.is_case else 'BitAnd'
+ condition = ' || '.join([
+ '%s(%s, %s)' % (op, switch_var, self.expr(expr))
+ for expr in case.type.expr
+ ])
+
+ with Indent(self, 'if (%s) {' % condition, '}'):
+ with (ScopedFields(self, case.field_name, case.type.fields)
+ if case.field_name else NullContext()):
+ for case_field in case.type.fields:
+ assert case_field.wire
+ self.copy_field(case_field)
+
+ def declare_switch(self, field):
+ t = field.type
+ name = safe_name(field.field_name)
+
+ with Indent(self, 'struct {', '} %s;' % name):
+ for case in t.bitcases:
+ self.declare_case(case)
+
+ def copy_switch(self, field):
+ t = field.type
+ name = safe_name(field.field_name)
+
+ scope_fields = []
+ for case in t.bitcases:
+ if case.field_name:
+ scope_fields.append(case)
+ else:
+ scope_fields.extend(case.type.fields)
+ with Indent(self, '{', '}'), ScopedFields(self, name, scope_fields):
+ switch_var = name + '_expr'
+ self.write('auto %s = %s;' % (switch_var, self.expr(t.expr)))
+ for case in t.bitcases:
+ self.copy_case(case, switch_var)
+
+ def declare_list(self, field):
+ t = field.type
+ type_name = self.fieldtype(field)
+ name = safe_name(field.field_name)
+
+ assert (t.nmemb not in (0, 1))
+ if t.nmemb:
+ type_name = 'std::array<%s, %d>' % (type_name, t.nmemb)
+ else:
+ if type_name == 'void':
+ # xcb uses void* in some places, but we prefer to use
+ # std::vector<T> when possible. Use T=uint8_t instead of
+ # T=void for containers.
+ type_name = 'std::vector<uint8_t>'
+ elif type_name == 'char':
+ type_name = 'std::string'
+ else:
+ type_name = 'std::vector<%s>' % type_name
+ self.write('%s %s{};' % (type_name, name))
+
+ def copy_list(self, field):
+ t = field.type
+ name = safe_name(field.field_name)
+
+ if not t.nmemb:
+ size = self.expr(t.expr)
+ if self.is_read:
+ self.write('%s.resize(%s);' % (name, size))
+ else:
+ left = 'static_cast<size_t>(%s)' % size
+ self.write('DCHECK_EQ(%s, %s.size());' % (left, name))
+ with Indent(self, 'for (auto& %s_elem : %s) {' % (name, name), '}'):
+ elem_name = name + '_elem'
+ elem_type = t.member
+ if elem_type.is_simple or elem_type.is_union:
+ assert (not isinstance(elem_type, self.xcbgen.xtypes.Enum))
+ self.copy_primitive(elem_name)
+ else:
+ assert elem_type.is_container
+ self.copy_container(elem_type, elem_name)
+
+ def declare_field(self, field):
+ t = field.type
+ name = safe_name(field.field_name)
+
+ if not field.wire or not field.visible or field.for_list:
+ return
+
+ if t.is_switch:
+ self.declare_switch(field)
+ elif t.is_list:
+ self.declare_list(field)
+ else:
+ self.write(
+ '%s %s{};' %
+ (self.qualtype(field.type, field.enum
+ if field.enum else field.field_type), name))
+
+ def copy_field(self, field):
+ t = field.type
+ name = safe_name(field.field_name)
+
+ self.write('// ' + name)
+ if t.is_pad:
+ if t.align > 1:
+ assert t.nmemb == 1
+ assert t.align in (2, 4)
+ self.write('Align(&buf, %d);' % t.align)
+ else:
+ self.write('Pad(&buf, %d);' % t.nmemb)
+ elif not field.visible:
+ self.copy_special_field(field)
+ elif field.for_list:
+ if not self.is_read:
+ self.write('%s = %s.size();' %
+ (name, safe_name(field.for_list.field_name)))
+ self.copy_primitive(name)
+ elif t.is_switch:
+ self.copy_switch(field)
+ elif t.is_list:
+ self.copy_list(field)
+ elif t.is_union:
+ self.copy_primitive(name)
+ elif t.is_container:
+ with Indent(self, '{', '}'):
+ self.copy_container(t, name)
+ else:
+ assert t.is_simple
+ if field.enum:
+ self.copy_enum(field)
+ else:
+ self.copy_primitive(name)
+
+ def declare_enum(self, enum):
+ def declare_enum_entry(name, value):
+ name = safe_name(name)
+ self.undef(name)
+ self.write('%s = %s,' % (name, value))
+
+ self.undef(enum.name[-1])
+ with Indent(
+ self, 'enum class %s : %s {' %
+ (adjust_type_case(enum.name[-1]), self.enum_types[enum.name][0]
+ if enum.name in self.enum_types else 'int'), '};'):
+ bitnames = set([name for name, _ in enum.bits])
+ for name, value in enum.values:
+ if name not in bitnames:
+ declare_enum_entry(name, value)
+ for name, value in enum.bits:
+ declare_enum_entry(name, '1 << ' + value)
+ self.write()
+
+ def copy_enum(self, field):
+ # The size of enum types may be different depending on the
+ # context, so they should always be casted to the contextual
+ # underlying type before calling Read() or Write().
+ underlying_type = self.fieldtype(field)
+ tmp_name = 'tmp%d' % self.new_uid()
+ real_name = safe_name(field.field_name)
+ self.write('%s %s;' % (underlying_type, tmp_name))
+ if not self.is_read:
+ self.write('%s = static_cast<%s>(%s);' %
+ (tmp_name, underlying_type, real_name))
+ self.copy_primitive(tmp_name)
+ if self.is_read:
+ enum_type = self.qualtype(field.type, field.enum)
+ self.write('%s = static_cast<%s>(%s);' %
+ (real_name, enum_type, tmp_name))
+
+ def declare_container(self, struct):
+ name = struct.name[-1] + self.type_suffix(struct)
+ self.undef(name)
+ with Indent(self, 'struct %s {' % adjust_type_case(name), '};'):
+ for field in struct.fields:
+ self.declare_field(field)
+ self.write()
+
+ def copy_container(self, struct, name):
+ assert not struct.is_union
+ with ScopedFields(self, name, struct.fields):
+ for field in struct.fields:
+ if field.wire:
+ self.copy_field(field)
+ self.write()
+
+ def declare_union(self, union):
+ name = union.name[-1]
+ with Indent(self, 'union %s {' % name, '};'):
+ self.write('%s() { memset(this, 0, sizeof(*this)); }' % name)
+ self.write()
+ for field in union.fields:
+ type_name = self.fieldtype(field)
+ self.write('%s %s;' % (type_name, safe_name(field.field_name)))
+ self.write(
+ 'static_assert(std::is_trivially_copyable<%s>::value, "");' % name)
+ self.write()
+
+ def declare_request(self, request):
+ method_name = request.name[-1]
+ request_name = method_name + 'Request'
+ reply_name = method_name + 'Reply'
+
+ self.declare_container(request)
+ if request.reply:
+ self.declare_container(request.reply)
+ else:
+ reply_name = 'void'
+
+ self.write('using %sResponse = Response<%s>;' %
+ (method_name, reply_name))
+ self.write()
+
+ self.write('Future<%s> %s(' % (reply_name, method_name))
+ self.write(' const %s& request);' % request_name)
+ self.write()
+
+ def define_request(self, request):
+ method_name = '%s::%s' % (self.class_name, request.name[-1])
+ request_name = method_name + 'Request'
+ reply_name = method_name + 'Reply'
+
+ reply = request.reply
+ if not reply:
+ reply_name = 'void'
+
+ self.write('Future<%s>' % reply_name)
+ self.write('%s(' % method_name)
+ with Indent(self, ' const %s& request) {' % request_name, '}'):
+ self.namespace = ['x11', self.class_name]
+ self.write('WriteBuffer buf;')
+ self.write()
+ self.is_read = False
+ self.copy_container(request, 'request')
+ self.write('Align(&buf, 4);')
+ self.write()
+ self.write('return x11::SendRequest<%s>(display_, &buf);' %
+ reply_name)
+ self.write()
+
+ if not reply:
+ return
+
+ self.write('template<> COMPONENT_EXPORT(X11)')
+ self.write('std::unique_ptr<%s>' % reply_name)
+ sig = 'detail::ReadReply<%s>(const uint8_t* buffer) {' % reply_name
+ with Indent(self, sig, '}'):
+ self.namespace = ['x11']
+ self.write('ReadBuffer buf{buffer, 0UL};')
+ self.write('auto reply = std::make_unique<%s>();' % reply_name)
+ self.write()
+ self.is_read = True
+ self.copy_container(reply, '(*reply)')
+ self.write('Align(&buf, 4);')
+ offset = 'buf.offset < 32 ? 0 : buf.offset - 32'
+ self.write('DCHECK_EQ(%s, 4 * length);' % offset)
+ self.write()
+ self.write('return reply;')
+ self.write()
+
+ def declare_type(self, item, name):
+ if item.is_union:
+ self.declare_union(item)
+ elif isinstance(item, self.xcbgen.xtypes.Request):
+ self.declare_request(item)
+ elif item.is_container:
+ item.name = name
+ self.declare_container(item)
+ elif isinstance(item, self.xcbgen.xtypes.Enum):
+ self.declare_enum(item)
+ else:
+ assert item.is_simple
+ self.declare_simple(item, name)
+
+ # Additional type information identifying the enum/mask is present in the
+ # XML data, but xcbgen doesn't make use of it: it only uses the underlying
+ # type, as it appears on the wire. We want additional type safety, so
+ # extract this information the from XML directly.
+ def resolve_element(self, xml_element, fields):
+ for child in xml_element:
+ if 'name' not in child.attrib:
+ if child.tag == 'case' or child.tag == 'bitcase':
+ self.resolve_element(child, fields)
+ continue
+ name = child.attrib['name']
+ field = fields[name]
+ field.elt = child
+ enums = [
+ child.attrib[attr] for attr in ['enum', 'mask']
+ if attr in child.attrib
+ ]
+ if enums:
+ assert len(enums) == 1
+ enum = enums[0]
+ field.enum = self.module.get_type(enum).name if enums else None
+ self.enum_types[enum].add(field.type.name)
+
+ def resolve_type(self, t, name):
+ renamed = tuple(self.rename_type(t, name))
+ if t in self.types[renamed]:
+ return
+ self.types[renamed].add(t)
+
+ if not t.is_container:
+ return
+
+ if t.is_switch:
+ fields = {}
+ for case in t.bitcases:
+ if case.field_name:
+ fields[case.field_name] = case
+ else:
+ for field in case.type.fields:
+ fields[field.field_name] = field
+ else:
+ fields = {field.field_name: field for field in t.fields}
+
+ self.resolve_element(t.elt, fields)
+
+ for field in fields.values():
+ field.parent = t
+ field.for_list = None
+ if field.type.is_switch or field.type.is_case_or_bitcase:
+ self.resolve_type(field.type, field.field_type)
+ elif field.type.is_list:
+ self.resolve_type(field.type.member, field.type.member.name)
+ expr = field.type.expr
+ if not expr.op and expr.lenfield_name in fields:
+ fields[expr.lenfield_name].for_list = field
+ else:
+ self.resolve_type(field.type, field.type.name)
+
+ if isinstance(t, self.xcbgen.xtypes.Request) and t.reply:
+ self.resolve_type(t.reply, t.reply.name)
+
+ # Perform preprocessing like renaming, reordering, and adding additional
+ # data fields.
+ def resolve(self):
+ for name, t in self.module.all:
+ self.resolve_type(t, name)
+
+ to_delete = []
+ for enum in self.enum_types:
+ types = self.enum_types[enum]
+ if len(types) == 1:
+ self.enum_types[enum] = list(types)[0]
+ else:
+ to_delete.append(enum)
+ for x in to_delete:
+ del self.enum_types[x]
+
+ for t in self.types:
+ # Lots of fields have types like uint8_t. Ignore these.
+ if len(t) == 1:
+ continue
+ l = list(self.types[t])
+ # For some reason, FDs always have distint types so they appear
+ # duplicated in the set. If the set contains only FDs, then bail.
+ if all(x.is_fd for x in l):
+ continue
+ if len(l) == 1:
+ continue
+
+ # Allow simple types and enums to alias each other after renaming.
+ # This is done because we want strong typing even for simple types.
+ # If the types were not merged together, then a cast would be
+ # necessary to convert from eg. AtomEnum to AtomSimple.
+ assert len(l) == 2
+ if isinstance(l[0], self.xcbgen.xtypes.Enum):
+ enum = l[0]
+ simple = l[1]
+ elif isinstance(l[1], self.xcbgen.xtypes.Enum):
+ enum = l[1]
+ simple = l[0]
+ assert simple.is_simple
+ assert enum and simple
+ self.replace_with_enum.add(t)
+ self.enum_types[enum.name] = simple.name
+
+ # The order of types in xcbproto's xml files are inconsistent, so sort
+ # them in the order {type aliases, enums, structs, requests/replies}.
+ def type_order_priority(item):
+ if item.is_simple:
+ return 0
+ if isinstance(item, self.xcbgen.xtypes.Enum):
+ return 1
+ if isinstance(item, self.xcbgen.xtypes.Request):
+ return 3
+ return 2
+
+ def cmp((_1, item1), (_2, item2)):
+ return type_order_priority(item1) - type_order_priority(item2)
+
+ # sort() is guaranteed to be stable.
+ self.module.all.sort(cmp=cmp)
+
+ def gen_header(self):
+ self.file = self.args.headerfile
+ include_guard = self.args.headerfile.name.replace('/', '_').replace(
+ '.', '_').upper() + '_'
+ self.write('#ifndef ' + include_guard)
+ self.write('#define ' + include_guard)
+ self.write()
+ self.write('#include <array>')
+ self.write('#include <cstddef>')
+ self.write('#include <cstdint>')
+ self.write('#include <cstring>')
+ self.write('#include <vector>')
+ self.write()
+ self.write('#include "base/component_export.h"')
+ self.write('#include "ui/gfx/x/xproto_types.h"')
+ for direct_import in self.module.direct_imports:
+ self.write('#include "%s.h"' % direct_import[-1])
+ self.write('#include "%s_undef.h"' % self.module.namespace.header)
+ self.write()
+ self.write('typedef struct _XDisplay XDisplay;')
+ self.write()
+ self.write('namespace x11 {')
+ self.write()
+
+ name = self.class_name
+ self.undef(name)
+ with Indent(self, 'class COMPONENT_EXPORT(X11) %s {' % name, '};'):
+ self.namespace = ['x11', self.class_name]
+ self.write('public:')
+ self.write('explicit %s(XDisplay* display);' % name)
+ self.write()
+ self.write('XDisplay* display() { return display_; }')
+ self.write()
+ for (name, item) in self.module.all:
+ self.declare_type(item, name)
+ self.write('private:')
+ self.write('XDisplay* const display_;')
+
+ self.write()
+ self.write('} // namespace x11')
+ self.write()
+ self.write('#endif // ' + include_guard)
+
+ def gen_source(self):
+ self.file = self.args.sourcefile
+ self.write('#include "%s.h"' % self.module.namespace.header)
+ self.write()
+ self.write('#include <xcb/xcb.h>')
+ self.write('#include <xcb/xcbext.h>')
+ self.write()
+ self.write('#include "base/logging.h"')
+ self.write('#include "ui/gfx/x/xproto_internal.h"')
+ self.write()
+ self.write('namespace x11 {')
+ self.write()
+ name = self.class_name
+ self.write('%s::%s(XDisplay* display) : display_(display) {}' %
+ (name, name))
+ self.write()
+ for (name, item) in self.module.all:
+ if isinstance(item, self.xcbgen.xtypes.Request):
+ self.define_request(item)
+ self.write('} // namespace x11')
+
+ def generate(self):
+ self.module = self.xcbgen.state.Module(self.args.xmlfile.name, None)
+ self.module.register()
+ self.module.resolve()
+ self.resolve()
+ self.class_name = (adjust_type_case(self.module.namespace.ext_name)
+ if self.module.namespace.is_ext else 'XProto')
+
+ self.gen_header()
+ self.gen_source()
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser.add_argument('xmlfile', type=argparse.FileType('r'))
+ parser.add_argument('undeffile', type=argparse.FileType('w'))
+ parser.add_argument('headerfile', type=argparse.FileType('w'))
+ parser.add_argument('sourcefile', type=argparse.FileType('w'))
+ parser.add_argument('--sysroot')
+ args = parser.parse_args()
+
+ if args.sysroot:
+ path = os.path.join(args.sysroot, 'usr', 'lib', 'python2.7',
+ 'dist-packages')
+ sys.path.insert(1, path)
+
+ import xcbgen.xtypes
+ import xcbgen.state
+
+ generator = GenXproto(args, xcbgen)
+ generator.generate()
+
+ return 0
+
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/chromium/ui/gfx/x/request_queue.cc b/chromium/ui/gfx/x/request_queue.cc
new file mode 100644
index 00000000000..9bd3ab2f248
--- /dev/null
+++ b/chromium/ui/gfx/x/request_queue.cc
@@ -0,0 +1,29 @@
+// Copyright 2020 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 "ui/gfx/x/request_queue.h"
+
+#include "base/check_op.h"
+
+namespace x11 {
+
+// static
+RequestQueue* RequestQueue::instance_ = nullptr;
+
+RequestQueue::RequestQueue() {
+ DCHECK(!instance_);
+ instance_ = this;
+}
+
+RequestQueue::~RequestQueue() {
+ DCHECK_EQ(instance_, this);
+ instance_ = nullptr;
+}
+
+// static
+RequestQueue* RequestQueue::GetInstance() {
+ return instance_;
+}
+
+} // namespace x11
diff --git a/chromium/ui/gfx/x/request_queue.h b/chromium/ui/gfx/x/request_queue.h
new file mode 100644
index 00000000000..b48b1c031de
--- /dev/null
+++ b/chromium/ui/gfx/x/request_queue.h
@@ -0,0 +1,51 @@
+// Copyright 2020 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 UI_GFX_X_REQUEST_QUEUE_H_
+#define UI_GFX_X_REQUEST_QUEUE_H_
+
+#include <xcb/xcb.h>
+
+#include <memory>
+
+#include "base/callback_forward.h"
+#include "base/component_export.h"
+#include "base/memory/free_deleter.h"
+
+namespace ui {
+class X11EventSource;
+}
+
+namespace x11 {
+
+// This interface allows //ui/gfx/x to call into //ui/events/platform/x11 which
+// is at a higher layer. It should not be used by client code.
+class COMPONENT_EXPORT(X11) RequestQueue {
+ private:
+ friend class ui::X11EventSource;
+ template <typename T>
+ friend class Future;
+
+ using Reply = std::unique_ptr<uint8_t, base::FreeDeleter>;
+ using Error = std::unique_ptr<xcb_generic_error_t, base::FreeDeleter>;
+ using ResponseCallback = base::OnceCallback<void(Reply reply, Error error)>;
+
+ RequestQueue();
+ virtual ~RequestQueue();
+
+ // Adds a request to the queue. |is_void| indicates if a reply is generated
+ // for this request. |sequence| is the ID of the request. |callback| will
+ // be called upon request completion (or failure).
+ virtual void AddRequest(bool is_void,
+ unsigned int sequence,
+ ResponseCallback callback) = 0;
+
+ static RequestQueue* GetInstance();
+
+ static RequestQueue* instance_;
+};
+
+} // namespace x11
+
+#endif // UI_GFX_X_REQUEST_QUEUE_H_
diff --git a/chromium/ui/gfx/x/x11.h b/chromium/ui/gfx/x/x11.h
index 61b4ab64bd1..b163f788d98 100644
--- a/chromium/ui/gfx/x/x11.h
+++ b/chromium/ui/gfx/x/x11.h
@@ -97,25 +97,12 @@ extern "C" {
#undef DeviceAdded // Defined by X11/extensions/XI.h to 0
#undef DeviceMode // Defined by X11/extensions/XI.h to 1
#undef DeviceRemoved // Defined by X11/extensions/XI.h to 1
-
-// The constants below are made available in the x11 namespace with
-// their original values so we double check that the value is what we
-// expect using static_assert.
-static_assert(FocusIn == 9 && FocusOut == 10, "Unexpected focus constants");
#undef FocusIn // Defined by X.h to 9
#undef FocusOut // Defined by X.h to 10
-
-static_assert(None == 0, "Unexpected value for X11 constant 'None'");
#undef None // Defined by X11/X.h to 0L
-
-static_assert(True == 1 && False == 0, "Unexpected X11 truth values");
#undef True // Defined by X11/Xlib.h to 1
#undef False // Defined by X11/Xlib.h to 0
-
-static_assert(CurrentTime == 0, "Unexpected value for X11 'CurrentTime'");
#undef CurrentTime // Defined by X11/X.h to 0L
-
-static_assert(Success == 0, "Unexpected value for X11 'Success'");
#undef Success // Defined by X11/X.h to 0
}
diff --git a/chromium/ui/gfx/x/x11_atom_cache.cc b/chromium/ui/gfx/x/x11_atom_cache.cc
index 8c6e3a1e070..75f18c1b57a 100644
--- a/chromium/ui/gfx/x/x11_atom_cache.cc
+++ b/chromium/ui/gfx/x/x11_atom_cache.cc
@@ -10,10 +10,11 @@
#include <utility>
#include <vector>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/memory/singleton.h"
#include "base/metrics/histogram_functions.h"
#include "base/stl_util.h"
+#include "ui/gfx/x/connection.h"
namespace {
@@ -251,37 +252,39 @@ X11AtomCache* X11AtomCache::GetInstance() {
return base::Singleton<X11AtomCache>::get();
}
-X11AtomCache::X11AtomCache() : xdisplay_(gfx::GetXDisplay()) {
+X11AtomCache::X11AtomCache() : connection_(x11::Connection::Get()) {
for (const auto& predefined_atom : kPredefinedAtoms)
cached_atoms_[predefined_atom.atom_name] = predefined_atom.atom_value;
- // Grab all the atoms we need now to minimize roundtrips to the X11 server.
- std::vector<XAtom> cached_atoms(kCacheCount);
- XInternAtoms(xdisplay_, const_cast<char**>(kAtomsToCache), kCacheCount, False,
- cached_atoms.data());
-
- for (int i = 0; i < kCacheCount; ++i)
- cached_atoms_[kAtomsToCache[i]] = cached_atoms[i];
+ std::vector<x11::Future<x11::XProto::InternAtomReply>> requests;
+ requests.reserve(kCacheCount);
+ for (const char* name : kAtomsToCache)
+ requests.push_back(connection_->InternAtom({.name = name}));
+ for (size_t i = 0; i < kCacheCount; ++i) {
+ if (auto response = requests[i].Sync())
+ cached_atoms_[kAtomsToCache[i]] = static_cast<XAtom>(response->atom);
+ }
}
-X11AtomCache::~X11AtomCache() {}
+X11AtomCache::~X11AtomCache() = default;
XAtom X11AtomCache::GetAtom(const char* name) const {
+ DCHECK(name);
const auto it = cached_atoms_.find(name);
if (it != cached_atoms_.end())
return it->second;
- // XInternAtom returns None on failure. Source:
- // https://www.x.org/releases/X11R7.5/doc/man/man3/XInternAtom.3.html
- XAtom atom = XInternAtom(xdisplay_, name, False);
- if (atom == None) {
+ XAtom atom = 0;
+ if (auto response = connection_->InternAtom({.name = name}).Sync()) {
+ atom = static_cast<XAtom>(response->atom);
+ cached_atoms_.emplace(name, atom);
+ } else {
static int error_count = 0;
++error_count;
// TODO(https://crbug.com/1000919): Evaluate and remove UMA metrics after
// enough data is gathered.
base::UmaHistogramCounts100("X11.XInternAtomFailure", error_count);
}
- cached_atoms_.emplace(name, atom);
return atom;
}
diff --git a/chromium/ui/gfx/x/x11_atom_cache.h b/chromium/ui/gfx/x/x11_atom_cache.h
index 9d2bc07f344..b04608a783c 100644
--- a/chromium/ui/gfx/x/x11_atom_cache.h
+++ b/chromium/ui/gfx/x/x11_atom_cache.h
@@ -17,6 +17,10 @@ template <typename T>
struct DefaultSingletonTraits;
}
+namespace x11 {
+class Connection;
+}
+
namespace gfx {
// Gets the X atom for default display corresponding to atom_name.
@@ -41,7 +45,7 @@ class GFX_EXPORT X11AtomCache {
// On failure, x11::None is returned.
XAtom GetAtom(const char*) const;
- XDisplay* xdisplay_;
+ x11::Connection* connection_;
// Using std::map, as it is possible for thousands of atoms to be registered.
mutable std::map<std::string, XAtom> cached_atoms_;
diff --git a/chromium/ui/gfx/x/x11_connection.cc b/chromium/ui/gfx/x/x11_connection.cc
deleted file mode 100644
index c5ee77f40d8..00000000000
--- a/chromium/ui/gfx/x/x11_connection.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 "ui/gfx/x/x11_connection.h"
-
-#include <X11/Xlib.h>
-
-#include "ui/gfx/x/x11_types.h"
-
-namespace gfx {
-
-bool InitializeThreadedX11() {
- return XInitThreads() && gfx::GetXDisplay();
-}
-
-} // namespace gfx
diff --git a/chromium/ui/gfx/x/x11_connection.h b/chromium/ui/gfx/x/x11_connection.h
deleted file mode 100644
index 06ca89fe800..00000000000
--- a/chromium/ui/gfx/x/x11_connection.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 UI_GFX_X_X11_CONNECTION_H_
-#define UI_GFX_X_X11_CONNECTION_H_
-
-#include "ui/gfx/gfx_export.h"
-
-namespace gfx {
-
-// Initializes thread support for X11, and opens a connection to the display.
-// Return false if either fails, and true otherwise.
-GFX_EXPORT bool InitializeThreadedX11();
-
-} // namespace gfx
-
-#endif // UI_GFX_X_X11_CONNECTION_H_
diff --git a/chromium/ui/gfx/x/x11_error_tracker.cc b/chromium/ui/gfx/x/x11_error_tracker.cc
index af031de356c..a6f054f5ba2 100644
--- a/chromium/ui/gfx/x/x11_error_tracker.cc
+++ b/chromium/ui/gfx/x/x11_error_tracker.cc
@@ -4,7 +4,7 @@
#include "ui/gfx/x/x11_error_tracker.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/gfx/x/x11_types.h"
namespace {
diff --git a/chromium/ui/gfx/x/x11_switches.cc b/chromium/ui/gfx/x/x11_switches.cc
index f69cc503b3a..9e53afd7e9d 100644
--- a/chromium/ui/gfx/x/x11_switches.cc
+++ b/chromium/ui/gfx/x/x11_switches.cc
@@ -2,18 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "build/build_config.h"
#include "ui/gfx/x/x11_switches.h"
namespace switches {
-#if !defined(OS_CHROMEOS)
// Which X11 display to connect to. Emulates the GTK+ "--display=" command line
// argument.
const char kX11Display[] = "display";
// Disables MIT-SHM extension.
const char kNoXshm[] = "no-xshm";
-#endif
} // namespace switches
diff --git a/chromium/ui/gfx/x/x11_switches.h b/chromium/ui/gfx/x/x11_switches.h
index c4ea7321342..2df00e56499 100644
--- a/chromium/ui/gfx/x/x11_switches.h
+++ b/chromium/ui/gfx/x/x11_switches.h
@@ -5,16 +5,13 @@
#ifndef UI_GFX_X_X11_SWITCHES_H_
#define UI_GFX_X_X11_SWITCHES_H_
-#include "build/build_config.h"
-#include "ui/gfx/gfx_export.h"
+#include "base/component_export.h"
namespace switches {
-#if !defined(OS_CHROMEOS)
-GFX_EXPORT extern const char kX11Display[];
+COMPONENT_EXPORT(X11) extern const char kX11Display[];
-GFX_EXPORT extern const char kNoXshm[];
-#endif
+COMPONENT_EXPORT(X11) extern const char kNoXshm[];
} // namespace switches
diff --git a/chromium/ui/gfx/x/x11_types.cc b/chromium/ui/gfx/x/x11_types.cc
index 263b7852a12..ebbe076ab6b 100644
--- a/chromium/ui/gfx/x/x11_types.cc
+++ b/chromium/ui/gfx/x/x11_types.cc
@@ -5,28 +5,22 @@
#include "ui/gfx/x/x11_types.h"
#include <X11/Xlib.h>
+#include <string.h>
#include "base/command_line.h"
+#include "base/logging.h"
#include "build/build_config.h"
+#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/x11_switches.h"
namespace gfx {
XDisplay* GetXDisplay() {
- static XDisplay* display = NULL;
- if (!display)
- display = OpenNewXDisplay();
- return display;
+ return x11::Connection::Get()->display();
}
-XDisplay* OpenNewXDisplay() {
-#if defined(OS_CHROMEOS)
- return XOpenDisplay(NULL);
-#else
- std::string display_str = base::CommandLine::ForCurrentProcess()->
- GetSwitchValueASCII(switches::kX11Display);
- return XOpenDisplay(display_str.empty() ? NULL : display_str.c_str());
-#endif
+XDisplay* CloneXDisplay(XDisplay* display) {
+ return XOpenDisplay(DisplayString(display));
}
void PutARGBImage(XDisplay* display,
@@ -83,10 +77,10 @@ void PutARGBImage(XDisplay* display,
image.width = data_width;
image.height = data_height;
- image.format = ZPixmap;
- image.byte_order = LSBFirst;
+ image.format = static_cast<int>(x11::XProto::ImageFormat::ZPixmap);
+ image.byte_order = static_cast<int>(x11::XProto::ImageOrder::LSBFirst);
image.bitmap_unit = 8;
- image.bitmap_bit_order = LSBFirst;
+ image.bitmap_bit_order = static_cast<int>(x11::XProto::ImageOrder::LSBFirst);
image.depth = depth;
image.bits_per_pixel = pixmap_bpp;
image.bytes_per_line = data_width * pixmap_bpp / 8;
diff --git a/chromium/ui/gfx/x/x11_types.h b/chromium/ui/gfx/x/x11_types.h
index f674c62226b..8ea0ca4ca49 100644
--- a/chromium/ui/gfx/x/x11_types.h
+++ b/chromium/ui/gfx/x/x11_types.h
@@ -17,10 +17,10 @@ typedef unsigned long VisualID;
typedef struct _XcursorImage XcursorImage;
typedef union _XEvent XEvent;
typedef struct _XImage XImage;
-typedef struct _XGC *GC;
+typedef struct _XGC* GC;
typedef struct _XDisplay XDisplay;
typedef struct _XRegion XRegion;
-typedef struct __GLXFBConfigRec *GLXFBConfig;
+typedef struct __GLXFBConfigRec* GLXFBConfig;
typedef XID GLXWindow;
typedef XID GLXDrawable;
@@ -38,13 +38,12 @@ struct XObjectDeleter {
template <class T, class D = XObjectDeleter<void, int, XFree>>
using XScopedPtr = std::unique_ptr<T, D>;
-// TODO(oshima|evan): This assume there is one display and doesn't work
-// undef multiple displays/monitor environment. Remove this and change the
-// chrome codebase to get the display from window.
+// Get the XDisplay singleton. Prefer x11::Connection::Get() instead.
GFX_EXPORT XDisplay* GetXDisplay();
-// This opens a new X11 XDisplay*, taking command line arguments into account.
-GFX_EXPORT XDisplay* OpenNewXDisplay();
+// Given a connection to an X server, opens a new parallel connection to the
+// same X server. It's the caller's responsibility to call XCloseDisplay().
+GFX_EXPORT XDisplay* CloneXDisplay(XDisplay* display);
// Return the number of bits-per-pixel for a pixmap of the given depth
GFX_EXPORT int BitsPerPixelForPixmapDepth(XDisplay* display, int depth);
diff --git a/chromium/ui/gfx/x/xproto_internal.h b/chromium/ui/gfx/x/xproto_internal.h
new file mode 100644
index 00000000000..f76ebe5ecac
--- /dev/null
+++ b/chromium/ui/gfx/x/xproto_internal.h
@@ -0,0 +1,161 @@
+// Copyright 2020 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 UI_GFX_X_XPROTO_INTERNAL_H_
+#define UI_GFX_X_XPROTO_INTERNAL_H_
+
+#ifndef IS_X11_IMPL
+#error "This file should only be included by generated xprotos"
+#endif
+
+#include <X11/Xlib-xcb.h>
+#include <stdint.h>
+#include <string.h>
+#include <xcb/xcb.h>
+#include <xcb/xcbext.h>
+
+#include <bitset>
+#include <limits>
+#include <type_traits>
+
+#include "base/component_export.h"
+#include "base/optional.h"
+#include "ui/gfx/x/xproto_types.h"
+
+namespace x11 {
+
+template <class Reply>
+class Future;
+
+using WriteBuffer = std::vector<uint8_t>;
+
+template <typename T, typename Enable = void>
+struct EnumBase {
+ using type = T;
+};
+
+template <typename T>
+struct EnumBase<T, typename std::enable_if_t<std::is_enum<T>::value>> {
+ using type = typename std::underlying_type<T>::type;
+};
+
+template <typename T>
+using EnumBaseType = typename EnumBase<T>::type;
+
+struct ReadBuffer {
+ const uint8_t* data = nullptr;
+ size_t offset = 0;
+};
+
+template <typename T>
+void Write(const T* t, WriteBuffer* buf) {
+ static_assert(std::is_trivially_copyable<T>::value, "");
+ // On the wire, X11 types are always aligned to their size. This is a sanity
+ // check to ensure padding etc are working properly.
+ DCHECK_EQ(buf->size() % sizeof(*t), 0UL);
+ const uint8_t* start = reinterpret_cast<const uint8_t*>(t);
+ std::copy(start, start + sizeof(*t), std::back_inserter(*buf));
+}
+
+template <typename T>
+void Read(T* t, ReadBuffer* buf) {
+ static_assert(std::is_trivially_copyable<T>::value, "");
+ // On the wire, X11 types are always aligned to their size. This is a sanity
+ // check to ensure padding etc are working properly.
+ DCHECK_EQ(buf->offset % sizeof(*t), 0UL);
+ memcpy(t, buf->data + buf->offset, sizeof(*t));
+ buf->offset += sizeof(*t);
+}
+
+inline void Pad(WriteBuffer* buf, size_t amount) {
+ buf->resize(buf->size() + amount, '\0');
+}
+
+inline void Pad(ReadBuffer* buf, size_t amount) {
+ buf->offset += amount;
+}
+
+inline void Align(WriteBuffer* buf, size_t align) {
+ Pad(buf, (align - (buf->size() % align)) % align);
+}
+
+inline void Align(ReadBuffer* buf, size_t align) {
+ Pad(buf, (align - (buf->offset % align)) % align);
+}
+
+template <typename Reply>
+Future<Reply> SendRequest(XDisplay* display, WriteBuffer* buf) {
+ // Clang crashes when the value of |is_void| is inlined below,
+ // so keep this variable outside of |xpr|.
+ constexpr bool is_void = std::is_void<Reply>::value;
+ xcb_protocol_request_t xpr{
+ .count = 1,
+ .ext = nullptr,
+ .isvoid = is_void,
+ };
+
+ struct RequestHeader {
+ uint8_t major_opcode;
+ uint8_t minor_opcode;
+ uint16_t length;
+ };
+
+ auto* header = reinterpret_cast<RequestHeader*>(buf->data());
+ // Requests are always a multiple of 4 bytes on the wire. Because of this,
+ // the length field represents the size in chunks of 4 bytes.
+ DCHECK_EQ(buf->size() % 4, 0UL);
+ DCHECK_LE(buf->size() / 4, std::numeric_limits<uint16_t>::max());
+ header->length = buf->size() / 4;
+
+ struct iovec io[3];
+ io[2].iov_base = buf->data();
+ io[2].iov_len = buf->size();
+ auto flags = XCB_REQUEST_CHECKED | XCB_REQUEST_RAW;
+
+ xcb_connection_t* conn = XGetXCBConnection(display);
+ auto sequence = xcb_send_request(conn, flags, &io[2], &xpr);
+ if (xcb_connection_has_error(conn))
+ return {nullptr, base::nullopt};
+ return {display, sequence};
+}
+
+// Helper function for xcbproto popcount. Given an integral type, returns the
+// number of 1 bits present.
+template <typename T>
+size_t PopCount(T t) {
+ return std::bitset<sizeof(T) * 8>(static_cast<EnumBaseType<T>>(t)).count();
+}
+
+// Helper function for xcbproto sumof. Given a function |f| and a container
+// |t|, maps the elements uisng |f| and reduces by summing the results.
+template <typename F, typename T>
+auto SumOf(F&& f, T& t) {
+ decltype(f(t[0])) sum = 0;
+ for (auto& v : t)
+ sum += f(v);
+ return sum;
+}
+
+// Helper function for xcbproto case. Checks for equality between |t| and |s|.
+template <typename T, typename S>
+bool CaseEq(T t, S s) {
+ return t == static_cast<decltype(t)>(s);
+}
+
+// Helper function for xcbproto bitcase and & expressions. Checks if the
+// bitmasks |t| and |s| have any intersection.
+template <typename T, typename S>
+bool BitAnd(T t, S s) {
+ return static_cast<EnumBaseType<T>>(t) & static_cast<EnumBaseType<T>>(s);
+}
+
+// Helper function for ~ expressions.
+template <typename T>
+bool BitNot(T t) {
+ return ~static_cast<EnumBaseType<T>>(t);
+}
+
+} // namespace x11
+
+#endif // UI_GFX_X_XPROTO_INTERNAL_H_
diff --git a/chromium/ui/gfx/x/xproto_types.h b/chromium/ui/gfx/x/xproto_types.h
new file mode 100644
index 00000000000..9e5dfe09534
--- /dev/null
+++ b/chromium/ui/gfx/x/xproto_types.h
@@ -0,0 +1,209 @@
+// Copyright 2020 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 UI_GFX_X_XPROTO_TYPES_H_
+#define UI_GFX_X_XPROTO_TYPES_H_
+
+#include <X11/Xlib-xcb.h>
+#include <xcb/xcb.h>
+#include <xcb/xcbext.h>
+
+#include <cstdint>
+#include <memory>
+
+#include "base/bind.h"
+#include "base/callback.h"
+#include "base/memory/free_deleter.h"
+#include "base/optional.h"
+#include "ui/gfx/x/request_queue.h"
+#include "ui/gfx/x/xproto_util.h"
+
+typedef struct _XDisplay XDisplay;
+
+namespace x11 {
+
+namespace detail {
+
+template <typename Reply>
+std::unique_ptr<Reply> ReadReply(const uint8_t* buffer);
+
+}
+
+using Error = xcb_generic_error_t;
+
+template <class Reply>
+class Future;
+
+template <typename Reply>
+struct Response {
+ operator bool() const { return reply.get(); }
+ const Reply* operator->() const { return reply.get(); }
+
+ std::unique_ptr<Reply> reply;
+ std::unique_ptr<Error, base::FreeDeleter> error;
+
+ private:
+ friend class Future<Reply>;
+
+ Response(std::unique_ptr<Reply> reply,
+ std::unique_ptr<Error, base::FreeDeleter> error)
+ : reply(std::move(reply)), error(std::move(error)) {}
+};
+
+template <>
+struct Response<void> {
+ std::unique_ptr<Error, base::FreeDeleter> error;
+
+ private:
+ friend class Future<void>;
+
+ explicit Response(std::unique_ptr<Error, base::FreeDeleter> error)
+ : error(std::move(error)) {}
+};
+
+// An x11::Future wraps an asynchronous response from the X11 server. The
+// response may be waited-for with Sync(), or asynchronously handled by
+// installing a response handler using OnResponse().
+template <typename Reply>
+class Future {
+ public:
+ using Callback = base::OnceCallback<void(Response<Reply> response)>;
+ using RQ = RequestQueue;
+
+ // If a user-defined response-handler is not installed before this object goes
+ // out of scope, a default response handler will be installed. The default
+ // handler throws away the reply and prints the error if there is one.
+ ~Future() {
+ if (!sequence_)
+ return;
+
+ EnqueueRequest(base::BindOnce(
+ [](XDisplay* display, RQ::Reply reply, RQ::Error error) {
+ if (!error)
+ return;
+
+ x11::LogErrorEventDescription(XErrorEvent({
+ .type = error->response_type,
+ .display = display,
+ .resourceid = error->resource_id,
+ .serial = error->full_sequence,
+ .error_code = error->error_code,
+ .request_code = error->major_code,
+ .minor_code = error->minor_code,
+ }));
+ },
+ display_));
+ }
+
+ Future(const Future&) = delete;
+ Future& operator=(const Future&) = delete;
+
+ Future(Future&& future)
+ : display_(future.display_), sequence_(future.sequence_) {
+ future.display_ = nullptr;
+ future.sequence_ = base::nullopt;
+ }
+ Future& operator=(Future&& future) {
+ display_ = future.display_;
+ sequence_ = future.sequence_;
+ future.display_ = nullptr;
+ future.sequence_ = base::nullopt;
+ }
+
+ xcb_connection_t* connection() { return XGetXCBConnection(display_); }
+
+ // Blocks until we receive the response from the server. Returns the response.
+ Response<Reply> Sync() {
+ if (!sequence_)
+ return {{}, {}};
+
+ Error* raw_error = nullptr;
+ uint8_t* raw_reply = reinterpret_cast<uint8_t*>(
+ xcb_wait_for_reply(connection(), *sequence_, &raw_error));
+ sequence_ = base::nullopt;
+
+ std::unique_ptr<Reply> reply;
+ if (raw_reply) {
+ reply = detail::ReadReply<Reply>(raw_reply);
+ free(raw_reply);
+ }
+
+ std::unique_ptr<Error, base::FreeDeleter> error;
+ if (raw_error)
+ error.reset(raw_error);
+
+ return {std::move(reply), std::move(error)};
+ }
+
+ // Installs |callback| to be run when the response is received.
+ void OnResponse(Callback callback) {
+ if (!sequence_)
+ return;
+
+ // This intermediate callback handles the conversion from |raw_reply| to a
+ // real Reply object before feeding the result to |callback|. This means
+ // |callback| must be bound as the first argument of the intermediate
+ // function.
+ auto wrapper = [](Callback callback, RQ::Reply raw_reply, RQ::Error error) {
+ std::unique_ptr<Reply> reply =
+ raw_reply ? detail::ReadReply<Reply>(raw_reply.get()) : nullptr;
+ std::move(callback).Run({std::move(reply), std::move(error)});
+ };
+ EnqueueRequest(base::BindOnce(wrapper, std::move(callback)));
+
+ sequence_ = base::nullopt;
+ }
+
+ private:
+ template <typename R>
+ friend Future<R> SendRequest(XDisplay*, std::vector<uint8_t>*);
+
+ Future(XDisplay* display, base::Optional<unsigned int> sequence)
+ : display_(display), sequence_(sequence) {}
+
+ void EnqueueRequest(RQ::ResponseCallback callback) {
+ RQ::GetInstance()->AddRequest(std::is_void<Reply>::value, *sequence_,
+ std::move(callback));
+ }
+
+ XDisplay* display_;
+ base::Optional<unsigned int> sequence_;
+};
+
+// Sync() specialization for requests that don't generate replies. The returned
+// response will only contain an error if there was one.
+template <>
+inline Response<void> Future<void>::Sync() {
+ if (!sequence_)
+ return Response<void>(nullptr);
+
+ Error* raw_error = xcb_request_check(connection(), {*sequence_});
+ std::unique_ptr<Error, base::FreeDeleter> error;
+ if (raw_error)
+ error.reset(raw_error);
+
+ return Response<void>{std::move(error)};
+}
+
+// OnResponse() specialization for requests that don't generate replies. The
+// response argument to |callback| will only contain an error if there was one.
+template <>
+inline void Future<void>::OnResponse(Callback callback) {
+ if (!sequence_)
+ return;
+
+ // See Future<Reply>::OnResponse() for an explanation of why
+ // this wrapper is necessary.
+ auto wrapper = [](Callback callback, RQ::Reply reply, RQ::Error error) {
+ DCHECK(!reply);
+ std::move(callback).Run(Response<void>{std::move(error)});
+ };
+ EnqueueRequest(base::BindOnce(wrapper, std::move(callback)));
+
+ sequence_ = base::nullopt;
+}
+
+} // namespace x11
+
+#endif // UI_GFX_X_XPROTO_TYPES_H_
diff --git a/chromium/ui/gfx/x/xproto_util.cc b/chromium/ui/gfx/x/xproto_util.cc
new file mode 100644
index 00000000000..495e4a64221
--- /dev/null
+++ b/chromium/ui/gfx/x/xproto_util.cc
@@ -0,0 +1,59 @@
+// Copyright 2020 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 "ui/gfx/x/xproto_util.h"
+
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/stringprintf.h"
+#include "ui/gfx/x/xproto.h"
+
+namespace x11 {
+
+void LogErrorEventDescription(const XErrorEvent& error_event) {
+ // This function may make some expensive round trips (XListExtensions,
+ // XQueryExtension), but the only effect this function has is LOG(WARNING),
+ // so early-return if the log would never be sent anyway.
+ if (!LOG_IS_ON(WARNING))
+ return;
+
+ char error_str[256];
+ char request_str[256];
+
+ XDisplay* dpy = error_event.display;
+ XProto conn{dpy};
+ XGetErrorText(dpy, error_event.error_code, error_str, sizeof(error_str));
+
+ strncpy(request_str, "Unknown", sizeof(request_str));
+ if (error_event.request_code < 128) {
+ std::string num = base::NumberToString(error_event.request_code);
+ XGetErrorDatabaseText(dpy, "XRequest", num.c_str(), "Unknown", request_str,
+ sizeof(request_str));
+ } else {
+ if (auto response = conn.ListExtensions({}).Sync()) {
+ for (const auto& str : response->names) {
+ int ext_code, first_event, first_error;
+ const char* name = str.name.c_str();
+ XQueryExtension(dpy, name, &ext_code, &first_event, &first_error);
+ if (error_event.request_code == ext_code) {
+ std::string msg =
+ base::StringPrintf("%s.%d", name, error_event.minor_code);
+ XGetErrorDatabaseText(dpy, "XRequest", msg.c_str(), "Unknown",
+ request_str, sizeof(request_str));
+ break;
+ }
+ }
+ }
+ }
+
+ LOG(WARNING) << "X error received: "
+ << "serial " << error_event.serial << ", "
+ << "error_code " << static_cast<int>(error_event.error_code)
+ << " (" << error_str << "), "
+ << "request_code " << static_cast<int>(error_event.request_code)
+ << ", "
+ << "minor_code " << static_cast<int>(error_event.minor_code)
+ << " (" << request_str << ")";
+}
+
+} // namespace x11
diff --git a/chromium/ui/gfx/x/xproto_util.h b/chromium/ui/gfx/x/xproto_util.h
new file mode 100644
index 00000000000..baf2aaa540a
--- /dev/null
+++ b/chromium/ui/gfx/x/xproto_util.h
@@ -0,0 +1,19 @@
+// Copyright 2020 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 UI_GFX_X_XPROTO_UTIL_H_
+#define UI_GFX_X_XPROTO_UTIL_H_
+
+#include <X11/Xlib.h>
+
+#include "base/component_export.h"
+
+namespace x11 {
+
+COMPONENT_EXPORT(X11)
+void LogErrorEventDescription(const XErrorEvent& error_event);
+
+} // namespace x11
+
+#endif // UI_GFX_X_XPROTO_UTIL_H_
diff --git a/chromium/ui/gl/BUILD.gn b/chromium/ui/gl/BUILD.gn
index 8fac30ee40e..b707e157ddb 100644
--- a/chromium/ui/gl/BUILD.gn
+++ b/chromium/ui/gl/BUILD.gn
@@ -10,13 +10,8 @@ import("//build/config/ui.gni")
import("//testing/test.gni")
import("//ui/gl/features.gni")
import("//ui/ozone/ozone.gni")
-declare_args() {
- enable_swiftshader = (is_win || is_linux || (is_mac && use_egl) ||
- is_chromeos || is_fuchsia) &&
- (target_cpu == "x86" || target_cpu == "x64" ||
- target_cpu == "arm" || target_cpu == "arm64" ||
- target_cpu == "mipsel" || target_cpu == "mips64el")
+declare_args() {
# Whether service side logging (actual calls into the GL driver) is enabled
# or not.
enable_gpu_service_logging = false
@@ -204,6 +199,8 @@ jumbo_component("gl") {
"gl_bindings_autogen_egl.h",
"gl_context_egl.cc",
"gl_context_egl.h",
+ "gl_display_egl_util.cc",
+ "gl_display_egl_util.h",
"gl_egl_api_implementation.cc",
"gl_egl_api_implementation.h",
"gl_fence_egl.cc",
@@ -253,8 +250,10 @@ jumbo_component("gl") {
]
}
- if (use_x11) {
+ if (use_x11 || ozone_platform_x11) {
sources += [
+ "gl_surface_egl_x11.cc",
+ "gl_surface_egl_x11.h",
"gl_surface_egl_x11_gles2.cc",
"gl_surface_egl_x11_gles2.h",
"gl_surface_glx_x11.cc",
@@ -290,13 +289,6 @@ jumbo_component("gl") {
"gl_visual_picker_glx.h",
]
- configs += [
- "//build/config/linux:x11",
- "//build/config/linux:xcomposite",
- "//build/config/linux:xext",
- "//build/config/linux:xrandr",
- ]
-
deps += [
"//ui/base/x",
"//ui/gfx/x",
@@ -478,10 +470,12 @@ jumbo_static_library("gl_unittest_utils") {
jumbo_static_library("test_support") {
testonly = true
sources = [
+ "test/gl_image_bind_test_template.h",
"test/gl_image_test_support.cc",
"test/gl_image_test_support.h",
"test/gl_image_test_template.cc",
"test/gl_image_test_template.h",
+ "test/gl_image_zero_initialize_test_template.h",
"test/gl_surface_test_support.cc",
"test/gl_surface_test_support.h",
"test/gl_test_helper.cc",
@@ -505,8 +499,10 @@ jumbo_static_library("test_support") {
}
if (use_x11) {
- configs += [ "//build/config/linux:x11" ]
- deps += [ "//ui/platform_window/x11" ]
+ deps += [
+ "//ui/gfx/x",
+ "//ui/platform_window/x11",
+ ]
}
if (use_ozone) {
@@ -600,10 +596,10 @@ test("gl_unittests") {
data_deps = [ "//third_party/mesa_headers" ]
+ # TODO(https://crbug.com/789065): this must be moved to Ozone.
if (use_x11) {
sources += [ "gl_context_glx_unittest.cc" ]
deps += [ "//ui/gfx/x" ]
- configs += [ "//build/config/linux:x11" ]
}
}
diff --git a/chromium/ui/gl/android/android_surface_control_compat.cc b/chromium/ui/gl/android/android_surface_control_compat.cc
index 223c28c17aa..70a2f706f41 100644
--- a/chromium/ui/gl/android/android_surface_control_compat.cc
+++ b/chromium/ui/gl/android/android_surface_control_compat.cc
@@ -37,6 +37,12 @@ enum {
ASURFACE_TRANSACTION_TRANSPARENCY_OPAQUE = 2,
};
+// ANativeWindow_FrameRateCompatibility enums
+enum {
+ ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT = 0,
+ ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE = 1
+};
+
// ASurfaceTransaction
using pASurfaceTransaction_create = ASurfaceTransaction* (*)(void);
using pASurfaceTransaction_delete = void (*)(ASurfaceTransaction*);
@@ -75,6 +81,11 @@ using pASurfaceTransaction_setBufferDataSpace =
void (*)(ASurfaceTransaction* transaction,
ASurfaceControl* surface,
uint64_t data_space);
+using pASurfaceTransaction_setFrameRate =
+ void (*)(ASurfaceTransaction* transaction,
+ ASurfaceControl* surface_control,
+ float frameRate,
+ int8_t compatibility);
// ASurfaceTransactionStats
using pASurfaceTransactionStats_getPresentFenceFd =
@@ -107,6 +118,11 @@ uint64_t g_agb_required_usage_bits = AHARDWAREBUFFER_USAGE_COMPOSER_OVERLAY;
} \
} while (0)
+#define LOAD_FUNCTION_MAYBE(lib, func) \
+ do { \
+ func##Fn = reinterpret_cast<p##func>(dlsym(lib, #func)); \
+ } while (0)
+
struct SurfaceControlMethods {
public:
static const SurfaceControlMethods& Get() {
@@ -138,6 +154,7 @@ struct SurfaceControlMethods {
LOAD_FUNCTION(main_dl_handle, ASurfaceTransaction_setBufferTransparency);
LOAD_FUNCTION(main_dl_handle, ASurfaceTransaction_setDamageRegion);
LOAD_FUNCTION(main_dl_handle, ASurfaceTransaction_setBufferDataSpace);
+ LOAD_FUNCTION_MAYBE(main_dl_handle, ASurfaceTransaction_setFrameRate);
LOAD_FUNCTION(main_dl_handle, ASurfaceTransactionStats_getPresentFenceFd);
LOAD_FUNCTION(main_dl_handle, ASurfaceTransactionStats_getLatchTime);
@@ -171,6 +188,7 @@ struct SurfaceControlMethods {
pASurfaceTransaction_setDamageRegion ASurfaceTransaction_setDamageRegionFn;
pASurfaceTransaction_setBufferDataSpace
ASurfaceTransaction_setBufferDataSpaceFn;
+ pASurfaceTransaction_setFrameRate ASurfaceTransaction_setFrameRateFn;
// TransactionStats methods.
pASurfaceTransactionStats_getPresentFenceFd
@@ -312,6 +330,13 @@ void SurfaceControl::EnableQualcommUBWC() {
g_agb_required_usage_bits |= AHARDWAREBUFFER_USAGE_VENDOR_0;
}
+bool SurfaceControl::SupportsSetFrameRate() {
+ // TODO(khushalsagar): Assert that this function is always available on R.
+ return IsSupported() &&
+ SurfaceControlMethods::Get().ASurfaceTransaction_setFrameRateFn !=
+ nullptr;
+}
+
SurfaceControl::Surface::Surface() = default;
SurfaceControl::Surface::Surface(const Surface& parent, const char* name) {
@@ -443,6 +468,17 @@ void SurfaceControl::Transaction::SetColorSpace(
transaction_, surface.surface(), data_space);
}
+void SurfaceControl::Transaction::SetFrameRate(const Surface& surface,
+ float frame_rate) {
+ DCHECK(SupportsSetFrameRate());
+
+ // We always used fixed source here since a non-default value is only used for
+ // videos which have a fixed playback rate.
+ SurfaceControlMethods::Get().ASurfaceTransaction_setFrameRateFn(
+ transaction_, surface.surface(), frame_rate,
+ ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_FIXED_SOURCE);
+}
+
void SurfaceControl::Transaction::SetOnCompleteCb(
OnCompleteCb cb,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
diff --git a/chromium/ui/gl/android/android_surface_control_compat.h b/chromium/ui/gl/android/android_surface_control_compat.h
index c46bf653d2f..c5baeb7807d 100644
--- a/chromium/ui/gl/android/android_surface_control_compat.h
+++ b/chromium/ui/gl/android/android_surface_control_compat.h
@@ -47,6 +47,9 @@ class GL_EXPORT SurfaceControl {
// called early at process startup, before any buffer allocations are made.
static void EnableQualcommUBWC();
+ // Returns true if tagging a surface with a frame rate value is supported.
+ static bool SupportsSetFrameRate();
+
class GL_EXPORT Surface : public base::RefCounted<Surface> {
public:
Surface();
@@ -117,6 +120,7 @@ class GL_EXPORT SurfaceControl {
void SetDamageRect(const Surface& surface, const gfx::Rect& rect);
void SetColorSpace(const Surface& surface,
const gfx::ColorSpace& color_space);
+ void SetFrameRate(const Surface& surface, float frame_rate);
// Sets the callback which will be dispatched when the transaction is acked
// by the framework.
diff --git a/chromium/ui/gl/android/scoped_java_surface.cc b/chromium/ui/gl/android/scoped_java_surface.cc
index 67df19a67fc..b9dda95db22 100644
--- a/chromium/ui/gl/android/scoped_java_surface.cc
+++ b/chromium/ui/gl/android/scoped_java_surface.cc
@@ -4,7 +4,7 @@
#include "ui/gl/android/scoped_java_surface.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/gl/android/surface_texture.h"
#include "ui/gl/surface_jni_headers/Surface_jni.h"
diff --git a/chromium/ui/gl/android/surface_texture.cc b/chromium/ui/gl/android/surface_texture.cc
index 1ae21039988..9005ae73340 100644
--- a/chromium/ui/gl/android/surface_texture.cc
+++ b/chromium/ui/gl/android/surface_texture.cc
@@ -8,8 +8,8 @@
#include <utility>
#include "base/android/jni_android.h"
+#include "base/check.h"
#include "base/debug/crash_logging.h"
-#include "base/logging.h"
#include "ui/gl/android/scoped_java_surface.h"
#include "ui/gl/android/surface_texture_listener.h"
#include "ui/gl/gl_bindings.h"
diff --git a/chromium/ui/gl/direct_composition_child_surface_win.cc b/chromium/ui/gl/direct_composition_child_surface_win.cc
index f132887eed8..197d9798cb5 100644
--- a/chromium/ui/gl/direct_composition_child_surface_win.cc
+++ b/chromium/ui/gl/direct_composition_child_surface_win.cc
@@ -33,6 +33,8 @@
#ifndef EGL_ANGLE_d3d_texture_client_buffer
#define EGL_ANGLE_d3d_texture_client_buffer 1
#define EGL_D3D_TEXTURE_ANGLE 0x33A3
+#define EGL_TEXTURE_OFFSET_X_ANGLE 0x3490
+#define EGL_TEXTURE_OFFSET_Y_ANGLE 0x3491
#endif /* EGL_ANGLE_d3d_texture_client_buffer */
namespace gl {
@@ -45,7 +47,9 @@ IDCompositionSurface* g_current_surface = nullptr;
} // namespace
-DirectCompositionChildSurfaceWin::DirectCompositionChildSurfaceWin() = default;
+DirectCompositionChildSurfaceWin::DirectCompositionChildSurfaceWin(
+ bool use_angle_texture_offset)
+ : use_angle_texture_offset_(use_angle_texture_offset) {}
DirectCompositionChildSurfaceWin::~DirectCompositionChildSurfaceWin() {
Destroy();
@@ -317,16 +321,12 @@ bool DirectCompositionChildSurfaceWin::SetDrawRectangle(
first_swap_ = true;
base::UmaHistogramSparse(
"GPU.DirectComposition.CreateSwapChainForComposition", hr);
- if (FAILED(hr)) {
- DLOG(ERROR) << "CreateSwapChainForComposition failed with error "
- << std::hex << hr;
- // If CreateSwapChainForComposition fails, we cannot draw to the
- // browser window. Failure here is indicative of an unrecoverable driver
- // bug. Hence, terminate immediately and let the browser process start
- // a fresh new instance.
- base::Process::TerminateCurrentProcessImmediately(0);
- // No code runs beyond this point.
- }
+
+ // If CreateSwapChainForComposition fails, we cannot draw to the
+ // browser window. Failure here is indicative of an unrecoverable driver
+ // bug.
+ CHECK(SUCCEEDED(hr));
+
Microsoft::WRL::ComPtr<IDXGISwapChain3> swap_chain;
if (SUCCEEDED(swap_chain_.As(&swap_chain))) {
hr = swap_chain->SetColorSpace1(
@@ -358,21 +358,26 @@ bool DirectCompositionChildSurfaceWin::SetDrawRectangle(
g_current_surface = dcomp_surface_.Get();
- EGLint pbuffer_attribs[] = {
- EGL_WIDTH,
- size_.width(),
- EGL_HEIGHT,
- size_.height(),
- EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE,
- EGL_TRUE,
- EGL_NONE,
- };
+ std::vector<EGLint> pbuffer_attribs;
+ pbuffer_attribs.push_back(EGL_WIDTH);
+ pbuffer_attribs.push_back(size_.width());
+ pbuffer_attribs.push_back(EGL_HEIGHT);
+ pbuffer_attribs.push_back(size_.height());
+ pbuffer_attribs.push_back(EGL_FLEXIBLE_SURFACE_COMPATIBILITY_SUPPORTED_ANGLE);
+ pbuffer_attribs.push_back(EGL_TRUE);
+ if (use_angle_texture_offset_) {
+ pbuffer_attribs.push_back(EGL_TEXTURE_OFFSET_X_ANGLE);
+ pbuffer_attribs.push_back(draw_offset_.x());
+ pbuffer_attribs.push_back(EGL_TEXTURE_OFFSET_Y_ANGLE);
+ pbuffer_attribs.push_back(draw_offset_.y());
+ }
+ pbuffer_attribs.push_back(EGL_NONE);
EGLClientBuffer buffer =
reinterpret_cast<EGLClientBuffer>(draw_texture_.Get());
- real_surface_ =
- eglCreatePbufferFromClientBuffer(GetDisplay(), EGL_D3D_TEXTURE_ANGLE,
- buffer, GetConfig(), pbuffer_attribs);
+ real_surface_ = eglCreatePbufferFromClientBuffer(
+ GetDisplay(), EGL_D3D_TEXTURE_ANGLE, buffer, GetConfig(),
+ pbuffer_attribs.data());
if (!real_surface_) {
DLOG(ERROR) << "eglCreatePbufferFromClientBuffer failed with error "
<< ui::GetLastEGLErrorString();
@@ -389,8 +394,13 @@ bool DirectCompositionChildSurfaceWin::SetDrawRectangle(
return true;
}
+void DirectCompositionChildSurfaceWin::SetDCompSurfaceForTesting(
+ Microsoft::WRL::ComPtr<IDCompositionSurface> surface) {
+ dcomp_surface_ = std::move(surface);
+}
+
gfx::Vector2d DirectCompositionChildSurfaceWin::GetDrawOffset() const {
- return draw_offset_;
+ return use_angle_texture_offset_ ? gfx::Vector2d() : draw_offset_;
}
void DirectCompositionChildSurfaceWin::SetVSyncEnabled(bool enabled) {
diff --git a/chromium/ui/gl/direct_composition_child_surface_win.h b/chromium/ui/gl/direct_composition_child_surface_win.h
index 5b8cacb4f6b..8708087a1dd 100644
--- a/chromium/ui/gl/direct_composition_child_surface_win.h
+++ b/chromium/ui/gl/direct_composition_child_surface_win.h
@@ -10,13 +10,14 @@
#include <dcomp.h>
#include <wrl/client.h>
+#include "ui/gl/gl_export.h"
#include "ui/gl/gl_surface_egl.h"
namespace gl {
-class DirectCompositionChildSurfaceWin : public GLSurfaceEGL {
+class GL_EXPORT DirectCompositionChildSurfaceWin : public GLSurfaceEGL {
public:
- DirectCompositionChildSurfaceWin();
+ explicit DirectCompositionChildSurfaceWin(bool use_angle_texture_offset);
// GLSurfaceEGL implementation.
bool Initialize(GLSurfaceFormat format) override;
@@ -48,6 +49,9 @@ class DirectCompositionChildSurfaceWin : public GLSurfaceEGL {
uint64_t dcomp_surface_serial() const { return dcomp_surface_serial_; }
+ void SetDCompSurfaceForTesting(
+ Microsoft::WRL::ComPtr<IDCompositionSurface> surface);
+
protected:
~DirectCompositionChildSurfaceWin() override;
@@ -57,6 +61,8 @@ class DirectCompositionChildSurfaceWin : public GLSurfaceEGL {
// to it. Returns false if this fails.
bool ReleaseDrawTexture(bool will_discard);
+ const bool use_angle_texture_offset_;
+
gfx::Size size_ = gfx::Size(1, 1);
bool enable_dc_layers_ = false;
bool has_alpha_ = true;
diff --git a/chromium/ui/gl/direct_composition_surface_win.cc b/chromium/ui/gl/direct_composition_surface_win.cc
index 4131d2e3e48..94d32c59d67 100644
--- a/chromium/ui/gl/direct_composition_surface_win.cc
+++ b/chromium/ui/gl/direct_composition_surface_win.cc
@@ -36,7 +36,7 @@ namespace gl {
namespace {
// Whether the overlay caps are valid or not. GUARDED_BY GetOverlayLock().
bool g_overlay_caps_valid = false;
-// Indicates support for either NV12 or YUY2 hardware overlays. GUARDED_BY
+// Indicates support for either NV12 or YUY2 overlays. GUARDED_BY
// GetOverlayLock().
bool g_supports_overlays = false;
@@ -67,7 +67,7 @@ void SetOverlayCapsValid(bool valid) {
// Used for workaround limiting overlay size to monitor size.
gfx::Size g_overlay_monitor_size;
-// Preferred overlay format set when detecting hardware overlay support during
+// Preferred overlay format set when detecting overlay support during
// initialization. Set to NV12 by default so that it's used when enabling
// overlays using command line flags.
DXGI_FORMAT g_overlay_format_used = DXGI_FORMAT_NV12;
@@ -82,11 +82,11 @@ bool FlagsSupportsOverlays(UINT flags) {
DXGI_OVERLAY_SUPPORT_FLAG_SCALING));
}
-void GetGpuDriverHardwareOverlayInfo(bool* supports_overlays,
- DXGI_FORMAT* overlay_format_used,
- UINT* nv12_overlay_support_flags,
- UINT* yuy2_overlay_support_flags,
- gfx::Size* overlay_monitor_size) {
+void GetGpuDriverOverlayInfo(bool* supports_overlays,
+ DXGI_FORMAT* overlay_format_used,
+ UINT* nv12_overlay_support_flags,
+ UINT* yuy2_overlay_support_flags,
+ gfx::Size* overlay_monitor_size) {
// Initialization
*supports_overlays = false;
*overlay_format_used = DXGI_FORMAT_NV12;
@@ -182,6 +182,7 @@ void GetGpuDriverHardwareOverlayInfo(bool* supports_overlays,
gfx::Rect(monitor_desc.DesktopCoordinates).size();
}
}
+
// Early out after the first output that reports overlay support. All
// outputs are expected to report the same overlay support according to
// Microsoft's WDDM documentation:
@@ -191,9 +192,27 @@ void GetGpuDriverHardwareOverlayInfo(bool* supports_overlays,
if (*supports_overlays)
break;
}
+
+ if (*supports_overlays || !base::FeatureList::IsEnabled(
+ features::kDirectCompositionSoftwareOverlays)) {
+ return;
+ }
+
+ // If no devices with hardware overlay support were found use software ones.
+ *supports_overlays = true;
+ *nv12_overlay_support_flags = 0;
+ *yuy2_overlay_support_flags = 0;
+
+ // Software overlays always use NV12 because it's slightly more efficient and
+ // YUY2 was only used because Skylake doesn't support NV12 hardware overlays.
+ *overlay_format_used = DXGI_FORMAT_NV12;
+
+ // This is only needed for https://crbug.com/720059 which is Intel only -- it
+ // doesn't affect software overlays.
+ *overlay_monitor_size = gfx::Size();
}
-void UpdateHardwareOverlaySupport() {
+void UpdateOverlaySupport() {
if (OverlayCapsValid())
return;
SetOverlayCapsValid(true);
@@ -204,9 +223,9 @@ void UpdateHardwareOverlaySupport() {
UINT yuy2_overlay_support_flags = 0;
gfx::Size overlay_monitor_size = gfx::Size();
- GetGpuDriverHardwareOverlayInfo(
- &supports_overlays, &overlay_format_used, &nv12_overlay_support_flags,
- &yuy2_overlay_support_flags, &overlay_monitor_size);
+ GetGpuDriverOverlayInfo(&supports_overlays, &overlay_format_used,
+ &nv12_overlay_support_flags,
+ &yuy2_overlay_support_flags, &overlay_monitor_size);
if (supports_overlays != SupportsOverlays() ||
overlay_format_used != g_overlay_format_used) {
@@ -259,7 +278,8 @@ DirectCompositionSurfaceWin::DirectCompositionSurfaceWin(
: GLSurfaceEGL(),
child_window_(parent_window),
task_runner_(base::ThreadTaskRunnerHandle::Get()),
- root_surface_(new DirectCompositionChildSurfaceWin()),
+ root_surface_(new DirectCompositionChildSurfaceWin(
+ settings.use_angle_texture_offset)),
layer_tree_(std::make_unique<DCLayerTree>(
settings.disable_nv12_dynamic_textures,
settings.disable_larger_than_screen_overlays,
@@ -338,7 +358,7 @@ bool DirectCompositionSurfaceWin::IsDirectCompositionSupported() {
bool DirectCompositionSurfaceWin::AreOverlaysSupported() {
// Always initialize and record overlay support information irrespective of
// command line flags.
- UpdateHardwareOverlaySupport();
+ UpdateOverlaySupport();
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
// Enable flag should be checked before the disable flag, so we could
@@ -355,7 +375,7 @@ bool DirectCompositionSurfaceWin::AreOverlaysSupported() {
bool DirectCompositionSurfaceWin::IsDecodeSwapChainSupported() {
if (base::FeatureList::IsEnabled(
features::kDirectCompositionUseNV12DecodeSwapChain)) {
- UpdateHardwareOverlaySupport();
+ UpdateOverlaySupport();
return GetOverlayFormatUsed() == DXGI_FORMAT_NV12;
}
return false;
@@ -373,16 +393,20 @@ void DirectCompositionSurfaceWin::InvalidateOverlayCaps() {
// static
bool DirectCompositionSurfaceWin::AreScaledOverlaysSupported() {
- UpdateHardwareOverlaySupport();
- if (g_overlay_format_used == DXGI_FORMAT_NV12)
- return !!(g_nv12_overlay_support_flags & DXGI_OVERLAY_SUPPORT_FLAG_SCALING);
+ UpdateOverlaySupport();
+ if (g_overlay_format_used == DXGI_FORMAT_NV12) {
+ return (g_nv12_overlay_support_flags & DXGI_OVERLAY_SUPPORT_FLAG_SCALING) ||
+ (SupportsOverlays() &&
+ base::FeatureList::IsEnabled(
+ features::kDirectCompositionSoftwareOverlays));
+ }
DCHECK_EQ(DXGI_FORMAT_YUY2, g_overlay_format_used);
return !!(g_yuy2_overlay_support_flags & DXGI_OVERLAY_SUPPORT_FLAG_SCALING);
}
// static
UINT DirectCompositionSurfaceWin::GetOverlaySupportFlags(DXGI_FORMAT format) {
- UpdateHardwareOverlaySupport();
+ UpdateOverlaySupport();
if (format == DXGI_FORMAT_NV12)
return g_nv12_overlay_support_flags;
DCHECK_EQ(DXGI_FORMAT_YUY2, format);
@@ -402,7 +426,7 @@ DXGI_FORMAT DirectCompositionSurfaceWin::GetOverlayFormatUsed() {
// static
void DirectCompositionSurfaceWin::SetScaledOverlaysSupportedForTesting(
bool supported) {
- UpdateHardwareOverlaySupport();
+ UpdateOverlaySupport();
if (supported) {
g_nv12_overlay_support_flags |= DXGI_OVERLAY_SUPPORT_FLAG_SCALING;
g_yuy2_overlay_support_flags |= DXGI_OVERLAY_SUPPORT_FLAG_SCALING;
@@ -417,7 +441,7 @@ void DirectCompositionSurfaceWin::SetScaledOverlaysSupportedForTesting(
void DirectCompositionSurfaceWin::SetOverlayFormatUsedForTesting(
DXGI_FORMAT format) {
DCHECK(format == DXGI_FORMAT_NV12 || format == DXGI_FORMAT_YUY2);
- UpdateHardwareOverlaySupport();
+ UpdateOverlaySupport();
g_overlay_format_used = format;
DCHECK_EQ(format, GetOverlayFormatUsed());
}
@@ -576,6 +600,16 @@ void DirectCompositionSurfaceWin::Destroy() {
// Destroy presentation helper first because its dtor calls GetHandle.
presentation_helper_ = nullptr;
root_surface_->Destroy();
+
+ // Freeing DComp resources such as visuals and surfaces causes the
+ // device to become 'dirty'. We must commit the changes to the device
+ // in order for the objects to actually be destroyed.
+ // Leaving the device in the dirty state for long periods of time means
+ // that if DWM.exe crashes, the Chromium window will become black until
+ // the next Commit.
+ layer_tree_.reset();
+ if (dcomp_device_)
+ dcomp_device_->Commit();
}
gfx::Size DirectCompositionSurfaceWin::GetSize() {
@@ -812,12 +846,12 @@ void DirectCompositionSurfaceWin::OnGpuSwitched(
void DirectCompositionSurfaceWin::OnDisplayAdded() {
InvalidateOverlayCaps();
- UpdateHardwareOverlaySupport();
+ UpdateOverlaySupport();
}
void DirectCompositionSurfaceWin::OnDisplayRemoved() {
InvalidateOverlayCaps();
- UpdateHardwareOverlaySupport();
+ UpdateOverlaySupport();
}
scoped_refptr<base::TaskRunner>
@@ -835,4 +869,9 @@ DirectCompositionSurfaceWin::GetBackbufferSwapChainForTesting() const {
return root_surface_->swap_chain();
}
+scoped_refptr<DirectCompositionChildSurfaceWin>
+DirectCompositionSurfaceWin::GetRootSurfaceForTesting() const {
+ return root_surface_;
+}
+
} // namespace gl
diff --git a/chromium/ui/gl/direct_composition_surface_win.h b/chromium/ui/gl/direct_composition_surface_win.h
index 54b7237d19d..aeef4c28d6f 100644
--- a/chromium/ui/gl/direct_composition_surface_win.h
+++ b/chromium/ui/gl/direct_composition_surface_win.h
@@ -36,6 +36,7 @@ class GL_EXPORT DirectCompositionSurfaceWin : public GLSurfaceEGL,
bool disable_larger_than_screen_overlays = false;
bool disable_vp_scaling = false;
size_t max_pending_frames = 2;
+ bool use_angle_texture_offset = false;
};
DirectCompositionSurfaceWin(
@@ -45,21 +46,20 @@ class GL_EXPORT DirectCompositionSurfaceWin : public GLSurfaceEGL,
const DirectCompositionSurfaceWin::Settings& settings);
// Returns true if direct composition is supported. We prefer to use direct
- // composition event without hardware overlays, because it allows us to bypass
+ // composition even without hardware overlays, because it allows us to bypass
// blitting by DWM to the window redirection surface by using a flip mode swap
// chain. Overridden with --disable-direct-composition.
static bool IsDirectCompositionSupported();
- // Returns true if hardware video overlays are supported and should be used.
- // Overridden with --enable-direct-composition-video-overlays and
- // --disable-direct-composition-video-overlays.
- // This function is thread safe.
+ // Returns true if video overlays are supported and should be used. Overridden
+ // with --enable-direct-composition-video-overlays and
+ // --disable-direct-composition-video-overlays. This function is thread safe.
static bool AreOverlaysSupported();
// Returns true if zero copy decode swap chain is supported.
static bool IsDecodeSwapChainSupported();
- // After this is called, hardware overlay support is disabled during the
+ // After this is called, overlay support is disabled during the
// current GPU process' lifetime.
static void DisableOverlays();
@@ -69,8 +69,7 @@ class GL_EXPORT DirectCompositionSurfaceWin : public GLSurfaceEGL,
// Returns true if scaled hardware overlays are supported.
static bool AreScaledOverlaysSupported();
- // Returns preferred overlay format set when detecting hardware overlay
- // support.
+ // Returns preferred overlay format set when detecting overlay support.
static DXGI_FORMAT GetOverlayFormatUsed();
// Returns monitor size.
@@ -146,6 +145,9 @@ class GL_EXPORT DirectCompositionSurfaceWin : public GLSurfaceEGL,
Microsoft::WRL::ComPtr<IDXGISwapChain1> GetBackbufferSwapChainForTesting()
const;
+ scoped_refptr<DirectCompositionChildSurfaceWin> GetRootSurfaceForTesting()
+ const;
+
protected:
~DirectCompositionSurfaceWin() override;
diff --git a/chromium/ui/gl/direct_composition_surface_win_unittest.cc b/chromium/ui/gl/direct_composition_surface_win_unittest.cc
index 69029d968ea..9c03f576b29 100644
--- a/chromium/ui/gl/direct_composition_surface_win_unittest.cc
+++ b/chromium/ui/gl/direct_composition_surface_win_unittest.cc
@@ -4,6 +4,9 @@
#include "ui/gl/direct_composition_surface_win.h"
+#include <wrl/client.h>
+#include <wrl/implements.h>
+
#include "base/bind_helpers.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/weak_ptr.h"
@@ -19,6 +22,7 @@
#include "ui/gfx/gdi_util.h"
#include "ui/gfx/transform.h"
#include "ui/gl/dc_renderer_layer_params.h"
+#include "ui/gl/direct_composition_child_surface_win.h"
#include "ui/gl/gl_angle_util_win.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_image_d3d.h"
@@ -50,8 +54,8 @@ class TestPlatformDelegate : public ui::PlatformWindowDelegate {
void RunPendingTasks(scoped_refptr<base::TaskRunner> task_runner) {
base::WaitableEvent done(base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
- task_runner->PostTask(FROM_HERE,
- Bind(&base::WaitableEvent::Signal, Unretained(&done)));
+ task_runner->PostTask(
+ FROM_HERE, BindOnce(&base::WaitableEvent::Signal, Unretained(&done)));
done.Wait();
}
@@ -1235,5 +1239,98 @@ TEST_F(DirectCompositionPixelTest, SwapChainImage) {
}
}
+// Offsets BeginDraw update rect so that the returned update offset is also
+// offset by at least the same amount from the original update rect.
+class DrawOffsetOverridingDCompositionSurface
+ : public Microsoft::WRL::RuntimeClass<
+ Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
+ IDCompositionSurface> {
+ public:
+ DrawOffsetOverridingDCompositionSurface(
+ Microsoft::WRL::ComPtr<IDCompositionSurface> surface,
+ const gfx::Point& draw_offset)
+ : surface_(std::move(surface)), draw_offset_(draw_offset) {}
+
+ IFACEMETHODIMP BeginDraw(const RECT* updateRect,
+ REFIID iid,
+ void** updateObject,
+ POINT* updateOffset) override {
+ RECT offsetRect = *updateRect;
+ offsetRect.left += draw_offset_.x();
+ offsetRect.right += draw_offset_.x();
+ offsetRect.top += draw_offset_.y();
+ offsetRect.bottom += draw_offset_.y();
+ return surface_->BeginDraw(&offsetRect, iid, updateObject, updateOffset);
+ }
+
+ IFACEMETHODIMP EndDraw() override { return surface_->EndDraw(); }
+
+ IFACEMETHODIMP ResumeDraw() override { return surface_->ResumeDraw(); }
+
+ IFACEMETHODIMP SuspendDraw() override { return surface_->SuspendDraw(); }
+
+ IFACEMETHODIMP Scroll(const RECT* scrollRect,
+ const RECT* clipRect,
+ int offsetX,
+ int offsetY) override {
+ return surface_->Scroll(scrollRect, clipRect, offsetX, offsetY);
+ }
+
+ private:
+ Microsoft::WRL::ComPtr<IDCompositionSurface> surface_;
+ const gfx::Point draw_offset_;
+};
+
+TEST_F(DirectCompositionPixelTest, RootSurfaceDrawOffset) {
+ if (!surface_)
+ return;
+
+ constexpr gfx::Size window_size(100, 100);
+ EXPECT_TRUE(surface_->Resize(window_size, 1.0, gfx::ColorSpace(), true));
+ EXPECT_TRUE(surface_->SetDrawRectangle(gfx::Rect(window_size)));
+
+ glClearColor(0.0, 0.0, 1.0, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK,
+ surface_->SwapBuffers(base::DoNothing()));
+
+ constexpr gfx::Point draw_offset(50, 50);
+ auto root_surface = surface_->GetRootSurfaceForTesting();
+ auto dcomp_surface =
+ Microsoft::WRL::Make<DrawOffsetOverridingDCompositionSurface>(
+ root_surface->dcomp_surface(), draw_offset);
+ root_surface->SetDCompSurfaceForTesting(std::move(dcomp_surface));
+
+ // Even though draw_rect is the first quadrant, the rendering will be limited
+ // to the third quadrant because the dcomp surface will return that offset.
+ constexpr gfx::Rect draw_rect(0, 0, 50, 50);
+ EXPECT_TRUE(surface_->SetDrawRectangle(draw_rect));
+
+ glClearColor(1.0, 0.0, 0.0, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ EXPECT_EQ(gfx::SwapResult::SWAP_ACK,
+ surface_->SwapBuffers(base::DoNothing()));
+
+ Sleep(1000);
+
+ // Note: The colors read back are BGRA so the expected colors are inverted
+ // with respect to the clear color.
+ struct {
+ gfx::Point position;
+ SkColor expected_color;
+ } test_cases[] = {{gfx::Point(75, 75), SkColorSetRGB(255, 0, 0)},
+ {gfx::Point(25, 25), SkColorSetRGB(0, 0, 255)}};
+
+ for (const auto& test_case : test_cases) {
+ SkColor actual_color =
+ ReadBackWindowPixel(window_.hwnd(), test_case.position);
+ EXPECT_TRUE(AreColorsSimilar(test_case.expected_color, actual_color))
+ << std::hex << "Expected " << test_case.expected_color << " Actual "
+ << actual_color;
+ }
+}
+
} // namespace
} // namespace gl
diff --git a/chromium/ui/gl/dual_gpu_state_mac.cc b/chromium/ui/gl/dual_gpu_state_mac.cc
index c9c5190572f..af4de0e1ff1 100644
--- a/chromium/ui/gl/dual_gpu_state_mac.cc
+++ b/chromium/ui/gl/dual_gpu_state_mac.cc
@@ -10,7 +10,6 @@
#include "base/bind.h"
#include "base/cancelable_callback.h"
#include "base/location.h"
-#include "base/logging.h"
#include "base/no_destructor.h"
#include "base/single_thread_task_runner.h"
#include "base/synchronization/lock.h"
diff --git a/chromium/ui/gl/features.gni b/chromium/ui/gl/features.gni
index 1d5898cd68f..cb2c986495d 100644
--- a/chromium/ui/gl/features.gni
+++ b/chromium/ui/gl/features.gni
@@ -19,3 +19,11 @@ declare_args() {
# Independent of use_dawn, which controls whether Dawn is used in Chromium.
build_dawn_tests = is_mac || is_win || is_linux
}
+
+declare_args() {
+ enable_swiftshader = (is_win || is_linux || (is_mac && use_egl) ||
+ is_chromeos || is_fuchsia) &&
+ (target_cpu == "x86" || target_cpu == "x64" ||
+ target_cpu == "arm" || target_cpu == "arm64" ||
+ target_cpu == "mipsel" || target_cpu == "mips64el")
+}
diff --git a/chromium/ui/gl/generate_bindings.py b/chromium/ui/gl/generate_bindings.py
index 01da79a95f8..c682b59b2d0 100755
--- a/chromium/ui/gl/generate_bindings.py
+++ b/chromium/ui/gl/generate_bindings.py
@@ -540,7 +540,8 @@ GL_FUNCTIONS = [
{ 'return_type': 'void',
'known_as': 'glDrawArraysInstancedBaseInstanceANGLE',
#TODO(shrekshao): workaround when native support not available for cmd decoder
- 'versions' : [{ 'name': 'glDrawArraysInstancedBaseInstance' },
+ 'versions' : [{ 'name': 'glDrawArraysInstancedBaseInstance',
+ 'extensions': ['GL_ARB_base_instance'] },
{ 'name': 'glDrawArraysInstancedBaseInstanceEXT' },
{ 'name': 'glDrawArraysInstancedBaseInstanceANGLE',
'extensions': ['GL_ANGLE_base_vertex_base_instance'] }],
@@ -569,7 +570,8 @@ GL_FUNCTIONS = [
{ 'return_type': 'void',
'known_as': 'glDrawElementsInstancedBaseVertexBaseInstanceANGLE',
#TODO(shrekshao): workaround when native support not available for cmd decoder
- 'versions' : [{ 'name': 'glDrawElementsInstancedBaseVertexBaseInstance' },
+ 'versions' : [{ 'name': 'glDrawElementsInstancedBaseVertexBaseInstance',
+ 'extensions': ['GL_ARB_base_instance'] },
{ 'name': 'glDrawElementsInstancedBaseVertexBaseInstanceEXT' },
{ 'name': 'glDrawElementsInstancedBaseVertexBaseInstanceANGLE',
'extensions': ['GL_ANGLE_base_vertex_base_instance'] }],
@@ -1293,6 +1295,10 @@ GL_FUNCTIONS = [
'names': ['glImportMemoryFdEXT'],
'arguments': 'GLuint memory, GLuint64 size, GLenum handleType, GLint fd', },
{ 'return_type': 'void',
+ 'names': ['glImportMemoryWin32HandleEXT'],
+ 'arguments': 'GLuint memory, GLuint64 size, GLenum handleType, void* handle',
+ },
+{ 'return_type': 'void',
'arguments': 'GLuint memory, GLuint64 size, GLenum handleType, GLuint handle',
'versions': [{'name': 'glImportMemoryZirconHandleANGLE',
'extensions': ['GL_ANGLE_memory_object_fuchsia']}]},
@@ -1300,6 +1306,9 @@ GL_FUNCTIONS = [
'names': ['glImportSemaphoreFdEXT'],
'arguments': 'GLuint semaphore, GLenum handleType, GLint fd', },
{ 'return_type': 'void',
+ 'names': ['glImportSemaphoreWin32HandleEXT'],
+ 'arguments': 'GLuint semaphore, GLenum handleType, void* handle', },
+{ 'return_type': 'void',
'arguments': 'GLuint semaphore, GLenum handleType, GLuint handle',
'versions': [{'name': 'glImportSemaphoreZirconHandleANGLE',
'extensions': ['GL_ANGLE_semaphore_fuchsia']}]},
@@ -2886,6 +2895,9 @@ FUNCTION_SETS = [
'GLES2/gl2chromium.h',
'GLES2/gl2extchromium.h'
], [
+ "GL_ARB_texture_swizzle",
+ "GL_EXT_texture_swizzle",
+ "GL_EXT_texture_format_BGRA8888",
"GL_EXT_unpack_subimage",
]
],
diff --git a/chromium/ui/gl/gl_bindings.cc b/chromium/ui/gl/gl_bindings.cc
index 913bc224927..3406fc728e1 100644
--- a/chromium/ui/gl/gl_bindings.cc
+++ b/chromium/ui/gl/gl_bindings.cc
@@ -4,10 +4,6 @@
#include "build/build_config.h"
-#if defined(USE_X11)
-#include "ui/gfx/x/x11.h"
-#endif // USE_X11
-
#if defined(USE_EGL)
#include <EGL/egl.h>
#endif
diff --git a/chromium/ui/gl/gl_bindings_api_autogen_gl.h b/chromium/ui/gl/gl_bindings_api_autogen_gl.h
index e205299e159..50f66d83266 100644
--- a/chromium/ui/gl/gl_bindings_api_autogen_gl.h
+++ b/chromium/ui/gl/gl_bindings_api_autogen_gl.h
@@ -881,6 +881,10 @@ void glImportMemoryFdEXTFn(GLuint memory,
GLuint64 size,
GLenum handleType,
GLint fd) override;
+void glImportMemoryWin32HandleEXTFn(GLuint memory,
+ GLuint64 size,
+ GLenum handleType,
+ void* handle) override;
void glImportMemoryZirconHandleANGLEFn(GLuint memory,
GLuint64 size,
GLenum handleType,
@@ -888,6 +892,9 @@ void glImportMemoryZirconHandleANGLEFn(GLuint memory,
void glImportSemaphoreFdEXTFn(GLuint semaphore,
GLenum handleType,
GLint fd) override;
+void glImportSemaphoreWin32HandleEXTFn(GLuint semaphore,
+ GLenum handleType,
+ void* handle) override;
void glImportSemaphoreZirconHandleANGLEFn(GLuint semaphore,
GLenum handleType,
GLuint handle) override;
diff --git a/chromium/ui/gl/gl_bindings_autogen_gl.cc b/chromium/ui/gl/gl_bindings_autogen_gl.cc
index d1dc1bbe6c5..67d468b0c34 100644
--- a/chromium/ui/gl/gl_bindings_autogen_gl.cc
+++ b/chromium/ui/gl/gl_bindings_autogen_gl.cc
@@ -309,6 +309,8 @@ void DriverGL::InitializeDynamicBindings(const GLVersionInfo* ver,
gfx::HasExtension(extensions, "GL_APPLE_vertex_array_object");
ext.b_GL_ARB_ES2_compatibility =
gfx::HasExtension(extensions, "GL_ARB_ES2_compatibility");
+ ext.b_GL_ARB_base_instance =
+ gfx::HasExtension(extensions, "GL_ARB_base_instance");
ext.b_GL_ARB_blend_func_extended =
gfx::HasExtension(extensions, "GL_ARB_blend_func_extended");
ext.b_GL_ARB_clear_texture =
@@ -341,6 +343,8 @@ void DriverGL::InitializeDynamicBindings(const GLVersionInfo* ver,
gfx::HasExtension(extensions, "GL_ARB_texture_multisample");
ext.b_GL_ARB_texture_storage =
gfx::HasExtension(extensions, "GL_ARB_texture_storage");
+ ext.b_GL_ARB_texture_swizzle =
+ gfx::HasExtension(extensions, "GL_ARB_texture_swizzle");
ext.b_GL_ARB_timer_query =
gfx::HasExtension(extensions, "GL_ARB_timer_query");
ext.b_GL_ARB_transform_feedback2 =
@@ -391,6 +395,8 @@ void DriverGL::InitializeDynamicBindings(const GLVersionInfo* ver,
gfx::HasExtension(extensions, "GL_EXT_memory_object");
ext.b_GL_EXT_memory_object_fd =
gfx::HasExtension(extensions, "GL_EXT_memory_object_fd");
+ ext.b_GL_EXT_memory_object_win32 =
+ gfx::HasExtension(extensions, "GL_EXT_memory_object_win32");
ext.b_GL_EXT_multisampled_render_to_texture =
gfx::HasExtension(extensions, "GL_EXT_multisampled_render_to_texture");
ext.b_GL_EXT_occlusion_query_boolean =
@@ -399,14 +405,20 @@ void DriverGL::InitializeDynamicBindings(const GLVersionInfo* ver,
ext.b_GL_EXT_semaphore = gfx::HasExtension(extensions, "GL_EXT_semaphore");
ext.b_GL_EXT_semaphore_fd =
gfx::HasExtension(extensions, "GL_EXT_semaphore_fd");
+ ext.b_GL_EXT_semaphore_win32 =
+ gfx::HasExtension(extensions, "GL_EXT_semaphore_win32");
ext.b_GL_EXT_shader_image_load_store =
gfx::HasExtension(extensions, "GL_EXT_shader_image_load_store");
ext.b_GL_EXT_texture_buffer =
gfx::HasExtension(extensions, "GL_EXT_texture_buffer");
ext.b_GL_EXT_texture_buffer_object =
gfx::HasExtension(extensions, "GL_EXT_texture_buffer_object");
+ ext.b_GL_EXT_texture_format_BGRA8888 =
+ gfx::HasExtension(extensions, "GL_EXT_texture_format_BGRA8888");
ext.b_GL_EXT_texture_storage =
gfx::HasExtension(extensions, "GL_EXT_texture_storage");
+ ext.b_GL_EXT_texture_swizzle =
+ gfx::HasExtension(extensions, "GL_EXT_texture_swizzle");
ext.b_GL_EXT_timer_query =
gfx::HasExtension(extensions, "GL_EXT_timer_query");
ext.b_GL_EXT_transform_feedback =
@@ -950,7 +962,7 @@ void DriverGL::InitializeDynamicBindings(const GLVersionInfo* ver,
GetGLProcAddress("glDrawArraysInstancedANGLE"));
}
- if (ver->IsAtLeastGL(4u, 2u)) {
+ if (ver->IsAtLeastGL(4u, 2u) || ext.b_GL_ARB_base_instance) {
fn.glDrawArraysInstancedBaseInstanceANGLEFn =
reinterpret_cast<glDrawArraysInstancedBaseInstanceANGLEProc>(
GetGLProcAddress("glDrawArraysInstancedBaseInstance"));
@@ -999,7 +1011,7 @@ void DriverGL::InitializeDynamicBindings(const GLVersionInfo* ver,
GetGLProcAddress("glDrawElementsInstancedANGLE"));
}
- if (ver->IsAtLeastGL(4u, 2u)) {
+ if (ver->IsAtLeastGL(4u, 2u) || ext.b_GL_ARB_base_instance) {
fn.glDrawElementsInstancedBaseVertexBaseInstanceANGLEFn = reinterpret_cast<
glDrawElementsInstancedBaseVertexBaseInstanceANGLEProc>(
GetGLProcAddress("glDrawElementsInstancedBaseVertexBaseInstance"));
@@ -1833,6 +1845,12 @@ void DriverGL::InitializeDynamicBindings(const GLVersionInfo* ver,
GetGLProcAddress("glImportMemoryFdEXT"));
}
+ if (ext.b_GL_EXT_memory_object_win32) {
+ fn.glImportMemoryWin32HandleEXTFn =
+ reinterpret_cast<glImportMemoryWin32HandleEXTProc>(
+ GetGLProcAddress("glImportMemoryWin32HandleEXT"));
+ }
+
if (ext.b_GL_ANGLE_memory_object_fuchsia) {
fn.glImportMemoryZirconHandleANGLEFn =
reinterpret_cast<glImportMemoryZirconHandleANGLEProc>(
@@ -1844,6 +1862,12 @@ void DriverGL::InitializeDynamicBindings(const GLVersionInfo* ver,
GetGLProcAddress("glImportSemaphoreFdEXT"));
}
+ if (ext.b_GL_EXT_semaphore_win32) {
+ fn.glImportSemaphoreWin32HandleEXTFn =
+ reinterpret_cast<glImportSemaphoreWin32HandleEXTProc>(
+ GetGLProcAddress("glImportSemaphoreWin32HandleEXT"));
+ }
+
if (ext.b_GL_ANGLE_semaphore_fuchsia) {
fn.glImportSemaphoreZirconHandleANGLEFn =
reinterpret_cast<glImportSemaphoreZirconHandleANGLEProc>(
@@ -4699,6 +4723,13 @@ void GLApiBase::glImportMemoryFdEXTFn(GLuint memory,
driver_->fn.glImportMemoryFdEXTFn(memory, size, handleType, fd);
}
+void GLApiBase::glImportMemoryWin32HandleEXTFn(GLuint memory,
+ GLuint64 size,
+ GLenum handleType,
+ void* handle) {
+ driver_->fn.glImportMemoryWin32HandleEXTFn(memory, size, handleType, handle);
+}
+
void GLApiBase::glImportMemoryZirconHandleANGLEFn(GLuint memory,
GLuint64 size,
GLenum handleType,
@@ -4713,6 +4744,12 @@ void GLApiBase::glImportSemaphoreFdEXTFn(GLuint semaphore,
driver_->fn.glImportSemaphoreFdEXTFn(semaphore, handleType, fd);
}
+void GLApiBase::glImportSemaphoreWin32HandleEXTFn(GLuint semaphore,
+ GLenum handleType,
+ void* handle) {
+ driver_->fn.glImportSemaphoreWin32HandleEXTFn(semaphore, handleType, handle);
+}
+
void GLApiBase::glImportSemaphoreZirconHandleANGLEFn(GLuint semaphore,
GLenum handleType,
GLuint handle) {
@@ -8304,6 +8341,15 @@ void TraceGLApi::glImportMemoryFdEXTFn(GLuint memory,
gl_api_->glImportMemoryFdEXTFn(memory, size, handleType, fd);
}
+void TraceGLApi::glImportMemoryWin32HandleEXTFn(GLuint memory,
+ GLuint64 size,
+ GLenum handleType,
+ void* handle) {
+ TRACE_EVENT_BINARY_EFFICIENT0("gpu",
+ "TraceGLAPI::glImportMemoryWin32HandleEXT")
+ gl_api_->glImportMemoryWin32HandleEXTFn(memory, size, handleType, handle);
+}
+
void TraceGLApi::glImportMemoryZirconHandleANGLEFn(GLuint memory,
GLuint64 size,
GLenum handleType,
@@ -8320,6 +8366,14 @@ void TraceGLApi::glImportSemaphoreFdEXTFn(GLuint semaphore,
gl_api_->glImportSemaphoreFdEXTFn(semaphore, handleType, fd);
}
+void TraceGLApi::glImportSemaphoreWin32HandleEXTFn(GLuint semaphore,
+ GLenum handleType,
+ void* handle) {
+ TRACE_EVENT_BINARY_EFFICIENT0("gpu",
+ "TraceGLAPI::glImportSemaphoreWin32HandleEXT")
+ gl_api_->glImportSemaphoreWin32HandleEXTFn(semaphore, handleType, handle);
+}
+
void TraceGLApi::glImportSemaphoreZirconHandleANGLEFn(GLuint semaphore,
GLenum handleType,
GLuint handle) {
@@ -12817,6 +12871,17 @@ void LogGLApi::glImportMemoryFdEXTFn(GLuint memory,
gl_api_->glImportMemoryFdEXTFn(memory, size, handleType, fd);
}
+void LogGLApi::glImportMemoryWin32HandleEXTFn(GLuint memory,
+ GLuint64 size,
+ GLenum handleType,
+ void* handle) {
+ GL_SERVICE_LOG("glImportMemoryWin32HandleEXT"
+ << "(" << memory << ", " << size << ", "
+ << GLEnums::GetStringEnum(handleType) << ", "
+ << static_cast<const void*>(handle) << ")");
+ gl_api_->glImportMemoryWin32HandleEXTFn(memory, size, handleType, handle);
+}
+
void LogGLApi::glImportMemoryZirconHandleANGLEFn(GLuint memory,
GLuint64 size,
GLenum handleType,
@@ -12837,6 +12902,16 @@ void LogGLApi::glImportSemaphoreFdEXTFn(GLuint semaphore,
gl_api_->glImportSemaphoreFdEXTFn(semaphore, handleType, fd);
}
+void LogGLApi::glImportSemaphoreWin32HandleEXTFn(GLuint semaphore,
+ GLenum handleType,
+ void* handle) {
+ GL_SERVICE_LOG("glImportSemaphoreWin32HandleEXT"
+ << "(" << semaphore << ", "
+ << GLEnums::GetStringEnum(handleType) << ", "
+ << static_cast<const void*>(handle) << ")");
+ gl_api_->glImportSemaphoreWin32HandleEXTFn(semaphore, handleType, handle);
+}
+
void LogGLApi::glImportSemaphoreZirconHandleANGLEFn(GLuint semaphore,
GLenum handleType,
GLuint handle) {
@@ -16860,6 +16935,13 @@ void NoContextGLApi::glImportMemoryFdEXTFn(GLuint memory,
NoContextHelper("glImportMemoryFdEXT");
}
+void NoContextGLApi::glImportMemoryWin32HandleEXTFn(GLuint memory,
+ GLuint64 size,
+ GLenum handleType,
+ void* handle) {
+ NoContextHelper("glImportMemoryWin32HandleEXT");
+}
+
void NoContextGLApi::glImportMemoryZirconHandleANGLEFn(GLuint memory,
GLuint64 size,
GLenum handleType,
@@ -16873,6 +16955,12 @@ void NoContextGLApi::glImportSemaphoreFdEXTFn(GLuint semaphore,
NoContextHelper("glImportSemaphoreFdEXT");
}
+void NoContextGLApi::glImportSemaphoreWin32HandleEXTFn(GLuint semaphore,
+ GLenum handleType,
+ void* handle) {
+ NoContextHelper("glImportSemaphoreWin32HandleEXT");
+}
+
void NoContextGLApi::glImportSemaphoreZirconHandleANGLEFn(GLuint semaphore,
GLenum handleType,
GLuint handle) {
diff --git a/chromium/ui/gl/gl_bindings_autogen_gl.h b/chromium/ui/gl/gl_bindings_autogen_gl.h
index a661aa5aeb4..498ba7d718b 100644
--- a/chromium/ui/gl/gl_bindings_autogen_gl.h
+++ b/chromium/ui/gl/gl_bindings_autogen_gl.h
@@ -1039,6 +1039,11 @@ typedef void(GL_BINDING_CALL* glImportMemoryFdEXTProc)(GLuint memory,
GLuint64 size,
GLenum handleType,
GLint fd);
+typedef void(GL_BINDING_CALL* glImportMemoryWin32HandleEXTProc)(
+ GLuint memory,
+ GLuint64 size,
+ GLenum handleType,
+ void* handle);
typedef void(GL_BINDING_CALL* glImportMemoryZirconHandleANGLEProc)(
GLuint memory,
GLuint64 size,
@@ -1047,6 +1052,10 @@ typedef void(GL_BINDING_CALL* glImportMemoryZirconHandleANGLEProc)(
typedef void(GL_BINDING_CALL* glImportSemaphoreFdEXTProc)(GLuint semaphore,
GLenum handleType,
GLint fd);
+typedef void(GL_BINDING_CALL* glImportSemaphoreWin32HandleEXTProc)(
+ GLuint semaphore,
+ GLenum handleType,
+ void* handle);
typedef void(GL_BINDING_CALL* glImportSemaphoreZirconHandleANGLEProc)(
GLuint semaphore,
GLenum handleType,
@@ -1925,6 +1934,7 @@ struct ExtensionsGL {
bool b_GL_APPLE_sync;
bool b_GL_APPLE_vertex_array_object;
bool b_GL_ARB_ES2_compatibility;
+ bool b_GL_ARB_base_instance;
bool b_GL_ARB_blend_func_extended;
bool b_GL_ARB_clear_texture;
bool b_GL_ARB_draw_buffers;
@@ -1942,6 +1952,7 @@ struct ExtensionsGL {
bool b_GL_ARB_sync;
bool b_GL_ARB_texture_multisample;
bool b_GL_ARB_texture_storage;
+ bool b_GL_ARB_texture_swizzle;
bool b_GL_ARB_timer_query;
bool b_GL_ARB_transform_feedback2;
bool b_GL_ARB_vertex_array_object;
@@ -1967,15 +1978,19 @@ struct ExtensionsGL {
bool b_GL_EXT_map_buffer_range;
bool b_GL_EXT_memory_object;
bool b_GL_EXT_memory_object_fd;
+ bool b_GL_EXT_memory_object_win32;
bool b_GL_EXT_multisampled_render_to_texture;
bool b_GL_EXT_occlusion_query_boolean;
bool b_GL_EXT_robustness;
bool b_GL_EXT_semaphore;
bool b_GL_EXT_semaphore_fd;
+ bool b_GL_EXT_semaphore_win32;
bool b_GL_EXT_shader_image_load_store;
bool b_GL_EXT_texture_buffer;
bool b_GL_EXT_texture_buffer_object;
+ bool b_GL_EXT_texture_format_BGRA8888;
bool b_GL_EXT_texture_storage;
+ bool b_GL_EXT_texture_swizzle;
bool b_GL_EXT_timer_query;
bool b_GL_EXT_transform_feedback;
bool b_GL_EXT_unpack_subimage;
@@ -2281,8 +2296,10 @@ struct ProcsGL {
glGetVertexAttribPointervRobustANGLEFn;
glHintProc glHintFn;
glImportMemoryFdEXTProc glImportMemoryFdEXTFn;
+ glImportMemoryWin32HandleEXTProc glImportMemoryWin32HandleEXTFn;
glImportMemoryZirconHandleANGLEProc glImportMemoryZirconHandleANGLEFn;
glImportSemaphoreFdEXTProc glImportSemaphoreFdEXTFn;
+ glImportSemaphoreWin32HandleEXTProc glImportSemaphoreWin32HandleEXTFn;
glImportSemaphoreZirconHandleANGLEProc glImportSemaphoreZirconHandleANGLEFn;
glInsertEventMarkerEXTProc glInsertEventMarkerEXTFn;
glInvalidateFramebufferProc glInvalidateFramebufferFn;
@@ -3419,6 +3436,10 @@ class GL_EXPORT GLApi {
GLuint64 size,
GLenum handleType,
GLint fd) = 0;
+ virtual void glImportMemoryWin32HandleEXTFn(GLuint memory,
+ GLuint64 size,
+ GLenum handleType,
+ void* handle) = 0;
virtual void glImportMemoryZirconHandleANGLEFn(GLuint memory,
GLuint64 size,
GLenum handleType,
@@ -3426,6 +3447,9 @@ class GL_EXPORT GLApi {
virtual void glImportSemaphoreFdEXTFn(GLuint semaphore,
GLenum handleType,
GLint fd) = 0;
+ virtual void glImportSemaphoreWin32HandleEXTFn(GLuint semaphore,
+ GLenum handleType,
+ void* handle) = 0;
virtual void glImportSemaphoreZirconHandleANGLEFn(GLuint semaphore,
GLenum handleType,
GLuint handle) = 0;
@@ -4615,10 +4639,14 @@ class GL_EXPORT GLApi {
::gl::g_current_gl_context->glGetVertexAttribPointervRobustANGLEFn
#define glHint ::gl::g_current_gl_context->glHintFn
#define glImportMemoryFdEXT ::gl::g_current_gl_context->glImportMemoryFdEXTFn
+#define glImportMemoryWin32HandleEXT \
+ ::gl::g_current_gl_context->glImportMemoryWin32HandleEXTFn
#define glImportMemoryZirconHandleANGLE \
::gl::g_current_gl_context->glImportMemoryZirconHandleANGLEFn
#define glImportSemaphoreFdEXT \
::gl::g_current_gl_context->glImportSemaphoreFdEXTFn
+#define glImportSemaphoreWin32HandleEXT \
+ ::gl::g_current_gl_context->glImportSemaphoreWin32HandleEXTFn
#define glImportSemaphoreZirconHandleANGLE \
::gl::g_current_gl_context->glImportSemaphoreZirconHandleANGLEFn
#define glInsertEventMarkerEXT \
diff --git a/chromium/ui/gl/gl_bindings_autogen_mock.cc b/chromium/ui/gl/gl_bindings_autogen_mock.cc
index 7161f202a60..b712d5c1851 100644
--- a/chromium/ui/gl/gl_bindings_autogen_mock.cc
+++ b/chromium/ui/gl/gl_bindings_autogen_mock.cc
@@ -2929,6 +2929,15 @@ MockGLInterface::Mock_glImportMemoryFdEXT(GLuint memory,
}
void GL_BINDING_CALL
+MockGLInterface::Mock_glImportMemoryWin32HandleEXT(GLuint memory,
+ GLuint64 size,
+ GLenum handleType,
+ void* handle) {
+ MakeGlMockFunctionUnique("glImportMemoryWin32HandleEXT");
+ interface_->ImportMemoryWin32HandleEXT(memory, size, handleType, handle);
+}
+
+void GL_BINDING_CALL
MockGLInterface::Mock_glImportMemoryZirconHandleANGLE(GLuint memory,
GLuint64 size,
GLenum handleType,
@@ -2946,6 +2955,14 @@ MockGLInterface::Mock_glImportSemaphoreFdEXT(GLuint semaphore,
}
void GL_BINDING_CALL
+MockGLInterface::Mock_glImportSemaphoreWin32HandleEXT(GLuint semaphore,
+ GLenum handleType,
+ void* handle) {
+ MakeGlMockFunctionUnique("glImportSemaphoreWin32HandleEXT");
+ interface_->ImportSemaphoreWin32HandleEXT(semaphore, handleType, handle);
+}
+
+void GL_BINDING_CALL
MockGLInterface::Mock_glImportSemaphoreZirconHandleANGLE(GLuint semaphore,
GLenum handleType,
GLuint handle) {
@@ -6029,11 +6046,17 @@ MockGLInterface::GetGLProcAddress(const char* name) {
return reinterpret_cast<GLFunctionPointerType>(Mock_glHint);
if (strcmp(name, "glImportMemoryFdEXT") == 0)
return reinterpret_cast<GLFunctionPointerType>(Mock_glImportMemoryFdEXT);
+ if (strcmp(name, "glImportMemoryWin32HandleEXT") == 0)
+ return reinterpret_cast<GLFunctionPointerType>(
+ Mock_glImportMemoryWin32HandleEXT);
if (strcmp(name, "glImportMemoryZirconHandleANGLE") == 0)
return reinterpret_cast<GLFunctionPointerType>(
Mock_glImportMemoryZirconHandleANGLE);
if (strcmp(name, "glImportSemaphoreFdEXT") == 0)
return reinterpret_cast<GLFunctionPointerType>(Mock_glImportSemaphoreFdEXT);
+ if (strcmp(name, "glImportSemaphoreWin32HandleEXT") == 0)
+ return reinterpret_cast<GLFunctionPointerType>(
+ Mock_glImportSemaphoreWin32HandleEXT);
if (strcmp(name, "glImportSemaphoreZirconHandleANGLE") == 0)
return reinterpret_cast<GLFunctionPointerType>(
Mock_glImportSemaphoreZirconHandleANGLE);
diff --git a/chromium/ui/gl/gl_bindings_autogen_mock.h b/chromium/ui/gl/gl_bindings_autogen_mock.h
index 0165308d12f..1387c72f19b 100644
--- a/chromium/ui/gl/gl_bindings_autogen_mock.h
+++ b/chromium/ui/gl/gl_bindings_autogen_mock.h
@@ -1279,6 +1279,10 @@ static void GL_BINDING_CALL Mock_glImportMemoryFdEXT(GLuint memory,
GLuint64 size,
GLenum handleType,
GLint fd);
+static void GL_BINDING_CALL Mock_glImportMemoryWin32HandleEXT(GLuint memory,
+ GLuint64 size,
+ GLenum handleType,
+ void* handle);
static void GL_BINDING_CALL
Mock_glImportMemoryZirconHandleANGLE(GLuint memory,
GLuint64 size,
@@ -1288,6 +1292,10 @@ static void GL_BINDING_CALL Mock_glImportSemaphoreFdEXT(GLuint semaphore,
GLenum handleType,
GLint fd);
static void GL_BINDING_CALL
+Mock_glImportSemaphoreWin32HandleEXT(GLuint semaphore,
+ GLenum handleType,
+ void* handle);
+static void GL_BINDING_CALL
Mock_glImportSemaphoreZirconHandleANGLE(GLuint semaphore,
GLenum handleType,
GLuint handle);
diff --git a/chromium/ui/gl/gl_context.cc b/chromium/ui/gl/gl_context.cc
index 30dbf1ea780..94cf06ed56c 100644
--- a/chromium/ui/gl/gl_context.cc
+++ b/chromium/ui/gl/gl_context.cc
@@ -272,6 +272,7 @@ void GLContext::DestroyBackpressureFences() {
void GLContext::FlushForDriverCrashWorkaround() {
if (!IsCurrent(nullptr))
return;
+ TRACE_EVENT0("gpu", "GLContext::FlushForDriverCrashWorkaround");
glFlush();
}
#endif
diff --git a/chromium/ui/gl/gl_context.h b/chromium/ui/gl/gl_context.h
index df670c3b039..48e9dd36276 100644
--- a/chromium/ui/gl/gl_context.h
+++ b/chromium/ui/gl/gl_context.h
@@ -13,6 +13,7 @@
#include "base/cancelable_callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "base/synchronization/atomic_flag.h"
#include "build/build_config.h"
#include "ui/gfx/extension_set.h"
@@ -90,7 +91,8 @@ struct GL_EXPORT GLContextAttribs {
};
// Encapsulates an OpenGL context, hiding platform specific management.
-class GL_EXPORT GLContext : public base::RefCounted<GLContext> {
+class GL_EXPORT GLContext : public base::RefCounted<GLContext>,
+ public base::SupportsWeakPtr<GLContext> {
public:
explicit GLContext(GLShareGroup* share_group);
diff --git a/chromium/ui/gl/gl_context_egl.cc b/chromium/ui/gl/gl_context_egl.cc
index d00a0a83a2d..cbcb9bc6bdd 100644
--- a/chromium/ui/gl/gl_context_egl.cc
+++ b/chromium/ui/gl/gl_context_egl.cc
@@ -11,12 +11,6 @@
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
-#if defined(USE_X11)
-// Must be included before khronos headers or they will pollute the
-// global scope with X11 macros.
-#include "ui/gfx/x/x11.h"
-#endif
-
#include "third_party/khronos/EGL/egl.h"
#include "third_party/khronos/EGL/eglext.h"
#include "ui/gl/egl_util.h"
@@ -63,6 +57,13 @@
#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103
#endif /* EGL_CONTEXT_PRIORITY_LEVEL */
+#ifndef EGL_ANGLE_power_preference
+#define EGL_ANGLE_power_preference 1
+#define EGL_POWER_PREFERENCE_ANGLE 0x3482
+#define EGL_LOW_POWER_ANGLE 0x0001
+#define EGL_HIGH_POWER_ANGLE 0x0002
+#endif /* EGL_ANGLE_power_preference */
+
using ui::GetLastEGLErrorString;
namespace gl {
@@ -202,6 +203,24 @@ bool GLContextEGL::Initialize(GLSurface* compatible_surface,
context_attributes.push_back(EGL_FALSE);
}
+ if (GLSurfaceEGL::IsANGLEPowerPreferenceSupported()) {
+ switch (attribs.gpu_preference) {
+ case GpuPreference ::kDefault:
+ // Don't request any GPU, let ANGLE and the native driver decide.
+ break;
+ case GpuPreference ::kLowPower:
+ context_attributes.push_back(EGL_POWER_PREFERENCE_ANGLE);
+ context_attributes.push_back(EGL_LOW_POWER_ANGLE);
+ break;
+ case GpuPreference ::kHighPerformance:
+ context_attributes.push_back(EGL_POWER_PREFERENCE_ANGLE);
+ context_attributes.push_back(EGL_HIGH_POWER_ANGLE);
+ break;
+ default:
+ NOTREACHED();
+ }
+ }
+
// Append final EGL_NONE to signal the context attributes are finished
context_attributes.push_back(EGL_NONE);
context_attributes.push_back(EGL_NONE);
diff --git a/chromium/ui/gl/gl_display_egl_util.cc b/chromium/ui/gl/gl_display_egl_util.cc
new file mode 100644
index 00000000000..923203a629e
--- /dev/null
+++ b/chromium/ui/gl/gl_display_egl_util.cc
@@ -0,0 +1,52 @@
+// Copyright 2020 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 "ui/gl/gl_display_egl_util.h"
+
+#include "base/no_destructor.h"
+
+namespace gl {
+
+namespace {
+
+static GLDisplayEglUtil* g_instance = nullptr;
+
+class GLDisplayEglUtilStub : public GLDisplayEglUtil {
+ public:
+ static GLDisplayEglUtilStub* GetInstance() {
+ static base::NoDestructor<GLDisplayEglUtilStub> instance;
+ return instance.get();
+ }
+ void GetPlatformExtraDisplayAttribs(
+ EGLenum platform_type,
+ std::vector<EGLAttrib>* attributes) override {}
+
+ void ChoosePlatformCustomAlphaAndBufferSize(EGLint* alpha_size,
+ EGLint* buffer_size) override {}
+
+ private:
+ friend base::NoDestructor<GLDisplayEglUtilStub>;
+
+ GLDisplayEglUtilStub() = default;
+ ~GLDisplayEglUtilStub() override = default;
+ GLDisplayEglUtilStub(const GLDisplayEglUtilStub& util) = delete;
+ GLDisplayEglUtilStub& operator=(const GLDisplayEglUtilStub& util) = delete;
+};
+
+} // namespace
+
+// static
+GLDisplayEglUtil* GLDisplayEglUtil::GetInstance() {
+ // If a platform specific impl is not set, create a stub instance.
+ if (!g_instance)
+ SetInstance(GLDisplayEglUtilStub::GetInstance());
+ return g_instance;
+}
+
+// static
+void GLDisplayEglUtil::SetInstance(GLDisplayEglUtil* gl_display_util) {
+ g_instance = gl_display_util;
+}
+
+} // namespace gl
diff --git a/chromium/ui/gl/gl_display_egl_util.h b/chromium/ui/gl/gl_display_egl_util.h
new file mode 100644
index 00000000000..1566704988c
--- /dev/null
+++ b/chromium/ui/gl/gl_display_egl_util.h
@@ -0,0 +1,47 @@
+// Copyright 2020 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 UI_GL_GL_DISPLAY_EGL_UTIL_H_
+#define UI_GL_GL_DISPLAY_EGL_UTIL_H_
+
+#include <vector>
+
+#include "third_party/khronos/EGL/egl.h"
+#include "ui/gl/gl_export.h"
+#include "ui/gl/gl_surface_egl.h"
+
+namespace gl {
+
+// Utility singleton class that helps to set additional egl properties. This
+// class should be implemented by each platform except Ozone. In case of Ozone,
+// there is a common implementation that forwards calls to a public interface of
+// a platform.
+// The reason why it is defined here in ui/gl is that ui/gl cannot depend on
+// ozone and we have to provide an interface here. ui/gl/init will provide an
+// implementation for this utility class upon initialization of gl.
+class GL_EXPORT GLDisplayEglUtil {
+ public:
+ // Returns either set instance or stub instance.
+ static GLDisplayEglUtil* GetInstance();
+
+ static void SetInstance(GLDisplayEglUtil* gl_display_util);
+
+ // Returns display attributes for the given |platform_type|. Each platform can
+ // have different attributes.
+ virtual void GetPlatformExtraDisplayAttribs(
+ EGLenum platform_type,
+ std::vector<EGLAttrib>* attributes) = 0;
+
+ // Sets custom alpha and buffer size for a given platform. By default, the
+ // values are not modified.
+ virtual void ChoosePlatformCustomAlphaAndBufferSize(EGLint* alpha_size,
+ EGLint* buffer_size) = 0;
+
+ protected:
+ virtual ~GLDisplayEglUtil() = default;
+};
+
+} // namespace gl
+
+#endif // UI_GL_GL_DISPLAY_EGL_UTIL_H_
diff --git a/chromium/ui/gl/gl_helper.cc b/chromium/ui/gl/gl_helper.cc
index 4378c6b8183..31f72f3d9b9 100644
--- a/chromium/ui/gl/gl_helper.cc
+++ b/chromium/ui/gl/gl_helper.cc
@@ -6,7 +6,7 @@
#include <string>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_version_info.h"
#include "ui/gl/scoped_binders.h"
diff --git a/chromium/ui/gl/gl_image_ahardwarebuffer_unittest.cc b/chromium/ui/gl/gl_image_ahardwarebuffer_unittest.cc
index fa92ef5d0ec..27e47ed046c 100644
--- a/chromium/ui/gl/gl_image_ahardwarebuffer_unittest.cc
+++ b/chromium/ui/gl/gl_image_ahardwarebuffer_unittest.cc
@@ -10,7 +10,9 @@
#include "base/memory/scoped_refptr.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gl/gl_image_ahardwarebuffer.h"
+#include "ui/gl/test/gl_image_bind_test_template.h"
#include "ui/gl/test/gl_image_test_template.h"
+#include "ui/gl/test/gl_image_zero_initialize_test_template.h"
namespace gl {
namespace {
diff --git a/chromium/ui/gl/gl_image_d3d_unittest.cc b/chromium/ui/gl/gl_image_d3d_unittest.cc
index b9d0331831a..e76c5598f24 100644
--- a/chromium/ui/gl/gl_image_d3d_unittest.cc
+++ b/chromium/ui/gl/gl_image_d3d_unittest.cc
@@ -7,7 +7,9 @@
#include "build/build_config.h"
#include "ui/gl/gl_angle_util_win.h"
#include "ui/gl/gl_bindings.h"
+#include "ui/gl/test/gl_image_bind_test_template.h"
#include "ui/gl/test/gl_image_test_template.h"
+#include "ui/gl/test/gl_image_zero_initialize_test_template.h"
namespace gl {
namespace {
diff --git a/chromium/ui/gl/gl_image_dxgi_unittest.cc b/chromium/ui/gl/gl_image_dxgi_unittest.cc
index 78ab903e133..668e7860a51 100644
--- a/chromium/ui/gl/gl_image_dxgi_unittest.cc
+++ b/chromium/ui/gl/gl_image_dxgi_unittest.cc
@@ -10,7 +10,9 @@
#include "ui/gfx/buffer_format_util.h"
#include "ui/gl/gl_angle_util_win.h"
#include "ui/gl/gl_image_dxgi.h"
+#include "ui/gl/test/gl_image_bind_test_template.h"
#include "ui/gl/test/gl_image_test_template.h"
+#include "ui/gl/test/gl_image_zero_initialize_test_template.h"
namespace gl {
namespace {
diff --git a/chromium/ui/gl/gl_image_io_surface_unittest.cc b/chromium/ui/gl/gl_image_io_surface_unittest.cc
index d321438c306..3488aebbdc7 100644
--- a/chromium/ui/gl/gl_image_io_surface_unittest.cc
+++ b/chromium/ui/gl/gl_image_io_surface_unittest.cc
@@ -11,7 +11,9 @@
#include "ui/gfx/buffer_format_util.h"
#include "ui/gfx/mac/io_surface.h"
#include "ui/gl/gl_image_io_surface.h"
+#include "ui/gl/test/gl_image_bind_test_template.h"
#include "ui/gl/test/gl_image_test_template.h"
+#include "ui/gl/test/gl_image_zero_initialize_test_template.h"
namespace gl {
namespace {
diff --git a/chromium/ui/gl/gl_image_memory.cc b/chromium/ui/gl/gl_image_memory.cc
index 138cf1774cc..433dae32f13 100644
--- a/chromium/ui/gl/gl_image_memory.cc
+++ b/chromium/ui/gl/gl_image_memory.cc
@@ -21,8 +21,10 @@
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_enums.h"
+#include "ui/gl/gl_surface.h"
#include "ui/gl/gl_version_info.h"
#include "ui/gl/scoped_binders.h"
+#include "ui/gl/scoped_make_current.h"
using gfx::BufferFormat;
@@ -227,8 +229,11 @@ GLImageMemory::GLImageMemory(const gfx::Size& size)
stride_(0) {}
GLImageMemory::~GLImageMemory() {
- if (buffer_)
+ if (buffer_ && original_context_ && original_surface_) {
+ ui::ScopedMakeCurrent make_current(original_context_.get(),
+ original_surface_.get());
glDeleteBuffersARB(1, &buffer_);
+ }
}
// static
@@ -262,6 +267,7 @@ bool GLImageMemory::Initialize(const unsigned char* memory,
tex_image_from_pbo_is_slow = true;
#endif // OS_WIN
GLContext* context = GLContext::GetCurrent();
+ DCHECK(context);
if (!tex_image_from_pbo_is_slow && SupportsPBO(context) &&
(SupportsMapBuffer(context) || SupportsMapBufferRange(context))) {
constexpr size_t kTaskBytes = 1024 * 1024;
@@ -273,6 +279,10 @@ bool GLImageMemory::Initialize(const unsigned char* memory,
ScopedBufferBinder binder(GL_PIXEL_UNPACK_BUFFER, buffer_);
glBufferData(GL_PIXEL_UNPACK_BUFFER, buffer_bytes_, nullptr,
GL_DYNAMIC_DRAW);
+ original_context_ = context->AsWeakPtr();
+ GLSurface* surface = GLSurface::GetCurrent();
+ DCHECK(surface);
+ original_surface_ = surface->AsWeakPtr();
}
}
@@ -332,7 +342,9 @@ bool GLImageMemory::CopyTexImage(unsigned target) {
GLint data_row_length = DataRowLength(stride_, format_);
base::Optional<std::vector<uint8_t>> gles2_data;
- if (GLContext::GetCurrent()->GetVersionInfo()->is_es) {
+ GLContext* context = GLContext::GetCurrent();
+ DCHECK(context);
+ if (context->GetVersionInfo()->is_es) {
gles2_data = GLES2Data(size_, format_, stride_, memory_, &data_format,
&data_type, &data_row_length);
}
@@ -350,17 +362,18 @@ bool GLImageMemory::CopyTexImage(unsigned target) {
size = buffer_bytes_;
}
- if (buffer_) {
+ bool uploaded = false;
+ if (buffer_ && original_context_.get() == context) {
glTexImage2D(target, 0, GetInternalFormat(), size_.width(), size_.height(),
0, data_format, data_type, nullptr);
ScopedBufferBinder binder(GL_PIXEL_UNPACK_BUFFER, buffer_);
void* dst = nullptr;
- if (SupportsMapBuffer(GLContext::GetCurrent())) {
+ if (SupportsMapBuffer(context)) {
dst = glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
} else {
- DCHECK(SupportsMapBufferRange(GLContext::GetCurrent()));
+ DCHECK(SupportsMapBufferRange(context));
dst = glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, size, GL_MAP_WRITE_BIT);
}
@@ -380,13 +393,14 @@ bool GLImageMemory::CopyTexImage(unsigned target) {
glTexSubImage2D(target, 0, 0, 0, size_.width(), size_.height(),
data_format, data_type, 0);
+ uploaded = true;
} else {
glDeleteBuffersARB(1, &buffer_);
buffer_ = 0;
}
}
- if (!buffer_) {
+ if (!uploaded) {
glTexImage2D(target, 0, GetInternalFormat(), size_.width(), size_.height(),
0, data_format, data_type, src);
}
diff --git a/chromium/ui/gl/gl_image_memory.h b/chromium/ui/gl/gl_image_memory.h
index 2995a2b6aba..ae30660bb2a 100644
--- a/chromium/ui/gl/gl_image_memory.h
+++ b/chromium/ui/gl/gl_image_memory.h
@@ -10,11 +10,14 @@
#include <stddef.h>
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
#include "base/numerics/safe_math.h"
#include "ui/gfx/buffer_types.h"
#include "ui/gl/gl_export.h"
namespace gl {
+class GLContext;
+class GLSurface;
class GL_EXPORT GLImageMemory : public GLImage {
public:
@@ -65,6 +68,9 @@ class GL_EXPORT GLImageMemory : public GLImage {
size_t stride_;
unsigned buffer_ = 0;
+ // The context/surface from which the |buffer_| is created.
+ base::WeakPtr<GLContext> original_context_;
+ base::WeakPtr<GLSurface> original_surface_;
size_t buffer_bytes_ = 0;
int memcpy_tasks_ = 0;
diff --git a/chromium/ui/gl/gl_image_ref_counted_memory.cc b/chromium/ui/gl/gl_image_ref_counted_memory.cc
index 259ba08650e..c8ea915c50a 100644
--- a/chromium/ui/gl/gl_image_ref_counted_memory.cc
+++ b/chromium/ui/gl/gl_image_ref_counted_memory.cc
@@ -6,7 +6,7 @@
#include <stddef.h>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/memory/ref_counted_memory.h"
#include "base/trace_event/memory_allocator_dump.h"
#include "base/trace_event/memory_dump_manager.h"
diff --git a/chromium/ui/gl/gl_mock_autogen_gl.h b/chromium/ui/gl/gl_mock_autogen_gl.h
index eee1abf47e7..23861cae559 100644
--- a/chromium/ui/gl/gl_mock_autogen_gl.h
+++ b/chromium/ui/gl/gl_mock_autogen_gl.h
@@ -873,10 +873,15 @@ MOCK_METHOD2(Hint, void(GLenum target, GLenum mode));
MOCK_METHOD4(ImportMemoryFdEXT,
void(GLuint memory, GLuint64 size, GLenum handleType, GLint fd));
MOCK_METHOD4(
+ ImportMemoryWin32HandleEXT,
+ void(GLuint memory, GLuint64 size, GLenum handleType, void* handle));
+MOCK_METHOD4(
ImportMemoryZirconHandleANGLE,
void(GLuint memory, GLuint64 size, GLenum handleType, GLuint handle));
MOCK_METHOD3(ImportSemaphoreFdEXT,
void(GLuint semaphore, GLenum handleType, GLint fd));
+MOCK_METHOD3(ImportSemaphoreWin32HandleEXT,
+ void(GLuint semaphore, GLenum handleType, void* handle));
MOCK_METHOD3(ImportSemaphoreZirconHandleANGLE,
void(GLuint semaphore, GLenum handleType, GLuint handle));
MOCK_METHOD2(InsertEventMarkerEXT, void(GLsizei length, const char* marker));
diff --git a/chromium/ui/gl/gl_share_group.cc b/chromium/ui/gl/gl_share_group.cc
index 9292b3d0a48..62f0ea7685d 100644
--- a/chromium/ui/gl/gl_share_group.cc
+++ b/chromium/ui/gl/gl_share_group.cc
@@ -4,7 +4,7 @@
#include "ui/gl/gl_share_group.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "build/build_config.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
diff --git a/chromium/ui/gl/gl_stub_autogen_gl.h b/chromium/ui/gl/gl_stub_autogen_gl.h
index 037e180d0dc..a175caed59f 100644
--- a/chromium/ui/gl/gl_stub_autogen_gl.h
+++ b/chromium/ui/gl/gl_stub_autogen_gl.h
@@ -890,6 +890,10 @@ void glImportMemoryFdEXTFn(GLuint memory,
GLuint64 size,
GLenum handleType,
GLint fd) override {}
+void glImportMemoryWin32HandleEXTFn(GLuint memory,
+ GLuint64 size,
+ GLenum handleType,
+ void* handle) override {}
void glImportMemoryZirconHandleANGLEFn(GLuint memory,
GLuint64 size,
GLenum handleType,
@@ -897,6 +901,9 @@ void glImportMemoryZirconHandleANGLEFn(GLuint memory,
void glImportSemaphoreFdEXTFn(GLuint semaphore,
GLenum handleType,
GLint fd) override {}
+void glImportSemaphoreWin32HandleEXTFn(GLuint semaphore,
+ GLenum handleType,
+ void* handle) override {}
void glImportSemaphoreZirconHandleANGLEFn(GLuint semaphore,
GLenum handleType,
GLuint handle) override {}
diff --git a/chromium/ui/gl/gl_surface.cc b/chromium/ui/gl/gl_surface.cc
index f6eb3e236ee..8284db4f327 100644
--- a/chromium/ui/gl/gl_surface.cc
+++ b/chromium/ui/gl/gl_surface.cc
@@ -4,9 +4,10 @@
#include "ui/gl/gl_surface.h"
+#include "base/check.h"
#include "base/command_line.h"
#include "base/lazy_instance.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
#include "base/threading/thread_local.h"
#include "base/trace_event/trace_event.h"
@@ -508,6 +509,10 @@ void GLSurfaceAdapter::SetDisplayTransform(gfx::OverlayTransform transform) {
return surface_->SetDisplayTransform(transform);
}
+void GLSurfaceAdapter::SetFrameRate(float frame_rate) {
+ surface_->SetFrameRate(frame_rate);
+}
+
void GLSurfaceAdapter::SetCurrent() {
surface_->SetCurrent();
}
diff --git a/chromium/ui/gl/gl_surface.h b/chromium/ui/gl/gl_surface.h
index f16f664612e..b150a76b0d5 100644
--- a/chromium/ui/gl/gl_surface.h
+++ b/chromium/ui/gl/gl_surface.h
@@ -11,6 +11,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
#include "build/build_config.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_f.h"
@@ -44,7 +45,8 @@ class EGLTimestampClient;
// Encapsulates a surface that can be rendered to with GL, hiding platform
// specific management.
-class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> {
+class GL_EXPORT GLSurface : public base::RefCounted<GLSurface>,
+ public base::SupportsWeakPtr<GLSurface> {
public:
GLSurface();
@@ -297,6 +299,7 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> {
virtual void SetGpuVSyncEnabled(bool enabled);
virtual void SetDisplayTransform(gfx::OverlayTransform transform) {}
+ virtual void SetFrameRate(float frame_rate) {}
static GLSurface* GetCurrent();
@@ -394,6 +397,7 @@ class GL_EXPORT GLSurfaceAdapter : public GLSurface {
bool SupportsGpuVSync() const override;
void SetGpuVSyncEnabled(bool enabled) override;
void SetDisplayTransform(gfx::OverlayTransform transform) override;
+ void SetFrameRate(float frame_rate) override;
void SetCurrent() override;
bool IsCurrent() override;
diff --git a/chromium/ui/gl/gl_surface_egl.cc b/chromium/ui/gl/gl_surface_egl.cc
index 4cf66eac736..07cd11466e3 100644
--- a/chromium/ui/gl/gl_surface_egl.cc
+++ b/chromium/ui/gl/gl_surface_egl.cc
@@ -20,7 +20,6 @@
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/system/sys_info.h"
-#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "ui/events/platform/platform_event_dispatcher.h"
@@ -30,6 +29,7 @@
#include "ui/gl/egl_util.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_context_egl.h"
+#include "ui/gl/gl_display_egl_util.h"
#include "ui/gl/gl_image.h"
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_surface_presentation_helper.h"
@@ -38,12 +38,6 @@
#include "ui/gl/scoped_make_current.h"
#include "ui/gl/sync_control_vsync_provider.h"
-#if defined(USE_X11)
-#include "ui/base/x/x11_display_util.h"
-#include "ui/base/x/x11_util_internal.h" // nogncheck
-#include "ui/gfx/x/x11.h"
-#endif
-
#if defined(OS_ANDROID)
#include <android/native_window_jni.h>
#include "base/android/build_info.h"
@@ -189,6 +183,7 @@ bool g_egl_create_context_client_arrays_supported = false;
bool g_egl_android_native_fence_sync_supported = false;
bool g_egl_ext_pixel_format_float_supported = false;
bool g_egl_angle_feature_control_supported = false;
+bool g_egl_angle_power_preference_supported = false;
constexpr const char kSwapEventTraceCategories[] = "gpu";
@@ -204,37 +199,6 @@ struct TraceSwapEventsInitializer {
static base::LazyInstance<TraceSwapEventsInitializer>::Leaky
g_trace_swap_enabled = LAZY_INSTANCE_INITIALIZER;
-#if defined(USE_X11)
-class XrandrIntervalOnlyVSyncProvider : public gfx::VSyncProvider {
- public:
- XrandrIntervalOnlyVSyncProvider(Display* display)
- : display_(display), interval_(base::TimeDelta::FromSeconds(1 / 60.)) {}
-
- void GetVSyncParameters(UpdateVSyncCallback callback) override {
- if (++calls_since_last_update_ >= kCallsBetweenUpdates) {
- calls_since_last_update_ = 0;
- interval_ = ui::GetPrimaryDisplayRefreshIntervalFromXrandr(display_);
- }
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::BindOnce(std::move(callback), base::TimeTicks(), interval_));
- }
-
- bool GetVSyncParametersIfAvailable(base::TimeTicks* timebase,
- base::TimeDelta* interval) override {
- return false;
- }
- bool SupportGetVSyncParametersIfAvailable() const override { return false; }
- bool IsHWClock() const override { return false; }
-
- private:
- Display* const display_ = nullptr;
- base::TimeDelta interval_;
- static const int kCallsBetweenUpdates = 100;
- int calls_since_last_update_ = kCallsBetweenUpdates;
-};
-#endif
-
class EGLSyncControlVSyncProvider : public SyncControlVSyncProvider {
public:
explicit EGLSyncControlVSyncProvider(EGLSurface surface)
@@ -313,18 +277,8 @@ EGLDisplay GetPlatformANGLEDisplay(
display_attribs.push_back(EGL_PLATFORM_ANGLE_TYPE_ANGLE);
display_attribs.push_back(static_cast<EGLAttrib>(platform_type));
-#if defined(USE_X11)
- // ANGLE_NULL doesn't use the visual, and may run without X11 where we can't
- // get it anyway.
- if (platform_type != EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE) {
- Visual* visual;
- ui::XVisualManager::GetInstance()->ChooseVisualForWindow(
- true, &visual, nullptr, nullptr, nullptr);
- display_attribs.push_back(EGL_X11_VISUAL_ID_ANGLE);
- display_attribs.push_back(
- static_cast<EGLAttrib>(XVisualIDFromVisual(visual)));
- }
-#endif
+ GLDisplayEglUtil::GetInstance()->GetPlatformExtraDisplayAttribs(
+ platform_type, &display_attribs);
std::vector<const char*> enabled_features_attribs =
GetAttribArrayFromStringVector(enabled_features);
@@ -574,15 +528,10 @@ EGLConfig ChooseConfig(GLSurfaceFormat format, bool surfaceless) {
EGLint stencil_size = format.GetStencilBits();
EGLint samples = format.GetSamples();
-#if defined(USE_X11)
- // If we're using ANGLE_NULL, we may not have a display, in which case we
- // can't use XVisualManager.
- if (g_native_display.GetDisplay() != EGL_DEFAULT_DISPLAY) {
- ui::XVisualManager::GetInstance()->ChooseVisualForWindow(
- true, nullptr, &buffer_size, nullptr, nullptr);
- alpha_size = buffer_size == 32 ? 8 : 0;
- }
-#endif
+ // Some platforms (eg. X11) may want to set custom values for alpha and buffer
+ // sizes.
+ GLDisplayEglUtil::GetInstance()->ChoosePlatformCustomAlphaAndBufferSize(
+ &alpha_size, &buffer_size);
EGLint surface_type =
(surfaceless ? EGL_DONT_CARE : EGL_WINDOW_BIT | EGL_PBUFFER_BIT);
@@ -1011,6 +960,9 @@ bool GLSurfaceEGL::InitializeOneOffCommon() {
g_egl_ext_pixel_format_float_supported =
HasEGLExtension("EGL_EXT_pixel_format_float");
+ g_egl_angle_power_preference_supported =
+ HasEGLExtension("EGL_ANGLE_power_preference");
+
initialized_ = true;
return true;
}
@@ -1124,6 +1076,10 @@ bool GLSurfaceEGL::IsANGLEFeatureControlSupported() {
return g_egl_angle_feature_control_supported;
}
+bool GLSurfaceEGL::IsANGLEPowerPreferenceSupported() {
+ return g_egl_angle_power_preference_supported;
+}
+
GLSurfaceEGL::~GLSurfaceEGL() {}
// InitializeDisplay is necessary because the static binding code
@@ -1375,34 +1331,8 @@ bool NativeViewGLSurfaceEGL::Initialize(GLSurfaceFormat format) {
std::make_unique<EGLSyncControlVSyncProvider>(surface_);
}
-#if defined(USE_X11)
- // Query all child windows and store them. ANGLE creates a child window when
- // eglCreateWidnowSurface is called on X11 and expose events from this window
- // need to be received by this class.
- Display* x11_display = GetNativeDisplay();
- Window root = 0;
- Window parent = 0;
- Window* children = nullptr;
- unsigned num_children = 0;
- if (XQueryTree(x11_display, window_, &root, &parent, &children,
- &num_children)) {
- for (unsigned int i = 0; i < num_children; ++i) {
- children_.push_back(children[i]);
- }
- if (num_children > 0) {
- XFree(children);
- }
- }
-
- if (ui::X11EventSource::HasInstance()) {
- ui::X11EventSource::GetInstance()->AddXEventDispatcher(this);
- }
-
- if (!vsync_provider_external_ && !vsync_provider_internal_) {
- vsync_provider_internal_ =
- std::make_unique<XrandrIntervalOnlyVSyncProvider>(x11_display);
- }
-#endif
+ if (!vsync_provider_external_ && !vsync_provider_internal_)
+ vsync_provider_internal_ = CreateVsyncProviderInternal();
presentation_helper_ =
std::make_unique<GLSurfacePresentationHelper>(GetVSyncProvider());
@@ -1499,11 +1429,6 @@ void NativeViewGLSurfaceEGL::Destroy() {
vsync_provider_internal_ = nullptr;
if (surface_) {
-#if defined(USE_X11)
- if (ui::X11EventSource::HasInstance()) {
- ui::X11EventSource::GetInstance()->RemoveXEventDispatcher(this);
- }
-#endif
if (!eglDestroySurface(GetDisplay(), surface_)) {
LOG(ERROR) << "eglDestroySurface failed with error "
<< GetLastEGLErrorString();
@@ -1547,17 +1472,6 @@ gfx::SwapResult NativeViewGLSurfaceEGL::SwapBuffers(
UpdateSwapEvents(new_frame_id, new_frame_id_is_valid);
}
-#if defined(USE_X11)
- // We need to restore the background pixel that we set to WhitePixel on
- // views::DesktopWindowTreeHostX11::InitX11Window back to None for the
- // XWindow associated to this surface after the first SwapBuffers has
- // happened, to avoid showing a weird white background while resizing.
- if (GetNativeDisplay() && !has_swapped_buffers_) {
- XSetWindowBackgroundPixmap(GetNativeDisplay(), window_, 0);
- has_swapped_buffers_ = true;
- }
-#endif
-
return scoped_swap_buffers.result();
}
@@ -1676,6 +1590,11 @@ void NativeViewGLSurfaceEGL::TraceSwapEvents(EGLuint64KHR oldFrameId) {
}
}
+std::unique_ptr<gfx::VSyncProvider>
+NativeViewGLSurfaceEGL::CreateVsyncProviderInternal() {
+ return nullptr;
+}
+
gfx::Size NativeViewGLSurfaceEGL::GetSize() {
EGLint width;
EGLint height;
@@ -1984,25 +1903,6 @@ bool NativeViewGLSurfaceEGL::CommitAndClearPendingOverlays() {
return success;
}
-#if defined(USE_X11)
-bool NativeViewGLSurfaceEGL::DispatchXEvent(XEvent* x_event) {
- // When ANGLE is used for EGL, it creates an X11 child window. Expose events
- // from this window need to be forwarded to this class.
- bool can_dispatch = x_event->type == Expose &&
- std::find(children_.begin(), children_.end(),
- x_event->xexpose.window) != children_.end();
-
- if (!can_dispatch)
- return false;
-
- x_event->xexpose.window = window_;
- Display* x11_display = GetNativeDisplay();
- XSendEvent(x11_display, window_, x11::False, ExposureMask, x_event);
- XFlush(x11_display);
- return true;
-}
-#endif
-
PbufferGLSurfaceEGL::PbufferGLSurfaceEGL(const gfx::Size& size)
: size_(size),
surface_(NULL) {
diff --git a/chromium/ui/gl/gl_surface_egl.h b/chromium/ui/gl/gl_surface_egl.h
index 10099277dbc..ec6bf0816d5 100644
--- a/chromium/ui/gl/gl_surface_egl.h
+++ b/chromium/ui/gl/gl_surface_egl.h
@@ -27,10 +27,6 @@
#include "ui/gl/gl_surface.h"
#include "ui/gl/gl_surface_overlay.h"
-#if defined(USE_X11)
-#include "ui/events/platform/x11/x11_event_source.h" // nogncheck
-#endif
-
namespace gl {
class EGLDisplayPlatform {
@@ -121,6 +117,7 @@ class GL_EXPORT GLSurfaceEGL : public GLSurface {
static bool IsAndroidNativeFenceSyncSupported();
static bool IsPixelFormatFloatSupported();
static bool IsANGLEFeatureControlSupported();
+ static bool IsANGLEPowerPreferenceSupported();
protected:
~GLSurfaceEGL() override;
@@ -136,9 +133,6 @@ class GL_EXPORT GLSurfaceEGL : public GLSurface {
// Encapsulates an EGL surface bound to a view.
class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL,
-#if defined(USE_X11)
- public ui::XEventDispatcher,
-#endif
public EGLTimestampClient {
public:
NativeViewGLSurfaceEGL(EGLNativeWindowType window,
@@ -194,7 +188,6 @@ class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL,
~NativeViewGLSurfaceEGL() override;
EGLNativeWindowType window_ = 0;
- std::vector<EGLNativeWindowType> children_;
gfx::Size size_ = gfx::Size(1, 1);
bool enable_fixed_size_angle_ = true;
@@ -213,20 +206,14 @@ class GL_EXPORT NativeViewGLSurfaceEGL : public GLSurfaceEGL,
void UpdateSwapEvents(EGLuint64KHR newFrameId, bool newFrameIdIsValid);
void TraceSwapEvents(EGLuint64KHR oldFrameId);
-#if defined(USE_X11)
- // XEventDispatcher:
- bool DispatchXEvent(XEvent* xev) override;
-#endif
+ // Some platforms may provide a custom implementation of vsync provider.
+ virtual std::unique_ptr<gfx::VSyncProvider> CreateVsyncProviderInternal();
EGLSurface surface_ = nullptr;
bool supports_post_sub_buffer_ = false;
bool supports_swap_buffer_with_damage_ = false;
gfx::SurfaceOrigin surface_origin_ = gfx::SurfaceOrigin::kBottomLeft;
-#if defined(USE_X11)
- bool has_swapped_buffers_ = false;
-#endif
-
std::unique_ptr<gfx::VSyncProvider> vsync_provider_external_;
std::unique_ptr<gfx::VSyncProvider> vsync_provider_internal_;
diff --git a/chromium/ui/gl/gl_surface_egl_surface_control.cc b/chromium/ui/gl/gl_surface_egl_surface_control.cc
index b8a4bcb5019..b07b18a93e6 100644
--- a/chromium/ui/gl/gl_surface_egl_surface_control.cc
+++ b/chromium/ui/gl/gl_surface_egl_surface_control.cc
@@ -240,6 +240,7 @@ void GLSurfaceEGLSurfaceControl::CommitPendingTransaction(
// them after receiving read fences from the framework.
surface_list_.resize(pending_surfaces_count_);
pending_surfaces_count_ = 0u;
+ frame_rate_update_pending_ = false;
if (transaction_ack_pending_) {
pending_transaction_queue_.push(std::move(pending_transaction_).value());
@@ -376,6 +377,9 @@ bool GLSurfaceEGLSurfaceControl::ScheduleOverlayPlane(
image_color_space);
}
+ if (frame_rate_update_pending_)
+ pending_transaction_->SetFrameRate(*surface_state.surface, frame_rate_);
+
return true;
}
@@ -520,6 +524,14 @@ gfx::SurfaceOrigin GLSurfaceEGLSurfaceControl::GetOrigin() const {
return gfx::SurfaceOrigin::kTopLeft;
}
+void GLSurfaceEGLSurfaceControl::SetFrameRate(float frame_rate) {
+ if (frame_rate_ == frame_rate)
+ return;
+
+ frame_rate_ = frame_rate;
+ frame_rate_update_pending_ = true;
+}
+
gfx::Rect GLSurfaceEGLSurfaceControl::ApplyDisplayInverse(
const gfx::Rect& input) const {
gfx::Transform display_inverse = gfx::OverlayTransformToTransform(
diff --git a/chromium/ui/gl/gl_surface_egl_surface_control.h b/chromium/ui/gl/gl_surface_egl_surface_control.h
index ed895974a9e..425e679e3bd 100644
--- a/chromium/ui/gl/gl_surface_egl_surface_control.h
+++ b/chromium/ui/gl/gl_surface_egl_surface_control.h
@@ -83,6 +83,7 @@ class GL_EXPORT GLSurfaceEGLSurfaceControl : public GLSurfaceEGL {
bool SupportsCommitOverlayPlanes() override;
void SetDisplayTransform(gfx::OverlayTransform transform) override;
gfx::SurfaceOrigin GetOrigin() const override;
+ void SetFrameRate(float frame_rate) override;
private:
~GLSurfaceEGLSurfaceControl() override;
@@ -196,6 +197,10 @@ class GL_EXPORT GLSurfaceEGLSurfaceControl : public GLSurfaceEGL {
bool transaction_ack_pending_ = false;
gfx::OverlayTransform display_transform_ = gfx::OVERLAY_TRANSFORM_NONE;
+
+ float frame_rate_ = 0;
+ bool frame_rate_update_pending_ = false;
+
EGLSurface offscreen_surface_ = nullptr;
base::CancelableOnceClosure check_pending_presentation_callback_queue_task_;
diff --git a/chromium/ui/gl/gl_surface_egl_x11.cc b/chromium/ui/gl/gl_surface_egl_x11.cc
new file mode 100644
index 00000000000..2dd6ea790e2
--- /dev/null
+++ b/chromium/ui/gl/gl_surface_egl_x11.cc
@@ -0,0 +1,126 @@
+// Copyright 2020 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 "ui/gl/gl_surface_egl_x11.h"
+
+#include "base/threading/thread_task_runner_handle.h"
+#include "ui/base/x/x11_display_util.h"
+#include "ui/gfx/x/x11.h"
+#include "ui/gfx/x/xproto.h"
+#include "ui/gl/egl_util.h"
+
+namespace gl {
+
+namespace {
+
+class XrandrIntervalOnlyVSyncProvider : public gfx::VSyncProvider {
+ public:
+ explicit XrandrIntervalOnlyVSyncProvider(Display* display)
+ : display_(display), interval_(base::TimeDelta::FromSeconds(1 / 60.)) {}
+
+ void GetVSyncParameters(UpdateVSyncCallback callback) override {
+ if (++calls_since_last_update_ >= kCallsBetweenUpdates) {
+ calls_since_last_update_ = 0;
+ interval_ = ui::GetPrimaryDisplayRefreshIntervalFromXrandr(display_);
+ }
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::BindOnce(std::move(callback), base::TimeTicks(), interval_));
+ }
+
+ bool GetVSyncParametersIfAvailable(base::TimeTicks* timebase,
+ base::TimeDelta* interval) override {
+ return false;
+ }
+ bool SupportGetVSyncParametersIfAvailable() const override { return false; }
+ bool IsHWClock() const override { return false; }
+
+ private:
+ Display* const display_ = nullptr;
+ base::TimeDelta interval_;
+ static const int kCallsBetweenUpdates = 100;
+ int calls_since_last_update_ = kCallsBetweenUpdates;
+};
+
+} // namespace
+
+NativeViewGLSurfaceEGLX11::NativeViewGLSurfaceEGLX11(EGLNativeWindowType window)
+ : NativeViewGLSurfaceEGL(window, nullptr) {}
+
+bool NativeViewGLSurfaceEGLX11::Initialize(GLSurfaceFormat format) {
+ if (!NativeViewGLSurfaceEGL::Initialize(format))
+ return false;
+
+ // Query all child windows and store them. ANGLE creates a child window when
+ // eglCreateWidnowSurface is called on X11 and expose events from this window
+ // need to be received by this class.
+ if (auto reply = x11::Connection::Get()
+ ->QueryTree({static_cast<x11::Window>(window_)})
+ .Sync()) {
+ children_ = std::move(reply->children);
+ }
+
+ if (ui::X11EventSource::HasInstance()) {
+ dispatcher_set_ = true;
+ ui::X11EventSource::GetInstance()->AddXEventDispatcher(this);
+ }
+ return true;
+}
+
+void NativeViewGLSurfaceEGLX11::Destroy() {
+ NativeViewGLSurfaceEGL::Destroy();
+ if (dispatcher_set_ && ui::X11EventSource::HasInstance())
+ ui::X11EventSource::GetInstance()->RemoveXEventDispatcher(this);
+}
+
+gfx::SwapResult NativeViewGLSurfaceEGLX11::SwapBuffers(
+ PresentationCallback callback) {
+ auto result = NativeViewGLSurfaceEGL::SwapBuffers(std::move(callback));
+ if (result == gfx::SwapResult::SWAP_FAILED)
+ return result;
+
+ // We need to restore the background pixel that we set to WhitePixel on
+ // views::DesktopWindowTreeHostX11::InitX11Window back to None for the
+ // XWindow associated to this surface after the first SwapBuffers has
+ // happened, to avoid showing a weird white background while resizing.
+ if (GetXNativeDisplay() && !has_swapped_buffers_) {
+ XSetWindowBackgroundPixmap(GetXNativeDisplay(), window_, 0);
+ has_swapped_buffers_ = true;
+ }
+ return result;
+}
+
+NativeViewGLSurfaceEGLX11::~NativeViewGLSurfaceEGLX11() {
+ Destroy();
+}
+
+Display* NativeViewGLSurfaceEGLX11::GetXNativeDisplay() const {
+ return reinterpret_cast<Display*>(GetNativeDisplay());
+}
+
+std::unique_ptr<gfx::VSyncProvider>
+NativeViewGLSurfaceEGLX11::CreateVsyncProviderInternal() {
+ return std::make_unique<XrandrIntervalOnlyVSyncProvider>(GetXNativeDisplay());
+}
+
+bool NativeViewGLSurfaceEGLX11::DispatchXEvent(XEvent* x_event) {
+ // When ANGLE is used for EGL, it creates an X11 child window. Expose events
+ // from this window need to be forwarded to this class.
+ bool can_dispatch =
+ x_event->type == Expose &&
+ std::find(children_.begin(), children_.end(),
+ static_cast<x11::Window>(x_event->xexpose.window)) !=
+ children_.end();
+
+ if (!can_dispatch)
+ return false;
+
+ x_event->xexpose.window = window_;
+ Display* x11_display = GetXNativeDisplay();
+ XSendEvent(x11_display, window_, x11::False, ExposureMask, x_event);
+ XFlush(x11_display);
+ return true;
+}
+
+} // namespace gl
diff --git a/chromium/ui/gl/gl_surface_egl_x11.h b/chromium/ui/gl/gl_surface_egl_x11.h
new file mode 100644
index 00000000000..e16ef3f7ff1
--- /dev/null
+++ b/chromium/ui/gl/gl_surface_egl_x11.h
@@ -0,0 +1,56 @@
+// Copyright 2020 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 UI_GL_GL_SURFACE_EGL_X11_H_
+#define UI_GL_GL_SURFACE_EGL_X11_H_
+
+#include <stdint.h>
+
+#include <string>
+
+#include "base/macros.h"
+#include "ui/events/platform/x11/x11_event_source.h"
+#include "ui/gfx/x/connection.h"
+#include "ui/gl/gl_export.h"
+#include "ui/gl/gl_surface_egl.h"
+
+namespace gl {
+
+// Encapsulates an EGL surface bound to a view using the X Window System.
+class GL_EXPORT NativeViewGLSurfaceEGLX11 : public NativeViewGLSurfaceEGL,
+ public ui::XEventDispatcher {
+ public:
+ explicit NativeViewGLSurfaceEGLX11(EGLNativeWindowType window);
+ NativeViewGLSurfaceEGLX11(const NativeViewGLSurfaceEGLX11& other) = delete;
+ NativeViewGLSurfaceEGLX11& operator=(const NativeViewGLSurfaceEGLX11& rhs) =
+ delete;
+
+ // NativeViewGLSurfaceEGL overrides.
+ bool Initialize(GLSurfaceFormat format) override;
+ void Destroy() override;
+ gfx::SwapResult SwapBuffers(PresentationCallback callback) override;
+
+ protected:
+ ~NativeViewGLSurfaceEGLX11() override;
+
+ Display* GetXNativeDisplay() const;
+
+ private:
+ // NativeViewGLSurfaceEGL overrides:
+ std::unique_ptr<gfx::VSyncProvider> CreateVsyncProviderInternal() override;
+
+ // XEventDispatcher:
+ bool DispatchXEvent(XEvent* xev) override;
+
+ std::vector<x11::Window> children_;
+
+ // Indicates if the dispatcher has been set.
+ bool dispatcher_set_ = false;
+
+ bool has_swapped_buffers_ = false;
+};
+
+} // namespace gl
+
+#endif // UI_GL_GL_SURFACE_EGL_X11_H_
diff --git a/chromium/ui/gl/gl_surface_egl_x11_gles2.cc b/chromium/ui/gl/gl_surface_egl_x11_gles2.cc
index 684eb6368d6..000b7fd362d 100644
--- a/chromium/ui/gl/gl_surface_egl_x11_gles2.cc
+++ b/chromium/ui/gl/gl_surface_egl_x11_gles2.cc
@@ -14,10 +14,10 @@ namespace gl {
NativeViewGLSurfaceEGLX11GLES2::NativeViewGLSurfaceEGLX11GLES2(
EGLNativeWindowType window)
- : NativeViewGLSurfaceEGL(0, nullptr), parent_window_(window) {}
+ : NativeViewGLSurfaceEGLX11(0), parent_window_(window) {}
bool NativeViewGLSurfaceEGLX11GLES2::InitializeNativeWindow() {
- Display* x11_display = GetNativeDisplay();
+ Display* x11_display = GetXNativeDisplay();
XWindowAttributes attributes;
if (!XGetWindowAttributes(x11_display, parent_window_, &attributes)) {
LOG(ERROR) << "XGetWindowAttributes failed for window " << parent_window_
@@ -36,8 +36,9 @@ bool NativeViewGLSurfaceEGLX11GLES2::InitializeNativeWindow() {
swa.background_pixmap = 0;
swa.bit_gravity = NorthWestGravity;
window_ = XCreateWindow(x11_display, parent_window_, 0, 0, size_.width(),
- size_.height(), 0, CopyFromParent, InputOutput,
- CopyFromParent, CWBackPixmap | CWBitGravity, &swa);
+ size_.height(), 0, 0 /* CopyFromParent */,
+ 1 /* InputOutput */, 0 /* CopyFromParent */,
+ CWBackPixmap | CWBitGravity, &swa);
XMapWindow(x11_display, window_);
XSelectInput(x11_display, window_, ExposureMask);
XFlush(x11_display);
@@ -46,10 +47,10 @@ bool NativeViewGLSurfaceEGLX11GLES2::InitializeNativeWindow() {
}
void NativeViewGLSurfaceEGLX11GLES2::Destroy() {
- NativeViewGLSurfaceEGL::Destroy();
+ NativeViewGLSurfaceEGLX11::Destroy();
if (window_) {
- Display* x11_display = GetNativeDisplay();
+ Display* x11_display = GetXNativeDisplay();
XDestroyWindow(x11_display, window_);
window_ = 0;
XFlush(x11_display);
@@ -61,7 +62,7 @@ EGLConfig NativeViewGLSurfaceEGLX11GLES2::GetConfig() {
// Get a config compatible with the window
DCHECK(window_);
XWindowAttributes win_attribs;
- if (!XGetWindowAttributes(GetNativeDisplay(), window_, &win_attribs)) {
+ if (!XGetWindowAttributes(GetXNativeDisplay(), window_, &win_attribs)) {
return nullptr;
}
@@ -130,18 +131,19 @@ bool NativeViewGLSurfaceEGLX11GLES2::Resize(const gfx::Size& size,
size_ = size;
eglWaitGL();
- XResizeWindow(GetNativeDisplay(), window_, size.width(), size.height());
+ XResizeWindow(GetXNativeDisplay(), window_, size.width(), size.height());
eglWaitNative(EGL_CORE_NATIVE_ENGINE);
return true;
}
bool NativeViewGLSurfaceEGLX11GLES2::DispatchXEvent(XEvent* xev) {
- if (xev->type != Expose || xev->xexpose.window != window_)
+ if (xev->type != Expose ||
+ xev->xexpose.window != static_cast<Window>(window_))
return false;
xev->xexpose.window = parent_window_;
- Display* x11_display = GetNativeDisplay();
+ Display* x11_display = GetXNativeDisplay();
XSendEvent(x11_display, parent_window_, x11::False, ExposureMask, xev);
XFlush(x11_display);
return true;
diff --git a/chromium/ui/gl/gl_surface_egl_x11_gles2.h b/chromium/ui/gl/gl_surface_egl_x11_gles2.h
index fcf17dc22d7..ac4f26c534b 100644
--- a/chromium/ui/gl/gl_surface_egl_x11_gles2.h
+++ b/chromium/ui/gl/gl_surface_egl_x11_gles2.h
@@ -11,12 +11,13 @@
#include "base/macros.h"
#include "ui/gl/gl_export.h"
-#include "ui/gl/gl_surface_egl.h"
+#include "ui/gl/gl_surface_egl_x11.h"
namespace gl {
// Encapsulates an EGL surface bound to a view using the X Window System.
-class GL_EXPORT NativeViewGLSurfaceEGLX11GLES2 : public NativeViewGLSurfaceEGL {
+class GL_EXPORT NativeViewGLSurfaceEGLX11GLES2
+ : public NativeViewGLSurfaceEGLX11 {
public:
explicit NativeViewGLSurfaceEGLX11GLES2(EGLNativeWindowType window);
@@ -29,9 +30,10 @@ class GL_EXPORT NativeViewGLSurfaceEGLX11GLES2 : public NativeViewGLSurfaceEGL {
bool has_alpha) override;
bool InitializeNativeWindow() override;
- private:
+ protected:
~NativeViewGLSurfaceEGLX11GLES2() override;
+ private:
// XEventDispatcher:
bool DispatchXEvent(XEvent* xev) override;
diff --git a/chromium/ui/gl/gl_surface_format.cc b/chromium/ui/gl/gl_surface_format.cc
index 2fc6ef03a79..3f962175a67 100644
--- a/chromium/ui/gl/gl_surface_format.cc
+++ b/chromium/ui/gl/gl_surface_format.cc
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/logging.h"
#include "ui/gl/gl_surface_format.h"
+#include "base/notreached.h"
namespace gl {
diff --git a/chromium/ui/gl/gl_surface_glx.cc b/chromium/ui/gl/gl_surface_glx.cc
index ffe1b98eaec..09a91304794 100644
--- a/chromium/ui/gl/gl_surface_glx.cc
+++ b/chromium/ui/gl/gl_surface_glx.cc
@@ -26,7 +26,6 @@
#include "ui/base/x/x11_util.h"
#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/x/x11.h"
-#include "ui/gfx/x/x11_connection.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
@@ -245,7 +244,7 @@ class SGIVideoSyncThread : public base::Thread,
}
static Display* GetDisplayImpl() {
- static Display* display = gfx::OpenNewXDisplay();
+ static Display* display = gfx::CloneXDisplay(gfx::GetXDisplay());
return display;
}
@@ -440,10 +439,6 @@ bool GLSurfaceGLX::InitializeOneOff() {
// http://crbug.com/245466
setenv("force_s3tc_enable", "true", 1);
- // SGIVideoSyncProviderShim (if instantiated) will issue X commands on
- // it's own thread.
- gfx::InitializeThreadedX11();
-
if (!gfx::GetXDisplay()) {
LOG(ERROR) << "XOpenDisplay failed.";
return false;
diff --git a/chromium/ui/gl/gl_switches.cc b/chromium/ui/gl/gl_switches.cc
index a0c332a57c2..c047cd9a82b 100644
--- a/chromium/ui/gl/gl_switches.cc
+++ b/chromium/ui/gl/gl_switches.cc
@@ -196,6 +196,11 @@ const base::Feature kDirectCompositionPreferNV12Overlays{
const base::Feature kDirectCompositionPresentationFeedback{
"DirectCompositionPresentationFeedback", base::FEATURE_ENABLED_BY_DEFAULT};
+// Allow overlay swapchain to present on all GPUs even if they only support
+// software overlays.
+const base::Feature kDirectCompositionSoftwareOverlays{
+ "DirectCompositionSoftwareOverlays", base::FEATURE_DISABLED_BY_DEFAULT};
+
// Use decode swap chain created from compatible video decoder buffers.
const base::Feature kDirectCompositionUseNV12DecodeSwapChain{
"DirectCompositionUseNV12DecodeSwapChain",
diff --git a/chromium/ui/gl/gl_switches.h b/chromium/ui/gl/gl_switches.h
index bd36328d855..05df4c6e069 100644
--- a/chromium/ui/gl/gl_switches.h
+++ b/chromium/ui/gl/gl_switches.h
@@ -86,6 +86,7 @@ GL_EXPORT extern const base::Feature kDirectCompositionLowLatencyPresentation;
GL_EXPORT extern const base::Feature kDirectCompositionNonrootOverlays;
GL_EXPORT extern const base::Feature kDirectCompositionPreferNV12Overlays;
GL_EXPORT extern const base::Feature kDirectCompositionPresentationFeedback;
+GL_EXPORT extern const base::Feature kDirectCompositionSoftwareOverlays;
GL_EXPORT extern const base::Feature kDirectCompositionUseNV12DecodeSwapChain;
GL_EXPORT extern const base::Feature kDefaultANGLEOpenGL;
extern const base::Feature kTrackCurrentShaders;
diff --git a/chromium/ui/gl/gl_version_info.cc b/chromium/ui/gl/gl_version_info.cc
index ac2b1f385f1..f66cfd1a8b3 100644
--- a/chromium/ui/gl/gl_version_info.cc
+++ b/chromium/ui/gl/gl_version_info.cc
@@ -4,6 +4,8 @@
#include "ui/gl/gl_version_info.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
#include "base/strings/strcat.h"
#include "base/strings/string_split.h"
diff --git a/chromium/ui/gl/init/BUILD.gn b/chromium/ui/gl/init/BUILD.gn
index 921e56779db..72a840d78fa 100644
--- a/chromium/ui/gl/init/BUILD.gn
+++ b/chromium/ui/gl/init/BUILD.gn
@@ -58,13 +58,21 @@ jumbo_component("init") {
libs = [ "OpenGL.framework" ]
} else if (use_x11) {
sources += [
+ "gl_display_egl_util_x11.cc",
+ "gl_display_egl_util_x11.h",
"gl_factory_x11.cc",
"gl_initializer_x11.cc",
]
- deps += [ "//ui/gfx/x" ]
+ deps += [
+ "//ui/base/x",
+ "//ui/base/x:gl",
+ "//ui/gfx/x",
+ ]
} else if (use_ozone) {
sources += [
+ "gl_display_egl_util_ozone.cc",
+ "gl_display_egl_util_ozone.h",
"gl_factory_ozone.cc",
"gl_initializer_ozone.cc",
"ozone_util.h",
diff --git a/chromium/ui/gl/init/create_gr_gl_interface.cc b/chromium/ui/gl/init/create_gr_gl_interface.cc
index 3e0fab1641b..d71dd24f871 100644
--- a/chromium/ui/gl/init/create_gr_gl_interface.cc
+++ b/chromium/ui/gl/init/create_gr_gl_interface.cc
@@ -6,6 +6,7 @@
#include "base/metrics/histogram_macros.h"
#include "base/no_destructor.h"
+#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_implementation.h"
@@ -158,9 +159,17 @@ GrGLFunction<R GR_GL_FUNCTION_TYPE(Args...)> bind_with_flush_on_mac(
// Conditional may be optimized out because droppable_call is set at compile
// time.
if (!droppable_call || !HasInitializedNullDrawGLBindings()) {
- glFlush();
+ {
+ TRACE_EVENT0(
+ "gpu", "CreateGrGLInterface - bind_with_flush_on_mac - beforefunc")
+ glFlush();
+ }
func(args...);
- glFlush();
+ {
+ TRACE_EVENT0("gpu",
+ "CreateGrGLInterface - bind_with_flush_on_mac - afterfunc")
+ glFlush();
+ }
}
};
#else
@@ -215,8 +224,7 @@ const char* kBlacklistExtensions[] = {
sk_sp<GrGLInterface> CreateGrGLInterface(
const gl::GLVersionInfo& version_info,
bool use_version_es2,
- gl::ProgressReporter* progress_reporter,
- std::vector<const char*> blacklisted_extensions) {
+ gl::ProgressReporter* progress_reporter) {
// Can't fake ES with desktop GL.
use_version_es2 &= version_info.is_es;
@@ -268,8 +276,6 @@ sk_sp<GrGLInterface> CreateGrGLInterface(
}
for (const char* extension : kBlacklistExtensions)
extensions.remove(extension);
- for (const char* extension : blacklisted_extensions)
- extensions.remove(extension);
GrGLInterface* interface = new GrGLInterface();
GrGLInterface::Functions* functions = &interface->fFunctions;
@@ -504,8 +510,8 @@ sk_sp<GrGLInterface> CreateGrGLInterface(
gl->glGetFramebufferAttachmentParameterivEXTFn;
functions->fGetRenderbufferParameteriv =
gl->glGetRenderbufferParameterivEXTFn;
- functions->fBindFramebuffer =
- bind_with_flush_on_mac(gl->glBindFramebufferEXTFn);
+ functions->fBindFramebuffer = bind_slow_with_flush_on_mac(
+ gl->glBindFramebufferEXTFn, progress_reporter);
functions->fFramebufferTexture2D = gl->glFramebufferTexture2DEXTFn;
functions->fCheckFramebufferStatus = gl->glCheckFramebufferStatusEXTFn;
functions->fDeleteFramebuffers = bind_slow_with_flush_on_mac(
diff --git a/chromium/ui/gl/init/create_gr_gl_interface.h b/chromium/ui/gl/init/create_gr_gl_interface.h
index bef92698434..9243fbea018 100644
--- a/chromium/ui/gl/init/create_gr_gl_interface.h
+++ b/chromium/ui/gl/init/create_gr_gl_interface.h
@@ -5,8 +5,6 @@
#ifndef UI_GL_INIT_CREATE_GR_GL_INTERFACE_H_
#define UI_GL_INIT_CREATE_GR_GL_INTERFACE_H_
-#include <vector>
-
#include "third_party/skia/include/gpu/gl/GrGLInterface.h"
#include "ui/gl/init/gl_init_export.h"
@@ -24,8 +22,7 @@ namespace init {
GL_INIT_EXPORT sk_sp<GrGLInterface> CreateGrGLInterface(
const gl::GLVersionInfo& version_info,
bool use_version_es2,
- gl::ProgressReporter* progress_reporter = nullptr,
- std::vector<const char*> blacklisted_extensions = {});
+ gl::ProgressReporter* progress_reporter = nullptr);
} // namespace init
} // namespace gl
diff --git a/chromium/ui/gl/init/gl_display_egl_util_ozone.cc b/chromium/ui/gl/init/gl_display_egl_util_ozone.cc
new file mode 100644
index 00000000000..fd003497402
--- /dev/null
+++ b/chromium/ui/gl/init/gl_display_egl_util_ozone.cc
@@ -0,0 +1,38 @@
+// Copyright 2020 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 "ui/gl/init/gl_display_egl_util_ozone.h"
+
+#include "ui/ozone/public/ozone_platform.h"
+#include "ui/ozone/public/platform_gl_egl_utility.h"
+
+namespace gl {
+
+// static
+GLDisplayEglUtilOzone* GLDisplayEglUtilOzone::GetInstance() {
+ static base::NoDestructor<GLDisplayEglUtilOzone> instance;
+ return instance.get();
+}
+
+void GLDisplayEglUtilOzone::GetPlatformExtraDisplayAttribs(
+ EGLenum platform_type,
+ std::vector<EGLAttrib>* attributes) {
+ auto* utility = ui::OzonePlatform::GetInstance()->GetPlatformGLEGLUtility();
+ if (utility)
+ utility->GetAdditionalEGLAttributes(platform_type, attributes);
+}
+
+void GLDisplayEglUtilOzone::ChoosePlatformCustomAlphaAndBufferSize(
+ EGLint* alpha_size,
+ EGLint* buffer_size) {
+ auto* utility = ui::OzonePlatform::GetInstance()->GetPlatformGLEGLUtility();
+ if (utility)
+ utility->ChooseEGLAlphaAndBufferSize(alpha_size, buffer_size);
+}
+
+GLDisplayEglUtilOzone::GLDisplayEglUtilOzone() = default;
+
+GLDisplayEglUtilOzone::~GLDisplayEglUtilOzone() = default;
+
+} // namespace gl
diff --git a/chromium/ui/gl/init/gl_display_egl_util_ozone.h b/chromium/ui/gl/init/gl_display_egl_util_ozone.h
new file mode 100644
index 00000000000..32ecce607f1
--- /dev/null
+++ b/chromium/ui/gl/init/gl_display_egl_util_ozone.h
@@ -0,0 +1,39 @@
+// Copyright 2020 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 UI_GL_INIT_GL_DISPLAY_EGL_UTIL_OZONE_H_
+#define UI_GL_INIT_GL_DISPLAY_EGL_UTIL_OZONE_H_
+
+#include <vector>
+
+#include "base/no_destructor.h"
+#include "ui/gl/gl_display_egl_util.h"
+
+namespace gl {
+
+// Forwards calls to PlatformGLEGLUtility. It might be implemented by some
+// platforms.
+class GLDisplayEglUtilOzone : public GLDisplayEglUtil {
+ public:
+ static GLDisplayEglUtilOzone* GetInstance();
+
+ // GLDisplayEglUtil overrides:
+ void GetPlatformExtraDisplayAttribs(
+ EGLenum platform_type,
+ std::vector<EGLAttrib>* attributes) override;
+ void ChoosePlatformCustomAlphaAndBufferSize(EGLint* alpha_size,
+ EGLint* buffer_size) override;
+
+ private:
+ friend base::NoDestructor<GLDisplayEglUtilOzone>;
+
+ GLDisplayEglUtilOzone();
+ ~GLDisplayEglUtilOzone() override;
+ GLDisplayEglUtilOzone(const GLDisplayEglUtilOzone& util) = delete;
+ GLDisplayEglUtilOzone& operator=(const GLDisplayEglUtilOzone& util) = delete;
+};
+
+} // namespace gl
+
+#endif // UI_GL_INIT_GL_DISPLAY_EGL_UTIL_OZONE_H_
diff --git a/chromium/ui/gl/init/gl_display_egl_util_x11.cc b/chromium/ui/gl/init/gl_display_egl_util_x11.cc
new file mode 100644
index 00000000000..182291b8e3a
--- /dev/null
+++ b/chromium/ui/gl/init/gl_display_egl_util_x11.cc
@@ -0,0 +1,33 @@
+// Copyright 2020 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 "ui/gl/init/gl_display_egl_util_x11.h"
+
+#include "ui/base/x/x11_gl_egl_utility.h"
+
+namespace gl {
+
+// static
+GLDisplayEglUtilX11* GLDisplayEglUtilX11::GetInstance() {
+ static base::NoDestructor<GLDisplayEglUtilX11> instance;
+ return instance.get();
+}
+
+void GLDisplayEglUtilX11::GetPlatformExtraDisplayAttribs(
+ EGLenum platform_type,
+ std::vector<EGLAttrib>* attributes) {
+ ui::GetPlatformExtraDisplayAttribs(platform_type, attributes);
+}
+
+void GLDisplayEglUtilX11::ChoosePlatformCustomAlphaAndBufferSize(
+ EGLint* alpha_size,
+ EGLint* buffer_size) {
+ ui::ChoosePlatformCustomAlphaAndBufferSize(alpha_size, buffer_size);
+}
+
+GLDisplayEglUtilX11::GLDisplayEglUtilX11() = default;
+
+GLDisplayEglUtilX11::~GLDisplayEglUtilX11() = default;
+
+} // namespace gl \ No newline at end of file
diff --git a/chromium/ui/gl/init/gl_display_egl_util_x11.h b/chromium/ui/gl/init/gl_display_egl_util_x11.h
new file mode 100644
index 00000000000..290de7f2dc5
--- /dev/null
+++ b/chromium/ui/gl/init/gl_display_egl_util_x11.h
@@ -0,0 +1,36 @@
+// Copyright 2020 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 UI_GL_INIT_GL_DISPLAY_EGL_UTIL_X11_H_
+#define UI_GL_INIT_GL_DISPLAY_EGL_UTIL_X11_H_
+
+#include <vector>
+
+#include "base/no_destructor.h"
+#include "ui/gl/gl_display_egl_util.h"
+
+namespace gl {
+
+class GLDisplayEglUtilX11 : public GLDisplayEglUtil {
+ public:
+ static GLDisplayEglUtilX11* GetInstance();
+
+ // GLDisplayEglUtil overrides:
+ void GetPlatformExtraDisplayAttribs(
+ EGLenum platform_type,
+ std::vector<EGLAttrib>* attributes) override;
+ void ChoosePlatformCustomAlphaAndBufferSize(EGLint* alpha_size,
+ EGLint* buffer_size) override;
+
+ private:
+ friend base::NoDestructor<GLDisplayEglUtilX11>;
+ GLDisplayEglUtilX11();
+ ~GLDisplayEglUtilX11() override;
+ GLDisplayEglUtilX11(const GLDisplayEglUtilX11& util) = delete;
+ GLDisplayEglUtilX11& operator=(const GLDisplayEglUtilX11& util) = delete;
+};
+
+} // namespace gl
+
+#endif // UI_GL_INIT_GL_DISPLAY_EGL_UTIL_X11_H_
diff --git a/chromium/ui/gl/init/gl_factory_android.cc b/chromium/ui/gl/init/gl_factory_android.cc
index 4e77e6fa3b0..f7e497b5ab5 100644
--- a/chromium/ui/gl/init/gl_factory_android.cc
+++ b/chromium/ui/gl/init/gl_factory_android.cc
@@ -4,7 +4,8 @@
#include "ui/gl/init/gl_factory.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/trace_event/trace_event.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
diff --git a/chromium/ui/gl/init/gl_factory_mac.cc b/chromium/ui/gl/init/gl_factory_mac.cc
index c0b95d49461..dfa1f1e8a98 100644
--- a/chromium/ui/gl/init/gl_factory_mac.cc
+++ b/chromium/ui/gl/init/gl_factory_mac.cc
@@ -4,8 +4,9 @@
#include "ui/gl/init/gl_factory.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/macros.h"
+#include "base/notreached.h"
#include "base/trace_event/trace_event.h"
#include "ui/gl/buildflags.h"
#include "ui/gl/gl_bindings.h"
diff --git a/chromium/ui/gl/init/gl_factory_ozone.cc b/chromium/ui/gl/init/gl_factory_ozone.cc
index 2adf4888003..cd64372831f 100644
--- a/chromium/ui/gl/init/gl_factory_ozone.cc
+++ b/chromium/ui/gl/init/gl_factory_ozone.cc
@@ -4,7 +4,8 @@
#include "ui/gl/init/gl_factory.h"
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "base/trace_event/trace_event.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_context_stub.h"
diff --git a/chromium/ui/gl/init/gl_factory_win.cc b/chromium/ui/gl/init/gl_factory_win.cc
index 86314020020..6b65ba349fc 100644
--- a/chromium/ui/gl/init/gl_factory_win.cc
+++ b/chromium/ui/gl/init/gl_factory_win.cc
@@ -4,7 +4,8 @@
#include "ui/gl/init/gl_factory.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/trace_event/trace_event.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_context_egl.h"
diff --git a/chromium/ui/gl/init/gl_factory_x11.cc b/chromium/ui/gl/init/gl_factory_x11.cc
index 75c9f0e3d52..4bebef1a31d 100644
--- a/chromium/ui/gl/init/gl_factory_x11.cc
+++ b/chromium/ui/gl/init/gl_factory_x11.cc
@@ -14,7 +14,7 @@
#include "ui/gl/gl_implementation.h"
#include "ui/gl/gl_share_group.h"
#include "ui/gl/gl_surface.h"
-#include "ui/gl/gl_surface_egl.h"
+#include "ui/gl/gl_surface_egl_x11.h"
#include "ui/gl/gl_surface_egl_x11_gles2.h"
#include "ui/gl/gl_surface_glx.h"
#include "ui/gl/gl_surface_glx_x11.h"
@@ -83,7 +83,7 @@ scoped_refptr<GLSurface> CreateViewGLSurface(gfx::AcceleratedWidget window) {
return InitializeGLSurface(new NativeViewGLSurfaceEGLX11GLES2(window));
case kGLImplementationEGLANGLE:
DCHECK(window != gfx::kNullAcceleratedWidget);
- return InitializeGLSurface(new NativeViewGLSurfaceEGL(window, nullptr));
+ return InitializeGLSurface(new NativeViewGLSurfaceEGLX11(window));
case kGLImplementationMockGL:
case kGLImplementationStubGL:
return new GLSurfaceStub;
diff --git a/chromium/ui/gl/init/gl_initializer_ozone.cc b/chromium/ui/gl/init/gl_initializer_ozone.cc
index 754b36c2922..a94b6d4b7cb 100644
--- a/chromium/ui/gl/init/gl_initializer_ozone.cc
+++ b/chromium/ui/gl/init/gl_initializer_ozone.cc
@@ -4,18 +4,23 @@
#include "ui/gl/init/gl_initializer.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_gl_api_implementation.h"
#include "ui/gl/gl_surface.h"
+#include "ui/gl/init/gl_display_egl_util_ozone.h"
#include "ui/gl/init/ozone_util.h"
+#include "ui/ozone/public/ozone_platform.h"
namespace gl {
namespace init {
bool InitializeGLOneOffPlatform() {
- if (HasGLOzone())
+ if (HasGLOzone()) {
+ gl::GLDisplayEglUtil::SetInstance(gl::GLDisplayEglUtilOzone::GetInstance());
return GetGLOzone()->InitializeGLOneOffPlatform();
+ }
switch (GetGLImplementation()) {
case kGLImplementationMockGL:
diff --git a/chromium/ui/gl/init/gl_initializer_x11.cc b/chromium/ui/gl/init/gl_initializer_x11.cc
index d9190a957ca..d76d146b0d8 100644
--- a/chromium/ui/gl/init/gl_initializer_x11.cc
+++ b/chromium/ui/gl/init/gl_initializer_x11.cc
@@ -20,6 +20,7 @@
#include "ui/gl/gl_surface_egl.h"
#include "ui/gl/gl_surface_glx.h"
#include "ui/gl/gl_switches.h"
+#include "ui/gl/init/gl_display_egl_util_x11.h"
namespace gl {
namespace init {
@@ -152,6 +153,8 @@ bool InitializeGLOneOffPlatform() {
case kGLImplementationSwiftShaderGL:
case kGLImplementationEGLGLES2:
case kGLImplementationEGLANGLE:
+ // Set utility class that helps to initialize egl platform.
+ gl::GLDisplayEglUtil::SetInstance(gl::GLDisplayEglUtilX11::GetInstance());
if (!GLSurfaceEGL::InitializeOneOff(
EGLDisplayPlatform(gfx::GetXDisplay()))) {
LOG(ERROR) << "GLSurfaceEGL::InitializeOneOff failed.";
diff --git a/chromium/ui/gl/mojom/BUILD.gn b/chromium/ui/gl/mojom/BUILD.gn
index 564e3423ee6..60a4ea0ab4c 100644
--- a/chromium/ui/gl/mojom/BUILD.gn
+++ b/chromium/ui/gl/mojom/BUILD.gn
@@ -6,8 +6,19 @@ import("//mojo/public/tools/bindings/mojom.gni")
mojom("mojom") {
sources = [ "gpu_preference.mojom" ]
-
public_deps = [ "//mojo/public/mojom/base" ]
+ cpp_typemaps = [
+ {
+ types = [
+ {
+ mojom = "gl.mojom.GpuPreference"
+ cpp = "::gl::GpuPreference"
+ },
+ ]
+ traits_headers = [ "gpu_preference_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/gl" ]
+ },
+ ]
}
mojom("test_interfaces") {
diff --git a/chromium/ui/gl/mojom/OWNERS b/chromium/ui/gl/mojom/OWNERS
index ae29a36aac8..1feb5149750 100644
--- a/chromium/ui/gl/mojom/OWNERS
+++ b/chromium/ui/gl/mojom/OWNERS
@@ -2,5 +2,3 @@ per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
-per-file *.typemap=set noparent
-per-file *.typemap=file://ipc/SECURITY_OWNERS
diff --git a/chromium/ui/gl/mojom/gpu_preference.typemap b/chromium/ui/gl/mojom/gpu_preference.typemap
deleted file mode 100644
index ec7a1546409..00000000000
--- a/chromium/ui/gl/mojom/gpu_preference.typemap
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright 2019 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.
-
-mojom = "//ui/gl/mojom/gpu_preference.mojom"
-public_headers = [ "//ui/gl/gpu_preference.h" ]
-traits_headers = [ "//ui/gl/mojom/gpu_preference_mojom_traits.h" ]
-sources = []
-public_deps = [
- "//ui/gl",
-]
-type_mappings = [ "gl.mojom.GpuPreference=::gl::GpuPreference" ]
diff --git a/chromium/ui/gl/scoped_cgl.cc b/chromium/ui/gl/scoped_cgl.cc
index b3472319e90..db7a62e2185 100644
--- a/chromium/ui/gl/scoped_cgl.cc
+++ b/chromium/ui/gl/scoped_cgl.cc
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/logging.h"
#include "ui/gl/scoped_cgl.h"
+#include "base/check_op.h"
namespace gl {
diff --git a/chromium/ui/gl/scoped_make_current.cc b/chromium/ui/gl/scoped_make_current.cc
index c6bc9f3223c..2f351f35d1f 100644
--- a/chromium/ui/gl/scoped_make_current.cc
+++ b/chromium/ui/gl/scoped_make_current.cc
@@ -4,7 +4,7 @@
#include "ui/gl/scoped_make_current.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_surface.h"
diff --git a/chromium/ui/gl/shader_tracking.cc b/chromium/ui/gl/shader_tracking.cc
index 88362245cb4..d7b9a402520 100644
--- a/chromium/ui/gl/shader_tracking.cc
+++ b/chromium/ui/gl/shader_tracking.cc
@@ -4,7 +4,7 @@
#include "ui/gl/shader_tracking.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/gl/gl_switches.h"
namespace gl {
diff --git a/chromium/ui/gl/swap_chain_presenter.cc b/chromium/ui/gl/swap_chain_presenter.cc
index 4221f439982..40851d765bd 100644
--- a/chromium/ui/gl/swap_chain_presenter.cc
+++ b/chromium/ui/gl/swap_chain_presenter.cc
@@ -698,6 +698,16 @@ bool SwapChainPresenter::PresentToSwapChain(
return true;
}
+ if (nv12_image && !nv12_image->texture()) {
+ // We can't proceed if |nv12_image| has no underlying d3d11 texture. It's
+ // unclear how we get into this state, but we do observe crashes due to it.
+ // Just stop here instead, and render incorrectly.
+ // https://crbug.com/1077645
+ DLOG(ERROR) << "Video NV12 texture is missing";
+ ReleaseSwapChainResources();
+ return true;
+ }
+
std::string image_type = "software video frame";
if (nv12_image)
image_type = "hardware video frame";
diff --git a/chromium/ui/gl/typemaps.gni b/chromium/ui/gl/typemaps.gni
deleted file mode 100644
index f831c21b185..00000000000
--- a/chromium/ui/gl/typemaps.gni
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-typemaps = [ "//ui/gl/mojom/gpu_preference.typemap" ]
diff --git a/chromium/ui/gl/vsync_provider_win.cc b/chromium/ui/gl/vsync_provider_win.cc
index 918c0d11d5c..041b85d3090 100644
--- a/chromium/ui/gl/vsync_provider_win.cc
+++ b/chromium/ui/gl/vsync_provider_win.cc
@@ -6,7 +6,6 @@
#include <dwmapi.h>
-#include "base/logging.h"
#include "base/trace_event/trace_event.h"
#include "ui/gfx/native_widget_types.h"
diff --git a/chromium/ui/gtk/BUILD.gn b/chromium/ui/gtk/BUILD.gn
index 2dd67393ec4..99d97e9c145 100644
--- a/chromium/ui/gtk/BUILD.gn
+++ b/chromium/ui/gtk/BUILD.gn
@@ -72,7 +72,6 @@ jumbo_component("gtk") {
# our own HarfBuzz avoid mixing symbols from system HarfBuzz and
# our own through the indirect dependency to harfbuzz-ng here.
"//build/config/linux/gtk",
- "//chrome/browser:theme_properties",
"//third_party:freetype_harfbuzz",
"//ui/aura",
"//ui/base",
@@ -86,16 +85,22 @@ jumbo_component("gtk") {
"//ui/gfx",
"//ui/gfx:native_widget_types",
"//ui/gfx/geometry",
+ "//ui/gfx/x",
"//ui/native_theme",
"//ui/shell_dialogs",
"//ui/strings",
"//ui/views",
]
+
+ if (use_cups) {
+ deps += [ "//printing/mojom" ]
+ }
+
public_deps = [ ":gtk_ui_delegate" ]
if (use_x11 || ozone_platform_x11) {
# select_file_dialog_impl_kde.cc still refers to XID
- configs += [ "//build/config/linux:x11" ]
+ deps += [ "//ui/gfx/x" ]
}
# TODO: This should be removed.
@@ -103,23 +108,3 @@ jumbo_component("gtk") {
deps += [ "//ui/ozone" ]
}
}
-
-component("x") {
- output_name = "ui_gtk_x"
- sources = [
- "gtk_event_loop_x11.cc",
- "gtk_event_loop_x11.h",
- "gtk_ui_delegate_x11.cc",
- "gtk_ui_delegate_x11.h",
- ]
- deps = [
- "//base",
- "//build/config/linux/gtk",
- "//ui/base",
- "//ui/events/platform/x11",
- "//ui/gfx/x",
- ]
- public_deps = [ ":gtk_ui_delegate" ]
- defines = [ "IS_UI_GTK_X_IMPL" ]
- configs += [ "//build/config/linux:x11" ]
-}
diff --git a/chromium/ui/gtk/gtk_ui.cc b/chromium/ui/gtk/gtk_ui.cc
index fab92f38df8..77d2c7633af 100644
--- a/chromium/ui/gtk/gtk_ui.cc
+++ b/chromium/ui/gtk/gtk_ui.cc
@@ -23,7 +23,7 @@
#include "base/stl_util.h"
#include "base/strings/string_split.h"
#include "base/strings/stringprintf.h"
-#include "chrome/browser/themes/theme_properties.h"
+#include "chrome/browser/themes/theme_properties.h" // nogncheck
#include "printing/buildflags/buildflags.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
diff --git a/chromium/ui/gtk/native_theme_gtk.cc b/chromium/ui/gtk/native_theme_gtk.cc
index 352bc3d9fb5..e4b9c5e52d6 100644
--- a/chromium/ui/gtk/native_theme_gtk.cc
+++ b/chromium/ui/gtk/native_theme_gtk.cc
@@ -219,19 +219,20 @@ base::Optional<SkColor> SkColorFromColorId(
return GetSeparatorColor("GtkSeparator#separator.horizontal");
// Button
+ case ui::NativeTheme::kColorId_ButtonColor:
+ return GetBgColor("GtkButton#button");
case ui::NativeTheme::kColorId_ButtonEnabledColor:
case ui::NativeTheme::kColorId_ButtonUncheckedColor:
return GetFgColor("GtkButton#button.text-button GtkLabel");
case ui::NativeTheme::kColorId_ButtonDisabledColor:
return GetFgColor("GtkButton#button.text-button:disabled GtkLabel");
- case ui::NativeTheme::kColorId_ButtonPressedShade:
- return SK_ColorTRANSPARENT;
// TODO(thomasanderson): Add this once this CL lands:
// https://chromium-review.googlesource.com/c/chromium/src/+/2053144
// case ui::NativeTheme::kColorId_ButtonHoverColor:
// return GetBgColor("GtkButton#button:hover");
// ProminentButton
+ case ui::NativeTheme::kColorId_ButtonCheckedColor:
case ui::NativeTheme::kColorId_ProminentButtonColor:
case ui::NativeTheme::kColorId_ProminentButtonFocusedColor:
return GetBgColor(
@@ -320,6 +321,7 @@ base::Optional<SkColor> SkColorFromColorId(
// Trees and Tables (implemented on GTK using the same class)
case ui::NativeTheme::kColorId_TableBackground:
+ case ui::NativeTheme::kColorId_TableBackgroundAlternate:
case ui::NativeTheme::kColorId_TreeBackground:
return GetBgColor(
"GtkTreeView#treeview.view GtkTreeView#treeview.view.cell");
@@ -374,11 +376,14 @@ base::Optional<SkColor> SkColorFromColorId(
return fallback_theme->GetSystemColor(color_id);
}
- case ui::NativeTheme::kColorId_DefaultIconColor:
+ case ui::NativeTheme::kColorId_MenuIconColor:
if (GtkCheckVersion(3, 20))
return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem #radio");
return GetFgColor("GtkMenu#menu GtkMenuItem#menuitem.radio");
+ case ui::NativeTheme::kColorId_DefaultIconColor:
+ return GetFgColor("GtkButton#button.flat.scale GtkImage#image");
+
case ui::NativeTheme::kColorId_NumColors:
NOTREACHED();
break;
diff --git a/chromium/ui/gtk/print_dialog_gtk.cc b/chromium/ui/gtk/print_dialog_gtk.cc
index 2450103dd69..7368b297a54 100644
--- a/chromium/ui/gtk/print_dialog_gtk.cc
+++ b/chromium/ui/gtk/print_dialog_gtk.cc
@@ -33,6 +33,10 @@
#include "ui/gtk/gtk_util.h"
#include "ui/gtk/printing_gtk_util.h"
+#if defined(USE_CUPS)
+#include "printing/mojom/print.mojom.h"
+#endif
+
using printing::PageRanges;
using printing::PrintSettings;
@@ -244,19 +248,20 @@ void PrintDialogGtk::UpdateSettings(
gtk_print_settings_set(gtk_settings_, color_setting_name.c_str(),
color_value.c_str());
- if (settings->duplex_mode() != printing::UNKNOWN_DUPLEX_MODE) {
+ if (settings->duplex_mode() !=
+ printing::mojom::DuplexMode::kUnknownDuplexMode) {
const char* cups_duplex_mode = nullptr;
switch (settings->duplex_mode()) {
- case printing::LONG_EDGE:
+ case printing::mojom::DuplexMode::kLongEdge:
cups_duplex_mode = kDuplexNoTumble;
break;
- case printing::SHORT_EDGE:
+ case printing::mojom::DuplexMode::kShortEdge:
cups_duplex_mode = kDuplexTumble;
break;
- case printing::SIMPLEX:
+ case printing::mojom::DuplexMode::kSimplex:
cups_duplex_mode = kDuplexNone;
break;
- default: // UNKNOWN_DUPLEX_MODE
+ default: // kUnknownDuplexMode
NOTREACHED();
break;
}
diff --git a/chromium/ui/gtk/x/BUILD.gn b/chromium/ui/gtk/x/BUILD.gn
new file mode 100644
index 00000000000..9cdf6607336
--- /dev/null
+++ b/chromium/ui/gtk/x/BUILD.gn
@@ -0,0 +1,27 @@
+# Copyright 2020 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("//ui/ozone/ozone.gni")
+
+assert(use_x11 || ozone_platform_x11)
+
+component("x") {
+ output_name = "ui_gtk_x"
+ sources = [
+ "gtk_event_loop_x11.cc",
+ "gtk_event_loop_x11.h",
+ "gtk_ui_delegate_x11.cc",
+ "gtk_ui_delegate_x11.h",
+ ]
+ deps = [
+ "//base",
+ "//build/config/linux/gtk",
+ "//ui/base",
+ "//ui/events/platform/x11",
+ "//ui/gfx/x",
+ ]
+ public_deps = [ "//ui/gtk:gtk_ui_delegate" ]
+ defines = [ "IS_UI_GTK_X_IMPL" ]
+}
diff --git a/chromium/ui/gtk/gtk_event_loop_x11.cc b/chromium/ui/gtk/x/gtk_event_loop_x11.cc
index 5dd6474c794..aab1a9c3581 100644
--- a/chromium/ui/gtk/gtk_event_loop_x11.cc
+++ b/chromium/ui/gtk/x/gtk_event_loop_x11.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/gtk/gtk_event_loop_x11.h"
+#include "ui/gtk/x/gtk_event_loop_x11.h"
#include <gdk/gdk.h>
#include <gdk/gdkx.h>
diff --git a/chromium/ui/gtk/gtk_event_loop_x11.h b/chromium/ui/gtk/x/gtk_event_loop_x11.h
index 41b3ffa754d..7ea72051d36 100644
--- a/chromium/ui/gtk/gtk_event_loop_x11.h
+++ b/chromium/ui/gtk/x/gtk_event_loop_x11.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_GTK_GTK_EVENT_LOOP_X11_H_
-#define UI_GTK_GTK_EVENT_LOOP_X11_H_
+#ifndef UI_GTK_X_GTK_EVENT_LOOP_X11_H_
+#define UI_GTK_X_GTK_EVENT_LOOP_X11_H_
#include "base/macros.h"
#include "ui/base/glib/glib_integers.h"
@@ -36,4 +36,4 @@ class GtkEventLoopX11 {
} // namespace ui
-#endif // UI_GTK_GTK_EVENT_LOOP_X11_H_
+#endif // UI_GTK_X_GTK_EVENT_LOOP_X11_H_
diff --git a/chromium/ui/gtk/gtk_ui_delegate_x11.cc b/chromium/ui/gtk/x/gtk_ui_delegate_x11.cc
index 7de953d17fd..8967d4af8ac 100644
--- a/chromium/ui/gtk/gtk_ui_delegate_x11.cc
+++ b/chromium/ui/gtk/x/gtk_ui_delegate_x11.cc
@@ -2,16 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/gtk/gtk_ui_delegate_x11.h"
+#include "ui/gtk/x/gtk_ui_delegate_x11.h"
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/x11.h"
-#include "ui/gtk/gtk_event_loop_x11.h"
+#include "ui/gtk/x/gtk_event_loop_x11.h"
namespace ui {
diff --git a/chromium/ui/gtk/gtk_ui_delegate_x11.h b/chromium/ui/gtk/x/gtk_ui_delegate_x11.h
index d2e4b32eb84..e1f252df708 100644
--- a/chromium/ui/gtk/gtk_ui_delegate_x11.h
+++ b/chromium/ui/gtk/x/gtk_ui_delegate_x11.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_GTK_GTK_UI_DELEGATE_X11_H_
-#define UI_GTK_GTK_UI_DELEGATE_X11_H_
+#ifndef UI_GTK_X_GTK_UI_DELEGATE_X11_H_
+#define UI_GTK_X_GTK_UI_DELEGATE_X11_H_
#include "base/component_export.h"
#include "ui/gfx/native_widget_types.h"
@@ -43,4 +43,4 @@ class COMPONENT_EXPORT(UI_GTK_X) GtkUiDelegateX11 : public GtkUiDelegate {
} // namespace ui
-#endif // UI_GTK_GTK_UI_DELEGATE_X11_H_
+#endif // UI_GTK_X_GTK_UI_DELEGATE_X11_H_
diff --git a/chromium/ui/latency/latency_info.cc b/chromium/ui/latency/latency_info.cc
index 540a91ab19f..8be273a5529 100644
--- a/chromium/ui/latency/latency_info.cc
+++ b/chromium/ui/latency/latency_info.cc
@@ -17,6 +17,7 @@
#include "base/trace_event/trace_event.h"
#include "services/tracing/public/cpp/perfetto/flow_event_utils.h"
#include "services/tracing/public/cpp/perfetto/macros.h"
+#include "third_party/perfetto/protos/perfetto/trace/track_event/chrome_latency_info.pbzero.h"
namespace {
@@ -25,25 +26,28 @@ using perfetto::protos::pbzero::TrackEvent;
const size_t kMaxLatencyInfoNumber = 100;
-const char* GetComponentName(ui::LatencyComponentType type) {
-#define CASE_TYPE(t) case ui::t: return #t
+ChromeLatencyInfo::LatencyComponentType GetComponentProtoEnum(
+ ui::LatencyComponentType type) {
+#define CASE_TYPE(t) \
+ case ui::t##_COMPONENT: \
+ return ChromeLatencyInfo::COMPONENT_##t
switch (type) {
- CASE_TYPE(INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT);
- CASE_TYPE(INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL_COMPONENT);
- CASE_TYPE(INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL_COMPONENT);
- CASE_TYPE(INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT);
- CASE_TYPE(INPUT_EVENT_LATENCY_UI_COMPONENT);
- CASE_TYPE(INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN_COMPONENT);
- CASE_TYPE(INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL_COMPONENT);
- CASE_TYPE(INPUT_EVENT_LATENCY_SCROLL_UPDATE_LAST_EVENT_COMPONENT);
- CASE_TYPE(INPUT_EVENT_LATENCY_RENDERER_MAIN_COMPONENT);
- CASE_TYPE(INPUT_EVENT_LATENCY_RENDERER_SWAP_COMPONENT);
- CASE_TYPE(DISPLAY_COMPOSITOR_RECEIVED_FRAME_COMPONENT);
- CASE_TYPE(INPUT_EVENT_GPU_SWAP_BUFFER_COMPONENT);
- CASE_TYPE(INPUT_EVENT_LATENCY_FRAME_SWAP_COMPONENT);
+ CASE_TYPE(INPUT_EVENT_LATENCY_BEGIN_RWH);
+ CASE_TYPE(INPUT_EVENT_LATENCY_SCROLL_UPDATE_ORIGINAL);
+ CASE_TYPE(INPUT_EVENT_LATENCY_FIRST_SCROLL_UPDATE_ORIGINAL);
+ CASE_TYPE(INPUT_EVENT_LATENCY_ORIGINAL);
+ CASE_TYPE(INPUT_EVENT_LATENCY_UI);
+ CASE_TYPE(INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_MAIN);
+ CASE_TYPE(INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_IMPL);
+ CASE_TYPE(INPUT_EVENT_LATENCY_SCROLL_UPDATE_LAST_EVENT);
+ CASE_TYPE(INPUT_EVENT_LATENCY_RENDERER_MAIN);
+ CASE_TYPE(INPUT_EVENT_LATENCY_RENDERER_SWAP);
+ CASE_TYPE(DISPLAY_COMPOSITOR_RECEIVED_FRAME);
+ CASE_TYPE(INPUT_EVENT_GPU_SWAP_BUFFER);
+ CASE_TYPE(INPUT_EVENT_LATENCY_FRAME_SWAP);
default:
NOTREACHED() << "Unhandled LatencyComponentType: " << type;
- return "unknown";
+ return ChromeLatencyInfo::COMPONENT_UNSPECIFIED;
}
#undef CASE_TYPE
}
@@ -118,7 +122,8 @@ LatencyInfo::LatencyInfo(SourceEventType type)
terminated_(false),
source_event_type_(type),
scroll_update_delta_(0),
- predicted_scroll_update_delta_(0) {}
+ predicted_scroll_update_delta_(0),
+ gesture_scroll_id_(0) {}
LatencyInfo::LatencyInfo(const LatencyInfo& other) = default;
LatencyInfo::LatencyInfo(LatencyInfo&& other) = default;
@@ -133,7 +138,8 @@ LatencyInfo::LatencyInfo(int64_t trace_id, bool terminated)
terminated_(terminated),
source_event_type_(SourceEventType::UNKNOWN),
scroll_update_delta_(0),
- predicted_scroll_update_delta_(0) {}
+ predicted_scroll_update_delta_(0),
+ gesture_scroll_id_(0) {}
LatencyInfo& LatencyInfo::operator=(const LatencyInfo& other) = default;
@@ -188,6 +194,7 @@ void LatencyInfo::CopyLatencyFrom(const LatencyInfo& other,
}
coalesced_ = other.coalesced();
+ gesture_scroll_id_ = other.gesture_scroll_id();
scroll_update_delta_ = other.scroll_update_delta();
// TODO(tdresser): Ideally we'd copy |began_| here as well, but |began_|
// isn't very intuitive, and we can actually begin multiple times across
@@ -212,6 +219,7 @@ void LatencyInfo::AddNewLatencyFrom(const LatencyInfo& other) {
}
coalesced_ = other.coalesced();
+ gesture_scroll_id_ = other.gesture_scroll_id();
scroll_update_delta_ = other.scroll_update_delta();
// TODO(tdresser): Ideally we'd copy |began_| here as well, but |began_| isn't
// very intuitive, and we can actually begin multiple times across copied
@@ -265,9 +273,8 @@ void LatencyInfo::AddLatencyNumberWithTimestampImpl(
ts = base::TimeTicks::Now();
}
- TRACE_EVENT_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(
- kTraceCategoriesForAsyncEvents, trace_name_str,
- TRACE_ID_GLOBAL(trace_id_), ts);
+ TRACE_EVENT_BEGIN(kTraceCategoriesForAsyncEvents, trace_name_str,
+ perfetto::Track::Global(trace_id_), ts);
}
TRACE_EVENT("input,benchmark", "LatencyInfo.Flow",
@@ -297,15 +304,25 @@ void LatencyInfo::Terminate() {
terminated_ = true;
if (*g_latency_info_enabled.Get().latency_info_enabled) {
- // The name field is not needed for NESTABLE events because we only need the
- // category to know which event to close. In fact the name will not be
- // emitted internally.
- //
- // TODO(nuskos): Once we have the new TraceEvent macros that support Tracks
- // we can migrate this macro to it (and the name will no longer be there).
- TRACE_EVENT_NESTABLE_ASYNC_END1(kTraceCategoriesForAsyncEvents,
- /* name = */ "", TRACE_ID_GLOBAL(trace_id_),
- "data", AsTraceableData());
+ TRACE_EVENT_END(
+ kTraceCategoriesForAsyncEvents, perfetto::Track::Global(trace_id_),
+ [this](perfetto::EventContext ctx) {
+ ChromeLatencyInfo* info = ctx.event()->set_chrome_latency_info();
+ for (const auto& lc : latency_components_) {
+ ChromeLatencyInfo::ComponentInfo* component =
+ info->add_component_info();
+
+ component->set_component_type(GetComponentProtoEnum(lc.first));
+ component->set_time_us(lc.second.since_origin().InMicroseconds());
+ }
+
+ if (gesture_scroll_id_ > 0) {
+ info->set_gesture_scroll_id(gesture_scroll_id_);
+ }
+
+ info->set_trace_id(trace_id_);
+ info->set_is_coalesced(coalesced_);
+ });
}
TRACE_EVENT("input,benchmark", "LatencyInfo.Flow",
@@ -339,22 +356,6 @@ LatencyInfo LatencyInfo::ScaledBy(float scale) const {
return scaled_latency_info;
}
-std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
-LatencyInfo::AsTraceableData() {
- std::unique_ptr<base::DictionaryValue> record_data(
- new base::DictionaryValue());
- for (const auto& lc : latency_components_) {
- std::unique_ptr<base::DictionaryValue> component_info(
- new base::DictionaryValue());
- component_info->SetDouble(
- "time", static_cast<double>(lc.second.since_origin().InMicroseconds()));
- record_data->Set(GetComponentName(lc.first), std::move(component_info));
- }
- record_data->SetDouble("trace_id", static_cast<double>(trace_id_));
- record_data->SetBoolean("is_coalesced", coalesced_);
- return LatencyInfoTracedValue::FromValue(std::move(record_data));
-}
-
bool LatencyInfo::FindLatency(LatencyComponentType type,
base::TimeTicks* output) const {
auto it = latency_components_.find(type);
diff --git a/chromium/ui/latency/latency_info.h b/chromium/ui/latency/latency_info.h
index 1c8b1926362..ac41fa7750b 100644
--- a/chromium/ui/latency/latency_info.h
+++ b/chromium/ui/latency/latency_info.h
@@ -24,12 +24,6 @@
#include "mojo/public/cpp/bindings/struct_traits.h" // nogncheck
#endif
-namespace base {
-namespace trace_event {
-class ConvertableToTraceFormat;
-}
-}
-
namespace ui {
#if !defined(OS_IOS)
@@ -195,16 +189,14 @@ class LatencyInfo {
float predicted_scroll_update_delta() const {
return predicted_scroll_update_delta_;
}
+ int64_t gesture_scroll_id() const { return gesture_scroll_id_; }
+ void set_gesture_scroll_id(int64_t id) { gesture_scroll_id_ = id; }
private:
void AddLatencyNumberWithTimestampImpl(LatencyComponentType component,
base::TimeTicks time,
const char* trace_name_str);
- // Converts latencyinfo into format that can be dumped into trace buffer.
- std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
- AsTraceableData();
-
LatencyMap latency_components_;
// The unique id for matching the ASYNC_BEGIN/END trace event.
@@ -224,6 +216,14 @@ class LatencyInfo {
float scroll_update_delta_;
float predicted_scroll_update_delta_;
+ // The unique id for denoting a scroll gesture. This is only set for
+ // GestureScrollBegin, GestureScrollUpdate, and GestureScrollEnd events, and
+ // allows easy grouping of these global async events into a single logical
+ // scroll in the sql interface of TBMv3 (Trace Based Metrics v3). As a current
+ // implementation detail this unique id comes from the |trace_id| of the
+ // associated GestureScrollBegin (-1 if there was none or it wasn't valid).
+ int64_t gesture_scroll_id_;
+
#if !defined(OS_IOS)
friend struct IPC::ParamTraits<ui::LatencyInfo>;
friend struct mojo::StructTraits<ui::mojom::LatencyInfoDataView,
diff --git a/chromium/ui/latency/latency_tracker.h b/chromium/ui/latency/latency_tracker.h
index 37de25db729..cb3898ba5d5 100644
--- a/chromium/ui/latency/latency_tracker.h
+++ b/chromium/ui/latency/latency_tracker.h
@@ -5,6 +5,7 @@
#ifndef UI_LATENCY_LATENCY_TRACKER_H_
#define UI_LATENCY_LATENCY_TRACKER_H_
+#include "base/callback_forward.h"
#include "base/macros.h"
#include "ui/latency/average_lag_tracker.h"
#include "ui/latency/latency_info.h"
diff --git a/chromium/ui/latency/mojom/BUILD.gn b/chromium/ui/latency/mojom/BUILD.gn
index 607bc5e2346..f8aeb4c757e 100644
--- a/chromium/ui/latency/mojom/BUILD.gn
+++ b/chromium/ui/latency/mojom/BUILD.gn
@@ -9,6 +9,25 @@ mojom("mojom") {
sources = [ "latency_info.mojom" ]
public_deps = [ "//mojo/public/mojom/base" ]
+
+ cpp_typemaps = [
+ {
+ types = [
+ {
+ mojom = "ui.mojom.LatencyComponentType"
+ cpp = "::ui::LatencyComponentType"
+ },
+ {
+ mojom = "ui.mojom.LatencyInfo"
+ cpp = "::ui::LatencyInfo"
+ },
+ ]
+ traits_sources = [ "latency_info_mojom_traits.cc" ]
+ traits_headers = [ "latency_info_mojom_traits.h" ]
+ traits_public_deps = [ "//ui/latency" ]
+ traits_deps = [ "//ipc:param_traits" ]
+ },
+ ]
}
mojom("test_interfaces") {
diff --git a/chromium/ui/latency/mojom/OWNERS b/chromium/ui/latency/mojom/OWNERS
index 743855d259f..1feb5149750 100644
--- a/chromium/ui/latency/mojom/OWNERS
+++ b/chromium/ui/latency/mojom/OWNERS
@@ -1,8 +1,4 @@
per-file *.mojom=set noparent
per-file *.mojom=file://ipc/SECURITY_OWNERS
-
-per-file *.typemap=set noparent
-per-file *.typemap=file://ipc/SECURITY_OWNERS
-
per-file *_mojom_traits*.*=set noparent
per-file *_mojom_traits*.*=file://ipc/SECURITY_OWNERS
diff --git a/chromium/ui/latency/mojom/latency_info.mojom b/chromium/ui/latency/mojom/latency_info.mojom
index b4d84409ec1..77a5c42e6cc 100644
--- a/chromium/ui/latency/mojom/latency_info.mojom
+++ b/chromium/ui/latency/mojom/latency_info.mojom
@@ -67,4 +67,6 @@ struct LatencyInfo {
SourceEventType source_event_type;
float scroll_update_delta;
float predicted_scroll_update_delta;
+ // optional: only valid on GestureScroll events.
+ int64 gesture_scroll_id;
};
diff --git a/chromium/ui/latency/mojom/latency_info.typemap b/chromium/ui/latency/mojom/latency_info.typemap
deleted file mode 100644
index 304e600b9a0..00000000000
--- a/chromium/ui/latency/mojom/latency_info.typemap
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-mojom = "//ui/latency/mojom/latency_info.mojom"
-public_headers = [ "//ui/latency/latency_info.h" ]
-traits_headers = [ "//ui/latency/mojom/latency_info_mojom_traits.h" ]
-sources = [
- "latency_info_mojom_traits.cc",
- "latency_info_mojom_traits.h",
-]
-public_deps = [
- "//ui/latency",
-]
-deps = [
- "//ipc:param_traits",
-]
-type_mappings = [
- "ui.mojom.LatencyComponentType=::ui::LatencyComponentType",
- "ui.mojom.LatencyInfo=::ui::LatencyInfo",
-]
diff --git a/chromium/ui/latency/mojom/latency_info_mojom_traits.cc b/chromium/ui/latency/mojom/latency_info_mojom_traits.cc
index 11fc916fd6e..4760725e9f2 100644
--- a/chromium/ui/latency/mojom/latency_info_mojom_traits.cc
+++ b/chromium/ui/latency/mojom/latency_info_mojom_traits.cc
@@ -121,6 +121,13 @@ float StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::
}
// static
+int64_t
+StructTraits<ui::mojom::LatencyInfoDataView,
+ ui::LatencyInfo>::gesture_scroll_id(const ui::LatencyInfo& info) {
+ return info.gesture_scroll_id();
+}
+
+// static
bool StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::Read(
ui::mojom::LatencyInfoDataView data,
ui::LatencyInfo* out) {
@@ -134,6 +141,7 @@ bool StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo>::Read(
out->source_event_type_ = MojoSourceEventTypeToUI(data.source_event_type());
out->scroll_update_delta_ = data.scroll_update_delta();
out->predicted_scroll_update_delta_ = data.predicted_scroll_update_delta();
+ out->gesture_scroll_id_ = data.gesture_scroll_id();
return true;
}
diff --git a/chromium/ui/latency/mojom/latency_info_mojom_traits.h b/chromium/ui/latency/mojom/latency_info_mojom_traits.h
index ee88a55718b..5bc2a683060 100644
--- a/chromium/ui/latency/mojom/latency_info_mojom_traits.h
+++ b/chromium/ui/latency/mojom/latency_info_mojom_traits.h
@@ -55,6 +55,7 @@ struct StructTraits<ui::mojom::LatencyInfoDataView, ui::LatencyInfo> {
const ui::LatencyInfo& info);
static float scroll_update_delta(const ui::LatencyInfo& info);
static float predicted_scroll_update_delta(const ui::LatencyInfo& info);
+ static int64_t gesture_scroll_id(const ui::LatencyInfo& info);
static bool Read(ui::mojom::LatencyInfoDataView data, ui::LatencyInfo* out);
};
diff --git a/chromium/ui/latency/mojom/typemaps.gni b/chromium/ui/latency/mojom/typemaps.gni
deleted file mode 100644
index aa9d39aa638..00000000000
--- a/chromium/ui/latency/mojom/typemaps.gni
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-typemaps = [ "//ui/latency/mojom/latency_info.typemap" ]
diff --git a/chromium/ui/login/display_manager.js b/chromium/ui/login/display_manager.js
index aa8eaccc16a..6857c87482c 100644
--- a/chromium/ui/login/display_manager.js
+++ b/chromium/ui/login/display_manager.js
@@ -211,12 +211,6 @@ cr.define('cr.ui.login', function() {
userCount_: 0,
/**
- * Number of reloadContent() calls since start for testing.
- * @type {number}
- */
- reloadContentNumEvents_: 0,
-
- /**
* Stored OOBE configuration for newly registered screens.
* @type {!OobeTypes.OobeConfiguration}
*/
@@ -265,9 +259,7 @@ cr.define('cr.ui.login', function() {
* @return {boolean}
*/
get showingViewsLogin() {
- return loadTimeData.valueExists('showViewsLogin') &&
- loadTimeData.getString('showViewsLogin') == 'on' &&
- (this.displayType_ == DISPLAY_TYPE.GAIA_SIGNIN);
+ return this.displayType_ == DISPLAY_TYPE.GAIA_SIGNIN;
},
/**
@@ -727,6 +719,7 @@ cr.define('cr.ui.login', function() {
registerScreen: function(el, attributes) {
var screenId = el.id;
assert(screenId);
+ assert(!this.screens_.includes(screenId), "Duplicate screen ID.");
this.screens_.push(screenId);
this.screensAttributes_.push(attributes);
@@ -811,7 +804,6 @@ cr.define('cr.ui.login', function() {
var currentScreenId = this.screens_[this.currentStep_];
var currentScreen = $(currentScreenId);
this.updateScreenSize(currentScreen);
- ++this.reloadContentNumEvents_;
},
/**
diff --git a/chromium/ui/message_center/BUILD.gn b/chromium/ui/message_center/BUILD.gn
index 1deef129c55..1b1ae8aec81 100644
--- a/chromium/ui/message_center/BUILD.gn
+++ b/chromium/ui/message_center/BUILD.gn
@@ -196,6 +196,7 @@ if (enable_message_center) {
if (toolkit_views) {
sources += [
"views/message_popup_collection_unittest.cc",
+ "views/notification_control_buttons_unittest.cc",
"views/notification_header_view_unittest.cc",
"views/notification_view_md_unittest.cc",
"views/relative_time_formatter_unittest.cc",
diff --git a/chromium/ui/message_center/dummy_message_center.cc b/chromium/ui/message_center/dummy_message_center.cc
index 56410a6ec3d..db8d9dedf5a 100644
--- a/chromium/ui/message_center/dummy_message_center.cc
+++ b/chromium/ui/message_center/dummy_message_center.cc
@@ -9,8 +9,8 @@
// and link with Android implementations of Chrome which do not have
// notification systems yet. This is to avoid spreading compile-time flags
// everywhere in the code.
-#if !defined(OS_ANDROID)
-#error This file should only be used in Android.
+#if !(defined(OS_ANDROID) || defined(OS_FUCHSIA))
+#error This file should only be used in Android and Fuchsia.
#endif
namespace message_center {
diff --git a/chromium/ui/message_center/message_center_observer.h b/chromium/ui/message_center/message_center_observer.h
index 999f7cd6219..3e31960c977 100644
--- a/chromium/ui/message_center/message_center_observer.h
+++ b/chromium/ui/message_center/message_center_observer.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/optional.h"
+#include "base/strings/string16.h"
#include "ui/message_center/message_center_export.h"
#include "ui/message_center/message_center_types.h"
diff --git a/chromium/ui/message_center/notification_list.cc b/chromium/ui/message_center/notification_list.cc
index d4278f9e5fb..2e283dd0094 100644
--- a/chromium/ui/message_center/notification_list.cc
+++ b/chromium/ui/message_center/notification_list.cc
@@ -7,7 +7,7 @@
#include <utility>
#include "base/bind.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "base/time/time.h"
#include "base/values.h"
#include "ui/gfx/image/image.h"
diff --git a/chromium/ui/message_center/public/cpp/message_center_constants.h b/chromium/ui/message_center/public/cpp/message_center_constants.h
index 5996883738f..9b585cbba68 100644
--- a/chromium/ui/message_center/public/cpp/message_center_constants.h
+++ b/chromium/ui/message_center/public/cpp/message_center_constants.h
@@ -34,11 +34,6 @@ const size_t kMaxVisiblePopupNotifications = 3;
// DIP dimension; H size of the whole card.
const int kNotificationWidth = 360;
-// Colors.
-constexpr SkColor kMessageCenterBorderColor = SkColorSetRGB(0xC7, 0xCA, 0xCE);
-constexpr SkColor kMessageCenterShadowColor =
- SkColorSetA(SK_ColorBLACK, 0.5 * 255);
-
// Within a notification ///////////////////////////////////////////////////////
// DIP dimensions (H = horizontal, V = vertical).
@@ -66,11 +61,6 @@ const int kMessageLineHeight = 18; // In DIPs.
// Colors.
// Background of the card.
constexpr SkColor kNotificationBackgroundColor = SK_ColorWHITE;
-// Background of the image.
-constexpr SkColor kImageBackgroundColor = kNotificationBackgroundColor;
-// Title, message, ...
-constexpr SkColor kRegularTextColorMD = SkColorSetRGB(0x21, 0x21, 0x21);
-constexpr SkColor kDimTextColorMD = SkColorSetRGB(0x75, 0x75, 0x75);
// The focus border.
constexpr SkColor kFocusBorderColor = SkColorSetRGB(64, 128, 250);
// Foreground of small icon image.
@@ -78,13 +68,6 @@ constexpr SkColor kSmallImageMaskForegroundColor = SK_ColorWHITE;
// Background of small icon image.
constexpr SkColor kSmallImageMaskBackgroundColor =
SkColorSetRGB(0xa3, 0xa3, 0xa3);
-// Background of the close button and the settings button.
-#if defined(OS_CHROMEOS)
-constexpr SkColor kControlButtonBackgroundColor =
- SkColorSetA(SK_ColorWHITE, 0.9 * 0xff);
-#else
-constexpr SkColor kControlButtonBackgroundColor = SK_ColorTRANSPARENT;
-#endif
// Default accent color of notifications that are not generated by system.
constexpr SkColor kNotificationDefaultAccentColor = gfx::kChromeIconGrey;
@@ -109,18 +92,13 @@ const int kButtonHorizontalPadding = 16; // In DIPs.
const int kButtonIconTopPadding = 11; // In DIPs.
const int kButtonIconToTitlePadding = 16; // In DIPs.
-#if !defined(OS_LINUX) || defined(USE_AURA)
-constexpr SkColor kButtonSeparatorColor = SkColorSetRGB(234, 234, 234);
constexpr SkColor kHoveredButtonBackgroundColor = SkColorSetRGB(243, 243, 243);
-#endif
// Progress bar.
const int kProgressBarTopPadding = 16;
#if defined(OS_MACOSX)
const int kProgressBarThickness = 5;
const int kProgressBarCornerRadius = 3;
-constexpr SkColor kProgressBarBackgroundColor = SkColorSetARGB(26, 0, 0, 0);
-constexpr SkColor kProgressBarSliceColor = SkColorSetRGB(26, 194, 34);
#endif
// Line limits.
diff --git a/chromium/ui/message_center/public/cpp/notification.cc b/chromium/ui/message_center/public/cpp/notification.cc
index fe5219dab32..f9c1e4f373f 100644
--- a/chromium/ui/message_center/public/cpp/notification.cc
+++ b/chromium/ui/message_center/public/cpp/notification.cc
@@ -7,7 +7,6 @@
#include <map>
#include <memory>
-#include "base/logging.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/paint_vector_icon.h"
diff --git a/chromium/ui/message_center/public/cpp/notification_delegate.cc b/chromium/ui/message_center/public/cpp/notification_delegate.cc
index fe133b90d25..c0a1b63b58e 100644
--- a/chromium/ui/message_center/public/cpp/notification_delegate.cc
+++ b/chromium/ui/message_center/public/cpp/notification_delegate.cc
@@ -5,7 +5,7 @@
#include "ui/message_center/public/cpp/notification_delegate.h"
#include "base/bind.h"
-#include "base/logging.h"
+#include "base/check.h"
namespace message_center {
diff --git a/chromium/ui/message_center/public/cpp/notifier_id.cc b/chromium/ui/message_center/public/cpp/notifier_id.cc
index 3549b9ae81e..4a68545f4f0 100644
--- a/chromium/ui/message_center/public/cpp/notifier_id.cc
+++ b/chromium/ui/message_center/public/cpp/notifier_id.cc
@@ -3,7 +3,7 @@
// found in the LICENSE file.
#include "ui/message_center/public/cpp/notifier_id.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "base/strings/string_number_conversions.h"
namespace message_center {
diff --git a/chromium/ui/message_center/views/desktop_message_popup_collection.cc b/chromium/ui/message_center/views/desktop_message_popup_collection.cc
index b7b060f39f0..e4f875b591b 100644
--- a/chromium/ui/message_center/views/desktop_message_popup_collection.cc
+++ b/chromium/ui/message_center/views/desktop_message_popup_collection.cc
@@ -93,6 +93,13 @@ bool DesktopMessagePopupCollection::IsPrimaryDisplayForNotification() const {
return true;
}
+bool DesktopMessagePopupCollection::BlockForMixedFullscreen(
+ const Notification& notification) const {
+ // Always return false. Notifications for fullscreen will be blocked by
+ // chrome/browser/notifications/fullscreen_notification_blocker.
+ return false;
+}
+
// Anytime the display configuration changes, we need to recompute the alignment
// on the primary display. But, we get different events on different platforms.
// On Windows, for example, when switching from a laptop display to an external
diff --git a/chromium/ui/message_center/views/desktop_message_popup_collection.h b/chromium/ui/message_center/views/desktop_message_popup_collection.h
index 5ff406c0ffb..0c3cca147b2 100644
--- a/chromium/ui/message_center/views/desktop_message_popup_collection.h
+++ b/chromium/ui/message_center/views/desktop_message_popup_collection.h
@@ -45,6 +45,7 @@ class MESSAGE_CENTER_EXPORT DesktopMessagePopupCollection
bool IsTopDown() const override;
bool IsFromLeft() const override;
bool IsPrimaryDisplayForNotification() const override;
+ bool BlockForMixedFullscreen(const Notification& notification) const override;
private:
friend class test::MessagePopupCollectionTest;
diff --git a/chromium/ui/message_center/views/message_popup_collection.cc b/chromium/ui/message_center/views/message_popup_collection.cc
index 65511fb5d2e..95fd1e78b37 100644
--- a/chromium/ui/message_center/views/message_popup_collection.cc
+++ b/chromium/ui/message_center/views/message_popup_collection.cc
@@ -34,6 +34,8 @@ MessagePopupCollection::MessagePopupCollection()
}
MessagePopupCollection::~MessagePopupCollection() {
+ // Ignore calls to update which can cause crashes.
+ is_updating_ = true;
for (const auto& item : popup_items_)
item.popup->Close();
MessageCenter::Get()->RemoveObserver(this);
@@ -139,7 +141,7 @@ void MessagePopupCollection::OnNotificationUpdated(
return;
// Find Notification object with |notification_id|.
- const auto& notifications = MessageCenter::Get()->GetPopupNotifications();
+ const auto& notifications = GetPopupNotifications();
auto it = notifications.begin();
while (it != notifications.end()) {
if ((*it)->id() == notification_id)
@@ -388,25 +390,37 @@ void MessagePopupCollection::UpdateByAnimation() {
}
}
-bool MessagePopupCollection::AddPopup() {
- std::set<std::string> existing_ids;
- for (const auto& item : popup_items_)
- existing_ids.insert(item.id);
-
- auto notifications = MessageCenter::Get()->GetPopupNotifications();
- Notification* new_notification = nullptr;
- // Reverse iterating because notifications are in reverse chronological order.
- for (auto it = notifications.rbegin(); it != notifications.rend(); ++it) {
+std::vector<Notification*> MessagePopupCollection::GetPopupNotifications()
+ const {
+ std::vector<Notification*> result;
+ for (auto* notification : MessageCenter::Get()->GetPopupNotifications()) {
// Disables popup of custom notification on non-primary displays, since
// currently custom notification supports only on one display at the same
// time.
// TODO(yoshiki): Support custom popup notification on multiple display
// (https://crbug.com/715370).
if (!IsPrimaryDisplayForNotification() &&
- (*it)->type() == NOTIFICATION_TYPE_CUSTOM) {
+ notification->type() == NOTIFICATION_TYPE_CUSTOM) {
continue;
}
+ if (BlockForMixedFullscreen(*notification))
+ continue;
+
+ result.emplace_back(notification);
+ }
+ return result;
+}
+
+bool MessagePopupCollection::AddPopup() {
+ std::set<std::string> existing_ids;
+ for (const auto& item : popup_items_)
+ existing_ids.insert(item.id);
+
+ auto notifications = GetPopupNotifications();
+ Notification* new_notification = nullptr;
+ // Reverse iterating because notifications are in reverse chronological order.
+ for (auto it = notifications.rbegin(); it != notifications.rend(); ++it) {
if (!existing_ids.count((*it)->id())) {
new_notification = *it;
break;
@@ -461,13 +475,16 @@ bool MessagePopupCollection::AddPopup() {
void MessagePopupCollection::MarkRemovedPopup() {
std::set<std::string> existing_ids;
- for (Notification* notification :
- MessageCenter::Get()->GetPopupNotifications()) {
+ for (Notification* notification : GetPopupNotifications()) {
existing_ids.insert(notification->id());
}
- for (auto& item : popup_items_)
- item.is_animating = !existing_ids.count(item.id);
+ for (auto& item : popup_items_) {
+ bool removing = !existing_ids.count(item.id);
+ item.is_animating = removing;
+ if (removing)
+ NotifyPopupRemoved(item.id);
+ }
}
void MessagePopupCollection::MoveDownPopups() {
@@ -585,8 +602,7 @@ bool MessagePopupCollection::HasAddedPopup() const {
for (const auto& item : popup_items_)
existing_ids.insert(item.id);
- for (Notification* notification :
- MessageCenter::Get()->GetPopupNotifications()) {
+ for (Notification* notification : GetPopupNotifications()) {
if (!existing_ids.count(notification->id()))
return true;
}
@@ -595,8 +611,7 @@ bool MessagePopupCollection::HasAddedPopup() const {
bool MessagePopupCollection::HasRemovedPopup() const {
std::set<std::string> existing_ids;
- for (Notification* notification :
- MessageCenter::Get()->GetPopupNotifications()) {
+ for (Notification* notification : GetPopupNotifications()) {
existing_ids.insert(notification->id());
}
diff --git a/chromium/ui/message_center/views/message_popup_collection.h b/chromium/ui/message_center/views/message_popup_collection.h
index 9d4b9e70025..b3c1381bf0b 100644
--- a/chromium/ui/message_center/views/message_popup_collection.h
+++ b/chromium/ui/message_center/views/message_popup_collection.h
@@ -6,6 +6,7 @@
#define UI_MESSAGE_CENTER_VIEWS_MESSAGE_POPUP_COLLECTION_H_
#include <memory>
+#include <vector>
#include "base/memory/weak_ptr.h"
#include "ui/gfx/animation/animation_delegate.h"
@@ -104,8 +105,22 @@ class MESSAGE_CENTER_EXPORT MessagePopupCollection
// display.
virtual bool IsPrimaryDisplayForNotification() const = 0;
+ // Returns true if |notification| should be blocked because this display to
+ // show the notification is fullscreen. If all (1 of 1, or n of n) displays
+ // are fullscreen, the notification will already be blocked by the associated
+ // FullscreenNotificationBlocker, but this function is required for the case
+ // where there are multiple displays, and the notification should be blocked
+ // on those that are fullscreen, but displayed on the others.
+ //
+ // This function can return false when only a single display is supported
+ // since FullscreenNotificationBlocker will have already blocked anything.
+ virtual bool BlockForMixedFullscreen(
+ const Notification& notification) const = 0;
+
// Called when a new popup item is added.
virtual void NotifyPopupAdded(MessagePopupView* popup) {}
+ // Called with |notification_id| when a popup is marked to be removed.
+ virtual void NotifyPopupRemoved(const std::string& notification_id) {}
// virtual for testing.
virtual MessagePopupView* CreatePopup(const Notification& notification);
@@ -181,6 +196,10 @@ class MESSAGE_CENTER_EXPORT MessagePopupCollection
// Update bounds and opacity of popups during animation.
void UpdateByAnimation();
+ // Get popup notifications in sort order from MessageCenter, filtered for any
+ // that should not show on this display.
+ std::vector<Notification*> GetPopupNotifications() const;
+
// Add a new popup to |popup_items_| for FADE_IN animation.
// Return true if a popup is actually added. It may still return false when
// HasAddedPopup() return true by the lack of work area to show popup.
diff --git a/chromium/ui/message_center/views/message_popup_collection_unittest.cc b/chromium/ui/message_center/views/message_popup_collection_unittest.cc
index 2f3df8d422e..a79a6379d58 100644
--- a/chromium/ui/message_center/views/message_popup_collection_unittest.cc
+++ b/chromium/ui/message_center/views/message_popup_collection_unittest.cc
@@ -51,6 +51,8 @@ class MockMessagePopupCollection : public DesktopMessagePopupCollection {
is_primary_display_ = is_primary_display;
}
+ void set_is_fullscreen(bool is_fullscreen) { is_fullscreen_ = is_fullscreen; }
+
void set_new_popup_height(int new_popup_height) {
new_popup_height_ = new_popup_height;
}
@@ -83,6 +85,11 @@ class MockMessagePopupCollection : public DesktopMessagePopupCollection {
return is_primary_display_;
}
+ bool BlockForMixedFullscreen(
+ const Notification& notification) const override {
+ return is_fullscreen_;
+ }
+
private:
gfx::NativeWindow context_;
@@ -90,6 +97,7 @@ class MockMessagePopupCollection : public DesktopMessagePopupCollection {
bool popup_timer_started_ = false;
bool is_primary_display_ = true;
+ bool is_fullscreen_ = false;
int new_popup_height_ = 84;
DISALLOW_COPY_AND_ASSIGN(MockMessagePopupCollection);
@@ -503,6 +511,20 @@ TEST_F(MessagePopupCollectionTest, NotShowCustomOnSubDisplay) {
EXPECT_EQ(0u, GetPopupCounts());
}
+TEST_F(MessagePopupCollectionTest, MixedFullscreenShow) {
+ popup_collection()->set_is_fullscreen(false);
+ AddNotification();
+ EXPECT_TRUE(IsAnimating());
+ EXPECT_EQ(1u, GetPopupCounts());
+}
+
+TEST_F(MessagePopupCollectionTest, MixedFullscreenBlock) {
+ popup_collection()->set_is_fullscreen(true);
+ AddNotification();
+ EXPECT_FALSE(IsAnimating());
+ EXPECT_EQ(0u, GetPopupCounts());
+}
+
TEST_F(MessagePopupCollectionTest, NotificationsMoveDown) {
std::vector<std::string> ids;
for (size_t i = 0; i < kMaxVisiblePopupNotifications + 1; ++i)
diff --git a/chromium/ui/message_center/views/message_view.cc b/chromium/ui/message_center/views/message_view.cc
index 3232f6c4fde..a6a19d6d334 100644
--- a/chromium/ui/message_center/views/message_view.cc
+++ b/chromium/ui/message_center/views/message_view.cc
@@ -23,7 +23,6 @@
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/image_button.h"
-#include "ui/views/controls/highlight_path_generator.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/focus/focus_manager.h"
@@ -69,19 +68,12 @@ bool ShouldShowAeroShadowBorder() {
// static
const char MessageView::kViewClassName[] = "MessageView";
-class MessageView::HighlightPathGenerator
- : public views::HighlightPathGenerator {
- public:
- HighlightPathGenerator() = default;
+MessageView::HighlightPathGenerator::HighlightPathGenerator() = default;
- // views::HighlightPathGenerator:
- SkPath GetHighlightPath(const views::View* view) override {
- return static_cast<const MessageView*>(view)->GetHighlightPath();
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(HighlightPathGenerator);
-};
+SkPath MessageView::HighlightPathGenerator::GetHighlightPath(
+ const views::View* view) {
+ return static_cast<const MessageView*>(view)->GetHighlightPath();
+}
MessageView::MessageView(const Notification& notification)
: notification_id_(notification.id()), slide_out_controller_(this, this) {
@@ -90,9 +82,6 @@ MessageView::MessageView(const Notification& notification)
views::HighlightPathGenerator::Install(
this, std::make_unique<HighlightPathGenerator>());
- // TODO(amehfooz): Remove explicit color setting after native theme changes.
- focus_ring_->SetColor(gfx::kGoogleBlue500);
-
// Paint to a dedicated layer to make the layer non-opaque.
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
diff --git a/chromium/ui/message_center/views/message_view.h b/chromium/ui/message_center/views/message_view.h
index d3b822db492..51e6c26377a 100644
--- a/chromium/ui/message_center/views/message_view.h
+++ b/chromium/ui/message_center/views/message_view.h
@@ -22,6 +22,7 @@
#include "ui/views/animation/slide_out_controller.h"
#include "ui/views/animation/slide_out_controller_delegate.h"
#include "ui/views/controls/focus_ring.h"
+#include "ui/views/controls/highlight_path_generator.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/view.h"
@@ -165,6 +166,16 @@ class MESSAGE_CENTER_EXPORT MessageView
std::string notification_id() const { return notification_id_; }
protected:
+ class HighlightPathGenerator : public views::HighlightPathGenerator {
+ public:
+ HighlightPathGenerator();
+ HighlightPathGenerator(const HighlightPathGenerator&) = delete;
+ HighlightPathGenerator& operator=(const HighlightPathGenerator&) = delete;
+
+ // views::HighlightPathGenerator:
+ SkPath GetHighlightPath(const views::View* view) override;
+ };
+
virtual void UpdateControlButtonsVisibility();
// Changes the background color and schedules a paint.
@@ -174,15 +185,15 @@ class MESSAGE_CENTER_EXPORT MessageView
views::ScrollView* scroller() { return scroller_; }
+ base::ObserverList<Observer>::Unchecked* observers() { return &observers_; }
+
bool is_nested() const { return is_nested_; }
- base::ObserverList<Observer>::Unchecked* observers() { return &observers_; }
+ views::FocusRing* focus_ring() { return focus_ring_.get(); }
private:
friend class test::MessagePopupCollectionTest;
- class HighlightPathGenerator;
-
// Gets the highlight path for the notification based on bounds and corner
// radii.
SkPath GetHighlightPath() const;
diff --git a/chromium/ui/message_center/views/notification_control_buttons_unittest.cc b/chromium/ui/message_center/views/notification_control_buttons_unittest.cc
new file mode 100644
index 00000000000..2ce2e4cfcd5
--- /dev/null
+++ b/chromium/ui/message_center/views/notification_control_buttons_unittest.cc
@@ -0,0 +1,81 @@
+// Copyright 2020 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 "ui/message_center/views/notification_control_buttons_view.h"
+
+#include "base/strings/utf_string_conversions.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/image/image.h"
+#include "ui/message_center/public/cpp/notification.h"
+#include "ui/message_center/views/message_view.h"
+
+namespace message_center {
+
+namespace {
+
+class TestMessageView : public MessageView {
+ public:
+ explicit TestMessageView(const Notification& notification)
+ : MessageView(notification),
+ buttons_view_(std::make_unique<NotificationControlButtonsView>(this)) {}
+
+ NotificationControlButtonsView* GetControlButtonsView() const override {
+ return buttons_view_.get();
+ }
+
+ private:
+ std::unique_ptr<NotificationControlButtonsView> buttons_view_;
+};
+
+} // namespace
+
+class NotificationControlButtonsTest : public testing::Test {
+ public:
+ NotificationControlButtonsTest() = default;
+ ~NotificationControlButtonsTest() override = default;
+
+ // testing::Test
+ void SetUp() override {
+ Test::SetUp();
+ Notification notification(
+ NOTIFICATION_TYPE_SIMPLE, "id", base::UTF8ToUTF16("title"),
+ base::UTF8ToUTF16("id"), gfx::Image(), base::string16(), GURL(),
+ NotifierId(NotifierType::APPLICATION, "notifier_id"),
+ RichNotificationData(), nullptr);
+ message_view_ = std::make_unique<TestMessageView>(notification);
+ }
+
+ NotificationControlButtonsView* buttons_view() {
+ return message_view_->GetControlButtonsView();
+ }
+
+ private:
+ std::unique_ptr<TestMessageView> message_view_;
+
+ DISALLOW_COPY_AND_ASSIGN(NotificationControlButtonsTest);
+};
+
+TEST_F(NotificationControlButtonsTest, TestShowAndHideButtons) {
+ EXPECT_EQ(nullptr, buttons_view()->close_button());
+ EXPECT_EQ(nullptr, buttons_view()->settings_button());
+ EXPECT_EQ(nullptr, buttons_view()->snooze_button());
+
+ buttons_view()->ShowCloseButton(true);
+ buttons_view()->ShowSettingsButton(true);
+ buttons_view()->ShowSnoozeButton(true);
+
+ EXPECT_NE(nullptr, buttons_view()->close_button());
+ EXPECT_NE(nullptr, buttons_view()->settings_button());
+ EXPECT_NE(nullptr, buttons_view()->snooze_button());
+
+ buttons_view()->ShowCloseButton(false);
+ buttons_view()->ShowSettingsButton(false);
+ buttons_view()->ShowSnoozeButton(false);
+
+ EXPECT_EQ(nullptr, buttons_view()->close_button());
+ EXPECT_EQ(nullptr, buttons_view()->settings_button());
+ EXPECT_EQ(nullptr, buttons_view()->snooze_button());
+}
+
+} // namespace message_center
diff --git a/chromium/ui/message_center/views/notification_control_buttons_view.cc b/chromium/ui/message_center/views/notification_control_buttons_view.cc
index 1e4a7262e50..a7109999755 100644
--- a/chromium/ui/message_center/views/notification_control_buttons_view.cc
+++ b/chromium/ui/message_center/views/notification_control_buttons_view.cc
@@ -28,22 +28,22 @@ NotificationControlButtonsView::NotificationControlButtonsView(
MessageView* message_view)
: message_view_(message_view), icon_color_(gfx::kChromeIconGrey) {
DCHECK(message_view);
- SetLayoutManager(std::make_unique<views::BoxLayout>(
+ auto* layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal));
+ // Do not stretch buttons as that would stretch their focus indicator.
+ layout->set_cross_axis_alignment(
+ views::BoxLayout::CrossAxisAlignment::kStart);
// Use layer to change the opacity.
SetPaintToLayer();
layer()->SetFillsBoundsOpaquely(false);
-
- SetBackground(views::CreateSolidBackground(kControlButtonBackgroundColor));
}
NotificationControlButtonsView::~NotificationControlButtonsView() = default;
void NotificationControlButtonsView::ShowCloseButton(bool show) {
if (show && !close_button_) {
- close_button_ = std::make_unique<PaddedButton>(this);
- close_button_->set_owned_by_client();
+ close_button_ = AddChildView(std::make_unique<PaddedButton>(this));
close_button_->SetImage(
views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(kNotificationCloseButtonIcon, icon_color_));
@@ -53,20 +53,20 @@ void NotificationControlButtonsView::ShowCloseButton(bool show) {
IDS_MESSAGE_CENTER_CLOSE_NOTIFICATION_BUTTON_TOOLTIP));
close_button_->SetBackground(
views::CreateSolidBackground(SK_ColorTRANSPARENT));
-
- // Add the button at the last.
- AddChildView(close_button_.get());
Layout();
} else if (!show && close_button_) {
- DCHECK(Contains(close_button_.get()));
- close_button_.reset();
+ DCHECK(Contains(close_button_));
+ RemoveChildViewT(close_button_);
+ close_button_ = nullptr;
}
}
void NotificationControlButtonsView::ShowSettingsButton(bool show) {
if (show && !settings_button_) {
- settings_button_ = std::make_unique<PaddedButton>(this);
- settings_button_->set_owned_by_client();
+ // Add the button next right to the snooze button.
+ const int position = snooze_button_ ? 1 : 0;
+ settings_button_ =
+ AddChildViewAt(std::make_unique<PaddedButton>(this), position);
settings_button_->SetImage(
views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(kNotificationSettingsButtonIcon, icon_color_));
@@ -76,21 +76,18 @@ void NotificationControlButtonsView::ShowSettingsButton(bool show) {
IDS_MESSAGE_NOTIFICATION_SETTINGS_BUTTON_ACCESSIBLE_NAME));
settings_button_->SetBackground(
views::CreateSolidBackground(SK_ColorTRANSPARENT));
-
- // Add the button next right to the snooze button.
- int position = snooze_button_ ? 1 : 0;
- AddChildViewAt(settings_button_.get(), position);
Layout();
} else if (!show && settings_button_) {
- DCHECK(Contains(settings_button_.get()));
- settings_button_.reset();
+ DCHECK(Contains(settings_button_));
+ RemoveChildViewT(settings_button_);
+ settings_button_ = nullptr;
}
}
void NotificationControlButtonsView::ShowSnoozeButton(bool show) {
if (show && !snooze_button_) {
- snooze_button_ = std::make_unique<PaddedButton>(this);
- snooze_button_->set_owned_by_client();
+ // Snooze button should appear as the first child.
+ snooze_button_ = AddChildViewAt(std::make_unique<PaddedButton>(this), 0);
snooze_button_->SetImage(
views::Button::STATE_NORMAL,
gfx::CreateVectorIcon(kNotificationSnoozeButtonIcon, icon_color_));
@@ -100,13 +97,11 @@ void NotificationControlButtonsView::ShowSnoozeButton(bool show) {
IDS_MESSAGE_CENTER_NOTIFICATION_SNOOZE_BUTTON_TOOLTIP));
snooze_button_->SetBackground(
views::CreateSolidBackground(SK_ColorTRANSPARENT));
-
- // Add the button at the first.
- AddChildViewAt(snooze_button_.get(), 0);
Layout();
} else if (!show && snooze_button_) {
- DCHECK(Contains(snooze_button_.get()));
- snooze_button_.reset();
+ DCHECK(Contains(snooze_button_));
+ RemoveChildViewT(snooze_button_);
+ snooze_button_ = nullptr;
}
}
@@ -146,29 +141,25 @@ void NotificationControlButtonsView::SetButtonIconColors(SkColor color) {
}
}
-views::Button* NotificationControlButtonsView::close_button() const {
- return close_button_.get();
-}
-
-views::Button* NotificationControlButtonsView::settings_button() const {
- return settings_button_.get();
-}
-
-views::Button* NotificationControlButtonsView::snooze_button() const {
- return snooze_button_.get();
-}
-
const char* NotificationControlButtonsView::GetClassName() const {
return kViewClassName;
}
+#if defined(OS_CHROMEOS)
+void NotificationControlButtonsView::OnThemeChanged() {
+ View::OnThemeChanged();
+ SetBackground(views::CreateSolidBackground(GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_NotificationButtonBackground)));
+}
+#endif
+
void NotificationControlButtonsView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
- if (close_button_ && sender == close_button_.get()) {
+ if (close_button_ && sender == close_button_) {
message_view_->OnCloseButtonPressed();
- } else if (settings_button_ && sender == settings_button_.get()) {
+ } else if (settings_button_ && sender == settings_button_) {
message_view_->OnSettingsButtonPressed(event);
- } else if (snooze_button_ && sender == snooze_button_.get()) {
+ } else if (snooze_button_ && sender == snooze_button_) {
message_view_->OnSnoozeButtonPressed(event);
}
}
diff --git a/chromium/ui/message_center/views/notification_control_buttons_view.h b/chromium/ui/message_center/views/notification_control_buttons_view.h
index fe912f427e1..46821dc18b1 100644
--- a/chromium/ui/message_center/views/notification_control_buttons_view.h
+++ b/chromium/ui/message_center/views/notification_control_buttons_view.h
@@ -9,6 +9,7 @@
#include "base/macros.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/message_center/message_center_export.h"
+#include "ui/message_center/views/padded_button.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/view.h"
@@ -23,7 +24,6 @@ class Button;
namespace message_center {
class MessageView;
-class PaddedButton;
class MESSAGE_CENTER_EXPORT NotificationControlButtonsView
: public views::View,
@@ -53,12 +53,15 @@ class MESSAGE_CENTER_EXPORT NotificationControlButtonsView
void SetButtonIconColors(SkColor color);
// Methods for retrieving the control buttons directly.
- views::Button* close_button() const;
- views::Button* settings_button() const;
- views::Button* snooze_button() const;
+ views::Button* close_button() { return close_button_; }
+ views::Button* settings_button() { return settings_button_; }
+ views::Button* snooze_button() { return snooze_button_; }
// views::View
const char* GetClassName() const override;
+#if defined(OS_CHROMEOS)
+ void OnThemeChanged() override;
+#endif
// views::ButtonListener
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
@@ -66,9 +69,9 @@ class MESSAGE_CENTER_EXPORT NotificationControlButtonsView
private:
MessageView* message_view_;
- std::unique_ptr<PaddedButton> close_button_;
- std::unique_ptr<PaddedButton> settings_button_;
- std::unique_ptr<PaddedButton> snooze_button_;
+ PaddedButton* close_button_ = nullptr;
+ PaddedButton* settings_button_ = nullptr;
+ PaddedButton* snooze_button_ = nullptr;
// The color used for the close, settings, and snooze icons.
SkColor icon_color_;
diff --git a/chromium/ui/message_center/views/notification_header_view.cc b/chromium/ui/message_center/views/notification_header_view.cc
index 9be9b6dff60..11cb93f4b5f 100644
--- a/chromium/ui/message_center/views/notification_header_view.cc
+++ b/chromium/ui/message_center/views/notification_header_view.cc
@@ -81,6 +81,7 @@ class ExpandButton : public views::ImageView {
void OnPaint(gfx::Canvas* canvas) override;
void OnFocus() override;
void OnBlur() override;
+ void OnThemeChanged() override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
private:
@@ -88,8 +89,6 @@ class ExpandButton : public views::ImageView {
};
ExpandButton::ExpandButton() {
- focus_painter_ = views::Painter::CreateSolidFocusPainter(
- kFocusBorderColor, gfx::Insets(0, 0, 1, 1));
SetFocusBehavior(FocusBehavior::ALWAYS);
}
@@ -112,6 +111,14 @@ void ExpandButton::OnBlur() {
SchedulePaint();
}
+void ExpandButton::OnThemeChanged() {
+ ImageView::OnThemeChanged();
+ focus_painter_ = views::Painter::CreateSolidFocusPainter(
+ GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_FocusedBorderColor),
+ gfx::Insets(0, 0, 1, 1));
+}
+
void ExpandButton::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ax::mojom::Role::kButton;
node_data->SetName(GetTooltipText(gfx::Point()));
@@ -350,8 +357,6 @@ void NotificationHeaderView::SetAccentColor(SkColor color) {
app_name_view_->SetEnabledColor(accent_color_);
summary_text_view_->SetEnabledColor(accent_color_);
summary_text_divider_->SetEnabledColor(accent_color_);
- timestamp_divider_->SetEnabledColor(kRegularTextColorMD);
- timestamp_view_->SetEnabledColor(kRegularTextColorMD);
SetExpanded(is_expanded_);
// If we are using the default app icon we should clear it so we refresh it
diff --git a/chromium/ui/message_center/views/notification_view_md.cc b/chromium/ui/message_center/views/notification_view_md.cc
index 8ddcc497105..eadc6d89ea7 100644
--- a/chromium/ui/message_center/views/notification_view_md.cc
+++ b/chromium/ui/message_center/views/notification_view_md.cc
@@ -81,25 +81,12 @@ constexpr gfx::Insets kSettingsRowPadding(8, 0, 0, 0);
constexpr gfx::Insets kSettingsRadioButtonPadding(14, 18, 14, 18);
constexpr gfx::Insets kSettingsButtonRowPadding(8);
-// Background of inline actions area.
-constexpr SkColor kActionsRowBackgroundColor = SkColorSetRGB(0xee, 0xee, 0xee);
// Ripple ink drop opacity of action buttons.
const float kActionButtonInkDropRippleVisibleOpacity = 0.08f;
// Highlight (hover) ink drop opacity of action buttons.
const float kActionButtonInkDropHighlightVisibleOpacity = 0.08f;
// Text color of action button.
constexpr SkColor kActionButtonTextColor = gfx::kGoogleBlue600;
-// Background color of the large image.
-constexpr SkColor kLargeImageBackgroundColor = SkColorSetRGB(0xf5, 0xf5, 0xf5);
-// Background color of the inline settings.
-constexpr SkColor kInlineSettingsBackgroundColor =
- SkColorSetRGB(0xEE, 0xEE, 0xEE);
-
-// Text color and icon color of inline reply area when the textfield is empty.
-constexpr SkColor kTextfieldPlaceholderTextColorMD =
- SkColorSetA(SK_ColorWHITE, 0x8A);
-constexpr SkColor kTextfieldPlaceholderIconColorMD =
- SkColorSetA(SK_ColorWHITE, 0x60);
// The icon size of inline reply input field.
constexpr int kInputReplyButtonSize = 20;
@@ -185,20 +172,18 @@ std::unique_ptr<views::View> CreateItemView(const NotificationItem& item) {
title->SetFontList(font_list);
title->SetCollapseWhenHidden(true);
title->SetHorizontalAlignment(gfx::ALIGN_LEFT);
- title->SetEnabledColor(kRegularTextColorMD);
- title->SetBackgroundColor(kNotificationBackgroundColor);
title->SetAutoColorReadabilityEnabled(false);
view->AddChildView(title);
- views::Label* message = new views::Label(l10n_util::GetStringFUTF16(
- IDS_MESSAGE_CENTER_LIST_NOTIFICATION_MESSAGE_WITH_DIVIDER, item.message));
+ views::Label* message = view->AddChildView(std::make_unique<views::Label>(
+ l10n_util::GetStringFUTF16(
+ IDS_MESSAGE_CENTER_LIST_NOTIFICATION_MESSAGE_WITH_DIVIDER,
+ item.message),
+ views::style::CONTEXT_LABEL, views::style::STYLE_DISABLED));
message->SetFontList(font_list);
message->SetCollapseWhenHidden(true);
message->SetHorizontalAlignment(gfx::ALIGN_LEFT);
- message->SetEnabledColor(kDimTextColorMD);
- message->SetBackgroundColor(kNotificationBackgroundColor);
message->SetAutoColorReadabilityEnabled(false);
- view->AddChildView(message);
return view;
}
@@ -218,16 +203,13 @@ CompactTitleMessageView::CompactTitleMessageView() {
title_ = new views::Label();
title_->SetFontList(font_list);
title_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
- title_->SetEnabledColor(kRegularTextColorMD);
- title_->SetBackgroundColor(kNotificationBackgroundColor);
AddChildView(title_);
- message_ = new views::Label();
+ message_ = AddChildView(std::make_unique<views::Label>(
+ base::string16(), views::style::CONTEXT_LABEL,
+ views::style::STYLE_DISABLED));
message_->SetFontList(font_list);
message_->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
- message_->SetEnabledColor(kDimTextColorMD);
- message_->SetBackgroundColor(kNotificationBackgroundColor);
- AddChildView(message_);
}
gfx::Size CompactTitleMessageView::CalculatePreferredSize() const {
@@ -269,9 +251,7 @@ void CompactTitleMessageView::set_message(const base::string16& message) {
// LargeImageView //////////////////////////////////////////////////////////////
-LargeImageView::LargeImageView() {
- SetBackground(views::CreateSolidBackground(kLargeImageBackgroundColor));
-}
+LargeImageView::LargeImageView() = default;
LargeImageView::~LargeImageView() = default;
@@ -308,6 +288,12 @@ const char* LargeImageView::GetClassName() const {
return "LargeImageView";
}
+void LargeImageView::OnThemeChanged() {
+ View::OnThemeChanged();
+ SetBackground(views::CreateSolidBackground(GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_NotificationLargeImageBackground)));
+}
+
// Returns expected size of the image right after resizing.
// The GetResizedImageSize().width() <= kLargeImageMaxSize.width() holds, but
// GetResizedImageSize().height() may be larger than kLargeImageMaxSize.height()
@@ -376,7 +362,6 @@ NotificationInputContainerMD::NotificationInputContainerMD(
button_(new views::ImageButton(this)) {
auto* layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal, gfx::Insets(), 0));
- SetBackground(views::CreateSolidBackground(kActionsRowBackgroundColor));
SetInkDropMode(InkDropMode::ON);
set_ink_drop_visible_opacity(1);
@@ -384,9 +369,6 @@ NotificationInputContainerMD::NotificationInputContainerMD(
AddChildView(ink_drop_container_);
textfield_->set_controller(this);
- textfield_->SetTextColor(SK_ColorWHITE);
- textfield_->SetBackgroundColor(SK_ColorTRANSPARENT);
- textfield_->set_placeholder_text_color(kTextfieldPlaceholderTextColorMD);
textfield_->SetBorder(views::CreateEmptyBorder(kInputTextfieldPadding));
AddChildView(textfield_);
layout->SetFlexForView(textfield_, 1);
@@ -440,6 +422,18 @@ SkColor NotificationInputContainerMD::GetInkDropBaseColor() const {
return gfx::kGoogleBlue600;
}
+void NotificationInputContainerMD::OnThemeChanged() {
+ InkDropHostView::OnThemeChanged();
+ auto* theme = GetNativeTheme();
+ SetBackground(views::CreateSolidBackground(theme->GetSystemColor(
+ ui::NativeTheme::kColorId_NotificationActionsRowBackground)));
+ textfield_->SetTextColor(SK_ColorWHITE);
+ textfield_->SetBackgroundColor(SK_ColorTRANSPARENT);
+ textfield_->set_placeholder_text_color(theme->GetSystemColor(
+ ui::NativeTheme::kColorId_TextfieldPlaceholderColor));
+ SetButtonImage();
+}
+
bool NotificationInputContainerMD::HandleKeyEvent(views::Textfield* sender,
const ui::KeyEvent& event) {
if (event.type() == ui::ET_KEY_PRESSED &&
@@ -454,12 +448,7 @@ bool NotificationInputContainerMD::HandleKeyEvent(views::Textfield* sender,
void NotificationInputContainerMD::OnAfterUserAction(views::Textfield* sender) {
DCHECK_EQ(sender, textfield_);
- button_->SetImage(
- views::Button::STATE_NORMAL,
- gfx::CreateVectorIcon(kNotificationInlineReplyIcon, kInputReplyButtonSize,
- textfield_->GetText().empty()
- ? kTextfieldPlaceholderIconColorMD
- : SK_ColorWHITE));
+ SetButtonImage();
}
void NotificationInputContainerMD::ButtonPressed(views::Button* sender,
@@ -470,23 +459,45 @@ void NotificationInputContainerMD::ButtonPressed(views::Button* sender,
}
}
+void NotificationInputContainerMD::SetButtonImage() {
+ auto placeholder_icon_color_id =
+ textfield_->GetText().empty()
+ ? ui::NativeTheme::kColorId_NotificationEmptyPlaceholderIconColor
+ : ui::NativeTheme::kColorId_NotificationPlaceholderIconColor;
+ button_->SetImage(
+ views::Button::STATE_NORMAL,
+ gfx::CreateVectorIcon(
+ kNotificationInlineReplyIcon, kInputReplyButtonSize,
+ GetNativeTheme()->GetSystemColor(placeholder_icon_color_id)));
+}
+
// InlineSettingsRadioButton ///////////////////////////////////////////////////
class InlineSettingsRadioButton : public views::RadioButton {
public:
explicit InlineSettingsRadioButton(const base::string16& label_text)
: views::RadioButton(label_text, 1 /* group */) {
- SetEnabledTextColors(kRegularTextColorMD);
label()->SetFontList(GetTextFontList());
- label()->SetBackgroundColor(kInlineSettingsBackgroundColor);
label()->SetSubpixelRenderingEnabled(false);
}
+ void OnThemeChanged() override {
+ RadioButton::OnThemeChanged();
+ SetEnabledTextColors(GetTextColor());
+ label()->SetBackgroundColor(GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_NotificationInlineSettingsBackground));
+ }
+
private:
// views::RadioButton:
SkColor GetIconImageColor(int icon_state) const override {
return (icon_state & IconState::CHECKED) ? kActionButtonTextColor
- : kRegularTextColorMD;
+ : GetTextColor();
+ }
+
+ SkColor GetTextColor() const {
+ return GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_LabelEnabledColor);
}
};
@@ -520,14 +531,13 @@ class NotificationViewMD::NotificationViewMDPathGenerator
const NotificationViewMDPathGenerator&) = delete;
// views::HighlightPathGenerator:
- base::Optional<RoundRect> GetRoundRect(const gfx::RectF& rect) override {
- RoundRect round_rect;
- round_rect.bounds = rect;
+ base::Optional<gfx::RRectF> GetRoundRect(const gfx::RectF& rect) override {
+ gfx::RectF bounds = rect;
if (!preferred_size_.IsEmpty())
- round_rect.bounds.set_size(gfx::SizeF(preferred_size_));
- round_rect.corner_radius = gfx::RoundedCornersF(
- top_radius_, top_radius_, bottom_radius_, bottom_radius_);
- return round_rect;
+ bounds.set_size(gfx::SizeF(preferred_size_));
+ gfx::RoundedCornersF corner_radius(top_radius_, top_radius_, bottom_radius_,
+ bottom_radius_);
+ return gfx::RRectF(bounds, corner_radius);
}
void set_top_radius(int val) { top_radius_ = val; }
@@ -644,6 +654,10 @@ NotificationViewMD::NotificationViewMD(const Notification& notification)
views::HighlightPathGenerator::Install(this,
std::move(highlight_path_generator));
+ DCHECK(focus_ring());
+ focus_ring()->SetPathGenerator(
+ std::make_unique<MessageView::HighlightPathGenerator>());
+
UpdateCornerRadius(kNotificationCornerRadius, kNotificationCornerRadius);
}
@@ -853,7 +867,6 @@ void NotificationViewMD::CreateOrUpdateContextTitleView(
header_row_->SetAccentColor(notification.accent_color() == SK_ColorTRANSPARENT
? kNotificationDefaultAccentColor
: notification.accent_color());
- header_row_->SetBackgroundColor(kNotificationBackgroundColor);
header_row_->SetTimestamp(notification.timestamp());
header_row_->SetAppNameElideBehavior(gfx::ELIDE_TAIL);
header_row_->SetSummaryText(base::string16());
@@ -897,8 +910,6 @@ void NotificationViewMD::CreateOrUpdateTitleView(
title_view_ = new views::Label(title);
title_view_->SetFontList(font_list);
title_view_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD);
- title_view_->SetEnabledColor(kRegularTextColorMD);
- title_view_->SetBackgroundColor(kNotificationBackgroundColor);
title_view_->SetLineHeight(kLineHeightMD);
// TODO(knollr): multiline should not be required, but we need to set the
// width of |title_view_| (because of crbug.com/682266), which only works in
@@ -930,16 +941,16 @@ void NotificationViewMD::CreateOrUpdateMessageView(
if (!message_view_) {
const gfx::FontList& font_list = GetTextFontList();
- message_view_ = new views::Label(text);
+ message_view_ = left_content_->AddChildViewAt(
+ std::make_unique<views::Label>(text, views::style::CONTEXT_LABEL,
+ views::style::STYLE_DISABLED),
+ left_content_count_);
message_view_->SetFontList(font_list);
message_view_->SetHorizontalAlignment(gfx::ALIGN_TO_HEAD);
- message_view_->SetEnabledColor(kDimTextColorMD);
- message_view_->SetBackgroundColor(kNotificationBackgroundColor);
message_view_->SetLineHeight(kLineHeightMD);
message_view_->SetMultiLine(true);
message_view_->SetMaxLines(kMaxLinesForMessageView);
message_view_->SetAllowCharacterBreak(true);
- left_content_->AddChildViewAt(message_view_, left_content_count_);
} else {
message_view_->SetText(text);
}
@@ -1012,13 +1023,14 @@ void NotificationViewMD::CreateOrUpdateProgressStatusView(
if (!status_view_) {
const gfx::FontList& font_list = GetTextFontList();
- status_view_ = new views::Label();
+ status_view_ = left_content_->AddChildViewAt(
+ std::make_unique<views::Label>(base::string16(),
+ views::style::CONTEXT_LABEL,
+ views::style::STYLE_DISABLED),
+ left_content_count_);
status_view_->SetFontList(font_list);
status_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
- status_view_->SetEnabledColor(kDimTextColorMD);
- status_view_->SetBackgroundColor(kNotificationBackgroundColor);
status_view_->SetBorder(views::CreateEmptyBorder(kStatusTextPadding));
- left_content_->AddChildViewAt(status_view_, left_content_count_);
}
status_view_->SetText(notification.progress_status());
@@ -1106,8 +1118,6 @@ void NotificationViewMD::CreateOrUpdateImageView(
std::make_unique<views::FillLayout>());
image_container_view_->SetBorder(
views::CreateEmptyBorder(kLargeImageContainerPadding));
- image_container_view_->SetBackground(
- views::CreateSolidBackground(kImageBackgroundColor));
image_container_view_->AddChildView(new LargeImageView());
// Insert the created image container just after the |content_row_|.
@@ -1339,9 +1349,6 @@ void NotificationViewMD::ToggleInlineSettings(const ui::Event& event) {
settings_row_->SetVisible(inline_settings_visible);
content_row_->SetVisible(!inline_settings_visible);
header_row_->SetDetailViewsVisible(!inline_settings_visible);
- header_row_->SetBackgroundColor(inline_settings_visible
- ? kInlineSettingsBackgroundColor
- : kNotificationBackgroundColor);
// Always check "Don't block" when inline settings is shown.
// If it's already blocked, users should not see inline settings.
@@ -1379,7 +1386,9 @@ void NotificationViewMD::UpdateCornerRadius(int top_radius, int bottom_radius) {
MessageView::UpdateCornerRadius(top_radius, bottom_radius);
action_buttons_row_->SetBackground(views::CreateBackgroundFromPainter(
std::make_unique<NotificationBackgroundPainter>(
- 0, bottom_radius, kActionsRowBackgroundColor)));
+ 0, bottom_radius,
+ GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_NotificationActionsRowBackground))));
highlight_path_generator_->set_top_radius(top_radius);
highlight_path_generator_->set_bottom_radius(bottom_radius);
}
@@ -1420,6 +1429,15 @@ void NotificationViewMD::OnSettingsButtonPressed(const ui::Event& event) {
MessageView::OnSettingsButtonPressed(event);
}
+void NotificationViewMD::OnThemeChanged() {
+ MessageView::OnThemeChanged();
+ bool inline_settings_visible = settings_row_ && !settings_row_->GetVisible();
+ header_row_->SetBackgroundColor(GetNativeTheme()->GetSystemColor(
+ inline_settings_visible
+ ? ui::NativeTheme::kColorId_NotificationInlineSettingsBackground
+ : ui::NativeTheme::kColorId_NotificationDefaultBackground));
+}
+
void NotificationViewMD::Activate() {
GetWidget()->widget_delegate()->SetCanActivate(true);
GetWidget()->Activate();
@@ -1481,7 +1499,8 @@ std::unique_ptr<views::InkDropMask> NotificationViewMD::CreateInkDropMask()
}
SkColor NotificationViewMD::GetInkDropBaseColor() const {
- return kInlineSettingsBackgroundColor;
+ return GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_NotificationInlineSettingsBackground);
}
void NotificationViewMD::InkDropAnimationStarted() {
diff --git a/chromium/ui/message_center/views/notification_view_md.h b/chromium/ui/message_center/views/notification_view_md.h
index bbc1dc0b2c4..bc0520e7bf5 100644
--- a/chromium/ui/message_center/views/notification_view_md.h
+++ b/chromium/ui/message_center/views/notification_view_md.h
@@ -63,6 +63,7 @@ class LargeImageView : public views::View {
void OnPaint(gfx::Canvas* canvas) override;
const char* GetClassName() const override;
+ void OnThemeChanged() override;
private:
gfx::Size GetResizedImageSize();
@@ -129,6 +130,7 @@ class NotificationInputContainerMD : public views::InkDropHostView,
void RemoveLayerBeneathView(ui::Layer* layer) override;
std::unique_ptr<views::InkDropRipple> CreateInkDropRipple() const override;
SkColor GetInkDropBaseColor() const override;
+ void OnThemeChanged() override;
// Overridden from views::TextfieldController:
bool HandleKeyEvent(views::Textfield* sender,
@@ -142,6 +144,8 @@ class NotificationInputContainerMD : public views::InkDropHostView,
views::ImageButton* button() const { return button_; }
private:
+ void SetButtonImage();
+
NotificationInputDelegate* const delegate_;
views::InkDropContainerView* const ink_drop_container_;
@@ -194,6 +198,7 @@ class MESSAGE_CENTER_EXPORT NotificationViewMD
bool IsManuallyExpandedOrCollapsed() const override;
void SetManuallyExpandedOrCollapsed(bool value) override;
void OnSettingsButtonPressed(const ui::Event& event) override;
+ void OnThemeChanged() override;
// views::InkDropObserver:
void InkDropAnimationStarted() override;
diff --git a/chromium/ui/message_center/views/padded_button.cc b/chromium/ui/message_center/views/padded_button.cc
index fe671f7347a..1ce6a9c42a1 100644
--- a/chromium/ui/message_center/views/padded_button.cc
+++ b/chromium/ui/message_center/views/padded_button.cc
@@ -21,7 +21,6 @@ namespace message_center {
PaddedButton::PaddedButton(views::ButtonListener* listener)
: views::ImageButton(listener) {
SetFocusForPlatform();
- SetBackground(views::CreateSolidBackground(kControlButtonBackgroundColor));
SetBorder(views::CreateEmptyBorder(gfx::Insets(kControlButtonBorderSize)));
set_animate_on_state_change(false);
@@ -39,7 +38,12 @@ std::unique_ptr<views::InkDrop> PaddedButton::CreateInkDrop() {
void PaddedButton::OnThemeChanged() {
ImageButton::OnThemeChanged();
- set_ink_drop_base_color(GetNativeTheme()->GetSystemColor(
+ auto* theme = GetNativeTheme();
+#if defined(OS_CHROMEOS)
+ SetBackground(views::CreateSolidBackground(theme->GetSystemColor(
+ ui::NativeTheme::kColorId_NotificationButtonBackground)));
+#endif
+ set_ink_drop_base_color(theme->GetSystemColor(
ui::NativeTheme::kColorId_PaddedButtonInkDropColor));
}
diff --git a/chromium/ui/native_theme/BUILD.gn b/chromium/ui/native_theme/BUILD.gn
index 148189f1e0d..08bf35542c3 100644
--- a/chromium/ui/native_theme/BUILD.gn
+++ b/chromium/ui/native_theme/BUILD.gn
@@ -128,7 +128,10 @@ jumbo_source_set("test_support") {
}
test("native_theme_unittests") {
- sources = [ "native_theme_unittest.cc" ]
+ sources = [
+ "native_theme_unittest.cc",
+ "themed_vector_icon_unittest.cc",
+ ]
if (use_aura) {
sources += [ "native_theme_aura_unittest.cc" ]
diff --git a/chromium/ui/native_theme/caption_style_win.cc b/chromium/ui/native_theme/caption_style_win.cc
index 8e4d13f9db5..566de5e13a4 100644
--- a/chromium/ui/native_theme/caption_style_win.cc
+++ b/chromium/ui/native_theme/caption_style_win.cc
@@ -9,6 +9,8 @@
#include <string>
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/win/core_winrt_util.h"
#include "base/win/windows_version.h"
#include "skia/ext/skia_utils_win.h"
diff --git a/chromium/ui/native_theme/common_theme.cc b/chromium/ui/native_theme/common_theme.cc
index aac3821e6d9..5820f4ab68b 100644
--- a/chromium/ui/native_theme/common_theme.cc
+++ b/chromium/ui/native_theme/common_theme.cc
@@ -4,8 +4,10 @@
#include "ui/native_theme/common_theme.h"
-#include "base/logging.h"
+#include "base/no_destructor.h"
+#include "base/notreached.h"
#include "base/optional.h"
+#include "build/build_config.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/canvas.h"
@@ -20,6 +22,23 @@ namespace ui {
namespace {
+NativeTheme::SecurityChipColorId GetSecurityChipColorId(
+ NativeTheme::ColorId color_id) {
+ static const base::NoDestructor<
+ base::flat_map<NativeTheme::ColorId, NativeTheme::SecurityChipColorId>>
+ color_id_map({
+ {NativeTheme::kColorId_CustomTabBarSecurityChipDefaultColor,
+ NativeTheme::SecurityChipColorId::DEFAULT},
+ {NativeTheme::kColorId_CustomTabBarSecurityChipSecureColor,
+ NativeTheme::SecurityChipColorId::SECURE},
+ {NativeTheme::kColorId_CustomTabBarSecurityChipWithCertColor,
+ NativeTheme::SecurityChipColorId::SECURE_WITH_CERT},
+ {NativeTheme::kColorId_CustomTabBarSecurityChipDangerousColor,
+ NativeTheme::SecurityChipColorId::DANGEROUS},
+ });
+ return color_id_map->at(color_id);
+}
+
base::Optional<SkColor> GetHighContrastColor(
NativeTheme::ColorId color_id,
NativeTheme::ColorScheme color_scheme) {
@@ -32,6 +51,7 @@ base::Optional<SkColor> GetHighContrastColor(
case NativeTheme::kColorId_TabBottomBorder:
return color_scheme == NativeTheme::ColorScheme::kDark ? SK_ColorWHITE
: SK_ColorBLACK;
+ case NativeTheme::kColorId_ButtonCheckedColor:
case NativeTheme::kColorId_ButtonEnabledColor:
case NativeTheme::kColorId_FocusedBorderColor:
case NativeTheme::kColorId_ProminentButtonColor:
@@ -47,6 +67,7 @@ base::Optional<SkColor> GetDarkSchemeColor(NativeTheme::ColorId color_id) {
switch (color_id) {
// Dialogs
case NativeTheme::kColorId_WindowBackground:
+ case NativeTheme::kColorId_ButtonColor:
case NativeTheme::kColorId_DialogBackground:
case NativeTheme::kColorId_BubbleBackground:
return color_utils::AlphaBlend(SK_ColorWHITE, gfx::kGoogleGrey900, 0.04f);
@@ -66,6 +87,7 @@ base::Optional<SkColor> GetDarkSchemeColor(NativeTheme::ColorId color_id) {
// Button
case NativeTheme::kColorId_ButtonBorderColor:
return gfx::kGoogleGrey800;
+ case NativeTheme::kColorId_ButtonCheckedColor:
case NativeTheme::kColorId_ButtonEnabledColor:
case NativeTheme::kColorId_ProminentButtonColor:
return gfx::kGoogleBlue300;
@@ -109,6 +131,10 @@ base::Optional<SkColor> GetDarkSchemeColor(NativeTheme::ColorId color_id) {
case NativeTheme::kColorId_CustomFrameInactiveColor:
return gfx::kGoogleGrey800;
+ // Custom tab bar
+ case NativeTheme::kColorId_CustomTabBarBackgroundColor:
+ return gfx::kGoogleGrey900;
+
// Dropdown
case NativeTheme::kColorId_DropdownBackgroundColor:
return color_utils::AlphaBlend(SK_ColorWHITE, gfx::kGoogleGrey900, 0.04f);
@@ -185,6 +211,9 @@ base::Optional<SkColor> GetDarkSchemeColor(NativeTheme::ColorId color_id) {
case NativeTheme::kColorId_BubbleBorder:
return gfx::kGoogleGrey800;
+ case NativeTheme::kColorId_FootnoteContainerBorder:
+ return gfx::kGoogleGrey900;
+
// Alert icon colors
case NativeTheme::kColorId_AlertSeverityLow:
return gfx::kGoogleGreen300;
@@ -193,6 +222,7 @@ base::Optional<SkColor> GetDarkSchemeColor(NativeTheme::ColorId color_id) {
case NativeTheme::kColorId_AlertSeverityHigh:
return gfx::kGoogleRed300;
+ case NativeTheme::kColorId_MenuIconColor:
case NativeTheme::kColorId_DefaultIconColor:
return gfx::kGoogleGrey500;
default:
@@ -208,6 +238,7 @@ SkColor GetDefaultColor(NativeTheme::ColorId color_id,
switch (color_id) {
// Dialogs
case NativeTheme::kColorId_WindowBackground:
+ case NativeTheme::kColorId_ButtonColor:
case NativeTheme::kColorId_DialogBackground:
case NativeTheme::kColorId_BubbleBackground:
return SK_ColorWHITE;
@@ -219,6 +250,7 @@ SkColor GetDefaultColor(NativeTheme::ColorId color_id,
return gfx::kGoogleGrey050;
// Buttons
+ case NativeTheme::kColorId_ButtonCheckedColor:
case NativeTheme::kColorId_ButtonEnabledColor:
return gfx::kGoogleBlue600;
case NativeTheme::kColorId_ButtonInkDropShadowColor:
@@ -243,13 +275,11 @@ SkColor GetDefaultColor(NativeTheme::ColorId color_id,
return gfx::kGoogleBlue600;
case NativeTheme::kColorId_TextOnProminentButtonColor:
return SK_ColorWHITE;
- case NativeTheme::kColorId_ButtonPressedShade:
- return SK_ColorTRANSPARENT;
case NativeTheme::kColorId_ButtonUncheckedColor:
return gfx::kGoogleGrey700;
case NativeTheme::kColorId_ButtonDisabledColor: {
const SkColor bg = base_theme->GetSystemColor(
- NativeTheme::kColorId_DialogBackground, color_scheme);
+ NativeTheme::kColorId_ButtonColor, color_scheme);
const SkColor fg = base_theme->GetSystemColor(
NativeTheme::kColorId_LabelEnabledColor, color_scheme);
return color_utils::BlendForMinContrast(gfx::kGoogleGrey600, bg, fg)
@@ -257,7 +287,7 @@ SkColor GetDefaultColor(NativeTheme::ColorId color_id,
}
case NativeTheme::kColorId_ProminentButtonDisabledColor: {
const SkColor bg = base_theme->GetSystemColor(
- NativeTheme::kColorId_DialogBackground, color_scheme);
+ NativeTheme::kColorId_ButtonColor, color_scheme);
return color_utils::BlendForMinContrast(bg, bg, base::nullopt, 1.2f)
.color;
}
@@ -324,6 +354,23 @@ SkColor GetDefaultColor(NativeTheme::ColorId color_id,
case NativeTheme::kColorId_CustomFrameInactiveColor:
return SkColorSetRGB(0xE7, 0xEA, 0xED);
+ // Custom tab bar
+ case NativeTheme::kColorId_CustomTabBarBackgroundColor:
+ return SK_ColorWHITE;
+ case NativeTheme::kColorId_CustomTabBarForegroundColor:
+ return color_utils::GetColorWithMaxContrast(base_theme->GetSystemColor(
+ NativeTheme::kColorId_CustomTabBarBackgroundColor, color_scheme));
+ case NativeTheme::kColorId_CustomTabBarSecurityChipWithCertColor:
+ case NativeTheme::kColorId_CustomTabBarSecurityChipSecureColor:
+ case NativeTheme::kColorId_CustomTabBarSecurityChipDefaultColor:
+ case NativeTheme::kColorId_CustomTabBarSecurityChipDangerousColor: {
+ const SkColor fg = base_theme->GetSystemColor(
+ NativeTheme::kColorId_CustomTabBarForegroundColor, color_scheme);
+ const SkColor bg = base_theme->GetSystemColor(
+ NativeTheme::kColorId_CustomTabBarBackgroundColor, color_scheme);
+ return GetSecurityChipColor(GetSecurityChipColorId(color_id), fg, bg);
+ }
+
// Dropdown
case NativeTheme::kColorId_DropdownBackgroundColor:
return SK_ColorWHITE;
@@ -368,6 +415,23 @@ SkColor GetDefaultColor(NativeTheme::ColorId color_id,
case NativeTheme::kColorId_LinkPressed:
return gfx::kGoogleBlue600;
+ // Notification view
+ // TODO(crbug.com/1065604): Add support for dark mode.
+ case NativeTheme::kColorId_NotificationDefaultBackground:
+ case NativeTheme::kColorId_NotificationPlaceholderIconColor:
+ return SK_ColorWHITE;
+ case NativeTheme::kColorId_NotificationActionsRowBackground:
+ case NativeTheme::kColorId_NotificationInlineSettingsBackground:
+ return SkColorSetRGB(0xee, 0xee, 0xee);
+ case NativeTheme::kColorId_NotificationLargeImageBackground:
+ return SkColorSetRGB(0xf5, 0xf5, 0xf5);
+ case NativeTheme::kColorId_NotificationEmptyPlaceholderIconColor:
+ return SkColorSetA(SK_ColorWHITE, 0x60);
+#if defined(OS_CHROMEOS)
+ case NativeTheme::kColorId_NotificationButtonBackground:
+ return SkColorSetA(SK_ColorWHITE, 0.9 * 0xff);
+#endif
+
// Scrollbar
case NativeTheme::kColorId_OverlayScrollbarThumbBackground:
return SK_ColorBLACK;
@@ -503,6 +567,10 @@ SkColor GetDefaultColor(NativeTheme::ColorId color_id,
case NativeTheme::kColorId_AlertSeverityHigh:
return gfx::kGoogleRed600;
+ case NativeTheme::kColorId_FootnoteContainerBorder:
+ return gfx::kGoogleGrey200;
+
+ case NativeTheme::kColorId_MenuIconColor:
case NativeTheme::kColorId_DefaultIconColor:
return gfx::kGoogleGrey700;
@@ -533,6 +601,39 @@ SkColor GetDefaultColor(NativeTheme::ColorId color_id,
} // namespace
+SkColor GetSecurityChipColor(NativeTheme::SecurityChipColorId chip_color_id,
+ SkColor fg,
+ SkColor bg,
+ bool high_contrast) {
+ const bool dark = color_utils::IsDark(bg);
+ const auto blend_for_min_contrast = [&](SkColor fg, SkColor bg,
+ base::Optional<SkColor> hc_fg =
+ base::nullopt) {
+ const float ratio =
+ high_contrast ? 6.0f : color_utils::kMinimumReadableContrastRatio;
+ return color_utils::BlendForMinContrast(fg, bg, hc_fg, ratio).color;
+ };
+ const auto security_chip_color = [&](SkColor color) {
+ return blend_for_min_contrast(color, bg);
+ };
+
+ switch (chip_color_id) {
+ case NativeTheme::SecurityChipColorId::DEFAULT:
+ case NativeTheme::SecurityChipColorId::SECURE:
+ return dark
+ ? color_utils::BlendTowardMaxContrast(fg, 0x18)
+ : security_chip_color(color_utils::DeriveDefaultIconColor(fg));
+ case NativeTheme::SecurityChipColorId::DANGEROUS:
+ return dark ? color_utils::BlendTowardMaxContrast(fg, 0x18)
+ : security_chip_color(gfx::kGoogleRed600);
+ case NativeTheme::SecurityChipColorId::SECURE_WITH_CERT:
+ return blend_for_min_contrast(fg, fg, blend_for_min_contrast(bg, bg));
+ default:
+ NOTREACHED();
+ return gfx::kPlaceholderColor;
+ }
+}
+
SkColor GetAuraColor(NativeTheme::ColorId color_id,
const NativeTheme* base_theme,
NativeTheme::ColorScheme color_scheme) {
diff --git a/chromium/ui/native_theme/common_theme.h b/chromium/ui/native_theme/common_theme.h
index 1d275078189..4c87d30f366 100644
--- a/chromium/ui/native_theme/common_theme.h
+++ b/chromium/ui/native_theme/common_theme.h
@@ -14,6 +14,14 @@ namespace ui {
// Drawing code that is common for all platforms.
+// Takes a SecurityChipColorId and |fg| and |bg| colors so that the security
+// chip color implementation can be shared outside of NativeTheme.
+SkColor NATIVE_THEME_EXPORT
+GetSecurityChipColor(NativeTheme::SecurityChipColorId chip_color_id,
+ SkColor fg,
+ SkColor bg,
+ bool high_contrast = false);
+
// Returns the color to use on Aura for |color_id|. For a few colors that are
// theme-specific, |base_theme| must be non-null; consult the code to see which
// color IDs fall into this category.
diff --git a/chromium/ui/native_theme/native_theme.cc b/chromium/ui/native_theme/native_theme.cc
index 2d4ec42b5c1..1d9716fc421 100644
--- a/chromium/ui/native_theme/native_theme.cc
+++ b/chromium/ui/native_theme/native_theme.cc
@@ -27,120 +27,127 @@
namespace ui {
namespace {
-
+// clang-format off
const base::flat_map<NativeTheme::ColorId, ColorId>&
NativeThemeColorIdToColorIdMap() {
using NTCID = NativeTheme::ColorId;
static const base::NoDestructor<base::flat_map<NativeTheme::ColorId, ColorId>>
map({
- {NTCID::kColorId_AlertSeverityHigh, kColorAlertHighSeverity},
- {NTCID::kColorId_AlertSeverityLow, kColorAlertLowSeverity},
- {NTCID::kColorId_AlertSeverityMedium, kColorAlertMediumSeverity},
- {NTCID::kColorId_BubbleBackground, kColorBubbleBackground},
- {NTCID::kColorId_BubbleFooterBackground,
- kColorBubbleFooterBackground},
- {NTCID::kColorId_DialogBackground, kColorButtonBackground},
- {NTCID::kColorId_ButtonBorderColor, kColorButtonBorder},
- {NTCID::kColorId_ButtonDisabledColor, kColorButtonDisabledForeground},
- {NTCID::kColorId_ButtonEnabledColor, kColorButtonForeground},
- {NTCID::kColorId_ProminentButtonColor,
- kColorButtonProminentBackground},
- {NTCID::kColorId_ProminentButtonDisabledColor,
- kColorButtonProminentDisabledBackground},
- {NTCID::kColorId_ProminentButtonFocusedColor,
- kColorButtonProminentFocusedBackground},
- {NTCID::kColorId_TextOnProminentButtonColor,
- kColorButtonProminentForeground},
- {NTCID::kColorId_ButtonUncheckedColor,
- kColorButtonUncheckedForeground},
- {NTCID::kColorId_DialogBackground, kColorDialogBackground},
- {NTCID::kColorId_DialogForeground, kColorDialogForeground},
- {NTCID::kColorId_FocusedBorderColor, kColorFocusableBorderFocused},
- {NTCID::kColorId_UnfocusedBorderColor,
- kColorFocusableBorderUnfocused},
- {NTCID::kColorId_DefaultIconColor, kColorIcon},
- {NTCID::kColorId_LabelDisabledColor, kColorLabelDisabledForeground},
- {NTCID::kColorId_LabelEnabledColor, kColorLabelForeground},
- {NTCID::kColorId_LabelSecondaryColor, kColorLabelSecondaryForeground},
- {NTCID::kColorId_LabelTextSelectionBackgroundFocused,
- kColorLabelSelectionBackground},
- {NTCID::kColorId_LabelTextSelectionColor,
- kColorLabelSelectionForeground},
- {NTCID::kColorId_LinkDisabled, kColorLinkDisabledForeground},
- {NTCID::kColorId_LinkEnabled, kColorLinkForeground},
- {NTCID::kColorId_LinkPressed, kColorLinkPressedForeground},
- {NTCID::kColorId_MenuBackgroundColor, kColorMenuBackground},
- {NTCID::kColorId_MenuBorderColor, kColorMenuBorder},
- {NTCID::kColorId_MenuItemInitialAlertBackgroundColor,
- kColorMenuItemBackgroundAlertedInitial},
- {NTCID::kColorId_MenuItemTargetAlertBackgroundColor,
- kColorMenuItemBackgroundAlertedTarget},
- {NTCID::kColorId_DisabledMenuItemForegroundColor,
- kColorMenuItemDisabledForeground},
- {NTCID::kColorId_EnabledMenuItemForegroundColor,
- kColorMenuItemForeground},
- {NTCID::kColorId_HighlightedMenuItemBackgroundColor,
- kColorMenuItemHighlightedBackground},
- {NTCID::kColorId_HighlightedMenuItemForegroundColor,
- kColorMenuItemHighlightedForeground},
- {NTCID::kColorId_MenuItemMinorTextColor,
- kColorMenuItemSecondaryForeground},
- {NTCID::kColorId_FocusedMenuItemBackgroundColor,
- kColorMenuItemSelectedBackground},
- {NTCID::kColorId_SelectedMenuItemForegroundColor,
- kColorMenuItemSelectedForeground},
- {NTCID::kColorId_MenuSeparatorColor, kColorMenuSeparator},
- {NTCID::kColorId_TabBottomBorder, kColorTabContentSeparator},
- {NTCID::kColorId_TabTitleColorInactive, kColorTabForeground},
- {NTCID::kColorId_TabTitleColorActive, kColorTabSelectedForeground},
- {NTCID::kColorId_TableBackground, kColorTableBackground},
- // TODO(http://crbug.com/1057754): kColorId_TableBackgroundAlternate,
- // which is not needed on platforms other than Mac..
- {NTCID::kColorId_TableText, kColorTableForeground},
- {NTCID::kColorId_TableGroupingIndicatorColor,
- kColorTableGroupingIndicator},
- {NTCID::kColorId_TableHeaderBackground, kColorTableHeaderBackground},
- {NTCID::kColorId_TableHeaderText, kColorTableHeaderForeground},
- // TODO(http://crbug.com/1057754): kColorId_TableHeaderSeparator,
- // which is implemented as a native theme override on Mac.
- {NTCID::kColorId_TableSelectionBackgroundFocused,
- kColorTableSelectedFocusedBackground},
- {NTCID::kColorId_TableSelectedText,
- kColorTableSelectedFocusedForeground},
- {NTCID::kColorId_TableSelectionBackgroundUnfocused,
- kColorTableSelectedUnfocusedBackground},
- {NTCID::kColorId_TableSelectedTextUnfocused,
- kColorTableSelectedUnfocusedForeground},
- {NTCID::kColorId_TextfieldDefaultBackground,
- kColorTextfieldBackground},
- {NTCID::kColorId_TextfieldReadOnlyBackground,
- kColorTextfieldDisabledBackground},
- {NTCID::kColorId_TextfieldReadOnlyColor,
- kColorTextfieldDisabledForeground},
- {NTCID::kColorId_TextfieldPlaceholderColor,
- kColorTextfieldPlaceholderForeground},
- {NTCID::kColorId_TextfieldDefaultColor, kColorTextfieldForeground},
- {NTCID::kColorId_TextfieldSelectionBackgroundFocused,
- kColorTextfieldSelectionBackground},
- {NTCID::kColorId_TextfieldSelectionColor,
- kColorTextfieldSelectionForeground},
- {NTCID::kColorId_ThrobberSpinningColor, kColorThrobber},
- {NTCID::kColorId_TooltipBackground, kColorTooltipBackground},
- {NTCID::kColorId_TooltipText, kColorTooltipForeground},
- {NTCID::kColorId_TreeBackground, kColorTreeBackground},
- {NTCID::kColorId_TreeText, kColorTreeNodeForeground},
- {NTCID::kColorId_TreeSelectionBackgroundFocused,
- kColorTreeNodeSelectedFocusedBackground},
- {NTCID::kColorId_TreeSelectedText,
- kColorTreeNodeSelectedFocusedForeground},
- {NTCID::kColorId_TreeSelectionBackgroundUnfocused,
- kColorTreeNodeSelectedUnfocusedBackground},
- {NTCID::kColorId_TreeSelectedTextUnfocused,
- kColorTreeNodeSelectedUnfocusedForeground},
- {NTCID::kColorId_WindowBackground, kColorWindowBackground},
+ {NTCID::kColorId_AlertSeverityHigh, kColorAlertHighSeverity},
+ {NTCID::kColorId_AlertSeverityLow, kColorAlertLowSeverity},
+ {NTCID::kColorId_AlertSeverityMedium, kColorAlertMediumSeverity},
+ {NTCID::kColorId_BubbleBackground, kColorBubbleBackground},
+ {NTCID::kColorId_BubbleFooterBackground,
+ kColorBubbleFooterBackground},
+ {NTCID::kColorId_ButtonColor, kColorButtonBackground},
+ {NTCID::kColorId_ButtonBorderColor, kColorButtonBorder},
+ {NTCID::kColorId_ButtonDisabledColor,
+ kColorButtonDisabledForeground},
+ {NTCID::kColorId_ButtonEnabledColor, kColorButtonForeground},
+ {NTCID::kColorId_ProminentButtonColor,
+ kColorButtonProminentBackground},
+ {NTCID::kColorId_ProminentButtonDisabledColor,
+ kColorButtonProminentDisabledBackground},
+ {NTCID::kColorId_ProminentButtonFocusedColor,
+ kColorButtonProminentFocusedBackground},
+ {NTCID::kColorId_TextOnProminentButtonColor,
+ kColorButtonProminentForeground},
+ {NTCID::kColorId_ButtonUncheckedColor,
+ kColorButtonUncheckedForeground},
+ {NTCID::kColorId_DialogBackground, kColorDialogBackground},
+ {NTCID::kColorId_DialogForeground, kColorDialogForeground},
+ {NTCID::kColorId_FocusedBorderColor, kColorFocusableBorderFocused},
+ {NTCID::kColorId_UnfocusedBorderColor,
+ kColorFocusableBorderUnfocused},
+ {NTCID::kColorId_MenuIconColor, kColorMenuIcon},
+ {NTCID::kColorId_DefaultIconColor, kColorIcon},
+ {NTCID::kColorId_LabelDisabledColor, kColorLabelDisabledForeground},
+ {NTCID::kColorId_LabelEnabledColor, kColorLabelForeground},
+ {NTCID::kColorId_LabelSecondaryColor,
+ kColorLabelSecondaryForeground},
+ {NTCID::kColorId_LabelTextSelectionBackgroundFocused,
+ kColorLabelSelectionBackground},
+ {NTCID::kColorId_LabelTextSelectionColor,
+ kColorLabelSelectionForeground},
+ {NTCID::kColorId_LinkDisabled, kColorLinkDisabledForeground},
+ {NTCID::kColorId_LinkEnabled, kColorLinkForeground},
+ {NTCID::kColorId_LinkPressed, kColorLinkPressedForeground},
+ {NTCID::kColorId_MenuBackgroundColor, kColorMenuBackground},
+ {NTCID::kColorId_MenuBorderColor, kColorMenuBorder},
+ {NTCID::kColorId_MenuItemInitialAlertBackgroundColor,
+ kColorMenuItemBackgroundAlertedInitial},
+ {NTCID::kColorId_MenuItemTargetAlertBackgroundColor,
+ kColorMenuItemBackgroundAlertedTarget},
+ {NTCID::kColorId_DisabledMenuItemForegroundColor,
+ kColorMenuItemDisabledForeground},
+ {NTCID::kColorId_EnabledMenuItemForegroundColor,
+ kColorMenuItemForeground},
+ {NTCID::kColorId_HighlightedMenuItemBackgroundColor,
+ kColorMenuItemHighlightedBackground},
+ {NTCID::kColorId_HighlightedMenuItemForegroundColor,
+ kColorMenuItemHighlightedForeground},
+ {NTCID::kColorId_MenuItemMinorTextColor,
+ kColorMenuItemSecondaryForeground},
+ {NTCID::kColorId_FocusedMenuItemBackgroundColor,
+ kColorMenuItemSelectedBackground},
+ {NTCID::kColorId_SelectedMenuItemForegroundColor,
+ kColorMenuItemSelectedForeground},
+ {NTCID::kColorId_MenuSeparatorColor, kColorMenuSeparator},
+ {NTCID::kColorId_TabBottomBorder, kColorTabContentSeparator},
+ {NTCID::kColorId_TabTitleColorInactive, kColorTabForeground},
+ {NTCID::kColorId_TabTitleColorActive, kColorTabSelectedForeground},
+ {NTCID::kColorId_TableBackground, kColorTableBackground},
+#if defined(OS_MACOSX)
+ {NTCID::kColorId_TableBackgroundAlternate,
+ kColorTableBackgroundAlternate},
+#endif
+ {NTCID::kColorId_TableText, kColorTableForeground},
+ {NTCID::kColorId_TableGroupingIndicatorColor,
+ kColorTableGroupingIndicator},
+ {NTCID::kColorId_TableHeaderBackground,
+ kColorTableHeaderBackground},
+ {NTCID::kColorId_TableHeaderText, kColorTableHeaderForeground},
+ // TODO(http://crbug.com/1057754): kColorId_TableHeaderSeparator,
+ // which is implemented as a native theme override on Mac.
+ {NTCID::kColorId_TableSelectionBackgroundFocused,
+ kColorTableSelectedFocusedBackground},
+ {NTCID::kColorId_TableSelectedText,
+ kColorTableSelectedFocusedForeground},
+ {NTCID::kColorId_TableSelectionBackgroundUnfocused,
+ kColorTableSelectedUnfocusedBackground},
+ {NTCID::kColorId_TableSelectedTextUnfocused,
+ kColorTableSelectedUnfocusedForeground},
+ {NTCID::kColorId_TextfieldDefaultBackground,
+ kColorTextfieldBackground},
+ {NTCID::kColorId_TextfieldReadOnlyBackground,
+ kColorTextfieldDisabledBackground},
+ {NTCID::kColorId_TextfieldReadOnlyColor,
+ kColorTextfieldDisabledForeground},
+ {NTCID::kColorId_TextfieldPlaceholderColor,
+ kColorTextfieldPlaceholderForeground},
+ {NTCID::kColorId_TextfieldDefaultColor, kColorTextfieldForeground},
+ {NTCID::kColorId_TextfieldSelectionBackgroundFocused,
+ kColorTextfieldSelectionBackground},
+ {NTCID::kColorId_TextfieldSelectionColor,
+ kColorTextfieldSelectionForeground},
+ {NTCID::kColorId_ThrobberSpinningColor, kColorThrobber},
+ {NTCID::kColorId_TooltipBackground, kColorTooltipBackground},
+ {NTCID::kColorId_TooltipText, kColorTooltipForeground},
+ {NTCID::kColorId_TreeBackground, kColorTreeBackground},
+ {NTCID::kColorId_TreeText, kColorTreeNodeForeground},
+ {NTCID::kColorId_TreeSelectionBackgroundFocused,
+ kColorTreeNodeSelectedFocusedBackground},
+ {NTCID::kColorId_TreeSelectedText,
+ kColorTreeNodeSelectedFocusedForeground},
+ {NTCID::kColorId_TreeSelectionBackgroundUnfocused,
+ kColorTreeNodeSelectedUnfocusedBackground},
+ {NTCID::kColorId_TreeSelectedTextUnfocused,
+ kColorTreeNodeSelectedUnfocusedForeground},
+ {NTCID::kColorId_WindowBackground, kColorWindowBackground},
});
return *map;
}
+// clang-format on
void ReportHistogramBooleanUsesColorProvider(bool uses_color_provider) {
UMA_HISTOGRAM_BOOLEAN("NativeTheme.GetSystemColor.UsesColorProvider",
@@ -190,6 +197,10 @@ SkColor NativeTheme::GetSystemColor(ColorId color_id,
return GetAuraColor(color_id, this, color_scheme);
}
+SkColor NativeTheme::GetSystemButtonPressedColor(SkColor base_color) const {
+ return base_color;
+}
+
float NativeTheme::GetBorderRadiusForPart(Part part,
float width,
float height,
@@ -220,10 +231,12 @@ NativeTheme::NativeTheme(bool should_use_dark_colors)
ColorProviderManager::Get().SetColorProviderInitializer(base::BindRepeating(
[](ColorProvider* provider, ColorProviderManager::ColorMode color_mode,
ColorProviderManager::ContrastMode contrast_mode) {
- ui::AddCoreDefaultColorMixers(
- provider, color_mode == ColorProviderManager::ColorMode::kDark);
- ui::AddNativeColorMixers(provider);
- ui::AddUiColorMixers(provider);
+ const bool is_dark_color_mode =
+ color_mode == ColorProviderManager::ColorMode::kDark;
+ ui::AddCoreDefaultColorMixer(provider, is_dark_color_mode);
+ ui::AddNativeCoreColorMixer(provider, is_dark_color_mode);
+ ui::AddUiColorMixer(provider);
+ ui::AddNativeUiColorMixer(provider, is_dark_color_mode);
}));
});
if (!color_provider_manager_init.is_null())
diff --git a/chromium/ui/native_theme/native_theme.h b/chromium/ui/native_theme/native_theme.h
index 8c60a3f7ba7..82751ea52da 100644
--- a/chromium/ui/native_theme/native_theme.h
+++ b/chromium/ui/native_theme/native_theme.h
@@ -137,6 +137,14 @@ class NATIVE_THEME_EXPORT NativeTheme {
// Win)
};
+ // This enum represents the available unique security chip color states.
+ enum class SecurityChipColorId {
+ DEFAULT,
+ SECURE,
+ SECURE_WITH_CERT,
+ DANGEROUS,
+ };
+
// Each structure below holds extra information needed when painting a given
// part.
@@ -437,6 +445,10 @@ class NATIVE_THEME_EXPORT NativeTheme {
bool is_high_contrast,
const base::flat_map<SystemThemeColor, uint32_t>& colors);
+ // On certain platforms, currently only Mac, there is a unique visual for
+ // pressed states.
+ virtual SkColor GetSystemButtonPressedColor(SkColor base_color) const;
+
protected:
explicit NativeTheme(bool should_only_use_dark_colors);
virtual ~NativeTheme();
diff --git a/chromium/ui/native_theme/native_theme_android.cc b/chromium/ui/native_theme/native_theme_android.cc
index 1a33a8f3496..509c9d274ae 100644
--- a/chromium/ui/native_theme/native_theme_android.cc
+++ b/chromium/ui/native_theme/native_theme_android.cc
@@ -4,7 +4,7 @@
#include "ui/native_theme/native_theme_android.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "ui/gfx/geometry/size.h"
namespace ui {
diff --git a/chromium/ui/native_theme/native_theme_aura.cc b/chromium/ui/native_theme/native_theme_aura.cc
index 81df28dd82a..c9f858e69e7 100644
--- a/chromium/ui/native_theme/native_theme_aura.cc
+++ b/chromium/ui/native_theme/native_theme_aura.cc
@@ -7,7 +7,8 @@
#include <limits>
#include <utility>
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "cc/paint/paint_canvas.h"
@@ -144,7 +145,9 @@ void NativeThemeAura::PaintArrowButton(
State state,
ColorScheme color_scheme,
const ScrollbarArrowExtraParams& arrow) const {
- SkColor bg_color = kTrackColor;
+ SkColor bg_color = color_scheme == ui::NativeTheme::ColorScheme::kDark
+ ? SkColorSetRGB(0x42, 0x42, 0x42)
+ : kTrackColor;
// Aura-win uses slightly different arrow colors.
SkColor arrow_color = gfx::kPlaceholderColor;
switch (state) {
@@ -152,14 +155,22 @@ void NativeThemeAura::PaintArrowButton(
arrow_color = GetArrowColor(state, color_scheme);
break;
case kHovered:
- bg_color = SkColorSetRGB(0xD2, 0xD2, 0xD2);
+ bg_color = color_scheme == ui::NativeTheme::ColorScheme::kDark
+ ? SkColorSetRGB(0x4F, 0x4F, 0x4F)
+ : SkColorSetRGB(0xD2, 0xD2, 0xD2);
FALLTHROUGH;
case kNormal:
- arrow_color = SkColorSetRGB(0x50, 0x50, 0x50);
+ arrow_color = color_scheme == ui::NativeTheme::ColorScheme::kDark
+ ? SK_ColorWHITE
+ : SkColorSetRGB(0x50, 0x50, 0x50);
break;
case kPressed:
- bg_color = SkColorSetRGB(0x78, 0x78, 0x78);
- arrow_color = SK_ColorWHITE;
+ bg_color = color_scheme == ui::NativeTheme::ColorScheme::kDark
+ ? SkColorSetRGB(0xB1, 0xB1, 0xB1)
+ : SkColorSetRGB(0x78, 0x78, 0x78);
+ arrow_color = color_scheme == ui::NativeTheme::ColorScheme::kDark
+ ? SK_ColorBLACK
+ : SK_ColorWHITE;
break;
case kNumStates:
break;
@@ -209,7 +220,10 @@ void NativeThemeAura::PaintScrollbarTrack(
// Overlay Scrollbar should never paint a scrollbar track.
DCHECK(!use_overlay_scrollbars_);
cc::PaintFlags flags;
- flags.setColor(kTrackColor);
+ SkColor track_color = color_scheme == ui::NativeTheme::ColorScheme::kDark
+ ? SkColorSetRGB(0x42, 0x42, 0x42)
+ : kTrackColor;
+ flags.setColor(track_color);
canvas->drawIRect(gfx::RectToSkIRect(rect), flags);
}
@@ -313,7 +327,9 @@ void NativeThemeAura::PaintScrollbarThumb(cc::PaintCanvas* canvas,
else
thumb_rect.Inset(extra_padding, kThumbPadding);
- thumb_color = SK_ColorBLACK;
+ thumb_color = color_scheme == ui::NativeTheme::ColorScheme::kDark
+ ? SK_ColorWHITE
+ : SK_ColorBLACK;
}
cc::PaintFlags flags;
diff --git a/chromium/ui/native_theme/native_theme_base.cc b/chromium/ui/native_theme/native_theme_base.cc
index 48f78064bb7..d13499976b8 100644
--- a/chromium/ui/native_theme/native_theme_base.cc
+++ b/chromium/ui/native_theme/native_theme_base.cc
@@ -7,8 +7,9 @@
#include <limits>
#include <memory>
+#include "base/check.h"
#include "base/command_line.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/numerics/ranges.h"
#include "build/build_config.h"
#include "cc/paint/paint_flags.h"
@@ -43,7 +44,7 @@ const int kSliderThumbHeight = 21;
constexpr SkColor kThumbActiveColor[2] = {SkColorSetRGB(0xF4, 0xF4, 0xF4),
gfx::kPlaceholderColor};
constexpr SkColor kThumbInactiveColor[2] = {SkColorSetRGB(0xEA, 0xEA, 0xEA),
- gfx::kPlaceholderColor};
+ SK_ColorWHITE};
constexpr SkColor kTrackColor[2] = {SkColorSetRGB(0xD3, 0xD3, 0xD3),
gfx::kPlaceholderColor};
constexpr SkColor kSliderTrackBackgroundColor[2] = {
diff --git a/chromium/ui/native_theme/native_theme_color_id.h b/chromium/ui/native_theme/native_theme_color_id.h
index 0fddcbf08d0..9b3d8039bc2 100644
--- a/chromium/ui/native_theme/native_theme_color_id.h
+++ b/chromium/ui/native_theme/native_theme_color_id.h
@@ -7,7 +7,7 @@
// Clang format mangles sectioned lists like the below badly.
// clang-format off
-#define NATIVE_THEME_COLOR_IDS \
+#define NATIVE_THEME_CROSS_PLATFORM_COLOR_IDS \
/* Windows */ \
OP(kColorId_WindowBackground), \
/* Dialogs */ \
@@ -20,14 +20,15 @@
OP(kColorId_FocusedBorderColor), \
OP(kColorId_UnfocusedBorderColor), \
/* Button */ \
+ OP(kColorId_ButtonColor), \
OP(kColorId_ButtonBorderColor), \
+ OP(kColorId_ButtonCheckedColor), \
+ OP(kColorId_ButtonUncheckedColor), \
OP(kColorId_ButtonEnabledColor), \
OP(kColorId_ButtonDisabledColor), \
OP(kColorId_ButtonHoverColor), \
OP(kColorId_ButtonInkDropFillColor), \
OP(kColorId_ButtonInkDropShadowColor), \
- OP(kColorId_ButtonPressedShade), \
- OP(kColorId_ButtonUncheckedColor), \
OP(kColorId_ProminentButtonColor), \
OP(kColorId_ProminentButtonDisabledColor), \
OP(kColorId_ProminentButtonFocusedColor), \
@@ -50,6 +51,8 @@
OP(kColorId_MenuSeparatorColor), \
OP(kColorId_MenuBackgroundColor), \
OP(kColorId_MenuBorderColor), \
+ /* Colors for icons displayed in a menu context. */ \
+ OP(kColorId_MenuIconColor), \
OP(kColorId_HighlightedMenuItemBackgroundColor), \
OP(kColorId_HighlightedMenuItemForegroundColor), \
OP(kColorId_MenuItemInitialAlertBackgroundColor), \
@@ -57,6 +60,13 @@
/* Custom frame view */ \
OP(kColorId_CustomFrameActiveColor), \
OP(kColorId_CustomFrameInactiveColor), \
+ /* Custom tab bar */ \
+ OP(kColorId_CustomTabBarBackgroundColor), \
+ OP(kColorId_CustomTabBarForegroundColor), \
+ OP(kColorId_CustomTabBarSecurityChipDangerousColor), \
+ OP(kColorId_CustomTabBarSecurityChipDefaultColor), \
+ OP(kColorId_CustomTabBarSecurityChipSecureColor), \
+ OP(kColorId_CustomTabBarSecurityChipWithCertColor), \
/* Dropdown */ \
OP(kColorId_DropdownBackgroundColor), \
OP(kColorId_DropdownForegroundColor), \
@@ -74,6 +84,13 @@
OP(kColorId_LinkPressed), \
OP(kColorId_OverlayScrollbarThumbBackground), \
OP(kColorId_OverlayScrollbarThumbForeground), \
+ /* Notification view */ \
+ OP(kColorId_NotificationDefaultBackground), \
+ OP(kColorId_NotificationActionsRowBackground), \
+ OP(kColorId_NotificationInlineSettingsBackground), \
+ OP(kColorId_NotificationLargeImageBackground), \
+ OP(kColorId_NotificationPlaceholderIconColor), \
+ OP(kColorId_NotificationEmptyPlaceholderIconColor), \
/* Slider */ \
OP(kColorId_SliderThumbDefault), \
OP(kColorId_SliderTroughDefault), \
@@ -130,13 +147,29 @@
OP(kColorId_ThrobberLightColor), \
/* Colors for Bubble Border */ \
OP(kColorId_BubbleBorder), \
+ /* Colors for Footnote Container. */ \
+ OP(kColorId_FootnoteContainerBorder), \
/* Colors for icons that alert, e.g. upgrade reminders. */ \
OP(kColorId_AlertSeverityLow), \
OP(kColorId_AlertSeverityMedium), \
OP(kColorId_AlertSeverityHigh), \
- /* Colors for icons in secondary UI (content settings, help button, etc). */ \
+ /* Colors for icons in non-menu contexts. */ \
OP(kColorId_DefaultIconColor)
+#if defined(OS_CHROMEOS)
+#define NATIVE_THEME_CHROMEOS_COLOR_IDS \
+ /* Notification view */ \
+ OP(kColorId_NotificationButtonBackground)
+#endif
+
+#if defined(OS_CHROMEOS)
+#define NATIVE_THEME_COLOR_IDS \
+ NATIVE_THEME_CROSS_PLATFORM_COLOR_IDS, \
+ NATIVE_THEME_CHROMEOS_COLOR_IDS
+#else
+#define NATIVE_THEME_COLOR_IDS NATIVE_THEME_CROSS_PLATFORM_COLOR_IDS
+#endif
+
// clang-format on
#endif // UI_NATIVE_THEME_NATIVE_THEME_COLOR_ID_H_
diff --git a/chromium/ui/native_theme/native_theme_features.cc b/chromium/ui/native_theme/native_theme_features.cc
index 22d088ac330..8457e0fef09 100644
--- a/chromium/ui/native_theme/native_theme_features.cc
+++ b/chromium/ui/native_theme/native_theme_features.cc
@@ -4,9 +4,11 @@
#include "ui/native_theme/native_theme_features.h"
+#include "build/build_config.h"
+
namespace features {
-#if defined(OS_ANDROID) || defined(OS_CHROMEOS)
+#if defined(OS_ANDROID) || defined(OS_CHROMEOS) || defined(OS_FUCHSIA)
constexpr base::FeatureState kOverlayScrollbarFeatureState =
base::FEATURE_ENABLED_BY_DEFAULT;
#else
diff --git a/chromium/ui/native_theme/native_theme_mac.h b/chromium/ui/native_theme/native_theme_mac.h
index d3ed73693cb..4804b26ba82 100644
--- a/chromium/ui/native_theme/native_theme_mac.h
+++ b/chromium/ui/native_theme/native_theme_mac.h
@@ -40,6 +40,9 @@ class NATIVE_THEME_EXPORT NativeThemeMac : public NativeThemeBase {
SkColor GetSystemColor(ColorId color_id,
ColorScheme color_scheme) const override;
+ // Overridden from NativeTheme:
+ SkColor GetSystemButtonPressedColor(SkColor base_color) const override;
+
// Overridden from NativeThemeBase:
void PaintMenuPopupBackground(
cc::PaintCanvas* canvas,
@@ -82,6 +85,12 @@ class NATIVE_THEME_EXPORT NativeThemeMac : public NativeThemeBase {
void ConfigureWebInstance() override;
+ // Used by the GetSystem to run the switch for MacOS override colors that may
+ // use named NS system colors. This is a separate function from GetSystemColor
+ // to make sure the NSAppearance can be set in a scoped way.
+ base::Optional<SkColor> GetOSColor(ColorId color_id,
+ ColorScheme color_scheme) const;
+
base::scoped_nsobject<NativeThemeEffectiveAppearanceObserver>
appearance_observer_;
id high_contrast_notification_token_;
@@ -91,6 +100,8 @@ class NATIVE_THEME_EXPORT NativeThemeMac : public NativeThemeBase {
std::unique_ptr<NativeTheme::ColorSchemeNativeThemeObserver>
color_scheme_observer_;
+ bool should_only_use_dark_colors_;
+
DISALLOW_COPY_AND_ASSIGN(NativeThemeMac);
};
diff --git a/chromium/ui/native_theme/native_theme_mac.mm b/chromium/ui/native_theme/native_theme_mac.mm
index 92cbb499e69..fc84f17cd4d 100644
--- a/chromium/ui/native_theme/native_theme_mac.mm
+++ b/chromium/ui/native_theme/native_theme_mac.mm
@@ -14,7 +14,9 @@
#import "skia/ext/skia_utils_mac.h"
#include "ui/base/ui_base_features.h"
#include "ui/base/ui_base_switches.h"
+#include "ui/color/mac/scoped_current_nsappearance.h"
#include "ui/gfx/color_palette.h"
+#include "ui/gfx/color_utils.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/skia_util.h"
#include "ui/native_theme/common_theme.h"
@@ -96,45 +98,6 @@ struct EnumArray {
VALUE array[static_cast<size_t>(KEY::COUNT)];
};
-// NSColor has a number of methods that return system colors (i.e. controlled by
-// user preferences). This function converts the color given by an NSColor class
-// method to an SkColor. Official documentation suggests developers only rely on
-// +[NSColor selectedTextBackgroundColor] and +[NSColor selectedControlColor],
-// but other colors give a good baseline. For many, a gradient is involved; the
-// palette chosen based on the enum value given by +[NSColor currentColorTint].
-// Apple's documentation also suggests to use NSColorList, but the system color
-// list is just populated with class methods on NSColor.
-SkColor NSSystemColorToSkColor(NSColor* color) {
- // System colors use the an NSNamedColorSpace called "System", so first step
- // is to convert the color into something that can be worked with.
- NSColor* device_color =
- [color colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]];
- if (device_color)
- return skia::NSDeviceColorToSkColor(device_color);
-
- // Sometimes the conversion is not possible, but we can get an approximation
- // by going through a CGColorRef. Note that simply using NSColor methods for
- // accessing components for system colors results in exceptions like
- // "-numberOfComponents not valid for the NSColor NSNamedColorSpace System
- // windowBackgroundColor; need to first convert colorspace." Hence the
- // conversion first to CGColor.
- CGColorRef cg_color = [color CGColor];
- const size_t component_count = CGColorGetNumberOfComponents(cg_color);
- if (component_count == 4)
- return skia::CGColorRefToSkColor(cg_color);
-
- CHECK(component_count == 1 || component_count == 2);
- // 1-2 components means a grayscale channel and maybe an alpha channel, which
- // CGColorRefToSkColor will not like. But RGB is additive, so the conversion
- // is easy (RGB to grayscale is less easy).
- const CGFloat* components = CGColorGetComponents(cg_color);
- CGFloat alpha = component_count == 2 ? components[1] : 1.0;
- return SkColorSetARGB(SkScalarRoundToInt(255.0 * alpha),
- SkScalarRoundToInt(255.0 * components[0]),
- SkScalarRoundToInt(255.0 * components[0]),
- SkScalarRoundToInt(255.0 * components[0]));
-}
-
// Converts an SkColor to grayscale by using luminance for all three components.
// Experimentally, this seems to produce a better result than a flat average or
// a min/max average for UI controls.
@@ -193,19 +156,19 @@ SkColor NativeThemeMac::GetSystemColor(ColorId color_id,
if (color_scheme == ColorScheme::kDefault)
color_scheme = GetDefaultSystemColorScheme();
- if ((color_scheme == ColorScheme::kDark) != IsDarkMode())
+ // The first check makes sure that when we are using the color providers that
+ // we actually go to the providers instead of just returning the colors
+ // below. The second check is to make sure that when not using color
+ // providers, we only skip the rest of the method when we are in an incognito
+ // window.
+ // TODO(http://crbug.com/1057754): Remove the && kPlatformHighContrast
+ // once NativeTheme.cc handles kColorProviderReirection and
+ // kPlatformHighContrast both being on.
+ if ((base::FeatureList::IsEnabled(features::kColorProviderRedirection) &&
+ color_scheme != ColorScheme::kPlatformHighContrast) ||
+ should_only_use_dark_colors_)
return NativeTheme::GetSystemColor(color_id, color_scheme);
- // Empirically, currentAppearance is incorrect when switching
- // appearances. It's unclear exactly why right now, so work
- // around it for the time being by resynchronizing.
- if (@available(macOS 10.14, *)) {
- NSAppearance* effective_appearance = [NSApp effectiveAppearance];
- if (![effective_appearance isEqual:[NSAppearance currentAppearance]]) {
- [NSAppearance setCurrentAppearance:effective_appearance];
- }
- }
-
if (UsesHighContrastColors()) {
switch (color_id) {
case kColorId_SelectedMenuItemForegroundColor:
@@ -218,13 +181,28 @@ SkColor NativeThemeMac::GetSystemColor(ColorId color_id,
break;
}
}
+
+ base::Optional<SkColor> os_color = GetOSColor(color_id, color_scheme);
+ if (os_color.has_value())
+ return os_color.value();
+
+ return ApplySystemControlTint(
+ NativeTheme::GetSystemColor(color_id, color_scheme));
+}
+
+base::Optional<SkColor> NativeThemeMac::GetOSColor(
+ ColorId color_id,
+ ColorScheme color_scheme) const {
+ ScopedCurrentNSAppearance scoped_nsappearance(color_scheme ==
+ ColorScheme::kDark);
+
// Even with --secondary-ui-md, menus use the platform colors and styling, and
// Mac has a couple of specific color overrides, documented below.
switch (color_id) {
case kColorId_EnabledMenuItemForegroundColor:
- return NSSystemColorToSkColor([NSColor controlTextColor]);
+ return skia::NSSystemColorToSkColor([NSColor controlTextColor]);
case kColorId_DisabledMenuItemForegroundColor:
- return NSSystemColorToSkColor([NSColor disabledControlTextColor]);
+ return skia::NSSystemColorToSkColor([NSColor disabledControlTextColor]);
case kColorId_MenuSeparatorColor:
return color_scheme == ColorScheme::kDark
? SkColorSetA(gfx::kGoogleGrey800, 0xCC)
@@ -232,38 +210,40 @@ SkColor NativeThemeMac::GetSystemColor(ColorId color_id,
case kColorId_MenuBorderColor:
return SkColorSetA(SK_ColorBLACK, 0x60);
- // Mac has a different "pressed button" styling because it doesn't use
- // ripples.
- case kColorId_ButtonPressedShade:
- return SkColorSetA(SK_ColorBLACK, 0x10);
-
// There's a system setting General > Highlight color which sets the
// background color for text selections. We honor that setting.
// TODO(ellyjones): Listen for NSSystemColorsDidChangeNotification somewhere
// and propagate it to the View hierarchy.
case kColorId_LabelTextSelectionBackgroundFocused:
case kColorId_TextfieldSelectionBackgroundFocused:
- return NSSystemColorToSkColor([NSColor selectedTextBackgroundColor]);
+ return skia::NSSystemColorToSkColor(
+ [NSColor selectedTextBackgroundColor]);
case kColorId_FocusedBorderColor:
return SkColorSetA(
- NSSystemColorToSkColor([NSColor keyboardFocusIndicatorColor]),
+ skia::NSSystemColorToSkColor([NSColor keyboardFocusIndicatorColor]),
0x66);
case kColorId_TableBackgroundAlternate:
if (@available(macOS 10.14, *)) {
- return NSSystemColorToSkColor(
+ return skia::NSSystemColorToSkColor(
NSColor.alternatingContentBackgroundColors[1]);
}
- return NSSystemColorToSkColor(
+ return skia::NSSystemColorToSkColor(
NSColor.controlAlternatingRowBackgroundColors[1]);
default:
- break;
+ return base::nullopt;
}
+}
- return ApplySystemControlTint(
- NativeTheme::GetSystemColor(color_id, color_scheme));
+SkColor NativeThemeMac::GetSystemButtonPressedColor(SkColor base_color) const {
+ // TODO crbug.com/1003612: This should probably be replaced with a color
+ // transform.
+ // Mac has a different "pressed button" styling because it doesn't use
+ // ripples.
+ return color_utils::GetResultingPaintColor(SkColorSetA(SK_ColorBLACK, 0x10),
+ base_color);
}
void NativeThemeMac::PaintMenuPopupBackground(
@@ -301,7 +281,8 @@ void NativeThemeMac::PaintMenuItemBackground(
NativeThemeMac::NativeThemeMac(bool configure_web_instance,
bool should_only_use_dark_colors)
- : NativeThemeBase(should_only_use_dark_colors) {
+ : NativeThemeBase(should_only_use_dark_colors),
+ should_only_use_dark_colors_(should_only_use_dark_colors) {
if (!should_only_use_dark_colors)
InitializeDarkModeStateAndObserver();
diff --git a/chromium/ui/native_theme/native_theme_win.cc b/chromium/ui/native_theme/native_theme_win.cc
index 272b70d7c99..8cc9cdc5eab 100644
--- a/chromium/ui/native_theme/native_theme_win.cc
+++ b/chromium/ui/native_theme/native_theme_win.cc
@@ -11,8 +11,9 @@
#include <vssym32.h>
#include "base/bind.h"
+#include "base/check.h"
#include "base/command_line.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/optional.h"
#include "base/stl_util.h"
#include "base/threading/sequenced_task_runner_handle.h"
@@ -590,12 +591,14 @@ SkColor NativeThemeWin::GetSystemColor(ColorId color_id,
if (color_scheme == ColorScheme::kDefault)
color_scheme = GetDefaultSystemColorScheme();
- return (color_scheme == ColorScheme::kPlatformHighContrast)
- ? GetPlatformHighContrastColor(color_id)
- : NativeTheme::GetSystemColor(color_id, color_scheme);
+ base::Optional<SkColor> color;
+ if (color_scheme == ColorScheme::kPlatformHighContrast)
+ color = GetPlatformHighContrastColor(color_id);
+ return color.value_or(NativeTheme::GetSystemColor(color_id, color_scheme));
}
-SkColor NativeThemeWin::GetPlatformHighContrastColor(ColorId color_id) const {
+base::Optional<SkColor> NativeThemeWin::GetPlatformHighContrastColor(
+ ColorId color_id) const {
switch (color_id) {
// Window Background
case kColorId_WindowBackground:
@@ -605,12 +608,13 @@ SkColor NativeThemeWin::GetPlatformHighContrastColor(ColorId color_id) const {
case kColorId_TreeBackground:
case kColorId_TableHeaderBackground:
case kColorId_TableBackground:
+ case kColorId_TableBackgroundAlternate:
case kColorId_TooltipBackground:
case kColorId_ProminentButtonDisabledColor:
return system_colors_[SystemThemeColor::kWindow];
// Window Text
- case kColorId_DefaultIconColor:
+ case kColorId_MenuIconColor:
case kColorId_DialogForeground:
case kColorId_LabelEnabledColor:
case kColorId_LabelSecondaryColor:
@@ -625,6 +629,7 @@ SkColor NativeThemeWin::GetPlatformHighContrastColor(ColorId color_id) const {
case kColorId_AlertSeverityLow:
case kColorId_AlertSeverityMedium:
case kColorId_AlertSeverityHigh:
+ case kColorId_DefaultIconColor:
return system_colors_[SystemThemeColor::kWindowText];
// Hyperlinks
@@ -642,11 +647,11 @@ SkColor NativeThemeWin::GetPlatformHighContrastColor(ColorId color_id) const {
return system_colors_[SystemThemeColor::kGrayText];
// Button Background
+ case kColorId_ButtonColor:
case kColorId_MenuBackgroundColor:
case kColorId_HighlightedMenuItemBackgroundColor:
case kColorId_TextfieldDefaultBackground:
case kColorId_TextfieldReadOnlyBackground:
- case kColorId_ButtonPressedShade:
return system_colors_[SystemThemeColor::kButtonFace];
// Button Text Foreground
@@ -691,7 +696,7 @@ SkColor NativeThemeWin::GetPlatformHighContrastColor(ColorId color_id) const {
return system_colors_[SystemThemeColor::kHighlightText];
default:
- return gfx::kPlaceholderColor;
+ return base::nullopt;
}
}
diff --git a/chromium/ui/native_theme/native_theme_win.h b/chromium/ui/native_theme/native_theme_win.h
index 699d1a3b259..c6a15a8a4dc 100644
--- a/chromium/ui/native_theme/native_theme_win.h
+++ b/chromium/ui/native_theme/native_theme_win.h
@@ -15,6 +15,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/no_destructor.h"
+#include "base/optional.h"
#include "base/win/registry.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/geometry/size.h"
@@ -196,7 +197,7 @@ class NATIVE_THEME_EXPORT NativeThemeWin : public NativeTheme,
// Returns the platform provided high contrast color for the given
// |color_id|.
- SkColor GetPlatformHighContrastColor(ColorId color_id) const;
+ base::Optional<SkColor> GetPlatformHighContrastColor(ColorId color_id) const;
// Dark Mode registry key.
base::win::RegKey hkcu_themes_regkey_;
diff --git a/chromium/ui/native_theme/themed_vector_icon.cc b/chromium/ui/native_theme/themed_vector_icon.cc
index 0750002a169..3881f84d423 100644
--- a/chromium/ui/native_theme/themed_vector_icon.cc
+++ b/chromium/ui/native_theme/themed_vector_icon.cc
@@ -12,17 +12,41 @@ namespace ui {
ThemedVectorIcon::ThemedVectorIcon() = default;
ThemedVectorIcon::ThemedVectorIcon(const gfx::VectorIcon* icon,
- NativeTheme::ColorId color_id)
- : icon_(icon), color_id_(color_id) {}
+ NativeTheme::ColorId color_id,
+ int icon_size)
+ : icon_(icon), icon_size_(icon_size), color_id_(color_id) {}
-ThemedVectorIcon::ThemedVectorIcon(const gfx::VectorIcon* icon, SkColor color)
- : icon_(icon), color_(color) {}
+ThemedVectorIcon::ThemedVectorIcon(const VectorIconModel& vector_icon_model)
+ : icon_(vector_icon_model.vector_icon()),
+ icon_size_(vector_icon_model.icon_size()) {
+ if (vector_icon_model.has_color()) {
+ color_ = vector_icon_model.color();
+ } else if (vector_icon_model.color_id() >= 0) {
+ color_id_ =
+ static_cast<ui::NativeTheme::ColorId>(vector_icon_model.color_id());
+ } else {
+ color_id_ = ui::NativeTheme::kColorId_MenuIconColor;
+ }
+}
+
+ThemedVectorIcon::ThemedVectorIcon(const gfx::VectorIcon* icon,
+ SkColor color,
+ int icon_size)
+ : icon_(icon), icon_size_(icon_size), color_(color) {}
+
+ThemedVectorIcon::ThemedVectorIcon(const ThemedVectorIcon&) = default;
+
+ThemedVectorIcon& ThemedVectorIcon::operator=(const ThemedVectorIcon&) =
+ default;
+
+ThemedVectorIcon::ThemedVectorIcon(ThemedVectorIcon&&) = default;
-ThemedVectorIcon::ThemedVectorIcon(const ThemedVectorIcon& other) = default;
+ThemedVectorIcon& ThemedVectorIcon::operator=(ThemedVectorIcon&&) = default;
const gfx::ImageSkia ThemedVectorIcon::GetImageSkia(NativeTheme* theme) const {
DCHECK(!empty());
- return CreateVectorIcon(*icon_, GetColor(theme));
+ return icon_size_ > 0 ? CreateVectorIcon(*icon_, icon_size_, GetColor(theme))
+ : CreateVectorIcon(*icon_, GetColor(theme));
}
const gfx::ImageSkia ThemedVectorIcon::GetImageSkia(NativeTheme* theme,
@@ -33,7 +57,8 @@ const gfx::ImageSkia ThemedVectorIcon::GetImageSkia(NativeTheme* theme,
const gfx::ImageSkia ThemedVectorIcon::GetImageSkia(SkColor color) const {
DCHECK(!empty());
- return CreateVectorIcon(*icon_, color);
+ return icon_size_ > 0 ? CreateVectorIcon(*icon_, icon_size_, color)
+ : CreateVectorIcon(*icon_, color);
}
SkColor ThemedVectorIcon::GetColor(NativeTheme* theme) const {
@@ -41,4 +66,4 @@ SkColor ThemedVectorIcon::GetColor(NativeTheme* theme) const {
return color_id_ ? theme->GetSystemColor(color_id_.value()) : color_.value();
}
-} // namespace ui \ No newline at end of file
+} // namespace ui
diff --git a/chromium/ui/native_theme/themed_vector_icon.h b/chromium/ui/native_theme/themed_vector_icon.h
index 31779e72709..e65348c9fde 100644
--- a/chromium/ui/native_theme/themed_vector_icon.h
+++ b/chromium/ui/native_theme/themed_vector_icon.h
@@ -7,6 +7,7 @@
#include "base/optional.h"
#include "third_party/skia/include/core/SkColor.h"
+#include "ui/base/models/image_model.h"
#include "ui/native_theme/native_theme.h"
#include "ui/native_theme/native_theme_export.h"
@@ -22,11 +23,20 @@ class NATIVE_THEME_EXPORT ThemedVectorIcon {
ThemedVectorIcon();
explicit ThemedVectorIcon(
const gfx::VectorIcon* icon,
- NativeTheme::ColorId color_id = NativeTheme::kColorId_DefaultIconColor);
+ NativeTheme::ColorId color_id = NativeTheme::kColorId_MenuIconColor,
+ int icon_size = 0);
+ explicit ThemedVectorIcon(const VectorIconModel& vector_icon_model);
// TODO (kylixrd): Remove this once all the hard-coded uses of color are
// removed.
- ThemedVectorIcon(const gfx::VectorIcon* icon, SkColor color);
+ ThemedVectorIcon(const gfx::VectorIcon* icon,
+ SkColor color,
+ int icon_size = 0);
+
+ // Copyable and moveable
ThemedVectorIcon(const ThemedVectorIcon& other);
+ ThemedVectorIcon& operator=(const ThemedVectorIcon&);
+ ThemedVectorIcon(ThemedVectorIcon&&);
+ ThemedVectorIcon& operator=(ThemedVectorIcon&&);
void clear() { icon_ = nullptr; }
bool empty() const { return !icon_; }
@@ -38,6 +48,7 @@ class NATIVE_THEME_EXPORT ThemedVectorIcon {
SkColor GetColor(NativeTheme* theme) const;
const gfx::VectorIcon* icon_ = nullptr;
+ int icon_size_ = 0;
base::Optional<NativeTheme::ColorId> color_id_;
base::Optional<SkColor> color_;
};
diff --git a/chromium/ui/native_theme/themed_vector_icon_unittest.cc b/chromium/ui/native_theme/themed_vector_icon_unittest.cc
new file mode 100644
index 00000000000..22e9814ab2d
--- /dev/null
+++ b/chromium/ui/native_theme/themed_vector_icon_unittest.cc
@@ -0,0 +1,50 @@
+// Copyright 2020 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 "ui/native_theme/themed_vector_icon.h"
+
+#include "base/macros.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/gfx/paint_vector_icon.h"
+#include "ui/gfx/vector_icon_types.h"
+
+namespace ui {
+
+namespace {
+
+const gfx::VectorIcon* GetVectorIcon() {
+ static constexpr gfx::PathElement path[] = {gfx::CommandType::CIRCLE, 24, 18,
+ 5};
+ static const gfx::VectorIconRep rep[] = {{path, 4}};
+ static constexpr gfx::VectorIcon circle_icon = {rep, 1, "circle"};
+
+ return &circle_icon;
+}
+
+} // namespace
+
+TEST(ThemedVectorIconTest, DefaultEmpty) {
+ ThemedVectorIcon vector_icon;
+
+ EXPECT_TRUE(vector_icon.empty());
+}
+
+TEST(ThemedVectorIconTest, CheckForVectorIcon) {
+ ThemedVectorIcon vector_icon = ThemedVectorIcon(GetVectorIcon());
+
+ EXPECT_FALSE(vector_icon.empty());
+}
+
+TEST(ImageModelTest, CheckAssign) {
+ ThemedVectorIcon vector_icon_dest;
+ ThemedVectorIcon vector_icon_src(GetVectorIcon());
+
+ EXPECT_TRUE(vector_icon_dest.empty());
+ EXPECT_FALSE(vector_icon_src.empty());
+
+ vector_icon_dest = vector_icon_src;
+ EXPECT_FALSE(vector_icon_dest.empty());
+}
+
+} // namespace ui
diff --git a/chromium/ui/ozone/BUILD.gn b/chromium/ui/ozone/BUILD.gn
index 7e53cb2a7ac..a3e07b47d27 100644
--- a/chromium/ui/ozone/BUILD.gn
+++ b/chromium/ui/ozone/BUILD.gn
@@ -85,6 +85,7 @@ jumbo_component("ozone_base") {
"public/ozone_switches.cc",
"public/ozone_switches.h",
"public/platform_clipboard.h",
+ "public/platform_gl_egl_utility.h",
"public/platform_screen.cc",
"public/platform_screen.h",
"public/platform_window_surface.h",
@@ -104,7 +105,7 @@ jumbo_component("ozone_base") {
"//ipc",
"//skia",
"//ui/base/clipboard:clipboard_types",
- "//ui/base/mojom:cursor_type",
+ "//ui/base/cursor/mojom:cursor_type",
"//ui/display",
"//ui/display/types",
"//ui/display/util",
@@ -136,6 +137,8 @@ jumbo_component("ozone_base") {
"//ui/base/ime/chromeos/*",
]
+ configs += [ "//third_party/khronos:khronos_headers" ]
+
# Out of tree platforms can depend on this.
visibility += ozone_external_platform_visibility
}
@@ -171,6 +174,7 @@ source_set("platform") {
"//ipc",
"//services/service_manager/public/cpp",
"//skia",
+ "//ui/base:data_exchange",
"//ui/display/types",
"//ui/events",
"//ui/events/devices",
diff --git a/chromium/ui/ozone/DEPS b/chromium/ui/ozone/DEPS
index 95114917729..7d2c78764c3 100644
--- a/chromium/ui/ozone/DEPS
+++ b/chromium/ui/ozone/DEPS
@@ -9,6 +9,8 @@ include_rules = [
"+ui/display",
"+ui/events",
"+ui/base/clipboard/clipboard_buffer.h",
+ "+ui/base/dragdrop/os_exchange_data.h",
+ "+ui/base/dragdrop/os_exchange_data_provider_factory.h",
"+ui/base/cursor",
"+ui/gfx",
"+ui/gl",
diff --git a/chromium/ui/ozone/common/BUILD.gn b/chromium/ui/ozone/common/BUILD.gn
index 05f34b34014..47617e27956 100644
--- a/chromium/ui/ozone/common/BUILD.gn
+++ b/chromium/ui/ozone/common/BUILD.gn
@@ -15,11 +15,6 @@ source_set("common") {
"gl_ozone_egl.h",
"gl_surface_egl_readback.cc",
"gl_surface_egl_readback.h",
- "gpu/ozone_gpu_message_generator.cc",
- "gpu/ozone_gpu_message_generator.h",
- "gpu/ozone_gpu_message_params.cc",
- "gpu/ozone_gpu_message_params.h",
- "gpu/ozone_gpu_messages.h",
"stub_overlay_manager.cc",
"stub_overlay_manager.h",
]
diff --git a/chromium/ui/ozone/common/egl_util.cc b/chromium/ui/ozone/common/egl_util.cc
index 7336356a4da..56e5ebb152a 100644
--- a/chromium/ui/ozone/common/egl_util.cc
+++ b/chromium/ui/ozone/common/egl_util.cc
@@ -20,17 +20,27 @@ const base::FilePath::CharType kDefaultEglSoname[] =
FILE_PATH_LITERAL("libEGL.dll");
const base::FilePath::CharType kDefaultGlesSoname[] =
FILE_PATH_LITERAL("libGLESv2.dll");
-#elif defined(OS_FUCHSIA)
+const base::FilePath::CharType kAngleEglSoname[] =
+ FILE_PATH_LITERAL("libEGL.dll");
+const base::FilePath::CharType kAngleGlesSoname[] =
+ FILE_PATH_LITERAL("libGLESv2.dll");
+#else
+#if defined(OS_FUCHSIA)
const base::FilePath::CharType kDefaultEglSoname[] =
FILE_PATH_LITERAL("libEGL.so");
const base::FilePath::CharType kDefaultGlesSoname[] =
FILE_PATH_LITERAL("libGLESv2.so");
-#else // !defined(OS_WIN) && !defined(OS_FUCHSIA)
+#else // !defined(OS_FUCHSIA)
const base::FilePath::CharType kDefaultEglSoname[] =
FILE_PATH_LITERAL("libEGL.so.1");
const base::FilePath::CharType kDefaultGlesSoname[] =
FILE_PATH_LITERAL("libGLESv2.so.2");
-#endif // !defined(OS_WIN) && !defined(OS_FUCHSIA)
+#endif
+const base::FilePath::CharType kAngleEglSoname[] =
+ FILE_PATH_LITERAL("libEGL.so");
+const base::FilePath::CharType kAngleGlesSoname[] =
+ FILE_PATH_LITERAL("libGLESv2.so");
+#endif // !defined(OS_WIN)
#if BUILDFLAG(ENABLE_SWIFTSHADER)
#if defined(OS_WIN)
@@ -109,6 +119,9 @@ bool LoadDefaultEGLGLES2Bindings(gl::GLImplementation implementation) {
#else
return false;
#endif
+ } else if (implementation == gl::kGLImplementationEGLANGLE) {
+ glesv2_path = base::FilePath(kAngleGlesSoname);
+ egl_path = base::FilePath(kAngleEglSoname);
} else {
glesv2_path = base::FilePath(kDefaultGlesSoname);
egl_path = base::FilePath(kDefaultEglSoname);
diff --git a/chromium/ui/ozone/common/gl_surface_egl_readback.cc b/chromium/ui/ozone/common/gl_surface_egl_readback.cc
index 4f15ad6fb0d..128d4f02273 100644
--- a/chromium/ui/ozone/common/gl_surface_egl_readback.cc
+++ b/chromium/ui/ozone/common/gl_surface_egl_readback.cc
@@ -43,9 +43,7 @@ bool GLSurfaceEglReadback::IsOffscreen() {
gfx::SwapResult GLSurfaceEglReadback::SwapBuffers(
PresentationCallback callback) {
- const gfx::Size size = GetSize();
- glReadPixels(0, 0, size.width(), size.height(), GL_BGRA, GL_UNSIGNED_BYTE,
- pixels_.get());
+ ReadPixels(pixels_.get());
gfx::SwapResult swap_result = gfx::SwapResult::SWAP_FAILED;
gfx::PresentationFeedback feedback;
@@ -74,4 +72,30 @@ bool GLSurfaceEglReadback::HandlePixels(uint8_t* pixels) {
return true;
}
+void GLSurfaceEglReadback::ReadPixels(void* buffer) {
+ const gfx::Size size = GetSize();
+
+ GLint read_fbo = 0;
+ GLint pixel_pack_buffer = 0;
+ glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &read_fbo);
+ glGetIntegerv(GL_PIXEL_PACK_BUFFER_BINDING, &pixel_pack_buffer);
+
+ // Make sure pixels are read from fbo 0.
+ if (read_fbo)
+ glBindFramebufferEXT(GL_READ_FRAMEBUFFER, 0);
+
+ // Make sure pixels are stored into |pixels_| instead of buffer binding to
+ // GL_PIXEL_PACK_BUFFER.
+ if (pixel_pack_buffer)
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
+
+ glReadPixels(0, 0, size.width(), size.height(), GL_BGRA, GL_UNSIGNED_BYTE,
+ buffer);
+
+ if (read_fbo)
+ glBindFramebufferEXT(GL_READ_FRAMEBUFFER, read_fbo);
+ if (pixel_pack_buffer)
+ glBindBuffer(GL_PIXEL_PACK_BUFFER, pixel_pack_buffer);
+}
+
} // namespace ui
diff --git a/chromium/ui/ozone/common/gl_surface_egl_readback.h b/chromium/ui/ozone/common/gl_surface_egl_readback.h
index d25c12da865..c4ab56df0dc 100644
--- a/chromium/ui/ozone/common/gl_surface_egl_readback.h
+++ b/chromium/ui/ozone/common/gl_surface_egl_readback.h
@@ -44,6 +44,9 @@ class GLSurfaceEglReadback : public gl::PbufferGLSurfaceEGL {
// failure.
virtual bool HandlePixels(uint8_t* pixels);
+ // Reads pixels with glReadPixels from fbo to |buffer|.
+ void ReadPixels(void* buffer);
+
private:
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
std::unique_ptr<uint8_t[]> pixels_;
diff --git a/chromium/ui/ozone/common/gpu/OWNERS b/chromium/ui/ozone/common/gpu/OWNERS
deleted file mode 100644
index 41a9e54b464..00000000000
--- a/chromium/ui/ozone/common/gpu/OWNERS
+++ /dev/null
@@ -1,5 +0,0 @@
-per-file *_messages*.h=set noparent
-per-file *_messages*.h=file://ipc/SECURITY_OWNERS
-
-per-file *_message_param*.*=set noparent
-per-file *_message_param*.*=file://ipc/SECURITY_OWNERS
diff --git a/chromium/ui/ozone/common/gpu/ozone_gpu_message_generator.cc b/chromium/ui/ozone/common/gpu/ozone_gpu_message_generator.cc
deleted file mode 100644
index d2f07ee8ab1..00000000000
--- a/chromium/ui/ozone/common/gpu/ozone_gpu_message_generator.cc
+++ /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.
-
-// Get basic type definitions.
-#define IPC_MESSAGE_IMPL
-#include "ui/ozone/common/gpu/ozone_gpu_message_generator.h"
-
-// Generate constructors.
-#include "ipc/struct_constructor_macros.h"
-#include "ui/ozone/common/gpu/ozone_gpu_message_generator.h"
-
-// Generate param traits write methods.
-#include "ipc/param_traits_write_macros.h"
-namespace IPC {
-#include "ui/ozone/common/gpu/ozone_gpu_message_generator.h"
-} // namespace IPC
-
-// Generate param traits read methods.
-#include "ipc/param_traits_read_macros.h"
-namespace IPC {
-#include "ui/ozone/common/gpu/ozone_gpu_message_generator.h"
-} // namespace IPC
-
-// Generate param traits log methods.
-#include "ipc/param_traits_log_macros.h"
-namespace IPC {
-#include "ui/ozone/common/gpu/ozone_gpu_message_generator.h"
-} // namespace IPC
diff --git a/chromium/ui/ozone/common/gpu/ozone_gpu_message_generator.h b/chromium/ui/ozone/common/gpu/ozone_gpu_message_generator.h
deleted file mode 100644
index 3b35c0e7bce..00000000000
--- a/chromium/ui/ozone/common/gpu/ozone_gpu_message_generator.h
+++ /dev/null
@@ -1,7 +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.
-
-// Multiply-included file, hence no include guard.
-
-#include "ui/ozone/common/gpu/ozone_gpu_messages.h"
diff --git a/chromium/ui/ozone/common/gpu/ozone_gpu_message_params.cc b/chromium/ui/ozone/common/gpu/ozone_gpu_message_params.cc
deleted file mode 100644
index 48aaeefd2ca..00000000000
--- a/chromium/ui/ozone/common/gpu/ozone_gpu_message_params.cc
+++ /dev/null
@@ -1,24 +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 "ui/ozone/common/gpu/ozone_gpu_message_params.h"
-
-#include "ui/gfx/geometry/rect_conversions.h"
-#include "ui/gfx/ipc/gfx_param_traits.h"
-#include "ui/gfx/ipc/skia/gfx_skia_param_traits.h"
-
-namespace ui {
-
-DisplayMode_Params::DisplayMode_Params() {}
-
-DisplayMode_Params::~DisplayMode_Params() {}
-
-DisplaySnapshot_Params::DisplaySnapshot_Params() {}
-
-DisplaySnapshot_Params::DisplaySnapshot_Params(
- const DisplaySnapshot_Params& other) = default;
-
-DisplaySnapshot_Params::~DisplaySnapshot_Params() {}
-
-} // namespace ui
diff --git a/chromium/ui/ozone/common/gpu/ozone_gpu_message_params.h b/chromium/ui/ozone/common/gpu/ozone_gpu_message_params.h
deleted file mode 100644
index 128252e7d26..00000000000
--- a/chromium/ui/ozone/common/gpu/ozone_gpu_message_params.h
+++ /dev/null
@@ -1,65 +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 UI_OZONE_COMMON_GPU_OZONE_GPU_MESSAGE_PARAMS_H_
-#define UI_OZONE_COMMON_GPU_OZONE_GPU_MESSAGE_PARAMS_H_
-
-#include <stdint.h>
-
-#include <string>
-#include <vector>
-
-#include "base/files/file_path.h"
-#include "ui/display/types/display_constants.h"
-#include "ui/gfx/buffer_types.h"
-#include "ui/gfx/color_space.h"
-#include "ui/gfx/geometry/point.h"
-#include "ui/gfx/geometry/size.h"
-
-namespace ui {
-
-struct DisplayMode_Params {
- DisplayMode_Params();
- ~DisplayMode_Params();
-
- gfx::Size size;
- bool is_interlaced = false;
- float refresh_rate = 0.0f;
-};
-
-struct DisplaySnapshot_Params {
- DisplaySnapshot_Params();
- DisplaySnapshot_Params(const DisplaySnapshot_Params& other);
- ~DisplaySnapshot_Params();
-
- int64_t display_id = 0;
- gfx::Point origin;
- gfx::Size physical_size;
- display::DisplayConnectionType type = display::DISPLAY_CONNECTION_TYPE_NONE;
- bool is_aspect_preserving_scaling = false;
- bool has_overscan = false;
- display::PrivacyScreenState privacy_screen_state =
- display::PrivacyScreenState::kNotSupported;
- bool has_color_correction_matrix = false;
- bool color_correction_in_linear_space = false;
- gfx::ColorSpace color_space;
- uint32_t bits_per_channel = 0;
- std::string display_name;
- base::FilePath sys_path;
- std::vector<DisplayMode_Params> modes;
- display::PanelOrientation panel_orientation =
- display::PanelOrientation::kNormal;
- std::vector<uint8_t> edid;
- bool has_current_mode = false;
- DisplayMode_Params current_mode;
- bool has_native_mode = false;
- DisplayMode_Params native_mode;
- int64_t product_code = 0;
- int32_t year_of_manufacture = display::kInvalidYearOfManufacture;
- gfx::Size maximum_cursor_size;
-};
-
-} // namespace ui
-
-#endif // UI_OZONE_COMMON_GPU_OZONE_GPU_MESSAGE_PARAMS_H_
diff --git a/chromium/ui/ozone/common/gpu/ozone_gpu_messages.h b/chromium/ui/ozone/common/gpu/ozone_gpu_messages.h
deleted file mode 100644
index 74caeb476cb..00000000000
--- a/chromium/ui/ozone/common/gpu/ozone_gpu_messages.h
+++ /dev/null
@@ -1,190 +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.
-
-// Multiply-included message file, hence no include guard here, but see below
-// for a much smaller-than-usual include guard section.
-// no-include-guard-because-multiply-included
-// NOLINT(build/header_guard)
-
-#include <stdint.h>
-
-#include <vector>
-
-#include "base/file_descriptor_posix.h"
-#include "ipc/ipc_message_macros.h"
-#include "third_party/skia/include/core/SkBitmap.h"
-#include "ui/display/types/display_constants.h"
-#include "ui/display/types/gamma_ramp_rgb_entry.h"
-#include "ui/gfx/geometry/point.h"
-#include "ui/gfx/geometry/rect.h"
-#include "ui/gfx/ipc/buffer_types/gfx_param_traits.h"
-#include "ui/gfx/ipc/color/gfx_param_traits.h"
-#include "ui/gfx/ipc/geometry/gfx_param_traits.h"
-#include "ui/gfx/ipc/gfx_param_traits.h"
-#include "ui/gfx/ipc/skia/gfx_skia_param_traits.h"
-#include "ui/gfx/native_widget_types.h"
-#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
-
-#undef IPC_MESSAGE_EXPORT
-#define IPC_MESSAGE_EXPORT
-
-#define IPC_MESSAGE_START OzoneGpuMsgStart
-
-IPC_ENUM_TRAITS_MAX_VALUE(display::DisplayConnectionType,
- display::DISPLAY_CONNECTION_TYPE_LAST)
-
-IPC_ENUM_TRAITS_MAX_VALUE(display::HDCPState, display::HDCP_STATE_LAST)
-
-IPC_ENUM_TRAITS_MAX_VALUE(display::PanelOrientation,
- display::PanelOrientation::kLast)
-
-IPC_ENUM_TRAITS_MAX_VALUE(display::PrivacyScreenState,
- display::PrivacyScreenState::kPrivacyScreenStateLast)
-
-// clang-format off
-IPC_STRUCT_TRAITS_BEGIN(ui::DisplayMode_Params)
- IPC_STRUCT_TRAITS_MEMBER(size)
- IPC_STRUCT_TRAITS_MEMBER(is_interlaced)
- IPC_STRUCT_TRAITS_MEMBER(refresh_rate)
-IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_TRAITS_BEGIN(ui::DisplaySnapshot_Params)
- IPC_STRUCT_TRAITS_MEMBER(display_id)
- IPC_STRUCT_TRAITS_MEMBER(origin)
- IPC_STRUCT_TRAITS_MEMBER(physical_size)
- IPC_STRUCT_TRAITS_MEMBER(type)
- IPC_STRUCT_TRAITS_MEMBER(is_aspect_preserving_scaling)
- IPC_STRUCT_TRAITS_MEMBER(has_overscan)
- IPC_STRUCT_TRAITS_MEMBER(privacy_screen_state)
- IPC_STRUCT_TRAITS_MEMBER(has_color_correction_matrix)
- IPC_STRUCT_TRAITS_MEMBER(color_correction_in_linear_space)
- IPC_STRUCT_TRAITS_MEMBER(color_space)
- IPC_STRUCT_TRAITS_MEMBER(bits_per_channel)
- IPC_STRUCT_TRAITS_MEMBER(display_name)
- IPC_STRUCT_TRAITS_MEMBER(sys_path)
- IPC_STRUCT_TRAITS_MEMBER(modes)
- IPC_STRUCT_TRAITS_MEMBER(panel_orientation)
- IPC_STRUCT_TRAITS_MEMBER(edid)
- IPC_STRUCT_TRAITS_MEMBER(has_current_mode)
- IPC_STRUCT_TRAITS_MEMBER(current_mode)
- IPC_STRUCT_TRAITS_MEMBER(has_native_mode)
- IPC_STRUCT_TRAITS_MEMBER(native_mode)
- IPC_STRUCT_TRAITS_MEMBER(product_code)
- IPC_STRUCT_TRAITS_MEMBER(year_of_manufacture)
- IPC_STRUCT_TRAITS_MEMBER(maximum_cursor_size)
-IPC_STRUCT_TRAITS_END()
-
-IPC_STRUCT_TRAITS_BEGIN(display::GammaRampRGBEntry)
- IPC_STRUCT_TRAITS_MEMBER(r)
- IPC_STRUCT_TRAITS_MEMBER(g)
- IPC_STRUCT_TRAITS_MEMBER(b)
-IPC_STRUCT_TRAITS_END()
-// clang-format on
-
-//------------------------------------------------------------------------------
-// GPU Messages
-// These are messages from the browser to the GPU process.
-
-// Update the HW cursor bitmap & move to specified location.
-IPC_MESSAGE_CONTROL4(OzoneGpuMsg_CursorSet,
- gfx::AcceleratedWidget,
- std::vector<SkBitmap>,
- gfx::Point /* location */,
- int /* frame_delay_ms */)
-
-// Move the HW cursor to the specified location.
-IPC_MESSAGE_CONTROL2(OzoneGpuMsg_CursorMove,
- gfx::AcceleratedWidget, gfx::Point)
-
-// Explicit creation of a window. We explicitly create the window such
-// that any state change in the window is not lost while the surface is
-// created on the GPU side.
-IPC_MESSAGE_CONTROL2(OzoneGpuMsg_CreateWindow,
- gfx::AcceleratedWidget /* widget */,
- gfx::Rect /* initial_bounds */)
-
-IPC_MESSAGE_CONTROL1(OzoneGpuMsg_DestroyWindow,
- gfx::AcceleratedWidget /* widget */)
-
-// Updates the location and size of the widget on the screen.
-IPC_MESSAGE_CONTROL2(OzoneGpuMsg_WindowBoundsChanged,
- gfx::AcceleratedWidget /* widget */,
- gfx::Rect /* bounds */)
-
-// Trigger a display reconfiguration. OzoneHostMsg_UpdateNativeDisplays will be
-// sent as a response.
-IPC_MESSAGE_CONTROL0(OzoneGpuMsg_RefreshNativeDisplays)
-
-// Configure a display with the specified mode at the specified location.
-IPC_MESSAGE_CONTROL3(OzoneGpuMsg_ConfigureNativeDisplay,
- int64_t, // display ID
- ui::DisplayMode_Params, // display mode
- gfx::Point) // origin for the display
-
-IPC_MESSAGE_CONTROL1(OzoneGpuMsg_DisableNativeDisplay,
- int64_t) // display ID
-
-// |device_path| is inside of the /sys filesystem, since UDL display/input
-// association logic needs to access the path components.
-IPC_MESSAGE_CONTROL2(OzoneGpuMsg_AddGraphicsDevice,
- base::FilePath /* device_path */,
- base::FileDescriptor /* device_fd */)
-
-IPC_MESSAGE_CONTROL1(OzoneGpuMsg_RemoveGraphicsDevice,
- base::FilePath /* device_path */)
-
-// Take control of the display
-IPC_MESSAGE_CONTROL0(OzoneGpuMsg_TakeDisplayControl)
-
-// Let other entity control the display
-IPC_MESSAGE_CONTROL0(OzoneGpuMsg_RelinquishDisplayControl)
-
-IPC_MESSAGE_CONTROL1(OzoneGpuMsg_GetHDCPState, int64_t /* display_id */)
-
-IPC_MESSAGE_CONTROL2(OzoneGpuMsg_SetHDCPState,
- int64_t /* display_id */,
- display::HDCPState /* state */)
-
-IPC_MESSAGE_CONTROL2(OzoneGpuMsg_SetColorMatrix,
- int64_t, // Display ID
- std::vector<float>) // Color transform matrix
-
-IPC_MESSAGE_CONTROL3(OzoneGpuMsg_SetGammaCorrection,
- int64_t, // Display ID
- std::vector<display::GammaRampRGBEntry>, // Degamma lut
- std::vector<display::GammaRampRGBEntry>) // Gamma lut
-
-// Set the privacy screen state of the display with |display_id|
-IPC_MESSAGE_CONTROL2(OzoneGpuMsg_SetPrivacyScreen,
- int64_t /* display_id */,
- bool /* enabled */)
-//------------------------------------------------------------------------------
-// Browser Messages
-// These messages are from the GPU to the browser process.
-
-// Updates the list of active displays.
-IPC_MESSAGE_CONTROL1(OzoneHostMsg_UpdateNativeDisplays,
- std::vector<ui::DisplaySnapshot_Params>)
-
-IPC_MESSAGE_CONTROL2(OzoneHostMsg_DisplayConfigured,
- int64_t /* display_id */,
- bool /* status */)
-
-// Response for OzoneGpuMsg_GetHDCPState.
-IPC_MESSAGE_CONTROL3(OzoneHostMsg_HDCPStateReceived,
- int64_t /* display_id */,
- bool /* success */,
- display::HDCPState /* state */)
-
-// Response for OzoneGpuMsg_SetHDCPState.
-IPC_MESSAGE_CONTROL2(OzoneHostMsg_HDCPStateUpdated,
- int64_t /* display_id */,
- bool /* success */)
-
-// Response to OzoneGpuMsg_TakeDisplayControl.
-IPC_MESSAGE_CONTROL1(OzoneHostMsg_DisplayControlTaken, bool /* success */)
-
-// Response to OzoneGpuMsg_RelinquishDisplayControl.
-IPC_MESSAGE_CONTROL1(OzoneHostMsg_DisplayControlRelinquished,
- bool /* success */)
diff --git a/chromium/ui/ozone/common/stub_client_native_pixmap_factory.cc b/chromium/ui/ozone/common/stub_client_native_pixmap_factory.cc
index 737e9cdc639..bebe80025cf 100644
--- a/chromium/ui/ozone/common/stub_client_native_pixmap_factory.cc
+++ b/chromium/ui/ozone/common/stub_client_native_pixmap_factory.cc
@@ -5,6 +5,7 @@
#include <memory>
#include "base/macros.h"
+#include "base/notreached.h"
#include "ui/gfx/client_native_pixmap_factory.h"
#include "ui/gfx/native_pixmap_handle.h"
diff --git a/chromium/ui/ozone/demo/gl_renderer.cc b/chromium/ui/ozone/demo/gl_renderer.cc
index 8c266b61096..c5812189846 100644
--- a/chromium/ui/ozone/demo/gl_renderer.cc
+++ b/chromium/ui/ozone/demo/gl_renderer.cc
@@ -38,13 +38,13 @@ bool GlRenderer::Initialize() {
return false;
}
- gl_surface_->Resize(size_, 1.f, gfx::ColorSpace(), true);
-
if (!context_->MakeCurrent(gl_surface_.get())) {
LOG(ERROR) << "Failed to make GL context current";
return false;
}
+ gl_surface_->Resize(size_, 1.f, gfx::ColorSpace(), true);
+
// Schedule the initial render.
PostRenderFrameTask(gfx::SwapResult::SWAP_ACK, nullptr);
return true;
diff --git a/chromium/ui/ozone/demo/ozone_demo.cc b/chromium/ui/ozone/demo/ozone_demo.cc
index 937778bb238..bb639f0871b 100644
--- a/chromium/ui/ozone/demo/ozone_demo.cc
+++ b/chromium/ui/ozone/demo/ozone_demo.cc
@@ -21,7 +21,6 @@
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
#include "ui/ozone/demo/simple_renderer_factory.h"
#include "ui/ozone/demo/window_manager.h"
-#include "ui/ozone/public/ozone_gpu_test_helper.h"
#include "ui/ozone/public/ozone_platform.h"
const char kHelp[] = "help";
@@ -82,17 +81,6 @@ int main(int argc, char** argv) {
ui::OzonePlatform::InitializeForGPU(params);
- std::unique_ptr<ui::OzoneGpuTestHelper> gpu_helper;
- if (!ui::OzonePlatform::GetInstance()
- ->GetPlatformProperties()
- .requires_mojo) {
- // OzoneGpuTestHelper transports Chrome IPC messages between host & gpu code
- // in single process mode. We don't use both Chrome IPC and mojo, so only
- // initialize it for non-mojo platforms.
- gpu_helper = std::make_unique<ui::OzoneGpuTestHelper>();
- gpu_helper->Initialize(base::ThreadTaskRunnerHandle::Get());
- }
-
base::RunLoop run_loop;
ui::WindowManager window_manager(
diff --git a/chromium/ui/ozone/demo/simple_renderer_factory.h b/chromium/ui/ozone/demo/simple_renderer_factory.h
index 3e4e04e7f4f..45da9a6d850 100644
--- a/chromium/ui/ozone/demo/simple_renderer_factory.h
+++ b/chromium/ui/ozone/demo/simple_renderer_factory.h
@@ -9,7 +9,6 @@
#include "gpu/vulkan/buildflags.h"
#include "ui/ozone/demo/renderer_factory.h"
-#include "ui/ozone/public/ozone_gpu_test_helper.h"
#if BUILDFLAG(ENABLE_VULKAN)
#include "gpu/vulkan/vulkan_implementation.h"
diff --git a/chromium/ui/ozone/demo/skia/skia_demo.cc b/chromium/ui/ozone/demo/skia/skia_demo.cc
index 400f1e85581..d3bc9d7acff 100644
--- a/chromium/ui/ozone/demo/skia/skia_demo.cc
+++ b/chromium/ui/ozone/demo/skia/skia_demo.cc
@@ -20,7 +20,6 @@
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
#include "ui/ozone/demo/skia/skia_renderer_factory.h"
#include "ui/ozone/demo/window_manager.h"
-#include "ui/ozone/public/ozone_gpu_test_helper.h"
#include "ui/ozone/public/ozone_platform.h"
int main(int argc, char** argv) {
@@ -57,17 +56,6 @@ int main(int argc, char** argv) {
ui::OzonePlatform::InitializeForGPU(params);
- std::unique_ptr<ui::OzoneGpuTestHelper> gpu_helper;
- if (!ui::OzonePlatform::GetInstance()
- ->GetPlatformProperties()
- .requires_mojo) {
- // OzoneGpuTestHelper transports Chrome IPC messages between host & gpu code
- // in single process mode. We don't use both Chrome IPC and mojo, so only
- // initialize it for non-mojo platforms.
- gpu_helper = std::make_unique<ui::OzoneGpuTestHelper>();
- gpu_helper->Initialize(base::ThreadTaskRunnerHandle::Get());
- }
-
base::RunLoop run_loop;
ui::WindowManager window_manager(std::make_unique<ui::SkiaRendererFactory>(),
diff --git a/chromium/ui/ozone/demo/skia/skia_gl_renderer.cc b/chromium/ui/ozone/demo/skia/skia_gl_renderer.cc
index a4ed2416df4..ceb5cc4f5f2 100644
--- a/chromium/ui/ozone/demo/skia/skia_gl_renderer.cc
+++ b/chromium/ui/ozone/demo/skia/skia_gl_renderer.cc
@@ -111,13 +111,13 @@ void SkiaGlRenderer::RenderFrame() {
if (gl_surface_->SupportsAsyncSwap()) {
gl_surface_->SwapBuffersAsync(
- base::BindRepeating(&SkiaGlRenderer::PostRenderFrameTask,
- weak_ptr_factory_.GetWeakPtr()),
- base::BindRepeating(&SkiaGlRenderer::OnPresentation,
- weak_ptr_factory_.GetWeakPtr()));
+ base::BindOnce(&SkiaGlRenderer::PostRenderFrameTask,
+ weak_ptr_factory_.GetWeakPtr()),
+ base::BindOnce(&SkiaGlRenderer::OnPresentation,
+ weak_ptr_factory_.GetWeakPtr()));
} else {
PostRenderFrameTask(
- gl_surface_->SwapBuffers(base::BindRepeating(
+ gl_surface_->SwapBuffers(base::BindOnce(
&SkiaGlRenderer::OnPresentation, weak_ptr_factory_.GetWeakPtr())),
nullptr);
}
@@ -130,8 +130,8 @@ void SkiaGlRenderer::PostRenderFrameTask(
gpu_fence->Wait();
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindRepeating(&SkiaGlRenderer::RenderFrame,
- weak_ptr_factory_.GetWeakPtr()));
+ FROM_HERE, base::BindOnce(&SkiaGlRenderer::RenderFrame,
+ weak_ptr_factory_.GetWeakPtr()));
}
void SkiaGlRenderer::Draw(SkCanvas* canvas, float fraction) {
diff --git a/chromium/ui/ozone/demo/skia/skia_renderer_factory.h b/chromium/ui/ozone/demo/skia/skia_renderer_factory.h
index 524bbea7fea..192c12d67af 100644
--- a/chromium/ui/ozone/demo/skia/skia_renderer_factory.h
+++ b/chromium/ui/ozone/demo/skia/skia_renderer_factory.h
@@ -10,7 +10,6 @@
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/ozone/demo/renderer_factory.h"
-#include "ui/ozone/public/ozone_gpu_test_helper.h"
namespace ui {
diff --git a/chromium/ui/ozone/demo/skia/skia_surfaceless_gl_renderer.cc b/chromium/ui/ozone/demo/skia/skia_surfaceless_gl_renderer.cc
index 14b8650f3e0..e2ee9432d98 100644
--- a/chromium/ui/ozone/demo/skia/skia_surfaceless_gl_renderer.cc
+++ b/chromium/ui/ozone/demo/skia/skia_surfaceless_gl_renderer.cc
@@ -264,8 +264,8 @@ void SurfacelessSkiaGlRenderer::RenderFrame() {
back_buffer_ ^= 1;
gl_surface_->SwapBuffersAsync(
- base::BindRepeating(&SurfacelessSkiaGlRenderer::PostRenderFrameTask,
- weak_ptr_factory_.GetWeakPtr()),
+ base::BindOnce(&SurfacelessSkiaGlRenderer::PostRenderFrameTask,
+ weak_ptr_factory_.GetWeakPtr()),
base::DoNothing());
}
diff --git a/chromium/ui/ozone/demo/window_manager.cc b/chromium/ui/ozone/demo/window_manager.cc
index ed4f66c8df4..181539c4673 100644
--- a/chromium/ui/ozone/demo/window_manager.cc
+++ b/chromium/ui/ozone/demo/window_manager.cc
@@ -89,9 +89,9 @@ void WindowManager::OnDisplaysAquired(
delegate_->Configure(
*display, display->native_mode(), origin,
- base::BindRepeating(&WindowManager::OnDisplayConfigured,
- base::Unretained(this),
- gfx::Rect(origin, display->native_mode()->size())));
+ base::BindOnce(&WindowManager::OnDisplayConfigured,
+ base::Unretained(this),
+ gfx::Rect(origin, display->native_mode()->size())));
origin.Offset(display->native_mode()->size().width(), 0);
}
is_configuring_ = false;
@@ -99,8 +99,8 @@ void WindowManager::OnDisplaysAquired(
if (should_configure_) {
should_configure_ = false;
base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE, base::BindRepeating(&WindowManager::OnConfigurationChanged,
- base::Unretained(this)));
+ FROM_HERE, base::BindOnce(&WindowManager::OnConfigurationChanged,
+ base::Unretained(this)));
}
}
diff --git a/chromium/ui/ozone/gl/gl_image_ozone_native_pixmap_unittest.cc b/chromium/ui/ozone/gl/gl_image_ozone_native_pixmap_unittest.cc
index 229b15167bb..40087309e67 100644
--- a/chromium/ui/ozone/gl/gl_image_ozone_native_pixmap_unittest.cc
+++ b/chromium/ui/ozone/gl/gl_image_ozone_native_pixmap_unittest.cc
@@ -9,6 +9,7 @@
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/client_native_pixmap.h"
#include "ui/gl/gl_image_native_pixmap.h"
+#include "ui/gl/test/gl_image_bind_test_template.h"
#include "ui/gl/test/gl_image_test_template.h"
#include "ui/ozone/public/client_native_pixmap_factory_ozone.h"
#include "ui/ozone/public/ozone_platform.h"
diff --git a/chromium/ui/ozone/ozone.gni b/chromium/ui/ozone/ozone.gni
index 1e6db325cbe..13fecf9038a 100644
--- a/chromium/ui/ozone/ozone.gni
+++ b/chromium/ui/ozone/ozone.gni
@@ -4,6 +4,7 @@
import("//build/config/chromecast_build.gni")
import("//build/config/ui.gni")
+import("//build/toolchain/toolchain.gni")
declare_args() {
# Ozone extra platforms file path. Can be overridden to build out of
@@ -86,8 +87,10 @@ _ozone_extra_directory = get_path_info(ozone_extra_path, "dir")
# Extra paths to add to targets visibility list.
ozone_external_platform_visibility = [ "$_ozone_extra_directory/*" ]
-assert(use_ozone || !(ozone_platform_cast || ozone_platform_gbm ||
- ozone_platform_headless || ozone_platform_x11 ||
- ozone_platform_wayland || ozone_platform_windows ||
- ozone_platform_scenic),
- "Must set use_ozone to select ozone platforms")
+if (is_a_target_toolchain) {
+ assert(use_ozone || !(ozone_platform_cast || ozone_platform_gbm ||
+ ozone_platform_headless || ozone_platform_x11 ||
+ ozone_platform_wayland || ozone_platform_windows ||
+ ozone_platform_scenic),
+ "Must set use_ozone to select ozone platforms")
+}
diff --git a/chromium/ui/ozone/platform/cast/client_native_pixmap_factory_cast.cc b/chromium/ui/ozone/platform/cast/client_native_pixmap_factory_cast.cc
index f957a364aa4..c4c2c9d7efa 100644
--- a/chromium/ui/ozone/platform/cast/client_native_pixmap_factory_cast.cc
+++ b/chromium/ui/ozone/platform/cast/client_native_pixmap_factory_cast.cc
@@ -6,7 +6,7 @@
#include <memory>
-#include "base/logging.h"
+#include "base/notreached.h"
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/client_native_pixmap.h"
#include "ui/gfx/client_native_pixmap_factory.h"
diff --git a/chromium/ui/ozone/platform/drm/BUILD.gn b/chromium/ui/ozone/platform/drm/BUILD.gn
index d820eee6a6f..0ef7cd7e786 100644
--- a/chromium/ui/ozone/platform/drm/BUILD.gn
+++ b/chromium/ui/ozone/platform/drm/BUILD.gn
@@ -54,8 +54,6 @@ source_set("gbm") {
"gpu/drm_overlay_validator.h",
"gpu/drm_thread.cc",
"gpu/drm_thread.h",
- "gpu/drm_thread_message_proxy.cc",
- "gpu/drm_thread_message_proxy.h",
"gpu/drm_thread_proxy.cc",
"gpu/drm_thread_proxy.h",
"gpu/drm_window.cc",
@@ -102,8 +100,6 @@ source_set("gbm") {
"host/drm_display_host.h",
"host/drm_display_host_manager.cc",
"host/drm_display_host_manager.h",
- "host/drm_gpu_platform_support_host.cc",
- "host/drm_gpu_platform_support_host.h",
"host/drm_native_display_delegate.cc",
"host/drm_native_display_delegate.h",
"host/drm_window_host.cc",
@@ -152,6 +148,11 @@ source_set("gbm") {
"//ui/platform_window",
]
+ data_deps = [
+ "//third_party/angle:libEGL",
+ "//third_party/angle:libGLESv2",
+ ]
+
if (is_chromeos) {
deps += [ "//ui/base/ime/chromeos" ]
}
diff --git a/chromium/ui/ozone/platform/drm/common/drm_util.cc b/chromium/ui/ozone/platform/drm/common/drm_util.cc
index 06a9c37cd2c..7ac144c6bdf 100644
--- a/chromium/ui/ozone/platform/drm/common/drm_util.cc
+++ b/chromium/ui/ozone/platform/drm/common/drm_util.cc
@@ -16,6 +16,7 @@
#include <utility>
#include "base/containers/flat_map.h"
+#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "ui/display/types/display_constants.h"
#include "ui/display/types/display_mode.h"
@@ -245,12 +246,6 @@ bool IsDrmModuleName(const int fd, const std::string& name) {
return result;
}
-bool AreDisplayModesEqual(const DisplayMode_Params& lhs,
- const DisplayMode_Params& rhs) {
- return lhs.size == rhs.size && lhs.is_interlaced == rhs.is_interlaced &&
- lhs.refresh_rate == rhs.refresh_rate;
-}
-
} // namespace
ScopedDrmPropertyPtr FindDrmProperty(int fd,
@@ -270,20 +265,6 @@ bool HasColorCorrectionMatrix(int fd, drmModeCrtc* crtc) {
return !!FindDrmProperty(fd, crtc_props.get(), "CTM");
}
-DisplayMode_Params GetDisplayModeParams(const display::DisplayMode& mode) {
- DisplayMode_Params params;
- params.size = mode.size();
- params.is_interlaced = mode.is_interlaced();
- params.refresh_rate = mode.refresh_rate();
- return params;
-}
-
-std::unique_ptr<display::DisplayMode> CreateDisplayModeFromParams(
- const DisplayMode_Params& pmode) {
- return std::make_unique<display::DisplayMode>(pmode.size, pmode.is_interlaced,
- pmode.refresh_rate);
-}
-
const gfx::Size ModeSize(const drmModeModeInfo& mode) {
return gfx::Size(mode.hdisplay, mode.vdisplay);
}
@@ -523,76 +504,6 @@ std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot(
maximum_cursor_size);
}
-// TODO(rjkroege): Remove in a subsequent CL once Mojo IPC is used everywhere.
-std::vector<DisplaySnapshot_Params> CreateDisplaySnapshotParams(
- const MovableDisplaySnapshots& displays) {
- std::vector<DisplaySnapshot_Params> params;
- for (auto& d : displays) {
- DisplaySnapshot_Params p;
-
- p.display_id = d->display_id();
- p.origin = d->origin();
- p.physical_size = d->physical_size();
- p.type = d->type();
- p.is_aspect_preserving_scaling = d->is_aspect_preserving_scaling();
- p.has_overscan = d->has_overscan();
- p.privacy_screen_state = d->privacy_screen_state();
- p.has_color_correction_matrix = d->has_color_correction_matrix();
- p.color_correction_in_linear_space = d->color_correction_in_linear_space();
- p.color_space = d->color_space();
- p.bits_per_channel = d->bits_per_channel();
- p.display_name = d->display_name();
- p.sys_path = d->sys_path();
-
- std::vector<DisplayMode_Params> mode_params;
- for (const auto& m : d->modes()) {
- mode_params.push_back(GetDisplayModeParams(*m));
- }
- p.modes = mode_params;
- p.panel_orientation = d->panel_orientation();
- p.edid = d->edid();
-
- p.has_current_mode = d->current_mode();
- if (d->current_mode())
- p.current_mode = GetDisplayModeParams(*d->current_mode());
-
- p.has_native_mode = d->native_mode();
- if (d->native_mode())
- p.native_mode = GetDisplayModeParams(*d->native_mode());
-
- p.product_code = d->product_code();
- p.year_of_manufacture = d->year_of_manufacture();
- p.maximum_cursor_size = d->maximum_cursor_size();
-
- params.push_back(p);
- }
- return params;
-}
-
-std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot(
- const DisplaySnapshot_Params& params) {
- display::DisplaySnapshot::DisplayModeList modes;
- const display::DisplayMode* current_mode = nullptr;
- const display::DisplayMode* native_mode = nullptr;
- for (const auto& mode : params.modes) {
- modes.push_back(CreateDisplayModeFromParams(mode));
- if (AreDisplayModesEqual(params.current_mode, mode))
- current_mode = modes.back().get();
- if (AreDisplayModesEqual(params.native_mode, mode))
- native_mode = modes.back().get();
- }
-
- return std::make_unique<display::DisplaySnapshot>(
- params.display_id, params.origin, params.physical_size, params.type,
- params.is_aspect_preserving_scaling, params.has_overscan,
- params.privacy_screen_state, params.has_color_correction_matrix,
- params.color_correction_in_linear_space, params.color_space,
- params.bits_per_channel, params.display_name, params.sys_path,
- std::move(modes), params.panel_orientation, params.edid, current_mode,
- native_mode, params.product_code, params.year_of_manufacture,
- params.maximum_cursor_size);
-}
-
int GetFourCCFormatForOpaqueFramebuffer(gfx::BufferFormat format) {
// DRM atomic interface doesn't currently support specifying an alpha
// blending. We can simulate disabling alpha bleding creating an fb
diff --git a/chromium/ui/ozone/platform/drm/common/drm_util.h b/chromium/ui/ozone/platform/drm/common/drm_util.h
index 74001bcb0d1..7fb2cebb77e 100644
--- a/chromium/ui/ozone/platform/drm/common/drm_util.h
+++ b/chromium/ui/ozone/platform/drm/common/drm_util.h
@@ -14,7 +14,6 @@
#include "base/files/file_path.h"
#include "base/macros.h"
#include "ui/display/types/display_snapshot.h"
-#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
#include "ui/ozone/platform/drm/common/display_types.h"
#include "ui/ozone/platform/drm/common/scoped_drm_types.h"
@@ -80,13 +79,6 @@ std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot(
size_t device_index,
const gfx::Point& origin);
-std::unique_ptr<display::DisplaySnapshot> CreateDisplaySnapshot(
- const DisplaySnapshot_Params& params);
-
-// Creates a serialized version of MovableDisplaySnapshots for IPC transmission.
-std::vector<DisplaySnapshot_Params> CreateDisplaySnapshotParams(
- const MovableDisplaySnapshots& displays);
-
int GetFourCCFormatForOpaqueFramebuffer(gfx::BufferFormat format);
gfx::Size GetMaximumCursorSize(int fd);
@@ -97,11 +89,6 @@ ScopedDrmPropertyPtr FindDrmProperty(int fd,
bool HasColorCorrectionMatrix(int fd, drmModeCrtc* crtc);
-DisplayMode_Params GetDisplayModeParams(const display::DisplayMode& mode);
-
-std::unique_ptr<display::DisplayMode> CreateDisplayModeFromParams(
- const DisplayMode_Params& pmode);
-
bool MatchMode(const display::DisplayMode& display_mode,
const drmModeModeInfo& m);
diff --git a/chromium/ui/ozone/platform/drm/common/drm_util_unittest.cc b/chromium/ui/ozone/platform/drm/common/drm_util_unittest.cc
index b81f31f265e..a0144bf0b10 100644
--- a/chromium/ui/ozone/platform/drm/common/drm_util_unittest.cc
+++ b/chromium/ui/ozone/platform/drm/common/drm_util_unittest.cc
@@ -16,170 +16,11 @@
#include "ui/display/types/display_snapshot.h"
#include "ui/display/util/edid_parser.h"
#include "ui/gfx/geometry/size.h"
-#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
namespace ui {
-bool operator==(const ui::DisplayMode_Params& a,
- const ui::DisplayMode_Params& b) {
- return a.size == b.size && a.is_interlaced == b.is_interlaced &&
- a.refresh_rate == b.refresh_rate;
-}
-
-bool operator==(const ui::DisplaySnapshot_Params& a,
- const ui::DisplaySnapshot_Params& b) {
- return a.display_id == b.display_id && a.origin == b.origin &&
- a.physical_size == b.physical_size && a.type == b.type &&
- a.is_aspect_preserving_scaling == b.is_aspect_preserving_scaling &&
- a.has_overscan == b.has_overscan &&
- a.has_color_correction_matrix == b.has_color_correction_matrix &&
- a.display_name == b.display_name && a.sys_path == b.sys_path &&
- std::equal(a.modes.cbegin(), a.modes.cend(), b.modes.cbegin()) &&
- std::equal(a.edid.cbegin(), a.edid.cend(), a.edid.cbegin()) &&
- a.has_current_mode == b.has_current_mode &&
- a.current_mode == b.current_mode &&
- a.has_native_mode == b.has_native_mode &&
- a.native_mode == b.native_mode && a.product_code == b.product_code &&
- a.year_of_manufacture == b.year_of_manufacture &&
- a.maximum_cursor_size == b.maximum_cursor_size;
-}
-
-namespace {
-
-DisplayMode_Params MakeDisplay(float refresh) {
- DisplayMode_Params params;
- params.size = gfx::Size(101, 42);
- params.is_interlaced = true;
- params.refresh_rate = refresh;
- return params;
-}
-
-void DetailedCompare(const ui::DisplaySnapshot_Params& a,
- const ui::DisplaySnapshot_Params& b) {
- EXPECT_EQ(a.display_id, b.display_id);
- EXPECT_EQ(a.origin, b.origin);
- EXPECT_EQ(a.physical_size, b.physical_size);
- EXPECT_EQ(a.type, b.type);
- EXPECT_EQ(a.is_aspect_preserving_scaling, b.is_aspect_preserving_scaling);
- EXPECT_EQ(a.has_overscan, b.has_overscan);
- EXPECT_EQ(a.has_color_correction_matrix, b.has_color_correction_matrix);
- EXPECT_EQ(a.color_space, b.color_space);
- EXPECT_EQ(a.bits_per_channel, b.bits_per_channel);
- EXPECT_EQ(a.display_name, b.display_name);
- EXPECT_EQ(a.sys_path, b.sys_path);
- EXPECT_EQ(a.modes, b.modes);
- EXPECT_EQ(a.edid, b.edid);
- EXPECT_EQ(a.has_current_mode, b.has_current_mode);
- EXPECT_EQ(a.current_mode, b.current_mode);
- EXPECT_EQ(a.has_native_mode, b.has_native_mode);
- EXPECT_EQ(a.native_mode, b.native_mode);
- EXPECT_EQ(a.product_code, b.product_code);
- EXPECT_EQ(a.year_of_manufacture, b.year_of_manufacture);
- EXPECT_EQ(a.maximum_cursor_size, b.maximum_cursor_size);
-}
-
-} // namespace
-
class DrmUtilTest : public testing::Test {};
-TEST_F(DrmUtilTest, RoundTripDisplayMode) {
- DisplayMode_Params orig_params = MakeDisplay(3.14);
-
- auto udm = CreateDisplayModeFromParams(orig_params);
- auto roundtrip_params = GetDisplayModeParams(*udm.get());
-
- EXPECT_EQ(orig_params.size.width(), roundtrip_params.size.width());
- EXPECT_EQ(orig_params.size.height(), roundtrip_params.size.height());
- EXPECT_EQ(orig_params.is_interlaced, roundtrip_params.is_interlaced);
- EXPECT_EQ(orig_params.refresh_rate, roundtrip_params.refresh_rate);
-}
-
-TEST_F(DrmUtilTest, RoundTripDisplaySnapshot) {
- std::vector<DisplaySnapshot_Params> orig_params;
- DisplaySnapshot_Params fp, sp, ep;
-
- fp.display_id = 101;
- fp.origin = gfx::Point(101, 42);
- fp.physical_size = gfx::Size(102, 43);
- fp.type = display::DISPLAY_CONNECTION_TYPE_INTERNAL;
- fp.is_aspect_preserving_scaling = true;
- fp.has_overscan = true;
- fp.has_color_correction_matrix = true;
- fp.color_space = gfx::ColorSpace::CreateREC709();
- fp.bits_per_channel = 8u;
- fp.display_name = "bending glass";
- fp.sys_path = base::FilePath("/bending");
- fp.modes =
- std::vector<DisplayMode_Params>({MakeDisplay(1.1), MakeDisplay(1.2)});
- fp.edid = std::vector<uint8_t>({'f', 'p'});
- fp.has_current_mode = true;
- fp.current_mode = MakeDisplay(1.2);
- fp.has_native_mode = true;
- fp.native_mode = MakeDisplay(1.1);
- fp.product_code = 7;
- fp.year_of_manufacture = 1776;
- fp.maximum_cursor_size = gfx::Size(103, 44);
-
- sp.display_id = 1002;
- sp.origin = gfx::Point(500, 42);
- sp.physical_size = gfx::Size(500, 43);
- sp.type = display::DISPLAY_CONNECTION_TYPE_INTERNAL;
- sp.is_aspect_preserving_scaling = true;
- sp.has_overscan = true;
- sp.has_color_correction_matrix = true;
- sp.color_space = gfx::ColorSpace::CreateExtendedSRGB();
- sp.bits_per_channel = 8u;
- sp.display_name = "rigid glass";
- sp.sys_path = base::FilePath("/bending");
- sp.modes =
- std::vector<DisplayMode_Params>({MakeDisplay(500.1), MakeDisplay(500.2)});
- sp.edid = std::vector<uint8_t>({'s', 'p'});
- sp.has_current_mode = false;
- sp.has_native_mode = true;
- sp.native_mode = MakeDisplay(500.2);
- sp.product_code = 8;
- sp.year_of_manufacture = 2018;
- sp.maximum_cursor_size = gfx::Size(500, 44);
-
- ep.display_id = 2002;
- ep.origin = gfx::Point(1000, 42);
- ep.physical_size = gfx::Size(1000, 43);
- ep.type = display::DISPLAY_CONNECTION_TYPE_INTERNAL;
- ep.is_aspect_preserving_scaling = false;
- ep.has_overscan = false;
- ep.has_color_correction_matrix = false;
- ep.color_space = gfx::ColorSpace::CreateDisplayP3D65();
- sp.bits_per_channel = 9u;
- ep.display_name = "fluted glass";
- ep.sys_path = base::FilePath("/bending");
- ep.modes = std::vector<DisplayMode_Params>(
- {MakeDisplay(1000.1), MakeDisplay(1000.2)});
- ep.edid = std::vector<uint8_t>({'s', 'p'});
- ep.has_current_mode = true;
- ep.current_mode = MakeDisplay(1000.2);
- ep.has_native_mode = false;
- ep.product_code = 9;
- ep.year_of_manufacture = 2000;
- ep.maximum_cursor_size = gfx::Size(1000, 44);
-
- orig_params.push_back(fp);
- orig_params.push_back(sp);
- orig_params.push_back(ep);
-
- MovableDisplaySnapshots intermediate_snapshots;
- for (const auto& snapshot_params : orig_params)
- intermediate_snapshots.push_back(CreateDisplaySnapshot(snapshot_params));
-
- std::vector<DisplaySnapshot_Params> roundtrip_params =
- CreateDisplaySnapshotParams(intermediate_snapshots);
-
- DetailedCompare(fp, roundtrip_params[0]);
-
- EXPECT_EQ(fp, roundtrip_params[0]);
- EXPECT_EQ(sp, roundtrip_params[1]);
- EXPECT_EQ(ep, roundtrip_params[2]);
-}
-
TEST_F(DrmUtilTest, TestDisplayModesExtraction) {
// Initialize a list of display modes.
constexpr size_t kNumModes = 5;
diff --git a/chromium/ui/ozone/platform/drm/gpu/crtc_controller.cc b/chromium/ui/ozone/platform/drm/gpu/crtc_controller.cc
index adf1285bb7b..a7b0de83828 100644
--- a/chromium/ui/ozone/platform/drm/gpu/crtc_controller.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/crtc_controller.cc
@@ -76,11 +76,8 @@ bool CrtcController::Disable() {
}
bool CrtcController::AssignOverlayPlanes(HardwareDisplayPlaneList* plane_list,
- const DrmOverlayPlaneList& overlays,
- bool is_modesetting) {
- // If we're in the process of modesetting, the CRTC is still disabled.
- // Once the modeset is done, we expect it to be enabled.
- DCHECK(is_modesetting || !is_disabled_);
+ const DrmOverlayPlaneList& overlays) {
+ DCHECK(!is_disabled_);
const DrmOverlayPlane* primary = DrmOverlayPlane::GetPrimaryPlane(overlays);
if (primary && !drm_->plane_manager()->ValidatePrimarySize(*primary, mode_)) {
diff --git a/chromium/ui/ozone/platform/drm/gpu/crtc_controller.h b/chromium/ui/ozone/platform/drm/gpu/crtc_controller.h
index 258093f28fc..52dbd6c9458 100644
--- a/chromium/ui/ozone/platform/drm/gpu/crtc_controller.h
+++ b/chromium/ui/ozone/platform/drm/gpu/crtc_controller.h
@@ -51,8 +51,7 @@ class CrtcController {
bool Disable();
bool AssignOverlayPlanes(HardwareDisplayPlaneList* plane_list,
- const DrmOverlayPlaneList& planes,
- bool is_modesetting);
+ const DrmOverlayPlaneList& planes);
// Returns a vector of format modifiers for the given fourcc format
// on this CRTCs primary plane. A format modifier describes the
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_display.h b/chromium/ui/ozone/platform/drm/gpu/drm_display.h
index b6a1d08f9b2..de721282b28 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_display.h
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_display.h
@@ -14,7 +14,6 @@
#include "base/memory/ref_counted.h"
#include "ui/display/types/display_constants.h"
#include "ui/gfx/geometry/point.h"
-#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
#include "ui/ozone/platform/drm/common/scoped_drm_types.h"
typedef struct _drmModeModeInfo drmModeModeInfo;
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h b/chromium/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h
index 885732aaaaf..5efd37fde04 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h
@@ -11,8 +11,9 @@
#include "base/callback.h"
#include "base/macros.h"
+#include "ui/display/types/display_constants.h"
+#include "ui/gfx/geometry/point.h"
#include "ui/gfx/native_widget_types.h"
-#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
#include "ui/ozone/platform/drm/common/display_types.h"
namespace display {
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_overlay_validator_unittest.cc b/chromium/ui/ozone/platform/drm/gpu/drm_overlay_validator_unittest.cc
index cc86756bdf3..c4de6cc393e 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_overlay_validator_unittest.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_overlay_validator_unittest.cc
@@ -17,7 +17,6 @@
#include "ui/gfx/linux/drm_util_linux.h"
#include "ui/gfx/linux/gbm_buffer.h"
#include "ui/gfx/linux/test/mock_gbm_device.h"
-#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
#include "ui/ozone/platform/drm/common/drm_util.h"
#include "ui/ozone/platform/drm/gpu/crtc_controller.h"
#include "ui/ozone/platform/drm/gpu/drm_device_generator.h"
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_thread.cc b/chromium/ui/ozone/platform/drm/gpu/drm_thread.cc
index 33e3370b983..181fcd86a18 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_thread.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_thread.cc
@@ -92,17 +92,15 @@ void DrmThread::Start(base::OnceClosure receiver_completer,
LOG(FATAL) << "Failed to create DRM thread";
}
-void DrmThread::RunTaskAfterWindowReady(gfx::AcceleratedWidget window,
- base::OnceClosure task,
+void DrmThread::RunTaskAfterDeviceReady(base::OnceClosure task,
base::WaitableEvent* done) {
- if (!device_manager_->GetDrmDevices().empty() &&
- window <= last_created_window_) {
+ if (!device_manager_->GetDrmDevices().empty()) {
std::move(task).Run();
if (done)
done->Signal();
return;
}
- pending_tasks_[window].emplace_back(std::move(task), done);
+ pending_tasks_.emplace_back(std::move(task), done);
}
void DrmThread::Init() {
@@ -411,17 +409,13 @@ void DrmThread::AddDrmDeviceReceiver(
void DrmThread::ProcessPendingTasks() {
DCHECK(!device_manager_->GetDrmDevices().empty());
- auto it = pending_tasks_.begin();
- for (; it != pending_tasks_.end() && it->first <= last_created_window_;
- ++it) {
- for (auto& task_info : it->second) {
- std::move(task_info.task).Run();
- if (task_info.done)
- task_info.done->Signal();
- }
+ for (auto& task_info : pending_tasks_) {
+ std::move(task_info.task).Run();
+ if (task_info.done)
+ task_info.done->Signal();
}
- pending_tasks_.erase(pending_tasks_.begin(), it);
+ pending_tasks_.clear();
}
} // namespace ui
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_thread.h b/chromium/ui/ozone/platform/drm/gpu/drm_thread.h
index 69586599c7d..b4ec4298339 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_thread.h
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_thread.h
@@ -20,7 +20,6 @@
#include "ui/gfx/native_pixmap_handle.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/vsync_provider.h"
-#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
#include "ui/ozone/platform/drm/common/display_types.h"
#include "ui/ozone/platform/drm/gpu/drm_device_generator.h"
#include "ui/ozone/public/mojom/device_cursor.mojom.h"
@@ -74,10 +73,9 @@ class DrmThread : public base::Thread,
void Start(base::OnceClosure receiver_completer,
std::unique_ptr<DrmDeviceGenerator> device_generator);
- // Runs |task| once a DrmDevice is registered and |window| was created via
- // CreateWindow(). |done| will be signaled if it's not null.
- void RunTaskAfterWindowReady(gfx::AcceleratedWidget window,
- base::OnceClosure task,
+ // Runs |task| once a DrmDevice is registered. |done|
+ // will be signaled if it's not null.
+ void RunTaskAfterDeviceReady(base::OnceClosure task,
base::WaitableEvent* done);
// Must be called on the DRM thread. All methods for use from the GPU thread.
@@ -218,9 +216,8 @@ class DrmThread : public base::Thread,
// The AcceleratedWidget from the last call to CreateWindow.
gfx::AcceleratedWidget last_created_window_ = gfx::kNullAcceleratedWidget;
- // The tasks that are blocked on a DrmDevice and a certain AcceleratedWidget
- // becoming available.
- base::flat_map<gfx::AcceleratedWidget, std::vector<TaskInfo>> pending_tasks_;
+ // The tasks that are blocked on a DrmDevice becoming available.
+ std::vector<TaskInfo> pending_tasks_;
// Holds the DrmDeviceGenerator that DrmDeviceManager will use. Will be passed
// on to DrmDeviceManager after the thread starts.
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_thread_message_proxy.cc b/chromium/ui/ozone/platform/drm/gpu/drm_thread_message_proxy.cc
deleted file mode 100644
index f7072c320e1..00000000000
--- a/chromium/ui/ozone/platform/drm/gpu/drm_thread_message_proxy.cc
+++ /dev/null
@@ -1,286 +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 "ui/ozone/platform/drm/gpu/drm_thread_message_proxy.h"
-
-#include <utility>
-
-#include "base/bind.h"
-#include "base/task_runner_util.h"
-#include "base/threading/thread_task_runner_handle.h"
-#include "ipc/ipc_message.h"
-#include "ipc/ipc_sender.h"
-#include "ui/display/types/display_snapshot.h"
-#include "ui/ozone/common/gpu/ozone_gpu_messages.h"
-#include "ui/ozone/platform/drm/common/drm_util.h"
-#include "ui/ozone/platform/drm/gpu/drm_thread_proxy.h"
-#include "ui/ozone/platform/drm/gpu/proxy_helpers.h"
-
-namespace ui {
-
-DrmThreadMessageProxy::DrmThreadMessageProxy() {}
-
-DrmThreadMessageProxy::~DrmThreadMessageProxy() {}
-
-void DrmThreadMessageProxy::SetDrmThread(DrmThread* thread) {
- drm_thread_ = thread;
-}
-
-void DrmThreadMessageProxy::OnFilterAdded(IPC::Channel* channel) {
- sender_ = channel;
-}
-
-bool DrmThreadMessageProxy::OnMessageReceived(const IPC::Message& message) {
- bool handled = true;
-
- IPC_BEGIN_MESSAGE_MAP(DrmThreadMessageProxy, message)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_CreateWindow, OnCreateWindow)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_DestroyWindow, OnDestroyWindow)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_WindowBoundsChanged, OnWindowBoundsChanged)
-
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorSet, OnCursorSet)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_CursorMove, OnCursorMove)
-
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_RefreshNativeDisplays,
- OnRefreshNativeDisplays)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_ConfigureNativeDisplay,
- OnConfigureNativeDisplay)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_DisableNativeDisplay,
- OnDisableNativeDisplay)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_TakeDisplayControl, OnTakeDisplayControl)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_RelinquishDisplayControl,
- OnRelinquishDisplayControl)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_AddGraphicsDevice, OnAddGraphicsDevice)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_RemoveGraphicsDevice,
- OnRemoveGraphicsDevice)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_GetHDCPState, OnGetHDCPState)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_SetHDCPState, OnSetHDCPState)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_SetColorMatrix, OnSetColorMatrix)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_SetGammaCorrection, OnSetGammaCorrection)
- IPC_MESSAGE_HANDLER(OzoneGpuMsg_SetPrivacyScreen, OnSetPrivacyScreen)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
-
- return handled;
-}
-
-void DrmThreadMessageProxy::OnCreateWindow(gfx::AcceleratedWidget widget,
- const gfx::Rect& initial_bounds) {
- DCHECK(drm_thread_->IsRunning());
- drm_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::BindOnce(&DrmThread::CreateWindow, base::Unretained(drm_thread_),
- widget, initial_bounds));
-}
-
-void DrmThreadMessageProxy::OnDestroyWindow(gfx::AcceleratedWidget widget) {
- DCHECK(drm_thread_->IsRunning());
- drm_thread_->task_runner()->PostTask(
- FROM_HERE, base::BindOnce(&DrmThread::DestroyWindow,
- base::Unretained(drm_thread_), widget));
-}
-
-void DrmThreadMessageProxy::OnWindowBoundsChanged(gfx::AcceleratedWidget widget,
- const gfx::Rect& bounds) {
- DCHECK(drm_thread_->IsRunning());
- drm_thread_->task_runner()->PostTask(
- FROM_HERE, base::BindOnce(&DrmThread::SetWindowBounds,
- base::Unretained(drm_thread_), widget, bounds));
-}
-
-void DrmThreadMessageProxy::OnCursorSet(gfx::AcceleratedWidget widget,
- const std::vector<SkBitmap>& bitmaps,
- const gfx::Point& location,
- int frame_delay_ms) {
- DCHECK(drm_thread_->IsRunning());
- drm_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::BindOnce(&DrmThread::SetCursor, base::Unretained(drm_thread_),
- widget, bitmaps, location, frame_delay_ms));
-}
-
-void DrmThreadMessageProxy::OnCursorMove(gfx::AcceleratedWidget widget,
- const gfx::Point& location) {
- DCHECK(drm_thread_->IsRunning());
- drm_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::BindOnce(&DrmThread::MoveCursor, base::Unretained(drm_thread_),
- widget, location));
-}
-
-void DrmThreadMessageProxy::OnRefreshNativeDisplays() {
- DCHECK(drm_thread_->IsRunning());
- auto callback =
- base::BindOnce(&DrmThreadMessageProxy::OnRefreshNativeDisplaysCallback,
- weak_ptr_factory_.GetWeakPtr());
- auto safe_callback = CreateSafeOnceCallback(std::move(callback));
- drm_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::BindOnce(&DrmThread::RefreshNativeDisplays,
- base::Unretained(drm_thread_), std::move(safe_callback)));
-}
-
-void DrmThreadMessageProxy::OnConfigureNativeDisplay(
- int64_t id,
- const DisplayMode_Params& mode,
- const gfx::Point& origin) {
- DCHECK(drm_thread_->IsRunning());
- auto dmode = CreateDisplayModeFromParams(mode);
- auto callback =
- base::BindOnce(&DrmThreadMessageProxy::OnConfigureNativeDisplayCallback,
- weak_ptr_factory_.GetWeakPtr());
- auto safe_callback = CreateSafeOnceCallback(std::move(callback));
- drm_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::BindOnce(&DrmThread::ConfigureNativeDisplay,
- base::Unretained(drm_thread_), id, std::move(dmode),
- origin, std::move(safe_callback)));
-}
-
-void DrmThreadMessageProxy::OnDisableNativeDisplay(int64_t id) {
- DCHECK(drm_thread_->IsRunning());
- auto callback =
- base::BindOnce(&DrmThreadMessageProxy::OnDisableNativeDisplayCallback,
- weak_ptr_factory_.GetWeakPtr());
- auto safe_callback = CreateSafeOnceCallback(std::move(callback));
- drm_thread_->task_runner()->PostTask(
- FROM_HERE, base::BindOnce(&DrmThread::DisableNativeDisplay,
- base::Unretained(drm_thread_), id,
- std::move(safe_callback)));
-}
-
-void DrmThreadMessageProxy::OnTakeDisplayControl() {
- DCHECK(drm_thread_->IsRunning());
- auto callback =
- base::BindOnce(&DrmThreadMessageProxy::OnTakeDisplayControlCallback,
- weak_ptr_factory_.GetWeakPtr());
- auto safe_callback = CreateSafeOnceCallback(std::move(callback));
- drm_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::BindOnce(&DrmThread::TakeDisplayControl,
- base::Unretained(drm_thread_), std::move(safe_callback)));
-}
-
-void DrmThreadMessageProxy::OnRelinquishDisplayControl() {
- DCHECK(drm_thread_->IsRunning());
- auto callback =
- base::BindOnce(&DrmThreadMessageProxy::OnRelinquishDisplayControlCallback,
- weak_ptr_factory_.GetWeakPtr());
- auto safe_callback = CreateSafeOnceCallback(std::move(callback));
- drm_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::BindOnce(&DrmThread::RelinquishDisplayControl,
- base::Unretained(drm_thread_), std::move(safe_callback)));
-}
-
-void DrmThreadMessageProxy::OnAddGraphicsDevice(
- const base::FilePath& path,
- const base::FileDescriptor& fd) {
- DCHECK(drm_thread_->IsRunning());
- base::File file(fd.fd);
- drm_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::BindOnce(&DrmThread::AddGraphicsDevice,
- base::Unretained(drm_thread_), path, std::move(file)));
-}
-
-void DrmThreadMessageProxy::OnRemoveGraphicsDevice(const base::FilePath& path) {
- DCHECK(drm_thread_->IsRunning());
- drm_thread_->task_runner()->PostTask(
- FROM_HERE, base::BindOnce(&DrmThread::RemoveGraphicsDevice,
- base::Unretained(drm_thread_), path));
-}
-
-void DrmThreadMessageProxy::OnGetHDCPState(int64_t display_id) {
- DCHECK(drm_thread_->IsRunning());
- auto callback = base::BindOnce(&DrmThreadMessageProxy::OnGetHDCPStateCallback,
- weak_ptr_factory_.GetWeakPtr());
- auto safe_callback = CreateSafeOnceCallback(std::move(callback));
- drm_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::BindOnce(&DrmThread::GetHDCPState, base::Unretained(drm_thread_),
- display_id, std::move(safe_callback)));
-}
-
-void DrmThreadMessageProxy::OnSetHDCPState(int64_t display_id,
- display::HDCPState state) {
- DCHECK(drm_thread_->IsRunning());
- auto callback = base::BindOnce(&DrmThreadMessageProxy::OnSetHDCPStateCallback,
- weak_ptr_factory_.GetWeakPtr());
- auto safe_callback = CreateSafeOnceCallback(std::move(callback));
- drm_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::BindOnce(&DrmThread::SetHDCPState, base::Unretained(drm_thread_),
- display_id, state, std::move(safe_callback)));
-}
-
-void DrmThreadMessageProxy::OnSetColorMatrix(
- int64_t display_id,
- const std::vector<float>& color_matrix) {
- DCHECK(drm_thread_->IsRunning());
- drm_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::BindOnce(&DrmThread::SetColorMatrix, base::Unretained(drm_thread_),
- display_id, color_matrix));
-}
-
-void DrmThreadMessageProxy::OnSetGammaCorrection(
- int64_t display_id,
- const std::vector<display::GammaRampRGBEntry>& degamma_lut,
- const std::vector<display::GammaRampRGBEntry>& gamma_lut) {
- DCHECK(drm_thread_->IsRunning());
- drm_thread_->task_runner()->PostTask(
- FROM_HERE, base::BindOnce(&DrmThread::SetGammaCorrection,
- base::Unretained(drm_thread_), display_id,
- degamma_lut, gamma_lut));
-}
-
-void DrmThreadMessageProxy::OnSetPrivacyScreen(int64_t display_id,
- bool enabled) {
- DCHECK(drm_thread_->IsRunning());
- drm_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::BindOnce(&DrmThread::SetPrivacyScreen,
- base::Unretained(drm_thread_), display_id, enabled));
-}
-
-void DrmThreadMessageProxy::OnRefreshNativeDisplaysCallback(
- MovableDisplaySnapshots displays) const {
- sender_->Send(new OzoneHostMsg_UpdateNativeDisplays(
- CreateDisplaySnapshotParams(displays)));
-}
-
-void DrmThreadMessageProxy::OnConfigureNativeDisplayCallback(
- int64_t display_id,
- bool success) const {
- sender_->Send(new OzoneHostMsg_DisplayConfigured(display_id, success));
-}
-
-void DrmThreadMessageProxy::OnDisableNativeDisplayCallback(int64_t display_id,
- bool success) const {
- sender_->Send(new OzoneHostMsg_DisplayConfigured(display_id, success));
-}
-
-void DrmThreadMessageProxy::OnTakeDisplayControlCallback(bool success) const {
- sender_->Send(new OzoneHostMsg_DisplayControlTaken(success));
-}
-
-void DrmThreadMessageProxy::OnRelinquishDisplayControlCallback(
- bool success) const {
- sender_->Send(new OzoneHostMsg_DisplayControlRelinquished(success));
-}
-
-void DrmThreadMessageProxy::OnGetHDCPStateCallback(
- int64_t display_id,
- bool success,
- display::HDCPState state) const {
- sender_->Send(new OzoneHostMsg_HDCPStateReceived(display_id, success, state));
-}
-
-void DrmThreadMessageProxy::OnSetHDCPStateCallback(int64_t display_id,
- bool success) const {
- sender_->Send(new OzoneHostMsg_HDCPStateUpdated(display_id, success));
-}
-
-} // namespace ui
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_thread_message_proxy.h b/chromium/ui/ozone/platform/drm/gpu/drm_thread_message_proxy.h
deleted file mode 100644
index 55407d6d44f..00000000000
--- a/chromium/ui/ozone/platform/drm/gpu/drm_thread_message_proxy.h
+++ /dev/null
@@ -1,100 +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 UI_OZONE_PLATFORM_DRM_GPU_DRM_THREAD_MESSAGE_PROXY_H_
-#define UI_OZONE_PLATFORM_DRM_GPU_DRM_THREAD_MESSAGE_PROXY_H_
-
-#include <stdint.h>
-
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "ipc/message_filter.h"
-#include "ui/display/types/display_constants.h"
-#include "ui/display/types/gamma_ramp_rgb_entry.h"
-#include "ui/gfx/native_widget_types.h"
-#include "ui/ozone/platform/drm/common/display_types.h"
-#include "ui/ozone/platform/drm/gpu/inter_thread_messaging_proxy.h"
-
-namespace base {
-struct FileDescriptor;
-class FilePath;
-}
-
-namespace gfx {
-class Point;
-class Rect;
-}
-
-namespace ui {
-class DrmThread;
-struct DisplayMode_Params;
-
-class DrmThreadMessageProxy : public IPC::MessageFilter,
- public InterThreadMessagingProxy {
- public:
- DrmThreadMessageProxy();
-
- // InterThreadMessagingProxy.
- void SetDrmThread(DrmThread* thread) override;
-
- // IPC::MessageFilter:
- void OnFilterAdded(IPC::Channel* channel) override;
- bool OnMessageReceived(const IPC::Message& message) override;
-
- private:
- ~DrmThreadMessageProxy() override;
-
- void OnCreateWindow(gfx::AcceleratedWidget widget,
- const gfx::Rect& initial_bounds);
- void OnDestroyWindow(gfx::AcceleratedWidget widget);
- void OnWindowBoundsChanged(gfx::AcceleratedWidget widget,
- const gfx::Rect& bounds);
- void OnCursorSet(gfx::AcceleratedWidget widget,
- const std::vector<SkBitmap>& bitmaps,
- const gfx::Point& location,
- int frame_delay_ms);
- void OnCursorMove(gfx::AcceleratedWidget widget, const gfx::Point& location);
-
- // Display related IPC handlers.
- void OnRefreshNativeDisplays();
- void OnConfigureNativeDisplay(int64_t id,
- const DisplayMode_Params& mode,
- const gfx::Point& origin);
- void OnDisableNativeDisplay(int64_t id);
- void OnTakeDisplayControl();
- void OnRelinquishDisplayControl();
- void OnAddGraphicsDevice(const base::FilePath& path,
- const base::FileDescriptor& fd);
- void OnRemoveGraphicsDevice(const base::FilePath& path);
- void OnGetHDCPState(int64_t display_id);
- void OnSetHDCPState(int64_t display_id, display::HDCPState state);
- void OnSetColorMatrix(int64_t display_id,
- const std::vector<float>& color_matrix);
- void OnSetGammaCorrection(
- int64_t display_id,
- const std::vector<display::GammaRampRGBEntry>& degamma_lut,
- const std::vector<display::GammaRampRGBEntry>& gamma_lut);
- void OnSetPrivacyScreen(int64_t display_id, bool enabled);
- void OnRefreshNativeDisplaysCallback(MovableDisplaySnapshots displays) const;
- void OnConfigureNativeDisplayCallback(int64_t display_id, bool success) const;
- void OnDisableNativeDisplayCallback(int64_t display_id, bool success) const;
- void OnTakeDisplayControlCallback(bool success) const;
- void OnRelinquishDisplayControlCallback(bool success) const;
- void OnGetHDCPStateCallback(int64_t display_id,
- bool success,
- display::HDCPState state) const;
- void OnSetHDCPStateCallback(int64_t display_id, bool success) const;
-
- DrmThread* drm_thread_ = nullptr;
-
- IPC::Sender* sender_ = nullptr;
-
- base::WeakPtrFactory<DrmThreadMessageProxy> weak_ptr_factory_{this};
-
- DISALLOW_COPY_AND_ASSIGN(DrmThreadMessageProxy);
-};
-
-} // namespace ui
-
-#endif // UI_OZONE_PLATFORM_DRM_GPU_DRM_THREAD_MESSAGE_PROXY_H_
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_thread_proxy.cc b/chromium/ui/ozone/platform/drm/gpu/drm_thread_proxy.cc
index 8a0178c20e9..685cd8fcea8 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_thread_proxy.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_thread_proxy.cc
@@ -8,10 +8,10 @@
#include <utility>
#include "base/bind.h"
+#include "base/trace_event/trace_event.h"
#include "ui/gfx/linux/gbm_wrapper.h"
#include "ui/ozone/platform/drm/gpu/drm_device.h"
#include "ui/ozone/platform/drm/gpu/drm_device_generator.h"
-#include "ui/ozone/platform/drm/gpu/drm_thread_message_proxy.h"
#include "ui/ozone/platform/drm/gpu/drm_window_proxy.h"
#include "ui/ozone/platform/drm/gpu/gbm_pixmap.h"
#include "ui/ozone/platform/drm/gpu/proxy_helpers.h"
@@ -62,12 +62,6 @@ DrmThreadProxy::DrmThreadProxy() = default;
DrmThreadProxy::~DrmThreadProxy() = default;
-// Used only with the paramtraits implementation.
-void DrmThreadProxy::BindThreadIntoMessagingProxy(
- InterThreadMessagingProxy* messaging_proxy) {
- messaging_proxy->SetDrmThread(&drm_thread_);
-}
-
void DrmThreadProxy::StartDrmThread(base::OnceClosure receiver_drainer) {
drm_thread_.Start(std::move(receiver_drainer),
std::make_unique<GbmDeviceGenerator>());
@@ -93,10 +87,9 @@ void DrmThreadProxy::CreateBuffer(gfx::AcceleratedWidget widget,
base::OnceClosure task = base::BindOnce(
&DrmThread::CreateBuffer, base::Unretained(&drm_thread_), widget, size,
framebuffer_size, format, usage, flags, buffer, framebuffer);
- PostSyncTask(
- drm_thread_.task_runner(),
- base::BindOnce(&DrmThread::RunTaskAfterWindowReady,
- base::Unretained(&drm_thread_), widget, std::move(task)));
+ PostSyncTask(drm_thread_.task_runner(),
+ base::BindOnce(&DrmThread::RunTaskAfterDeviceReady,
+ base::Unretained(&drm_thread_), std::move(task)));
}
void DrmThreadProxy::CreateBufferAsync(gfx::AcceleratedWidget widget,
@@ -112,15 +105,10 @@ void DrmThreadProxy::CreateBufferAsync(gfx::AcceleratedWidget widget,
size, format, usage, flags,
base::BindOnce(OnBufferCreatedOnDrmThread,
base::ThreadTaskRunnerHandle::Get(), std::move(callback)));
- // Since browser's UI thread blocks until a buffer is returned, we shouldn't
- // block on |widget| because a blocked UI thread cannot register |widget| and
- // causes a deadlock. We still want to block on a graphics device, though.
- // TODO(samans): Remove this hack once OOP-D launches.
- gfx::AcceleratedWidget blocking_widget = gfx::kNullAcceleratedWidget;
drm_thread_.task_runner()->PostTask(
- FROM_HERE, base::BindOnce(&DrmThread::RunTaskAfterWindowReady,
- base::Unretained(&drm_thread_), blocking_widget,
- std::move(task), nullptr));
+ FROM_HERE,
+ base::BindOnce(&DrmThread::RunTaskAfterDeviceReady,
+ base::Unretained(&drm_thread_), std::move(task), nullptr));
}
void DrmThreadProxy::CreateBufferFromHandle(
@@ -135,10 +123,9 @@ void DrmThreadProxy::CreateBufferFromHandle(
base::OnceClosure task = base::BindOnce(
&DrmThread::CreateBufferFromHandle, base::Unretained(&drm_thread_),
widget, size, format, std::move(handle), buffer, framebuffer);
- PostSyncTask(
- drm_thread_.task_runner(),
- base::BindOnce(&DrmThread::RunTaskAfterWindowReady,
- base::Unretained(&drm_thread_), widget, std::move(task)));
+ PostSyncTask(drm_thread_.task_runner(),
+ base::BindOnce(&DrmThread::RunTaskAfterDeviceReady,
+ base::Unretained(&drm_thread_), std::move(task)));
}
void DrmThreadProxy::SetClearOverlayCacheCallback(
@@ -162,9 +149,9 @@ void DrmThreadProxy::CheckOverlayCapabilities(
widget, candidates, CreateSafeOnceCallback(std::move(callback)));
drm_thread_.task_runner()->PostTask(
- FROM_HERE, base::BindOnce(&DrmThread::RunTaskAfterWindowReady,
- base::Unretained(&drm_thread_), widget,
- std::move(task), nullptr));
+ FROM_HERE,
+ base::BindOnce(&DrmThread::RunTaskAfterDeviceReady,
+ base::Unretained(&drm_thread_), std::move(task), nullptr));
}
std::vector<OverlayStatus> DrmThreadProxy::CheckOverlayCapabilitiesSync(
@@ -177,10 +164,9 @@ std::vector<OverlayStatus> DrmThreadProxy::CheckOverlayCapabilitiesSync(
base::OnceClosure task = base::BindOnce(
&DrmThread::CheckOverlayCapabilitiesSync, base::Unretained(&drm_thread_),
widget, candidates, &result);
- PostSyncTask(
- drm_thread_.task_runner(),
- base::BindOnce(&DrmThread::RunTaskAfterWindowReady,
- base::Unretained(&drm_thread_), widget, std::move(task)));
+ PostSyncTask(drm_thread_.task_runner(),
+ base::BindOnce(&DrmThread::RunTaskAfterDeviceReady,
+ base::Unretained(&drm_thread_), std::move(task)));
return result;
}
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_thread_unittest.cc b/chromium/ui/ozone/platform/drm/gpu/drm_thread_unittest.cc
index fdd7a2e3785..91005483ddd 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_thread_unittest.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_thread_unittest.cc
@@ -50,25 +50,24 @@ class DrmThreadTest : public testing::Test {
drm_thread_.FlushForTesting();
}
- std::unique_ptr<base::WaitableEvent> PostStubTaskWithWaitableEvent(
- gfx::AcceleratedWidget window) {
+ std::unique_ptr<base::WaitableEvent> PostStubTaskWithWaitableEvent() {
base::OnceClosure task = base::BindOnce(StubTask);
auto event = std::make_unique<base::WaitableEvent>(
base::WaitableEvent::ResetPolicy::AUTOMATIC,
base::WaitableEvent::InitialState::NOT_SIGNALED);
drm_thread_.task_runner()->PostTask(
- FROM_HERE, base::BindOnce(&DrmThread::RunTaskAfterWindowReady,
- base::Unretained(&drm_thread_), window,
+ FROM_HERE, base::BindOnce(&DrmThread::RunTaskAfterDeviceReady,
+ base::Unretained(&drm_thread_),
std::move(task), event.get()));
return event;
}
- void PostStubTask(gfx::AcceleratedWidget window, bool* done) {
+ void PostStubTask(bool* done) {
*done = false;
base::OnceClosure task = base::BindOnce(StubTaskWithDoneFeedback, done);
drm_thread_.task_runner()->PostTask(
- FROM_HERE, base::BindOnce(&DrmThread::RunTaskAfterWindowReady,
- base::Unretained(&drm_thread_), window,
+ FROM_HERE, base::BindOnce(&DrmThread::RunTaskAfterDeviceReady,
+ base::Unretained(&drm_thread_),
std::move(task), nullptr));
}
@@ -84,87 +83,30 @@ class DrmThreadTest : public testing::Test {
mojo::Remote<ozone::mojom::DrmDevice> drm_device_;
};
-TEST_F(DrmThreadTest, RunTaskAfterWindowReady) {
- constexpr gfx::Rect bounds(10, 10);
- bool called1 = false, called2 = false;
- gfx::AcceleratedWidget widget1 = 1, widget2 = 2;
+TEST_F(DrmThreadTest, RunTaskAfterDeviceReady) {
+ bool called = false;
- // Post a task not blocked on any window. It should still block on a graphics
- // device becoming available.
- PostStubTask(gfx::kNullAcceleratedWidget, &called1);
+ // Post 2 tasks. One with WaitableEvent and one without. They should block on
+ // a graphics device becoming available.
+ std::unique_ptr<base::WaitableEvent> event = PostStubTaskWithWaitableEvent();
+ PostStubTask(&called);
drm_thread_.FlushForTesting();
- EXPECT_FALSE(called1);
+ EXPECT_FALSE(event->IsSignaled());
+ EXPECT_FALSE(called);
- // Add the graphics device. The task should run.
+ // Add the graphics device. The tasks should run.
AddGraphicsDevice();
drm_thread_.FlushForTesting();
- ASSERT_TRUE(called1);
-
- // Now that a graphics device is available, further tasks that don't block on
- // any window should execute immediately.
- PostStubTask(gfx::kNullAcceleratedWidget, &called1);
- drm_thread_.FlushForTesting();
- ASSERT_TRUE(called1);
-
- // Post a task blocked on |widget1|. It shouldn't run.
- PostStubTask(widget1, &called1);
- drm_thread_.FlushForTesting();
- ASSERT_FALSE(called1);
-
- // Post two tasks blocked on |widget2|, one with a WaitableEvent and one
- // without. They shouldn't run.
- std::unique_ptr<base::WaitableEvent> event =
- PostStubTaskWithWaitableEvent(widget2);
- PostStubTask(widget2, &called2);
- drm_thread_.FlushForTesting();
- ASSERT_FALSE(event->IsSignaled());
- ASSERT_FALSE(called2);
-
- // Now create |widget1|. The first task should run.
- drm_device_->CreateWindow(widget1, bounds);
- drm_thread_.FlushForTesting();
- ASSERT_TRUE(called1);
- ASSERT_FALSE(event->IsSignaled());
- ASSERT_FALSE(called2);
-
- // Now that |widget1| is created. any further task depending on it should run
- // immediately.
- PostStubTask(widget1, &called1);
- drm_thread_.FlushForTesting();
- ASSERT_TRUE(called1);
- ASSERT_FALSE(event->IsSignaled());
- ASSERT_FALSE(called2);
-
- // Destroy |widget1| and post a task blocked on it. The task should still run
- // immediately even though the window is destroyed.
- drm_device_->DestroyWindow(widget1);
- PostStubTask(widget1, &called1);
- drm_thread_.FlushForTesting();
- ASSERT_TRUE(called1);
- ASSERT_FALSE(event->IsSignaled());
- ASSERT_FALSE(called2);
-
- // Create |widget2|. The two blocked tasks should run.
- drm_device_->CreateWindow(widget2, bounds);
- drm_thread_.FlushForTesting();
ASSERT_TRUE(event->IsSignaled());
- ASSERT_TRUE(called2);
+ ASSERT_TRUE(called);
- // Post another task blocked on |widget1| with a WaitableEvent. It should run
+ // Now that a graphics device is available, further tasks should execute
// immediately.
- event = PostStubTaskWithWaitableEvent(widget1);
+ event = PostStubTaskWithWaitableEvent();
+ PostStubTask(&called);
drm_thread_.FlushForTesting();
ASSERT_TRUE(event->IsSignaled());
-
- // Post another task blocked on |widget2| with a WaitableEvent. It should run
- // immediately.
- event = PostStubTaskWithWaitableEvent(widget2);
- drm_thread_.FlushForTesting();
- ASSERT_TRUE(event->IsSignaled());
-
- // Destroy |widget2| to avoid failures during tear down.
- drm_device_->DestroyWindow(widget2);
- drm_thread_.FlushForTesting();
+ ASSERT_TRUE(called);
}
// Verifies that we gracefully handle the case where CheckOverlayCapabilities()
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_window.cc b/chromium/ui/ozone/platform/drm/gpu/drm_window.cc
index 310e2e72600..ec3aa6b951d 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_window.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_window.cc
@@ -16,7 +16,6 @@
#include "third_party/skia/include/core/SkSurface.h"
#include "ui/gfx/gpu_fence.h"
#include "ui/gfx/presentation_feedback.h"
-#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
#include "ui/ozone/platform/drm/common/drm_util.h"
#include "ui/ozone/platform/drm/gpu/crtc_controller.h"
#include "ui/ozone/platform/drm/gpu/drm_device.h"
diff --git a/chromium/ui/ozone/platform/drm/gpu/drm_window_proxy.cc b/chromium/ui/ozone/platform/drm/gpu/drm_window_proxy.cc
index a2afe0d0f2b..f94428bf86f 100644
--- a/chromium/ui/ozone/platform/drm/gpu/drm_window_proxy.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/drm_window_proxy.cc
@@ -35,9 +35,9 @@ void DrmWindowProxy::SchedulePageFlip(
std::move(planes), CreateSafeOnceCallback(std::move(submission_callback)),
CreateSafeOnceCallback(std::move(presentation_callback)));
drm_thread_->task_runner()->PostTask(
- FROM_HERE, base::BindOnce(&DrmThread::RunTaskAfterWindowReady,
- base::Unretained(drm_thread_), widget_,
- std::move(task), nullptr));
+ FROM_HERE,
+ base::BindOnce(&DrmThread::RunTaskAfterDeviceReady,
+ base::Unretained(drm_thread_), std::move(task), nullptr));
}
bool DrmWindowProxy::SupportsGpuFences() const {
@@ -45,10 +45,9 @@ bool DrmWindowProxy::SupportsGpuFences() const {
base::OnceClosure task =
base::BindOnce(&DrmThread::IsDeviceAtomic, base::Unretained(drm_thread_),
widget_, &is_atomic);
- PostSyncTask(
- drm_thread_->task_runner(),
- base::BindOnce(&DrmThread::RunTaskAfterWindowReady,
- base::Unretained(drm_thread_), widget_, std::move(task)));
+ PostSyncTask(drm_thread_->task_runner(),
+ base::BindOnce(&DrmThread::RunTaskAfterDeviceReady,
+ base::Unretained(drm_thread_), std::move(task)));
return is_atomic && !base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableExplicitDmaFences);
}
diff --git a/chromium/ui/ozone/platform/drm/gpu/gbm_pixmap.cc b/chromium/ui/ozone/platform/drm/gpu/gbm_pixmap.cc
index 293aee6aea9..53aad5eba10 100644
--- a/chromium/ui/ozone/platform/drm/gpu/gbm_pixmap.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/gbm_pixmap.cc
@@ -8,7 +8,7 @@
#include <memory>
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/gfx/gpu_fence.h"
#include "ui/gfx/native_pixmap_handle.h"
#include "ui/ozone/platform/drm/gpu/drm_overlay_plane.h"
diff --git a/chromium/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc b/chromium/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc
index fcb45780025..5953baf4b28 100644
--- a/chromium/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/gbm_surface_factory.cc
@@ -248,6 +248,7 @@ std::vector<gl::GLImplementation>
GbmSurfaceFactory::GetAllowedGLImplementations() {
DCHECK(thread_checker_.CalledOnValidThread());
return std::vector<gl::GLImplementation>{gl::kGLImplementationEGLGLES2,
+ gl::kGLImplementationEGLANGLE,
gl::kGLImplementationSwiftShaderGL};
}
@@ -255,6 +256,7 @@ GLOzone* GbmSurfaceFactory::GetGLOzone(gl::GLImplementation implementation) {
switch (implementation) {
case gl::kGLImplementationEGLGLES2:
case gl::kGLImplementationSwiftShaderGL:
+ case gl::kGLImplementationEGLANGLE:
return egl_implementation_.get();
default:
return nullptr;
diff --git a/chromium/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc b/chromium/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc
index ae654f1dbf8..8c32abbafef 100644
--- a/chromium/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/gbm_surfaceless.cc
@@ -8,7 +8,8 @@
#include <utility>
#include "base/bind.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/task/post_task.h"
#include "base/task/thread_pool.h"
#include "base/trace_event/trace_event.h"
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller.cc b/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
index 6f240331ab6..7cc196aa293 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller.cc
@@ -90,20 +90,10 @@ bool HardwareDisplayController::ModesetCrtc(const DrmOverlayPlane& primary,
const drmModeModeInfo& mode) {
DCHECK(primary.buffer.get());
bool status = true;
-
- GetDrmDevice()->plane_manager()->BeginFrame(&owned_hardware_planes_);
- DrmOverlayPlaneList plane_list;
- plane_list.push_back(primary.Clone());
-
- for (const auto& controller : crtc_controllers_) {
- status &=
- controller->AssignOverlayPlanes(&owned_hardware_planes_, plane_list,
- /*is_modesetting=*/true);
-
+ for (const auto& controller : crtc_controllers_)
status &= controller->Modeset(
primary, use_current_crtc_mode ? controller->mode() : mode,
owned_hardware_planes_);
- }
is_disabled_ = false;
ResetCursor();
@@ -186,13 +176,12 @@ bool HardwareDisplayController::ScheduleOrTestPageFlip(
bool status = true;
for (const auto& controller : crtc_controllers_) {
- status &= controller->AssignOverlayPlanes(
- &owned_hardware_planes_, pending_planes, /*is_modesetting=*/false);
+ status &= controller->AssignOverlayPlanes(&owned_hardware_planes_,
+ pending_planes);
}
status &= GetDrmDevice()->plane_manager()->Commit(
- &owned_hardware_planes_, /*should_modeset=*/false, page_flip_request,
- out_fence);
+ &owned_hardware_planes_, page_flip_request, out_fence);
return status;
}
@@ -368,7 +357,6 @@ void HardwareDisplayController::OnModesetComplete(
// pending planes to the same values so that the callback keeps the correct
// state.
page_flip_request_ = nullptr;
- owned_hardware_planes_.legacy_page_flips.clear();
current_planes_.clear();
current_planes_.push_back(primary.Clone());
time_of_last_flip_ = base::TimeTicks::Now();
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc b/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc
index 80118d38fdc..3f751403fd0 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_controller_unittest.cc
@@ -30,18 +30,11 @@ namespace {
const drmModeModeInfo kDefaultMode = {0, 6, 0, 0, 0, 0, 4, 0,
0, 0, 0, 0, 0, 0, {'\0'}};
-constexpr uint32_t kCrtcIdBase = 100;
+constexpr uint32_t kCrtcIdBase = 1;
constexpr uint32_t kPrimaryCrtc = kCrtcIdBase;
constexpr uint32_t kSecondaryCrtc = kCrtcIdBase + 1;
-constexpr uint32_t kConnectorIdBase = 200;
-constexpr uint32_t kPlaneOffset = 300;
-constexpr uint32_t kInFormatsBlobPropId = 400;
-
-constexpr uint32_t kActivePropId = 1000;
-constexpr uint32_t kModePropId = 1001;
-constexpr uint32_t kCrtcIdPropId = 2000;
-constexpr uint32_t kTypePropId = 3010;
-constexpr uint32_t kInFormatsPropId = 3011;
+constexpr uint32_t kConnectorIdBase = 10;
+constexpr uint32_t kPlaneOffset = 1000;
const gfx::Size kDefaultModeSize(kDefaultMode.hdisplay, kDefaultMode.vdisplay);
const gfx::Size kOverlaySize(kDefaultMode.hdisplay / 2,
@@ -111,6 +104,10 @@ void HardwareDisplayControllerTest::TearDown() {
}
void HardwareDisplayControllerTest::InitializeDrmDevice(bool use_atomic) {
+ constexpr uint32_t kTypePropId = 3010;
+ constexpr uint32_t kInFormatsPropId = 3011;
+ constexpr uint32_t kInFormatsBlobPropId = 400;
+
std::vector<ui::MockDrmDevice::CrtcProperties> crtc_properties(2);
std::map<uint32_t, std::string> crtc_property_names = {
{1000, "ACTIVE"},
@@ -119,7 +116,7 @@ void HardwareDisplayControllerTest::InitializeDrmDevice(bool use_atomic) {
std::vector<ui::MockDrmDevice::ConnectorProperties> connector_properties(2);
std::map<uint32_t, std::string> connector_property_names = {
- {kCrtcIdPropId, "CRTC_ID"},
+ {2000, "CRTC_ID"},
};
for (size_t i = 0; i < connector_properties.size(); ++i) {
connector_properties[i].id = kConnectorIdBase + i;
@@ -228,78 +225,10 @@ TEST_F(HardwareDisplayControllerTest, CheckModesettingResult) {
EXPECT_FALSE(plane.buffer->HasOneRef());
}
-TEST_F(HardwareDisplayControllerTest, CheckModesettingSetsProps) {
- ui::DrmOverlayPlane plane1(CreateBuffer(), nullptr);
-
- EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
-
- ui::DrmOverlayPlane plane2(CreateBuffer(), nullptr);
- std::vector<ui::DrmOverlayPlane> planes = {};
- planes.push_back(plane2.Clone());
-
- SchedulePageFlip(std::move(planes));
-
- // Test props values after modesetting.
- ui::DrmDevice::Property connector_prop_crtc_id = {};
- ui::ScopedDrmObjectPropertyPtr connector_props =
- drm_->GetObjectProperties(kConnectorIdBase, DRM_MODE_OBJECT_CONNECTOR);
- ui::GetDrmPropertyForName(drm_.get(), connector_props.get(), "CRTC_ID",
- &connector_prop_crtc_id);
- EXPECT_EQ(kCrtcIdPropId, connector_prop_crtc_id.id);
- EXPECT_EQ(kCrtcIdBase, connector_prop_crtc_id.value);
-
- ui::DrmDevice::Property crtc_prop_for_name = {};
- ui::ScopedDrmObjectPropertyPtr crtc_props =
- drm_->GetObjectProperties(kPrimaryCrtc, DRM_MODE_OBJECT_CRTC);
- GetDrmPropertyForName(drm_.get(), crtc_props.get(), "ACTIVE",
- &crtc_prop_for_name);
- EXPECT_EQ(kActivePropId, crtc_prop_for_name.id);
- EXPECT_EQ(1U, crtc_prop_for_name.value);
-
- GetDrmPropertyForName(drm_.get(), crtc_props.get(), "MODE_ID",
- &crtc_prop_for_name);
- EXPECT_EQ(kModePropId, crtc_prop_for_name.id);
-}
-
-TEST_F(HardwareDisplayControllerTest, CheckDisableResetsProps) {
- ui::DrmOverlayPlane plane1(CreateBuffer(), nullptr);
-
- EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
-
- ui::DrmOverlayPlane plane2(CreateBuffer(), nullptr);
- std::vector<ui::DrmOverlayPlane> planes = {};
- planes.push_back(plane2.Clone());
-
- SchedulePageFlip(std::move(planes));
-
- // Test props values after disabling.
- controller_->Disable();
-
- ui::DrmDevice::Property connector_prop_crtc_id;
- ui::ScopedDrmObjectPropertyPtr connector_props =
- drm_->GetObjectProperties(kConnectorIdBase, DRM_MODE_OBJECT_CONNECTOR);
- ui::GetDrmPropertyForName(drm_.get(), connector_props.get(), "CRTC_ID",
- &connector_prop_crtc_id);
- EXPECT_EQ(0U, connector_prop_crtc_id.value);
-
- ui::DrmDevice::Property crtc_prop_for_name;
- ui::ScopedDrmObjectPropertyPtr crtc_props =
- drm_->GetObjectProperties(kPrimaryCrtc, DRM_MODE_OBJECT_CRTC);
- GetDrmPropertyForName(drm_.get(), crtc_props.get(), "ACTIVE",
- &crtc_prop_for_name);
- EXPECT_EQ(0U, crtc_prop_for_name.value);
-
- crtc_props = drm_->GetObjectProperties(kPrimaryCrtc, DRM_MODE_OBJECT_CRTC);
- GetDrmPropertyForName(drm_.get(), crtc_props.get(), "MODE_ID",
- &crtc_prop_for_name);
- EXPECT_EQ(0U, crtc_prop_for_name.value);
-}
-
TEST_F(HardwareDisplayControllerTest, CheckStateAfterPageFlip) {
ui::DrmOverlayPlane plane1(CreateBuffer(), nullptr);
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
- EXPECT_EQ(1, drm_->get_commit_count());
ui::DrmOverlayPlane plane2(CreateBuffer(), nullptr);
std::vector<ui::DrmOverlayPlane> planes;
@@ -313,14 +242,13 @@ TEST_F(HardwareDisplayControllerTest, CheckStateAfterPageFlip) {
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(1, page_flips_);
- EXPECT_EQ(2, drm_->get_commit_count());
+ EXPECT_EQ(1, drm_->get_commit_count());
// Verify only the primary display have a valid framebuffer.
EXPECT_NE(0u, GetPlanePropertyValue(kPlaneOffset, "FB_ID"));
EXPECT_EQ(0u, GetPlanePropertyValue(kPlaneOffset + 1, "FB_ID"));
}
TEST_F(HardwareDisplayControllerTest, CheckStateIfModesetFails) {
- InitializeDrmDevice(/* use_atomic */ false);
drm_->set_set_crtc_expectation(false);
ui::DrmOverlayPlane plane(CreateBuffer(), nullptr);
@@ -328,6 +256,20 @@ TEST_F(HardwareDisplayControllerTest, CheckStateIfModesetFails) {
EXPECT_FALSE(controller_->Modeset(plane, kDefaultMode));
}
+TEST_F(HardwareDisplayControllerTest, CheckStateIfPageFlipFails) {
+ drm_->set_commit_expectation(false);
+
+ ui::DrmOverlayPlane plane1(CreateBuffer(), nullptr);
+
+ EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
+
+ ui::DrmOverlayPlane plane2(CreateBuffer(), nullptr);
+ std::vector<ui::DrmOverlayPlane> planes;
+ planes.push_back(plane2.Clone());
+ EXPECT_DEATH_IF_SUPPORTED(SchedulePageFlip(std::move(planes)),
+ "SchedulePageFlip failed");
+}
+
TEST_F(HardwareDisplayControllerTest, CheckOverlayPresent) {
ui::DrmOverlayPlane plane1(CreateBuffer(), nullptr);
ui::DrmOverlayPlane plane2(
@@ -335,7 +277,6 @@ TEST_F(HardwareDisplayControllerTest, CheckOverlayPresent) {
gfx::Rect(kOverlaySize), gfx::RectF(kDefaultModeSizeF), true, nullptr);
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
- EXPECT_EQ(1, drm_->get_commit_count());
std::vector<ui::DrmOverlayPlane> planes;
planes.push_back(plane1.Clone());
@@ -345,7 +286,7 @@ TEST_F(HardwareDisplayControllerTest, CheckOverlayPresent) {
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(1, page_flips_);
- EXPECT_EQ(2, drm_->get_commit_count());
+ EXPECT_EQ(1, drm_->get_commit_count());
// Verify both planes on the primary display have a valid framebuffer.
EXPECT_NE(0u, GetPlanePropertyValue(kPlaneOffset, "FB_ID"));
EXPECT_NE(0u, GetPlanePropertyValue(kPlaneOffset + 1, "FB_ID"));
@@ -358,14 +299,13 @@ TEST_F(HardwareDisplayControllerTest, CheckOverlayTestMode) {
gfx::Rect(kOverlaySize), gfx::RectF(kDefaultModeSizeF), true, nullptr);
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
- EXPECT_EQ(1, drm_->get_commit_count());
std::vector<ui::DrmOverlayPlane> planes;
planes.push_back(plane1.Clone());
planes.push_back(plane2.Clone());
SchedulePageFlip(ui::DrmOverlayPlane::Clone(planes));
- EXPECT_EQ(2, drm_->get_commit_count());
+ EXPECT_EQ(1, drm_->get_commit_count());
// Verify both planes on the primary display have a valid framebuffer.
EXPECT_NE(0u, GetPlanePropertyValue(kPlaneOffset, "FB_ID"));
EXPECT_NE(0u, GetPlanePropertyValue(kPlaneOffset + 1, "FB_ID"));
@@ -375,14 +315,14 @@ TEST_F(HardwareDisplayControllerTest, CheckOverlayTestMode) {
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(1, page_flips_);
- EXPECT_EQ(3, drm_->get_commit_count());
+ EXPECT_EQ(2, drm_->get_commit_count());
// Regular flips should continue on normally.
SchedulePageFlip(ui::DrmOverlayPlane::Clone(planes));
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(2, page_flips_);
- EXPECT_EQ(4, drm_->get_commit_count());
+ EXPECT_EQ(3, drm_->get_commit_count());
// Verify both planes on the primary display have a valid framebuffer.
EXPECT_NE(0u, GetPlanePropertyValue(kPlaneOffset, "FB_ID"));
EXPECT_NE(0u, GetPlanePropertyValue(kPlaneOffset + 1, "FB_ID"));
@@ -413,7 +353,7 @@ TEST_F(HardwareDisplayControllerTest, PageflipMirroredControllers) {
ui::DrmOverlayPlane plane1(CreateBuffer(), nullptr);
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
- EXPECT_EQ(2, drm_->get_commit_count());
+ EXPECT_EQ(2, drm_->get_set_crtc_call_count());
ui::DrmOverlayPlane plane2(CreateBuffer(), nullptr);
std::vector<ui::DrmOverlayPlane> planes;
@@ -422,7 +362,7 @@ TEST_F(HardwareDisplayControllerTest, PageflipMirroredControllers) {
drm_->RunCallbacks();
EXPECT_EQ(gfx::SwapResult::SWAP_ACK, last_swap_result_);
EXPECT_EQ(1, page_flips_);
- EXPECT_EQ(3, drm_->get_commit_count());
+ EXPECT_EQ(1, drm_->get_commit_count());
// Verify only the displays have a valid framebuffer on the primary plane.
// First display:
EXPECT_NE(0u, GetPlanePropertyValue(kPlaneOffset, "FB_ID"));
@@ -569,10 +509,10 @@ TEST_F(HardwareDisplayControllerTest, ModesetWhilePageFlipping) {
}
TEST_F(HardwareDisplayControllerTest, FailPageFlipping) {
+ drm_->set_commit_expectation(false);
+
ui::DrmOverlayPlane plane1(CreateBuffer(), nullptr);
EXPECT_TRUE(controller_->Modeset(plane1, kDefaultMode));
-
- drm_->set_commit_expectation(false);
std::vector<ui::DrmOverlayPlane> planes;
planes.push_back(plane1.Clone());
EXPECT_DEATH_IF_SUPPORTED(SchedulePageFlip(std::move(planes)),
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h
index b24007d6611..b1070a0d89e 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager.h
@@ -97,7 +97,7 @@ class HardwareDisplayPlaneManager {
uint32_t crtc_id);
// Commit the plane states in |plane_list|.
- // if |should_modeset| is set, it only modesets without page flipping.
+ //
// If |page_flip_request| is null, this tests the plane configuration without
// submitting it.
// The fence returned in |out_fence| will signal when the currently scanned
@@ -105,7 +105,6 @@ class HardwareDisplayPlaneManager {
// |page_flip_request|. Note that the returned fence may be a nullptr
// if the system doesn't support out fences.
virtual bool Commit(HardwareDisplayPlaneList* plane_list,
- bool should_modeset,
scoped_refptr<PageFlipRequest> page_flip_request,
std::unique_ptr<gfx::GpuFence>* out_fence) = 0;
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.cc b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.cc
index 5f4a4101c2c..4ec9db772db 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.cc
@@ -65,32 +65,9 @@ bool HardwareDisplayPlaneManagerAtomic::Modeset(
uint32_t framebuffer_id,
uint32_t connector_id,
const drmModeModeInfo& mode,
- const HardwareDisplayPlaneList& plane_list) {
- const int connector_idx = LookupConnectorIndex(connector_id);
- DCHECK_GE(connector_idx, 0);
- connectors_props_[connector_idx].crtc_id.value = crtc_id;
- bool res =
- AddPropertyIfValid(plane_list.atomic_property_set.get(), connector_id,
- connectors_props_[connector_idx].crtc_id);
-
- const int crtc_idx = LookupCrtcIndex(crtc_id);
- DCHECK_GE(crtc_idx, 0);
- crtc_state_[crtc_idx].properties.active.value = 1UL;
- ScopedDrmPropertyBlob mode_blob =
- drm_->CreatePropertyBlob(&mode, sizeof(mode));
- crtc_state_[crtc_idx].properties.mode_id.value =
- mode_blob ? mode_blob->id() : 0;
-
- res &= AddPropertyIfValid(plane_list.atomic_property_set.get(), crtc_id,
- crtc_state_[crtc_idx].properties.active);
- res &= AddPropertyIfValid(plane_list.atomic_property_set.get(), crtc_id,
- crtc_state_[crtc_idx].properties.mode_id);
-
- DCHECK(res);
- return Commit(const_cast<HardwareDisplayPlaneList*>(&plane_list),
- /*should_modeset=*/true,
- /*page_flip_request=*/nullptr,
- /*out_fence=*/nullptr);
+ const HardwareDisplayPlaneList&) {
+ return drm_->SetCrtc(crtc_id, framebuffer_id,
+ std::vector<uint32_t>(1, connector_id), mode);
}
bool HardwareDisplayPlaneManagerAtomic::DisableModeset(uint32_t crtc_id,
@@ -119,19 +96,12 @@ bool HardwareDisplayPlaneManagerAtomic::DisableModeset(uint32_t crtc_id,
bool HardwareDisplayPlaneManagerAtomic::Commit(
HardwareDisplayPlaneList* plane_list,
- bool should_modeset,
scoped_refptr<PageFlipRequest> page_flip_request,
std::unique_ptr<gfx::GpuFence>* out_fence) {
- bool test_only = !should_modeset && !page_flip_request;
-
+ bool test_only = !page_flip_request;
for (HardwareDisplayPlane* plane : plane_list->old_plane_list) {
if (!base::Contains(plane_list->plane_list, plane)) {
- // |plane| is shared state between |old_plane_list| and |plane_list|.
- // When we call BeginFrame(), we reset in_use since we need to be able to
- // allocate the planes as needed. The current frame might not need to use
- // |plane|, thus |plane->in_use()| would be false even though the previous
- // frame used it. It's existence in |old_plane_list| is sufficient to
- // signal that |plane| was in use previously.
+ // This plane is being released, so we need to zero it.
plane->set_in_use(false);
HardwareDisplayPlaneAtomic* atomic_plane =
static_cast<HardwareDisplayPlaneAtomic*>(plane);
@@ -176,10 +146,11 @@ bool HardwareDisplayPlaneManagerAtomic::Commit(
}
uint32_t flags = 0;
- if (should_modeset)
- flags = DRM_MODE_ATOMIC_ALLOW_MODESET;
- else
- flags = test_only ? DRM_MODE_ATOMIC_TEST_ONLY : DRM_MODE_ATOMIC_NONBLOCK;
+ if (test_only) {
+ flags = DRM_MODE_ATOMIC_TEST_ONLY;
+ } else {
+ flags = DRM_MODE_ATOMIC_NONBLOCK;
+ }
// After we perform the atomic commit, and if the caller has requested an
// out-fence, the out_fence_fds vector will contain any provided out-fence
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h
index 2aa11b73071..7567a9bab24 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_atomic.h
@@ -26,7 +26,6 @@ class HardwareDisplayPlaneManagerAtomic : public HardwareDisplayPlaneManager {
const HardwareDisplayPlaneList& plane_list) override;
bool DisableModeset(uint32_t crtc_id, uint32_t connector) override;
bool Commit(HardwareDisplayPlaneList* plane_list,
- bool should_modeset,
scoped_refptr<PageFlipRequest> page_flip_request,
std::unique_ptr<gfx::GpuFence>* out_fence) override;
bool DisableOverlayPlanes(HardwareDisplayPlaneList* plane_list) override;
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc
index a09037cf0df..4bbd89541aa 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.cc
@@ -63,11 +63,8 @@ bool HardwareDisplayPlaneManagerLegacy::DisableModeset(uint32_t crtc_id,
bool HardwareDisplayPlaneManagerLegacy::Commit(
HardwareDisplayPlaneList* plane_list,
- bool should_modeset,
scoped_refptr<PageFlipRequest> page_flip_request,
std::unique_ptr<gfx::GpuFence>* out_fence) {
- DCHECK(!should_modeset);
-
bool test_only = !page_flip_request;
if (test_only) {
for (HardwareDisplayPlane* plane : plane_list->plane_list) {
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h
index 668ffde7258..237689dd288 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_legacy.h
@@ -26,7 +26,6 @@ class HardwareDisplayPlaneManagerLegacy : public HardwareDisplayPlaneManager {
const HardwareDisplayPlaneList& plane_list) override;
bool DisableModeset(uint32_t crtc_id, uint32_t connector) override;
bool Commit(HardwareDisplayPlaneList* plane_list,
- bool should_modeset,
scoped_refptr<PageFlipRequest> page_flip_request,
std::unique_ptr<gfx::GpuFence>* out_fence) override;
bool DisableOverlayPlanes(HardwareDisplayPlaneList* plane_list) override;
diff --git a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc
index 5acf29f9eb8..798ed118db5 100644
--- a/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/hardware_display_plane_manager_unittest.cc
@@ -37,7 +37,6 @@ constexpr uint32_t kCrtcIdBase = 500;
constexpr uint32_t kConnectorIdBase = 700;
constexpr uint32_t kActivePropId = 1000;
-constexpr uint32_t kModePropId = 1001;
constexpr uint32_t kBackgroundColorPropId = 1002;
constexpr uint32_t kCtmPropId = 1003;
constexpr uint32_t kGammaLutPropId = 1004;
@@ -122,7 +121,7 @@ void HardwareDisplayPlaneManagerTest::InitializeDrmState(
size_t planes_per_crtc) {
std::map<uint32_t, std::string> crtc_property_names = {
{kActivePropId, "ACTIVE"},
- {kModePropId, "MODE_ID"},
+ {1001, "MODE_ID"},
};
std::vector<ui::MockDrmDevice::ConnectorProperties> connector_properties(1);
@@ -227,8 +226,8 @@ void HardwareDisplayPlaneManagerTest::PerformPageFlip(
state, assigns, crtc_properties_[crtc_idx].id));
scoped_refptr<ui::PageFlipRequest> page_flip_request =
base::MakeRefCounted<ui::PageFlipRequest>(base::TimeDelta());
- ASSERT_TRUE(fake_drm_->plane_manager()->Commit(
- state, /*should_modeset*/ false, page_flip_request, nullptr));
+ ASSERT_TRUE(
+ fake_drm_->plane_manager()->Commit(state, page_flip_request, nullptr));
}
uint64_t HardwareDisplayPlaneManagerTest::GetObjectPropertyValue(
@@ -297,6 +296,8 @@ TEST_P(HardwareDisplayPlaneManagerTest, ResettingConnectorCache) {
EXPECT_TRUE(fake_drm_->plane_manager()->Modeset(
crtc_properties_[1].id, kFrameBuffer, kConnectorIdBase + 1, kDefaultMode,
state));
+ // TODO(markyacoub): Add a test that fails for kConnectorIdBase +2 when atomic
+ // modeset is enabled.
EXPECT_TRUE(fake_drm_->plane_manager()->Modeset(
crtc_properties_[2].id, kFrameBuffer, kConnectorIdBase + 3, kDefaultMode,
state));
@@ -454,7 +455,7 @@ TEST_P(HardwareDisplayPlaneManagerAtomicTest, Modeset) {
crtc_properties_[0].id, kFrameBuffer, connector_properties_[0].id,
kDefaultMode, state));
- EXPECT_EQ(1, fake_drm_->get_commit_count());
+ EXPECT_EQ(0, fake_drm_->get_commit_count());
}
TEST_P(HardwareDisplayPlaneManagerAtomicTest, DisableModeset) {
@@ -468,40 +469,6 @@ TEST_P(HardwareDisplayPlaneManagerAtomicTest, DisableModeset) {
EXPECT_EQ(1, fake_drm_->get_commit_count());
}
-TEST_P(HardwareDisplayPlaneManagerAtomicTest, CheckPropsAfterModeset) {
- InitializeDrmState(/*crtc_count=*/1, /*planes_per_crtc=*/1);
- fake_drm_->InitializeState(crtc_properties_, connector_properties_,
- plane_properties_, property_names_,
- /*use_atomic=*/true);
-
- constexpr uint32_t kFrameBuffer = 2;
- ui::HardwareDisplayPlaneList state;
- EXPECT_TRUE(fake_drm_->plane_manager()->Modeset(
- crtc_properties_[0].id, kFrameBuffer, connector_properties_[0].id,
- kDefaultMode, state));
-
- // Test props values after modesetting.
- ui::DrmDevice::Property connector_prop_crtc_id;
- ui::ScopedDrmObjectPropertyPtr connector_props =
- fake_drm_->GetObjectProperties(kConnectorIdBase,
- DRM_MODE_OBJECT_CONNECTOR);
- ui::GetDrmPropertyForName(fake_drm_.get(), connector_props.get(), "CRTC_ID",
- &connector_prop_crtc_id);
- EXPECT_EQ(kCrtcIdPropId, connector_prop_crtc_id.id);
-
- ui::DrmDevice::Property crtc_prop_for_name;
- ui::ScopedDrmObjectPropertyPtr crtc_props =
- fake_drm_->GetObjectProperties(kCrtcIdBase, DRM_MODE_OBJECT_CRTC);
- ui::GetDrmPropertyForName(fake_drm_.get(), crtc_props.get(), "ACTIVE",
- &crtc_prop_for_name);
- EXPECT_EQ(kActivePropId, crtc_prop_for_name.id);
- EXPECT_EQ(1U, crtc_prop_for_name.value);
-
- ui::GetDrmPropertyForName(fake_drm_.get(), crtc_props.get(), "MODE_ID",
- &crtc_prop_for_name);
- EXPECT_EQ(kModePropId, crtc_prop_for_name.id);
-}
-
TEST_P(HardwareDisplayPlaneManagerAtomicTest, CheckPropsAfterDisable) {
InitializeDrmState(/*crtc_count=*/1, /*planes_per_crtc=*/1);
fake_drm_->InitializeState(crtc_properties_, connector_properties_,
@@ -603,8 +570,8 @@ TEST_P(HardwareDisplayPlaneManagerAtomicTest, UnusedPlanesAreReleased) {
fake_drm_->plane_manager()->BeginFrame(&hdpl);
EXPECT_TRUE(fake_drm_->plane_manager()->AssignOverlayPlanes(
&hdpl, assigns, crtc_properties_[0].id));
- EXPECT_TRUE(fake_drm_->plane_manager()->Commit(
- &hdpl, /*should_modeset*/ false, page_flip_request, nullptr));
+ EXPECT_TRUE(
+ fake_drm_->plane_manager()->Commit(&hdpl, page_flip_request, nullptr));
assigns.clear();
assigns.push_back(ui::DrmOverlayPlane(primary_buffer, nullptr));
fake_drm_->plane_manager()->BeginFrame(&hdpl);
@@ -613,8 +580,8 @@ TEST_P(HardwareDisplayPlaneManagerAtomicTest, UnusedPlanesAreReleased) {
EXPECT_NE(0u, GetPlanePropertyValue(kPlaneOffset, "FB_ID"));
EXPECT_NE(0u, GetPlanePropertyValue(kPlaneOffset + 1, "FB_ID"));
- EXPECT_TRUE(fake_drm_->plane_manager()->Commit(
- &hdpl, /*should_modeset*/ false, page_flip_request, nullptr));
+ EXPECT_TRUE(
+ fake_drm_->plane_manager()->Commit(&hdpl, page_flip_request, nullptr));
EXPECT_NE(0u, GetPlanePropertyValue(kPlaneOffset, "FB_ID"));
EXPECT_EQ(0u, GetPlanePropertyValue(kPlaneOffset + 1, "FB_ID"));
}
@@ -947,8 +914,8 @@ TEST_P(HardwareDisplayPlaneManagerAtomicTest,
base::MakeRefCounted<ui::PageFlipRequest>(base::TimeDelta());
std::unique_ptr<gfx::GpuFence> out_fence;
- EXPECT_TRUE(fake_drm_->plane_manager()->Commit(
- &state_, /*should_modeset*/ false, page_flip_request, &out_fence));
+ EXPECT_TRUE(fake_drm_->plane_manager()->Commit(&state_, page_flip_request,
+ &out_fence));
EXPECT_EQ(nullptr, out_fence);
}
diff --git a/chromium/ui/ozone/platform/drm/gpu/mock_drm_device.cc b/chromium/ui/ozone/platform/drm/gpu/mock_drm_device.cc
index 32c5052a2a0..9463b821486 100644
--- a/chromium/ui/ozone/platform/drm/gpu/mock_drm_device.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/mock_drm_device.cc
@@ -8,7 +8,7 @@
#include <memory>
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/stl_util.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkCanvas.h"
@@ -430,10 +430,8 @@ bool MockDrmDevice::CommitProperties(
return false;
for (uint32_t i = 0; i < request->cursor; ++i) {
- bool res = ValidatePropertyValue(request->items[i].property_id,
- request->items[i].value);
- if (!res)
- return false;
+ EXPECT_TRUE(ValidatePropertyValue(request->items[i].property_id,
+ request->items[i].value));
}
if (page_flip_request)
@@ -444,11 +442,9 @@ bool MockDrmDevice::CommitProperties(
// Only update values if not testing.
for (uint32_t i = 0; i < request->cursor; ++i) {
- bool res =
- UpdateProperty(request->items[i].object_id,
- request->items[i].property_id, request->items[i].value);
- if (!res)
- return false;
+ EXPECT_TRUE(UpdateProperty(request->items[i].object_id,
+ request->items[i].property_id,
+ request->items[i].value));
}
return true;
diff --git a/chromium/ui/ozone/platform/drm/gpu/screen_manager_unittest.cc b/chromium/ui/ozone/platform/drm/gpu/screen_manager_unittest.cc
index fea1047c7a2..577cfa7d540 100644
--- a/chromium/ui/ozone/platform/drm/gpu/screen_manager_unittest.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/screen_manager_unittest.cc
@@ -31,18 +31,10 @@ namespace {
const drmModeModeInfo kDefaultMode = {0, 6, 0, 0, 0, 0, 4, 0,
0, 0, 0, 0, 0, 0, {'\0'}};
-constexpr uint32_t kCrtcIdBase = 100;
-constexpr uint32_t kPrimaryCrtc = kCrtcIdBase;
-constexpr uint32_t kSecondaryCrtc = kCrtcIdBase + 1;
-
-constexpr uint32_t kConnectorIdBase = 200;
-constexpr uint32_t kPrimaryConnector = kConnectorIdBase;
-constexpr uint32_t kSecondaryConnector = kConnectorIdBase + 1;
-constexpr uint32_t kPlaneIdBase = 300;
-constexpr uint32_t kInFormatsBlobPropIdBase = 400;
-
-constexpr uint32_t kTypePropId = 3010;
-constexpr uint32_t kInFormatsPropId = 3011;
+const uint32_t kPrimaryCrtc = 1;
+const uint32_t kPrimaryConnector = 2;
+const uint32_t kSecondaryCrtc = 3;
+const uint32_t kSecondaryConnector = 4;
drmModeModeInfo Mode(uint16_t hdisplay, uint16_t vdisplay) {
return {0, hdisplay, 0, 0, 0, 0, vdisplay, 0, 0, 0, 0, 0, 0, 0, {'\0'}};
@@ -52,16 +44,8 @@ drmModeModeInfo Mode(uint16_t hdisplay, uint16_t vdisplay) {
class ScreenManagerTest : public testing::Test {
public:
- struct PlaneState {
- std::vector<uint32_t> formats;
- };
-
- struct CrtcState {
- std::vector<PlaneState> planes;
- };
-
- ScreenManagerTest() = default;
- ~ScreenManagerTest() override = default;
+ ScreenManagerTest() {}
+ ~ScreenManagerTest() override {}
gfx::Rect GetPrimaryBounds() const {
return gfx::Rect(0, 0, kDefaultMode.hdisplay, kDefaultMode.vdisplay);
@@ -73,95 +57,6 @@ class ScreenManagerTest : public testing::Test {
kDefaultMode.vdisplay);
}
- void InitializeDrmState(const std::vector<CrtcState>& crtc_states) {
- std::vector<ui::MockDrmDevice::CrtcProperties> crtc_properties(
- crtc_states.size());
- std::map<uint32_t, std::string> crtc_property_names = {
- {1000, "ACTIVE"},
- {1001, "MODE_ID"},
- };
-
- std::vector<ui::MockDrmDevice::ConnectorProperties> connector_properties(2);
- std::map<uint32_t, std::string> connector_property_names = {
- {2000, "CRTC_ID"},
- };
- for (size_t i = 0; i < connector_properties.size(); ++i) {
- connector_properties[i].id = kPrimaryConnector + i;
- for (const auto& pair : connector_property_names) {
- connector_properties[i].properties.push_back(
- {/* .id = */ pair.first, /* .value = */ 0});
- }
- }
-
- std::vector<ui::MockDrmDevice::PlaneProperties> plane_properties;
- std::map<uint32_t, std::string> plane_property_names = {
- // Add all required properties.
- {3000, "CRTC_ID"},
- {3001, "CRTC_X"},
- {3002, "CRTC_Y"},
- {3003, "CRTC_W"},
- {3004, "CRTC_H"},
- {3005, "FB_ID"},
- {3006, "SRC_X"},
- {3007, "SRC_Y"},
- {3008, "SRC_W"},
- {3009, "SRC_H"},
- // Defines some optional properties we use for convenience.
- {kTypePropId, "type"},
- {kInFormatsPropId, "IN_FORMATS"},
- };
-
- uint32_t plane_id = kPlaneIdBase;
- uint32_t property_id = kInFormatsBlobPropIdBase;
-
- for (size_t crtc_idx = 0; crtc_idx < crtc_states.size(); ++crtc_idx) {
- crtc_properties[crtc_idx].id = kPrimaryCrtc + crtc_idx;
- for (const auto& pair : crtc_property_names) {
- crtc_properties[crtc_idx].properties.push_back(
- {/* .id = */ pair.first, /* .value = */ 0});
- }
-
- std::vector<ui::MockDrmDevice::PlaneProperties> crtc_plane_properties(
- crtc_states[crtc_idx].planes.size());
- for (size_t plane_idx = 0;
- plane_idx < crtc_states[crtc_idx].planes.size(); ++plane_idx) {
- crtc_plane_properties[plane_idx].id = plane_id++;
- crtc_plane_properties[plane_idx].crtc_mask = 1 << crtc_idx;
-
- for (const auto& pair : plane_property_names) {
- uint64_t value = 0;
- if (pair.first == kTypePropId) {
- value = plane_idx == 0 ? DRM_PLANE_TYPE_PRIMARY
- : DRM_PLANE_TYPE_OVERLAY;
- } else if (pair.first == kInFormatsPropId) {
- value = property_id++;
- drm_->SetPropertyBlob(ui::MockDrmDevice::AllocateInFormatsBlob(
- value, crtc_states[crtc_idx].planes[plane_idx].formats,
- std::vector<drm_format_modifier>()));
- }
-
- crtc_plane_properties[plane_idx].properties.push_back(
- {/* .id = */ pair.first, /* .value = */ value});
- }
- }
-
- plane_properties.insert(plane_properties.end(),
- crtc_plane_properties.begin(),
- crtc_plane_properties.end());
- }
-
- std::map<uint32_t, std::string> property_names;
- property_names.insert(crtc_property_names.begin(),
- crtc_property_names.end());
- property_names.insert(connector_property_names.begin(),
- connector_property_names.end());
- property_names.insert(plane_property_names.begin(),
- plane_property_names.end());
- drm_->InitializeState(crtc_properties, connector_properties,
- plane_properties, property_names,
- /* use_atomic= */ true);
- }
-
void SetUp() override {
auto gbm = std::make_unique<ui::MockGbmDevice>();
drm_ = new ui::MockDrmDevice(std::move(gbm));
@@ -307,24 +202,6 @@ TEST_F(ScreenManagerTest, CheckForControllersInMirroredMode) {
}
TEST_F(ScreenManagerTest, CheckMirrorModeTransitions) {
- std::vector<CrtcState> crtc_states = {
- {
- /* .planes = */
- {
- {/* .formats = */ {DRM_FORMAT_XRGB8888}},
- {/* .formats = */ {DRM_FORMAT_XRGB8888, DRM_FORMAT_NV12}},
- },
- },
- {
- /* .planes = */
- {
- {/* .formats = */ {DRM_FORMAT_XRGB8888}},
- {/* .formats = */ {DRM_FORMAT_XRGB8888, DRM_FORMAT_NV12}},
- },
- },
- };
- InitializeDrmState(crtc_states);
-
screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector);
screen_manager_->ConfigureDisplayController(
drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(),
@@ -476,24 +353,6 @@ TEST_F(ScreenManagerTest, ReuseFramebufferIfDisabledThenReEnabled) {
}
TEST_F(ScreenManagerTest, CheckMirrorModeAfterBeginReEnabled) {
- std::vector<CrtcState> crtc_states = {
- {
- /* .planes = */
- {
- {/* .formats = */ {DRM_FORMAT_XRGB8888}},
- {/* .formats = */ {DRM_FORMAT_XRGB8888, DRM_FORMAT_NV12}},
- },
- },
- {
- /* .planes = */
- {
- {/* .formats = */ {DRM_FORMAT_XRGB8888}},
- {/* .formats = */ {DRM_FORMAT_XRGB8888, DRM_FORMAT_NV12}},
- },
- },
- };
- InitializeDrmState(crtc_states);
-
screen_manager_->AddDisplayController(drm_, kPrimaryCrtc, kPrimaryConnector);
screen_manager_->ConfigureDisplayController(
drm_, kPrimaryCrtc, kPrimaryConnector, GetPrimaryBounds().origin(),
diff --git a/chromium/ui/ozone/platform/drm/gpu/vulkan_implementation_gbm.cc b/chromium/ui/ozone/platform/drm/gpu/vulkan_implementation_gbm.cc
index 6858ff5053c..601cdb36873 100644
--- a/chromium/ui/ozone/platform/drm/gpu/vulkan_implementation_gbm.cc
+++ b/chromium/ui/ozone/platform/drm/gpu/vulkan_implementation_gbm.cc
@@ -11,7 +11,6 @@
#include "gpu/vulkan/vulkan_function_pointers.h"
#include "gpu/vulkan/vulkan_image.h"
#include "gpu/vulkan/vulkan_instance.h"
-#include "gpu/vulkan/vulkan_posix_util.h"
#include "gpu/vulkan/vulkan_surface.h"
#include "gpu/vulkan/vulkan_util.h"
#include "ui/gfx/gpu_fence.h"
@@ -149,13 +148,13 @@ VkSemaphore VulkanImplementationGbm::CreateExternalSemaphore(
VkSemaphore VulkanImplementationGbm::ImportSemaphoreHandle(
VkDevice vk_device,
gpu::SemaphoreHandle sync_handle) {
- return gpu::ImportVkSemaphoreHandlePosix(vk_device, std::move(sync_handle));
+ return gpu::ImportVkSemaphoreHandle(vk_device, std::move(sync_handle));
}
gpu::SemaphoreHandle VulkanImplementationGbm::GetSemaphoreHandle(
VkDevice vk_device,
VkSemaphore vk_semaphore) {
- return gpu::GetVkSemaphoreHandlePosix(
+ return gpu::GetVkSemaphoreHandle(
vk_device, vk_semaphore, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT);
}
diff --git a/chromium/ui/ozone/platform/drm/host/drm_device_connector.cc b/chromium/ui/ozone/platform/drm/host/drm_device_connector.cc
index 0b3cf4a8775..e546a2294cc 100644
--- a/chromium/ui/ozone/platform/drm/host/drm_device_connector.cc
+++ b/chromium/ui/ozone/platform/drm/host/drm_device_connector.cc
@@ -21,14 +21,6 @@ DrmDeviceConnector::DrmDeviceConnector(
DrmDeviceConnector::~DrmDeviceConnector() = default;
-void DrmDeviceConnector::OnGpuProcessLaunched(
- int host_id,
- scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
- scoped_refptr<base::SingleThreadTaskRunner> send_runner,
- base::RepeatingCallback<void(IPC::Message*)> send_callback) {
- NOTREACHED();
-}
-
void DrmDeviceConnector::OnChannelDestroyed(int host_id) {
if (host_id != host_id_)
return;
@@ -52,11 +44,6 @@ void DrmDeviceConnector::OnGpuServiceLaunched(
ui_runner);
}
-void DrmDeviceConnector::OnMessageReceived(const IPC::Message& message) {
- NOTREACHED() << "This class should only be used with mojo transport but here "
- "we're wrongly getting invoked to handle IPC communication.";
-}
-
void DrmDeviceConnector::BindInterfaceDrmDevice(
mojo::PendingRemote<ui::ozone::mojom::DrmDevice>* drm_device) const {
binder_callback_.Run(ui::ozone::mojom::DrmDevice::Name_,
diff --git a/chromium/ui/ozone/platform/drm/host/drm_device_connector.h b/chromium/ui/ozone/platform/drm/host/drm_device_connector.h
index 2c783d2e219..094408501b0 100644
--- a/chromium/ui/ozone/platform/drm/host/drm_device_connector.h
+++ b/chromium/ui/ozone/platform/drm/host/drm_device_connector.h
@@ -24,13 +24,7 @@ class DrmDeviceConnector : public GpuPlatformSupportHost {
~DrmDeviceConnector() override;
// GpuPlatformSupportHost:
- void OnGpuProcessLaunched(
- int host_id,
- scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
- scoped_refptr<base::SingleThreadTaskRunner> send_runner,
- base::RepeatingCallback<void(IPC::Message*)> send_callback) override;
void OnChannelDestroyed(int host_id) override;
- void OnMessageReceived(const IPC::Message& message) override;
void OnGpuServiceLaunched(
int host_id,
scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
diff --git a/chromium/ui/ozone/platform/drm/host/drm_display_host.cc b/chromium/ui/ozone/platform/drm/host/drm_display_host.cc
index 10f559bb623..3c84a92181f 100644
--- a/chromium/ui/ozone/platform/drm/host/drm_display_host.cc
+++ b/chromium/ui/ozone/platform/drm/host/drm_display_host.cc
@@ -45,8 +45,8 @@ void DrmDisplayHost::Configure(const display::DisplayMode* mode,
configure_callback_ = std::move(callback);
bool status = false;
if (mode) {
- status = sender_->GpuConfigureNativeDisplay(
- snapshot_->display_id(), GetDisplayModeParams(*mode), origin);
+ status = sender_->GpuConfigureNativeDisplay(snapshot_->display_id(), *mode,
+ origin);
} else {
status = sender_->GpuDisableNativeDisplay(snapshot_->display_id());
}
diff --git a/chromium/ui/ozone/platform/drm/host/drm_display_host_manager.cc b/chromium/ui/ozone/platform/drm/host/drm_display_host_manager.cc
index ceb96616272..aa4298703a7 100644
--- a/chromium/ui/ozone/platform/drm/host/drm_display_host_manager.cc
+++ b/chromium/ui/ozone/platform/drm/host/drm_display_host_manager.cc
@@ -365,19 +365,19 @@ void DrmDisplayHostManager::OnGpuThreadReady() {
void DrmDisplayHostManager::OnGpuThreadRetired() {}
void DrmDisplayHostManager::GpuHasUpdatedNativeDisplays(
- const std::vector<DisplaySnapshot_Params>& params_vector) {
+ MovableDisplaySnapshots displays) {
if (delegate_)
delegate_->OnDisplaySnapshotsInvalidated();
std::vector<std::unique_ptr<DrmDisplayHost>> old_displays;
displays_.swap(old_displays);
- for (const auto& params : params_vector) {
+ for (auto& display : displays) {
auto it = std::find_if(old_displays.begin(), old_displays.end(),
- FindDrmDisplayHostById(params.display_id));
+ FindDrmDisplayHostById(display->display_id()));
if (it == old_displays.end()) {
displays_.push_back(std::make_unique<DrmDisplayHost>(
- proxy_, CreateDisplaySnapshot(params), false /* is_dummy */));
+ proxy_, std::move(display), false /* is_dummy */));
} else {
- (*it)->UpdateDisplaySnapshot(CreateDisplaySnapshot(params));
+ (*it)->UpdateDisplaySnapshot(std::move(display));
displays_.push_back(std::move(*it));
old_displays.erase(it);
}
diff --git a/chromium/ui/ozone/platform/drm/host/drm_display_host_manager.h b/chromium/ui/ozone/platform/drm/host/drm_display_host_manager.h
index 1ded8afe89e..5622804e08a 100644
--- a/chromium/ui/ozone/platform/drm/host/drm_display_host_manager.h
+++ b/chromium/ui/ozone/platform/drm/host/drm_display_host_manager.h
@@ -18,6 +18,7 @@
#include "ui/events/ozone/device/device_event.h"
#include "ui/events/ozone/device/device_event_observer.h"
#include "ui/events/ozone/evdev/event_factory_evdev.h"
+#include "ui/ozone/platform/drm/common/display_types.h"
#include "ui/ozone/platform/drm/host/gpu_thread_observer.h"
#include "ui/ozone/public/ozone_platform.h"
@@ -30,8 +31,6 @@ class DrmDisplayHostManager;
class DrmNativeDisplayDelegate;
class GpuThreadAdapter;
-struct DisplaySnapshot_Params;
-
// The portion of the DrmDisplayHostManager implementation that is agnostic
// in how its communication with GPU-specific functionality is implemented.
// This is used from both the IPC and the in-process versions in MUS.
@@ -63,8 +62,7 @@ class DrmDisplayHostManager : public DeviceEventObserver, GpuThreadObserver {
// Communication-free implementations of actions performed in response to
// messages from the GPU thread.
- void GpuHasUpdatedNativeDisplays(
- const std::vector<DisplaySnapshot_Params>& displays);
+ void GpuHasUpdatedNativeDisplays(MovableDisplaySnapshots displays);
void GpuConfiguredDisplay(int64_t display_id, bool status);
void GpuReceivedHDCPState(int64_t display_id,
bool status,
diff --git a/chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc b/chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc
deleted file mode 100644
index 3a435294dcd..00000000000
--- a/chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.cc
+++ /dev/null
@@ -1,341 +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 "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h"
-
-#include <stddef.h>
-#include <utility>
-
-#include "base/bind.h"
-#include "base/command_line.h"
-#include "base/threading/thread_task_runner_handle.h"
-#include "base/trace_event/trace_event.h"
-#include "ui/base/ui_base_switches.h"
-#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
-#include "ui/ozone/common/gpu/ozone_gpu_messages.h"
-#include "ui/ozone/platform/drm/common/drm_util.h"
-#include "ui/ozone/platform/drm/host/drm_cursor.h"
-#include "ui/ozone/platform/drm/host/drm_display_host_manager.h"
-#include "ui/ozone/platform/drm/host/gpu_thread_observer.h"
-
-namespace ui {
-
-namespace {
-
-// Helper class that provides DrmCursor with a mechanism to send messages
-// to the GPU process.
-class CursorIPC : public DrmCursorProxy {
- public:
- CursorIPC(scoped_refptr<base::SingleThreadTaskRunner> send_runner,
- base::RepeatingCallback<void(IPC::Message*)> send_callback);
- ~CursorIPC() override;
-
- // DrmCursorProxy implementation.
- void CursorSet(gfx::AcceleratedWidget window,
- const std::vector<SkBitmap>& bitmaps,
- const gfx::Point& point,
- int frame_delay_ms) override;
- void Move(gfx::AcceleratedWidget window, const gfx::Point& point) override;
- void InitializeOnEvdevIfNecessary() override;
-
- private:
- bool IsConnected();
- void Send(IPC::Message* message);
-
- scoped_refptr<base::SingleThreadTaskRunner> send_runner_;
- base::RepeatingCallback<void(IPC::Message*)> send_callback_;
-
- DISALLOW_COPY_AND_ASSIGN(CursorIPC);
-};
-
-CursorIPC::CursorIPC(scoped_refptr<base::SingleThreadTaskRunner> send_runner,
- base::RepeatingCallback<void(IPC::Message*)> send_callback)
- : send_runner_(send_runner), send_callback_(std::move(send_callback)) {}
-
-CursorIPC::~CursorIPC() {}
-
-bool CursorIPC::IsConnected() {
- return !send_callback_.is_null();
-}
-
-void CursorIPC::CursorSet(gfx::AcceleratedWidget window,
- const std::vector<SkBitmap>& bitmaps,
- const gfx::Point& point,
- int frame_delay_ms) {
- Send(new OzoneGpuMsg_CursorSet(window, bitmaps, point, frame_delay_ms));
-}
-
-void CursorIPC::Move(gfx::AcceleratedWidget window, const gfx::Point& point) {
- Send(new OzoneGpuMsg_CursorMove(window, point));
-}
-
-void CursorIPC::InitializeOnEvdevIfNecessary() {}
-
-void CursorIPC::Send(IPC::Message* message) {
- if (IsConnected() && send_runner_->PostTask(
- FROM_HERE, base::BindOnce(send_callback_, message)))
- return;
-
- // Drop disconnected updates. The cursor will get set once we connect, via
- // SetDrmCursorProxy().
- delete message;
-}
-
-} // namespace
-
-DrmGpuPlatformSupportHost::DrmGpuPlatformSupportHost(DrmCursor* cursor)
- : ui_runner_(base::ThreadTaskRunnerHandle::IsSet()
- ? base::ThreadTaskRunnerHandle::Get()
- : nullptr),
- cursor_(cursor) {
- if (ui_runner_)
- weak_ptr_ = weak_ptr_factory_.GetWeakPtr();
-}
-
-DrmGpuPlatformSupportHost::~DrmGpuPlatformSupportHost() {}
-
-void DrmGpuPlatformSupportHost::AddGpuThreadObserver(
- GpuThreadObserver* observer) {
- gpu_thread_observers_.AddObserver(observer);
-
- if (IsConnected())
- observer->OnGpuThreadReady();
-}
-
-void DrmGpuPlatformSupportHost::RemoveGpuThreadObserver(
- GpuThreadObserver* observer) {
- gpu_thread_observers_.RemoveObserver(observer);
-}
-
-bool DrmGpuPlatformSupportHost::IsConnected() {
- return host_id_ >= 0 && channel_established_;
-}
-
-void DrmGpuPlatformSupportHost::OnGpuServiceLaunched(
- int host_id,
- scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
- scoped_refptr<base::SingleThreadTaskRunner> io_runner,
- GpuHostBindInterfaceCallback binder,
- GpuHostTerminateCallback terminate_callback) {
- NOTREACHED() << "DrmGpuPlatformSupportHost::OnGpuServiceLaunched shouldn't "
- "be used with pre-mojo IPC";
-}
-
-void DrmGpuPlatformSupportHost::OnGpuProcessLaunched(
- int host_id,
- scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
- scoped_refptr<base::SingleThreadTaskRunner> send_runner,
- base::RepeatingCallback<void(IPC::Message*)> send_callback) {
- // If there was a task runner set during construction, prefer using that.
- if (!ui_runner_) {
- ui_runner_ = std::move(ui_runner);
- weak_ptr_ = weak_ptr_factory_.GetWeakPtr();
- }
- DCHECK(!ui_runner_->BelongsToCurrentThread());
- TRACE_EVENT1("drm", "DrmGpuPlatformSupportHost::OnGpuProcessLaunched",
- "host_id", host_id);
- host_id_ = host_id;
- send_runner_ = std::move(send_runner);
- send_callback_ = std::move(send_callback);
-
- for (GpuThreadObserver& observer : gpu_thread_observers_)
- observer.OnGpuProcessLaunched();
-
- ui_runner_->PostTask(
- FROM_HERE,
- base::BindOnce(&DrmGpuPlatformSupportHost::OnChannelEstablished,
- weak_ptr_));
-}
-
-void DrmGpuPlatformSupportHost::OnChannelDestroyed(int host_id) {
- TRACE_EVENT1("drm", "DrmGpuPlatformSupportHost::OnChannelDestroyed",
- "host_id", host_id);
-
- if (host_id_ == host_id) {
- cursor_->ResetDrmCursorProxy();
- host_id_ = -1;
- channel_established_ = false;
- send_runner_ = nullptr;
- send_callback_.Reset();
- for (GpuThreadObserver& observer : gpu_thread_observers_)
- observer.OnGpuThreadRetired();
- }
-}
-
-void DrmGpuPlatformSupportHost::OnMessageReceived(const IPC::Message& message) {
- DCHECK(ui_runner_);
- if (!ui_runner_->BelongsToCurrentThread()) {
- ui_runner_->PostTask(
- FROM_HERE, base::BindOnce(&DrmGpuPlatformSupportHost::OnMessageReceived,
- weak_ptr_, message));
- return;
- }
-
- IPC_BEGIN_MESSAGE_MAP(DrmGpuPlatformSupportHost, message)
- IPC_MESSAGE_HANDLER(OzoneHostMsg_UpdateNativeDisplays,
- OnUpdateNativeDisplays)
- IPC_MESSAGE_HANDLER(OzoneHostMsg_DisplayConfigured, OnDisplayConfigured)
- IPC_MESSAGE_HANDLER(OzoneHostMsg_HDCPStateReceived, OnHDCPStateReceived)
- IPC_MESSAGE_HANDLER(OzoneHostMsg_HDCPStateUpdated, OnHDCPStateUpdated)
- IPC_MESSAGE_HANDLER(OzoneHostMsg_DisplayControlTaken, OnTakeDisplayControl)
- IPC_MESSAGE_HANDLER(OzoneHostMsg_DisplayControlRelinquished,
- OnRelinquishDisplayControl)
- IPC_END_MESSAGE_MAP()
-}
-
-bool DrmGpuPlatformSupportHost::Send(IPC::Message* message) {
- if (IsConnected() && send_runner_->PostTask(
- FROM_HERE, base::BindOnce(send_callback_, message)))
- return true;
-
- delete message;
- return false;
-}
-
-// DisplayHost
-void DrmGpuPlatformSupportHost::RegisterHandlerForDrmDisplayHostManager(
- DrmDisplayHostManager* handler) {
- display_manager_ = handler;
-}
-
-void DrmGpuPlatformSupportHost::UnRegisterHandlerForDrmDisplayHostManager() {
- display_manager_ = nullptr;
-}
-
-void DrmGpuPlatformSupportHost::OnChannelEstablished() {
- TRACE_EVENT0("drm", "DrmGpuPlatformSupportHost::OnChannelEstablished");
- channel_established_ = true;
-
- for (GpuThreadObserver& observer : gpu_thread_observers_)
- observer.OnGpuThreadReady();
-
- // The cursor is special since it will process input events on the IO thread
- // and can by-pass the UI thread. This means that we need to special case it
- // and notify it after all other observers/handlers are notified such that the
- // (windowing) state on the GPU can be initialized before the cursor is
- // allowed to IPC messages (which are targeted to a specific window).
- cursor_->SetDrmCursorProxy(
- std::make_unique<CursorIPC>(send_runner_, send_callback_));
-}
-
-void DrmGpuPlatformSupportHost::OnUpdateNativeDisplays(
- const std::vector<DisplaySnapshot_Params>& params) {
- display_manager_->GpuHasUpdatedNativeDisplays(params);
-}
-
-void DrmGpuPlatformSupportHost::OnDisplayConfigured(int64_t display_id,
- bool status) {
- display_manager_->GpuConfiguredDisplay(display_id, status);
-}
-
-void DrmGpuPlatformSupportHost::OnHDCPStateReceived(int64_t display_id,
- bool status,
- display::HDCPState state) {
- display_manager_->GpuReceivedHDCPState(display_id, status, state);
-}
-
-void DrmGpuPlatformSupportHost::OnHDCPStateUpdated(int64_t display_id,
- bool status) {
- display_manager_->GpuUpdatedHDCPState(display_id, status);
-}
-
-void DrmGpuPlatformSupportHost::OnTakeDisplayControl(bool status) {
- display_manager_->GpuTookDisplayControl(status);
-}
-
-void DrmGpuPlatformSupportHost::OnRelinquishDisplayControl(bool status) {
- display_manager_->GpuRelinquishedDisplayControl(status);
-}
-
-bool DrmGpuPlatformSupportHost::GpuRefreshNativeDisplays() {
- return Send(new OzoneGpuMsg_RefreshNativeDisplays());
-}
-
-bool DrmGpuPlatformSupportHost::GpuTakeDisplayControl() {
- return Send(new OzoneGpuMsg_TakeDisplayControl());
-}
-
-bool DrmGpuPlatformSupportHost::GpuRelinquishDisplayControl() {
- return Send(new OzoneGpuMsg_RelinquishDisplayControl());
-}
-
-bool DrmGpuPlatformSupportHost::GpuAddGraphicsDeviceOnUIThread(
- const base::FilePath& path,
- base::ScopedFD fd) {
- return Send(new OzoneGpuMsg_AddGraphicsDevice(
- path, base::FileDescriptor(std::move(fd))));
-}
-
-void DrmGpuPlatformSupportHost::GpuAddGraphicsDeviceOnIOThread(
- const base::FilePath& path,
- base::ScopedFD fd) {
- DCHECK(!send_callback_.is_null());
- send_callback_.Run(new OzoneGpuMsg_AddGraphicsDevice(
- path, base::FileDescriptor(std::move(fd))));
-}
-
-bool DrmGpuPlatformSupportHost::GpuRemoveGraphicsDevice(
- const base::FilePath& path) {
- return Send(new OzoneGpuMsg_RemoveGraphicsDevice(path));
-}
-
-// DrmDisplayHost
-bool DrmGpuPlatformSupportHost::GpuConfigureNativeDisplay(
- int64_t display_id,
- const ui::DisplayMode_Params& display_mode,
- const gfx::Point& point) {
- return Send(
- new OzoneGpuMsg_ConfigureNativeDisplay(display_id, display_mode, point));
-}
-
-bool DrmGpuPlatformSupportHost::GpuDisableNativeDisplay(int64_t display_id) {
- return Send(new OzoneGpuMsg_DisableNativeDisplay(display_id));
-}
-
-bool DrmGpuPlatformSupportHost::GpuGetHDCPState(int64_t display_id) {
- return Send(new OzoneGpuMsg_GetHDCPState(display_id));
-}
-
-bool DrmGpuPlatformSupportHost::GpuSetHDCPState(int64_t display_id,
- display::HDCPState state) {
- return Send(new OzoneGpuMsg_SetHDCPState(display_id, state));
-}
-
-bool DrmGpuPlatformSupportHost::GpuSetColorMatrix(
- int64_t display_id,
- const std::vector<float>& color_matrix) {
- return Send(new OzoneGpuMsg_SetColorMatrix(display_id, color_matrix));
-}
-
-bool DrmGpuPlatformSupportHost::GpuSetGammaCorrection(
- int64_t display_id,
- const std::vector<display::GammaRampRGBEntry>& degamma_lut,
- const std::vector<display::GammaRampRGBEntry>& gamma_lut) {
- return Send(
- new OzoneGpuMsg_SetGammaCorrection(display_id, degamma_lut, gamma_lut));
-}
-
-bool DrmGpuPlatformSupportHost::GpuDestroyWindow(
- gfx::AcceleratedWidget widget) {
- return Send(new OzoneGpuMsg_DestroyWindow(widget));
-}
-
-bool DrmGpuPlatformSupportHost::GpuSetPrivacyScreen(int64_t display_id,
- bool enabled) {
- return Send(new OzoneGpuMsg_SetPrivacyScreen(display_id, enabled));
-}
-
-bool DrmGpuPlatformSupportHost::GpuCreateWindow(
- gfx::AcceleratedWidget widget,
- const gfx::Rect& initial_bounds) {
- return Send(new OzoneGpuMsg_CreateWindow(widget, initial_bounds));
-}
-
-bool DrmGpuPlatformSupportHost::GpuWindowBoundsChanged(
- gfx::AcceleratedWidget widget,
- const gfx::Rect& bounds) {
- return Send(new OzoneGpuMsg_WindowBoundsChanged(widget, bounds));
-}
-
-} // namespace ui
diff --git a/chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h b/chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h
deleted file mode 100644
index 0d319cc3070..00000000000
--- a/chromium/ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h
+++ /dev/null
@@ -1,128 +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 UI_OZONE_PLATFORM_DRM_HOST_DRM_GPU_PLATFORM_SUPPORT_HOST_H_
-#define UI_OZONE_PLATFORM_DRM_HOST_DRM_GPU_PLATFORM_SUPPORT_HOST_H_
-
-#include <vector>
-
-#include "base/callback.h"
-#include "base/observer_list.h"
-#include "base/single_thread_task_runner.h"
-#include "ui/display/types/display_constants.h"
-#include "ui/gfx/native_widget_types.h"
-#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
-#include "ui/ozone/platform/drm/host/gpu_thread_adapter.h"
-#include "ui/ozone/public/gpu_platform_support_host.h"
-
-namespace gfx {
-class Point;
-}
-
-namespace ui {
-
-class DrmCursor;
-class DrmDisplayHostMananger;
-class GpuThreadObserver;
-
-class DrmGpuPlatformSupportHost : public GpuPlatformSupportHost,
- public GpuThreadAdapter,
- public IPC::Sender {
- public:
- explicit DrmGpuPlatformSupportHost(DrmCursor* cursor);
- ~DrmGpuPlatformSupportHost() override;
-
- // GpuPlatformSupportHost:
- void OnGpuProcessLaunched(
- int host_id,
- scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
- scoped_refptr<base::SingleThreadTaskRunner> send_runner,
- base::RepeatingCallback<void(IPC::Message*)> send_callback) override;
- void OnChannelDestroyed(int host_id) override;
- void OnGpuServiceLaunched(
- int host_id,
- scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
- scoped_refptr<base::SingleThreadTaskRunner> io_runner,
- GpuHostBindInterfaceCallback binder,
- GpuHostTerminateCallback terminate_callback) override;
-
- void OnMessageReceived(const IPC::Message& message) override;
-
- // IPC::Sender:
- bool Send(IPC::Message* message) override;
-
- // GpuThreadAdapter.
- // Core functionality.
- void AddGpuThreadObserver(GpuThreadObserver* observer) override;
- void RemoveGpuThreadObserver(GpuThreadObserver* observer) override;
- bool IsConnected() override;
-
- // Services needed for DrmDisplayHostMananger.
- void RegisterHandlerForDrmDisplayHostManager(
- DrmDisplayHostManager* handler) override;
- void UnRegisterHandlerForDrmDisplayHostManager() override;
-
- bool GpuTakeDisplayControl() override;
- bool GpuRefreshNativeDisplays() override;
- bool GpuRelinquishDisplayControl() override;
- bool GpuAddGraphicsDeviceOnUIThread(const base::FilePath& path,
- base::ScopedFD fd) override;
- void GpuAddGraphicsDeviceOnIOThread(const base::FilePath& path,
- base::ScopedFD fd) override;
- bool GpuRemoveGraphicsDevice(const base::FilePath& path) override;
-
- // Services needed by DrmDisplayHost
- bool GpuConfigureNativeDisplay(int64_t display_id,
- const ui::DisplayMode_Params& display_mode,
- const gfx::Point& point) override;
- bool GpuDisableNativeDisplay(int64_t display_id) override;
- bool GpuGetHDCPState(int64_t display_id) override;
- bool GpuSetHDCPState(int64_t display_id, display::HDCPState state) override;
- bool GpuSetColorMatrix(int64_t display_id,
- const std::vector<float>& color_matrix) override;
- bool GpuSetGammaCorrection(
- int64_t display_id,
- const std::vector<display::GammaRampRGBEntry>& degamma_lut,
- const std::vector<display::GammaRampRGBEntry>& gamma_lut) override;
- bool GpuSetPrivacyScreen(int64_t display_id, bool enabled) override;
-
- // Services needed by DrmWindowHost
- bool GpuDestroyWindow(gfx::AcceleratedWidget widget) override;
- bool GpuCreateWindow(gfx::AcceleratedWidget widget,
- const gfx::Rect& initial_bounds) override;
- bool GpuWindowBoundsChanged(gfx::AcceleratedWidget widget,
- const gfx::Rect& bounds) override;
-
- private:
- void OnChannelEstablished();
- void OnUpdateNativeDisplays(
- const std::vector<DisplaySnapshot_Params>& displays);
- void OnDisplayConfigured(int64_t display_id, bool status);
- void OnHDCPStateReceived(int64_t display_id,
- bool status,
- display::HDCPState state);
- void OnHDCPStateUpdated(int64_t display_id, bool status);
- void OnTakeDisplayControl(bool status);
- void OnRelinquishDisplayControl(bool status);
-
- int host_id_ = -1;
- bool channel_established_ = false;
-
- scoped_refptr<base::SingleThreadTaskRunner> ui_runner_;
- scoped_refptr<base::SingleThreadTaskRunner> send_runner_;
- base::RepeatingCallback<void(IPC::Message*)> send_callback_;
-
- DrmDisplayHostManager* display_manager_; // Not owned.
-
- DrmCursor* const cursor_; // Not owned.
- base::ObserverList<GpuThreadObserver>::Unchecked gpu_thread_observers_;
-
- base::WeakPtr<DrmGpuPlatformSupportHost> weak_ptr_;
- base::WeakPtrFactory<DrmGpuPlatformSupportHost> weak_ptr_factory_{this};
- DISALLOW_COPY_AND_ASSIGN(DrmGpuPlatformSupportHost);
-};
-
-} // namespace ui
-
-#endif // UI_OZONE_PLATFORM_DRM_HOST_DRM_GPU_PLATFORM_SUPPORT_HOST_H_
diff --git a/chromium/ui/ozone/platform/drm/host/drm_window_host_manager.cc b/chromium/ui/ozone/platform/drm/host/drm_window_host_manager.cc
index 14c2d46881c..268796f702a 100644
--- a/chromium/ui/ozone/platform/drm/host/drm_window_host_manager.cc
+++ b/chromium/ui/ozone/platform/drm/host/drm_window_host_manager.cc
@@ -4,7 +4,8 @@
#include "ui/ozone/platform/drm/host/drm_window_host_manager.h"
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "ui/ozone/platform/drm/host/drm_window_host.h"
namespace ui {
diff --git a/chromium/ui/ozone/platform/drm/host/gpu_thread_adapter.h b/chromium/ui/ozone/platform/drm/host/gpu_thread_adapter.h
index 5035672702e..d6c6804a586 100644
--- a/chromium/ui/ozone/platform/drm/host/gpu_thread_adapter.h
+++ b/chromium/ui/ozone/platform/drm/host/gpu_thread_adapter.h
@@ -10,7 +10,10 @@
#include "ui/display/types/gamma_ramp_rgb_entry.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/native_widget_types.h"
-#include "ui/ozone/common/gpu/ozone_gpu_message_params.h"
+
+namespace display {
+class DisplayMode;
+} // namespace display
namespace ui {
@@ -43,10 +46,9 @@ class GpuThreadAdapter {
virtual bool GpuRemoveGraphicsDevice(const base::FilePath& path) = 0;
// Services needed by DrmDisplayHost
- virtual bool GpuConfigureNativeDisplay(
- int64_t display_id,
- const ui::DisplayMode_Params& display_mode,
- const gfx::Point& point) = 0;
+ virtual bool GpuConfigureNativeDisplay(int64_t display_id,
+ const display::DisplayMode& pmode,
+ const gfx::Point& point) = 0;
virtual bool GpuDisableNativeDisplay(int64_t display_id) = 0;
virtual bool GpuGetHDCPState(int64_t display_id) = 0;
virtual bool GpuSetHDCPState(int64_t display_id,
diff --git a/chromium/ui/ozone/platform/drm/host/host_cursor_proxy.cc b/chromium/ui/ozone/platform/drm/host/host_cursor_proxy.cc
index 1486038b808..2900d45d868 100644
--- a/chromium/ui/ozone/platform/drm/host/host_cursor_proxy.cc
+++ b/chromium/ui/ozone/platform/drm/host/host_cursor_proxy.cc
@@ -7,7 +7,6 @@
#include <utility>
#include "base/threading/thread_task_runner_handle.h"
-#include "services/service_manager/public/cpp/connector.h"
#include "ui/ozone/public/gpu_platform_support_host.h"
namespace ui {
diff --git a/chromium/ui/ozone/platform/drm/host/host_drm_device.cc b/chromium/ui/ozone/platform/drm/host/host_drm_device.cc
index 922b895b423..a2ca1364f51 100644
--- a/chromium/ui/ozone/platform/drm/host/host_drm_device.cc
+++ b/chromium/ui/ozone/platform/drm/host/host_drm_device.cc
@@ -14,8 +14,8 @@
#include "base/task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
-#include "services/service_manager/public/cpp/connector.h"
#include "ui/display/types/display_snapshot.h"
+#include "ui/ozone/platform/drm/common/display_types.h"
#include "ui/ozone/platform/drm/common/drm_util.h"
#include "ui/ozone/platform/drm/host/drm_device_connector.h"
#include "ui/ozone/platform/drm/host/drm_display_host_manager.h"
@@ -129,14 +129,14 @@ bool HostDrmDevice::GpuRefreshNativeDisplays() {
}
bool HostDrmDevice::GpuConfigureNativeDisplay(int64_t id,
- const DisplayMode_Params& pmode,
+ const display::DisplayMode& pmode,
const gfx::Point& origin) {
DCHECK_CALLED_ON_VALID_THREAD(on_ui_thread_);
if (!IsConnected())
return false;
- // TODO(rjkroege): Remove the use of mode here.
- auto mode = CreateDisplayModeFromParams(pmode);
+ auto mode = std::make_unique<display::DisplayMode>(
+ pmode.size(), pmode.is_interlaced(), pmode.refresh_rate());
auto callback =
base::BindOnce(&HostDrmDevice::GpuConfigureNativeDisplayCallback, this);
@@ -272,12 +272,10 @@ void HostDrmDevice::GpuConfigureNativeDisplayCallback(int64_t display_id,
display_manager_->GpuConfiguredDisplay(display_id, success);
}
-// TODO(rjkroege): Remove the unnecessary conversion back into params.
void HostDrmDevice::GpuRefreshNativeDisplaysCallback(
- std::vector<std::unique_ptr<display::DisplaySnapshot>> displays) const {
+ MovableDisplaySnapshots displays) const {
DCHECK_CALLED_ON_VALID_THREAD(on_ui_thread_);
- display_manager_->GpuHasUpdatedNativeDisplays(
- CreateDisplaySnapshotParams(displays));
+ display_manager_->GpuHasUpdatedNativeDisplays(std::move(displays));
}
void HostDrmDevice::GpuDisableNativeDisplayCallback(int64_t display_id,
diff --git a/chromium/ui/ozone/platform/drm/host/host_drm_device.h b/chromium/ui/ozone/platform/drm/host/host_drm_device.h
index c88343d152a..fbe3723e419 100644
--- a/chromium/ui/ozone/platform/drm/host/host_drm_device.h
+++ b/chromium/ui/ozone/platform/drm/host/host_drm_device.h
@@ -16,16 +16,13 @@
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "ui/gfx/native_widget_types.h"
+#include "ui/ozone/platform/drm/common/display_types.h"
#include "ui/ozone/platform/drm/host/drm_cursor.h"
#include "ui/ozone/platform/drm/host/gpu_thread_adapter.h"
#include "ui/ozone/public/gpu_platform_support_host.h"
#include "ui/ozone/public/mojom/device_cursor.mojom.h"
#include "ui/ozone/public/mojom/drm_device.mojom.h"
-namespace display {
-class DisplaySnapshot;
-}
-
namespace ui {
class DrmDisplayHostManager;
class GpuThreadObserver;
@@ -69,7 +66,7 @@ class HostDrmDevice : public base::RefCountedThreadSafe<HostDrmDevice>,
// Services needed by DrmDisplayHost
bool GpuConfigureNativeDisplay(int64_t display_id,
- const ui::DisplayMode_Params& display_mode,
+ const display::DisplayMode& pmode,
const gfx::Point& point) override;
bool GpuDisableNativeDisplay(int64_t display_id) override;
bool GpuGetHDCPState(int64_t display_id) override;
@@ -97,14 +94,10 @@ class HostDrmDevice : public base::RefCountedThreadSafe<HostDrmDevice>,
void OnDrmServiceStarted();
- // TODO(rjkroege): Get rid of the need for this method in a subsequent CL.
- void PollForSingleThreadReady(int previous_delay);
-
void GpuConfigureNativeDisplayCallback(int64_t display_id,
bool success) const;
- void GpuRefreshNativeDisplaysCallback(
- std::vector<std::unique_ptr<display::DisplaySnapshot>> displays) const;
+ void GpuRefreshNativeDisplaysCallback(MovableDisplaySnapshots displays) const;
void GpuDisableNativeDisplayCallback(int64_t display_id, bool success) const;
void GpuTakeDisplayControlCallback(bool success) const;
void GpuRelinquishDisplayControlCallback(bool success) const;
diff --git a/chromium/ui/ozone/platform/drm/ozone_platform_gbm.cc b/chromium/ui/ozone/platform/drm/ozone_platform_gbm.cc
index 16d379a0e89..23786834484 100644
--- a/chromium/ui/ozone/platform/drm/ozone_platform_gbm.cc
+++ b/chromium/ui/ozone/platform/drm/ozone_platform_gbm.cc
@@ -11,10 +11,11 @@
#include <utility>
#include "base/bind.h"
+#include "base/check.h"
#include "base/command_line.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
+#include "base/notreached.h"
#include "base/threading/platform_thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
@@ -32,14 +33,12 @@
#include "ui/ozone/platform/drm/gpu/drm_framebuffer.h"
#include "ui/ozone/platform/drm/gpu/drm_gpu_display_manager.h"
#include "ui/ozone/platform/drm/gpu/drm_overlay_manager_gpu.h"
-#include "ui/ozone/platform/drm/gpu/drm_thread_message_proxy.h"
#include "ui/ozone/platform/drm/gpu/drm_thread_proxy.h"
#include "ui/ozone/platform/drm/gpu/gbm_surface_factory.h"
#include "ui/ozone/platform/drm/gpu/proxy_helpers.h"
#include "ui/ozone/platform/drm/host/drm_cursor.h"
#include "ui/ozone/platform/drm/host/drm_device_connector.h"
#include "ui/ozone/platform/drm/host/drm_display_host_manager.h"
-#include "ui/ozone/platform/drm/host/drm_gpu_platform_support_host.h"
#include "ui/ozone/platform/drm/host/drm_native_display_delegate.h"
#include "ui/ozone/platform/drm/host/drm_window_host.h"
#include "ui/ozone/platform/drm/host/drm_window_host_manager.h"
@@ -87,13 +86,6 @@ class OzonePlatformGbm : public OzonePlatform {
InputController* GetInputController() override {
return event_factory_ozone_->input_controller();
}
- IPC::MessageFilter* GetGpuMessageFilter() override {
- if (using_mojo_) {
- return nullptr;
- } else {
- return gpu_message_filter_.get();
- }
- }
std::unique_ptr<PlatformScreen> CreateScreen() override {
NOTREACHED();
@@ -101,11 +93,7 @@ class OzonePlatformGbm : public OzonePlatform {
}
GpuPlatformSupportHost* GetGpuPlatformSupportHost() override {
- if (using_mojo_) {
return drm_device_connector_.get();
- } else {
- return gpu_platform_support_host_.get();
- }
}
std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() override {
@@ -115,14 +103,10 @@ class OzonePlatformGbm : public OzonePlatform {
// In multi-process mode, this function must be executed in Viz as it sets up
// the callbacks needed for Mojo receivers. In single process mode, it may be
// called on any thread. It must follow one of |InitializeUI| or
- // |InitializeGPU|. Invocations of this method when not using mojo will be
- // ignored. While the caller may choose to invoke this method before entering
- // the sandbox, the actual interface adding has to happen on the DRM Device
- // thread and so will be deferred until the DRM thread is running.
+ // |InitializeGPU|. While the caller may choose to invoke this method before
+ // entering the sandbox, the actual interface adding has to happen on the DRM
+ // Device thread and so will be deferred until the DRM thread is running.
void AddInterfaces(mojo::BinderMap* binders) override {
- if (!using_mojo_)
- return;
-
binders->Add<ozone::mojom::DrmDevice>(
base::BindRepeating(&OzonePlatformGbm::CreateDrmDeviceReceiver,
weak_factory_.GetWeakPtr()),
@@ -153,10 +137,7 @@ class OzonePlatformGbm : public OzonePlatform {
std::unique_ptr<PlatformWindow> CreatePlatformWindow(
PlatformWindowDelegate* delegate,
PlatformWindowInitProperties properties) override {
- GpuThreadAdapter* adapter = gpu_platform_support_host_.get();
- if (using_mojo_) {
- adapter = host_drm_device_.get();
- }
+ GpuThreadAdapter* adapter = host_drm_device_.get();
auto platform_window = std::make_unique<DrmWindowHost>(
delegate, properties.bounds, adapter, event_factory_ozone_.get(),
@@ -185,16 +166,13 @@ class OzonePlatformGbm : public OzonePlatform {
}
void InitializeUI(const InitParams& args) override {
- // Ozone drm can operate in three modes configured at runtime.
- // 1. legacy mode where host and viz components communicate
- // via param traits IPC. This will be soon deprecated in favor of 3.
- // 2. single-process mode where host and viz components
+ // Ozone drm can operate in two modes configured at runtime.
+ // 1. single-process mode where host and viz components
// communicate via in-process mojo. Single-process mode can be single
// or multi-threaded.
- // 3. multi-process mode where host and viz components communicate
+ // 2. multi-process mode where host and viz components communicate
// via mojo IPC.
- using_mojo_ = args.using_mojo;
host_thread_ = base::PlatformThread::CurrentRef();
device_manager_ = CreateDeviceManager();
@@ -216,47 +194,28 @@ class OzonePlatformGbm : public OzonePlatform {
GpuThreadAdapter* adapter;
- if (using_mojo_) {
- host_drm_device_ = base::MakeRefCounted<HostDrmDevice>(cursor_.get());
- drm_device_connector_ =
- std::make_unique<DrmDeviceConnector>(host_drm_device_);
- adapter = host_drm_device_.get();
- } else {
- gpu_platform_support_host_ =
- std::make_unique<DrmGpuPlatformSupportHost>(cursor_.get());
- adapter = gpu_platform_support_host_.get();
- }
+ host_drm_device_ = base::MakeRefCounted<HostDrmDevice>(cursor_.get());
+ drm_device_connector_ =
+ std::make_unique<DrmDeviceConnector>(host_drm_device_);
+ adapter = host_drm_device_.get();
display_manager_ = std::make_unique<DrmDisplayHostManager>(
adapter, device_manager_.get(), &host_properties_,
event_factory_ozone_->input_controller());
cursor_factory_ozone_ = std::make_unique<BitmapCursorFactoryOzone>();
- if (using_mojo_)
- host_drm_device_->SetDisplayManager(display_manager_.get());
+ host_drm_device_->SetDisplayManager(display_manager_.get());
}
void InitializeGPU(const InitParams& args) override {
- using_mojo_ = args.using_mojo;
gpu_task_runner_ = base::ThreadTaskRunnerHandle::Get();
- InterThreadMessagingProxy* itmp;
- if (!using_mojo_) {
- scoped_refptr<DrmThreadMessageProxy> message_proxy(
- new DrmThreadMessageProxy());
- itmp = message_proxy.get();
- gpu_message_filter_ = std::move(message_proxy);
- }
-
// NOTE: Can't start the thread here since this is called before sandbox
// initialization in multi-process Chrome.
drm_thread_proxy_ = std::make_unique<DrmThreadProxy>();
surface_factory_ =
std::make_unique<GbmSurfaceFactory>(drm_thread_proxy_.get());
- if (!using_mojo_) {
- drm_thread_proxy_->BindThreadIntoMessagingProxy(itmp);
- }
overlay_manager_ =
std::make_unique<DrmOverlayManagerGpu>(drm_thread_proxy_.get());
@@ -266,12 +225,14 @@ class OzonePlatformGbm : public OzonePlatform {
if (!single_process())
return;
- // In single process/mojo mode we need to make sure DrainReceiverRequest is
- // executed on this thread before we start the drm device.
- const bool block_for_drm_thread = using_mojo_;
+ // Note we exit this code above when running in multiple processes and so
+ // following code only executes in single process mode. In single process
+ // mode we need to make sure DrainReceiverRequest is executed on this thread
+ // before we start the drm device.
+ const bool block_for_drm_thread = true;
StartDrmThread(block_for_drm_thread);
- if (using_mojo_ && host_thread_ == base::PlatformThread::CurrentRef()) {
+ if (host_thread_ == base::PlatformThread::CurrentRef()) {
CHECK(has_initialized_ui()) << "Mojo single-thread mode requires "
"InitializeUI to be called first.";
// Connect host and gpu here since OnGpuServiceLaunched() is not called in
@@ -319,12 +280,9 @@ class OzonePlatformGbm : public OzonePlatform {
}
}
- bool using_mojo_ = false;
-
// Objects in the GPU process.
std::unique_ptr<DrmThreadProxy> drm_thread_proxy_;
std::unique_ptr<GbmSurfaceFactory> surface_factory_;
- scoped_refptr<IPC::MessageFilter> gpu_message_filter_;
scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner_;
std::unique_ptr<DrmOverlayManager> overlay_manager_;
@@ -334,16 +292,11 @@ class OzonePlatformGbm : public OzonePlatform {
pending_gpu_adapter_receivers_;
bool drm_thread_started_ = false;
- // gpu_platform_support_host_ is the IPC bridge to the GPU process while
// host_drm_device_ is the mojo bridge to the Viz process. Only one can be in
// use at any time.
- // TODO(rjkroege): Remove gpu_platform_support_host_ once ozone/drm with mojo
- // has reached the stable channel.
- // A raw pointer to either |gpu_platform_support_host_| or |host_drm_device_|
- // is passed to |display_manager_| in InitializeUI(). To avoid a use after
- // free, the following two members should be declared before the two managers,
- // so that they're deleted after them.
- std::unique_ptr<DrmGpuPlatformSupportHost> gpu_platform_support_host_;
+ // A raw pointer to |host_drm_device_| is passed to |display_manager_| in
+ // InitializeUI(). To avoid a use after free, the following two members should
+ // be declared before the two managers, so that they're deleted after them.
// Objects in the host process.
#if BUILDFLAG(USE_XKBCOMMON)
diff --git a/chromium/ui/ozone/platform/headless/headless_surface_factory.cc b/chromium/ui/ozone/platform/headless/headless_surface_factory.cc
index fc1f019133f..9d77b6c3f6a 100644
--- a/chromium/ui/ozone/platform/headless/headless_surface_factory.cc
+++ b/chromium/ui/ozone/platform/headless/headless_surface_factory.cc
@@ -55,8 +55,7 @@ void WriteDataToFile(const base::FilePath& location, const SkBitmap& bitmap) {
DCHECK(!location.empty());
std::vector<unsigned char> png_data;
gfx::PNGCodec::FastEncodeBGRASkBitmap(bitmap, true, &png_data);
- if (base::WriteFile(location, reinterpret_cast<const char*>(png_data.data()),
- png_data.size()) < 0) {
+ if (!base::WriteFile(location, png_data)) {
static bool logged_once = false;
LOG_IF(ERROR, !logged_once)
<< "Failed to write frame to file. "
diff --git a/chromium/ui/ozone/platform/scenic/BUILD.gn b/chromium/ui/ozone/platform/scenic/BUILD.gn
index f927e8dda1c..ed6dd8a0f29 100644
--- a/chromium/ui/ozone/platform/scenic/BUILD.gn
+++ b/chromium/ui/ozone/platform/scenic/BUILD.gn
@@ -46,6 +46,7 @@ source_set("scenic") {
"//mojo/public/cpp/system",
"//services/service_manager/public/cpp",
"//skia",
+ "//third_party/angle/src/common/fuchsia_egl",
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.images",
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.mem",
"//third_party/fuchsia-sdk/sdk/fidl/fuchsia.sysmem",
diff --git a/chromium/ui/ozone/platform/scenic/DEPS b/chromium/ui/ozone/platform/scenic/DEPS
index 59ecb7ae9a9..c295f5d44b4 100644
--- a/chromium/ui/ozone/platform/scenic/DEPS
+++ b/chromium/ui/ozone/platform/scenic/DEPS
@@ -1,6 +1,7 @@
include_rules = [
"+gpu/ipc/common",
"+mojo/public",
+ "+third_party/angle/src/common/fuchsia_egl",
"+third_party/skia/include",
"+gpu/ipc/common",
]
diff --git a/chromium/ui/ozone/platform/scenic/ozone_platform_scenic.cc b/chromium/ui/ozone/platform/scenic/ozone_platform_scenic.cc
index d05d7fbe1fa..c9f0f74031d 100644
--- a/chromium/ui/ozone/platform/scenic/ozone_platform_scenic.cc
+++ b/chromium/ui/ozone/platform/scenic/ozone_platform_scenic.cc
@@ -8,11 +8,12 @@
#include <utility>
#include <vector>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/message_loop/message_loop_current.h"
#include "base/message_loop/message_pump_type.h"
+#include "base/notreached.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "ui/base/cursor/ozone/bitmap_cursor_factory_ozone.h"
#include "ui/base/ime/fuchsia/input_method_fuchsia.h"
@@ -46,8 +47,9 @@ constexpr OzonePlatform::PlatformProperties kScenicPlatformProperties{
/*needs_view_token=*/true,
/*custom_frame_pref_default=*/false,
/*use_system_title_bar=*/false,
- /*requires_mojo=*/true,
- /*message_pump_type_for_gpu=*/base::MessagePumpType::IO};
+ /*message_pump_type_for_gpu=*/base::MessagePumpType::IO,
+ /*supports_vulkan_swap_chain=*/true,
+};
class ScenicPlatformEventSource : public ui::PlatformEventSource {
public:
@@ -95,6 +97,7 @@ class OzonePlatformScenic
std::unique_ptr<PlatformWindow> CreatePlatformWindow(
PlatformWindowDelegate* delegate,
PlatformWindowInitProperties properties) override {
+ BindInMainProcessIfNecessary();
if (!properties.view_token.value) {
NOTREACHED();
return nullptr;
@@ -136,36 +139,31 @@ class OzonePlatformScenic
input_controller_ = CreateStubInputController();
cursor_factory_ozone_ = std::make_unique<BitmapCursorFactoryOzone>();
- base::MessageLoopCurrent::Get()->AddDestructionObserver(this);
-
scenic_gpu_host_ = std::make_unique<ScenicGpuHost>(window_manager_.get());
// SurfaceFactory is configured here to use a ui-process remote for software
// output.
- surface_factory_ = std::make_unique<ScenicSurfaceFactory>(
- scenic_gpu_host_->CreateHostProcessSelfRemote());
+ if (!surface_factory_)
+ surface_factory_ = std::make_unique<ScenicSurfaceFactory>();
+
+ if (base::ThreadTaskRunnerHandle::IsSet())
+ BindInMainProcessIfNecessary();
}
void InitializeGPU(const InitParams& params) override {
- if (params.single_process) {
- if (!surface_factory_) {
- // Without calling InitializeForUI, window surfaces cannot be created.
- // Some test such as gpu_unittests do this.
- // TODO(spang): This is not ideal; perhaps we should move the GL &
- // vulkan initializers out of SurfaceFactoryOzone.
- surface_factory_ =
- std::make_unique<ScenicSurfaceFactory>(mojo::NullRemote());
- }
- } else {
- DCHECK(!surface_factory_);
+ DCHECK(!surface_factory_ || params.single_process);
+
+ if (!surface_factory_)
+ surface_factory_ = std::make_unique<ScenicSurfaceFactory>();
+
+ if (!params.single_process) {
mojo::PendingRemote<mojom::ScenicGpuHost> scenic_gpu_host_remote;
scenic_gpu_service_ = std::make_unique<ScenicGpuService>(
scenic_gpu_host_remote.InitWithNewPipeAndPassReceiver());
// SurfaceFactory is configured here to use a gpu-process remote. The
// other end of the pipe will be attached through ScenicGpuService.
- surface_factory_ = std::make_unique<ScenicSurfaceFactory>(
- std::move(scenic_gpu_host_remote));
+ surface_factory_->Initialize(std::move(scenic_gpu_host_remote));
}
}
@@ -181,19 +179,31 @@ class OzonePlatformScenic
}
private:
- // base::MessageLoopCurrent::DestructionObserver implementation.
- void WillDestroyCurrentMessageLoop() override {
- // We must ensure to destroy any resources which rely on the MessageLoop's
- // async_dispatcher.
- surface_factory_ = nullptr;
- scenic_gpu_host_ = nullptr;
- overlay_manager_ = nullptr;
- input_controller_ = nullptr;
- cursor_factory_ozone_ = nullptr;
- platform_event_source_ = nullptr;
- window_manager_ = nullptr;
+ // Binds main process surface factory to main process ScenicGpuHost
+ void BindInMainProcessIfNecessary() {
+ if (bound_in_main_process_)
+ return;
+
+ mojo::PendingRemote<mojom::ScenicGpuHost> gpu_host_remote;
+ scenic_gpu_host_->Initialize(
+ gpu_host_remote.InitWithNewPipeAndPassReceiver());
+ surface_factory_->Initialize(std::move(gpu_host_remote));
+ bound_in_main_process_ = true;
+
+ base::MessageLoopCurrent::Get()->AddDestructionObserver(this);
+ }
+
+ void ShutdownInMainProcess() {
+ DCHECK(bound_in_main_process_);
+ surface_factory_->Shutdown();
+ scenic_gpu_host_->Shutdown();
+ window_manager_->Shutdown();
+ bound_in_main_process_ = false;
}
+ // base::MessageLoopCurrent::DestructionObserver implementation.
+ void WillDestroyCurrentMessageLoop() override { ShutdownInMainProcess(); }
+
std::unique_ptr<ScenicWindowManager> window_manager_;
std::unique_ptr<KeyboardLayoutEngine> keyboard_layout_engine_;
@@ -205,6 +215,9 @@ class OzonePlatformScenic
std::unique_ptr<ScenicGpuService> scenic_gpu_service_;
std::unique_ptr<ScenicSurfaceFactory> surface_factory_;
+ // Whether the main process has initialized mojo bindings.
+ bool bound_in_main_process_ = false;
+
DISALLOW_COPY_AND_ASSIGN(OzonePlatformScenic);
};
diff --git a/chromium/ui/ozone/platform/scenic/scenic_gpu_host.cc b/chromium/ui/ozone/platform/scenic/scenic_gpu_host.cc
index e596541637f..878f1ca85e1 100644
--- a/chromium/ui/ozone/platform/scenic/scenic_gpu_host.cc
+++ b/chromium/ui/ozone/platform/scenic/scenic_gpu_host.cc
@@ -35,19 +35,32 @@ void BindInterface(mojo::PendingReceiver<Interface> receiver,
namespace ui {
ScenicGpuHost::ScenicGpuHost(ScenicWindowManager* scenic_window_manager)
- : scenic_window_manager_(scenic_window_manager),
- ui_thread_runner_(base::ThreadTaskRunnerHandle::Get()) {
+ : scenic_window_manager_(scenic_window_manager) {
DETACH_FROM_THREAD(io_thread_checker_);
}
ScenicGpuHost::~ScenicGpuHost() {
+ Shutdown();
+}
+
+void ScenicGpuHost::Initialize(
+ mojo::PendingReceiver<mojom::ScenicGpuHost> host_receiver) {
DCHECK_CALLED_ON_VALID_THREAD(ui_thread_checker_);
+
+ DCHECK(!ui_thread_runner_);
+ ui_thread_runner_ = base::ThreadTaskRunnerHandle::Get();
+ DCHECK(ui_thread_runner_);
+
+ host_receiver_.Bind(std::move(host_receiver));
}
-mojo::PendingRemote<mojom::ScenicGpuHost>
-ScenicGpuHost::CreateHostProcessSelfRemote() {
- DCHECK(!host_receiver_.is_bound());
- return host_receiver_.BindNewPipeAndPassRemote();
+void ScenicGpuHost::Shutdown() {
+ DCHECK_CALLED_ON_VALID_THREAD(ui_thread_checker_);
+
+ ui_thread_runner_ = nullptr;
+ host_receiver_.reset();
+ gpu_receiver_.reset();
+ gpu_service_.reset();
}
void ScenicGpuHost::AttachSurfaceToWindow(
@@ -63,14 +76,6 @@ void ScenicGpuHost::AttachSurfaceToWindow(
scenic_window->AttachSurfaceView(std::move(surface_view_holder_token));
}
-void ScenicGpuHost::OnGpuProcessLaunched(
- int host_id,
- scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
- scoped_refptr<base::SingleThreadTaskRunner> send_runner,
- base::RepeatingCallback<void(IPC::Message*)> send_callback) {
- NOTREACHED();
-}
-
void ScenicGpuHost::OnChannelDestroyed(int host_id) {}
void ScenicGpuHost::OnGpuServiceLaunched(
@@ -100,8 +105,4 @@ void ScenicGpuHost::OnGpuServiceLaunchedOnUI(
gpu_service_->Initialize(gpu_receiver_.BindNewPipeAndPassRemote());
}
-void ScenicGpuHost::OnMessageReceived(const IPC::Message& message) {
- NOTREACHED();
-}
-
} // namespace ui
diff --git a/chromium/ui/ozone/platform/scenic/scenic_gpu_host.h b/chromium/ui/ozone/platform/scenic/scenic_gpu_host.h
index 25d073ba0fe..4bf26775ead 100644
--- a/chromium/ui/ozone/platform/scenic/scenic_gpu_host.h
+++ b/chromium/ui/ozone/platform/scenic/scenic_gpu_host.h
@@ -35,9 +35,12 @@ class ScenicGpuHost : public mojom::ScenicGpuHost,
ScenicGpuHost(ScenicWindowManager* scenic_window_manager);
~ScenicGpuHost() override;
- // Creates browser process remote. This is used to create a software output
- // on the UI thread.
- mojo::PendingRemote<mojom::ScenicGpuHost> CreateHostProcessSelfRemote();
+ // Binds the receiver for the main process surface factory.
+ void Initialize(mojo::PendingReceiver<mojom::ScenicGpuHost> pending_receiver);
+
+ // Shuts down mojo service. After calling shutdown, it's safe to call
+ // Initialize() again.
+ void Shutdown();
// mojom::ScenicGpuHost:
void AttachSurfaceToWindow(
@@ -45,13 +48,7 @@ class ScenicGpuHost : public mojom::ScenicGpuHost,
mojo::PlatformHandle surface_view_holder_token_mojo) override;
// GpuPlatformSupportHost:
- void OnGpuProcessLaunched(
- int host_id,
- scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
- scoped_refptr<base::SingleThreadTaskRunner> send_runner,
- base::RepeatingCallback<void(IPC::Message*)> send_callback) override;
void OnChannelDestroyed(int host_id) override;
- void OnMessageReceived(const IPC::Message& message) override;
void OnGpuServiceLaunched(
int host_id,
scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
diff --git a/chromium/ui/ozone/platform/scenic/scenic_surface_factory.cc b/chromium/ui/ozone/platform/scenic/scenic_surface_factory.cc
index 14053720363..7280c5e154f 100644
--- a/chromium/ui/ozone/platform/scenic/scenic_surface_factory.cc
+++ b/chromium/ui/ozone/platform/scenic/scenic_surface_factory.cc
@@ -13,6 +13,7 @@
#include "base/fuchsia/fuchsia_logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
+#include "third_party/angle/src/common/fuchsia_egl/fuchsia_egl.h"
#include "ui/gfx/native_pixmap.h"
#include "ui/gfx/skia_util.h"
#include "ui/gfx/vsync_provider.h"
@@ -34,16 +35,77 @@ namespace ui {
namespace {
+struct FuchsiaEGLWindowDeleter {
+ void operator()(fuchsia_egl_window* egl_window) {
+ fuchsia_egl_window_destroy(egl_window);
+ }
+};
+
+fuchsia::ui::scenic::ScenicPtr ConnectToScenic() {
+ fuchsia::ui::scenic::ScenicPtr scenic =
+ base::fuchsia::ComponentContextForCurrentProcess()
+ ->svc()
+ ->Connect<fuchsia::ui::scenic::Scenic>();
+ scenic.set_error_handler([](zx_status_t status) {
+ ZX_LOG(FATAL, status) << "Scenic connection failed";
+ });
+ return scenic;
+}
+
+class GLSurfaceFuchsiaImagePipe : public gl::NativeViewGLSurfaceEGL {
+ public:
+ explicit GLSurfaceFuchsiaImagePipe(
+ ScenicSurfaceFactory* scenic_surface_factory,
+ gfx::AcceleratedWidget widget)
+ : NativeViewGLSurfaceEGL(0, nullptr),
+ scenic_surface_factory_(scenic_surface_factory),
+ widget_(widget) {}
+ GLSurfaceFuchsiaImagePipe(const GLSurfaceFuchsiaImagePipe&) = delete;
+ GLSurfaceFuchsiaImagePipe& operator=(const GLSurfaceFuchsiaImagePipe&) =
+ delete;
+
+ // gl::NativeViewGLSurfaceEGL:
+ bool InitializeNativeWindow() override {
+ fuchsia::images::ImagePipe2Ptr image_pipe;
+ ScenicSurface* scenic_surface =
+ scenic_surface_factory_->GetSurface(widget_);
+ scenic_surface->SetTextureToNewImagePipe(image_pipe.NewRequest());
+ egl_window_.reset(
+ fuchsia_egl_window_create(image_pipe.Unbind().TakeChannel().release(),
+ size_.width(), size_.height()));
+ window_ = reinterpret_cast<EGLNativeWindowType>(egl_window_.get());
+ return true;
+ }
+
+ bool Resize(const gfx::Size& size,
+ float scale_factor,
+ const gfx::ColorSpace& color_space,
+ bool has_alpha) override {
+ fuchsia_egl_window_resize(egl_window_.get(), size.width(), size.height());
+ return gl::NativeViewGLSurfaceEGL::Resize(size, scale_factor, color_space,
+ has_alpha);
+ }
+
+ private:
+ ~GLSurfaceFuchsiaImagePipe() override {}
+
+ ScenicSurfaceFactory* const scenic_surface_factory_;
+ gfx::AcceleratedWidget widget_ = gfx::kNullAcceleratedWidget;
+ std::unique_ptr<fuchsia_egl_window, FuchsiaEGLWindowDeleter> egl_window_;
+};
+
class GLOzoneEGLScenic : public GLOzoneEGL {
public:
- GLOzoneEGLScenic() = default;
+ explicit GLOzoneEGLScenic(ScenicSurfaceFactory* scenic_surface_factory)
+ : scenic_surface_factory_(scenic_surface_factory) {}
~GLOzoneEGLScenic() override = default;
// GLOzone:
scoped_refptr<gl::GLSurface> CreateViewGLSurface(
gfx::AcceleratedWidget window) override {
- NOTIMPLEMENTED();
- return nullptr;
+ return gl::InitializeGLSurface(
+ base::MakeRefCounted<GLSurfaceFuchsiaImagePipe>(scenic_surface_factory_,
+ window));
}
scoped_refptr<gl::GLSurface> CreateOffscreenGLSurface(
@@ -62,11 +124,12 @@ class GLOzoneEGLScenic : public GLOzoneEGL {
}
private:
+ ScenicSurfaceFactory* const scenic_surface_factory_;
DISALLOW_COPY_AND_ASSIGN(GLOzoneEGLScenic);
};
-fuchsia::sysmem::AllocatorSyncPtr ConnectSysmemAllocator() {
- fuchsia::sysmem::AllocatorSyncPtr allocator;
+fuchsia::sysmem::AllocatorHandle ConnectSysmemAllocator() {
+ fuchsia::sysmem::AllocatorHandle allocator;
base::fuchsia::ComponentContextForCurrentProcess()->svc()->Connect(
allocator.NewRequest());
return allocator;
@@ -74,24 +137,46 @@ fuchsia::sysmem::AllocatorSyncPtr ConnectSysmemAllocator() {
} // namespace
-ScenicSurfaceFactory::ScenicSurfaceFactory(
- mojo::PendingRemote<mojom::ScenicGpuHost> gpu_host)
- : gpu_host_(std::move(gpu_host)),
- egl_implementation_(std::make_unique<GLOzoneEGLScenic>()),
- sysmem_buffer_manager_(ConnectSysmemAllocator()),
- weak_ptr_factory_(this) {
- // TODO(spang, crbug.com/923445): Add message loop to GPU tests.
- if (base::ThreadTaskRunnerHandle::IsSet())
- main_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get();
-}
+ScenicSurfaceFactory::ScenicSurfaceFactory()
+ : egl_implementation_(std::make_unique<GLOzoneEGLScenic>(this)),
+ weak_ptr_factory_(this) {}
ScenicSurfaceFactory::~ScenicSurfaceFactory() {
+ Shutdown();
+}
+
+void ScenicSurfaceFactory::Initialize(
+ mojo::PendingRemote<mojom::ScenicGpuHost> gpu_host) {
+ DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
+ base::AutoLock lock(surface_lock_);
+ DCHECK(surface_map_.empty());
+
+ main_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get();
+ DCHECK(main_thread_task_runner_);
+
+ DCHECK(!gpu_host_);
+ gpu_host_.Bind(std::move(gpu_host));
+
+ sysmem_buffer_manager_.Initialize(ConnectSysmemAllocator());
+
+ // Scenic is lazily connected to avoid a dependency in headless mode.
+ DCHECK(!scenic_);
+}
+
+void ScenicSurfaceFactory::Shutdown() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
+ base::AutoLock lock(surface_lock_);
+ DCHECK(surface_map_.empty());
+ main_thread_task_runner_ = nullptr;
+ gpu_host_.reset();
+ sysmem_buffer_manager_.Shutdown();
+ scenic_ = nullptr;
}
std::vector<gl::GLImplementation>
ScenicSurfaceFactory::GetAllowedGLImplementations() {
return std::vector<gl::GLImplementation>{
+ gl::kGLImplementationEGLANGLE,
gl::kGLImplementationSwiftShaderGL,
gl::kGLImplementationEGLGLES2,
gl::kGLImplementationStubGL,
@@ -102,6 +187,7 @@ GLOzone* ScenicSurfaceFactory::GetGLOzone(gl::GLImplementation implementation) {
switch (implementation) {
case gl::kGLImplementationSwiftShaderGL:
case gl::kGLImplementationEGLGLES2:
+ case gl::kGLImplementationEGLANGLE:
return egl_implementation_.get();
default:
return nullptr;
@@ -197,38 +283,22 @@ ScenicSurfaceFactory::CreateScenicSession() {
fuchsia::ui::scenic::SessionPtr session;
fidl::InterfaceHandle<fuchsia::ui::scenic::SessionListener> listener_handle;
auto listener_request = listener_handle.NewRequest();
- auto create_session_task =
- base::BindOnce(&ScenicSurfaceFactory::CreateScenicSessionOnMainThread,
- weak_ptr_factory_.GetWeakPtr(), session.NewRequest(),
- listener_handle.Bind());
- if (main_thread_task_runner_->BelongsToCurrentThread()) {
- // In a single threaded environment, we need to connect the session
- // before returning so that synchronous calls do not deadlock the
- // current thread.
- std::move(create_session_task).Run();
- } else {
- main_thread_task_runner_->PostTask(FROM_HERE,
- std::move(create_session_task));
+
+ {
+ // Cache Scenic connection for main thread. For other treads create
+ // one-shot connection.
+ fuchsia::ui::scenic::ScenicPtr local_scenic;
+ fuchsia::ui::scenic::ScenicPtr* scenic =
+ main_thread_task_runner_->BelongsToCurrentThread() ? &scenic_
+ : &local_scenic;
+ if (!*scenic)
+ *scenic = ConnectToScenic();
+ (*scenic)->CreateSession(session.NewRequest(), std::move(listener_handle));
}
return {std::move(session), std::move(listener_request)};
}
-void ScenicSurfaceFactory::CreateScenicSessionOnMainThread(
- fidl::InterfaceRequest<fuchsia::ui::scenic::Session> session_request,
- fidl::InterfaceHandle<fuchsia::ui::scenic::SessionListener> listener) {
- DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
- if (!scenic_) {
- scenic_ = base::fuchsia::ComponentContextForCurrentProcess()
- ->svc()
- ->Connect<fuchsia::ui::scenic::Scenic>();
- scenic_.set_error_handler([](zx_status_t status) {
- ZX_LOG(FATAL, status) << "Scenic connection failed";
- });
- }
- scenic_->CreateSession(std::move(session_request), std::move(listener));
-}
-
void ScenicSurfaceFactory::AttachSurfaceToWindow(
gfx::AcceleratedWidget window,
mojo::PlatformHandle surface_view_holder_token_mojo) {
diff --git a/chromium/ui/ozone/platform/scenic/scenic_surface_factory.h b/chromium/ui/ozone/platform/scenic/scenic_surface_factory.h
index a14be294357..945d72429de 100644
--- a/chromium/ui/ozone/platform/scenic/scenic_surface_factory.h
+++ b/chromium/ui/ozone/platform/scenic/scenic_surface_factory.h
@@ -30,10 +30,17 @@ class ScenicSurface;
class ScenicSurfaceFactory : public SurfaceFactoryOzone {
public:
- explicit ScenicSurfaceFactory(
- mojo::PendingRemote<mojom::ScenicGpuHost> gpu_host);
+ ScenicSurfaceFactory();
~ScenicSurfaceFactory() override;
+ // Initializes the surface factory. Binds the surface factory to the
+ // current thread (and thus must run with a message loop).
+ void Initialize(mojo::PendingRemote<mojom::ScenicGpuHost> gpu_host);
+
+ // Disconnects from ScenicGpuHost and detaches from the current thread.
+ // After shutting down, it is safe to call Initialize() again.
+ void Shutdown();
+
// SurfaceFactoryOzone implementation.
std::vector<gl::GLImplementation> GetAllowedGLImplementations() override;
GLOzone* GetGLOzone(gl::GLImplementation implementation) override;
@@ -83,11 +90,6 @@ class ScenicSurfaceFactory : public SurfaceFactoryOzone {
// Creates a new scenic session on any thread.
scenic::SessionPtrAndListenerRequest CreateScenicSession();
- // Creates a new scenic session on the main thread.
- void CreateScenicSessionOnMainThread(
- fidl::InterfaceRequest<fuchsia::ui::scenic::Session> session_request,
- fidl::InterfaceHandle<fuchsia::ui::scenic::SessionListener> listener);
-
// Links a surface to its parent window in the host process.
void AttachSurfaceToWindow(
gfx::AcceleratedWidget window,
@@ -97,7 +99,7 @@ class ScenicSurfaceFactory : public SurfaceFactoryOzone {
GUARDED_BY(surface_lock_);
base::Lock surface_lock_;
- mojo::Remote<mojom::ScenicGpuHost> const gpu_host_;
+ mojo::Remote<mojom::ScenicGpuHost> gpu_host_;
std::unique_ptr<GLOzone> egl_implementation_;
fuchsia::ui::scenic::ScenicPtr scenic_;
diff --git a/chromium/ui/ozone/platform/scenic/scenic_window_manager.cc b/chromium/ui/ozone/platform/scenic/scenic_window_manager.cc
index 8c43500bea5..b8a8c539251 100644
--- a/chromium/ui/ozone/platform/scenic/scenic_window_manager.cc
+++ b/chromium/ui/ozone/platform/scenic/scenic_window_manager.cc
@@ -14,7 +14,15 @@
namespace ui {
ScenicWindowManager::ScenicWindowManager() = default;
-ScenicWindowManager::~ScenicWindowManager() = default;
+
+ScenicWindowManager::~ScenicWindowManager() {
+ Shutdown();
+}
+
+void ScenicWindowManager::Shutdown() {
+ DCHECK(windows_.IsEmpty());
+ scenic_ = nullptr;
+}
std::unique_ptr<PlatformScreen> ScenicWindowManager::CreateScreen() {
DCHECK(windows_.IsEmpty());
diff --git a/chromium/ui/ozone/platform/scenic/scenic_window_manager.h b/chromium/ui/ozone/platform/scenic/scenic_window_manager.h
index d8ce93528bd..a3861f54d8e 100644
--- a/chromium/ui/ozone/platform/scenic/scenic_window_manager.h
+++ b/chromium/ui/ozone/platform/scenic/scenic_window_manager.h
@@ -33,6 +33,9 @@ class COMPONENT_EXPORT(OZONE) ScenicWindowManager {
ScenicWindowManager();
~ScenicWindowManager();
+ // Shuts down the window manager.
+ void Shutdown();
+
std::unique_ptr<PlatformScreen> CreateScreen();
// Scenic interface that is used by ScenicWindow instances. The interface
diff --git a/chromium/ui/ozone/platform/scenic/sysmem_buffer_manager.cc b/chromium/ui/ozone/platform/scenic/sysmem_buffer_manager.cc
index 654a4a5ea1e..2d0a2d5869a 100644
--- a/chromium/ui/ozone/platform/scenic/sysmem_buffer_manager.cc
+++ b/chromium/ui/ozone/platform/scenic/sysmem_buffer_manager.cc
@@ -12,13 +12,24 @@
namespace ui {
-SysmemBufferManager::SysmemBufferManager(
- fuchsia::sysmem::AllocatorSyncPtr allocator)
- : allocator_(std::move(allocator)) {}
+SysmemBufferManager::SysmemBufferManager() = default;
SysmemBufferManager::~SysmemBufferManager() {
+ Shutdown();
+}
+
+void SysmemBufferManager::Initialize(
+ fuchsia::sysmem::AllocatorHandle allocator) {
+ base::AutoLock auto_lock(collections_lock_);
+ DCHECK(collections_.empty());
+ DCHECK(!allocator_);
+ allocator_.Bind(std::move(allocator));
+}
+
+void SysmemBufferManager::Shutdown() {
base::AutoLock auto_lock(collections_lock_);
DCHECK(collections_.empty());
+ allocator_ = nullptr;
}
scoped_refptr<SysmemBufferCollection> SysmemBufferManager::CreateCollection(
diff --git a/chromium/ui/ozone/platform/scenic/sysmem_buffer_manager.h b/chromium/ui/ozone/platform/scenic/sysmem_buffer_manager.h
index b20d52ea820..b726855beb2 100644
--- a/chromium/ui/ozone/platform/scenic/sysmem_buffer_manager.h
+++ b/chromium/ui/ozone/platform/scenic/sysmem_buffer_manager.h
@@ -26,9 +26,16 @@ class SysmemBufferCollection;
class SysmemBufferManager {
public:
- explicit SysmemBufferManager(fuchsia::sysmem::AllocatorSyncPtr allocator);
+ explicit SysmemBufferManager();
~SysmemBufferManager();
+ // Initializes the buffer manager with a connection to the sysmem service.
+ void Initialize(fuchsia::sysmem::AllocatorHandle allocator);
+
+ // Disconnects from the sysmem service. After disconnecting, it's safe to call
+ // Initialize() again.
+ void Shutdown();
+
scoped_refptr<SysmemBufferCollection> CreateCollection(
VkDevice vk_device,
gfx::Size size,
@@ -61,4 +68,4 @@ class SysmemBufferManager {
} // namespace ui
-#endif // UI_OZONE_PLATFORM_SCENIC_SYSMEM_BUFFER_MANAGER_H_ \ No newline at end of file
+#endif // UI_OZONE_PLATFORM_SCENIC_SYSMEM_BUFFER_MANAGER_H_
diff --git a/chromium/ui/ozone/platform/scenic/vulkan_implementation_scenic.cc b/chromium/ui/ozone/platform/scenic/vulkan_implementation_scenic.cc
index 599c0cb345e..ce74e4b9cf8 100644
--- a/chromium/ui/ozone/platform/scenic/vulkan_implementation_scenic.cc
+++ b/chromium/ui/ozone/platform/scenic/vulkan_implementation_scenic.cc
@@ -111,7 +111,7 @@ VulkanImplementationScenic::CreateViewSurface(gfx::AcceleratedWidget window) {
}
return std::make_unique<gpu::VulkanSurface>(
- vulkan_instance_.vk_instance(), surface,
+ vulkan_instance_.vk_instance(), window, surface,
enforce_protected_memory() /* use_protected_memory */);
}
diff --git a/chromium/ui/ozone/platform/wayland/BUILD.gn b/chromium/ui/ozone/platform/wayland/BUILD.gn
index cb2257c898b..b0ec8a82a5e 100644
--- a/chromium/ui/ozone/platform/wayland/BUILD.gn
+++ b/chromium/ui/ozone/platform/wayland/BUILD.gn
@@ -6,6 +6,7 @@ visibility = [ "//ui/ozone/*" ]
import("//build/config/linux/gtk/gtk.gni")
import("//build/config/linux/pkg_config.gni")
+import("//gpu/vulkan/features.gni")
import("//testing/libfuzzer/fuzzer_test.gni")
import("//ui/ozone/platform/wayland/wayland.gni")
@@ -42,12 +43,6 @@ source_set("wayland") {
"host/gtk_primary_selection_offer.h",
"host/gtk_primary_selection_source.cc",
"host/gtk_primary_selection_source.h",
- "host/internal/wayland_data_device_base.cc",
- "host/internal/wayland_data_device_base.h",
- "host/internal/wayland_data_offer_base.cc",
- "host/internal/wayland_data_offer_base.h",
- "host/internal/wayland_data_source_base.cc",
- "host/internal/wayland_data_source_base.h",
"host/shell_object_factory.cc",
"host/shell_object_factory.h",
"host/shell_popup_wrapper.cc",
@@ -68,14 +63,24 @@ source_set("wayland") {
"host/wayland_cursor_position.h",
"host/wayland_data_device.cc",
"host/wayland_data_device.h",
+ "host/wayland_data_device_base.cc",
+ "host/wayland_data_device_base.h",
"host/wayland_data_device_manager.cc",
"host/wayland_data_device_manager.h",
"host/wayland_data_offer.cc",
"host/wayland_data_offer.h",
+ "host/wayland_data_offer_base.cc",
+ "host/wayland_data_offer_base.h",
"host/wayland_data_source.cc",
"host/wayland_data_source.h",
+ "host/wayland_data_source_base.cc",
+ "host/wayland_data_source_base.h",
"host/wayland_drm.cc",
"host/wayland_drm.h",
+ "host/wayland_event_source.cc",
+ "host/wayland_event_source.h",
+ "host/wayland_event_watcher.cc",
+ "host/wayland_event_watcher.h",
"host/wayland_input_method_context.cc",
"host/wayland_input_method_context.h",
"host/wayland_input_method_context_factory.cc",
@@ -200,6 +205,14 @@ source_set("wayland") {
data_deps = [ "//third_party/weston" ]
}
+ if (enable_vulkan) {
+ sources += [
+ "gpu/vulkan_implementation_wayland.cc",
+ "gpu/vulkan_implementation_wayland.h",
+ ]
+ deps += [ "//gpu/vulkan" ]
+ }
+
configs += [
":wayland-egl",
"//third_party/khronos:khronos_headers",
@@ -221,8 +234,6 @@ source_set("test_support") {
"test/mock_surface.h",
"test/mock_wp_presentation.cc",
"test/mock_wp_presentation.h",
- "test/mock_xdg_popup.cc",
- "test/mock_xdg_popup.h",
"test/mock_xdg_shell.cc",
"test/mock_xdg_shell.h",
"test/mock_xdg_surface.cc",
@@ -261,6 +272,8 @@ source_set("test_support") {
"test/test_touch.h",
"test/test_wayland_server_thread.cc",
"test/test_wayland_server_thread.h",
+ "test/test_xdg_popup.cc",
+ "test/test_xdg_popup.h",
"test/test_zwp_linux_buffer_params.cc",
"test/test_zwp_linux_buffer_params.h",
"test/test_zwp_text_input_manager.cc",
@@ -293,6 +306,7 @@ source_set("wayland_unittests") {
"gpu/wayland_surface_factory_unittest.cc",
"host/wayland_connection_unittest.cc",
"host/wayland_data_device_unittest.cc",
+ "host/wayland_event_source_unittest.cc",
"host/wayland_input_method_context_unittest.cc",
"host/wayland_keyboard_unittest.cc",
"host/wayland_pointer_unittest.cc",
diff --git a/chromium/ui/ozone/platform/wayland/README.md b/chromium/ui/ozone/platform/wayland/README.md
new file mode 100644
index 00000000000..6dc38e8977d
--- /dev/null
+++ b/chromium/ui/ozone/platform/wayland/README.md
@@ -0,0 +1,45 @@
+See [Ozone
+Overview](https://source.chromium.org/chromium/chromium/src/+/master:docs/ozone_overview.md)
+for high-level summary.
+
+Wayland is a window server protocol primarily being developed for Linux desktop.
+See [home page](https://wayland.freedesktop.org/) and [core protocol
+API](https://wayland.freedesktop.org/docs/html/). The API lives
+[here](https://source.chromium.org/chromium/chromium/src/+/master:third_party/wayland/)
+and the default Weston implementation can be found
+[here](https://source.chromium.org/chromium/chromium/src/+/master:third_party/weston/).
+
+For those less familiar, the primary purpose of a window server protocol is to
+provide a mechanism by which clients [e.g. web browser] can submit pixel
+buffers. The various pixel buffers from different clients are composited, and
+ultimately displayed on a screen.
+
+The core protocol is intentionally minimalist. It supports basic event handling,
+message passing and transactional buffer submissions. Wayland supports
+extensions, which allow for extensive customization of the protocol.
+
+The canonical reference implementation of a Wayland server is Weston. Chrome has
+a custom implementation used on chromeOS called
+[exo](https://source.chromium.org/chromium/chromium/src/+/master:components/exo/).
+
+This directory contains Chrome's implementation of the Wayland client. The gpu/
+subdirectory contains code typically run in the GPU process, and the host/
+subdirectory contains code typically run in the browser process. A typical
+high-level control flow for displaying content looks something like this:
+
+* The browser process is the sole Wayland client, and is responsible for all
+communication with the Wayland server. It is responsible for configuring window
+settings, and routes input.
+* The GPU process is responsible for actually drawing content. First, it
+allocates or reuses a buffer. See subclasses of WaylandSurfaceGpu for types of
+buffers.
+* The GPU process then registers the buffer with the Wayland server. This is
+done via IPC to the browser process and results in the creation of a wl_buffer
+object in the browser process. See CreateShmBasedBuffer() and
+CreateDmabufBasedBuffer().
+* The GPU process draws into the buffer.
+* The GPU process commits the buffer for presentation. This is done via IPC to
+the browser process. See CommitBuffer().
+* The browser process eventually returns with OnSubmission() and
+OnPresentation(), which mark the buffer as ready for reuse.
+
diff --git a/chromium/ui/ozone/platform/wayland/gpu/gl_surface_egl_readback_wayland.cc b/chromium/ui/ozone/platform/wayland/gpu/gl_surface_egl_readback_wayland.cc
index 700cb969edf..60c70c7e82e 100644
--- a/chromium/ui/ozone/platform/wayland/gpu/gl_surface_egl_readback_wayland.cc
+++ b/chromium/ui/ozone/platform/wayland/gpu/gl_surface_egl_readback_wayland.cc
@@ -29,9 +29,7 @@ GLSurfaceEglReadbackWayland::PixelBuffer::~PixelBuffer() = default;
GLSurfaceEglReadbackWayland::GLSurfaceEglReadbackWayland(
gfx::AcceleratedWidget widget,
WaylandBufferManagerGpu* buffer_manager)
- : PbufferGLSurfaceEGL(gfx::Size(1, 1)),
- widget_(widget),
- buffer_manager_(buffer_manager) {
+ : widget_(widget), buffer_manager_(buffer_manager) {
buffer_manager_->RegisterSurface(widget_, this);
}
@@ -115,13 +113,11 @@ void GLSurfaceEglReadbackWayland::SwapBuffersAsync(
auto* next_buffer = in_flight_pixel_buffers_.back().get();
available_buffers_.erase(available_buffers_.begin());
- const gfx::Size size = GetSize();
CHECK(next_buffer->shm_mapping_.memory());
- glReadPixels(0, 0, size.width(), size.height(), GL_BGRA, GL_UNSIGNED_BYTE,
- next_buffer->shm_mapping_.memory());
+ ReadPixels(next_buffer->shm_mapping_.memory());
buffer_manager_->CommitBuffer(widget_, next_buffer->buffer_id_,
- {{0, 0}, size});
+ {{0, 0}, GetSize()});
}
gfx::SurfaceOrigin GLSurfaceEglReadbackWayland::GetOrigin() const {
diff --git a/chromium/ui/ozone/platform/wayland/gpu/gl_surface_egl_readback_wayland.h b/chromium/ui/ozone/platform/wayland/gpu/gl_surface_egl_readback_wayland.h
index de83a75b2a6..6fb4a60c324 100644
--- a/chromium/ui/ozone/platform/wayland/gpu/gl_surface_egl_readback_wayland.h
+++ b/chromium/ui/ozone/platform/wayland/gpu/gl_surface_egl_readback_wayland.h
@@ -15,9 +15,22 @@ namespace ui {
class WaylandBufferManagerGpu;
-// GLSurface implementation that copies pixels from readback to shared memory
-// and let Wayland compositor to present them.
-class GLSurfaceEglReadbackWayland : public gl::PbufferGLSurfaceEGL,
+// This is a GLSurface implementation that uses glReadPixels to populate a
+// shared memory region with the contents of the surface, and then passes the
+// shared memory region to Wayland for presentation.
+//
+// Basic control flow:
+// 1. Resize() creates kMaxBuffers shared memory regions. These are added to
+// available_buffers_ and registered with Wayland via CreateShmBasedBuffer().
+// 2. SwapBuffersAsync() calls glReadPixels() to read the contents of the
+// active GL context into the next available shared memory region. The shared
+// memory region is immediately sent to Wayland via CommitBuffer().
+// 3. The buffer is not available for reuse until OnSubmission() is called.
+//
+// Note: This class relies on the assumption that kMaxBuffers is necessary and
+// sufficient. The behavior is undefined if SwapBuffersAsync() is called and no
+// buffers are available.
+class GLSurfaceEglReadbackWayland : public GLSurfaceEglReadback,
public WaylandSurfaceGpu {
public:
GLSurfaceEglReadbackWayland(gfx::AcceleratedWidget widget,
diff --git a/chromium/ui/ozone/platform/wayland/gpu/vulkan_implementation_wayland.cc b/chromium/ui/ozone/platform/wayland/gpu/vulkan_implementation_wayland.cc
new file mode 100644
index 00000000000..3ec6820f18f
--- /dev/null
+++ b/chromium/ui/ozone/platform/wayland/gpu/vulkan_implementation_wayland.cc
@@ -0,0 +1,151 @@
+// Copyright 2020 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 "ui/ozone/platform/wayland/gpu/vulkan_implementation_wayland.h"
+
+#include <vulkan/vulkan_wayland.h>
+
+#include "base/base_paths.h"
+#include "base/bind_helpers.h"
+#include "base/files/file_path.h"
+#include "base/notreached.h"
+#include "base/path_service.h"
+#include "gpu/vulkan/vulkan_function_pointers.h"
+#include "gpu/vulkan/vulkan_image.h"
+#include "gpu/vulkan/vulkan_instance.h"
+#include "gpu/vulkan/vulkan_surface.h"
+#include "gpu/vulkan/vulkan_util.h"
+#include "ui/gfx/gpu_fence.h"
+#include "ui/gfx/gpu_memory_buffer.h"
+
+namespace ui {
+
+namespace {
+
+bool InitializeVulkanFunctionPointers(
+ const base::FilePath& path,
+ gpu::VulkanFunctionPointers* vulkan_function_pointers) {
+ base::NativeLibraryLoadError native_library_load_error;
+ vulkan_function_pointers->vulkan_loader_library =
+ base::LoadNativeLibrary(path, &native_library_load_error);
+ return !!vulkan_function_pointers->vulkan_loader_library;
+}
+
+} // namespace
+
+VulkanImplementationWayland::VulkanImplementationWayland()
+ : gpu::VulkanImplementation(false /* use_swiftshader */) {}
+
+VulkanImplementationWayland::~VulkanImplementationWayland() {}
+
+bool VulkanImplementationWayland::InitializeVulkanInstance(bool using_surface) {
+ std::vector<const char*> required_extensions = {
+ VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME,
+ VK_KHR_EXTERNAL_SEMAPHORE_CAPABILITIES_EXTENSION_NAME,
+ };
+
+ auto* vulkan_function_pointers = gpu::GetVulkanFunctionPointers();
+
+ base::FilePath path("libvulkan.so.1");
+
+ if (!InitializeVulkanFunctionPointers(path, vulkan_function_pointers))
+ return false;
+
+ if (!vulkan_instance_.Initialize(required_extensions, {}))
+ return false;
+ return true;
+}
+
+gpu::VulkanInstance* VulkanImplementationWayland::GetVulkanInstance() {
+ return &vulkan_instance_;
+}
+
+std::unique_ptr<gpu::VulkanSurface>
+VulkanImplementationWayland::CreateViewSurface(gfx::AcceleratedWidget window) {
+ NOTIMPLEMENTED();
+ return nullptr;
+}
+
+bool VulkanImplementationWayland::GetPhysicalDevicePresentationSupport(
+ VkPhysicalDevice device,
+ const std::vector<VkQueueFamilyProperties>& queue_family_properties,
+ uint32_t queue_family_index) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+std::vector<const char*>
+VulkanImplementationWayland::GetRequiredDeviceExtensions() {
+ return {
+ VK_EXT_EXTERNAL_MEMORY_DMA_BUF_EXTENSION_NAME,
+ VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME,
+ VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME,
+ VK_KHR_EXTERNAL_SEMAPHORE_EXTENSION_NAME,
+ VK_KHR_EXTERNAL_SEMAPHORE_FD_EXTENSION_NAME,
+ };
+}
+
+std::vector<const char*>
+VulkanImplementationWayland::GetOptionalDeviceExtensions() {
+ // VK_EXT_image_drm_format_modifier is not well supported right now, so has to
+ // request as an optional extension.
+ return {
+ VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME,
+ };
+}
+
+VkFence VulkanImplementationWayland::CreateVkFenceForGpuFence(
+ VkDevice vk_device) {
+ NOTREACHED();
+ return VK_NULL_HANDLE;
+}
+
+std::unique_ptr<gfx::GpuFence>
+VulkanImplementationWayland::ExportVkFenceToGpuFence(VkDevice vk_device,
+ VkFence vk_fence) {
+ NOTREACHED();
+ return nullptr;
+}
+
+VkSemaphore VulkanImplementationWayland::CreateExternalSemaphore(
+ VkDevice vk_device) {
+ return gpu::CreateExternalVkSemaphore(
+ vk_device, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT);
+}
+
+VkSemaphore VulkanImplementationWayland::ImportSemaphoreHandle(
+ VkDevice vk_device,
+ gpu::SemaphoreHandle sync_handle) {
+ return gpu::ImportVkSemaphoreHandle(vk_device, std::move(sync_handle));
+}
+
+gpu::SemaphoreHandle VulkanImplementationWayland::GetSemaphoreHandle(
+ VkDevice vk_device,
+ VkSemaphore vk_semaphore) {
+ return gpu::GetVkSemaphoreHandle(
+ vk_device, vk_semaphore, VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT);
+}
+
+VkExternalMemoryHandleTypeFlagBits
+VulkanImplementationWayland::GetExternalImageHandleType() {
+ return VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT;
+}
+
+bool VulkanImplementationWayland::CanImportGpuMemoryBuffer(
+ gfx::GpuMemoryBufferType memory_buffer_type) {
+ NOTIMPLEMENTED();
+ return false;
+}
+
+std::unique_ptr<gpu::VulkanImage>
+VulkanImplementationWayland::CreateImageFromGpuMemoryHandle(
+ gpu::VulkanDeviceQueue* device_queue,
+ gfx::GpuMemoryBufferHandle gmb_handle,
+ gfx::Size size,
+ VkFormat vk_formate) {
+ NOTIMPLEMENTED();
+ return nullptr;
+}
+
+} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/gpu/vulkan_implementation_wayland.h b/chromium/ui/ozone/platform/wayland/gpu/vulkan_implementation_wayland.h
new file mode 100644
index 00000000000..e504ac313ef
--- /dev/null
+++ b/chromium/ui/ozone/platform/wayland/gpu/vulkan_implementation_wayland.h
@@ -0,0 +1,59 @@
+// Copyright 2020 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 UI_OZONE_PLATFORM_WAYLAND_GPU_VULKAN_IMPLEMENTATION_WAYLAND_H_
+#define UI_OZONE_PLATFORM_WAYLAND_GPU_VULKAN_IMPLEMENTATION_WAYLAND_H_
+
+#include <memory>
+
+#include "gpu/vulkan/vulkan_implementation.h"
+#include "gpu/vulkan/vulkan_instance.h"
+
+namespace ui {
+
+class VulkanImplementationWayland : public gpu::VulkanImplementation {
+ public:
+ VulkanImplementationWayland();
+ ~VulkanImplementationWayland() override;
+
+ VulkanImplementationWayland(const VulkanImplementationWayland&) = delete;
+ VulkanImplementationWayland& operator=(const VulkanImplementationWayland&) =
+ delete;
+
+ // VulkanImplementation:
+ bool InitializeVulkanInstance(bool using_surface) override;
+ gpu::VulkanInstance* GetVulkanInstance() override;
+ std::unique_ptr<gpu::VulkanSurface> CreateViewSurface(
+ gfx::AcceleratedWidget window) override;
+ bool GetPhysicalDevicePresentationSupport(
+ VkPhysicalDevice device,
+ const std::vector<VkQueueFamilyProperties>& queue_family_properties,
+ uint32_t queue_family_index) override;
+ std::vector<const char*> GetRequiredDeviceExtensions() override;
+ std::vector<const char*> GetOptionalDeviceExtensions() override;
+ VkFence CreateVkFenceForGpuFence(VkDevice vk_device) override;
+ std::unique_ptr<gfx::GpuFence> ExportVkFenceToGpuFence(
+ VkDevice vk_device,
+ VkFence vk_fence) override;
+ VkSemaphore CreateExternalSemaphore(VkDevice vk_device) override;
+ VkSemaphore ImportSemaphoreHandle(VkDevice vk_device,
+ gpu::SemaphoreHandle handle) override;
+ gpu::SemaphoreHandle GetSemaphoreHandle(VkDevice vk_device,
+ VkSemaphore vk_semaphore) override;
+ VkExternalMemoryHandleTypeFlagBits GetExternalImageHandleType() override;
+ bool CanImportGpuMemoryBuffer(
+ gfx::GpuMemoryBufferType memory_buffer_type) override;
+ std::unique_ptr<gpu::VulkanImage> CreateImageFromGpuMemoryHandle(
+ gpu::VulkanDeviceQueue* device_queue,
+ gfx::GpuMemoryBufferHandle gmb_handle,
+ gfx::Size size,
+ VkFormat vk_format) override;
+
+ private:
+ gpu::VulkanInstance vulkan_instance_;
+};
+
+} // namespace ui
+
+#endif // UI_OZONE_PLATFORM_WAYLAND_GPU_VULKAN_IMPLEMENTATION_WAYLAND_H_ \ No newline at end of file
diff --git a/chromium/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc b/chromium/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc
index 6adfc621532..20e8736b057 100644
--- a/chromium/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc
+++ b/chromium/ui/ozone/platform/wayland/gpu/wayland_buffer_manager_gpu.cc
@@ -89,7 +89,11 @@ void WaylandBufferManagerGpu::CreateDmabufBasedBuffer(
uint32_t current_format,
uint32_t planes_count,
uint32_t buffer_id) {
- DCHECK(io_thread_runner_);
+ if (!remote_host_) {
+ LOG(ERROR) << "Interface is not bound. Can't request "
+ "WaylandBufferManagerHost to create/commit/destroy buffers.";
+ return;
+ }
// Do the mojo call on the IO child thread.
io_thread_runner_->PostTask(
@@ -106,7 +110,11 @@ void WaylandBufferManagerGpu::CreateShmBasedBuffer(
size_t length,
gfx::Size size,
uint32_t buffer_id) {
- DCHECK(io_thread_runner_);
+ if (!remote_host_) {
+ LOG(ERROR) << "Interface is not bound. Can't request "
+ "WaylandBufferManagerHost to create/commit/destroy buffers.";
+ return;
+ }
// Do the mojo call on the IO child thread.
io_thread_runner_->PostTask(
@@ -119,7 +127,11 @@ void WaylandBufferManagerGpu::CreateShmBasedBuffer(
void WaylandBufferManagerGpu::CommitBuffer(gfx::AcceleratedWidget widget,
uint32_t buffer_id,
const gfx::Rect& damage_region) {
- DCHECK(io_thread_runner_);
+ if (!remote_host_) {
+ LOG(ERROR) << "Interface is not bound. Can't request "
+ "WaylandBufferManagerHost to create/commit/destroy buffers.";
+ return;
+ }
if (!commit_thread_runner_)
commit_thread_runner_ = base::ThreadTaskRunnerHandle::Get();
@@ -133,7 +145,11 @@ void WaylandBufferManagerGpu::CommitBuffer(gfx::AcceleratedWidget widget,
void WaylandBufferManagerGpu::DestroyBuffer(gfx::AcceleratedWidget widget,
uint32_t buffer_id) {
- DCHECK(io_thread_runner_);
+ if (!remote_host_) {
+ LOG(ERROR) << "Interface is not bound. Can't request "
+ "WaylandBufferManagerHost to create/commit/destroy buffers.";
+ return;
+ }
// Do the mojo call on the IO child thread.
io_thread_runner_->PostTask(
@@ -171,7 +187,6 @@ void WaylandBufferManagerGpu::CreateDmabufBasedBufferInternal(
uint32_t planes_count,
uint32_t buffer_id) {
DCHECK(io_thread_runner_->BelongsToCurrentThread());
- DCHECK(remote_host_);
remote_host_->CreateDmabufBasedBuffer(
mojo::PlatformHandle(std::move(dmabuf_fd)), size, strides, offsets,
modifiers, current_format, planes_count, buffer_id);
@@ -183,7 +198,6 @@ void WaylandBufferManagerGpu::CreateShmBasedBufferInternal(
gfx::Size size,
uint32_t buffer_id) {
DCHECK(io_thread_runner_->BelongsToCurrentThread());
- DCHECK(remote_host_);
remote_host_->CreateShmBasedBuffer(mojo::PlatformHandle(std::move(shm_fd)),
length, size, buffer_id);
}
@@ -193,8 +207,6 @@ void WaylandBufferManagerGpu::CommitBufferInternal(
uint32_t buffer_id,
const gfx::Rect& damage_region) {
DCHECK(io_thread_runner_->BelongsToCurrentThread());
- DCHECK(remote_host_);
-
remote_host_->CommitBuffer(widget, buffer_id, damage_region);
}
@@ -202,8 +214,6 @@ void WaylandBufferManagerGpu::DestroyBufferInternal(
gfx::AcceleratedWidget widget,
uint32_t buffer_id) {
DCHECK(io_thread_runner_->BelongsToCurrentThread());
- DCHECK(remote_host_);
-
remote_host_->DestroyBuffer(widget, buffer_id);
}
diff --git a/chromium/ui/ozone/platform/wayland/gpu/wayland_canvas_surface.h b/chromium/ui/ozone/platform/wayland/gpu/wayland_canvas_surface.h
index 054e27de8f1..e052981ad3e 100644
--- a/chromium/ui/ozone/platform/wayland/gpu/wayland_canvas_surface.h
+++ b/chromium/ui/ozone/platform/wayland/gpu/wayland_canvas_surface.h
@@ -21,10 +21,23 @@ namespace ui {
class WaylandBufferManagerGpu;
-// Returns SkSurface, which must be used to write to a shared memory region. It
-// is guaranteed that the returned SkSurface is not backed by the shared memory
-// region used by a Wayland compositor. Instead, a new SkSurface will be
-// returned and the client can write to it without resulting in tearing.
+// WaylandCanvasSurface creates an SkCanvas whose contents is backed by a shared
+// memory region. The shared memory region is registered with the Wayland server
+// as a wl_buffer.
+//
+// Basic control flow:
+// 1. WaylandCanvasSurface creates an anonymous shared memory region.
+// 2. WaylandCanvasSurface creates an SkCanvas that rasters directly into
+// this shared memory region.
+// 3. WaylandCanvasSurface registers the shared memory region with the
+// WaylandServer via IPC through WaylandBufferManagerGpu and
+// WaylandBufferManagerHost. See
+// WaylandBufferManagerHost::CreateShmBasedBuffer. This creates a wl_buffer
+// object in the browser process.
+// 4. WaylandCanvasSurface::CommitBuffer simply routes via IPC through the
+// browser process to the Wayland server. It is not safe to modify the shared
+// memory region in (1) until OnSubmission/OnPresentation callbacks are
+// received.
class WaylandCanvasSurface : public SurfaceOzoneCanvas,
public WaylandSurfaceGpu {
public:
@@ -33,6 +46,9 @@ class WaylandCanvasSurface : public SurfaceOzoneCanvas,
~WaylandCanvasSurface() override;
// SurfaceOzoneCanvas
+
+ // GetCanvas() returns an SkCanvas whose shared memory region is not being
+ // used by Wayland. If no such SkCanvas is available, a new one is created.
SkCanvas* GetCanvas() override;
void ResizeCanvas(const gfx::Size& viewport_size) override;
void PresentCanvas(const gfx::Rect& damage) override;
diff --git a/chromium/ui/ozone/platform/wayland/gpu/wayland_surface_factory.cc b/chromium/ui/ozone/platform/wayland/gpu/wayland_surface_factory.cc
index b8258fda199..76ba72b23eb 100644
--- a/chromium/ui/ozone/platform/wayland/gpu/wayland_surface_factory.cc
+++ b/chromium/ui/ozone/platform/wayland/gpu/wayland_surface_factory.cc
@@ -25,6 +25,10 @@
#include "ui/ozone/public/ozone_platform.h"
#endif
+#if BUILDFLAG(ENABLE_VULKAN)
+#include "ui/ozone/platform/wayland/gpu/vulkan_implementation_wayland.h"
+#endif
+
namespace ui {
namespace {
@@ -159,6 +163,15 @@ GLOzone* WaylandSurfaceFactory::GetGLOzone(
}
}
+#if BUILDFLAG(ENABLE_VULKAN)
+std::unique_ptr<gpu::VulkanImplementation>
+WaylandSurfaceFactory::CreateVulkanImplementation(
+ bool allow_protected_memory,
+ bool enforce_protected_memory) {
+ return std::make_unique<VulkanImplementationWayland>();
+}
+#endif
+
scoped_refptr<gfx::NativePixmap> WaylandSurfaceFactory::CreateNativePixmap(
gfx::AcceleratedWidget widget,
VkDevice vk_device,
diff --git a/chromium/ui/ozone/platform/wayland/gpu/wayland_surface_factory.h b/chromium/ui/ozone/platform/wayland/gpu/wayland_surface_factory.h
index 51e7f9ecf95..5fb57e84b2f 100644
--- a/chromium/ui/ozone/platform/wayland/gpu/wayland_surface_factory.h
+++ b/chromium/ui/ozone/platform/wayland/gpu/wayland_surface_factory.h
@@ -29,6 +29,11 @@ class WaylandSurfaceFactory : public SurfaceFactoryOzone {
// SurfaceFactoryOzone overrides:
std::vector<gl::GLImplementation> GetAllowedGLImplementations() override;
GLOzone* GetGLOzone(gl::GLImplementation implementation) override;
+#if BUILDFLAG(ENABLE_VULKAN)
+ std::unique_ptr<gpu::VulkanImplementation> CreateVulkanImplementation(
+ bool allow_protected_memory,
+ bool enforce_protected_memory) override;
+#endif
std::unique_ptr<SurfaceOzoneCanvas> CreateCanvasForWidget(
gfx::AcceleratedWidget widget,
scoped_refptr<base::SequencedTaskRunner> task_runner) override;
diff --git a/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_device.cc b/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_device.cc
index d1e49b70381..23e2eaf306f 100644
--- a/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_device.cc
+++ b/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_device.cc
@@ -15,7 +15,7 @@ namespace ui {
GtkPrimarySelectionDevice::GtkPrimarySelectionDevice(
WaylandConnection* connection,
gtk_primary_selection_device* data_device)
- : internal::WaylandDataDeviceBase(connection), data_device_(data_device) {
+ : WaylandDataDeviceBase(connection), data_device_(data_device) {
static const struct gtk_primary_selection_device_listener kListener = {
GtkPrimarySelectionDevice::OnDataOffer,
GtkPrimarySelectionDevice::OnSelection};
diff --git a/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_device.h b/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_device.h
index 173faaeda5d..fc567936fe3 100644
--- a/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_device.h
+++ b/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_device.h
@@ -12,7 +12,7 @@
#include "base/callback.h"
#include "base/macros.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
-#include "ui/ozone/platform/wayland/host/internal/wayland_data_device_base.h"
+#include "ui/ozone/platform/wayland/host/wayland_data_device_base.h"
struct gtk_primary_selection_device;
@@ -21,7 +21,7 @@ namespace ui {
class WaylandConnection;
// This class provides access to primary selection clipboard available on GTK.
-class GtkPrimarySelectionDevice : public internal::WaylandDataDeviceBase {
+class GtkPrimarySelectionDevice : public WaylandDataDeviceBase {
public:
GtkPrimarySelectionDevice(WaylandConnection* connection,
gtk_primary_selection_device* data_device);
diff --git a/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_offer.cc b/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_offer.cc
index 3ab1ad7897e..a611215ec3e 100644
--- a/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_offer.cc
+++ b/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_offer.cc
@@ -9,8 +9,8 @@
#include <fcntl.h>
#include <algorithm>
+#include "base/check.h"
#include "base/files/file_util.h"
-#include "base/logging.h"
#include "base/stl_util.h"
#include "ui/base/clipboard/clipboard_constants.h"
diff --git a/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_offer.h b/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_offer.h
index 23f6e112e67..5a34f541412 100644
--- a/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_offer.h
+++ b/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_offer.h
@@ -6,30 +6,29 @@
#define UI_OZONE_PLATFORM_WAYLAND_HOST_GTK_PRIMARY_SELECTION_OFFER_H_
#include <string>
-#include <vector>
#include "base/files/scoped_file.h"
#include "base/macros.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
-#include "ui/ozone/platform/wayland/host/internal/wayland_data_offer_base.h"
+#include "ui/ozone/platform/wayland/host/wayland_data_offer_base.h"
struct gtk_primary_selection_offer;
namespace ui {
-// This class represents a piece of data offered for transfer by another
-// client, the source client (see GtkPrimarySelectionSource for more).
-// It is used by the primary selection mechanism.
+// This class represents a piece of data offered for transfer by another client,
+// the source client (see GtkPrimarySelectionSource for more). It is used by the
+// primary selection mechanism.
//
// The offer describes MIME types that the data can be converted to and provides
// the mechanism for transferring the data directly from the source client.
-class GtkPrimarySelectionOffer : public internal::WaylandDataOfferBase {
+class GtkPrimarySelectionOffer : public WaylandDataOfferBase {
public:
// Takes ownership of data_offer.
explicit GtkPrimarySelectionOffer(gtk_primary_selection_offer* data_offer);
~GtkPrimarySelectionOffer() override;
- // internal::WaylandDataOfferBase overrides:
+ // WaylandDataOfferBase overrides:
base::ScopedFD Receive(const std::string& mime_type) override;
private:
diff --git a/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_source.cc b/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_source.cc
index 3cef4631174..7160cdd83fa 100644
--- a/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_source.cc
+++ b/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_source.cc
@@ -6,8 +6,8 @@
#include <gtk-primary-selection-client-protocol.h>
+#include "base/check.h"
#include "base/files/file_util.h"
-#include "base/logging.h"
#include "ui/base/clipboard/clipboard_constants.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
diff --git a/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_source.h b/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_source.h
index 02326c91618..994fffa25d3 100644
--- a/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_source.h
+++ b/chromium/ui/ozone/platform/wayland/host/gtk_primary_selection_source.h
@@ -7,7 +7,7 @@
#include "base/macros.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
-#include "ui/ozone/platform/wayland/host/internal/wayland_data_source_base.h"
+#include "ui/ozone/platform/wayland/host/wayland_data_source_base.h"
#include "ui/ozone/public/platform_clipboard.h"
struct gtk_primary_selection_source;
@@ -16,7 +16,7 @@ namespace ui {
class WaylandConnection;
-class GtkPrimarySelectionSource : public internal::WaylandDataSourceBase {
+class GtkPrimarySelectionSource : public WaylandDataSourceBase {
public:
// Takes ownership of data_source.
GtkPrimarySelectionSource(gtk_primary_selection_source* data_source,
diff --git a/chromium/ui/ozone/platform/wayland/host/shell_popup_wrapper.cc b/chromium/ui/ozone/platform/wayland/host/shell_popup_wrapper.cc
index 0e6653dfe94..1dc1f4d4f76 100644
--- a/chromium/ui/ozone/platform/wayland/host/shell_popup_wrapper.cc
+++ b/chromium/ui/ozone/platform/wayland/host/shell_popup_wrapper.cc
@@ -46,16 +46,26 @@ gfx::Rect GetAnchorRect(MenuType menu_type,
auto anchor_width =
parent_window_bounds.width() -
(parent_window_bounds.width() - menu_bounds.x()) * 2;
- anchor_rect =
- gfx::Rect(parent_window_bounds.width() - menu_bounds.x(),
- menu_bounds.y(), anchor_width, kAnchorDefaultHeight);
+ if (anchor_width <= 0) {
+ anchor_rect = gfx::Rect(menu_bounds.x(), menu_bounds.y(),
+ kAnchorDefaultWidth, kAnchorDefaultHeight);
+ } else {
+ anchor_rect =
+ gfx::Rect(parent_window_bounds.width() - menu_bounds.x(),
+ menu_bounds.y(), anchor_width, kAnchorDefaultHeight);
+ }
} else {
DCHECK_LE(menu_bounds.x(), 0);
auto position = menu_bounds.width() + menu_bounds.x();
DCHECK(position > 0 && position < parent_window_bounds.width());
auto anchor_width = parent_window_bounds.width() - position * 2;
- anchor_rect = gfx::Rect(position, menu_bounds.y(), anchor_width,
- kAnchorDefaultHeight);
+ if (anchor_width <= 0) {
+ anchor_rect = gfx::Rect(position, menu_bounds.y(),
+ kAnchorDefaultWidth, kAnchorDefaultHeight);
+ } else {
+ anchor_rect = gfx::Rect(position, menu_bounds.y(), anchor_width,
+ kAnchorDefaultHeight);
+ }
}
break;
case MenuType::TYPE_UNKNOWN:
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_connector.cc b/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_connector.cc
index 5d2a047f532..da4fdd5fa93 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_connector.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_connector.cc
@@ -11,47 +11,20 @@
namespace ui {
-namespace {
-
-// TODO(msisov): In the future when GpuProcessHost is moved to vizhost, remove
-// this utility code.
-using BinderCallback = ui::GpuPlatformSupportHost::GpuHostBindInterfaceCallback;
-
-void BindInterfaceInGpuProcess(const std::string& interface_name,
- mojo::ScopedMessagePipeHandle interface_pipe,
- const BinderCallback& binder_callback) {
- return binder_callback.Run(interface_name, std::move(interface_pipe));
-}
-
-template <typename Interface>
-void BindInterfaceInGpuProcess(mojo::PendingReceiver<Interface> request,
- const BinderCallback& binder_callback) {
- BindInterfaceInGpuProcess(Interface::Name_, std::move(request.PassPipe()),
- binder_callback);
-}
-
-} // namespace
-
WaylandBufferManagerConnector::WaylandBufferManagerConnector(
WaylandBufferManagerHost* buffer_manager_host)
- : buffer_manager_host_(buffer_manager_host) {}
-
-WaylandBufferManagerConnector::~WaylandBufferManagerConnector() = default;
-
-void WaylandBufferManagerConnector::OnGpuProcessLaunched(
- int host_id,
- scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
- scoped_refptr<base::SingleThreadTaskRunner> send_runner,
- base::RepeatingCallback<void(IPC::Message*)> send_callback) {}
+ : buffer_manager_host_(buffer_manager_host) {
+ DETACH_FROM_THREAD(io_thread_checker_);
+}
-void WaylandBufferManagerConnector::OnChannelDestroyed(int host_id) {
- buffer_manager_host_->OnChannelDestroyed();
+WaylandBufferManagerConnector::~WaylandBufferManagerConnector() {
+ DCHECK_CALLED_ON_VALID_THREAD(ui_thread_checker_);
}
-void WaylandBufferManagerConnector::OnMessageReceived(
- const IPC::Message& message) {
- NOTREACHED() << "This class should only be used with mojo transport but here "
- "we're wrongly getting invoked to handle IPC communication.";
+void WaylandBufferManagerConnector::OnChannelDestroyed(int host_id) {
+ DCHECK_CALLED_ON_VALID_THREAD(ui_thread_checker_);
+ if (host_id_ == host_id)
+ buffer_manager_host_->OnChannelDestroyed();
}
void WaylandBufferManagerConnector::OnGpuServiceLaunched(
@@ -60,30 +33,49 @@ void WaylandBufferManagerConnector::OnGpuServiceLaunched(
scoped_refptr<base::SingleThreadTaskRunner> io_runner,
GpuHostBindInterfaceCallback binder,
GpuHostTerminateCallback terminate_callback) {
- terminate_callback_ = std::move(terminate_callback);
- binder_ = std::move(binder);
+ DCHECK_CALLED_ON_VALID_THREAD(io_thread_checker_);
+ binder_ = std::move(binder);
io_runner_ = io_runner;
+
+ ui_runner->PostTask(
+ FROM_HERE,
+ base::BindOnce(&WaylandBufferManagerConnector::OnGpuServiceLaunchedOnUI,
+ base::Unretained(this), host_id,
+ std::move(terminate_callback)));
+}
+
+void WaylandBufferManagerConnector::OnGpuServiceLaunchedOnUI(
+ int host_id,
+ GpuHostTerminateCallback terminate_callback) {
+ DCHECK_CALLED_ON_VALID_THREAD(ui_thread_checker_);
+
+ host_id_ = host_id;
+
auto on_terminate_gpu_cb =
base::BindOnce(&WaylandBufferManagerConnector::OnTerminateGpuProcess,
base::Unretained(this));
buffer_manager_host_->SetTerminateGpuCallback(std::move(on_terminate_gpu_cb));
+ terminate_callback_ = std::move(terminate_callback);
- base::PostTaskAndReplyWithResult(
- ui_runner.get(), FROM_HERE,
- base::BindOnce(&WaylandBufferManagerHost::BindInterface,
- base::Unretained(buffer_manager_host_)),
+ auto pending_remote = buffer_manager_host_->BindInterface();
+
+ io_runner_->PostTask(
+ FROM_HERE,
base::BindOnce(
&WaylandBufferManagerConnector::OnBufferManagerHostPtrBinded,
- base::Unretained(this)));
+ base::Unretained(this), std::move(pending_remote)));
}
void WaylandBufferManagerConnector::OnBufferManagerHostPtrBinded(
mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost>
buffer_manager_host) const {
+ DCHECK_CALLED_ON_VALID_THREAD(io_thread_checker_);
+
mojo::Remote<ozone::mojom::WaylandBufferManagerGpu> buffer_manager_gpu_remote;
- auto receiver = buffer_manager_gpu_remote.BindNewPipeAndPassReceiver();
- BindInterfaceInGpuProcess(std::move(receiver), binder_);
+ binder_.Run(
+ ozone::mojom::WaylandBufferManagerGpu::Name_,
+ buffer_manager_gpu_remote.BindNewPipeAndPassReceiver().PassPipe());
DCHECK(buffer_manager_gpu_remote);
wl::BufferFormatsWithModifiersMap buffer_formats_with_modifiers =
@@ -98,6 +90,9 @@ void WaylandBufferManagerConnector::OnBufferManagerHostPtrBinded(
}
void WaylandBufferManagerConnector::OnTerminateGpuProcess(std::string message) {
+ DCHECK_CALLED_ON_VALID_THREAD(ui_thread_checker_);
+
+ DCHECK(!terminate_callback_.is_null());
io_runner_->PostTask(FROM_HERE, base::BindOnce(std::move(terminate_callback_),
std::move(message)));
}
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_connector.h b/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_connector.h
index 24db6b7d208..1a40e3782c8 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_connector.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_connector.h
@@ -7,6 +7,7 @@
#include "ui/ozone/public/gpu_platform_support_host.h"
+#include "base/threading/thread_checker.h"
#include "mojo/public/cpp/bindings/remote.h"
#include "ui/ozone/public/mojom/wayland/wayland_buffer_manager.mojom.h"
@@ -24,13 +25,7 @@ class WaylandBufferManagerConnector : public GpuPlatformSupportHost {
~WaylandBufferManagerConnector() override;
// GpuPlatformSupportHost:
- void OnGpuProcessLaunched(
- int host_id,
- scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
- scoped_refptr<base::SingleThreadTaskRunner> send_runner,
- base::RepeatingCallback<void(IPC::Message*)> send_callback) override;
void OnChannelDestroyed(int host_id) override;
- void OnMessageReceived(const IPC::Message& message) override;
void OnGpuServiceLaunched(
int host_id,
scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
@@ -39,6 +34,9 @@ class WaylandBufferManagerConnector : public GpuPlatformSupportHost {
GpuHostTerminateCallback terminate_callback) override;
private:
+ void OnGpuServiceLaunchedOnUI(int host_id,
+ GpuHostTerminateCallback terminate_callback);
+
void OnBufferManagerHostPtrBinded(
mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost>
buffer_manager_host) const;
@@ -54,6 +52,12 @@ class WaylandBufferManagerConnector : public GpuPlatformSupportHost {
scoped_refptr<base::SingleThreadTaskRunner> io_runner_;
+ // Owned by the ui thread.
+ int host_id_ = -1;
+
+ THREAD_CHECKER(ui_thread_checker_);
+ THREAD_CHECKER(io_thread_checker_);
+
DISALLOW_COPY_AND_ASSIGN(WaylandBufferManagerConnector);
};
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc b/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc
index 79495b21a37..96c4099fdb8 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.cc
@@ -639,7 +639,10 @@ void WaylandBufferManagerHost::SetTerminateGpuCallback(
mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost>
WaylandBufferManagerHost::BindInterface() {
- DCHECK(!receiver_.is_bound());
+ // Allow to rebind the interface if it hasn't been destroyed yet.
+ if (receiver_.is_bound())
+ OnChannelDestroyed();
+
mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost>
buffer_manager_host;
receiver_.Bind(buffer_manager_host.InitWithNewPipeAndPassReceiver());
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h b/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h
index 9049a3f5a4f..c0c6809cad2 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h
@@ -85,7 +85,9 @@ class WaylandBufferManagerHost : public ozone::mojom::WaylandBufferManagerHost,
void SetTerminateGpuCallback(
base::OnceCallback<void(std::string)> terminate_gpu_cb);
- // Returns bound pointer to own mojo interface.
+ // Returns bound pointer to own mojo interface. If there were previous
+ // interface bindings, it will be unbound and the state of the
+ // |buffer_manager_| will be cleared.
mojo::PendingRemote<ozone::mojom::WaylandBufferManagerHost> BindInterface();
// Unbinds the interface and clears the state of the |buffer_manager_|. Used
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_clipboard.cc b/chromium/ui/ozone/platform/wayland/host/wayland_clipboard.cc
index 0191f14247c..11add83d1b0 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_clipboard.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_clipboard.cc
@@ -9,9 +9,9 @@
#include "ui/ozone/platform/wayland/host/gtk_primary_selection_device.h"
#include "ui/ozone/platform/wayland/host/gtk_primary_selection_device_manager.h"
#include "ui/ozone/platform/wayland/host/gtk_primary_selection_source.h"
-#include "ui/ozone/platform/wayland/host/internal/wayland_data_source_base.h"
#include "ui/ozone/platform/wayland/host/wayland_data_device.h"
#include "ui/ozone/platform/wayland/host/wayland_data_device_manager.h"
+#include "ui/ozone/platform/wayland/host/wayland_data_source_base.h"
namespace ui {
@@ -34,7 +34,7 @@ void WaylandClipboard::OfferClipboardData(
ClipboardBuffer buffer,
const PlatformClipboard::DataMap& data_map,
PlatformClipboard::OfferDataClosure callback) {
- internal::WaylandDataSourceBase* data_source = nullptr;
+ WaylandDataSourceBase* data_source = nullptr;
if (buffer == ClipboardBuffer::kCopyPaste) {
if (!clipboard_data_source_)
clipboard_data_source_ = data_device_manager_->CreateSource();
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_connection.cc b/chromium/ui/ozone/platform/wayland/host/wayland_connection.cc
index 21590d85a26..d6c27854df9 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_connection.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_connection.cc
@@ -6,9 +6,9 @@
#include <xdg-shell-client-protocol.h>
#include <xdg-shell-unstable-v6-client-protocol.h>
-#include <memory>
#include <algorithm>
+#include <memory>
#include <utility>
#include "base/bind.h"
@@ -22,10 +22,15 @@
#include "ui/gfx/swap_result.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h"
+#include "ui/ozone/platform/wayland/host/wayland_cursor.h"
#include "ui/ozone/platform/wayland/host/wayland_drm.h"
+#include "ui/ozone/platform/wayland/host/wayland_event_source.h"
#include "ui/ozone/platform/wayland/host/wayland_input_method_context.h"
+#include "ui/ozone/platform/wayland/host/wayland_keyboard.h"
#include "ui/ozone/platform/wayland/host/wayland_output_manager.h"
+#include "ui/ozone/platform/wayland/host/wayland_pointer.h"
#include "ui/ozone/platform/wayland/host/wayland_shm.h"
+#include "ui/ozone/platform/wayland/host/wayland_touch.h"
#include "ui/ozone/platform/wayland/host/wayland_window.h"
#include "ui/ozone/platform/wayland/host/wayland_zwp_linux_dmabuf.h"
@@ -45,7 +50,7 @@ constexpr uint32_t kMinWlDrmVersion = 2;
constexpr uint32_t kMinWlOutputVersion = 2;
} // namespace
-WaylandConnection::WaylandConnection() : controller_(FROM_HERE) {}
+WaylandConnection::WaylandConnection() = default;
WaylandConnection::~WaylandConnection() = default;
@@ -67,6 +72,12 @@ bool WaylandConnection::Initialize() {
return false;
}
+ // Now that the connection with the display server has been properly
+ // estabilished, initialize the event source and input objects.
+ DCHECK(!event_source_);
+ event_source_ =
+ std::make_unique<WaylandEventSource>(display(), wayland_window_manager());
+
wl_registry_add_listener(registry_.get(), &registry_listener, this);
while (!wayland_output_manager_ ||
!wayland_output_manager_->IsOutputReady()) {
@@ -96,32 +107,6 @@ bool WaylandConnection::Initialize() {
return true;
}
-bool WaylandConnection::StartProcessingEvents() {
- if (watching_)
- return true;
-
- DCHECK(display_);
-
- MaybePrepareReadQueue();
-
- // Displatch event from display to server.
- wl_display_flush(display_.get());
-
- return BeginWatchingFd(base::MessagePumpLibevent::WATCH_READ);
-}
-
-void WaylandConnection::MaybePrepareReadQueue() {
- if (prepared_)
- return;
-
- if (wl_display_prepare_read(display()) != -1) {
- prepared_ = true;
- return;
- }
- // Nothing to read, send events to the queue.
- wl_display_dispatch_pending(display());
-}
-
void WaylandConnection::ScheduleFlush() {
// When we are in tests, the message loop is set later when the
// initialization of the OzonePlatform complete. Thus, just
@@ -138,16 +123,9 @@ void WaylandConnection::ScheduleFlush() {
void WaylandConnection::SetCursorBitmap(const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location) {
- if (!pointer_ || !pointer_->cursor())
+ if (!cursor_)
return;
- pointer_->cursor()->UpdateBitmap(bitmaps, location, serial_);
-}
-
-int WaylandConnection::GetKeyboardModifiers() const {
- int modifiers = 0;
- if (keyboard_)
- modifiers = keyboard_->modifiers();
- return modifiers;
+ cursor_->UpdateBitmap(bitmaps, location, serial_);
}
void WaylandConnection::StartDrag(const ui::OSExchangeData& data,
@@ -185,56 +163,49 @@ bool WaylandConnection::IsDragInProgress() {
return data_device_->IsDragEntered() || drag_data_source();
}
-void WaylandConnection::ResetPointerFlags() {
- if (pointer_)
- pointer_->ResetFlags();
-}
-
-void WaylandConnection::OnDispatcherListChanged() {
- StartProcessingEvents();
-}
-
void WaylandConnection::Flush() {
wl_display_flush(display_.get());
scheduled_flush_ = false;
}
-void WaylandConnection::DispatchUiEvent(Event* event) {
- PlatformEventSource::DispatchEvent(event);
-}
-
-void WaylandConnection::OnFileCanReadWithoutBlocking(int fd) {
- if (prepared_) {
- prepared_ = false;
- if (wl_display_read_events(display()) == -1)
- return;
- wl_display_dispatch_pending(display());
+void WaylandConnection::UpdateInputDevices(wl_seat* seat,
+ uint32_t capabilities) {
+ DCHECK(seat);
+ DCHECK(event_source_);
+ auto has_pointer = capabilities & WL_SEAT_CAPABILITY_POINTER;
+ auto has_keyboard = capabilities & WL_SEAT_CAPABILITY_KEYBOARD;
+ auto has_touch = capabilities & WL_SEAT_CAPABILITY_TOUCH;
+
+ if (!has_pointer) {
+ pointer_.reset();
+ cursor_.reset();
+ wayland_cursor_position_.reset();
+ } else if (wl_pointer* pointer = wl_seat_get_pointer(seat)) {
+ pointer_ = std::make_unique<WaylandPointer>(pointer, this, event_source());
+ cursor_ = std::make_unique<WaylandCursor>(pointer_.get(), this);
+ wayland_cursor_position_ = std::make_unique<WaylandCursorPosition>();
+ } else {
+ LOG(ERROR) << "Failed to get wl_pointer from seat";
}
- MaybePrepareReadQueue();
-
- if (!prepared_)
- return;
-
- // Automatic Flush.
- int ret = wl_display_flush(display_.get());
- if (ret != -1 || errno != EAGAIN)
- return;
-
- // if all data could not be written, errno will be set to EAGAIN and -1
- // returned. In that case, use poll on the display file descriptor to wait for
- // it to become writable again.
- BeginWatchingFd(base::MessagePumpLibevent::WATCH_WRITE);
-}
-
-void WaylandConnection::OnFileCanWriteWithoutBlocking(int fd) {
- int ret = wl_display_flush(display_.get());
- if (ret != -1 || errno != EAGAIN)
- BeginWatchingFd(base::MessagePumpLibevent::WATCH_READ);
- else if (ret < 0 && errno != EPIPE && prepared_)
- wl_display_cancel_read(display());
+ if (!has_keyboard) {
+ keyboard_.reset();
+ } else if (wl_keyboard* keyboard = wl_seat_get_keyboard(seat)) {
+ auto* layout_engine =
+ KeyboardLayoutEngineManager::GetKeyboardLayoutEngine();
+ keyboard_ = std::make_unique<WaylandKeyboard>(keyboard, this, layout_engine,
+ event_source());
+ } else {
+ LOG(ERROR) << "Failed to get wl_keyboard from seat";
+ }
- // Otherwise just continue watching in the same mode.
+ if (!has_touch) {
+ touch_.reset();
+ } else if (wl_touch* touch = wl_seat_get_touch(seat)) {
+ touch_ = std::make_unique<WaylandTouch>(touch, this, event_source());
+ } else {
+ LOG(ERROR) << "Failed to get wl_touch from seat";
+ }
}
void WaylandConnection::EnsureDataDevice() {
@@ -254,20 +225,6 @@ void WaylandConnection::EnsureDataDevice() {
primary_selection_device_manager_.get(), primary_selection_device_.get());
}
-bool WaylandConnection::BeginWatchingFd(
- base::WatchableIOMessagePumpPosix::Mode mode) {
- if (watching_) {
- // Stop watching first.
- watching_ = !controller_.StopWatchingFileDescriptor();
- DCHECK(!watching_);
- }
-
- DCHECK(base::MessageLoopCurrentForUI::IsSet());
- watching_ = base::MessageLoopCurrentForUI::Get()->WatchFileDescriptor(
- wl_display_get_fd(display_.get()), true, mode, &controller_, this);
- return watching_;
-}
-
// static
void WaylandConnection::Global(void* data,
wl_registry* registry,
@@ -423,58 +380,10 @@ void WaylandConnection::GlobalRemove(void* data,
void WaylandConnection::Capabilities(void* data,
wl_seat* seat,
uint32_t capabilities) {
- WaylandConnection* connection = static_cast<WaylandConnection*>(data);
- if (capabilities & WL_SEAT_CAPABILITY_POINTER) {
- if (!connection->pointer_) {
- wl_pointer* pointer = wl_seat_get_pointer(connection->seat_.get());
- if (!pointer) {
- LOG(ERROR) << "Failed to get wl_pointer from seat";
- return;
- }
- connection->pointer_ = std::make_unique<WaylandPointer>(
- pointer, base::BindRepeating(&WaylandConnection::DispatchUiEvent,
- base::Unretained(connection)));
- connection->pointer_->set_connection(connection);
-
- connection->wayland_cursor_position_ =
- std::make_unique<WaylandCursorPosition>();
- }
- } else if (connection->pointer_) {
- connection->pointer_.reset();
- connection->wayland_cursor_position_.reset();
- }
- if (capabilities & WL_SEAT_CAPABILITY_KEYBOARD) {
- if (!connection->keyboard_) {
- wl_keyboard* keyboard = wl_seat_get_keyboard(connection->seat_.get());
- if (!keyboard) {
- LOG(ERROR) << "Failed to get wl_keyboard from seat";
- return;
- }
- connection->keyboard_ = std::make_unique<WaylandKeyboard>(
- keyboard, KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(),
- base::BindRepeating(&WaylandConnection::DispatchUiEvent,
- base::Unretained(connection)));
- connection->keyboard_->set_connection(connection);
- }
- } else if (connection->keyboard_) {
- connection->keyboard_.reset();
- }
- if (capabilities & WL_SEAT_CAPABILITY_TOUCH) {
- if (!connection->touch_) {
- wl_touch* touch = wl_seat_get_touch(connection->seat_.get());
- if (!touch) {
- LOG(ERROR) << "Failed to get wl_touch from seat";
- return;
- }
- connection->touch_ = std::make_unique<WaylandTouch>(
- touch, base::BindRepeating(&WaylandConnection::DispatchUiEvent,
- base::Unretained(connection)));
- connection->touch_->SetConnection(connection);
- }
- } else if (connection->touch_) {
- connection->touch_.reset();
- }
- connection->ScheduleFlush();
+ WaylandConnection* self = static_cast<WaylandConnection*>(data);
+ DCHECK(self);
+ self->UpdateInputDevices(seat, capabilities);
+ self->ScheduleFlush();
}
// static
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_connection.h b/chromium/ui/ozone/platform/wayland/host/wayland_connection.h
index 9adc5be026a..b3e0a8a6c3d 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_connection.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_connection.h
@@ -5,14 +5,10 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_CONNECTION_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_CONNECTION_H_
-#include <map>
#include <memory>
#include <string>
#include <vector>
-#include "base/files/file.h"
-#include "base/message_loop/message_pump_for_ui.h"
-#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/buffer_types.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
@@ -23,29 +19,30 @@
#include "ui/ozone/platform/wayland/host/wayland_data_device.h"
#include "ui/ozone/platform/wayland/host/wayland_data_device_manager.h"
#include "ui/ozone/platform/wayland/host/wayland_data_source.h"
-#include "ui/ozone/platform/wayland/host/wayland_keyboard.h"
-#include "ui/ozone/platform/wayland/host/wayland_output.h"
-#include "ui/ozone/platform/wayland/host/wayland_pointer.h"
-#include "ui/ozone/platform/wayland/host/wayland_touch.h"
#include "ui/ozone/platform/wayland/host/wayland_window_manager.h"
namespace ui {
class WaylandBufferManagerHost;
+class WaylandCursor;
+class WaylandDrm;
+class WaylandEventSource;
+class WaylandKeyboard;
class WaylandOutputManager;
+class WaylandPointer;
+class WaylandShm;
+class WaylandTouch;
class WaylandWindow;
-class WaylandDrm;
class WaylandZwpLinuxDmabuf;
-class WaylandShm;
-class WaylandConnection : public PlatformEventSource,
- public base::MessagePumpForUI::FdWatcher {
+class WaylandConnection {
public:
WaylandConnection();
- ~WaylandConnection() override;
+ WaylandConnection(const WaylandConnection&) = delete;
+ WaylandConnection& operator=(const WaylandConnection&) = delete;
+ ~WaylandConnection();
bool Initialize();
- bool StartProcessingEvents();
// Schedules a flush of the Wayland connection.
void ScheduleFlush();
@@ -72,13 +69,16 @@ class WaylandConnection : public PlatformEventSource,
void SetCursorBitmap(const std::vector<SkBitmap>& bitmaps,
const gfx::Point& location);
- int GetKeyboardModifiers() const;
+ WaylandEventSource* event_source() const { return event_source_.get(); }
+
+ // Returns the current touch, which may be null.
+ WaylandTouch* touch() const { return touch_.get(); }
// Returns the current pointer, which may be null.
WaylandPointer* pointer() const { return pointer_.get(); }
- // Returns the current touch, which may be null.
- WaylandTouch* touch() const { return touch_.get(); }
+ // Returns the current keyboard, which may be null.
+ WaylandKeyboard* keyboard() const { return keyboard_.get(); }
WaylandClipboard* clipboard() const { return clipboard_.get(); }
@@ -132,33 +132,13 @@ class WaylandConnection : public PlatformEventSource,
// Returns true when dragging is entered or started.
bool IsDragInProgress();
- // Resets flags and keyboard modifiers.
- //
- // This method is specially handy for cases when the WaylandPointer state is
- // modified by a POINTER_DOWN event, but the respective POINTER_UP event is
- // not delivered.
- void ResetPointerFlags();
-
private:
- // WaylandInputMethodContextFactory needs access to DispatchUiEvent
- friend class WaylandInputMethodContextFactory;
-
void Flush();
- void DispatchUiEvent(Event* event);
-
- // PlatformEventSource
- void OnDispatcherListChanged() override;
-
- // base::MessagePumpForUI::FdWatcher
- void OnFileCanReadWithoutBlocking(int fd) override;
- void OnFileCanWriteWithoutBlocking(int fd) override;
+ void UpdateInputDevices(wl_seat* seat, uint32_t capabilities);
// Make sure data device is properly initialized
void EnsureDataDevice();
- bool BeginWatchingFd(base::WatchableIOMessagePumpPosix::Mode mode);
- void MaybePrepareReadQueue();
-
// wl_registry_listener
static void Global(void* data,
wl_registry* registry,
@@ -177,10 +157,10 @@ class WaylandConnection : public PlatformEventSource,
// xdg_wm_base_listener
static void Ping(void* data, xdg_wm_base* shell, uint32_t serial);
+ uint32_t compositor_version_ = 0;
wl::Object<wl_display> display_;
wl::Object<wl_registry> registry_;
wl::Object<wl_compositor> compositor_;
- uint32_t compositor_version_ = 0;
wl::Object<wl_subcompositor> subcompositor_;
wl::Object<wl_seat> seat_;
wl::Object<xdg_wm_base> shell_;
@@ -188,14 +168,21 @@ class WaylandConnection : public PlatformEventSource,
wl::Object<wp_presentation> presentation_;
wl::Object<zwp_text_input_manager_v1> text_input_manager_v1_;
+ // Event source instance. Must be declared before input objects so it outlives
+ // them so thus being able to properly handle their destruction.
+ std::unique_ptr<WaylandEventSource> event_source_;
+
+ // Input device objects.
+ std::unique_ptr<WaylandKeyboard> keyboard_;
+ std::unique_ptr<WaylandPointer> pointer_;
+ std::unique_ptr<WaylandTouch> touch_;
+
+ std::unique_ptr<WaylandCursor> cursor_;
std::unique_ptr<WaylandDataDeviceManager> data_device_manager_;
std::unique_ptr<WaylandDataDevice> data_device_;
std::unique_ptr<WaylandClipboard> clipboard_;
std::unique_ptr<WaylandDataSource> dragdrop_data_source_;
- std::unique_ptr<WaylandKeyboard> keyboard_;
std::unique_ptr<WaylandOutputManager> wayland_output_manager_;
- std::unique_ptr<WaylandPointer> pointer_;
- std::unique_ptr<WaylandTouch> touch_;
std::unique_ptr<WaylandCursorPosition> wayland_cursor_position_;
std::unique_ptr<WaylandZwpLinuxDmabuf> zwp_dmabuf_;
std::unique_ptr<WaylandDrm> drm_;
@@ -210,13 +197,8 @@ class WaylandConnection : public PlatformEventSource,
WaylandWindowManager wayland_window_manager_;
bool scheduled_flush_ = false;
- bool watching_ = false;
- bool prepared_ = false;
- base::MessagePumpForUI::FdWatchController controller_;
uint32_t serial_ = 0;
-
- DISALLOW_COPY_AND_ASSIGN(WaylandConnection);
};
} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_connection_unittest.cc b/chromium/ui/ozone/platform/wayland/host/wayland_connection_unittest.cc
index 380973600ff..cfce7dba945 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_connection_unittest.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_connection_unittest.cc
@@ -9,6 +9,7 @@
#include "base/test/task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
+#include "ui/ozone/platform/wayland/host/wayland_event_source.h"
#include "ui/ozone/platform/wayland/test/test_wayland_server_thread.h"
namespace ui {
@@ -24,7 +25,7 @@ TEST(WaylandConnectionTest, Ping) {
ASSERT_TRUE(server.Start(kXdgVersionStable));
WaylandConnection connection;
ASSERT_TRUE(connection.Initialize());
- connection.StartProcessingEvents();
+ connection.event_source()->StartProcessingEvents();
base::RunLoop().RunUntilIdle();
server.Pause();
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_cursor.cc b/chromium/ui/ozone/platform/wayland/host/wayland_cursor.cc
index 3e0fc6562a7..0d495501f06 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_cursor.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_cursor.cc
@@ -11,11 +11,20 @@
#include "ui/gfx/skia_util.h"
#include "ui/ozone/platform/wayland/common/wayland_util.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
+#include "ui/ozone/platform/wayland/host/wayland_pointer.h"
#include "ui/ozone/platform/wayland/host/wayland_shm.h"
namespace ui {
-WaylandCursor::WaylandCursor() = default;
+WaylandCursor::WaylandCursor(WaylandPointer* pointer,
+ WaylandConnection* connection)
+ : pointer_(pointer), connection_(connection) {
+ DCHECK(connection);
+ DCHECK(connection->compositor());
+
+ pointer_surface_.reset(
+ wl_compositor_create_surface(connection->compositor()));
+}
WaylandCursor::~WaylandCursor() = default;
@@ -26,23 +35,11 @@ void WaylandCursor::OnBufferRelease(void* data, wl_buffer* buffer) {
cursor->buffers_.erase(buffer);
}
-void WaylandCursor::Init(wl_pointer* pointer, WaylandConnection* connection) {
- DCHECK(connection);
- DCHECK(connection->shm());
- DCHECK(connection->compositor());
-
- input_pointer_ = pointer;
- shm_ = connection->shm();
- pointer_surface_.reset(
- wl_compositor_create_surface(connection->compositor()));
-
- connection_ = connection;
-}
-
void WaylandCursor::UpdateBitmap(const std::vector<SkBitmap>& cursor_image,
const gfx::Point& hotspot,
uint32_t serial) {
- if (!input_pointer_)
+ DCHECK(connection_->shm());
+ if (!pointer_)
return;
if (!cursor_image.size())
@@ -53,7 +50,7 @@ void WaylandCursor::UpdateBitmap(const std::vector<SkBitmap>& cursor_image,
return HideCursor(serial);
gfx::Size image_size = gfx::SkISizeToSize(image.dimensions());
- WaylandShmBuffer buffer(shm_, image_size);
+ WaylandShmBuffer buffer(connection_->shm(), image_size);
if (!buffer.IsValid()) {
LOG(ERROR) << "Failed to create SHM buffer for Cursor Bitmap.";
@@ -67,7 +64,7 @@ void WaylandCursor::UpdateBitmap(const std::vector<SkBitmap>& cursor_image,
wl::DrawBitmap(image, &buffer);
- wl_pointer_set_cursor(input_pointer_, serial, pointer_surface_.get(),
+ wl_pointer_set_cursor(pointer_->wl_object(), serial, pointer_surface_.get(),
hotspot.x(), hotspot.y());
wl_surface_damage(pointer_surface_.get(), 0, 0, image_size.width(),
image_size.height());
@@ -79,8 +76,8 @@ void WaylandCursor::UpdateBitmap(const std::vector<SkBitmap>& cursor_image,
}
void WaylandCursor::HideCursor(uint32_t serial) {
- DCHECK(input_pointer_);
- wl_pointer_set_cursor(input_pointer_, serial, nullptr, 0, 0);
+ DCHECK(pointer_);
+ wl_pointer_set_cursor(pointer_->wl_object(), serial, nullptr, 0, 0);
wl_surface_attach(pointer_surface_.get(), nullptr, 0, 0);
wl_surface_commit(pointer_surface_.get());
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_cursor.h b/chromium/ui/ozone/platform/wayland/host/wayland_cursor.h
index 2d53782ed68..5f8b6364bd4 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_cursor.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_cursor.h
@@ -7,8 +7,6 @@
#include <wayland-client.h>
-#include <memory>
-#include <utility>
#include <vector>
#include "base/containers/flat_map.h"
@@ -26,7 +24,7 @@ class Point;
namespace ui {
class WaylandConnection;
-class WaylandShm;
+class WaylandPointer;
// Manages the actual visual representation (what users see drawn) of the
// 'pointer' (which is the Wayland term for mouse/mice).
@@ -38,11 +36,9 @@ class WaylandShm;
// Wayland protocol calls.
class WaylandCursor {
public:
- WaylandCursor();
+ WaylandCursor(WaylandPointer* pointer, WaylandConnection* connection);
~WaylandCursor();
- void Init(wl_pointer* pointer, WaylandConnection* connection);
-
// Updates wl_pointer's visual representation with the given bitmap
// image set and hotspot.
void UpdateBitmap(const std::vector<SkBitmap>& bitmaps,
@@ -55,9 +51,8 @@ class WaylandCursor {
void HideCursor(uint32_t serial);
- WaylandShm* shm_ = nullptr; // Owned by WaylandConnection.
- wl_pointer* input_pointer_ = nullptr; // Owned by WaylandPointer.
- WaylandConnection* connection_ = nullptr;
+ WaylandPointer* const pointer_;
+ WaylandConnection* const connection_;
// Holds the buffers and their memory until the compositor releases them.
base::flat_map<wl_buffer*, WaylandShmBuffer> buffers_;
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_data_device.cc b/chromium/ui/ozone/platform/wayland/host/wayland_data_device.cc
index 4c5008dd42b..361ffa519f1 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_data_device.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_data_device.cc
@@ -6,6 +6,7 @@
#include <memory>
#include <utility>
+#include <vector>
#include "base/bind.h"
#include "base/strings/string16.h"
@@ -20,6 +21,8 @@
#include "ui/base/dragdrop/os_exchange_data_provider_aura.h"
#include "ui/ozone/platform/wayland/common/wayland_util.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
+#include "ui/ozone/platform/wayland/host/wayland_data_offer.h"
+#include "ui/ozone/platform/wayland/host/wayland_shm_buffer.h"
#include "ui/ozone/platform/wayland/host/wayland_window.h"
#include "url/gurl.h"
#include "url/url_canon.h"
@@ -29,8 +32,7 @@ namespace ui {
namespace {
-constexpr OSExchangeData::FilenameToURLPolicy kFilenameToURLPolicy =
- OSExchangeData::FilenameToURLPolicy::CONVERT_FILENAMES;
+constexpr FilenameToURLPolicy kFilenameToURLPolicy = CONVERT_FILENAMES;
// Converts raw data to either narrow or wide string.
template <typename StringType>
@@ -192,7 +194,7 @@ void AddToOSExchangeData(const PlatformClipboard::Data& data,
// static
WaylandDataDevice::WaylandDataDevice(WaylandConnection* connection,
wl_data_device* data_device)
- : internal::WaylandDataDeviceBase(connection), data_device_(data_device) {
+ : WaylandDataDeviceBase(connection), data_device_(data_device) {
static const struct wl_data_device_listener kDataDeviceListener = {
WaylandDataDevice::OnDataOffer, WaylandDataDevice::OnEnter,
WaylandDataDevice::OnLeave, WaylandDataDevice::OnMotion,
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_data_device.h b/chromium/ui/ozone/platform/wayland/host/wayland_data_device.h
index 3f4ade9c4ea..cf2e8cc7a65 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_data_device.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_data_device.h
@@ -10,16 +10,12 @@
#include <list>
#include <memory>
#include <string>
-#include <vector>
#include "base/callback.h"
#include "base/files/scoped_file.h"
#include "base/macros.h"
-#include "ui/gfx/geometry/size.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
-#include "ui/ozone/platform/wayland/host/internal/wayland_data_device_base.h"
-#include "ui/ozone/platform/wayland/host/wayland_data_offer.h"
-#include "ui/ozone/platform/wayland/host/wayland_shm_buffer.h"
+#include "ui/ozone/platform/wayland/host/wayland_data_device_base.h"
#include "ui/ozone/public/platform_clipboard.h"
class SkBitmap;
@@ -29,11 +25,12 @@ namespace ui {
class OSExchangeData;
class WaylandDataOffer;
class WaylandConnection;
+class WaylandShmBuffer;
class WaylandWindow;
// This class provides access to inter-client data transfer mechanisms
// such as copy-and-paste and drag-and-drop mechanisms.
-class WaylandDataDevice : public internal::WaylandDataDeviceBase {
+class WaylandDataDevice : public WaylandDataDeviceBase {
public:
WaylandDataDevice(WaylandConnection* connection, wl_data_device* data_device);
~WaylandDataDevice() override;
@@ -144,7 +141,7 @@ class WaylandDataDevice : public internal::WaylandDataDeviceBase {
bool is_handling_dropped_data_ = false;
bool is_leaving_ = false;
- std::unique_ptr<WaylandShmBuffer> shm_buffer_ = nullptr;
+ std::unique_ptr<WaylandShmBuffer> shm_buffer_;
wl::Object<wl_surface> icon_surface_;
// Mime types to be handled.
diff --git a/chromium/ui/ozone/platform/wayland/host/internal/wayland_data_device_base.cc b/chromium/ui/ozone/platform/wayland/host/wayland_data_device_base.cc
index ca94ce992b5..e61c9b53816 100644
--- a/chromium/ui/ozone/platform/wayland/host/internal/wayland_data_device_base.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_data_device_base.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/ozone/platform/wayland/host/internal/wayland_data_device_base.h"
+#include "ui/ozone/platform/wayland/host/wayland_data_device_base.h"
#include <utility>
@@ -11,7 +11,6 @@
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
namespace ui {
-namespace internal {
WaylandDataDeviceBase::WaylandDataDeviceBase(WaylandConnection* connection)
: connection_(connection) {}
@@ -41,7 +40,7 @@ bool WaylandDataDeviceBase::RequestSelectionData(const std::string& mime_type) {
// Ensure there is not pending operation to be performed by the compositor,
// otherwise read(..) can block awaiting data to be sent to pipe.
RegisterDeferredReadClosure(
- base::BindOnce(&GtkPrimarySelectionDevice::ReadClipboardDataFromFD,
+ base::BindOnce(&WaylandDataDeviceBase::ReadClipboardDataFromFD,
base::Unretained(this), std::move(fd), mime_type));
RegisterDeferredReadCallback();
return true;
@@ -99,5 +98,4 @@ void WaylandDataDeviceBase::DeferredReadCallbackInternal(struct wl_callback* cb,
std::move(deferred_read_closure_).Run();
}
-} // namespace internal
} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/host/internal/wayland_data_device_base.h b/chromium/ui/ozone/platform/wayland/host/wayland_data_device_base.h
index f5ff76443b9..78abf99aec9 100644
--- a/chromium/ui/ozone/platform/wayland/host/internal/wayland_data_device_base.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_data_device_base.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_INTERNAL_WAYLAND_DATA_DEVICE_BASE_H_
-#define UI_OZONE_PLATFORM_WAYLAND_HOST_INTERNAL_WAYLAND_DATA_DEVICE_BASE_H_
+#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_DEVICE_BASE_H_
+#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_DEVICE_BASE_H_
#include <string>
@@ -11,15 +11,12 @@
#include "base/files/scoped_file.h"
#include "base/macros.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
+#include "ui/ozone/platform/wayland/host/wayland_data_offer_base.h"
namespace ui {
class WaylandConnection;
-namespace internal {
-
-class WaylandDataOfferBase;
-
// Implements high level (protocol-agnostic) interface to a Wayland data device.
class WaylandDataDeviceBase {
public:
@@ -75,7 +72,6 @@ class WaylandDataDeviceBase {
DISALLOW_COPY_AND_ASSIGN(WaylandDataDeviceBase);
};
-} // namespace internal
} // namespace ui
-#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_INTERNAL_WAYLAND_DATA_DEVICE_BASE_H_
+#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_DEVICE_BASE_H_
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_data_device_unittest.cc b/chromium/ui/ozone/platform/wayland/host/wayland_data_device_unittest.cc
index cfd1eca7b26..9195d876030 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_data_device_unittest.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_data_device_unittest.cc
@@ -37,8 +37,7 @@ namespace ui {
namespace {
-constexpr OSExchangeData::FilenameToURLPolicy kFilenameToURLPolicy =
- OSExchangeData::FilenameToURLPolicy::CONVERT_FILENAMES;
+constexpr FilenameToURLPolicy kFilenameToURLPolicy = CONVERT_FILENAMES;
template <typename StringType>
ui::PlatformClipboard::Data ToClipboardData(const StringType& data_string) {
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_data_offer.cc b/chromium/ui/ozone/platform/wayland/host/wayland_data_offer.cc
index 4a186a7e0b1..1b274192123 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_data_offer.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_data_offer.cc
@@ -4,12 +4,8 @@
#include "ui/ozone/platform/wayland/host/wayland_data_offer.h"
-#include <fcntl.h>
-#include <algorithm>
-
+#include "base/check.h"
#include "base/files/file_util.h"
-#include "base/logging.h"
-#include "base/stl_util.h"
#include "ui/base/clipboard/clipboard_constants.h"
namespace ui {
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_data_offer.h b/chromium/ui/ozone/platform/wayland/host/wayland_data_offer.h
index 24cba88112a..f79bc7b3b71 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_data_offer.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_data_offer.h
@@ -8,12 +8,11 @@
#include <wayland-client.h>
#include <string>
-#include <vector>
#include "base/files/scoped_file.h"
#include "base/macros.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
-#include "ui/ozone/platform/wayland/host/internal/wayland_data_offer_base.h"
+#include "ui/ozone/platform/wayland/host/wayland_data_offer_base.h"
namespace ui {
@@ -24,7 +23,7 @@ namespace ui {
// The offer describes the different mime types that the data can be
// converted to and provides the mechanism for transferring the data
// directly from the source client.
-class WaylandDataOffer : public internal::WaylandDataOfferBase {
+class WaylandDataOffer : public WaylandDataOfferBase {
public:
// Takes ownership of data_offer.
explicit WaylandDataOffer(wl_data_offer* data_offer);
@@ -34,7 +33,7 @@ class WaylandDataOffer : public internal::WaylandDataOfferBase {
void Accept(uint32_t serial, const std::string& mime_type);
void Reject(uint32_t serial);
- // internal::WaylandDataOfferBase overrides:
+ // WaylandDataOfferBase overrides:
base::ScopedFD Receive(const std::string& mime_type) override;
void FinishOffer();
diff --git a/chromium/ui/ozone/platform/wayland/host/internal/wayland_data_offer_base.cc b/chromium/ui/ozone/platform/wayland/host/wayland_data_offer_base.cc
index d2068d7d492..8656f41412c 100644
--- a/chromium/ui/ozone/platform/wayland/host/internal/wayland_data_offer_base.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_data_offer_base.cc
@@ -2,13 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/ozone/platform/wayland/host/internal/wayland_data_offer_base.h"
+#include "ui/ozone/platform/wayland/host/wayland_data_offer_base.h"
#include "base/stl_util.h"
#include "ui/base/clipboard/clipboard_constants.h"
namespace ui {
-namespace internal {
namespace {
@@ -40,5 +39,4 @@ void WaylandDataOfferBase::AddMimeType(const char* mime_type) {
mime_types_.push_back(mime_type);
}
-} // namespace internal
} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/host/internal/wayland_data_offer_base.h b/chromium/ui/ozone/platform/wayland/host/wayland_data_offer_base.h
index b1e61026606..3f0e91c8281 100644
--- a/chromium/ui/ozone/platform/wayland/host/internal/wayland_data_offer_base.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_data_offer_base.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_INTERNAL_WAYLAND_DATA_OFFER_BASE_H_
-#define UI_OZONE_PLATFORM_WAYLAND_HOST_INTERNAL_WAYLAND_DATA_OFFER_BASE_H_
+#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_OFFER_BASE_H_
+#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_OFFER_BASE_H_
#include <string>
#include <vector>
@@ -12,7 +12,6 @@
#include "base/macros.h"
namespace ui {
-namespace internal {
// Implements common part of WaylandDataOffer and GtkPrimarySelectionOffer
// (which is handling of the clipboard data).
@@ -51,7 +50,6 @@ class WaylandDataOfferBase {
DISALLOW_COPY_AND_ASSIGN(WaylandDataOfferBase);
};
-} // namespace internal
} // namespace ui
-#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_INTERNAL_WAYLAND_DATA_OFFER_BASE_H_
+#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_OFFER_BASE_H_
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_data_source.cc b/chromium/ui/ozone/platform/wayland/host/wayland_data_source.cc
index e35746eb998..0b92ceaeba7 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_data_source.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_data_source.cc
@@ -4,7 +4,10 @@
#include "ui/ozone/platform/wayland/host/wayland_data_source.h"
+#include <vector>
+
#include "base/files/file_util.h"
+#include "base/optional.h"
#include "ui/base/clipboard/clipboard_constants.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/os_exchange_data.h"
@@ -47,7 +50,7 @@ void WaylandDataSource::Offer(const ui::OSExchangeData& data) {
if (data.HasFile()) {
mime_types.push_back(kMimeTypeURIList);
}
- if (data.HasURL(ui::OSExchangeData::FilenameToURLPolicy::CONVERT_FILENAMES)) {
+ if (data.HasURL(ui::CONVERT_FILENAMES)) {
mime_types.push_back(kMimeTypeMozillaURL);
}
if (data.HasHtml()) {
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_data_source.h b/chromium/ui/ozone/platform/wayland/host/wayland_data_source.h
index 7ee699ba635..4f66465a699 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_data_source.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_data_source.h
@@ -9,13 +9,12 @@
#include <map>
#include <string>
-#include <vector>
#include "base/logging.h"
#include "base/macros.h"
#include "base/optional.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
-#include "ui/ozone/platform/wayland/host/internal/wayland_data_source_base.h"
+#include "ui/ozone/platform/wayland/host/wayland_data_source_base.h"
#include "ui/ozone/public/platform_clipboard.h"
namespace ui {
@@ -29,7 +28,7 @@ class WaylandWindow;
// transfer and provides a way to describe the offered data
// (wl_data_source_offer) // and a way to respond to requests to
// transfer the data (OnSend listener).
-class WaylandDataSource : public internal::WaylandDataSourceBase {
+class WaylandDataSource : public WaylandDataSourceBase {
public:
using DragDataMap = std::map<std::string, std::string>;
diff --git a/chromium/ui/ozone/platform/wayland/host/internal/wayland_data_source_base.cc b/chromium/ui/ozone/platform/wayland/host/wayland_data_source_base.cc
index a101fdb8ebd..c7bba1d2538 100644
--- a/chromium/ui/ozone/platform/wayland/host/internal/wayland_data_source_base.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_data_source_base.cc
@@ -2,10 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/ozone/platform/wayland/host/internal/wayland_data_source_base.h"
+#include "ui/ozone/platform/wayland/host/wayland_data_source_base.h"
namespace ui {
-namespace internal {
WaylandDataSourceBase::WaylandDataSourceBase() = default;
WaylandDataSourceBase::~WaylandDataSourceBase() = default;
@@ -19,5 +18,4 @@ void WaylandDataSourceBase::GetClipboardData(
data->emplace(it->second);
}
-} // namespace internal
} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/host/internal/wayland_data_source_base.h b/chromium/ui/ozone/platform/wayland/host/wayland_data_source_base.h
index e630f4c4132..4e4d66b1607 100644
--- a/chromium/ui/ozone/platform/wayland/host/internal/wayland_data_source_base.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_data_source_base.h
@@ -2,14 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_INTERNAL_WAYLAND_DATA_SOURCE_BASE_H_
-#define UI_OZONE_PLATFORM_WAYLAND_HOST_INTERNAL_WAYLAND_DATA_SOURCE_BASE_H_
+#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_SOURCE_BASE_H_
+#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_SOURCE_BASE_H_
#include "base/macros.h"
#include "ui/ozone/public/platform_clipboard.h"
namespace ui {
-namespace internal {
// Implements high level (protocol-agnostic) interface to a Wayland data source.
class WaylandDataSourceBase {
@@ -34,7 +33,6 @@ class WaylandDataSourceBase {
DISALLOW_COPY_AND_ASSIGN(WaylandDataSourceBase);
};
-} // namespace internal
} // namespace ui
-#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_INTERNAL_WAYLAND_DATA_SOURCE_BASE_H_
+#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_DATA_SOURCE_BASE_H_
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_event_source.cc b/chromium/ui/ozone/platform/wayland/host/wayland_event_source.cc
new file mode 100644
index 00000000000..a83c0bfe87c
--- /dev/null
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_event_source.cc
@@ -0,0 +1,360 @@
+// Copyright 2020 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 "ui/ozone/platform/wayland/host/wayland_event_source.h"
+
+#include <algorithm>
+#include <memory>
+
+#include "base/bind.h"
+#include "base/check.h"
+#include "base/optional.h"
+#include "base/time/time.h"
+#include "ui/events/base_event_utils.h"
+#include "ui/events/event.h"
+#include "ui/events/keycodes/dom/dom_code.h"
+#include "ui/events/keycodes/dom/dom_key.h"
+#include "ui/events/keycodes/keyboard_code_conversion.h"
+#include "ui/events/keycodes/keyboard_codes.h"
+#include "ui/events/pointer_details.h"
+#include "ui/events/types/event_type.h"
+#include "ui/gfx/geometry/point_f.h"
+#include "ui/gfx/geometry/vector2d_f.h"
+#include "ui/ozone/platform/wayland/host/wayland_connection.h"
+#include "ui/ozone/platform/wayland/host/wayland_event_watcher.h"
+#include "ui/ozone/platform/wayland/host/wayland_keyboard.h"
+#include "ui/ozone/platform/wayland/host/wayland_window.h"
+#include "ui/ozone/platform/wayland/host/wayland_window_manager.h"
+
+namespace ui {
+
+namespace {
+
+bool HasAnyPointerButtonFlag(int flags) {
+ return (flags & (EF_LEFT_MOUSE_BUTTON | EF_MIDDLE_MOUSE_BUTTON |
+ EF_RIGHT_MOUSE_BUTTON | EF_BACK_MOUSE_BUTTON |
+ EF_FORWARD_MOUSE_BUTTON)) != 0;
+}
+
+} // namespace
+
+struct WaylandEventSource::TouchPoint {
+ TouchPoint(gfx::PointF location, WaylandWindow* current_window);
+ ~TouchPoint() = default;
+
+ WaylandWindow* const window;
+ gfx::PointF last_known_location;
+};
+
+WaylandEventSource::TouchPoint::TouchPoint(gfx::PointF location,
+ WaylandWindow* current_window)
+ : window(current_window), last_known_location(location) {
+ DCHECK(window);
+}
+
+// WaylandEventSource implementation
+
+WaylandEventSource::WaylandEventSource(wl_display* display,
+ WaylandWindowManager* window_manager)
+ : window_manager_(window_manager),
+ event_watcher_(std::make_unique<WaylandEventWatcher>(display)) {
+ DCHECK(window_manager_);
+
+ // Observes remove changes to know when touch points can be removed.
+ window_manager_->AddObserver(this);
+}
+
+WaylandEventSource::~WaylandEventSource() = default;
+
+bool WaylandEventSource::StartProcessingEvents() {
+ return event_watcher_->StartProcessingEvents();
+}
+
+bool WaylandEventSource::StopProcessingEvents() {
+ return event_watcher_->StopProcessingEvents();
+}
+
+void WaylandEventSource::OnKeyboardCreated(WaylandKeyboard* keyboard) {
+ DCHECK(keyboard);
+ keyboard_ = keyboard;
+}
+
+void WaylandEventSource::OnKeyboardDestroyed(WaylandKeyboard* keyboard) {
+ DCHECK_EQ(keyboard_, keyboard);
+ keyboard_modifiers_ = 0;
+ keyboard_ = nullptr;
+}
+
+void WaylandEventSource::OnKeyboardFocusChanged(WaylandWindow* window,
+ bool focused) {
+ DCHECK(window);
+ HandleKeyboardFocusChange(window, focused);
+}
+
+void WaylandEventSource::OnKeyboardModifiersChanged(int modifiers) {
+ keyboard_modifiers_ = modifiers;
+}
+
+void WaylandEventSource::OnKeyboardKeyEvent(EventType type,
+ DomCode dom_code,
+ DomKey dom_key,
+ KeyboardCode key_code,
+ bool repeat,
+ base::TimeTicks timestamp) {
+ DCHECK(type == ET_KEY_PRESSED || type == ET_KEY_RELEASED);
+ if (!keyboard_)
+ return;
+
+ // try to decode key, if not yet.
+ if (dom_key == DomKey::NONE &&
+ !keyboard_->Decode(dom_code, keyboard_modifiers_, &dom_key, &key_code)) {
+ LOG(ERROR) << "Failed to decode key event.";
+ return;
+ }
+
+ if (!repeat) {
+ int flag = ModifierDomKeyToEventFlag(dom_key);
+ UpdateKeyboardModifiers(flag, type == ET_KEY_PRESSED);
+ }
+
+ KeyEvent event(type, key_code, dom_code, keyboard_modifiers_, dom_key,
+ timestamp);
+ event.set_source_device_id(keyboard_->device_id());
+ DispatchEvent(&event);
+}
+
+void WaylandEventSource::OnPointerCreated(WaylandPointer* pointer) {
+ DCHECK(pointer);
+ pointer_ = pointer;
+}
+
+void WaylandEventSource::OnPointerDestroyed(WaylandPointer* pointer) {
+ DCHECK_EQ(pointer_, pointer);
+
+ // Clear focused window, if any.
+ if (auto* focused_window = window_manager_->GetCurrentFocusedWindow())
+ HandlePointerFocusChange(focused_window, false);
+
+ ResetPointerFlags();
+ pointer_ = nullptr;
+}
+
+void WaylandEventSource::OnPointerFocusChanged(WaylandWindow* window,
+ bool focused,
+ const gfx::PointF& location) {
+ if (!pointer_)
+ return;
+
+ // Save new pointer location.
+ pointer_location_ = location;
+
+ if (focused)
+ HandlePointerFocusChange(window, focused);
+
+ EventType type = focused ? ET_MOUSE_ENTERED : ET_MOUSE_EXITED;
+ MouseEvent event(type, location, location, EventTimeForNow(), pointer_flags_,
+ 0);
+ DispatchEvent(&event);
+
+ if (!focused)
+ HandlePointerFocusChange(window, focused);
+}
+
+void WaylandEventSource::OnPointerButtonEvent(EventType type,
+ int changed_button) {
+ DCHECK(type == ET_MOUSE_PRESSED || type == ET_MOUSE_RELEASED);
+ DCHECK(HasAnyPointerButtonFlag(changed_button));
+
+ if (!pointer_)
+ return;
+
+ pointer_flags_ = type == ET_MOUSE_PRESSED
+ ? (pointer_flags_ | changed_button)
+ : (pointer_flags_ & ~changed_button);
+ // MouseEvent's flags should contain the button that was released too.
+ int flags = pointer_flags_ | keyboard_modifiers_ | changed_button;
+ MouseEvent event(type, pointer_location_, pointer_location_,
+ EventTimeForNow(), flags, changed_button);
+ DispatchEvent(&event);
+}
+
+void WaylandEventSource::OnPointerMotionEvent(const gfx::PointF& location) {
+ pointer_location_ = location;
+ int flags = pointer_flags_ | keyboard_modifiers_;
+ MouseEvent event(ET_MOUSE_MOVED, pointer_location_, pointer_location_,
+ EventTimeForNow(), flags, 0);
+ DispatchEvent(&event);
+}
+
+void WaylandEventSource::OnPointerAxisEvent(const gfx::Vector2d& offset) {
+ int flags = pointer_flags_ | keyboard_modifiers_;
+ MouseWheelEvent event(offset, pointer_location_, pointer_location_,
+ EventTimeForNow(), flags, 0);
+ DispatchEvent(&event);
+}
+
+void WaylandEventSource::OnTouchCreated(WaylandTouch* touch) {
+ DCHECK(touch);
+ touch_ = touch;
+}
+
+void WaylandEventSource::OnTouchDestroyed(WaylandTouch* touch) {
+ DCHECK_EQ(touch_, touch);
+ touch_points_.clear();
+ touch_ = nullptr;
+}
+
+void WaylandEventSource::OnTouchPressEvent(WaylandWindow* window,
+ const gfx::PointF& location,
+ base::TimeTicks timestamp,
+ PointerId id) {
+ DCHECK(window);
+ HandleTouchFocusChange(window, true);
+
+ // Make sure this touch point wasn't present before.
+ auto success = touch_points_.try_emplace(
+ id, std::make_unique<TouchPoint>(location, window));
+ if (!success.second) {
+ LOG(WARNING) << "Touch down fired with wrong id";
+ return;
+ }
+
+ PointerDetails details(EventPointerType::kTouch, id);
+ TouchEvent event(ET_TOUCH_PRESSED, location, location, timestamp, details);
+ DispatchEvent(&event);
+}
+
+void WaylandEventSource::OnTouchReleaseEvent(base::TimeTicks timestamp,
+ PointerId id) {
+ // Make sure this touch point was present before.
+ const auto it = touch_points_.find(id);
+ if (it == touch_points_.end()) {
+ LOG(WARNING) << "Touch up fired with no matching touch down";
+ return;
+ }
+
+ TouchPoint* touch_point = it->second.get();
+ gfx::PointF location = touch_point->last_known_location;
+ PointerDetails details(EventPointerType::kTouch, id);
+
+ TouchEvent event(ET_TOUCH_RELEASED, location, location, timestamp, details);
+ DispatchEvent(&event);
+
+ HandleTouchFocusChange(touch_point->window, false, id);
+ touch_points_.erase(it);
+}
+
+void WaylandEventSource::OnTouchMotionEvent(const gfx::PointF& location,
+ base::TimeTicks timestamp,
+ PointerId id) {
+ const auto it = touch_points_.find(id);
+ // Make sure this touch point was present before.
+ if (it == touch_points_.end()) {
+ LOG(WARNING) << "Touch event fired with wrong id";
+ return;
+ }
+ it->second->last_known_location = location;
+ PointerDetails details(EventPointerType::kTouch, id);
+ TouchEvent event(ET_TOUCH_MOVED, location, location, timestamp, details);
+ DispatchEvent(&event);
+}
+
+void WaylandEventSource::OnTouchCancelEvent() {
+ gfx::PointF location;
+ base::TimeTicks timestamp = base::TimeTicks::Now();
+ for (auto& touch_point : touch_points_) {
+ PointerId id = touch_point.first;
+ TouchEvent event(ET_TOUCH_CANCELLED, location, location, timestamp,
+ PointerDetails(EventPointerType::kTouch, id));
+ DispatchEvent(&event);
+ HandleTouchFocusChange(touch_point.second->window, false);
+ }
+ touch_points_.clear();
+}
+
+bool WaylandEventSource::IsPointerButtonPressed(EventFlags button) const {
+ DCHECK(HasAnyPointerButtonFlag(button));
+ return pointer_flags_ & button;
+}
+
+void WaylandEventSource::ResetPointerFlags() {
+ pointer_flags_ = 0;
+}
+
+void WaylandEventSource::OnDispatcherListChanged() {
+ StartProcessingEvents();
+}
+
+void WaylandEventSource::OnWindowRemoved(WaylandWindow* window) {
+ // Clear pointer-related data.
+ if (window == window_with_pointer_focus_)
+ window_with_pointer_focus_ = nullptr;
+
+ // Clear touch-related data.
+ base::EraseIf(touch_points_, [window](const auto& point) {
+ return point.second->window == window;
+ });
+}
+
+// Currently EF_MOD3_DOWN means that the CapsLock key is currently down, and
+// EF_CAPS_LOCK_ON means the caps lock state is enabled (and the key may or
+// may not be down, but usually isn't). There does need to be two different
+// flags, since the physical CapsLock key is subject to remapping, but the
+// caps lock state (which can be triggered in a variety of ways) is not.
+//
+// TODO(crbug.com/1076661): This is likely caused by some CrOS-specific code.
+// Get rid of this function once it is properly guarded under OS_CHROMEOS.
+void WaylandEventSource::UpdateKeyboardModifiers(int modifier, bool down) {
+ if (modifier == EF_NONE)
+ return;
+
+ if (modifier == EF_CAPS_LOCK_ON) {
+ modifier = (modifier & ~EF_CAPS_LOCK_ON) | EF_MOD3_DOWN;
+ }
+ keyboard_modifiers_ = down ? (keyboard_modifiers_ | modifier)
+ : (keyboard_modifiers_ & ~modifier);
+}
+
+void WaylandEventSource::HandleKeyboardFocusChange(WaylandWindow* window,
+ bool focused) {
+ DCHECK(window);
+ window->set_keyboard_focus(focused);
+}
+
+void WaylandEventSource::HandlePointerFocusChange(WaylandWindow* window,
+ bool focused) {
+ // window can be null on wl_pointer::leave events, for example.
+ if (window)
+ window->SetPointerFocus(focused);
+
+ if (focused) {
+ DCHECK(window);
+ window_with_pointer_focus_ = window;
+ } else {
+ // Focused window might have been destroyed at this point (eg: context
+ // menus), in this case, |window| is null, otherwise it must be equal to
+ // |window_with_pointer_focus_|. In both cases, they must be equal.
+ DCHECK_EQ(window_with_pointer_focus_, window);
+ window_with_pointer_focus_ = nullptr;
+ }
+}
+
+void WaylandEventSource::HandleTouchFocusChange(WaylandWindow* window,
+ bool focused,
+ base::Optional<PointerId> id) {
+ DCHECK(window);
+ bool actual_focus = id ? !ShouldUnsetTouchFocus(window, id.value()) : focused;
+ window->set_touch_focus(actual_focus);
+}
+
+// Focus must not be unset if there is another touch point within |window|.
+bool WaylandEventSource::ShouldUnsetTouchFocus(WaylandWindow* win,
+ PointerId id) {
+ auto result = std::find_if(
+ touch_points_.begin(), touch_points_.end(),
+ [win, id](auto& p) { return p.second->window == win && p.first != id; });
+ return result == touch_points_.end();
+}
+
+} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_event_source.h b/chromium/ui/ozone/platform/wayland/host/wayland_event_source.h
new file mode 100644
index 00000000000..7f1a565c613
--- /dev/null
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_event_source.h
@@ -0,0 +1,153 @@
+// Copyright 2020 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 UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_EVENT_SOURCE_H_
+#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_EVENT_SOURCE_H_
+
+#include <memory>
+
+#include "base/containers/flat_map.h"
+#include "base/optional.h"
+#include "base/time/time.h"
+#include "ui/events/event_constants.h"
+#include "ui/events/keycodes/dom/dom_code.h"
+#include "ui/events/keycodes/dom/dom_key.h"
+#include "ui/events/keycodes/keyboard_codes.h"
+#include "ui/events/platform/platform_event_source.h"
+#include "ui/events/pointer_details.h"
+#include "ui/events/types/event_type.h"
+#include "ui/gfx/geometry/point_f.h"
+#include "ui/ozone/platform/wayland/host/wayland_event_watcher.h"
+#include "ui/ozone/platform/wayland/host/wayland_input_method_context.h"
+#include "ui/ozone/platform/wayland/host/wayland_keyboard.h"
+#include "ui/ozone/platform/wayland/host/wayland_pointer.h"
+#include "ui/ozone/platform/wayland/host/wayland_touch.h"
+#include "ui/ozone/platform/wayland/host/wayland_window_manager.h"
+#include "ui/ozone/platform/wayland/host/wayland_window_observer.h"
+
+struct wl_display;
+
+namespace gfx {
+class Vector2d;
+}
+
+namespace ui {
+
+class WaylandWindow;
+class WaylandWindowManager;
+
+// Wayland implementation of ui::PlatformEventSource. It polls for events
+// through WaylandEventWatcher and centralizes the input and focus handling
+// logic within Ozone Wayland backend. In order to do so, it also implements the
+// input objects' delegate interfaces, which are the entry point of event data
+// coming from input devices, e.g: wl_{keyboard,pointer,touch}, which are then
+// pre-processed, translated into ui::Event instances and dispatched to the
+// PlatformEvent system.
+class WaylandEventSource : public PlatformEventSource,
+ public WaylandWindowObserver,
+ public WaylandKeyboard::Delegate,
+ public WaylandPointer::Delegate,
+ public WaylandTouch::Delegate {
+ public:
+ WaylandEventSource(wl_display* display, WaylandWindowManager* window_manager);
+ WaylandEventSource(const WaylandEventSource&) = delete;
+ WaylandEventSource& operator=(const WaylandEventSource&) = delete;
+ ~WaylandEventSource() override;
+
+ // Starts polling for events from the wayland connection file descriptor.
+ // This method assumes connection is already estabilished and input objects
+ // are already bound and properly initialized.
+ bool StartProcessingEvents();
+ // Stops polling for events from input devices.
+ bool StopProcessingEvents();
+
+ // Tells if pointer |button| is currently pressed.
+ bool IsPointerButtonPressed(EventFlags button) const;
+
+ // Allow to explicitly reset pointer flags. Required in cases where the
+ // pointer state is modified by a button pressed event, but the respective
+ // button released event is not delivered (e.g: window moving, drag and drop).
+ void ResetPointerFlags();
+
+ protected:
+ // WaylandKeyboard::Delegate
+ void OnKeyboardCreated(WaylandKeyboard* keyboard) override;
+ void OnKeyboardDestroyed(WaylandKeyboard* keyboard) override;
+ void OnKeyboardFocusChanged(WaylandWindow* window, bool focused) override;
+ void OnKeyboardModifiersChanged(int modifiers) override;
+ void OnKeyboardKeyEvent(EventType type,
+ DomCode dom_code,
+ DomKey dom_key,
+ KeyboardCode key_code,
+ bool repeat,
+ base::TimeTicks timestamp) override;
+
+ // WaylandPointer::Delegate
+ void OnPointerCreated(WaylandPointer* pointer) override;
+ void OnPointerDestroyed(WaylandPointer* pointer) override;
+ void OnPointerFocusChanged(WaylandWindow* window,
+ bool focused,
+ const gfx::PointF& location) override;
+ void OnPointerButtonEvent(EventType evtype, int changed_button) override;
+ void OnPointerMotionEvent(const gfx::PointF& location) override;
+ void OnPointerAxisEvent(const gfx::Vector2d& offset) override;
+
+ // WaylandTouch::Delegate
+ void OnTouchCreated(WaylandTouch* touch) override;
+ void OnTouchDestroyed(WaylandTouch* touch) override;
+ void OnTouchPressEvent(WaylandWindow* window,
+ const gfx::PointF& location,
+ base::TimeTicks timestamp,
+ PointerId id) override;
+ void OnTouchReleaseEvent(base::TimeTicks timestamp, PointerId id) override;
+ void OnTouchMotionEvent(const gfx::PointF& location,
+ base::TimeTicks timestamp,
+ PointerId id) override;
+ void OnTouchCancelEvent() override;
+
+ private:
+ struct TouchPoint;
+
+ // PlatformEventSource:
+ void OnDispatcherListChanged() override;
+
+ // WaylandWindowObserver
+ void OnWindowRemoved(WaylandWindow* window) override;
+
+ void UpdateKeyboardModifiers(int modifier, bool down);
+ void HandleKeyboardFocusChange(WaylandWindow* window, bool focused);
+ void HandlePointerFocusChange(WaylandWindow* window, bool focused);
+ void HandleTouchFocusChange(WaylandWindow* window,
+ bool focused,
+ base::Optional<PointerId> id = base::nullopt);
+ bool ShouldUnsetTouchFocus(WaylandWindow* window, PointerId id);
+
+ WaylandWindowManager* const window_manager_;
+
+ // Input device objects. Owned by WaylandConnection.
+ WaylandKeyboard* keyboard_ = nullptr;
+ WaylandPointer* pointer_ = nullptr;
+ WaylandTouch* touch_ = nullptr;
+
+ // Bitmask of EventFlags used to keep track of the the pointer state.
+ int pointer_flags_ = 0;
+
+ // Bitmask of EventFlags used to keep track of the the keyboard state.
+ int keyboard_modifiers_ = 0;
+
+ // Last known pointer location.
+ gfx::PointF pointer_location_;
+
+ // The window the pointer is over.
+ WaylandWindow* window_with_pointer_focus_ = nullptr;
+
+ // Map that keeps track of the current touch points, associating touch IDs to
+ // to the surface/location where they happened.
+ base::flat_map<PointerId, std::unique_ptr<TouchPoint>> touch_points_;
+
+ std::unique_ptr<WaylandEventWatcher> event_watcher_;
+};
+
+} // namespace ui
+#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_EVENT_SOURCE_H_
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_event_source_unittest.cc b/chromium/ui/ozone/platform/wayland/host/wayland_event_source_unittest.cc
new file mode 100644
index 00000000000..9cec9ccbd4b
--- /dev/null
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_event_source_unittest.cc
@@ -0,0 +1,118 @@
+// Copyright 2020 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 <linux/input.h>
+#include <wayland-client-protocol.h>
+#include <wayland-server-core.h>
+
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/ozone/platform/wayland/host/wayland_event_source.h"
+#include "ui/ozone/platform/wayland/test/mock_pointer.h"
+#include "ui/ozone/platform/wayland/test/mock_surface.h"
+#include "ui/ozone/platform/wayland/test/test_keyboard.h"
+#include "ui/ozone/platform/wayland/test/wayland_test.h"
+#include "ui/ozone/test/mock_platform_window_delegate.h"
+
+using ::testing::_;
+
+namespace ui {
+
+namespace {
+
+constexpr gfx::Rect kDefaultBounds(0, 0, 100, 100);
+
+} // namespace
+
+class WaylandEventSourceTest : public WaylandTest {
+ public:
+ WaylandEventSourceTest() {}
+
+ void SetUp() override {
+ WaylandTest::SetUp();
+
+ event_source_ = connection_->event_source();
+ DCHECK(event_source_);
+ }
+
+ protected:
+ std::unique_ptr<WaylandWindow> CreateWaylandWindowWithParams(
+ PlatformWindowType type,
+ const gfx::Rect bounds,
+ MockPlatformWindowDelegate* delegate) {
+ PlatformWindowInitProperties properties;
+ properties.bounds = bounds;
+ properties.type = type;
+ auto window = WaylandWindow::Create(delegate, connection_.get(),
+ std::move(properties));
+ if (window)
+ window->Show(false);
+ return window;
+ }
+
+ WaylandEventSource* event_source_ = nullptr;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(WaylandEventSourceTest);
+};
+
+// Verify WaylandEventSource properly manages its internal state as pointer
+// button events are sent. More specifically - pointer flags.
+TEST_P(WaylandEventSourceTest, CheckPointerButtonHandling) {
+ MockPlatformWindowDelegate delegate;
+ wl_seat_send_capabilities(server_.seat()->resource(),
+ WL_SEAT_CAPABILITY_POINTER);
+ Sync();
+
+ EXPECT_FALSE(event_source_->IsPointerButtonPressed(EF_LEFT_MOUSE_BUTTON));
+ EXPECT_FALSE(event_source_->IsPointerButtonPressed(EF_RIGHT_MOUSE_BUTTON));
+ EXPECT_FALSE(event_source_->IsPointerButtonPressed(EF_MIDDLE_MOUSE_BUTTON));
+ EXPECT_FALSE(event_source_->IsPointerButtonPressed(EF_BACK_MOUSE_BUTTON));
+ EXPECT_FALSE(event_source_->IsPointerButtonPressed(EF_FORWARD_MOUSE_BUTTON));
+
+ auto window1 = CreateWaylandWindowWithParams(PlatformWindowType::kWindow,
+ kDefaultBounds, &delegate);
+ Sync();
+
+ ASSERT_TRUE(server_.seat()->pointer());
+
+ uint32_t serial = 0;
+ uint32_t tstamp = 0;
+ wl_resource* surface_res =
+ server_.GetObject<wl::MockSurface>(window1->GetWidget())->resource();
+ wl_resource* pointer_res = server_.seat()->pointer()->resource();
+
+ wl_pointer_send_enter(pointer_res, serial++, surface_res, 0, 0);
+ wl_pointer_send_button(pointer_res, serial++, tstamp++, BTN_LEFT,
+ WL_POINTER_BUTTON_STATE_PRESSED);
+ EXPECT_CALL(delegate, DispatchEvent(_)).Times(2);
+ Sync();
+
+ EXPECT_TRUE(event_source_->IsPointerButtonPressed(EF_LEFT_MOUSE_BUTTON));
+
+ wl_pointer_send_button(pointer_res, serial++, tstamp++, BTN_RIGHT,
+ WL_POINTER_BUTTON_STATE_PRESSED);
+ EXPECT_CALL(delegate, DispatchEvent(_)).Times(1);
+ Sync();
+
+ EXPECT_TRUE(event_source_->IsPointerButtonPressed(EF_RIGHT_MOUSE_BUTTON));
+
+ wl_pointer_send_button(pointer_res, serial++, tstamp++, BTN_LEFT,
+ WL_POINTER_BUTTON_STATE_RELEASED);
+ wl_pointer_send_button(pointer_res, serial++, tstamp++, BTN_RIGHT,
+ WL_POINTER_BUTTON_STATE_RELEASED);
+ EXPECT_CALL(delegate, DispatchEvent(_)).Times(2);
+ Sync();
+
+ EXPECT_FALSE(event_source_->IsPointerButtonPressed(EF_LEFT_MOUSE_BUTTON));
+ EXPECT_FALSE(event_source_->IsPointerButtonPressed(EF_RIGHT_MOUSE_BUTTON));
+}
+
+INSTANTIATE_TEST_SUITE_P(XdgVersionStableTest,
+ WaylandEventSourceTest,
+ ::testing::Values(kXdgShellStable));
+INSTANTIATE_TEST_SUITE_P(XdgVersionV6Test,
+ WaylandEventSourceTest,
+ ::testing::Values(kXdgShellV6));
+
+} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_event_watcher.cc b/chromium/ui/ozone/platform/wayland/host/wayland_event_watcher.cc
new file mode 100644
index 00000000000..30325c45884
--- /dev/null
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_event_watcher.cc
@@ -0,0 +1,107 @@
+// Copyright 2020 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 "ui/ozone/platform/wayland/host/wayland_event_watcher.h"
+
+#include <wayland-client-core.h>
+#include <wayland-client-protocol.h>
+
+#include "base/bind.h"
+#include "base/check.h"
+#include "base/message_loop/message_loop_current.h"
+#include "ui/events/event.h"
+
+namespace ui {
+
+WaylandEventWatcher::WaylandEventWatcher(wl_display* display)
+ : controller_(FROM_HERE), display_(display) {
+ DCHECK(display_);
+}
+
+WaylandEventWatcher::~WaylandEventWatcher() {
+ StopProcessingEvents();
+}
+
+bool WaylandEventWatcher::StartProcessingEvents() {
+ DCHECK(display_);
+ if (watching_)
+ return true;
+
+ DCHECK(display_);
+ MaybePrepareReadQueue();
+ wl_display_flush(display_);
+ return StartWatchingFd(base::MessagePumpForUI::WATCH_READ);
+}
+
+bool WaylandEventWatcher::StopProcessingEvents() {
+ if (!watching_)
+ return false;
+
+ DCHECK(base::MessageLoopCurrentForUI::IsSet());
+ watching_ = false;
+ return controller_.StopWatchingFileDescriptor();
+}
+
+void WaylandEventWatcher::OnFileCanReadWithoutBlocking(int fd) {
+ if (prepared_) {
+ prepared_ = false;
+ if (wl_display_read_events(display_) == -1)
+ return;
+ wl_display_dispatch_pending(display_);
+ }
+
+ MaybePrepareReadQueue();
+
+ if (!prepared_)
+ return;
+
+ // Automatic Flush.
+ int ret = wl_display_flush(display_);
+ if (ret != -1 || errno != EAGAIN)
+ return;
+
+ // if all data could not be written, errno will be set to EAGAIN and -1
+ // returned. In that case, use poll on the display file descriptor to wait for
+ // it to become writable again.
+ StartWatchingFd(base::MessagePumpForUI::WATCH_WRITE);
+}
+
+void WaylandEventWatcher::OnFileCanWriteWithoutBlocking(int fd) {
+ int ret = wl_display_flush(display_);
+ if (ret != -1 || errno != EAGAIN)
+ StartWatchingFd(base::MessagePumpForUI::WATCH_READ);
+ else if (ret < 0 && errno != EPIPE && prepared_)
+ wl_display_cancel_read(display_);
+
+ // Otherwise just continue watching in the same mode.
+}
+
+bool WaylandEventWatcher::StartWatchingFd(
+ base::WatchableIOMessagePumpPosix::Mode mode) {
+ if (watching_) {
+ // Stop watching first.
+ watching_ = !controller_.StopWatchingFileDescriptor();
+ DCHECK(!watching_);
+ }
+
+ DCHECK(base::MessageLoopCurrentForUI::IsSet());
+ int display_fd = wl_display_get_fd(display_);
+ watching_ = base::MessageLoopCurrentForUI::Get()->WatchFileDescriptor(
+ display_fd, true, mode, &controller_, this);
+ return watching_;
+}
+
+void WaylandEventWatcher::MaybePrepareReadQueue() {
+ if (prepared_)
+ return;
+
+ if (wl_display_prepare_read(display_) != -1) {
+ prepared_ = true;
+ return;
+ }
+ // Nothing to read, send events to the queue.
+ wl_display_dispatch_pending(display_);
+}
+
+} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_event_watcher.h b/chromium/ui/ozone/platform/wayland/host/wayland_event_watcher.h
new file mode 100644
index 00000000000..9960855cd5a
--- /dev/null
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_event_watcher.h
@@ -0,0 +1,52 @@
+// Copyright 2020 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 UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_EVENT_WATCHER_H_
+#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_EVENT_WATCHER_H_
+
+#include "base/message_loop/message_pump_for_ui.h"
+#include "base/message_loop/watchable_io_message_pump_posix.h"
+
+struct wl_display;
+
+namespace ui {
+
+// WaylandEventWatcher serves a single purpose: poll for events in the wayland
+// connection file descriptor. Which will then trigger input objects (e.g:
+// WaylandPointer, WaylandKeyboard, etc) callbacks, indirectly leading to calls
+// into WaylandEventSource, so feeding the platform events pipeline.
+class WaylandEventWatcher : public base::MessagePumpForUI::FdWatcher {
+ public:
+ explicit WaylandEventWatcher(wl_display* display);
+ WaylandEventWatcher(const WaylandEventWatcher&) = delete;
+ WaylandEventWatcher& operator=(const WaylandEventWatcher&) = delete;
+ ~WaylandEventWatcher() override;
+
+ // Starts polling for events from the wayland connection file descriptor.
+ // This method assumes connection is already estabilished and input objects
+ // are already bound and properly initialized.
+ bool StartProcessingEvents();
+
+ // Stops polling for events from input devices.
+ bool StopProcessingEvents();
+
+ private:
+ // base::MessagePumpForUI::FdWatcher
+ void OnFileCanReadWithoutBlocking(int fd) override;
+ void OnFileCanWriteWithoutBlocking(int fd) override;
+
+ bool StartWatchingFd(base::WatchableIOMessagePumpPosix::Mode mode);
+ void MaybePrepareReadQueue();
+
+ base::MessagePumpForUI::FdWatchController controller_;
+
+ wl_display* const display_; // Owned by WaylandConnection.
+
+ bool watching_ = false;
+ bool prepared_ = false;
+};
+
+} // namespace ui
+
+#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_EVENT_WATCHER_H_
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context.cc b/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context.cc
index 81a75d4661a..d03e64f34a7 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context.cc
@@ -19,6 +19,7 @@
#include "ui/events/keycodes/keyboard_code_conversion_xkb.h"
#include "ui/events/ozone/layout/keyboard_layout_engine.h"
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
+#include "ui/events/types/event_type.h"
#include "ui/gfx/range/range.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/zwp_text_input_wrapper_v1.h"
@@ -34,13 +35,13 @@ constexpr int kXkbKeycodeOffset = 8;
WaylandInputMethodContext::WaylandInputMethodContext(
WaylandConnection* connection,
- LinuxInputMethodContextDelegate* delegate,
- bool is_simple,
- const EventDispatchCallback& callback)
+ WaylandKeyboard::Delegate* key_delegate,
+ LinuxInputMethodContextDelegate* ime_delegate,
+ bool is_simple)
: connection_(connection),
- delegate_(delegate),
+ key_delegate_(key_delegate),
+ ime_delegate_(ime_delegate),
is_simple_(is_simple),
- callback_(callback),
text_input_(nullptr) {
Init();
}
@@ -79,7 +80,7 @@ bool WaylandInputMethodContext::DispatchKeyEvent(
UpdatePreeditText(character_composer_.preedit_string());
auto composed = character_composer_.composed_character();
if (!composed.empty())
- delegate_->OnCommit(composed);
+ ime_delegate_->OnCommit(composed);
return true;
}
@@ -93,7 +94,7 @@ void WaylandInputMethodContext::UpdatePreeditText(
preedit.ime_text_spans.push_back(ImeTextSpan(
ImeTextSpan::Type::kComposition, 0, length, ImeTextSpan::Thickness::kThin,
ImeTextSpan::UnderlineStyle::kSolid, SK_ColorTRANSPARENT));
- delegate_->OnPreeditChanged(preedit);
+ ime_delegate_->OnPreeditChanged(preedit);
}
void WaylandInputMethodContext::Reset() {
@@ -144,22 +145,21 @@ void WaylandInputMethodContext::OnPreeditString(const std::string& text,
ui::CompositionText composition_text;
composition_text.text = base::UTF8ToUTF16(text);
composition_text.selection = selection_range;
- delegate_->OnPreeditChanged(composition_text);
+ ime_delegate_->OnPreeditChanged(composition_text);
}
void WaylandInputMethodContext::OnCommitString(const std::string& text) {
- delegate_->OnCommit(base::UTF8ToUTF16(text));
+ ime_delegate_->OnCommit(base::UTF8ToUTF16(text));
}
void WaylandInputMethodContext::OnDeleteSurroundingText(int32_t index,
uint32_t length) {
- delegate_->OnDeleteSurroundingText(index, length);
+ ime_delegate_->OnDeleteSurroundingText(index, length);
}
void WaylandInputMethodContext::OnKeysym(uint32_t key,
uint32_t state,
uint32_t modifiers) {
- uint8_t flags = 0; // for now ignore modifiers
DomKey dom_key = NonPrintableXKeySymToDomKey(key);
KeyboardCode key_code = NonPrintableDomKeyToKeyboardCode(dom_key);
DomCode dom_code =
@@ -167,10 +167,11 @@ void WaylandInputMethodContext::OnKeysym(uint32_t key,
if (dom_code == ui::DomCode::NONE)
return;
- bool down = state == WL_KEYBOARD_KEY_STATE_PRESSED;
- ui::KeyEvent event(down ? ET_KEY_PRESSED : ET_KEY_RELEASED, key_code,
- dom_code, flags, dom_key, EventTimeForNow());
- callback_.Run(&event);
+ // TODO(crbug.com/1079353): Handle modifiers.
+ EventType type =
+ state == WL_KEYBOARD_KEY_STATE_PRESSED ? ET_KEY_PRESSED : ET_KEY_RELEASED;
+ key_delegate_->OnKeyboardKeyEvent(type, dom_code, dom_key, key_code,
+ /*repeat=*/false, EventTimeForNow());
}
} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context.h b/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context.h
index 30268e235b3..6020ae716b8 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context.h
@@ -11,7 +11,7 @@
#include "base/macros.h"
#include "ui/base/ime/character_composer.h"
#include "ui/base/ime/linux/linux_input_method_context.h"
-#include "ui/events/ozone/evdev/event_dispatch_callback.h"
+#include "ui/ozone/platform/wayland/host/wayland_keyboard.h"
#include "ui/ozone/platform/wayland/host/zwp_text_input_wrapper.h"
namespace ui {
@@ -22,10 +22,12 @@ class ZWPTextInputWrapper;
class WaylandInputMethodContext : public LinuxInputMethodContext,
public ZWPTextInputWrapperClient {
public:
+ class Delegate;
+
WaylandInputMethodContext(WaylandConnection* connection,
- LinuxInputMethodContextDelegate* delegate,
- bool is_simple,
- const EventDispatchCallback& callback);
+ WaylandKeyboard::Delegate* key_delegate,
+ LinuxInputMethodContextDelegate* ime_delegate,
+ bool is_simple);
~WaylandInputMethodContext() override;
void Init(bool initialize_for_testing = false);
@@ -48,12 +50,14 @@ class WaylandInputMethodContext : public LinuxInputMethodContext,
private:
void UpdatePreeditText(const base::string16& preedit_text);
- WaylandConnection* connection_ = nullptr; // TODO(jani) Handle this better
+ WaylandConnection* const connection_; // TODO(jani) Handle this better
+
+ // Delegate key events to be injected into PlatformEvent system.
+ WaylandKeyboard::Delegate* const key_delegate_;
- // Delegate interface back to IME code in ui.
- LinuxInputMethodContextDelegate* delegate_;
+ // Delegate IME-specific events to be handled by //ui code.
+ LinuxInputMethodContextDelegate* const ime_delegate_;
bool is_simple_;
- EventDispatchCallback callback_;
std::unique_ptr<ZWPTextInputWrapper> text_input_;
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context_factory.cc b/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context_factory.cc
index 47424658348..d95b8430974 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context_factory.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context_factory.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
+#include "ui/ozone/platform/wayland/host/wayland_event_source.h"
#include "ui/ozone/platform/wayland/host/wayland_input_method_context.h"
namespace ui {
@@ -15,6 +16,7 @@ namespace ui {
WaylandInputMethodContextFactory::WaylandInputMethodContextFactory(
WaylandConnection* connection)
: connection_(connection) {
+ DCHECK(connection_);
}
WaylandInputMethodContextFactory::~WaylandInputMethodContextFactory() = default;
@@ -31,9 +33,7 @@ WaylandInputMethodContextFactory::CreateWaylandInputMethodContext(
LinuxInputMethodContextDelegate* delegate,
bool is_simple) const {
return std::make_unique<WaylandInputMethodContext>(
- connection_, delegate, is_simple,
- base::BindRepeating(&WaylandConnection::DispatchUiEvent,
- base::Unretained(connection_)));
+ connection_, connection_->event_source(), delegate, is_simple);
}
} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context_factory.h b/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context_factory.h
index c1c8711afe7..75a44e10523 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context_factory.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_input_method_context_factory.h
@@ -30,7 +30,7 @@ class WaylandInputMethodContextFactory : public LinuxInputMethodContextFactory {
bool is_simple) const;
private:
- WaylandConnection* connection_;
+ WaylandConnection* const connection_;
DISALLOW_COPY_AND_ASSIGN(WaylandInputMethodContextFactory);
};
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_keyboard.cc b/chromium/ui/ozone/platform/wayland/host/wayland_keyboard.cc
index 7da3270a9e3..0258d157776 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_keyboard.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_keyboard.cc
@@ -13,11 +13,13 @@
#include "ui/events/base_event_utils.h"
#include "ui/events/event.h"
#include "ui/events/keycodes/dom/dom_code.h"
+#include "ui/events/keycodes/dom/dom_key.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
-#include "ui/events/keycodes/keyboard_code_conversion.h"
+#include "ui/events/keycodes/keyboard_codes_posix.h"
#include "ui/events/ozone/evdev/keyboard_util_evdev.h"
#include "ui/events/ozone/layout/keyboard_layout_engine.h"
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
+#include "ui/events/types/event_type.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_window.h"
@@ -33,10 +35,12 @@ const wl_callback_listener WaylandKeyboard::callback_listener_ = {
};
WaylandKeyboard::WaylandKeyboard(wl_keyboard* keyboard,
+ WaylandConnection* connection,
KeyboardLayoutEngine* layout_engine,
- const EventDispatchCallback& callback)
+ Delegate* delegate)
: obj_(keyboard),
- callback_(callback),
+ connection_(connection),
+ delegate_(delegate),
auto_repeat_handler_(this),
#if BUILDFLAG(USE_XKBCOMMON)
layout_engine_(static_cast<XkbKeyboardLayoutEngine*>(layout_engine)) {
@@ -49,12 +53,16 @@ WaylandKeyboard::WaylandKeyboard(wl_keyboard* keyboard,
&WaylandKeyboard::Modifiers, &WaylandKeyboard::RepeatInfo,
};
- wl_keyboard_add_listener(obj_.get(), &listener, this);
+ DCHECK(delegate_);
+ delegate_->OnKeyboardCreated(this);
+ wl_keyboard_add_listener(obj_.get(), &listener, this);
// TODO(tonikitoo): Default auto-repeat to ON here?
}
-WaylandKeyboard::~WaylandKeyboard() {}
+WaylandKeyboard::~WaylandKeyboard() {
+ delegate_->OnKeyboardDestroyed(this);
+}
void WaylandKeyboard::Keymap(void* data,
wl_keyboard* obj,
@@ -87,8 +95,10 @@ void WaylandKeyboard::Enter(void* data,
wl_surface* surface,
wl_array* keys) {
// wl_surface might have been destroyed by this time.
- if (surface)
- WaylandWindow::FromSurface(surface)->set_keyboard_focus(true);
+ if (auto* window = WaylandWindow::FromSurface(surface)) {
+ auto* self = static_cast<WaylandKeyboard*>(data);
+ self->delegate_->OnKeyboardFocusChanged(window, /*focused=*/true);
+ }
}
void WaylandKeyboard::Leave(void* data,
@@ -96,14 +106,12 @@ void WaylandKeyboard::Leave(void* data,
uint32_t serial,
wl_surface* surface) {
// wl_surface might have been destroyed by this time.
- if (surface)
- WaylandWindow::FromSurface(surface)->set_keyboard_focus(false);
-
- WaylandKeyboard* keyboard = static_cast<WaylandKeyboard*>(data);
- DCHECK(keyboard);
+ auto* self = static_cast<WaylandKeyboard*>(data);
+ if (auto* window = WaylandWindow::FromSurface(surface))
+ self->delegate_->OnKeyboardFocusChanged(window, /*focused=*/false);
// Upon window focus lose, reset the key repeat timers.
- keyboard->auto_repeat_handler_.StopKeyRepeat();
+ self->auto_repeat_handler_.StopKeyRepeat();
}
void WaylandKeyboard::Key(void* data,
@@ -118,14 +126,14 @@ void WaylandKeyboard::Key(void* data,
keyboard->connection_->set_serial(serial);
bool down = state == WL_KEYBOARD_KEY_STATE_PRESSED;
- int device_id = keyboard->obj_.id();
+ int device_id = keyboard->device_id();
keyboard->auto_repeat_handler_.UpdateKeyRepeat(
- key, down, false /*suppress_auto_repeat*/, device_id);
+ key, 0 /*scan_code*/, down, false /*suppress_auto_repeat*/, device_id);
// TODO(tonikitoo,msisov): Handler 'repeat' parameter below.
- keyboard->DispatchKey(key, down, false /*repeat*/, EventTimeForNow(),
- device_id, EF_NONE);
+ keyboard->DispatchKey(key, 0 /*scan_code*/, down, false /*repeat*/,
+ EventTimeForNow(), device_id, EF_NONE);
}
void WaylandKeyboard::Modifiers(void* data,
@@ -139,8 +147,9 @@ void WaylandKeyboard::Modifiers(void* data,
WaylandKeyboard* keyboard = static_cast<WaylandKeyboard*>(data);
DCHECK(keyboard);
- keyboard->modifiers_ = keyboard->layout_engine_->UpdateModifiers(
- depressed, latched, locked, group);
+ int modifiers = keyboard->layout_engine_->UpdateModifiers(depressed, latched,
+ locked, group);
+ keyboard->delegate_->OnKeyboardModifiersChanged(modifiers);
#endif
}
@@ -171,6 +180,7 @@ void WaylandKeyboard::FlushInput(base::OnceClosure closure) {
}
void WaylandKeyboard::DispatchKey(uint32_t key,
+ uint32_t scan_code,
bool down,
bool repeat,
base::TimeTicks timestamp,
@@ -181,20 +191,20 @@ void WaylandKeyboard::DispatchKey(uint32_t key,
if (dom_code == ui::DomCode::NONE)
return;
- DomKey dom_key;
- KeyboardCode key_code;
- if (!layout_engine_->Lookup(dom_code, modifiers_, &dom_key, &key_code))
- return;
-
- if (!repeat) {
- int flag = ModifierDomKeyToEventFlag(dom_key);
- UpdateModifier(flag, down);
- }
+ // Pass empty DomKey and KeyboardCode here so the delegate can pre-process
+ // and decode it when needed.
+ delegate_->OnKeyboardKeyEvent(down ? ET_KEY_PRESSED : ET_KEY_RELEASED,
+ dom_code, DomKey::NONE,
+ KeyboardCode::VKEY_UNKNOWN, repeat, timestamp);
+}
- ui::KeyEvent event(down ? ET_KEY_PRESSED : ET_KEY_RELEASED, key_code,
- dom_code, modifiers_, dom_key, timestamp);
- event.set_source_device_id(device_id);
- callback_.Run(&event);
+bool WaylandKeyboard::Decode(DomCode dom_code,
+ int modifiers,
+ DomKey* out_dom_key,
+ KeyboardCode* out_key_code) {
+ DCHECK(out_dom_key);
+ DCHECK(out_key_code);
+ return layout_engine_->Lookup(dom_code, modifiers, out_dom_key, out_key_code);
}
void WaylandKeyboard::SyncCallback(void* data,
@@ -202,28 +212,9 @@ void WaylandKeyboard::SyncCallback(void* data,
uint32_t time) {
WaylandKeyboard* keyboard = static_cast<WaylandKeyboard*>(data);
DCHECK(keyboard);
-
+ DCHECK(keyboard->auto_repeat_closure_);
std::move(keyboard->auto_repeat_closure_).Run();
- DCHECK(keyboard->auto_repeat_closure_.is_null());
keyboard->sync_callback_.reset();
}
-void WaylandKeyboard::UpdateModifier(int modifier, bool down) {
- if (modifier == EF_NONE)
- return;
-
- // TODO(nickdiego): ChromeOS-specific keyboard remapping logic.
- // Remove this once it is properly guarded under OS_CHROMEOS.
- //
- // Currently EF_MOD3_DOWN means that the CapsLock key is currently down,
- // and EF_CAPS_LOCK_ON means the caps lock state is enabled (and the
- // key may or may not be down, but usually isn't). There does need to
- // to be two different flags, since the physical CapsLock key is subject
- // to remapping, but the caps lock state (which can be triggered in a
- // variety of ways) is not.
- if (modifier == EF_CAPS_LOCK_ON)
- modifier = (modifier & ~EF_CAPS_LOCK_ON) | EF_MOD3_DOWN;
- modifiers_ = down ? (modifiers_ | modifier) : (modifiers_ & ~modifier);
-}
-
} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_keyboard.h b/chromium/ui/ozone/platform/wayland/host/wayland_keyboard.h
index 497a95506b1..1630d8aa681 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_keyboard.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_keyboard.h
@@ -7,31 +7,39 @@
#include <wayland-client.h>
+#include "base/time/time.h"
#include "ui/base/buildflags.h"
-#include "ui/events/ozone/evdev/event_dispatch_callback.h"
+#include "ui/events/keycodes/dom/dom_code.h"
+#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/events/ozone/keyboard/event_auto_repeat_handler.h"
+#include "ui/events/types/event_type.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
namespace ui {
+class DomKey;
class KeyboardLayoutEngine;
+class WaylandConnection;
+class WaylandWindow;
#if BUILDFLAG(USE_XKBCOMMON)
class XkbKeyboardLayoutEngine;
#endif
-class WaylandConnection;
class WaylandKeyboard : public EventAutoRepeatHandler::Delegate {
public:
+ class Delegate;
+
WaylandKeyboard(wl_keyboard* keyboard,
+ WaylandConnection* connection,
KeyboardLayoutEngine* keyboard_layout_engine,
- const EventDispatchCallback& callback);
+ Delegate* delegate);
virtual ~WaylandKeyboard();
- void set_connection(WaylandConnection* connection) {
- connection_ = connection;
- }
-
- int modifiers() { return modifiers_; }
+ int device_id() const { return obj_.id(); }
+ bool Decode(DomCode dom_code,
+ int modifiers,
+ DomKey* out_dom_key,
+ KeyboardCode* out_key_code);
private:
// wl_keyboard_listener
@@ -69,21 +77,19 @@ class WaylandKeyboard : public EventAutoRepeatHandler::Delegate {
static void SyncCallback(void* data, struct wl_callback* cb, uint32_t time);
- void UpdateModifier(int modifier, bool down);
-
// EventAutoRepeatHandler::Delegate
void FlushInput(base::OnceClosure closure) override;
void DispatchKey(unsigned int key,
+ unsigned int scan_code,
bool down,
bool repeat,
base::TimeTicks timestamp,
int device_id,
int flags) override;
- WaylandConnection* connection_ = nullptr;
wl::Object<wl_keyboard> obj_;
- EventDispatchCallback callback_;
- int modifiers_ = 0;
+ WaylandConnection* const connection_;
+ Delegate* const delegate_;
// Key repeat handler.
static const wl_callback_listener callback_listener_;
@@ -98,6 +104,20 @@ class WaylandKeyboard : public EventAutoRepeatHandler::Delegate {
#endif
};
+class WaylandKeyboard::Delegate {
+ public:
+ virtual void OnKeyboardCreated(WaylandKeyboard* keyboard) = 0;
+ virtual void OnKeyboardDestroyed(WaylandKeyboard* keyboard) = 0;
+ virtual void OnKeyboardFocusChanged(WaylandWindow* window, bool focused) = 0;
+ virtual void OnKeyboardModifiersChanged(int modifiers) = 0;
+ virtual void OnKeyboardKeyEvent(EventType type,
+ DomCode dom_code,
+ DomKey dom_key,
+ KeyboardCode key_code,
+ bool repeat,
+ base::TimeTicks timestamp) = 0;
+};
+
} // namespace ui
#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_KEYBOARD_H_
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_pointer.cc b/chromium/ui/ozone/platform/wayland/host/wayland_pointer.cc
index c1620cedac0..8a2da9f409a 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_pointer.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_pointer.cc
@@ -5,11 +5,11 @@
#include "ui/ozone/platform/wayland/host/wayland_pointer.h"
#include <linux/input.h>
+#include <wayland-client-protocol.h>
#include <wayland-client.h>
-#include <memory>
-#include "ui/events/base_event_utils.h"
#include "ui/events/event.h"
+#include "ui/events/types/event_type.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_window.h"
@@ -17,39 +17,23 @@
namespace ui {
-namespace {
-
-bool VerifyFlagsAfterMasking(int flags, int original_flags, int modifiers) {
- flags &= ~modifiers;
- return flags == original_flags;
-}
-
-bool HasAnyButtonFlag(int flags) {
- return (flags & (EF_LEFT_MOUSE_BUTTON | EF_MIDDLE_MOUSE_BUTTON |
- EF_RIGHT_MOUSE_BUTTON | EF_BACK_MOUSE_BUTTON |
- EF_FORWARD_MOUSE_BUTTON)) != 0;
-}
-
-} // namespace
-
WaylandPointer::WaylandPointer(wl_pointer* pointer,
- const EventDispatchCallback& callback)
- : obj_(pointer), callback_(callback), weak_ptr_factory_(this) {
+ WaylandConnection* connection,
+ Delegate* delegate)
+ : obj_(pointer), connection_(connection), delegate_(delegate) {
static const wl_pointer_listener listener = {
&WaylandPointer::Enter, &WaylandPointer::Leave, &WaylandPointer::Motion,
&WaylandPointer::Button, &WaylandPointer::Axis,
};
- wl_pointer_add_listener(obj_.get(), &listener, this);
+ DCHECK(delegate_);
+ delegate_->OnPointerCreated(this);
- cursor_ = std::make_unique<WaylandCursor>();
+ wl_pointer_add_listener(obj_.get(), &listener, this);
}
WaylandPointer::~WaylandPointer() {
- if (window_with_pointer_focus_) {
- window_with_pointer_focus_->SetPointerFocus(false);
- window_with_pointer_focus_->set_has_implicit_grab(false);
- }
+ delegate_->OnPointerDestroyed(this);
}
// static
@@ -59,13 +43,12 @@ void WaylandPointer::Enter(void* data,
wl_surface* surface,
wl_fixed_t surface_x,
wl_fixed_t surface_y) {
+ DCHECK(data);
WaylandPointer* pointer = static_cast<WaylandPointer*>(data);
- pointer->location_.SetPoint(wl_fixed_to_double(surface_x),
- wl_fixed_to_double(surface_y));
- pointer->FocusWindow(surface);
- MouseEvent event(ET_MOUSE_ENTERED, pointer->location_, pointer->location_,
- EventTimeForNow(), pointer->flags_, 0);
- pointer->callback_.Run(&event);
+ gfx::PointF location(wl_fixed_to_double(surface_x),
+ wl_fixed_to_double(surface_y));
+ pointer->delegate_->OnPointerFocusChanged(WaylandWindow::FromSurface(surface),
+ /*focused=*/true, location);
}
// static
@@ -73,11 +56,10 @@ void WaylandPointer::Leave(void* data,
wl_pointer* obj,
uint32_t serial,
wl_surface* surface) {
+ DCHECK(data);
WaylandPointer* pointer = static_cast<WaylandPointer*>(data);
- MouseEvent event(ET_MOUSE_EXITED, gfx::Point(), gfx::Point(),
- EventTimeForNow(), pointer->flags_, 0);
- pointer->callback_.Run(&event);
- pointer->UnfocusWindow(surface);
+ pointer->delegate_->OnPointerFocusChanged(WaylandWindow::FromSurface(surface),
+ /*focused=*/false, {});
}
// static
@@ -87,14 +69,9 @@ void WaylandPointer::Motion(void* data,
wl_fixed_t surface_x,
wl_fixed_t surface_y) {
WaylandPointer* pointer = static_cast<WaylandPointer*>(data);
- pointer->location_.SetPoint(wl_fixed_to_double(surface_x),
- wl_fixed_to_double(surface_y));
- MouseEvent event(ET_MOUSE_MOVED, gfx::Point(), gfx::Point(),
- EventTimeForNow(), pointer->GetFlagsWithKeyboardModifiers(),
- 0);
- event.set_location_f(pointer->location_);
- event.set_root_location_f(pointer->location_);
- pointer->callback_.Run(&event);
+ gfx::PointF location(wl_fixed_to_double(surface_x),
+ wl_fixed_to_double(surface_y));
+ pointer->delegate_->OnPointerMotionEvent(location);
}
// static
@@ -128,37 +105,15 @@ void WaylandPointer::Button(void* data,
return;
}
- EventType type;
- if (state == WL_POINTER_BUTTON_STATE_PRESSED) {
- type = ET_MOUSE_PRESSED;
- pointer->flags_ |= changed_button;
+ // Set serial only on button presses. Popup windows can be created on
+ // button/touch presses, and, thus, require the serial of the last serial when
+ // the button was pressed. Otherwise, Wayland server dismisses the popup
+ // requests (see the protocol definition).
+ if (state == WL_POINTER_BUTTON_STATE_PRESSED)
pointer->connection_->set_serial(serial);
- } else {
- type = ET_MOUSE_RELEASED;
- pointer->flags_ &= ~changed_button;
- }
-
- // See comment bellow.
- if (type == ET_MOUSE_PRESSED)
- pointer->MaybeSetOrResetImplicitGrab();
-
- // MouseEvent's flags should contain the button that was released too.
- const int flags = pointer->GetFlagsWithKeyboardModifiers() | changed_button;
- MouseEvent event(type, gfx::Point(), gfx::Point(), EventTimeForNow(), flags,
- changed_button);
- event.set_location_f(pointer->location_);
- event.set_root_location_f(pointer->location_);
-
- auto weak_ptr = pointer->weak_ptr_factory_.GetWeakPtr();
- pointer->callback_.Run(&event);
-
- // Reset implicit grab only after the event has been sent. Otherwise,
- // we may end up in a situation, when a target checks for a pointer grab on
- // the MouseRelease event type, and fails to release capture due to early
- // pointer focus reset. Setting implicit grab is done normally before the
- // event has been sent.
- if (weak_ptr && type == ET_MOUSE_RELEASED)
- pointer->MaybeSetOrResetImplicitGrab();
+ EventType type = state == WL_POINTER_BUTTON_STATE_PRESSED ? ET_MOUSE_PRESSED
+ : ET_MOUSE_RELEASED;
+ pointer->delegate_->OnPointerButtonEvent(type, changed_button);
}
// static
@@ -175,61 +130,16 @@ void WaylandPointer::Axis(void* data,
// clients (e.g. GTK+) typically scale down by this amount to convert to
// discrete step coordinates. wl_pointer version 5 improves the situation by
// adding axis sources and discrete axis events.
- if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL)
+ if (axis == WL_POINTER_AXIS_VERTICAL_SCROLL) {
offset.set_y(-wl_fixed_to_double(value) / kAxisValueScale *
MouseWheelEvent::kWheelDelta);
- else if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL)
+ } else if (axis == WL_POINTER_AXIS_HORIZONTAL_SCROLL) {
offset.set_x(wl_fixed_to_double(value) / kAxisValueScale *
MouseWheelEvent::kWheelDelta);
- else
- return;
- MouseWheelEvent event(offset, gfx::Point(), gfx::Point(), EventTimeForNow(),
- pointer->GetFlagsWithKeyboardModifiers(), 0);
- event.set_location_f(pointer->location_);
- event.set_root_location_f(pointer->location_);
- pointer->callback_.Run(&event);
-}
-
-void WaylandPointer::MaybeSetOrResetImplicitGrab() {
- if (!window_with_pointer_focus_)
+ } else {
return;
-
- window_with_pointer_focus_->set_has_implicit_grab(HasAnyButtonFlag(flags_));
-}
-
-int WaylandPointer::GetFlagsWithKeyboardModifiers() {
- assert(sizeof(flags_) == sizeof(keyboard_modifiers_));
-
- // Remove old modifiers from flags and then update them with new modifiers.
- flags_ &= ~keyboard_modifiers_;
- keyboard_modifiers_ = connection_->GetKeyboardModifiers();
-
- int old_flags = flags_;
- flags_ |= keyboard_modifiers_;
- DCHECK(VerifyFlagsAfterMasking(flags_, old_flags, keyboard_modifiers_));
- return flags_;
-}
-
-void WaylandPointer::ResetFlags() {
- flags_ = 0;
- keyboard_modifiers_ = 0;
-}
-
-void WaylandPointer::FocusWindow(wl_surface* surface) {
- if (surface) {
- WaylandWindow* window = WaylandWindow::FromSurface(surface);
- window->SetPointerFocus(true);
- window_with_pointer_focus_ = window;
- }
-}
-
-void WaylandPointer::UnfocusWindow(wl_surface* surface) {
- if (surface) {
- WaylandWindow* window = WaylandWindow::FromSurface(surface);
- window->SetPointerFocus(false);
- window->set_has_implicit_grab(false);
- window_with_pointer_focus_ = nullptr;
}
+ pointer->delegate_->OnPointerAxisEvent(offset);
}
} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_pointer.h b/chromium/ui/ozone/platform/wayland/host/wayland_pointer.h
index bf51fed7919..c4c9ecfbc35 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_pointer.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_pointer.h
@@ -5,41 +5,32 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_POINTER_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_POINTER_H_
-#include <memory>
-
#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "ui/events/ozone/evdev/event_dispatch_callback.h"
-#include "ui/gfx/geometry/point_f.h"
+#include "ui/events/types/event_type.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
-#include "ui/ozone/platform/wayland/host/wayland_cursor.h"
+
+namespace gfx {
+class PointF;
+class Vector2d;
+} // namespace gfx
namespace ui {
+class WaylandConnection;
class WaylandWindow;
-// Wraps the wl_pointer object and transmits events to the dispatcher callback.
-//
-// Exposes an aggregated WaylandCursor that manages the visual shape of the
-// pointer.
+// Wraps the wl_pointer object and injects event data through
+// |WaylandPointer::Delegate| interface.
class WaylandPointer {
public:
- WaylandPointer(wl_pointer* pointer, const EventDispatchCallback& callback);
- virtual ~WaylandPointer();
-
- void set_connection(WaylandConnection* connection) {
- connection_ = connection;
- cursor_->Init(obj_.get(), connection_);
- }
+ class Delegate;
- int GetFlagsWithKeyboardModifiers();
- void ResetFlags();
-
- WaylandCursor* cursor() { return cursor_.get(); }
+ WaylandPointer(wl_pointer* pointer,
+ WaylandConnection* connection,
+ Delegate* delegate);
+ virtual ~WaylandPointer();
- void reset_window_with_pointer_focus() {
- window_with_pointer_focus_ = nullptr;
- }
+ wl_pointer* wl_object() const { return obj_.get(); }
private:
// wl_pointer_listener
@@ -70,31 +61,25 @@ class WaylandPointer {
uint32_t axis,
wl_fixed_t value);
- void MaybeSetOrResetImplicitGrab();
- void FocusWindow(wl_surface* surface);
- void UnfocusWindow(wl_surface* surface);
-
- WaylandConnection* connection_ = nullptr;
- std::unique_ptr<WaylandCursor> cursor_;
wl::Object<wl_pointer> obj_;
- EventDispatchCallback callback_;
- gfx::PointF location_;
- // Flags is a bitmask of EventFlags corresponding to the pointer/keyboard
- // state.
- int flags_ = 0;
-
- // Keeps track of current modifiers. These are needed in order to properly
- // update |flags_| with newest modifiers.
- int keyboard_modifiers_ = 0;
-
- // The window the mouse is over.
- WaylandWindow* window_with_pointer_focus_ = nullptr;
-
- base::WeakPtrFactory<WaylandPointer> weak_ptr_factory_;
+ WaylandConnection* const connection_;
+ Delegate* const delegate_;
DISALLOW_COPY_AND_ASSIGN(WaylandPointer);
};
+class WaylandPointer::Delegate {
+ public:
+ virtual void OnPointerCreated(WaylandPointer* pointer) = 0;
+ virtual void OnPointerDestroyed(WaylandPointer* pointer) = 0;
+ virtual void OnPointerFocusChanged(WaylandWindow* window,
+ bool focused,
+ const gfx::PointF& location) = 0;
+ virtual void OnPointerButtonEvent(EventType evtype, int changed_button) = 0;
+ virtual void OnPointerMotionEvent(const gfx::PointF& location) = 0;
+ virtual void OnPointerAxisEvent(const gfx::Vector2d& offset) = 0;
+};
+
} // namespace ui
#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_POINTER_H_
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_pointer_unittest.cc b/chromium/ui/ozone/platform/wayland/host/wayland_pointer_unittest.cc
index b96f2e6f73f..f20ee54c250 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_pointer_unittest.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_pointer_unittest.cc
@@ -155,114 +155,6 @@ TEST_P(WaylandPointerTest, MotionDragged) {
EXPECT_EQ(gfx::PointF(400, 500), mouse_event->root_location_f());
}
-TEST_P(WaylandPointerTest, ButtonPressAndCheckCapture) {
- wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(),
- wl_fixed_from_int(200), wl_fixed_from_int(150));
- Sync();
-
- wl_pointer_send_button(pointer_->resource(), 2, 1002, BTN_RIGHT,
- WL_POINTER_BUTTON_STATE_PRESSED);
- std::unique_ptr<Event> right_press_event;
- // By the time ET_MOUSE_PRESSED event comes, WaylandWindow must have capture
- // set.
- EXPECT_CALL(delegate_, DispatchEvent(_))
- .WillOnce(
- CloneEventAndCheckCapture(window_.get(), true, &right_press_event));
-
- Sync();
- ASSERT_TRUE(right_press_event);
- ASSERT_TRUE(right_press_event->IsMouseEvent());
- auto* right_press_mouse_event = right_press_event->AsMouseEvent();
- EXPECT_EQ(ET_MOUSE_PRESSED, right_press_mouse_event->type());
- EXPECT_EQ(EF_RIGHT_MOUSE_BUTTON, right_press_mouse_event->button_flags());
- EXPECT_EQ(EF_RIGHT_MOUSE_BUTTON,
- right_press_mouse_event->changed_button_flags());
-
- std::unique_ptr<Event> left_press_event;
- // Ensure capture is still set before DispatchEvent returns.
- EXPECT_CALL(delegate_, DispatchEvent(_))
- .WillOnce(
- CloneEventAndCheckCapture(window_.get(), true, &left_press_event));
- wl_pointer_send_button(pointer_->resource(), 3, 1003, BTN_LEFT,
- WL_POINTER_BUTTON_STATE_PRESSED);
-
- Sync();
-
- // Ensure capture is still set after DispatchEvent returns.
- ASSERT_TRUE(window_->HasCapture());
-
- ASSERT_TRUE(left_press_event);
- ASSERT_TRUE(left_press_event->IsMouseEvent());
- auto* left_press_mouse_event = left_press_event->AsMouseEvent();
- EXPECT_EQ(ET_MOUSE_PRESSED, left_press_mouse_event->type());
- EXPECT_EQ(EF_LEFT_MOUSE_BUTTON | EF_RIGHT_MOUSE_BUTTON,
- left_press_mouse_event->button_flags());
- EXPECT_EQ(EF_LEFT_MOUSE_BUTTON,
- left_press_mouse_event->changed_button_flags());
- EXPECT_EQ(EF_LEFT_MOUSE_BUTTON,
- left_press_mouse_event->changed_button_flags());
- EXPECT_EQ(gfx::PointF(200, 150), left_press_mouse_event->location_f());
- EXPECT_EQ(gfx::PointF(200, 150), left_press_mouse_event->root_location_f());
-}
-
-TEST_P(WaylandPointerTest, ButtonReleaseAndCheckCapture) {
- wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(),
- wl_fixed_from_int(50), wl_fixed_from_int(50));
- wl_pointer_send_button(pointer_->resource(), 2, 1002, BTN_BACK,
- WL_POINTER_BUTTON_STATE_PRESSED);
- wl_pointer_send_button(pointer_->resource(), 3, 1003, BTN_LEFT,
- WL_POINTER_BUTTON_STATE_PRESSED);
-
- Sync();
-
- std::unique_ptr<Event> event;
- // Ensure capture is set before DispatchEvent returns.
- EXPECT_CALL(delegate_, DispatchEvent(_))
- .WillOnce(CloneEventAndCheckCapture(window_.get(), true, &event));
- wl_pointer_send_button(pointer_->resource(), 4, 1004, BTN_LEFT,
- WL_POINTER_BUTTON_STATE_RELEASED);
-
- Sync();
-
- ASSERT_TRUE(event);
- ASSERT_TRUE(event->IsMouseEvent());
- auto* mouse_event = event->AsMouseEvent();
- EXPECT_EQ(ET_MOUSE_RELEASED, mouse_event->type());
- EXPECT_EQ(EF_LEFT_MOUSE_BUTTON | EF_BACK_MOUSE_BUTTON,
- mouse_event->button_flags());
- EXPECT_EQ(EF_LEFT_MOUSE_BUTTON, mouse_event->changed_button_flags());
- EXPECT_EQ(gfx::PointF(50, 50), mouse_event->location_f());
- EXPECT_EQ(gfx::PointF(50, 50), mouse_event->root_location_f());
-
- // Ensure capture is still set after DispatchEvent returns.
- ASSERT_TRUE(window_->HasCapture());
-
- mouse_event = nullptr;
- event.reset();
- // Ensure capture has not been reset before DispatchEvent returns, otherwise
- // the code on top of Ozone (aura and etc), might get a wrong result, when
- // calling HasCapture. If it is false, it can lead to mouse pressed handlers
- // to be never released.
- EXPECT_CALL(delegate_, DispatchEvent(_))
- .WillOnce(CloneEventAndCheckCapture(window_.get(), true, &event));
- wl_pointer_send_button(pointer_->resource(), 5, 1005, BTN_BACK,
- WL_POINTER_BUTTON_STATE_RELEASED);
-
- Sync();
-
- ASSERT_TRUE(event);
- ASSERT_TRUE(event->IsMouseEvent());
- mouse_event = event->AsMouseEvent();
- EXPECT_EQ(ET_MOUSE_RELEASED, mouse_event->type());
- EXPECT_EQ(EF_BACK_MOUSE_BUTTON, mouse_event->button_flags());
- EXPECT_EQ(EF_BACK_MOUSE_BUTTON, mouse_event->changed_button_flags());
- EXPECT_EQ(gfx::PointF(50, 50), mouse_event->location_f());
- EXPECT_EQ(gfx::PointF(50, 50), mouse_event->root_location_f());
-
- // It is safe to release capture now.
- ASSERT_TRUE(!window_->HasCapture());
-}
-
TEST_P(WaylandPointerTest, AxisVertical) {
wl_pointer_send_enter(pointer_->resource(), 1, surface_->resource(),
wl_fixed_from_int(0), wl_fixed_from_int(0));
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_popup.cc b/chromium/ui/ozone/platform/wayland/host/wayland_popup.cc
index dd9e6c268ab..116c7be47d1 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_popup.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_popup.cc
@@ -41,8 +41,6 @@ void WaylandPopup::Show(bool inactive) {
if (shell_popup_)
return;
- set_keyboard_focus(true);
-
if (!CreateShellPopup()) {
Close();
return;
@@ -73,11 +71,6 @@ bool WaylandPopup::IsVisible() const {
return !!shell_popup_;
}
-bool WaylandPopup::HasCapture() const {
- // WaylandPopups always have captures.
- return shell_popup();
-}
-
void WaylandPopup::HandlePopupConfigure(const gfx::Rect& bounds_dip) {
DCHECK(shell_popup());
DCHECK(parent_window());
@@ -165,37 +158,6 @@ gfx::Rect WaylandPopup::AdjustPopupWindowPosition() {
gfx::Rect new_bounds_dip = wl::TranslateBoundsToParentCoordinates(
gfx::ScaleToRoundedRect(GetBounds(), 1.0 / ui_scale()),
parent_bounds_dip);
-
- // Chromium may decide to position nested menu windows on the left side
- // instead of the right side of parent menu windows when the size of the
- // window becomes larger than the display it is shown on. It's correct when
- // the window is located on one display and occupies the whole work area, but
- // as soon as it's moved and there is space on the right side, Chromium
- // continues positioning the nested menus on the left side relative to the
- // parent menu (Wayland does not provide clients with global coordinates).
- // Instead, reposition that window to be on the right side of the parent menu
- // window and let the compositor decide how to position it if it does not fit
- // a single display. However, there is one exception - if the window is
- // maximized, let Chromium position it on the left side as long as the Wayland
- // compositor may decide to position the nested window on the right side of
- // the parent menu window, which results in showing it on a second display if
- // more than one display is used.
- if (wl::IsMenuType(parent_window()->type()) &&
- parent_window()->parent_window() &&
- (parent_window()->parent_window()->GetPlatformWindowState() !=
- PlatformWindowState::kMaximized)) {
- auto* top_level_window = parent_window()->parent_window();
- DCHECK(top_level_window && !wl::IsMenuType(top_level_window->type()));
- if (new_bounds_dip.x() <= 0 && top_level_window->GetPlatformWindowState() !=
- PlatformWindowState::kMaximized) {
- // Position the child menu window on the right side of the parent window
- // and let the Wayland compositor decide how to do constraint
- // adjustments.
- int new_x = parent_bounds_dip.width() -
- (new_bounds_dip.width() + new_bounds_dip.x());
- new_bounds_dip.set_x(new_x);
- }
- }
return gfx::ScaleToRoundedRect(new_bounds_dip, ui_scale() / buffer_scale());
}
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_popup.h b/chromium/ui/ozone/platform/wayland/host/wayland_popup.h
index 7bc48bb29a0..a5810317d86 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_popup.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_popup.h
@@ -23,7 +23,6 @@ class WaylandPopup : public WaylandWindow {
void Show(bool inactive) override;
void Hide() override;
bool IsVisible() const override;
- bool HasCapture() const override;
private:
// WaylandWindow overrides:
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_screen.cc b/chromium/ui/ozone/platform/wayland/host/wayland_screen.cc
index 126b252624a..81af6275b27 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_screen.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_screen.cc
@@ -4,11 +4,15 @@
#include "ui/ozone/platform/wayland/host/wayland_screen.h"
+#include <set>
+#include <vector>
+
+#include "base/stl_util.h"
#include "ui/display/display.h"
#include "ui/display/display_finder.h"
#include "ui/display/display_observer.h"
#include "ui/gfx/geometry/point.h"
-#include "ui/gfx/geometry/size.h"
+#include "ui/gfx/native_widget_types.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_cursor_position.h"
#include "ui/ozone/platform/wayland/host/wayland_window.h"
@@ -140,7 +144,6 @@ display::Display WaylandScreen::GetDisplayForAcceleratedWidget(
}
gfx::Point WaylandScreen::GetCursorScreenPoint() const {
- auto* wayland_window_manager = connection_->wayland_window_manager();
// Wayland does not provide either location of surfaces in global space
// coordinate system or location of a pointer. Instead, only locations of
// mouse/touch events are known. Given that Chromium assumes top-level windows
@@ -151,10 +154,12 @@ gfx::Point WaylandScreen::GetCursorScreenPoint() const {
// last known cursor position. Otherwise, return such a point, which is not
// contained by any of the windows.
auto* cursor_position = connection_->wayland_cursor_position();
- if (wayland_window_manager->GetCurrentFocusedWindow() && cursor_position)
+ if (connection_->wayland_window_manager()->GetCurrentFocusedWindow() &&
+ cursor_position)
return cursor_position->GetCursorSurfacePoint();
- auto* window = wayland_window_manager->GetWindowWithLargestBounds();
+ auto* window =
+ connection_->wayland_window_manager()->GetWindowWithLargestBounds();
DCHECK(window);
const gfx::Rect bounds = window->GetBounds();
return gfx::Point(bounds.width() + 10, bounds.height() + 10);
@@ -171,6 +176,14 @@ gfx::AcceleratedWidget WaylandScreen::GetAcceleratedWidgetAtScreenPoint(
return gfx::kNullAcceleratedWidget;
}
+gfx::AcceleratedWidget WaylandScreen::GetLocalProcessWidgetAtPoint(
+ const gfx::Point& point,
+ const std::set<gfx::AcceleratedWidget>& ignore) const {
+ auto widget = GetAcceleratedWidgetAtScreenPoint(point);
+ return !widget || base::Contains(ignore, widget) ? gfx::kNullAcceleratedWidget
+ : widget;
+}
+
display::Display WaylandScreen::GetDisplayNearestPoint(
const gfx::Point& point) const {
return *FindDisplayNearestPoint(display_list_.displays(), point);
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_screen.h b/chromium/ui/ozone/platform/wayland/host/wayland_screen.h
index c81b47a3ecd..8d65dd8130e 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_screen.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_screen.h
@@ -5,14 +5,13 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_SCREEN_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_SCREEN_H_
+#include <set>
#include <vector>
-#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
#include "ui/display/display_list.h"
-#include "ui/ozone/platform/wayland/host/wayland_output.h"
-#include "ui/ozone/public/ozone_platform.h"
+#include "ui/gfx/geometry/point.h"
#include "ui/ozone/public/platform_screen.h"
namespace ui {
@@ -23,6 +22,8 @@ class WaylandConnection;
class WaylandScreen : public PlatformScreen {
public:
explicit WaylandScreen(WaylandConnection* connection);
+ WaylandScreen(const WaylandScreen&) = delete;
+ WaylandScreen& operator=(const WaylandScreen&) = delete;
~WaylandScreen() override;
void OnOutputAdded(uint32_t output_id);
@@ -33,7 +34,7 @@ class WaylandScreen : public PlatformScreen {
base::WeakPtr<WaylandScreen> GetWeakPtr();
- // display::Screen implementation.
+ // PlatformScreen overrides:
const std::vector<display::Display>& GetAllDisplays() const override;
display::Display GetPrimaryDisplay() const override;
display::Display GetDisplayForAcceleratedWidget(
@@ -41,6 +42,9 @@ class WaylandScreen : public PlatformScreen {
gfx::Point GetCursorScreenPoint() const override;
gfx::AcceleratedWidget GetAcceleratedWidgetAtScreenPoint(
const gfx::Point& point) const override;
+ gfx::AcceleratedWidget GetLocalProcessWidgetAtPoint(
+ const gfx::Point& point,
+ const std::set<gfx::AcceleratedWidget>& ignore) const override;
display::Display GetDisplayNearestPoint(
const gfx::Point& point) const override;
display::Display GetDisplayMatching(
@@ -56,8 +60,6 @@ class WaylandScreen : public PlatformScreen {
base::ObserverList<display::DisplayObserver> observers_;
base::WeakPtrFactory<WaylandScreen> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(WaylandScreen);
};
} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc b/chromium/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc
index 9198aa88e05..899fff6445a 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_screen_unittest.cc
@@ -10,6 +10,7 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/display/display_observer.h"
#include "ui/display/display_switches.h"
+#include "ui/gfx/native_widget_types.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_output_manager.h"
#include "ui/ozone/platform/wayland/host/wayland_screen.h"
@@ -292,6 +293,28 @@ TEST_P(WaylandScreenTest, GetAcceleratedWidgetAtScreenPoint) {
window_->SetPointerFocus(false);
}
+TEST_P(WaylandScreenTest, GetLocalProcessWidgetAtPoint) {
+ gfx::Point point(10, 10);
+ EXPECT_EQ(platform_screen_->GetLocalProcessWidgetAtPoint(point, {}),
+ gfx::kNullAcceleratedWidget);
+
+ // Set a focus to the main window. Now, that focused window must be returned.
+ window_->SetPointerFocus(true);
+ EXPECT_EQ(platform_screen_->GetLocalProcessWidgetAtPoint(point, {}),
+ window_->GetWidget());
+
+ // Null widget must be returned when the focused window is part of the
+ // |ignore| list.
+ gfx::AcceleratedWidget w = window_->GetWidget();
+ EXPECT_EQ(
+ platform_screen_->GetLocalProcessWidgetAtPoint(point, {w - 1, w, w + 1}),
+ gfx::kNullAcceleratedWidget);
+
+ // Reset the focus to avoid crash on dtor as long as there is no real pointer
+ // object.
+ window_->SetPointerFocus(false);
+}
+
TEST_P(WaylandScreenTest, GetDisplayMatching) {
TestDisplayObserver observer;
platform_screen_->AddObserver(&observer);
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_surface.cc b/chromium/ui/ozone/platform/wayland/host/wayland_surface.cc
index bc45f677a75..6f72776d0d3 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_surface.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_surface.cc
@@ -12,6 +12,7 @@
#include "ui/ozone/platform/wayland/host/shell_surface_wrapper.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
+#include "ui/ozone/platform/wayland/host/wayland_event_source.h"
#include "ui/platform_window/platform_window_handler/wm_drop_handler.h"
namespace ui {
@@ -66,7 +67,7 @@ void WaylandSurface::DispatchHostWindowDragMovement(
const gfx::Point& pointer_location_in_px) {
DCHECK(shell_surface_);
- connection()->ResetPointerFlags();
+ connection()->event_source()->ResetPointerFlags();
if (hittest == HTCAPTION)
shell_surface_->SurfaceMove(connection());
else
@@ -93,7 +94,6 @@ void WaylandSurface::Show(bool inactive) {
return;
}
- set_keyboard_focus(true);
UpdateBufferScale(false);
}
@@ -286,7 +286,7 @@ void WaylandSurface::OnDragLeave() {
void WaylandSurface::OnDragSessionClose(uint32_t dnd_action) {
std::move(drag_closed_callback_).Run(dnd_action);
- connection()->ResetPointerFlags();
+ connection()->event_source()->ResetPointerFlags();
}
bool WaylandSurface::OnInitialize(PlatformWindowInitProperties properties) {
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_touch.cc b/chromium/ui/ozone/platform/wayland/host/wayland_touch.cc
index a3d0b25826a..aff5c24befa 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_touch.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_touch.cc
@@ -4,71 +4,32 @@
#include "ui/ozone/platform/wayland/host/wayland_touch.h"
-#include <sys/mman.h>
#include <wayland-client.h>
-#include "base/files/scoped_file.h"
-#include "ui/base/buildflags.h"
-#include "ui/events/event.h"
+#include "base/time/time.h"
+#include "ui/gfx/geometry/point_f.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_window.h"
-#include "ui/ozone/platform/wayland/host/wayland_window_manager.h"
namespace ui {
-WaylandTouch::TouchPoint::TouchPoint() = default;
-
-WaylandTouch::TouchPoint::TouchPoint(gfx::Point location,
- wl_surface* current_surface)
- : surface(current_surface), last_known_location(location) {}
-
-WaylandTouch::TouchPoint::~TouchPoint() = default;
-
-//-----------------------------------------------------------------------------
-
WaylandTouch::WaylandTouch(wl_touch* touch,
- const EventDispatchCallback& callback)
- : obj_(touch), callback_(callback) {
+ WaylandConnection* connection,
+ Delegate* delegate)
+ : obj_(touch), connection_(connection), delegate_(delegate) {
static const wl_touch_listener listener = {
&WaylandTouch::Down, &WaylandTouch::Up, &WaylandTouch::Motion,
&WaylandTouch::Frame, &WaylandTouch::Cancel,
};
+ DCHECK(delegate_);
+ delegate_->OnTouchCreated(this);
+
wl_touch_add_listener(obj_.get(), &listener, this);
}
WaylandTouch::~WaylandTouch() {
- DCHECK(current_points_.empty());
-}
-
-void WaylandTouch::SetConnection(WaylandConnection* connection) {
- connection_ = connection;
-
- // Observs remove changes to know when touch points can be removed.
- connection_->wayland_window_manager()->AddObserver(this);
-}
-
-void WaylandTouch::RemoveTouchPoints(const WaylandWindow* window) {
- base::EraseIf(current_points_,
- [window](const TouchPoints::value_type& point) {
- return point.second.surface == window->surface();
- });
-}
-
-void WaylandTouch::MaybeUnsetFocus(const WaylandTouch::TouchPoints& points,
- int32_t id,
- wl_surface* surface) {
- for (const auto& point : points) {
- // Return early on the first other point having this surface.
- if (surface == point.second.surface && id != point.first)
- return;
- }
- DCHECK(surface);
- WaylandWindow::FromSurface(surface)->set_touch_focus(false);
-}
-
-void WaylandTouch::OnWindowRemoved(WaylandWindow* window) {
- RemoveTouchPoints(window);
+ delegate_->OnTouchDestroyed(this);
}
void WaylandTouch::Down(void* data,
@@ -81,26 +42,16 @@ void WaylandTouch::Down(void* data,
wl_fixed_t y) {
if (!surface)
return;
+
WaylandTouch* touch = static_cast<WaylandTouch*>(data);
DCHECK(touch);
touch->connection_->set_serial(serial);
- WaylandWindow::FromSurface(surface)->set_touch_focus(true);
-
- // Make sure this touch point wasn't present before.
- if (touch->current_points_.find(id) != touch->current_points_.end()) {
- LOG(WARNING) << "Touch down fired with wrong id";
- return;
- }
- EventType type = ET_TOUCH_PRESSED;
- gfx::Point location(wl_fixed_to_double(x), wl_fixed_to_double(y));
- base::TimeTicks time_stamp =
+ WaylandWindow* window = WaylandWindow::FromSurface(surface);
+ gfx::PointF location(wl_fixed_to_double(x), wl_fixed_to_double(y));
+ base::TimeTicks timestamp =
base::TimeTicks() + base::TimeDelta::FromMilliseconds(time);
- PointerDetails pointer_details(EventPointerType::POINTER_TYPE_TOUCH, id);
- TouchEvent event(type, location, time_stamp, pointer_details);
- touch->callback_.Run(&event);
-
- touch->current_points_[id] = TouchPoint(location, surface);
+ touch->delegate_->OnTouchPressEvent(window, location, timestamp, id);
}
void WaylandTouch::Up(void* data,
@@ -110,25 +61,14 @@ void WaylandTouch::Up(void* data,
int32_t id) {
WaylandTouch* touch = static_cast<WaylandTouch*>(data);
DCHECK(touch);
- const auto iterator = touch->current_points_.find(id);
- // Make sure this touch point was present before.
- if (iterator == touch->current_points_.end()) {
- LOG(WARNING) << "Touch up fired with no matching touch down";
- return;
- }
-
- EventType type = ET_TOUCH_RELEASED;
- base::TimeTicks time_stamp =
+ base::TimeTicks timestamp =
base::TimeTicks() + base::TimeDelta::FromMilliseconds(time);
- PointerDetails pointer_details(EventPointerType::POINTER_TYPE_TOUCH, id);
- TouchEvent event(type, touch->current_points_[id].last_known_location,
- time_stamp, pointer_details);
- touch->callback_.Run(&event);
-
- touch->MaybeUnsetFocus(touch->current_points_, id,
- touch->current_points_[id].surface);
- touch->current_points_.erase(iterator);
+ touch->delegate_->OnTouchReleaseEvent(timestamp, id);
+
+ // Do not store the |serial| on UP events. Otherwise, Ozone can't create popup
+ // windows, which (according to the spec) can only be created on reaction to
+ // button/touch down serials.
}
void WaylandTouch::Motion(void* data,
@@ -140,39 +80,18 @@ void WaylandTouch::Motion(void* data,
WaylandTouch* touch = static_cast<WaylandTouch*>(data);
DCHECK(touch);
- // Make sure this touch point wasn't present before.
- if (touch->current_points_.find(id) == touch->current_points_.end()) {
- LOG(WARNING) << "Touch event fired with wrong id";
- return;
- }
-
- EventType type = ET_TOUCH_MOVED;
- gfx::Point location(wl_fixed_to_double(x), wl_fixed_to_double(y));
- base::TimeTicks time_stamp =
+ gfx::PointF location(wl_fixed_to_double(x), wl_fixed_to_double(y));
+ base::TimeTicks timestamp =
base::TimeTicks() + base::TimeDelta::FromMilliseconds(time);
- PointerDetails pointer_details(EventPointerType::POINTER_TYPE_TOUCH, id);
- TouchEvent event(type, location, time_stamp, pointer_details);
- touch->callback_.Run(&event);
- touch->current_points_[id].last_known_location = location;
+ touch->delegate_->OnTouchMotionEvent(location, timestamp, id);
}
-void WaylandTouch::Frame(void* data, wl_touch* obj) {}
-
void WaylandTouch::Cancel(void* data, wl_touch* obj) {
WaylandTouch* touch = static_cast<WaylandTouch*>(data);
DCHECK(touch);
- for (auto& point : touch->current_points_) {
- int32_t id = point.first;
-
- EventType type = ET_TOUCH_CANCELLED;
- base::TimeTicks time_stamp = base::TimeTicks::Now();
- PointerDetails pointer_details(EventPointerType::POINTER_TYPE_TOUCH, id);
- TouchEvent event(type, gfx::Point(), time_stamp, pointer_details);
- touch->callback_.Run(&event);
-
- WaylandWindow::FromSurface(point.second.surface)->set_touch_focus(false);
- }
- touch->current_points_.clear();
+ touch->delegate_->OnTouchCancelEvent();
}
+void WaylandTouch::Frame(void* data, wl_touch* obj) {}
+
} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_touch.h b/chromium/ui/ozone/platform/wayland/host/wayland_touch.h
index 4c60cf20f6e..14c9aaa0f78 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_touch.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_touch.h
@@ -5,47 +5,30 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_TOUCH_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_TOUCH_H_
-#include <memory>
-
-#include "base/containers/flat_map.h"
-#include "ui/events/ozone/evdev/event_dispatch_callback.h"
-#include "ui/gfx/geometry/rect.h"
+#include "base/macros.h"
+#include "base/time/time.h"
+#include "ui/events/pointer_details.h"
#include "ui/ozone/platform/wayland/common/wayland_object.h"
-#include "ui/ozone/platform/wayland/host/wayland_window_observer.h"
+
+namespace gfx {
+class PointF;
+} // namespace gfx
namespace ui {
class WaylandConnection;
class WaylandWindow;
-class WaylandTouch : public WaylandWindowObserver {
+class WaylandTouch {
public:
- WaylandTouch(wl_touch* touch, const EventDispatchCallback& callback);
- ~WaylandTouch() override;
+ class Delegate;
- void SetConnection(WaylandConnection* connection);
-
- void RemoveTouchPoints(const WaylandWindow* window);
+ WaylandTouch(wl_touch* touch,
+ WaylandConnection* connection,
+ Delegate* delegate);
+ ~WaylandTouch();
private:
- struct TouchPoint {
- TouchPoint();
- TouchPoint(gfx::Point location, wl_surface* current_surface);
- ~TouchPoint();
-
- wl_surface* surface = nullptr;
- gfx::Point last_known_location;
- };
-
- using TouchPoints = base::flat_map<int32_t, TouchPoint>;
-
- void MaybeUnsetFocus(const TouchPoints& points,
- int32_t id,
- wl_surface* surface);
-
- // WaylandWindowObserver implements:
- void OnWindowRemoved(WaylandWindow* window) override;
-
// wl_touch_listener
static void Down(void* data,
wl_touch* obj,
@@ -66,17 +49,31 @@ class WaylandTouch : public WaylandWindowObserver {
int32_t id,
wl_fixed_t x,
wl_fixed_t y);
- static void Frame(void* data, wl_touch* obj);
static void Cancel(void* data, wl_touch* obj);
+ static void Frame(void* data, wl_touch* obj);
- WaylandConnection* connection_ = nullptr;
wl::Object<wl_touch> obj_;
- EventDispatchCallback callback_;
- TouchPoints current_points_;
+ WaylandConnection* const connection_;
+ Delegate* const delegate_;
DISALLOW_COPY_AND_ASSIGN(WaylandTouch);
};
+class WaylandTouch::Delegate {
+ public:
+ virtual void OnTouchCreated(WaylandTouch* touch) = 0;
+ virtual void OnTouchDestroyed(WaylandTouch* touch) = 0;
+ virtual void OnTouchPressEvent(WaylandWindow* window,
+ const gfx::PointF& location,
+ base::TimeTicks timestamp,
+ PointerId id) = 0;
+ virtual void OnTouchReleaseEvent(base::TimeTicks timestamp, PointerId id) = 0;
+ virtual void OnTouchMotionEvent(const gfx::PointF& location,
+ base::TimeTicks timestamp,
+ PointerId id) = 0;
+ virtual void OnTouchCancelEvent() = 0;
+};
+
} // namespace ui
#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_TOUCH_H_
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_touch_unittest.cc b/chromium/ui/ozone/platform/wayland/host/wayland_touch_unittest.cc
index 00c6a950e42..4d1c4fedaea 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_touch_unittest.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_touch_unittest.cc
@@ -82,6 +82,80 @@ TEST_P(WaylandTouchTest, KeypressAndMotion) {
CheckEventType(ui::ET_TOUCH_RELEASED, event.get());
}
+// Tests that touch focus is correctly set and released.
+TEST_P(WaylandTouchTest, CheckTouchFocus) {
+ uint32_t serial = 0;
+ uint32_t time = 0;
+ constexpr uint32_t touch_id1 = 1;
+ constexpr uint32_t touch_id2 = 2;
+ constexpr uint32_t touch_id3 = 3;
+
+ wl_touch_send_down(touch_->resource(), ++serial, ++time, surface_->resource(),
+ touch_id1, wl_fixed_from_int(50), wl_fixed_from_int(100));
+
+ Sync();
+
+ EXPECT_TRUE(window_->has_touch_focus());
+
+ wl_touch_send_up(touch_->resource(), ++serial, ++time, touch_id1);
+
+ Sync();
+
+ EXPECT_FALSE(window_->has_touch_focus());
+
+ wl_touch_send_down(touch_->resource(), ++serial, ++time, surface_->resource(),
+ touch_id1, wl_fixed_from_int(30), wl_fixed_from_int(40));
+
+ Sync();
+
+ EXPECT_TRUE(window_->has_touch_focus());
+
+ wl_touch_send_down(touch_->resource(), ++serial, ++time, surface_->resource(),
+ touch_id2, wl_fixed_from_int(30), wl_fixed_from_int(40));
+ wl_touch_send_down(touch_->resource(), ++serial, ++time, surface_->resource(),
+ touch_id3, wl_fixed_from_int(30), wl_fixed_from_int(40));
+
+ Sync();
+
+ EXPECT_TRUE(window_->has_touch_focus());
+
+ wl_touch_send_up(touch_->resource(), ++serial, ++time, touch_id2);
+
+ Sync();
+
+ EXPECT_TRUE(window_->has_touch_focus());
+
+ wl_touch_send_up(touch_->resource(), ++serial, ++time, touch_id1);
+
+ Sync();
+
+ EXPECT_TRUE(window_->has_touch_focus());
+
+ wl_touch_send_up(touch_->resource(), ++serial, ++time, touch_id3);
+
+ Sync();
+
+ EXPECT_FALSE(window_->has_touch_focus());
+
+ // Now send many touches and cancel them.
+ wl_touch_send_down(touch_->resource(), ++serial, ++time, surface_->resource(),
+ touch_id1, wl_fixed_from_int(30), wl_fixed_from_int(40));
+ wl_touch_send_down(touch_->resource(), ++serial, ++time, surface_->resource(),
+ touch_id2, wl_fixed_from_int(30), wl_fixed_from_int(40));
+ wl_touch_send_down(touch_->resource(), ++serial, ++time, surface_->resource(),
+ touch_id3, wl_fixed_from_int(30), wl_fixed_from_int(40));
+
+ Sync();
+
+ EXPECT_TRUE(window_->has_touch_focus());
+
+ wl_touch_send_cancel(touch_->resource());
+
+ Sync();
+
+ EXPECT_FALSE(window_->has_touch_focus());
+}
+
INSTANTIATE_TEST_SUITE_P(XdgVersionStableTest,
WaylandTouchTest,
::testing::Values(kXdgShellStable));
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_window.cc b/chromium/ui/ozone/platform/wayland/host/wayland_window.cc
index cfb9644b1f5..9298cb3acbc 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_window.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_window.cc
@@ -5,6 +5,7 @@
#include "ui/ozone/platform/wayland/host/wayland_window.h"
#include <wayland-client.h>
+
#include <memory>
#include "base/bind.h"
@@ -12,6 +13,7 @@
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/events/ozone/events_ozone.h"
+#include "ui/events/platform/platform_event_source.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/ozone/platform/wayland/common/wayland_util.h"
#include "ui/ozone/platform/wayland/host/wayland_buffer_manager_host.h"
@@ -33,17 +35,20 @@ WaylandWindow::~WaylandWindow() {
if (parent_window_)
parent_window_->set_child_window(nullptr);
-
- if (has_pointer_focus_)
- connection_->pointer()->reset_window_with_pointer_focus();
}
// static
WaylandWindow* WaylandWindow::FromSurface(wl_surface* surface) {
+ if (!surface)
+ return nullptr;
return static_cast<WaylandWindow*>(
wl_proxy_get_user_data(reinterpret_cast<wl_proxy*>(surface)));
}
+void WaylandWindow::OnWindowLostCapture() {
+ delegate_->OnLostCapture();
+}
+
void WaylandWindow::UpdateBufferScale(bool update_bounds) {
DCHECK(connection_->wayland_output_manager());
const auto* screen = connection_->wayland_output_manager()->wayland_screen();
@@ -127,17 +132,25 @@ gfx::Rect WaylandWindow::GetBounds() {
void WaylandWindow::SetTitle(const base::string16& title) {}
void WaylandWindow::SetCapture() {
- // Wayland does implicit grabs, and doesn't allow for explicit grabs. The
- // exception to that are menus, but we explicitly send events to a
- // parent menu if such exists.
+ // Wayland doesn't allow explicit grabs. Instead, it sends events to "entered"
+ // windows. That is, if user enters their mouse pointer to a window, that
+ // window starts to receive events. However, Chromium may want to reroute
+ // these events to another window. In this case, tell the window manager that
+ // this specific window has grabbed the events, and they will be rerouted in
+ // WaylandWindow::DispatchEvent method.
+ if (!HasCapture())
+ connection_->wayland_window_manager()->GrabLocatedEvents(this);
}
void WaylandWindow::ReleaseCapture() {
+ if (HasCapture())
+ connection_->wayland_window_manager()->UngrabLocatedEvents(this);
// See comment in SetCapture() for details on wayland and grabs.
}
bool WaylandWindow::HasCapture() const {
- return has_implicit_grab_;
+ return connection_->wayland_window_manager()->located_events_grabber() ==
+ this;
}
void WaylandWindow::ToggleFullscreen() {}
@@ -221,20 +234,6 @@ void WaylandWindow::SetWindowIcons(const gfx::ImageSkia& window_icon,
void WaylandWindow::SizeConstraintsChanged() {}
bool WaylandWindow::CanDispatchEvent(const PlatformEvent& event) {
- // This window is a nested menu window, all the events must be forwarded
- // to the main menu window.
- if (child_window_ && wl::IsMenuType(child_window_->type()))
- return wl::IsMenuType(type());
-
- // If this is a nested menu window with a parent, it mustn't recieve any
- // events.
- if (parent_window_ && wl::IsMenuType(parent_window_->type()))
- return false;
-
- // If another window has capture, return early before checking focus.
- if (HasCapture())
- return true;
-
if (event->IsMouseEvent())
return has_pointer_focus_;
if (event->IsKeyEvent())
@@ -246,37 +245,35 @@ bool WaylandWindow::CanDispatchEvent(const PlatformEvent& event) {
uint32_t WaylandWindow::DispatchEvent(const PlatformEvent& native_event) {
Event* event = static_cast<Event*>(native_event);
- if (event->IsLocatedEvent()) {
- // Wayland sends locations in DIP so they need to be translated to
- // physical pixels.
- event->AsLocatedEvent()->set_location_f(gfx::ScalePoint(
- event->AsLocatedEvent()->location_f(), buffer_scale_, buffer_scale_));
- auto copied_event = Event::Clone(*event);
- UpdateCursorPositionFromEvent(std::move(copied_event));
- }
- // If the window does not have a pointer focus, but received this event, it
- // means the window is a menu window with a child menu window. In this case,
- // the location of the event must be converted from the nested menu to the
- // main menu, which the menu controller needs to properly handle events.
- if (event->IsLocatedEvent() && wl::IsMenuType(type())) {
- // Parent window of the main menu window is not a menu, but rather an
- // xdg surface.
- DCHECK(!wl::IsMenuType(parent_window_->type()) ||
- parent_window_->type() != PlatformWindowType::kTooltip);
- auto* window =
- connection_->wayland_window_manager()->GetCurrentFocusedWindow();
- if (window) {
- ConvertEventLocationToTargetWindowLocation(GetBounds().origin(),
- window->GetBounds().origin(),
- event->AsLocatedEvent());
+ if (event->IsLocatedEvent()) {
+ auto* event_grabber =
+ connection_->wayland_window_manager()->located_events_grabber();
+ auto* root_parent_window = GetRootParentWindow();
+ // We must reroute the events to the event grabber iff these windows belong
+ // to the same root parent window. For example, there are 2 top level
+ // Wayland windows. One of them (window_1) has a child menu window that is
+ // the event grabber. If the mouse is moved over the window_1, it must
+ // reroute the events to the event grabber. If the mouse is moved over the
+ // window_2, the events mustn't be rerouted, because that belongs to another
+ // stack of windows. Remember that Wayland sends local surface coordinates,
+ // and continuing rerouting all the events may result in events sent to the
+ // grabber even though the mouse is over another root window.
+ //
+ if (event_grabber &&
+ root_parent_window == event_grabber->GetRootParentWindow()) {
+ ConvertEventLocationToTargetWindowLocation(
+ event_grabber->GetBounds().origin(), GetBounds().origin(),
+ event->AsLocatedEvent());
+ return event_grabber->DispatchEventToDelegate(native_event);
}
}
- DispatchEventFromNativeUiEvent(
- native_event, base::BindOnce(&PlatformWindowDelegate::DispatchEvent,
- base::Unretained(delegate_)));
- return POST_DISPATCH_STOP_PROPAGATION;
+ // Dispatch all keyboard events to the root window.
+ if (event->IsKeyEvent())
+ return GetRootParentWindow()->DispatchEventToDelegate(event);
+
+ return DispatchEventToDelegate(native_event);
}
void WaylandWindow::HandleSurfaceConfigure(int32_t widht,
@@ -440,37 +437,25 @@ void WaylandWindow::RemoveEnteredOutputId(struct wl_output* output) {
void WaylandWindow::UpdateCursorPositionFromEvent(
std::unique_ptr<Event> event) {
DCHECK(event->IsLocatedEvent());
- auto* window =
- connection_->wayland_window_manager()->GetCurrentFocusedWindow();
+
// This is a tricky part. Initially, Wayland sends events to surfaces the
// events are targeted for. But, in order to fulfill Chromium's assumptions
// about event targets, some of the events are rerouted and their locations
- // are converted.
- //
- // The event we got here is rerouted, but it hasn't had its location fixed
- // yet. Passing an event with fixed location won't help as well - its location
- // is converted in a different way: if mouse is moved outside a menu window
- // to the left, the location of such event includes negative values.
+ // are converted. The event we got here is rerouted and it has had its
+ // location fixed.
//
- // In contrast, this method must translate coordinates of all events
+ // Basically, this method must translate coordinates of all events
// in regards to top-level windows' coordinates as it's always located at
// origin (0,0) from Chromium point of view (remember that Wayland doesn't
// provide global coordinates to its clients). And it's totally fine to use it
// as the target. Thus, the location of the |event| is always converted using
// the top-level window's bounds as the target excluding cases, when the
// mouse/touch is over a top-level window.
- if (parent_window_ && parent_window_ != window) {
- const gfx::Rect target_bounds = parent_window_->GetBounds();
- gfx::Rect own_bounds = GetBounds();
- // This is a bit trickier, and concerns nested menu windows. Whenever an
- // event is sent to the nested menu window, it's rerouted to a parent menu
- // window. Thus, in order to correctly translate its location, we must
- // choose correct values for the |own_bounds|. In this case, it must the
- // nested menu window, because |this| is the parent of that window.
- if (window == child_window_)
- own_bounds = child_window_->GetBounds();
+ auto* toplevel_window = GetRootParentWindow();
+ if (toplevel_window != this) {
ConvertEventLocationToTargetWindowLocation(
- target_bounds.origin(), own_bounds.origin(), event->AsLocatedEvent());
+ toplevel_window->GetBounds().origin(), GetBounds().origin(),
+ event->AsLocatedEvent());
}
auto* cursor_position = connection_->wayland_cursor_position();
if (cursor_position) {
@@ -499,6 +484,18 @@ bool WaylandWindow::IsOpaqueWindow() const {
return opacity_ == ui::PlatformWindowOpacity::kOpaqueWindow;
}
+uint32_t WaylandWindow::DispatchEventToDelegate(
+ const PlatformEvent& native_event) {
+ auto* event = static_cast<Event*>(native_event);
+ if (event->IsLocatedEvent())
+ UpdateCursorPositionFromEvent(Event::Clone(*event));
+
+ DispatchEventFromNativeUiEvent(
+ native_event, base::BindOnce(&PlatformWindowDelegate::DispatchEvent,
+ base::Unretained(delegate_)));
+ return POST_DISPATCH_STOP_PROPAGATION;
+}
+
// static
void WaylandWindow::Enter(void* data,
struct wl_surface* wl_surface,
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_window.h b/chromium/ui/ozone/platform/wayland/host/wayland_window.h
index 08658f1df87..43cfa54d4cc 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_window.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_window.h
@@ -44,6 +44,8 @@ class WaylandWindow : public PlatformWindow, public PlatformEventDispatcher {
static WaylandWindow* FromSurface(wl_surface* surface);
+ void OnWindowLostCapture();
+
// Updates the surface buffer scale of the window. Top level windows take
// scale from the output attached to either their current display or the
// primary one if their widget is not yet created, children inherit scale from
@@ -78,11 +80,6 @@ class WaylandWindow : public PlatformWindow, public PlatformEventDispatcher {
void set_child_window(WaylandWindow* window) { child_window_ = window; }
WaylandWindow* child_window() const { return child_window_; }
- // Set whether this window has an implicit grab (often referred to as capture
- // in Chrome code). Implicit grabs happen while a pointer is down.
- void set_has_implicit_grab(bool value) { has_implicit_grab_ = value; }
- bool has_implicit_grab() const { return has_implicit_grab_; }
-
int32_t buffer_scale() const { return buffer_scale_; }
int32_t ui_scale() const { return ui_scale_; }
@@ -197,6 +194,8 @@ class WaylandWindow : public PlatformWindow, public PlatformEventDispatcher {
bool IsOpaqueWindow() const;
+ uint32_t DispatchEventToDelegate(const PlatformEvent& native_event);
+
// Additional initialization of derived classes.
virtual bool OnInitialize(PlatformWindowInitProperties properties) = 0;
@@ -226,7 +225,6 @@ class WaylandWindow : public PlatformWindow, public PlatformEventDispatcher {
bool has_pointer_focus_ = false;
bool has_keyboard_focus_ = false;
bool has_touch_focus_ = false;
- bool has_implicit_grab_ = false;
// Wayland's scale factor for the output that this window currently belongs
// to.
int32_t buffer_scale_ = 1;
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_window_factory.cc b/chromium/ui/ozone/platform/wayland/host/wayland_window_factory.cc
index 16db3567652..f74df68dbff 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_window_factory.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_window_factory.cc
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/ozone/platform/wayland/host/wayland_window.h"
-
#include <memory>
#include "ui/gfx/native_widget_types.h"
@@ -11,6 +9,7 @@
#include "ui/ozone/platform/wayland/host/wayland_popup.h"
#include "ui/ozone/platform/wayland/host/wayland_subsurface.h"
#include "ui/ozone/platform/wayland/host/wayland_surface.h"
+#include "ui/ozone/platform/wayland/host/wayland_window.h"
namespace ui {
@@ -54,4 +53,4 @@ std::unique_ptr<WaylandWindow> WaylandWindow::Create(
: nullptr;
}
-} // namespace ui \ No newline at end of file
+} // namespace ui
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_window_manager.cc b/chromium/ui/ozone/platform/wayland/host/wayland_window_manager.cc
index 5cd79014983..bd7050813b2 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_window_manager.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_window_manager.cc
@@ -20,6 +20,25 @@ void WaylandWindowManager::RemoveObserver(WaylandWindowObserver* observer) {
observers_.RemoveObserver(observer);
}
+void WaylandWindowManager::GrabLocatedEvents(WaylandWindow* window) {
+ DCHECK_NE(located_events_grabber_, window);
+
+ // Wayland doesn't allow to grab the mouse. However, we start forwarding all
+ // mouse events received by WaylandWindow to the aura::WindowEventDispatcher
+ // which has capture.
+ auto* old_grabber = located_events_grabber_;
+ located_events_grabber_ = window;
+ if (old_grabber)
+ old_grabber->OnWindowLostCapture();
+}
+
+void WaylandWindowManager::UngrabLocatedEvents(WaylandWindow* window) {
+ DCHECK_EQ(located_events_grabber_, window);
+ auto* old_grabber = located_events_grabber_;
+ located_events_grabber_ = nullptr;
+ old_grabber->OnWindowLostCapture();
+}
+
WaylandWindow* WaylandWindowManager::GetWindow(
gfx::AcceleratedWidget widget) const {
auto it = window_map_.find(widget);
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_window_manager.h b/chromium/ui/ozone/platform/wayland/host/wayland_window_manager.h
index 258f768f91b..1873c907a68 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_window_manager.h
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_window_manager.h
@@ -27,6 +27,17 @@ class WaylandWindowManager {
void AddObserver(WaylandWindowObserver* observer);
void RemoveObserver(WaylandWindowObserver* observer);
+ // Stores the window that should grab the located events.
+ void GrabLocatedEvents(WaylandWindow* event_grabber);
+
+ // Removes the window that should grab the located events.
+ void UngrabLocatedEvents(WaylandWindow* event_grabber);
+
+ // Returns current event grabber.
+ WaylandWindow* located_events_grabber() const {
+ return located_events_grabber_;
+ }
+
// Returns a window found by |widget|.
WaylandWindow* GetWindow(gfx::AcceleratedWidget widget) const;
@@ -54,6 +65,8 @@ class WaylandWindowManager {
base::flat_map<gfx::AcceleratedWidget, WaylandWindow*> window_map_;
+ WaylandWindow* located_events_grabber_ = nullptr;
+
DISALLOW_COPY_AND_ASSIGN(WaylandWindowManager);
};
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_window_manager_unittests.cc b/chromium/ui/ozone/platform/wayland/host/wayland_window_manager_unittests.cc
index a4b1fc7d943..73b6d2c187e 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_window_manager_unittests.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_window_manager_unittests.cc
@@ -20,6 +20,8 @@ constexpr gfx::Rect kDefaultBounds(0, 0, 100, 100);
class WaylandWindowManagerTest : public WaylandTest {
public:
WaylandWindowManagerTest() {}
+ WaylandWindowManagerTest(const WaylandWindowManagerTest&) = delete;
+ WaylandWindowManagerTest& operator=(const WaylandWindowManagerTest&) = delete;
void SetUp() override {
WaylandTest::SetUp();
@@ -44,9 +46,6 @@ class WaylandWindowManagerTest : public WaylandTest {
}
WaylandWindowManager* manager_ = nullptr;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(WaylandWindowManagerTest);
};
TEST_P(WaylandWindowManagerTest, GetWindow) {
diff --git a/chromium/ui/ozone/platform/wayland/host/wayland_window_unittest.cc b/chromium/ui/ozone/platform/wayland/host/wayland_window_unittest.cc
index 3162fcf30ed..9a1112a1bd8 100644
--- a/chromium/ui/ozone/platform/wayland/host/wayland_window_unittest.cc
+++ b/chromium/ui/ozone/platform/wayland/host/wayland_window_unittest.cc
@@ -22,7 +22,9 @@
#include "ui/ozone/platform/wayland/common/wayland_util.h"
#include "ui/ozone/platform/wayland/test/mock_pointer.h"
#include "ui/ozone/platform/wayland/test/mock_surface.h"
+#include "ui/ozone/platform/wayland/test/test_keyboard.h"
#include "ui/ozone/platform/wayland/test/test_region.h"
+#include "ui/ozone/platform/wayland/test/test_touch.h"
#include "ui/ozone/platform/wayland/test/test_wayland_server_thread.h"
#include "ui/ozone/platform/wayland/test/wayland_test.h"
#include "ui/ozone/test/mock_platform_window_delegate.h"
@@ -193,7 +195,38 @@ class WaylandWindowTest : public WaylandTest {
EXPECT_EQ(popup->constraint_adjustment(), position.constraint_adjustment);
}
- wl::MockXdgPopup* GetPopupByWidget(gfx::AcceleratedWidget widget) {
+ void VerifyCanDispatchMouseEvents(
+ const std::vector<WaylandWindow*>& dispatching_windows,
+ const std::vector<WaylandWindow*>& non_dispatching_windows) {
+ for (auto* window : dispatching_windows)
+ EXPECT_TRUE(window->CanDispatchEvent(&test_mouse_event_));
+ for (auto* window : non_dispatching_windows)
+ EXPECT_FALSE(window->CanDispatchEvent(&test_mouse_event_));
+ }
+
+ void VerifyCanDispatchTouchEvents(
+ const std::vector<WaylandWindow*>& dispatching_windows,
+ const std::vector<WaylandWindow*>& non_dispatching_windows) {
+ PointerDetails pointer_details(EventPointerType::kTouch, 1);
+ TouchEvent test_touch_event(ET_TOUCH_PRESSED, {1, 1}, base::TimeTicks(),
+ pointer_details);
+ for (auto* window : dispatching_windows)
+ EXPECT_TRUE(window->CanDispatchEvent(&test_touch_event));
+ for (auto* window : non_dispatching_windows)
+ EXPECT_FALSE(window->CanDispatchEvent(&test_touch_event));
+ }
+
+ void VerifyCanDispatchKeyEvents(
+ const std::vector<WaylandWindow*>& dispatching_windows,
+ const std::vector<WaylandWindow*>& non_dispatching_windows) {
+ KeyEvent test_key_event(ET_KEY_PRESSED, VKEY_0, 0);
+ for (auto* window : dispatching_windows)
+ EXPECT_TRUE(window->CanDispatchEvent(&test_key_event));
+ for (auto* window : non_dispatching_windows)
+ EXPECT_FALSE(window->CanDispatchEvent(&test_key_event));
+ }
+
+ wl::TestXdgPopup* GetPopupByWidget(gfx::AcceleratedWidget widget) {
wl::MockSurface* mock_surface = server_.GetObject<wl::MockSurface>(widget);
if (mock_surface) {
auto* mock_xdg_surface = mock_surface->xdg_surface();
@@ -771,35 +804,6 @@ TEST_P(WaylandWindowTest, DispatchEvent) {
test_mouse_event_.changed_button_flags());
}
-TEST_P(WaylandWindowTest, HasCaptureUpdatedOnPointerEvents) {
- wl_seat_send_capabilities(server_.seat()->resource(),
- WL_SEAT_CAPABILITY_POINTER);
-
- Sync();
-
- wl::MockPointer* pointer = server_.seat()->pointer();
- ASSERT_TRUE(pointer);
-
- wl_pointer_send_enter(pointer->resource(), 1, surface_->resource(), 0, 0);
- Sync();
- EXPECT_FALSE(window_->HasCapture());
-
- wl_pointer_send_button(pointer->resource(), 2, 1002, BTN_LEFT,
- WL_POINTER_BUTTON_STATE_PRESSED);
- Sync();
- EXPECT_TRUE(window_->HasCapture());
-
- wl_pointer_send_motion(pointer->resource(), 1003, wl_fixed_from_int(400),
- wl_fixed_from_int(500));
- Sync();
- EXPECT_TRUE(window_->HasCapture());
-
- wl_pointer_send_button(pointer->resource(), 4, 1004, BTN_LEFT,
- WL_POINTER_BUTTON_STATE_RELEASED);
- Sync();
- EXPECT_FALSE(window_->HasCapture());
-}
-
TEST_P(WaylandWindowTest, ConfigureEvent) {
ScopedWlArray states;
@@ -920,10 +924,10 @@ TEST_P(WaylandWindowTest, CreateAndDestroyNestedMenuWindow) {
Sync();
}
-TEST_P(WaylandWindowTest, CanDispatchEventToMenuWindowNonNested) {
+TEST_P(WaylandWindowTest, DispatchesLocatedEventsToCapturedWindow) {
MockPlatformWindowDelegate menu_window_delegate;
std::unique_ptr<WaylandWindow> menu_window = CreateWaylandWindowWithParams(
- PlatformWindowType::kMenu, widget_, gfx::Rect(0, 0, 10, 10),
+ PlatformWindowType::kMenu, widget_, gfx::Rect(10, 10, 10, 10),
&menu_window_delegate);
EXPECT_TRUE(menu_window);
@@ -933,16 +937,224 @@ TEST_P(WaylandWindowTest, CanDispatchEventToMenuWindowNonNested) {
ASSERT_TRUE(connection_->pointer());
window_->SetPointerFocus(true);
- // Make sure the events are sent to the menu window despite the pointer focus
- // on the main window. Typically, it's the menu controller, which must get all
- // the events in the case like this.
- EXPECT_FALSE(window_->CanDispatchEvent(&test_mouse_event_));
- EXPECT_TRUE(menu_window->CanDispatchEvent(&test_mouse_event_));
+ // Make sure the events are handled by the window that has the pointer focus.
+ VerifyCanDispatchMouseEvents({window_.get()}, {menu_window.get()});
+
+ // The |window_| that has the pointer focus must receive the event.
+ EXPECT_CALL(menu_window_delegate, DispatchEvent(_)).Times(0);
+ std::unique_ptr<Event> event;
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+
+ // The event is send in local surface coordinates of the |window|.
+ wl_pointer_send_motion(server_.seat()->pointer()->resource(), 1002,
+ wl_fixed_from_double(10.75),
+ wl_fixed_from_double(20.375));
+
+ Sync();
+
+ ASSERT_TRUE(event->IsLocatedEvent());
+ EXPECT_EQ(event->AsLocatedEvent()->location(), gfx::Point(10, 20));
+
+ // Set capture to menu window now.
+ menu_window->SetCapture();
+
+ // It's still the |window_| that can dispatch the events, but it will reroute
+ // the event to correct window and fix the location.
+ VerifyCanDispatchMouseEvents({window_.get()}, {menu_window.get()});
+
+ // The |window_| that has the pointer focus must receive the event.
+ EXPECT_CALL(delegate_, DispatchEvent(_)).Times(0);
+ std::unique_ptr<Event> event2;
+ EXPECT_CALL(menu_window_delegate, DispatchEvent(_))
+ .WillOnce(CloneEvent(&event2));
+
+ // The event is send in local surface coordinates of the |window|.
+ wl_pointer_send_motion(server_.seat()->pointer()->resource(), 1002,
+ wl_fixed_from_double(10.75),
+ wl_fixed_from_double(20.375));
+
+ Sync();
+
+ ASSERT_TRUE(event2->IsLocatedEvent());
+ EXPECT_EQ(event2->AsLocatedEvent()->location(), gfx::Point(0, 10));
+
+ // The event is send in local surface coordinates of the |window|.
+ wl_pointer_send_motion(server_.seat()->pointer()->resource(), 1002,
+ wl_fixed_from_double(2.75),
+ wl_fixed_from_double(8.375));
+
+ EXPECT_CALL(delegate_, DispatchEvent(_)).Times(0);
+ std::unique_ptr<Event> event3;
+ EXPECT_CALL(menu_window_delegate, DispatchEvent(_))
+ .WillOnce(CloneEvent(&event3));
+
+ Sync();
+
+ ASSERT_TRUE(event3->IsLocatedEvent());
+ EXPECT_EQ(event3->AsLocatedEvent()->location(), gfx::Point(-8, -2));
+
+ // If nested menu window is added, the events are still correctly translated
+ // to the captured window.
+ MockPlatformWindowDelegate nested_menu_window_delegate;
+ std::unique_ptr<WaylandWindow> nested_menu_window =
+ CreateWaylandWindowWithParams(
+ PlatformWindowType::kMenu, menu_window->GetWidget(),
+ gfx::Rect(15, 18, 10, 10), &nested_menu_window_delegate);
+ EXPECT_TRUE(nested_menu_window);
+
+ Sync();
+
+ window_->SetPointerFocus(false);
+ nested_menu_window->SetPointerFocus(true);
+
+ // The event is processed by the window that has the pointer focus, but
+ // dispatched by the window that has the capture.
+ VerifyCanDispatchMouseEvents({nested_menu_window.get()},
+ {window_.get(), menu_window.get()});
+ EXPECT_TRUE(menu_window->HasCapture());
+
+ EXPECT_CALL(delegate_, DispatchEvent(_)).Times(0);
+ EXPECT_CALL(nested_menu_window_delegate, DispatchEvent(_)).Times(0);
+ std::unique_ptr<Event> event4;
+ EXPECT_CALL(menu_window_delegate, DispatchEvent(_))
+ .WillOnce(CloneEvent(&event4));
+
+ // The event is send in local surface coordinates of the |nested_menu_window|.
+ wl_pointer_send_motion(server_.seat()->pointer()->resource(), 1002,
+ wl_fixed_from_double(2.75),
+ wl_fixed_from_double(8.375));
+
+ Sync();
+
+ ASSERT_TRUE(event4->IsLocatedEvent());
+ EXPECT_EQ(event4->AsLocatedEvent()->location(), gfx::Point(7, 16));
+
+ menu_window.reset();
+}
+
+// Tests that the event grabber gets the events processed by its toplevel parent
+// window iff they belong to the same "family". Otherwise, events mustn't be
+// rerouted from another toplevel window to the event grabber.
+TEST_P(WaylandWindowTest,
+ DispatchesLocatedEventsToCapturedWindowInTheSameStack) {
+ MockPlatformWindowDelegate menu_window_delegate;
+ std::unique_ptr<WaylandWindow> menu_window = CreateWaylandWindowWithParams(
+ PlatformWindowType::kMenu, widget_, gfx::Rect(30, 40, 20, 50),
+ &menu_window_delegate);
+ EXPECT_TRUE(menu_window);
+
+ // Second toplevel window has the same bounds as the |window_|.
+ MockPlatformWindowDelegate toplevel_window2_delegate;
+ std::unique_ptr<WaylandWindow> toplevel_window2 =
+ CreateWaylandWindowWithParams(
+ PlatformWindowType::kWindow, gfx::kNullAcceleratedWidget,
+ window_->GetBounds(), &toplevel_window2_delegate);
+ EXPECT_TRUE(toplevel_window2);
+
+ wl_seat_send_capabilities(server_.seat()->resource(),
+ WL_SEAT_CAPABILITY_POINTER);
+ Sync();
+ ASSERT_TRUE(connection_->pointer());
+ window_->SetPointerFocus(true);
+
+ // Make sure the events are handled by the window that has the pointer focus.
+ VerifyCanDispatchMouseEvents({window_.get()},
+ {menu_window.get(), toplevel_window2.get()});
+
+ menu_window->SetCapture();
+
+ // The |menu_window| that has capture must receive the event.
+ EXPECT_CALL(delegate_, DispatchEvent(_)).Times(0);
+ EXPECT_CALL(toplevel_window2_delegate, DispatchEvent(_)).Times(0);
+ std::unique_ptr<Event> event;
+ EXPECT_CALL(menu_window_delegate, DispatchEvent(_))
+ .WillOnce(CloneEvent(&event));
+
+ // The event is send in local surface coordinates of the |window|.
+ wl_pointer_send_motion(server_.seat()->pointer()->resource(), 1002,
+ wl_fixed_from_double(10.75),
+ wl_fixed_from_double(20.375));
+
+ Sync();
+
+ ASSERT_TRUE(event->IsLocatedEvent());
+ EXPECT_EQ(event->AsLocatedEvent()->location(), gfx::Point(-20, -20));
+
+ // Now, pretend that the second toplevel window gets the pointer focus - the
+ // event grabber must be disragerder now.
+ window_->SetPointerFocus(false);
+ toplevel_window2->SetPointerFocus(true);
+
+ VerifyCanDispatchMouseEvents({toplevel_window2.get()},
+ {menu_window.get(), window_.get()});
+
+ // The |toplevel_window2| that has capture and must receive the event.
+ EXPECT_CALL(delegate_, DispatchEvent(_)).Times(0);
+ EXPECT_CALL(menu_window_delegate, DispatchEvent(_)).Times(0);
+ event.reset();
+ EXPECT_CALL(toplevel_window2_delegate, DispatchEvent(_))
+ .WillOnce(CloneEvent(&event));
+
+ // The event is send in local surface coordinates of the |toplevel_window2|
+ // (they're basically the same as the |window| has.)
+ wl_pointer_send_motion(server_.seat()->pointer()->resource(), 1002,
+ wl_fixed_from_double(10.75),
+ wl_fixed_from_double(20.375));
+
+ Sync();
+
+ ASSERT_TRUE(event->IsLocatedEvent());
+ EXPECT_EQ(event->AsLocatedEvent()->location(), gfx::Point(10, 20));
+}
+
+TEST_P(WaylandWindowTest, DispatchesKeyboardEventToToplevelWindow) {
+ MockPlatformWindowDelegate menu_window_delegate;
+ std::unique_ptr<WaylandWindow> menu_window = CreateWaylandWindowWithParams(
+ PlatformWindowType::kMenu, widget_, gfx::Rect(10, 10, 10, 10),
+ &menu_window_delegate);
+ EXPECT_TRUE(menu_window);
+
+ wl_seat_send_capabilities(server_.seat()->resource(),
+ WL_SEAT_CAPABILITY_KEYBOARD);
+ Sync();
+ ASSERT_TRUE(connection_->keyboard());
+ menu_window->set_keyboard_focus(true);
+
+ // Even though the menu window has the keyboard focus, the keyboard events are
+ // dispatched by the root parent wayland window in the end.
+ VerifyCanDispatchKeyEvents({menu_window.get()}, {window_.get()});
+ EXPECT_CALL(menu_window_delegate, DispatchEvent(_)).Times(0);
+ std::unique_ptr<Event> event;
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+
+ wl_keyboard_send_key(server_.seat()->keyboard()->resource(), 2, 0, 30 /* a */,
+ WL_KEYBOARD_KEY_STATE_PRESSED);
+
+ Sync();
+
+ ASSERT_TRUE(event->IsKeyEvent());
+
+ // Setting capture doesn't affect the kbd events.
+ menu_window->SetCapture();
+ VerifyCanDispatchKeyEvents({menu_window.get()}, {window_.get()});
+
+ wl_keyboard_send_key(server_.seat()->keyboard()->resource(), 2, 0, 30 /* a */,
+ WL_KEYBOARD_KEY_STATE_PRESSED);
+
+ EXPECT_CALL(menu_window_delegate, DispatchEvent(_)).Times(0);
+ event.reset();
+ EXPECT_CALL(delegate_, DispatchEvent(_)).WillOnce(CloneEvent(&event));
+
+ Sync();
+
+ ASSERT_TRUE(event->IsKeyEvent());
menu_window.reset();
}
-TEST_P(WaylandWindowTest, CanDispatchEventToMenuWindowNested) {
+// Tests that event is processed by the surface that has the focus. More
+// extensive tests are located in wayland touch/keyboard/pointer unittests.
+TEST_P(WaylandWindowTest, CanDispatchEvent) {
MockPlatformWindowDelegate menu_window_delegate;
gfx::AcceleratedWidget menu_window_widget;
EXPECT_CALL(menu_window_delegate, OnAcceleratedWidgetAvailable(_))
@@ -965,18 +1177,100 @@ TEST_P(WaylandWindowTest, CanDispatchEventToMenuWindowNested) {
Sync();
wl_seat_send_capabilities(server_.seat()->resource(),
- WL_SEAT_CAPABILITY_POINTER);
+ WL_SEAT_CAPABILITY_POINTER |
+ WL_SEAT_CAPABILITY_KEYBOARD |
+ WL_SEAT_CAPABILITY_TOUCH);
Sync();
ASSERT_TRUE(connection_->pointer());
- window_->SetPointerFocus(true);
+ ASSERT_TRUE(connection_->touch());
+ ASSERT_TRUE(connection_->keyboard());
- // In case of nested menu windows, it is the main menu window, which must
- // receive all the events.
- EXPECT_FALSE(window_->CanDispatchEvent(&test_mouse_event_));
- EXPECT_TRUE(menu_window->CanDispatchEvent(&test_mouse_event_));
- EXPECT_FALSE(nested_menu_window->CanDispatchEvent(&test_mouse_event_));
+ uint32_t serial = 0;
+
+ // Test that CanDispatchEvent is set correctly.
+ wl::MockSurface* toplevel_surface =
+ server_.GetObject<wl::MockSurface>(widget_);
+ wl_pointer_send_enter(server_.seat()->pointer()->resource(), ++serial,
+ toplevel_surface->resource(), 0, 0);
+
+ Sync();
+
+ // Only |window_| can dispatch MouseEvents.
+ VerifyCanDispatchMouseEvents({window_.get()},
+ {menu_window.get(), nested_menu_window.get()});
+ VerifyCanDispatchTouchEvents(
+ {}, {window_.get(), menu_window.get(), nested_menu_window.get()});
+ VerifyCanDispatchKeyEvents(
+ {}, {window_.get(), menu_window.get(), nested_menu_window.get()});
+
+ struct wl_array empty;
+ wl_array_init(&empty);
+ wl_keyboard_send_enter(server_.seat()->keyboard()->resource(), ++serial,
+ toplevel_surface->resource(), &empty);
+
+ Sync();
+
+ // Only |window_| can dispatch MouseEvents and KeyEvents.
+ VerifyCanDispatchMouseEvents({window_.get()},
+ {menu_window.get(), nested_menu_window.get()});
+ VerifyCanDispatchTouchEvents(
+ {}, {window_.get(), menu_window.get(), nested_menu_window.get()});
+ VerifyCanDispatchKeyEvents({window_.get()},
+ {menu_window.get(), nested_menu_window.get()});
+
+ wl_touch_send_down(server_.seat()->touch()->resource(), ++serial, 0,
+ toplevel_surface->resource(), 0 /* id */,
+ wl_fixed_from_int(50), wl_fixed_from_int(100));
+
+ Sync();
+
+ // Only |window_| can dispatch MouseEvents and KeyEvents.
+ VerifyCanDispatchMouseEvents({window_.get()},
+ {menu_window.get(), nested_menu_window.get()});
+ VerifyCanDispatchTouchEvents({window_.get()},
+ {menu_window.get(), nested_menu_window.get()});
+ VerifyCanDispatchKeyEvents({window_.get()},
+ {menu_window.get(), nested_menu_window.get()});
+
+ wl::MockSurface* menu_window_surface =
+ server_.GetObject<wl::MockSurface>(menu_window->GetWidget());
+
+ wl_pointer_send_leave(server_.seat()->pointer()->resource(), ++serial,
+ toplevel_surface->resource());
+ wl_pointer_send_enter(server_.seat()->pointer()->resource(), ++serial,
+ menu_window_surface->resource(), 0, 0);
+ wl_touch_send_up(server_.seat()->touch()->resource(), ++serial, 1000,
+ 0 /* id */);
+ wl_keyboard_send_leave(server_.seat()->keyboard()->resource(), ++serial,
+ toplevel_surface->resource());
+
+ Sync();
+
+ // Only |menu_window| can dispatch MouseEvents.
+ VerifyCanDispatchMouseEvents({menu_window.get()},
+ {window_.get(), nested_menu_window.get()});
+ VerifyCanDispatchTouchEvents(
+ {}, {window_.get(), menu_window.get(), nested_menu_window.get()});
+ VerifyCanDispatchKeyEvents(
+ {}, {window_.get(), menu_window.get(), nested_menu_window.get()});
+
+ wl::MockSurface* nested_menu_window_surface =
+ server_.GetObject<wl::MockSurface>(nested_menu_window->GetWidget());
+
+ wl_pointer_send_leave(server_.seat()->pointer()->resource(), ++serial,
+ menu_window_surface->resource());
+ wl_pointer_send_enter(server_.seat()->pointer()->resource(), ++serial,
+ nested_menu_window_surface->resource(), 0, 0);
Sync();
+
+ // Only |nested_menu_window| can dispatch MouseEvents.
+ VerifyCanDispatchMouseEvents({nested_menu_window.get()},
+ {window_.get(), menu_window.get()});
+ VerifyCanDispatchTouchEvents(
+ {}, {window_.get(), menu_window.get(), nested_menu_window.get()});
+ VerifyCanDispatchKeyEvents(
+ {}, {window_.get(), menu_window.get(), nested_menu_window.get()});
}
TEST_P(WaylandWindowTest, DispatchWindowMove) {
@@ -1002,9 +1296,7 @@ TEST_P(WaylandWindowTest, DispatchWindowResize) {
}
// Tests WaylandWindow repositions menu windows to be relative to parent window
-// in a right way. Also, tests it sends right anchor and is able to calculate
-// bounds back from relative to parent to be relative to screen/toplevel window.
-// All bounds values are taken by manually running the browser.
+// in a right way.
TEST_P(WaylandWindowTest, AdjustPopupBounds) {
PopupPosition menu_window_positioner, nested_menu_window_positioner;
@@ -1177,97 +1469,6 @@ TEST_P(WaylandWindowTest, AdjustPopupBounds) {
Sync();
VerifyAndClearExpectations();
-
- // Case 7: imagine the top level window has the size corresponding near to the
- // maximum work area of a display. Despite being unaware where the top level
- // window is, Chromium positions the nested menu window to be on the left side
- // of the menu window. But, WaylandWindow must reposition it to be on the
- // right side of the menu window, and let the Wayland compositor decide how to
- // position the nested menu (if its pixels do not fit one display, it can be
- // flipped along x-axis). PS: all the values are taken after manually using
- // the browser and logging bounds.
- nested_menu_window.reset();
- menu_window.reset();
-
- window_->SetBounds(gfx::Rect(0, 0, 2493, 1413));
-
- menu_window_bounds.set_origin({2206, 67});
- menu_window = CreateWaylandWindowWithParams(
- PlatformWindowType::kMenu, toplevel_window->GetWidget(),
- menu_window_bounds, &menu_window_delegate);
- EXPECT_TRUE(menu_window);
-
- Sync();
-
- menu_window_widget = menu_window->GetWidget();
- menu_window_positioner.anchor_rect.set_origin({2205, 37});
- VerifyXdgPopupPosition(menu_window_widget, menu_window_positioner);
-
- EXPECT_CALL(menu_window_delegate, OnBoundsChanged(_)).Times(0);
- SendConfigureEventPopup(menu_window_widget, menu_window_bounds);
-
- Sync();
-
- nested_menu_window_bounds.set_origin({1905, 147});
- nested_menu_window = CreateWaylandWindowWithParams(
- PlatformWindowType::kMenu, menu_window_widget, nested_menu_window_bounds,
- &nested_menu_window_delegate);
- EXPECT_TRUE(nested_menu_window);
-
- Sync();
-
- nested_menu_window_widget = nested_menu_window->GetWidget();
- nested_menu_window_positioner.anchor_rect.set_origin({4, 80});
- VerifyXdgPopupPosition(nested_menu_window_widget,
- nested_menu_window_positioner);
-
- VerifyAndClearExpectations();
-
- // Case 8: now, the top level window becomes maximized. Compared to the case
- // 7, despite having the size corresponding to the work area of a display, the
- // WaylandWindow must not reposition the nested menu window to the right side,
- // and let it be on the left side of a menu window as long as letting the
- // Wayland compositor repositioning the nested window may result in a window
- // shown on another display.
- auto active_maximized = MakeStateArray(
- {XDG_TOPLEVEL_STATE_ACTIVATED, XDG_TOPLEVEL_STATE_MAXIMIZED});
- EXPECT_CALL(*GetXdgToplevel(), SetMaximized());
-
- window_->Maximize();
- SendConfigureEvent(2493, 1413, 1, active_maximized.get());
-
- Sync();
-
- nested_menu_window.reset();
-
- nested_menu_window = CreateWaylandWindowWithParams(
- PlatformWindowType::kMenu, menu_window_widget, nested_menu_window_bounds,
- &nested_menu_window_delegate);
- EXPECT_TRUE(nested_menu_window);
-
- Sync();
-
- nested_menu_window_widget = nested_menu_window->GetWidget();
- // The anchor and gravity must change to be on the right side.
- if (GetParam() == kXdgShellV6) {
- nested_menu_window_positioner.anchor =
- ZXDG_POSITIONER_V6_ANCHOR_TOP | ZXDG_POSITIONER_V6_ANCHOR_LEFT;
- nested_menu_window_positioner.gravity =
- ZXDG_POSITIONER_V6_GRAVITY_BOTTOM | ZXDG_POSITIONER_V6_GRAVITY_LEFT;
- } else {
- nested_menu_window_positioner.anchor = XDG_POSITIONER_ANCHOR_TOP_LEFT;
- nested_menu_window_positioner.gravity = XDG_POSITIONER_GRAVITY_BOTTOM_LEFT;
- }
- VerifyXdgPopupPosition(nested_menu_window_widget,
- nested_menu_window_positioner);
-
- calculated_nested_bounds.set_origin({-301, 80});
- EXPECT_CALL(nested_menu_window_delegate, OnBoundsChanged(_)).Times(0);
- SendConfigureEventPopup(nested_menu_window_widget, calculated_nested_bounds);
-
- Sync();
-
- VerifyAndClearExpectations();
}
ACTION_P(VerifyRegion, ptr) {
@@ -1392,6 +1593,155 @@ TEST_P(WaylandWindowTest, SubsurfaceSimpleParent) {
window_->SetPointerFocus(false);
}
+// Case 1: When the menu bounds are positive and there is a positive,
+// non-zero anchor width
+TEST_P(WaylandWindowTest, NestedPopupMenu) {
+ VerifyAndClearExpectations();
+
+ gfx::Rect menu_window_bounds(gfx::Rect(4, 20, 8, 20));
+ std::unique_ptr<WaylandWindow> menu_window = CreateWaylandWindowWithParams(
+ PlatformWindowType::kMenu, window_->GetWidget(), menu_window_bounds,
+ &delegate_);
+ EXPECT_TRUE(menu_window);
+
+ VerifyAndClearExpectations();
+
+ gfx::Rect nestedPopup_bounds(gfx::Rect(10, 30, 40, 20));
+ std::unique_ptr<WaylandWindow> nestedPopup_window =
+ CreateWaylandWindowWithParams(PlatformWindowType::kPopup,
+ menu_window->GetWidget(),
+ nestedPopup_bounds, &delegate_);
+ EXPECT_TRUE(nestedPopup_window);
+
+ VerifyAndClearExpectations();
+
+ nestedPopup_window->SetPointerFocus(true);
+
+ Sync();
+
+ auto* mock_surface_nested_popup =
+ GetPopupByWidget(nestedPopup_window->GetWidget());
+
+ ASSERT_TRUE(mock_surface_nested_popup);
+
+ auto anchor_width = (mock_surface_nested_popup->anchor_rect()).width();
+ EXPECT_EQ(4, anchor_width);
+
+ nestedPopup_window->SetPointerFocus(false);
+}
+
+// Case 2: When the menu bounds are positive and there is a negative or
+// zero anchor width
+TEST_P(WaylandWindowTest, NestedPopupMenu1) {
+ VerifyAndClearExpectations();
+
+ gfx::Rect menu_window_bounds(gfx::Rect(6, 20, 8, 20));
+ std::unique_ptr<WaylandWindow> menu_window = CreateWaylandWindowWithParams(
+ PlatformWindowType::kMenu, window_->GetWidget(), menu_window_bounds,
+ &delegate_);
+ EXPECT_TRUE(menu_window);
+
+ VerifyAndClearExpectations();
+
+ gfx::Rect nestedPopup_bounds(gfx::Rect(10, 30, 10, 20));
+ std::unique_ptr<WaylandWindow> nestedPopup_window =
+ CreateWaylandWindowWithParams(PlatformWindowType::kPopup,
+ menu_window->GetWidget(),
+ nestedPopup_bounds, &delegate_);
+ EXPECT_TRUE(nestedPopup_window);
+
+ VerifyAndClearExpectations();
+
+ nestedPopup_window->SetPointerFocus(true);
+
+ Sync();
+
+ auto* mock_surface_nested_popup =
+ GetPopupByWidget(nestedPopup_window->GetWidget());
+
+ ASSERT_TRUE(mock_surface_nested_popup);
+
+ auto anchor_width = (mock_surface_nested_popup->anchor_rect()).width();
+ EXPECT_EQ(1, anchor_width);
+
+ nestedPopup_window->SetPointerFocus(false);
+}
+
+// Case 3: When the menu bounds are negative and there is a positive,
+// non-zero anchor width
+TEST_P(WaylandWindowTest, NestedPopupMenu2) {
+ VerifyAndClearExpectations();
+
+ gfx::Rect menu_window_bounds(gfx::Rect(10, 20, 40, 20));
+ std::unique_ptr<WaylandWindow> menu_window = CreateWaylandWindowWithParams(
+ PlatformWindowType::kMenu, window_->GetWidget(), menu_window_bounds,
+ &delegate_);
+ EXPECT_TRUE(menu_window);
+
+ VerifyAndClearExpectations();
+
+ gfx::Rect nestedPopup_bounds(gfx::Rect(5, 30, 21, 20));
+ std::unique_ptr<WaylandWindow> nestedPopup_window =
+ CreateWaylandWindowWithParams(PlatformWindowType::kPopup,
+ menu_window->GetWidget(),
+ nestedPopup_bounds, &delegate_);
+ EXPECT_TRUE(nestedPopup_window);
+
+ VerifyAndClearExpectations();
+
+ nestedPopup_window->SetPointerFocus(true);
+
+ Sync();
+
+ auto* mock_surface_nested_popup =
+ GetPopupByWidget(nestedPopup_window->GetWidget());
+
+ ASSERT_TRUE(mock_surface_nested_popup);
+
+ auto anchor_width = (mock_surface_nested_popup->anchor_rect()).width();
+ EXPECT_EQ(8, anchor_width);
+
+ nestedPopup_window->SetPointerFocus(false);
+}
+
+// Case 4: When the menu bounds are negative and there is a negative,
+// zero anchor width
+TEST_P(WaylandWindowTest, NestedPopupMenu3) {
+ VerifyAndClearExpectations();
+
+ gfx::Rect menu_window_bounds(gfx::Rect(10, 20, 20, 20));
+ std::unique_ptr<WaylandWindow> menu_window = CreateWaylandWindowWithParams(
+ PlatformWindowType::kMenu, window_->GetWidget(), menu_window_bounds,
+ &delegate_);
+ EXPECT_TRUE(menu_window);
+
+ VerifyAndClearExpectations();
+
+ gfx::Rect nestedPopup_bounds(gfx::Rect(5, 30, 21, 20));
+ std::unique_ptr<WaylandWindow> nestedPopup_window =
+ CreateWaylandWindowWithParams(PlatformWindowType::kPopup,
+ menu_window->GetWidget(),
+ nestedPopup_bounds, &delegate_);
+ EXPECT_TRUE(nestedPopup_window);
+
+ VerifyAndClearExpectations();
+
+ nestedPopup_window->SetPointerFocus(true);
+
+ Sync();
+
+ auto* mock_surface_nested_popup =
+ GetPopupByWidget(nestedPopup_window->GetWidget());
+
+ ASSERT_TRUE(mock_surface_nested_popup);
+
+ auto anchor_width = (mock_surface_nested_popup->anchor_rect()).width();
+
+ EXPECT_EQ(1, anchor_width);
+
+ nestedPopup_window->SetPointerFocus(false);
+}
+
TEST_P(WaylandWindowTest, SubsurfaceNestedParent) {
VerifyAndClearExpectations();
@@ -1580,6 +1930,94 @@ TEST_P(WaylandWindowTest, SetsPropertiesOnShow) {
EXPECT_EQ(mock_xdg_toplevel->title(), base::UTF16ToUTF8(kTitle));
}
+// Tests that a popup window is created using the serial of button press events
+// as required by the Wayland protocol spec.
+TEST_P(WaylandWindowTest, CreatesPopupOnButtonPressSerial) {
+ wl_seat_send_capabilities(
+ server_.seat()->resource(),
+ WL_SEAT_CAPABILITY_POINTER | WL_SEAT_CAPABILITY_KEYBOARD);
+
+ Sync();
+
+ constexpr uint32_t enter_serial = 1;
+ constexpr uint32_t button_press_serial = 2;
+ constexpr uint32_t button_release_serial = 3;
+
+ wl::MockSurface* toplevel_surface =
+ server_.GetObject<wl::MockSurface>(window_->GetWidget());
+ struct wl_array empty;
+ wl_array_init(&empty);
+ wl_keyboard_send_enter(server_.seat()->keyboard()->resource(), enter_serial,
+ toplevel_surface->resource(), &empty);
+
+ // Send two events - button down and button up.
+ wl_pointer_send_button(server_.seat()->pointer()->resource(),
+ button_press_serial, 1002, BTN_LEFT,
+ WL_POINTER_BUTTON_STATE_PRESSED);
+ wl_pointer_send_button(server_.seat()->pointer()->resource(),
+ button_release_serial, 1004, BTN_LEFT,
+ WL_POINTER_BUTTON_STATE_RELEASED);
+ Sync();
+
+ // Create a popup window and verify the client used correct serial.
+ MockPlatformWindowDelegate delegate;
+ auto popup = CreateWaylandWindowWithParams(
+ PlatformWindowType::kMenu, window_->GetWidget(), gfx::Rect(0, 0, 50, 50),
+ &delegate);
+ ASSERT_TRUE(popup);
+
+ Sync();
+
+ auto* test_popup = GetPopupByWidget(popup->GetWidget());
+ ASSERT_TRUE(test_popup);
+ EXPECT_NE(test_popup->grab_serial(), button_release_serial);
+ EXPECT_EQ(test_popup->grab_serial(), button_press_serial);
+}
+
+// Tests that a popup window is created using the serial of touch down events
+// as required by the Wayland protocol spec.
+TEST_P(WaylandWindowTest, CreatesPopupOnTouchDownSerial) {
+ wl_seat_send_capabilities(
+ server_.seat()->resource(),
+ WL_SEAT_CAPABILITY_TOUCH | WL_SEAT_CAPABILITY_KEYBOARD);
+
+ Sync();
+
+ constexpr uint32_t enter_serial = 1;
+ constexpr uint32_t touch_down_serial = 2;
+ constexpr uint32_t touch_up_serial = 3;
+
+ wl::MockSurface* toplevel_surface =
+ server_.GetObject<wl::MockSurface>(window_->GetWidget());
+ struct wl_array empty;
+ wl_array_init(&empty);
+ wl_keyboard_send_enter(server_.seat()->keyboard()->resource(), enter_serial,
+ toplevel_surface->resource(), &empty);
+
+ // Send two events - touch down and touch up.
+ wl_touch_send_down(server_.seat()->touch()->resource(), touch_down_serial, 0,
+ surface_->resource(), 0 /* id */, wl_fixed_from_int(50),
+ wl_fixed_from_int(100));
+ wl_touch_send_up(server_.seat()->touch()->resource(), touch_up_serial, 1000,
+ 0 /* id */);
+
+ Sync();
+
+ // Create a popup window and verify the client used correct serial.
+ MockPlatformWindowDelegate delegate;
+ auto popup = CreateWaylandWindowWithParams(
+ PlatformWindowType::kMenu, window_->GetWidget(), gfx::Rect(0, 0, 50, 50),
+ &delegate);
+ ASSERT_TRUE(popup);
+
+ Sync();
+
+ auto* test_popup = GetPopupByWidget(popup->GetWidget());
+ ASSERT_TRUE(test_popup);
+ EXPECT_NE(test_popup->grab_serial(), touch_up_serial);
+ EXPECT_EQ(test_popup->grab_serial(), touch_down_serial);
+}
+
INSTANTIATE_TEST_SUITE_P(XdgVersionStableTest,
WaylandWindowTest,
::testing::Values(kXdgShellStable));
diff --git a/chromium/ui/ozone/platform/wayland/host/xdg_popup_wrapper_impl.cc b/chromium/ui/ozone/platform/wayland/host/xdg_popup_wrapper_impl.cc
index 35ab0875304..1e81f70b003 100644
--- a/chromium/ui/ozone/platform/wayland/host/xdg_popup_wrapper_impl.cc
+++ b/chromium/ui/ozone/platform/wayland/host/xdg_popup_wrapper_impl.cc
@@ -6,6 +6,7 @@
#include <xdg-shell-client-protocol.h>
#include <xdg-shell-unstable-v6-client-protocol.h>
+
#include <memory>
#include "base/environment.h"
@@ -14,6 +15,7 @@
#include "ui/gfx/geometry/rect.h"
#include "ui/ozone/platform/wayland/common/wayland_util.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
+#include "ui/ozone/platform/wayland/host/wayland_event_source.h"
#include "ui/ozone/platform/wayland/host/wayland_pointer.h"
#include "ui/ozone/platform/wayland/host/wayland_popup.h"
#include "ui/ozone/platform/wayland/host/wayland_surface.h"
@@ -373,11 +375,8 @@ struct xdg_positioner* XDGPopupWrapperImpl::CreatePositionerStable(
if (!positioner)
return nullptr;
- auto* pointer = connection->pointer();
- uint32_t flags = 0;
- if (pointer)
- flags = pointer->GetFlagsWithKeyboardModifiers();
- bool is_right_click_menu = flags & EF_RIGHT_MOUSE_BUTTON;
+ bool is_right_click_menu =
+ connection->event_source()->IsPointerButtonPressed(EF_RIGHT_MOUSE_BUTTON);
// Different types of menu require different anchors, constraint adjustments,
// gravity and etc.
@@ -474,11 +473,8 @@ zxdg_positioner_v6* XDGPopupWrapperImpl::CreatePositionerV6(
if (!positioner)
return nullptr;
- auto* pointer = connection->pointer();
- uint32_t flags = 0;
- if (pointer)
- flags = pointer->GetFlagsWithKeyboardModifiers();
- bool is_right_click_menu = flags & EF_RIGHT_MOUSE_BUTTON;
+ bool is_right_click_menu =
+ connection->event_source()->IsPointerButtonPressed(EF_RIGHT_MOUSE_BUTTON);
// Different types of menu require different anchors, constraint adjustments,
// gravity and etc.
diff --git a/chromium/ui/ozone/platform/wayland/host/xdg_surface_wrapper_impl.h b/chromium/ui/ozone/platform/wayland/host/xdg_surface_wrapper_impl.h
index b34f4b2281e..ea1e81b44dc 100644
--- a/chromium/ui/ozone/platform/wayland/host/xdg_surface_wrapper_impl.h
+++ b/chromium/ui/ozone/platform/wayland/host/xdg_surface_wrapper_impl.h
@@ -68,7 +68,7 @@ class XDGSurfaceWrapperImpl : public ShellSurfaceWrapper {
static void CloseTopLevelV6(void* data,
struct zxdg_toplevel_v6* zxdg_toplevel_v6);
- xdg_surface* xdg_surface() const;
+ struct xdg_surface* xdg_surface() const;
zxdg_surface_v6* zxdg_surface() const;
private:
diff --git a/chromium/ui/ozone/platform/wayland/ozone_platform_wayland.cc b/chromium/ui/ozone/platform/wayland/ozone_platform_wayland.cc
index 949df2ac040..8ffb52c5213 100644
--- a/chromium/ui/ozone/platform/wayland/ozone_platform_wayland.cc
+++ b/chromium/ui/ozone/platform/wayland/ozone_platform_wayland.cc
@@ -72,12 +72,17 @@ constexpr OzonePlatform::PlatformProperties kWaylandPlatformProperties = {
/*custom_frame_pref_default=*/true,
/*use_system_title_bar=*/false,
- // Ozone/Wayland relies on the mojo communication when running in
- // !single_process.
- // TODO(msisov, rjkroege): Remove after http://crbug.com/806092.
- /*requires_mojo=*/true,
+ /*message_pump_type_for_gpu=*/base::MessagePumpType::DEFAULT,
- /*message_pump_type_for_gpu=*/base::MessagePumpType::DEFAULT};
+ /*supports_vulkan_swap_chain=*/false,
+
+ // Wayland doesn't provide clients with global screen coordinates. Instead,
+ // it forces clients to position windows relative to their top level windows
+ // if the have child-parent relationship. In case of toplevel windows,
+ // clients simply don't know their position on screens and always assume
+ // they are located at some arbitrary position.
+ /*ignore_screen_bounds_for_menus=*/true,
+};
class OzonePlatformWayland : public OzonePlatform {
public:
diff --git a/chromium/ui/ozone/platform/wayland/test/mock_surface.h b/chromium/ui/ozone/platform/wayland/test/mock_surface.h
index bbf63e41ea2..412d8386713 100644
--- a/chromium/ui/ozone/platform/wayland/test/mock_surface.h
+++ b/chromium/ui/ozone/platform/wayland/test/mock_surface.h
@@ -8,14 +8,14 @@
#include <memory>
#include <utility>
-#include <wayland-server-protocol-core.h>
+#include <wayland-server-protocol.h>
#include "base/macros.h"
#include "testing/gmock/include/gmock/gmock.h"
-#include "ui/ozone/platform/wayland/test/mock_xdg_popup.h"
#include "ui/ozone/platform/wayland/test/mock_xdg_surface.h"
#include "ui/ozone/platform/wayland/test/server_object.h"
#include "ui/ozone/platform/wayland/test/test_subsurface.h"
+#include "ui/ozone/platform/wayland/test/test_xdg_popup.h"
struct wl_resource;
diff --git a/chromium/ui/ozone/platform/wayland/test/mock_xdg_shell.cc b/chromium/ui/ozone/platform/wayland/test/mock_xdg_shell.cc
index cd76626a124..6edad195289 100644
--- a/chromium/ui/ozone/platform/wayland/test/mock_xdg_shell.cc
+++ b/chromium/ui/ozone/platform/wayland/test/mock_xdg_shell.cc
@@ -5,9 +5,9 @@
#include "ui/ozone/platform/wayland/test/mock_xdg_shell.h"
#include "ui/ozone/platform/wayland/test/mock_surface.h"
-#include "ui/ozone/platform/wayland/test/mock_xdg_popup.h"
#include "ui/ozone/platform/wayland/test/server_object.h"
#include "ui/ozone/platform/wayland/test/test_positioner.h"
+#include "ui/ozone/platform/wayland/test/test_xdg_popup.h"
namespace wl {
diff --git a/chromium/ui/ozone/platform/wayland/test/mock_xdg_surface.cc b/chromium/ui/ozone/platform/wayland/test/mock_xdg_surface.cc
index d0bd03add2b..7ffadf1e148 100644
--- a/chromium/ui/ozone/platform/wayland/test/mock_xdg_surface.cc
+++ b/chromium/ui/ozone/platform/wayland/test/mock_xdg_surface.cc
@@ -5,9 +5,9 @@
#include <xdg-shell-unstable-v6-server-protocol.h>
#include "ui/ozone/platform/wayland/test/mock_surface.h"
-#include "ui/ozone/platform/wayland/test/mock_xdg_popup.h"
#include "ui/ozone/platform/wayland/test/mock_xdg_surface.h"
#include "ui/ozone/platform/wayland/test/test_positioner.h"
+#include "ui/ozone/platform/wayland/test/test_xdg_popup.h"
namespace wl {
@@ -152,7 +152,7 @@ void GetXdgPopup(struct wl_client* client,
}
wl_resource* xdg_popup_resource =
- CreateResourceWithImpl<::testing::NiceMock<MockXdgPopup>>(
+ CreateResourceWithImpl<::testing::NiceMock<TestXdgPopup>>(
client, &xdg_popup_interface, wl_resource_get_version(resource),
&kXdgPopupImpl, id, resource);
@@ -161,21 +161,21 @@ void GetXdgPopup(struct wl_client* client,
return;
}
- auto* mock_xdg_popup = GetUserDataAs<MockXdgPopup>(xdg_popup_resource);
- DCHECK(mock_xdg_popup);
+ auto* test_xdg_popup = GetUserDataAs<TestXdgPopup>(xdg_popup_resource);
+ DCHECK(test_xdg_popup);
auto* positioner = GetUserDataAs<TestPositioner>(positioner_resource);
DCHECK(positioner);
- mock_xdg_popup->set_position(positioner->position());
- if (mock_xdg_popup->size().IsEmpty() ||
- mock_xdg_popup->anchor_rect().IsEmpty()) {
+ test_xdg_popup->set_position(positioner->position());
+ if (test_xdg_popup->size().IsEmpty() ||
+ test_xdg_popup->anchor_rect().IsEmpty()) {
wl_resource_post_error(resource, XDG_WM_BASE_ERROR_INVALID_POSITIONER,
"Positioner object is not complete");
return;
}
- mock_xdg_surface->set_xdg_popup(mock_xdg_popup);
+ mock_xdg_surface->set_xdg_popup(test_xdg_popup);
}
void GetZXdgPopupV6(struct wl_client* client,
@@ -197,7 +197,7 @@ void GetZXdgPopupV6(struct wl_client* client,
}
wl_resource* xdg_popup_resource =
- CreateResourceWithImpl<::testing::NiceMock<MockXdgPopup>>(
+ CreateResourceWithImpl<::testing::NiceMock<TestXdgPopup>>(
client, &zxdg_popup_v6_interface, wl_resource_get_version(resource),
&kZxdgPopupV6Impl, id, resource);
@@ -206,21 +206,21 @@ void GetZXdgPopupV6(struct wl_client* client,
return;
}
- auto* mock_xdg_popup = GetUserDataAs<MockXdgPopup>(xdg_popup_resource);
- DCHECK(mock_xdg_popup);
+ auto* test_xdg_popup = GetUserDataAs<TestXdgPopup>(xdg_popup_resource);
+ DCHECK(test_xdg_popup);
auto* positioner = GetUserDataAs<TestPositioner>(positioner_resource);
DCHECK(positioner);
- mock_xdg_popup->set_position(positioner->position());
- if (mock_xdg_popup->size().IsEmpty() ||
- mock_xdg_popup->anchor_rect().IsEmpty()) {
+ test_xdg_popup->set_position(positioner->position());
+ if (test_xdg_popup->size().IsEmpty() ||
+ test_xdg_popup->anchor_rect().IsEmpty()) {
wl_resource_post_error(resource, ZXDG_SHELL_V6_ERROR_INVALID_POSITIONER,
"Positioner object is not complete");
return;
}
- mock_xdg_surface->set_xdg_popup(mock_xdg_popup);
+ mock_xdg_surface->set_xdg_popup(test_xdg_popup);
}
const struct xdg_surface_interface kMockXdgSurfaceImpl = {
diff --git a/chromium/ui/ozone/platform/wayland/test/mock_xdg_surface.h b/chromium/ui/ozone/platform/wayland/test/mock_xdg_surface.h
index c41a6ed8fa3..0b83ed4fdda 100644
--- a/chromium/ui/ozone/platform/wayland/test/mock_xdg_surface.h
+++ b/chromium/ui/ozone/platform/wayland/test/mock_xdg_surface.h
@@ -12,8 +12,8 @@
#include <xdg-shell-unstable-v6-server-protocol.h>
#include "testing/gmock/include/gmock/gmock.h"
-#include "ui/ozone/platform/wayland/test/mock_xdg_popup.h"
#include "ui/ozone/platform/wayland/test/server_object.h"
+#include "ui/ozone/platform/wayland/test/test_xdg_popup.h"
struct wl_resource;
@@ -42,14 +42,14 @@ class MockXdgSurface : public ServerObject {
}
MockXdgTopLevel* xdg_toplevel() const { return xdg_toplevel_.get(); }
- void set_xdg_popup(MockXdgPopup* xdg_popup) { xdg_popup_ = xdg_popup; }
- MockXdgPopup* xdg_popup() const { return xdg_popup_; }
+ void set_xdg_popup(TestXdgPopup* xdg_popup) { xdg_popup_ = xdg_popup; }
+ TestXdgPopup* xdg_popup() const { return xdg_popup_; }
private:
// Has either toplevel role..
std::unique_ptr<MockXdgTopLevel> xdg_toplevel_;
// Or popup role.
- MockXdgPopup* xdg_popup_ = nullptr;
+ TestXdgPopup* xdg_popup_ = nullptr;
// MockSurface that is the ground for this xdg_surface.
wl_resource* surface_ = nullptr;
diff --git a/chromium/ui/ozone/platform/wayland/test/test_compositor.cc b/chromium/ui/ozone/platform/wayland/test/test_compositor.cc
index 88833029971..9a6244b0cb3 100644
--- a/chromium/ui/ozone/platform/wayland/test/test_compositor.cc
+++ b/chromium/ui/ozone/platform/wayland/test/test_compositor.cc
@@ -6,7 +6,6 @@
#include <wayland-server-core.h>
-#include "base/logging.h"
#include "ui/ozone/platform/wayland/test/mock_surface.h"
#include "ui/ozone/platform/wayland/test/server_object.h"
#include "ui/ozone/platform/wayland/test/test_region.h"
diff --git a/chromium/ui/ozone/platform/wayland/test/test_data_device.cc b/chromium/ui/ozone/platform/wayland/test/test_data_device.cc
index 2c6d2ad5e8f..fcd71d6e9c5 100644
--- a/chromium/ui/ozone/platform/wayland/test/test_data_device.cc
+++ b/chromium/ui/ozone/platform/wayland/test/test_data_device.cc
@@ -6,7 +6,7 @@
#include <wayland-server-core.h>
-#include "base/logging.h"
+#include "base/notreached.h"
#include "ui/ozone/platform/wayland/test/test_data_offer.h"
namespace wl {
diff --git a/chromium/ui/ozone/platform/wayland/test/test_data_device.h b/chromium/ui/ozone/platform/wayland/test/test_data_device.h
index f4f275eab0d..9ac3357ed53 100644
--- a/chromium/ui/ozone/platform/wayland/test/test_data_device.h
+++ b/chromium/ui/ozone/platform/wayland/test/test_data_device.h
@@ -5,7 +5,7 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_DATA_DEVICE_H_
#define UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_DATA_DEVICE_H_
-#include <wayland-server-protocol-core.h>
+#include <wayland-server-protocol.h>
#include "base/macros.h"
#include "ui/ozone/platform/wayland/test/server_object.h"
diff --git a/chromium/ui/ozone/platform/wayland/test/test_data_device_manager.h b/chromium/ui/ozone/platform/wayland/test/test_data_device_manager.h
index e274637f0c1..ace5051ea37 100644
--- a/chromium/ui/ozone/platform/wayland/test/test_data_device_manager.h
+++ b/chromium/ui/ozone/platform/wayland/test/test_data_device_manager.h
@@ -5,7 +5,7 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_DATA_DEVICE_MANAGER_H_
#define UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_DATA_DEVICE_MANAGER_H_
-#include <wayland-server-protocol-core.h>
+#include <wayland-server-protocol.h>
#include "base/macros.h"
#include "ui/ozone/platform/wayland/test/global_object.h"
diff --git a/chromium/ui/ozone/platform/wayland/test/test_data_offer.h b/chromium/ui/ozone/platform/wayland/test/test_data_offer.h
index 4ca6c586f9a..67080d3a0a9 100644
--- a/chromium/ui/ozone/platform/wayland/test/test_data_offer.h
+++ b/chromium/ui/ozone/platform/wayland/test/test_data_offer.h
@@ -8,7 +8,7 @@
#include <memory>
#include <string>
-#include <wayland-server-protocol-core.h>
+#include <wayland-server-protocol.h>
#include "base/files/scoped_file.h"
#include "base/macros.h"
diff --git a/chromium/ui/ozone/platform/wayland/test/test_data_source.h b/chromium/ui/ozone/platform/wayland/test/test_data_source.h
index 32592071f2d..3cfdbff7a69 100644
--- a/chromium/ui/ozone/platform/wayland/test/test_data_source.h
+++ b/chromium/ui/ozone/platform/wayland/test/test_data_source.h
@@ -5,7 +5,7 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_DATA_SOURCE_H_
#define UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_DATA_SOURCE_H_
-#include <wayland-server-protocol-core.h>
+#include <wayland-server-protocol.h>
#include <memory>
#include <string>
diff --git a/chromium/ui/ozone/platform/wayland/test/test_output.cc b/chromium/ui/ozone/platform/wayland/test/test_output.cc
index bbc6475cc07..1718d0d9bb5 100644
--- a/chromium/ui/ozone/platform/wayland/test/test_output.cc
+++ b/chromium/ui/ozone/platform/wayland/test/test_output.cc
@@ -4,7 +4,7 @@
#include "ui/ozone/platform/wayland/test/test_output.h"
-#include <wayland-server-protocol-core.h>
+#include <wayland-server-protocol.h>
namespace wl {
diff --git a/chromium/ui/ozone/platform/wayland/test/test_region.h b/chromium/ui/ozone/platform/wayland/test/test_region.h
index a0dd5829a39..11f0509029b 100644
--- a/chromium/ui/ozone/platform/wayland/test/test_region.h
+++ b/chromium/ui/ozone/platform/wayland/test/test_region.h
@@ -5,7 +5,7 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_REGION_H_
#define UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_REGION_H_
-#include <wayland-server-protocol-core.h>
+#include <wayland-server-protocol.h>
#include "third_party/skia/include/core/SkRegion.h"
diff --git a/chromium/ui/ozone/platform/wayland/test/test_seat.h b/chromium/ui/ozone/platform/wayland/test/test_seat.h
index 773f434f116..a4980549878 100644
--- a/chromium/ui/ozone/platform/wayland/test/test_seat.h
+++ b/chromium/ui/ozone/platform/wayland/test/test_seat.h
@@ -5,7 +5,7 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_SEAT_H_
#define UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_SEAT_H_
-#include <wayland-server-protocol-core.h>
+#include <wayland-server-protocol.h>
#include "base/macros.h"
#include "ui/ozone/platform/wayland/test/global_object.h"
diff --git a/chromium/ui/ozone/platform/wayland/test/test_subcompositor.cc b/chromium/ui/ozone/platform/wayland/test/test_subcompositor.cc
index cbb66349ada..6122e1f214f 100644
--- a/chromium/ui/ozone/platform/wayland/test/test_subcompositor.cc
+++ b/chromium/ui/ozone/platform/wayland/test/test_subcompositor.cc
@@ -6,7 +6,7 @@
#include <wayland-server-core.h>
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/ozone/platform/wayland/test/mock_surface.h"
#include "ui/ozone/platform/wayland/test/server_object.h"
#include "ui/ozone/platform/wayland/test/test_subsurface.h"
diff --git a/chromium/ui/ozone/platform/wayland/test/test_subsurface.h b/chromium/ui/ozone/platform/wayland/test/test_subsurface.h
index abf806500ca..d21f398f9c6 100644
--- a/chromium/ui/ozone/platform/wayland/test/test_subsurface.h
+++ b/chromium/ui/ozone/platform/wayland/test/test_subsurface.h
@@ -5,7 +5,7 @@
#ifndef UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_SUBSURFACE_H_
#define UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_SUBSURFACE_H_
-#include <wayland-server-protocol-core.h>
+#include <wayland-server-protocol.h>
#include <memory>
#include <utility>
diff --git a/chromium/ui/ozone/platform/wayland/test/mock_xdg_popup.cc b/chromium/ui/ozone/platform/wayland/test/test_xdg_popup.cc
index 4a92c79edab..f8268ed7cbe 100644
--- a/chromium/ui/ozone/platform/wayland/test/mock_xdg_popup.cc
+++ b/chromium/ui/ozone/platform/wayland/test/test_xdg_popup.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/ozone/platform/wayland/test/mock_xdg_popup.h"
+#include "ui/ozone/platform/wayland/test/test_xdg_popup.h"
#include "ui/ozone/platform/wayland/test/mock_xdg_surface.h"
@@ -14,7 +14,7 @@ void Grab(struct wl_client* client,
struct wl_resource* resource,
struct wl_resource* seat,
uint32_t serial) {
- GetUserDataAs<MockXdgPopup>(resource)->Grab(serial);
+ GetUserDataAs<TestXdgPopup>(resource)->set_grab_serial(serial);
}
} // namespace
@@ -29,13 +29,13 @@ const struct zxdg_popup_v6_interface kZxdgPopupV6Impl = {
&Grab, // grab
};
-MockXdgPopup::MockXdgPopup(wl_resource* resource, wl_resource* surface)
+TestXdgPopup::TestXdgPopup(wl_resource* resource, wl_resource* surface)
: ServerObject(resource), surface_(surface) {
auto* mock_xdg_surface = GetUserDataAs<MockXdgSurface>(surface_);
if (mock_xdg_surface)
mock_xdg_surface->set_xdg_popup(nullptr);
}
-MockXdgPopup::~MockXdgPopup() {}
+TestXdgPopup::~TestXdgPopup() {}
} // namespace wl
diff --git a/chromium/ui/ozone/platform/wayland/test/mock_xdg_popup.h b/chromium/ui/ozone/platform/wayland/test/test_xdg_popup.h
index 61a80513020..a3268bf369a 100644
--- a/chromium/ui/ozone/platform/wayland/test/mock_xdg_popup.h
+++ b/chromium/ui/ozone/platform/wayland/test/test_xdg_popup.h
@@ -2,16 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_OZONE_PLATFORM_WAYLAND_TEST_MOCK_XDG_POPUP_H_
-#define UI_OZONE_PLATFORM_WAYLAND_TEST_MOCK_XDG_POPUP_H_
+#ifndef UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_XDG_POPUP_H_
+#define UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_XDG_POPUP_H_
#include <utility>
#include <xdg-shell-server-protocol.h>
#include <xdg-shell-unstable-v6-server-protocol.h>
-#include "base/macros.h"
-#include "testing/gmock/include/gmock/gmock.h"
#include "ui/ozone/platform/wayland/test/server_object.h"
#include "ui/ozone/platform/wayland/test/test_positioner.h"
@@ -22,17 +20,21 @@ namespace wl {
extern const struct xdg_popup_interface kXdgPopupImpl;
extern const struct zxdg_popup_v6_interface kZxdgPopupV6Impl;
-class MockXdgPopup : public ServerObject {
+class TestXdgPopup : public ServerObject {
public:
- MockXdgPopup(wl_resource* resource, wl_resource* surface);
- ~MockXdgPopup() override;
-
- MOCK_METHOD1(Grab, void(uint32_t serial));
+ TestXdgPopup(wl_resource* resource, wl_resource* surface);
+ TestXdgPopup(const TestXdgPopup&) = delete;
+ TestXdgPopup& operator=(const TestXdgPopup&) = delete;
+ ~TestXdgPopup() override;
void set_position(struct TestPositioner::PopupPosition position) {
position_ = std::move(position);
}
+ // Returns and stores the serial used for grab.
+ uint32_t grab_serial() const { return grab_serial_; }
+ void set_grab_serial(uint32_t serial) { grab_serial_ = serial; }
+
gfx::Rect anchor_rect() const { return position_.anchor_rect; }
gfx::Size size() const { return position_.size; }
uint32_t anchor() const { return position_.anchor; }
@@ -47,9 +49,9 @@ class MockXdgPopup : public ServerObject {
// Ground surface for this popup.
wl_resource* surface_ = nullptr;
- DISALLOW_COPY_AND_ASSIGN(MockXdgPopup);
+ uint32_t grab_serial_ = 0;
};
} // namespace wl
-#endif // UI_OZONE_PLATFORM_WAYLAND_TEST_MOCK_XDG_POPUP_H_
+#endif // UI_OZONE_PLATFORM_WAYLAND_TEST_TEST_XDG_POPUP_H_
diff --git a/chromium/ui/ozone/platform/x11/BUILD.gn b/chromium/ui/ozone/platform/x11/BUILD.gn
index f1941921e42..fcdb99cdf60 100644
--- a/chromium/ui/ozone/platform/x11/BUILD.gn
+++ b/chromium/ui/ozone/platform/x11/BUILD.gn
@@ -12,14 +12,12 @@ source_set("x11") {
sources = [
"client_native_pixmap_factory_x11.cc",
"client_native_pixmap_factory_x11.h",
+ "gl_egl_utility_x11.cc",
+ "gl_egl_utility_x11.h",
"gl_ozone_glx.cc",
"gl_ozone_glx.h",
- "gl_surface_egl_ozone_x11.cc",
- "gl_surface_egl_ozone_x11.h",
"gl_surface_egl_readback_x11.cc",
"gl_surface_egl_readback_x11.h",
- "gl_surface_glx_ozone.cc",
- "gl_surface_glx_ozone.h",
"ozone_platform_x11.cc",
"ozone_platform_x11.h",
"x11_canvas_surface.cc",
@@ -34,11 +32,9 @@ source_set("x11") {
"x11_screen_ozone.h",
"x11_surface_factory.cc",
"x11_surface_factory.h",
- "x11_window_ozone.cc",
- "x11_window_ozone.h",
]
- public_deps = [ "//ui/base/mojom:cursor_type" ]
+ public_deps = [ "//ui/base/cursor/mojom:cursor_type" ]
deps = [
"//base",
@@ -47,9 +43,11 @@ source_set("x11") {
"//skia",
"//ui/base:base",
"//ui/base:buildflags",
+ "//ui/base:data_exchange",
"//ui/base/clipboard:clipboard_types",
"//ui/base/ime",
"//ui/base/x",
+ "//ui/base/x:gl",
"//ui/display/fake",
"//ui/events",
"//ui/events/devices",
@@ -70,8 +68,18 @@ source_set("x11") {
]
if (is_chromeos) {
+ sources += [
+ "x11_window_ozone_chromeos.cc",
+ "x11_window_ozone_chromeos.h",
+ ]
deps += [ "//ui/base/ime/chromeos" ]
} else {
+ sources += [
+ "x11_os_exchange_data_provider_ozone.cc",
+ "x11_os_exchange_data_provider_ozone.h",
+ "x11_window_ozone.cc",
+ "x11_window_ozone.h",
+ ]
deps += [ "//ui/base/ime/linux" ]
}
@@ -80,18 +88,13 @@ source_set("x11") {
}
if (use_gtk) {
- deps += [ "//ui/gtk:x" ]
+ deps += [ "//ui/gtk/x" ]
}
if (use_xkbcommon) {
configs += [ "//ui/events/ozone/layout:xkbcommon" ]
}
- configs += [
- "//build/config/linux:x11",
- "//build/config/linux:xrandr",
- ]
-
public_configs = [ "//third_party/khronos:khronos_headers" ]
}
diff --git a/chromium/ui/ozone/platform/x11/DEPS b/chromium/ui/ozone/platform/x11/DEPS
index c4251a75884..3d70447f3fe 100644
--- a/chromium/ui/ozone/platform/x11/DEPS
+++ b/chromium/ui/ozone/platform/x11/DEPS
@@ -2,5 +2,5 @@ include_rules = [
"+ui/base/x",
"+ui/base",
"+ui/gtk/gtk_ui_delegate.h",
- "+ui/gtk/gtk_ui_delegate_x11.h",
+ "+ui/gtk/x/gtk_ui_delegate_x11.h",
]
diff --git a/chromium/ui/ozone/platform/x11/OWNERS b/chromium/ui/ozone/platform/x11/OWNERS
index 65aaa3134f6..3affaeee636 100644
--- a/chromium/ui/ozone/platform/x11/OWNERS
+++ b/chromium/ui/ozone/platform/x11/OWNERS
@@ -1 +1,4 @@
kylechar@chromium.org
+msisov@igalia.com
+nickdiego@igalia.com
+thomasanderson@chromium.org
diff --git a/chromium/ui/ozone/platform/x11/gl_egl_utility_x11.cc b/chromium/ui/ozone/platform/x11/gl_egl_utility_x11.cc
new file mode 100644
index 00000000000..5b6673be54e
--- /dev/null
+++ b/chromium/ui/ozone/platform/x11/gl_egl_utility_x11.cc
@@ -0,0 +1,25 @@
+// Copyright 2020 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 "ui/ozone/platform/x11/gl_egl_utility_x11.h"
+
+#include "ui/base/x/x11_gl_egl_utility.h"
+
+namespace ui {
+
+GLEGLUtilityX11::GLEGLUtilityX11() = default;
+GLEGLUtilityX11::~GLEGLUtilityX11() = default;
+
+void GLEGLUtilityX11::GetAdditionalEGLAttributes(
+ EGLenum platform_type,
+ std::vector<EGLAttrib>* display_attributes) {
+ GetPlatformExtraDisplayAttribs(platform_type, display_attributes);
+}
+
+void GLEGLUtilityX11::ChooseEGLAlphaAndBufferSize(EGLint* alpha_size,
+ EGLint* buffer_size) {
+ ChoosePlatformCustomAlphaAndBufferSize(alpha_size, buffer_size);
+}
+
+} // namespace ui
diff --git a/chromium/ui/ozone/platform/x11/gl_egl_utility_x11.h b/chromium/ui/ozone/platform/x11/gl_egl_utility_x11.h
new file mode 100644
index 00000000000..e9a9981bbe2
--- /dev/null
+++ b/chromium/ui/ozone/platform/x11/gl_egl_utility_x11.h
@@ -0,0 +1,30 @@
+// Copyright 2020 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 UI_OZONE_PLATFORM_X11_GL_EGL_UTILITY_X11_H_
+#define UI_OZONE_PLATFORM_X11_GL_EGL_UTILITY_X11_H_
+
+#include "ui/ozone/public/platform_gl_egl_utility.h"
+
+namespace ui {
+
+// Allows EGL to ask platforms for platform specific EGL attributes.
+class GLEGLUtilityX11 : public PlatformGLEGLUtility {
+ public:
+ GLEGLUtilityX11();
+ ~GLEGLUtilityX11() override;
+ GLEGLUtilityX11(const GLEGLUtilityX11& util) = delete;
+ GLEGLUtilityX11& operator=(const GLEGLUtilityX11& util) = delete;
+
+ // PlatformGLEGLUtility overrides:
+ void GetAdditionalEGLAttributes(
+ EGLenum platform_type,
+ std::vector<EGLAttrib>* display_attributes) override;
+ void ChooseEGLAlphaAndBufferSize(EGLint* alpha_size,
+ EGLint* buffer_size) override;
+};
+
+} // namespace ui
+
+#endif // UI_OZONE_PLATFORM_X11_GL_EGL_UTILITY_X11_H_
diff --git a/chromium/ui/ozone/platform/x11/gl_ozone_glx.cc b/chromium/ui/ozone/platform/x11/gl_ozone_glx.cc
index 520c5223457..5a6a63ee4cf 100644
--- a/chromium/ui/ozone/platform/x11/gl_ozone_glx.cc
+++ b/chromium/ui/ozone/platform/x11/gl_ozone_glx.cc
@@ -9,7 +9,7 @@
#include "ui/gl/gl_context_glx.h"
#include "ui/gl/gl_gl_api_implementation.h"
#include "ui/gl/gl_glx_api_implementation.h"
-#include "ui/ozone/platform/x11/gl_surface_glx_ozone.h"
+#include "ui/gl/gl_surface_glx_x11.h"
namespace ui {
@@ -97,7 +97,7 @@ scoped_refptr<gl::GLContext> GLOzoneGLX::CreateGLContext(
scoped_refptr<gl::GLSurface> GLOzoneGLX::CreateViewGLSurface(
gfx::AcceleratedWidget window) {
- return gl::InitializeGLSurface(new GLSurfaceGLXOzone(window));
+ return gl::InitializeGLSurface(new gl::GLSurfaceGLXX11(window));
}
scoped_refptr<gl::GLSurface> GLOzoneGLX::CreateSurfacelessViewGLSurface(
diff --git a/chromium/ui/ozone/platform/x11/gl_surface_egl_ozone_x11.cc b/chromium/ui/ozone/platform/x11/gl_surface_egl_ozone_x11.cc
deleted file mode 100644
index 71d50ffa607..00000000000
--- a/chromium/ui/ozone/platform/x11/gl_surface_egl_ozone_x11.cc
+++ /dev/null
@@ -1,100 +0,0 @@
-// Copyright 2017 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 "ui/ozone/platform/x11/gl_surface_egl_ozone_x11.h"
-
-#include "ui/gfx/x/x11.h"
-#include "ui/gfx/x/x11_types.h"
-#include "ui/gl/egl_util.h"
-
-namespace ui {
-
-GLSurfaceEGLOzoneX11::GLSurfaceEGLOzoneX11(EGLNativeWindowType window)
- : NativeViewGLSurfaceEGL(window, nullptr) {}
-
-EGLConfig GLSurfaceEGLOzoneX11::GetConfig() {
- // Try matching the window depth with an alpha channel, because we're worried
- // the destination alpha width could constrain blending precision.
- const int kBufferSizeOffset = 1;
- const int kAlphaSizeOffset = 3;
- EGLint config_attribs[] = {EGL_BUFFER_SIZE,
- ~0, // To be replaced.
- EGL_ALPHA_SIZE,
- 8,
- EGL_BLUE_SIZE,
- 8,
- EGL_GREEN_SIZE,
- 8,
- EGL_RED_SIZE,
- 8,
- EGL_RENDERABLE_TYPE,
- EGL_OPENGL_ES2_BIT,
- EGL_SURFACE_TYPE,
- EGL_WINDOW_BIT,
- EGL_NONE};
-
- // Get the depth of XWindow for surface.
- XWindowAttributes win_attribs;
- if (XGetWindowAttributes(gfx::GetXDisplay(), window_, &win_attribs)) {
- config_attribs[kBufferSizeOffset] = win_attribs.depth;
- }
-
- EGLDisplay display = GetDisplay();
-
- EGLConfig config;
- EGLint num_configs;
- if (!eglChooseConfig(display, config_attribs, &config, 1, &num_configs)) {
- LOG(ERROR) << "eglChooseConfig failed with error "
- << GetLastEGLErrorString();
- return nullptr;
- }
-
- if (num_configs > 0) {
- EGLint config_depth;
- if (!eglGetConfigAttrib(display, config, EGL_BUFFER_SIZE, &config_depth)) {
- LOG(ERROR) << "eglGetConfigAttrib failed with error "
- << GetLastEGLErrorString();
- return nullptr;
- }
- if (config_depth == config_attribs[kBufferSizeOffset]) {
- return config;
- }
- }
-
- // Try without an alpha channel.
- config_attribs[kAlphaSizeOffset] = 0;
- if (!eglChooseConfig(display, config_attribs, &config, 1, &num_configs)) {
- LOG(ERROR) << "eglChooseConfig failed with error "
- << GetLastEGLErrorString();
- return nullptr;
- }
-
- if (num_configs == 0) {
- LOG(ERROR) << "No suitable EGL configs found.";
- return nullptr;
- }
- return config;
-}
-
-bool GLSurfaceEGLOzoneX11::Resize(const gfx::Size& size,
- float scale_factor,
- const gfx::ColorSpace& color_space,
- bool has_alpha) {
- if (size == GetSize())
- return true;
-
- size_ = size;
-
- eglWaitGL();
- XResizeWindow(gfx::GetXDisplay(), window_, size.width(), size.height());
- eglWaitNative(EGL_CORE_NATIVE_ENGINE);
-
- return true;
-}
-
-GLSurfaceEGLOzoneX11::~GLSurfaceEGLOzoneX11() {
- Destroy();
-}
-
-} // namespace ui
diff --git a/chromium/ui/ozone/platform/x11/gl_surface_egl_ozone_x11.h b/chromium/ui/ozone/platform/x11/gl_surface_egl_ozone_x11.h
deleted file mode 100644
index eab987a95b1..00000000000
--- a/chromium/ui/ozone/platform/x11/gl_surface_egl_ozone_x11.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2017 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 UI_OZONE_PLATFORM_X11_GL_SURFACE_EGL_OZONE_X11_H_
-#define UI_OZONE_PLATFORM_X11_GL_SURFACE_EGL_OZONE_X11_H_
-
-#include "base/macros.h"
-#include "ui/gfx/geometry/size.h"
-#include "ui/gl/gl_surface_egl.h"
-
-namespace ui {
-
-// GLSurface implementation for Ozone X11 EGL. This does not create a new
-// XWindow or observe XExpose events like GLSurfaceEGLX11 does.
-class GLSurfaceEGLOzoneX11 : public gl::NativeViewGLSurfaceEGL {
- public:
- explicit GLSurfaceEGLOzoneX11(EGLNativeWindowType window);
-
- // gl::NativeViewGLSurfaceEGL:
- EGLConfig GetConfig() override;
- bool Resize(const gfx::Size& size,
- float scale_factor,
- const gfx::ColorSpace& color_space,
- bool has_alpha) override;
-
- private:
- ~GLSurfaceEGLOzoneX11() override;
-
- DISALLOW_COPY_AND_ASSIGN(GLSurfaceEGLOzoneX11);
-};
-
-} // namespace ui
-
-#endif // UI_OZONE_PLATFORM_X11_GL_SURFACE_EGL_OZONE_X11_H_
diff --git a/chromium/ui/ozone/platform/x11/gl_surface_glx_ozone.cc b/chromium/ui/ozone/platform/x11/gl_surface_glx_ozone.cc
deleted file mode 100644
index 172f62afd01..00000000000
--- a/chromium/ui/ozone/platform/x11/gl_surface_glx_ozone.cc
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "ui/ozone/platform/x11/gl_surface_glx_ozone.h"
-
-#include "ui/gfx/x/x11.h"
-
-namespace ui {
-
-GLSurfaceGLXOzone::GLSurfaceGLXOzone(gfx::AcceleratedWidget window)
- : NativeViewGLSurfaceGLX(window) {}
-
-GLSurfaceGLXOzone::~GLSurfaceGLXOzone() {
- Destroy();
-}
-
-void GLSurfaceGLXOzone::RegisterEvents() {
- auto* event_source = X11EventSource::GetInstance();
- // Can be null in tests, when we don't care about Exposes.
- if (event_source) {
- XSelectInput(gfx::GetXDisplay(), window(), ExposureMask);
- event_source->AddXEventDispatcher(this);
- }
-}
-
-void GLSurfaceGLXOzone::UnregisterEvents() {
- auto* event_source = X11EventSource::GetInstance();
- if (event_source)
- event_source->RemoveXEventDispatcher(this);
-}
-
-bool GLSurfaceGLXOzone::DispatchXEvent(XEvent* event) {
- if (!CanHandleEvent(event))
- return false;
-
- ForwardExposeEvent(event);
- return true;
-}
-
-} // namespace ui
diff --git a/chromium/ui/ozone/platform/x11/gl_surface_glx_ozone.h b/chromium/ui/ozone/platform/x11/gl_surface_glx_ozone.h
deleted file mode 100644
index acf51a0c38b..00000000000
--- a/chromium/ui/ozone/platform/x11/gl_surface_glx_ozone.h
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef UI_OZONE_PLATFORM_X11_GL_SURFACE_GLX_OZONE_H_
-#define UI_OZONE_PLATFORM_X11_GL_SURFACE_GLX_OZONE_H_
-
-#include "base/macros.h"
-#include "ui/events/platform/x11/x11_event_source.h"
-#include "ui/gl/gl_surface_glx.h"
-
-namespace ui {
-
-// Ozone specific implementation of GLX surface. Registers as a XEventDispatcher
-// to handle XEvents.
-class GLSurfaceGLXOzone : public gl::NativeViewGLSurfaceGLX,
- public XEventDispatcher {
- public:
- explicit GLSurfaceGLXOzone(gfx::AcceleratedWidget window);
-
- protected:
- ~GLSurfaceGLXOzone() override;
-
- // NativeViewGLSurfaceGLX:
- void RegisterEvents() override;
- void UnregisterEvents() override;
-
- // XEventDispatcher:
- bool DispatchXEvent(XEvent* xevent) override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(GLSurfaceGLXOzone);
-};
-
-} // namespace ui
-
-#endif // UI_OZONE_PLATFORM_X11_GL_SURFACE_GLX_OZONE_H_
diff --git a/chromium/ui/ozone/platform/x11/ozone_platform_x11.cc b/chromium/ui/ozone/platform/x11/ozone_platform_x11.cc
index 78ea2a95e7e..2d26ced5587 100644
--- a/chromium/ui/ozone/platform/x11/ozone_platform_x11.cc
+++ b/chromium/ui/ozone/platform/x11/ozone_platform_x11.cc
@@ -9,7 +9,10 @@
#include "base/message_loop/message_pump_type.h"
#include "base/strings/utf_string_conversions.h"
+#include "build/build_config.h"
#include "ui/base/buildflags.h"
+#include "ui/base/dragdrop/os_exchange_data_provider_factory.h"
+#include "ui/base/dragdrop/os_exchange_data_provider_factory_ozone.h"
#include "ui/base/ime/linux/linux_input_method_context_factory.h"
#include "ui/base/x/x11_util.h"
#include "ui/display/fake/fake_display_delegate.h"
@@ -18,9 +21,9 @@
#include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/native_widget_types.h"
-#include "ui/gfx/x/x11_connection.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/ozone/common/stub_overlay_manager.h"
+#include "ui/ozone/platform/x11/gl_egl_utility_x11.h"
#include "ui/ozone/platform/x11/x11_clipboard_ozone.h"
#include "ui/ozone/platform/x11/x11_cursor_factory_ozone.h"
#include "ui/ozone/platform/x11/x11_screen_ozone.h"
@@ -34,14 +37,16 @@
#include "ui/platform_window/platform_window_init_properties.h"
#if defined(OS_CHROMEOS)
+#include "ui/base/dragdrop/os_exchange_data_provider_aura.h"
#include "ui/base/ime/chromeos/input_method_chromeos.h"
#else
#include "ui/base/ime/linux/input_method_auralinux.h"
+#include "ui/ozone/platform/x11/x11_os_exchange_data_provider_ozone.h"
#endif
#if BUILDFLAG(USE_GTK)
-#include "ui/gtk/gtk_ui_delegate.h" // nogncheck
-#include "ui/gtk/gtk_ui_delegate_x11.h" // nogncheck
+#include "ui/gtk/gtk_ui_delegate.h" // nogncheck
+#include "ui/gtk/x/gtk_ui_delegate_x11.h" // nogncheck
#endif
#if BUILDFLAG(USE_XKBCOMMON)
@@ -59,16 +64,18 @@ constexpr OzonePlatform::PlatformProperties kX11PlatformProperties{
/*needs_view_token=*/false,
/*custom_frame_pref_default=*/false,
/*use_system_title_bar=*/true,
- /*requires_mojo=*/false,
// When the Ozone X11 backend is running, use a UI loop to grab Expose
// events. See GLSurfaceGLX and https://crbug.com/326995.
- /*message_pump_type_for_gpu=*/base::MessagePumpType::UI};
+ /*message_pump_type_for_gpu=*/base::MessagePumpType::UI,
+ /*supports_vulkan_swap_chain=*/true,
+};
// Singleton OzonePlatform implementation for X11 platform.
-class OzonePlatformX11 : public OzonePlatform {
+class OzonePlatformX11 : public OzonePlatform,
+ public ui::OSExchangeDataProviderFactoryOzone {
public:
- OzonePlatformX11() {}
+ OzonePlatformX11() { SetInstance(this); }
~OzonePlatformX11() override {}
@@ -122,6 +129,10 @@ class OzonePlatformX11 : public OzonePlatform {
return clipboard_.get();
}
+ PlatformGLEGLUtility* GetPlatformGLEGLUtility() override {
+ return gl_egl_utility_.get();
+ }
+
std::unique_ptr<InputMethod> CreateInputMethod(
internal::InputMethodDelegate* delegate,
gfx::AcceleratedWidget) override {
@@ -138,6 +149,14 @@ class OzonePlatformX11 : public OzonePlatform {
#endif
}
+ std::unique_ptr<OSExchangeDataProvider> CreateProvider() override {
+#if defined(OS_CHROMEOS)
+ return std::make_unique<OSExchangeDataProviderAura>();
+#else
+ return std::make_unique<X11OSExchangeDataProviderOzone>();
+#endif
+ }
+
const PlatformProperties& GetPlatformProperties() override {
return kX11PlatformProperties;
}
@@ -180,6 +199,7 @@ class OzonePlatformX11 : public OzonePlatform {
CreatePlatformEventSource();
surface_factory_ozone_ = std::make_unique<X11SurfaceFactory>();
+ gl_egl_utility_ = std::make_unique<GLEGLUtilityX11>();
}
private:
@@ -188,11 +208,6 @@ class OzonePlatformX11 : public OzonePlatform {
if (common_initialized_)
return;
- // Always initialize in multi-thread mode, since this is used only during
- // development.
- // TODO(crbug.com/1024477): Initialize Xlib threads only when required
- gfx::InitializeThreadedX11();
-
// If XOpenDisplay() failed there is nothing we can do. Crash here instead
// of crashing later. If you are crashing here, make sure there is an X
// server running and $DISPLAY is set.
@@ -228,6 +243,7 @@ class OzonePlatformX11 : public OzonePlatform {
// Objects in the GPU process.
std::unique_ptr<X11SurfaceFactory> surface_factory_ozone_;
+ std::unique_ptr<GLEGLUtilityX11> gl_egl_utility_;
// Objects in both UI and GPU process.
std::unique_ptr<X11EventSource> event_source_;
diff --git a/chromium/ui/ozone/platform/x11/x11_cursor_factory_ozone.cc b/chromium/ui/ozone/platform/x11/x11_cursor_factory_ozone.cc
index e981ade21b6..1b9b47ff5f9 100644
--- a/chromium/ui/ozone/platform/x11/x11_cursor_factory_ozone.cc
+++ b/chromium/ui/ozone/platform/x11/x11_cursor_factory_ozone.cc
@@ -7,7 +7,7 @@
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/cursor/cursor_lookup.h"
#include "ui/base/cursor/cursors_aura.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/gfx/geometry/point.h"
namespace ui {
diff --git a/chromium/ui/ozone/platform/x11/x11_cursor_factory_ozone.h b/chromium/ui/ozone/platform/x11/x11_cursor_factory_ozone.h
index 05347bd6cd8..76efeeb526d 100644
--- a/chromium/ui/ozone/platform/x11/x11_cursor_factory_ozone.h
+++ b/chromium/ui/ozone/platform/x11/x11_cursor_factory_ozone.h
@@ -11,7 +11,7 @@
#include "base/macros.h"
#include "ui/base/cursor/cursor.h"
-#include "ui/base/mojom/cursor_type.mojom-forward.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-forward.h"
#include "ui/gfx/x/x11.h"
#include "ui/ozone/platform/x11/x11_cursor_ozone.h"
#include "ui/ozone/public/cursor_factory_ozone.h"
diff --git a/chromium/ui/ozone/platform/x11/x11_cursor_ozone.cc b/chromium/ui/ozone/platform/x11/x11_cursor_ozone.cc
index df03b259ebd..64eb043d301 100644
--- a/chromium/ui/ozone/platform/x11/x11_cursor_ozone.cc
+++ b/chromium/ui/ozone/platform/x11/x11_cursor_ozone.cc
@@ -4,7 +4,7 @@
#include "ui/ozone/platform/x11/x11_cursor_ozone.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/geometry/point.h"
@@ -12,40 +12,9 @@
namespace ui {
-namespace {
-
-// Converts a SKBitmap to unpremul alpha.
-SkBitmap ConvertSkBitmapToUnpremul(const SkBitmap& bitmap) {
- DCHECK_NE(bitmap.alphaType(), kUnpremul_SkAlphaType);
-
- SkImageInfo image_info = SkImageInfo::MakeN32(bitmap.width(), bitmap.height(),
- kUnpremul_SkAlphaType);
- SkBitmap converted_bitmap;
- converted_bitmap.allocPixels(image_info);
- bitmap.readPixels(image_info, converted_bitmap.getPixels(),
- image_info.minRowBytes(), 0, 0);
-
- return converted_bitmap;
-}
-
-// Creates an XCursorImage for cursor bitmap.
-XcursorImage* CreateXCursorImage(const SkBitmap& bitmap,
- const gfx::Point& hotspot) {
- // X11 expects bitmap with unpremul alpha. If bitmap is premul then convert,
- // otherwise semi-transparent parts of cursor will look strange.
- if (bitmap.alphaType() != kUnpremul_SkAlphaType) {
- SkBitmap converted_bitmap = ConvertSkBitmapToUnpremul(bitmap);
- return SkBitmapToXcursorImage(&converted_bitmap, hotspot);
- } else {
- return SkBitmapToXcursorImage(&bitmap, hotspot);
- }
-}
-
-} // namespace
-
X11CursorOzone::X11CursorOzone(const SkBitmap& bitmap,
const gfx::Point& hotspot) {
- XcursorImage* image = CreateXCursorImage(bitmap, hotspot);
+ XcursorImage* image = SkBitmapToXcursorImage(bitmap, hotspot);
xcursor_ = XcursorImageLoadCursor(gfx::GetXDisplay(), image);
XcursorImageDestroy(image);
}
@@ -58,7 +27,7 @@ X11CursorOzone::X11CursorOzone(const std::vector<SkBitmap>& bitmaps,
XcursorImages* images = XcursorImagesCreate(bitmaps.size());
images->nimage = bitmaps.size();
for (size_t frame = 0; frame < bitmaps.size(); ++frame) {
- XcursorImage* x_image = CreateXCursorImage(bitmaps[frame], hotspot);
+ XcursorImage* x_image = SkBitmapToXcursorImage(bitmaps[frame], hotspot);
x_image->delay = frame_delay_ms;
images->images[frame] = x_image;
}
diff --git a/chromium/ui/ozone/platform/x11/x11_os_exchange_data_provider_ozone.cc b/chromium/ui/ozone/platform/x11/x11_os_exchange_data_provider_ozone.cc
new file mode 100644
index 00000000000..7a31cb62ec9
--- /dev/null
+++ b/chromium/ui/ozone/platform/x11/x11_os_exchange_data_provider_ozone.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2020 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 "ui/ozone/platform/x11/x11_os_exchange_data_provider_ozone.h"
+
+#include <utility>
+
+#include "base/logging.h"
+#include "ui/base/x/selection_utils.h"
+
+namespace ui {
+
+X11OSExchangeDataProviderOzone::X11OSExchangeDataProviderOzone(
+ XID x_window,
+ const SelectionFormatMap& selection)
+ : XOSExchangeDataProvider(x_window, selection) {}
+
+X11OSExchangeDataProviderOzone::X11OSExchangeDataProviderOzone() {
+ DCHECK(own_window());
+ X11EventSource::GetInstance()->AddXEventDispatcher(this);
+}
+
+X11OSExchangeDataProviderOzone::~X11OSExchangeDataProviderOzone() {
+ if (own_window())
+ X11EventSource::GetInstance()->RemoveXEventDispatcher(this);
+}
+
+std::unique_ptr<OSExchangeDataProvider> X11OSExchangeDataProviderOzone::Clone()
+ const {
+ std::unique_ptr<X11OSExchangeDataProviderOzone> ret(
+ new X11OSExchangeDataProviderOzone());
+ ret->set_format_map(format_map());
+ return std::move(ret);
+}
+
+bool X11OSExchangeDataProviderOzone::DispatchXEvent(XEvent* xev) {
+ if (xev->xany.window != x_window())
+ return false;
+
+ switch (xev->type) {
+ case SelectionRequest:
+ selection_owner().OnSelectionRequest(*xev);
+ return true;
+ default:
+ NOTIMPLEMENTED();
+ }
+ return false;
+}
+
+} // namespace ui
diff --git a/chromium/ui/ozone/platform/x11/x11_os_exchange_data_provider_ozone.h b/chromium/ui/ozone/platform/x11/x11_os_exchange_data_provider_ozone.h
new file mode 100644
index 00000000000..7a0637318fc
--- /dev/null
+++ b/chromium/ui/ozone/platform/x11/x11_os_exchange_data_provider_ozone.h
@@ -0,0 +1,35 @@
+// Copyright (c) 2020 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 UI_OZONE_PLATFORM_X11_X11_OS_EXCHANGE_DATA_PROVIDER_OZONE_H_
+#define UI_OZONE_PLATFORM_X11_X11_OS_EXCHANGE_DATA_PROVIDER_OZONE_H_
+
+#include "ui/base/x/x11_os_exchange_data_provider.h"
+#include "ui/events/platform/x11/x11_event_source.h"
+
+namespace ui {
+
+// OSExchangeDataProvider implementation for Ozone/X11.
+class X11OSExchangeDataProviderOzone : public XOSExchangeDataProvider,
+ public XEventDispatcher {
+ public:
+ X11OSExchangeDataProviderOzone(XID x_window,
+ const SelectionFormatMap& selection);
+ X11OSExchangeDataProviderOzone();
+ ~X11OSExchangeDataProviderOzone() override;
+ X11OSExchangeDataProviderOzone(const X11OSExchangeDataProviderOzone&) =
+ delete;
+ X11OSExchangeDataProviderOzone& operator=(
+ const X11OSExchangeDataProviderOzone&) = delete;
+
+ // OSExchangeDataProvider:
+ std::unique_ptr<OSExchangeDataProvider> Clone() const override;
+
+ // XEventDispatcher:
+ bool DispatchXEvent(XEvent* xev) override;
+};
+
+} // namespace ui
+
+#endif // UI_OZONE_PLATFORM_X11_X11_OS_EXCHANGE_DATA_PROVIDER_OZONE_H_
diff --git a/chromium/ui/ozone/platform/x11/x11_screen_ozone.cc b/chromium/ui/ozone/platform/x11/x11_screen_ozone.cc
index 5d5b60fdd1f..5e9cf05b0a3 100644
--- a/chromium/ui/ozone/platform/x11/x11_screen_ozone.cc
+++ b/chromium/ui/ozone/platform/x11/x11_screen_ozone.cc
@@ -11,6 +11,7 @@
#include "ui/gfx/font_render_params.h"
#include "ui/gfx/geometry/dip_util.h"
#include "ui/ozone/platform/x11/x11_window_ozone.h"
+#include "ui/platform_window/x11/x11_topmost_window_finder.h"
#include "ui/platform_window/x11/x11_window_manager.h"
namespace ui {
@@ -31,65 +32,6 @@ gfx::Point PixelToDIPPoint(const gfx::Point& pixel_point) {
return gfx::ConvertPointToDIP(GetDeviceScaleFactor(), pixel_point);
}
-// ui::EnumerateTopLevelWindows API is used here to retrieve the x11 window
-// stack, so that windows are checked in descending z-order, covering window
-// overlapping cases gracefully.
-// TODO(nickdiego): Consider refactoring ui::EnumerateTopLevelWindows to use
-// lambda/callback instead of Delegate interface.
-class LocalProcessWindowFinder : public EnumerateWindowsDelegate {
- public:
- LocalProcessWindowFinder() = default;
- ~LocalProcessWindowFinder() override = default;
-
- X11Window* FindWindowAt(const gfx::Point& screen_point_in_pixels);
-
- private:
- // ui::EnumerateWindowsDelegate
- bool ShouldStopIterating(XID xid) override;
-
- // Returns true if |window| is visible and contains the
- // |screen_point_in_pixels_| within its bounds, even if custom shape is used.
- bool MatchWindow(X11Window* window) const;
-
- X11Window* window_found_ = nullptr;
- gfx::Point screen_point_in_pixels_;
-};
-
-X11Window* LocalProcessWindowFinder::FindWindowAt(
- const gfx::Point& screen_point_in_pixels) {
- screen_point_in_pixels_ = screen_point_in_pixels;
- ui::EnumerateTopLevelWindows(this);
- return window_found_;
-}
-
-bool LocalProcessWindowFinder::ShouldStopIterating(XID xid) {
- X11Window* window = X11WindowManager::GetInstance()->GetWindow(xid);
- if (!window || !MatchWindow(window))
- return false;
-
- window_found_ = window;
- return true;
-}
-
-bool LocalProcessWindowFinder::MatchWindow(X11Window* window) const {
- DCHECK(window);
-
- if (!window->IsVisible())
- return false;
-
- gfx::Rect window_bounds = window->GetOutterBounds();
- if (!window_bounds.Contains(screen_point_in_pixels_))
- return false;
-
- ::Region shape = window->shape();
- if (!shape)
- return true;
-
- gfx::Point window_point(screen_point_in_pixels_);
- window_point.Offset(-window_bounds.origin().x(), -window_bounds.origin().y());
- return XPointInRegion(shape, window_point.x(), window_point.y()) == x11::True;
-}
-
} // namespace
X11ScreenOzone::X11ScreenOzone()
@@ -143,9 +85,15 @@ gfx::Point X11ScreenOzone::GetCursorScreenPoint() const {
gfx::AcceleratedWidget X11ScreenOzone::GetAcceleratedWidgetAtScreenPoint(
const gfx::Point& point) const {
- LocalProcessWindowFinder finder;
- X11Window* window = finder.FindWindowAt(point);
- return window ? window->GetWidget() : gfx::kNullAcceleratedWidget;
+ X11TopmostWindowFinder finder;
+ return finder.FindWindowAt(point);
+}
+
+gfx::AcceleratedWidget X11ScreenOzone::GetLocalProcessWidgetAtPoint(
+ const gfx::Point& point,
+ const std::set<gfx::AcceleratedWidget>& ignore) const {
+ X11TopmostWindowFinder finder;
+ return finder.FindLocalProcessWindowAt(point, ignore);
}
display::Display X11ScreenOzone::GetDisplayNearestPoint(
diff --git a/chromium/ui/ozone/platform/x11/x11_screen_ozone.h b/chromium/ui/ozone/platform/x11/x11_screen_ozone.h
index 32493fca0c6..02806ba53fc 100644
--- a/chromium/ui/ozone/platform/x11/x11_screen_ozone.h
+++ b/chromium/ui/ozone/platform/x11/x11_screen_ozone.h
@@ -39,6 +39,9 @@ class X11ScreenOzone : public PlatformScreen,
gfx::Point GetCursorScreenPoint() const override;
gfx::AcceleratedWidget GetAcceleratedWidgetAtScreenPoint(
const gfx::Point& point) const override;
+ gfx::AcceleratedWidget GetLocalProcessWidgetAtPoint(
+ const gfx::Point& point,
+ const std::set<gfx::AcceleratedWidget>& ignore) const override;
display::Display GetDisplayNearestPoint(
const gfx::Point& point) const override;
display::Display GetDisplayMatching(
diff --git a/chromium/ui/ozone/platform/x11/x11_surface_factory.cc b/chromium/ui/ozone/platform/x11/x11_surface_factory.cc
index fa2289015ef..a0daef0e754 100644
--- a/chromium/ui/ozone/platform/x11/x11_surface_factory.cc
+++ b/chromium/ui/ozone/platform/x11/x11_surface_factory.cc
@@ -10,10 +10,10 @@
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gl/gl_surface_egl.h"
+#include "ui/gl/gl_surface_egl_x11_gles2.h"
#include "ui/ozone/common/egl_util.h"
#include "ui/ozone/common/gl_ozone_egl.h"
#include "ui/ozone/platform/x11/gl_ozone_glx.h"
-#include "ui/ozone/platform/x11/gl_surface_egl_ozone_x11.h"
#include "ui/ozone/platform/x11/gl_surface_egl_readback_x11.h"
#include "ui/ozone/platform/x11/x11_canvas_surface.h"
@@ -43,7 +43,7 @@ class GLOzoneEGLX11 : public GLOzoneEGL {
base::MakeRefCounted<GLSurfaceEglReadbackX11>(window));
} else {
return gl::InitializeGLSurface(
- base::MakeRefCounted<GLSurfaceEGLOzoneX11>(window));
+ base::MakeRefCounted<gl::NativeViewGLSurfaceEGLX11GLES2>(window));
}
}
diff --git a/chromium/ui/ozone/platform/x11/x11_window_ozone.cc b/chromium/ui/ozone/platform/x11/x11_window_ozone.cc
index 5334049b13f..66658dc1d92 100644
--- a/chromium/ui/ozone/platform/x11/x11_window_ozone.cc
+++ b/chromium/ui/ozone/platform/x11/x11_window_ozone.cc
@@ -1,11 +1,22 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
+// Copyright 2020 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 "ui/ozone/platform/x11/x11_window_ozone.h"
+#include "ui/base/dragdrop/os_exchange_data.h"
+#include "ui/base/x/x11_os_exchange_data_provider.h"
+#include "ui/base/x/x11_pointer_grab.h"
+#include "ui/base/x/x11_topmost_window_finder.h"
+#include "ui/events/event.h"
+#include "ui/events/platform/scoped_event_dispatcher.h"
+#include "ui/events/platform/x11/x11_event_source.h"
+#include "ui/events/x/x11_window_event_manager.h"
#include "ui/ozone/platform/x11/x11_cursor_ozone.h"
#include "ui/platform_window/platform_window_delegate.h"
+#include "ui/platform_window/platform_window_handler/wm_drop_handler.h"
+#include "ui/platform_window/x11/x11_topmost_window_finder.h"
+#include "ui/platform_window/x11/x11_window_manager.h"
namespace ui {
@@ -19,4 +30,129 @@ void X11WindowOzone::SetCursor(PlatformCursor cursor) {
XWindow::SetCursor(cursor_ozone->xcursor());
}
+void X11WindowOzone::Initialize(PlatformWindowInitProperties properties) {
+ X11Window::Initialize(std::move(properties));
+ // Set a class property key that allows |this| to be used for drag action.
+ SetWmDragHandler(this, this);
+
+ drag_drop_client_ =
+ std::make_unique<XDragDropClient>(this, display(), window());
+}
+
+void X11WindowOzone::StartDrag(const ui::OSExchangeData& data,
+ int operation,
+ gfx::NativeCursor cursor,
+ base::OnceCallback<void(int)> callback) {
+ DCHECK(drag_drop_client_);
+
+ end_drag_callback_ = std::move(callback);
+ drag_drop_client_->InitDrag(operation, &data);
+
+ SetCapture();
+
+ dragging_ = true;
+}
+
+std::unique_ptr<ui::XTopmostWindowFinder> X11WindowOzone::CreateWindowFinder() {
+ return std::make_unique<X11TopmostWindowFinder>();
+}
+
+int X11WindowOzone::UpdateDrag(const gfx::Point& screen_point) {
+ WmDropHandler* drop_handler = GetWmDropHandler(*this);
+ if (!drop_handler)
+ return ui::DragDropTypes::DRAG_NONE;
+ // TODO: calculate the appropriate drag operation here.
+ return drop_handler->OnDragMotion(gfx::PointF(screen_point),
+ ui::DragDropTypes::DRAG_COPY);
+}
+
+void X11WindowOzone::UpdateCursor(
+ ui::DragDropTypes::DragOperation negotiated_operation) {
+ NOTIMPLEMENTED_LOG_ONCE();
+}
+
+void X11WindowOzone::OnBeginForeignDrag(XID window) {
+ NOTIMPLEMENTED_LOG_ONCE();
+}
+
+void X11WindowOzone::OnEndForeignDrag() {
+ NOTIMPLEMENTED_LOG_ONCE();
+}
+
+void X11WindowOzone::OnBeforeDragLeave() {
+ NOTIMPLEMENTED_LOG_ONCE();
+}
+
+int X11WindowOzone::PerformDrop() {
+ WmDropHandler* drop_handler = GetWmDropHandler(*this);
+ if (!drop_handler)
+ return ui::DragDropTypes::DRAG_NONE;
+
+ DCHECK(drag_drop_client_);
+ auto* target_current_context = drag_drop_client_->target_current_context();
+ DCHECK(target_current_context);
+
+ int drag_operation = ui::DragDropTypes::DRAG_NONE;
+
+ drop_handler->OnDragDrop(std::make_unique<ui::OSExchangeData>(
+ std::make_unique<ui::XOSExchangeDataProvider>(
+ drag_drop_client_->xwindow(),
+ target_current_context->fetched_targets())));
+ return drag_operation;
+}
+
+void X11WindowOzone::EndMoveLoop() {
+ std::move(end_drag_callback_).Run(0);
+}
+
+bool X11WindowOzone::DispatchDraggingUiEvent(ui::Event* event) {
+ // Drag and drop have a priority over other processing.
+ if (dragging_) {
+ DCHECK(drag_drop_client_);
+
+ switch (event->type()) {
+ case ui::ET_MOUSE_MOVED:
+ case ui::ET_MOUSE_DRAGGED: {
+ drag_drop_client_->HandleMouseMovement(
+ event->AsLocatedEvent()->root_location(),
+ event->AsMouseEvent()->flags(),
+ event->AsMouseEvent()->time_stamp());
+ return true;
+ }
+ case ui::ET_MOUSE_RELEASED:
+ if (!event->AsMouseEvent()->IsLeftMouseButton())
+ break;
+ // Assume that drags are being done with the left mouse button. Only
+ // break the drag if the left mouse button was released.
+ drag_drop_client_->HandleMouseReleased();
+ dragging_ = false;
+ ReleaseCapture();
+ return true;
+ case ui::ET_KEY_PRESSED:
+ if (event->AsKeyEvent()->key_code() != ui::VKEY_ESCAPE)
+ break;
+ EndMoveLoop();
+ drag_drop_client_->HandleMoveLoopEnded();
+ dragging_ = false;
+ ReleaseCapture();
+ return true;
+ default:
+ break;
+ }
+ }
+ return false;
+}
+
+void X11WindowOzone::OnXWindowSelectionEvent(XEvent* xev) {
+ X11Window::OnXWindowSelectionEvent(xev);
+ DCHECK(drag_drop_client_);
+ drag_drop_client_->OnSelectionNotify(xev->xselection);
+}
+
+void X11WindowOzone::OnXWindowDragDropEvent(XEvent* xev) {
+ X11Window::OnXWindowDragDropEvent(xev);
+ DCHECK(drag_drop_client_);
+ drag_drop_client_->HandleXdndEvent(xev->xclient);
+}
+
} // namespace ui
diff --git a/chromium/ui/ozone/platform/x11/x11_window_ozone.h b/chromium/ui/ozone/platform/x11/x11_window_ozone.h
index edf18b39b76..3e2a83fe42d 100644
--- a/chromium/ui/ozone/platform/x11/x11_window_ozone.h
+++ b/chromium/ui/ozone/platform/x11/x11_window_ozone.h
@@ -1,27 +1,64 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
+// Copyright 2020 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 UI_OZONE_PLATFORM_X11_X11_WINDOW_OZONE_H_
#define UI_OZONE_PLATFORM_X11_X11_WINDOW_OZONE_H_
-#include "base/macros.h"
+#include "ui/base/x/x11_drag_drop_client.h"
+#include "ui/platform_window/platform_window_handler/wm_drag_handler.h"
#include "ui/platform_window/x11/x11_window.h"
namespace ui {
class PlatformWindowDelegate;
-// PlatformWindow implementation for X11 Ozone. PlatformEvents are ui::Events.
-class X11WindowOzone : public X11Window {
+// PlatformWindow implementation for non-ChromeOS X11 Ozone.
+// PlatformEvents are ui::Events.
+class X11WindowOzone : public X11Window,
+ public WmDragHandler,
+ public XDragDropClient::Delegate {
public:
explicit X11WindowOzone(PlatformWindowDelegate* delegate);
~X11WindowOzone() override;
+ X11WindowOzone(const X11WindowOzone&) = delete;
+ X11WindowOzone& operator=(const X11WindowOzone&) = delete;
+
// Overridden from PlatformWindow:
void SetCursor(PlatformCursor cursor) override;
- DISALLOW_COPY_AND_ASSIGN(X11WindowOzone);
+ // Overridden from X11Window:
+ void Initialize(PlatformWindowInitProperties properties) override;
+
+ private:
+ // WmDragHandler
+ void StartDrag(const ui::OSExchangeData& data,
+ int operation,
+ gfx::NativeCursor cursor,
+ base::OnceCallback<void(int)> callback) override;
+
+ // ui::XDragDropClient::Delegate
+ std::unique_ptr<ui::XTopmostWindowFinder> CreateWindowFinder() override;
+ int UpdateDrag(const gfx::Point& screen_point) override;
+ void UpdateCursor(
+ ui::DragDropTypes::DragOperation negotiated_operation) override;
+ void OnBeginForeignDrag(XID window) override;
+ void OnEndForeignDrag() override;
+ void OnBeforeDragLeave() override;
+ int PerformDrop() override;
+ void EndMoveLoop() override;
+
+ // X11Window:
+ bool DispatchDraggingUiEvent(ui::Event* event) override;
+ void OnXWindowSelectionEvent(XEvent* xev) override;
+ void OnXWindowDragDropEvent(XEvent* xev) override;
+
+ // True while the drag initiated in this window is in progress.
+ bool dragging_ = false;
+
+ std::unique_ptr<XDragDropClient> drag_drop_client_;
+ base::OnceCallback<void(int)> end_drag_callback_;
};
} // namespace ui
diff --git a/chromium/ui/ozone/platform/x11/x11_window_ozone_chromeos.cc b/chromium/ui/ozone/platform/x11/x11_window_ozone_chromeos.cc
new file mode 100644
index 00000000000..d4f22451189
--- /dev/null
+++ b/chromium/ui/ozone/platform/x11/x11_window_ozone_chromeos.cc
@@ -0,0 +1,28 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ui/ozone/platform/x11/x11_window_ozone_chromeos.h"
+
+#include "ui/events/event.h"
+#include "ui/ozone/platform/x11/x11_cursor_ozone.h"
+#include "ui/platform_window/platform_window_delegate.h"
+#include "ui/platform_window/x11/x11_window_manager.h"
+
+namespace ui {
+
+X11WindowOzone::X11WindowOzone(PlatformWindowDelegate* delegate)
+ : X11Window(delegate) {}
+
+X11WindowOzone::~X11WindowOzone() = default;
+
+void X11WindowOzone::SetCursor(PlatformCursor cursor) {
+ X11CursorOzone* cursor_ozone = static_cast<X11CursorOzone*>(cursor);
+ XWindow::SetCursor(cursor_ozone->xcursor());
+}
+
+void X11WindowOzone::Initialize(PlatformWindowInitProperties properties) {
+ X11Window::Initialize(std::move(properties));
+}
+
+} // namespace ui
diff --git a/chromium/ui/ozone/platform/x11/x11_window_ozone_chromeos.h b/chromium/ui/ozone/platform/x11/x11_window_ozone_chromeos.h
new file mode 100644
index 00000000000..3bcdec53c3c
--- /dev/null
+++ b/chromium/ui/ozone/platform/x11/x11_window_ozone_chromeos.h
@@ -0,0 +1,33 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef UI_OZONE_PLATFORM_X11_X11_WINDOW_OZONE_CHROMEOS_H_
+#define UI_OZONE_PLATFORM_X11_X11_WINDOW_OZONE_CHROMEOS_H_
+
+#include "base/macros.h"
+#include "ui/platform_window/x11/x11_window.h"
+
+namespace ui {
+
+class PlatformWindowDelegate;
+
+// PlatformWindow implementation for ChromeOS X11 Ozone.
+// PlatformEvents are ui::Events.
+class X11WindowOzone : public X11Window {
+ public:
+ explicit X11WindowOzone(PlatformWindowDelegate* delegate);
+ ~X11WindowOzone() override;
+
+ // Overridden from PlatformWindow:
+ void SetCursor(PlatformCursor cursor) override;
+
+ // Overridden from X11Window:
+ void Initialize(PlatformWindowInitProperties properties) override;
+
+ DISALLOW_COPY_AND_ASSIGN(X11WindowOzone);
+};
+
+} // namespace ui
+
+#endif // UI_OZONE_PLATFORM_X11_X11_WINDOW_OZONE_CHROMEOS_H_
diff --git a/chromium/ui/ozone/public/DEPS b/chromium/ui/ozone/public/DEPS
index 6d31ede447e..49d39fea419 100644
--- a/chromium/ui/ozone/public/DEPS
+++ b/chromium/ui/ozone/public/DEPS
@@ -1,4 +1,4 @@
include_rules = [
"+mojo/public",
- "+ui/base/mojom/cursor_type.mojom-forward.h",
+ "+ui/base/cursor/mojom/cursor_type.mojom-forward.h",
]
diff --git a/chromium/ui/ozone/public/cursor_factory_ozone.cc b/chromium/ui/ozone/public/cursor_factory_ozone.cc
index 542dce20aaa..95caf2a8a0b 100644
--- a/chromium/ui/ozone/public/cursor_factory_ozone.cc
+++ b/chromium/ui/ozone/public/cursor_factory_ozone.cc
@@ -4,7 +4,8 @@
#include "ui/ozone/public/cursor_factory_ozone.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
namespace ui {
diff --git a/chromium/ui/ozone/public/cursor_factory_ozone.h b/chromium/ui/ozone/public/cursor_factory_ozone.h
index 4492d2404b0..a179bf08e73 100644
--- a/chromium/ui/ozone/public/cursor_factory_ozone.h
+++ b/chromium/ui/ozone/public/cursor_factory_ozone.h
@@ -8,7 +8,7 @@
#include <vector>
#include "base/component_export.h"
-#include "ui/base/mojom/cursor_type.mojom-forward.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-forward.h"
#include "ui/gfx/native_widget_types.h"
namespace gfx {
diff --git a/chromium/ui/ozone/public/gpu_platform_support_host.cc b/chromium/ui/ozone/public/gpu_platform_support_host.cc
index cc649ab8a49..31e79ccbfd8 100644
--- a/chromium/ui/ozone/public/gpu_platform_support_host.cc
+++ b/chromium/ui/ozone/public/gpu_platform_support_host.cc
@@ -4,7 +4,6 @@
#include "ui/ozone/public/gpu_platform_support_host.h"
-#include "base/logging.h"
#include "base/trace_event/trace_event.h"
namespace ui {
@@ -15,14 +14,7 @@ namespace {
class StubGpuPlatformSupportHost : public GpuPlatformSupportHost {
public:
// GpuPlatformSupportHost:
- void OnGpuProcessLaunched(
- int host_id,
- scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
- scoped_refptr<base::SingleThreadTaskRunner> send_runner,
- base::RepeatingCallback<void(IPC::Message*)> send_callback) override {}
-
void OnChannelDestroyed(int host_id) override {}
- void OnMessageReceived(const IPC::Message&) override {}
void OnGpuServiceLaunched(
int host_id,
scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
diff --git a/chromium/ui/ozone/public/gpu_platform_support_host.h b/chromium/ui/ozone/public/gpu_platform_support_host.h
index af6da1d2879..0077b2574b2 100644
--- a/chromium/ui/ozone/public/gpu_platform_support_host.h
+++ b/chromium/ui/ozone/public/gpu_platform_support_host.h
@@ -10,8 +10,6 @@
#include "base/component_export.h"
#include "base/memory/ref_counted.h"
#include "base/single_thread_task_runner.h"
-#include "ipc/ipc_listener.h"
-#include "ipc/ipc_sender.h"
#include "mojo/public/cpp/system/message_pipe.h"
namespace ui {
@@ -36,22 +34,10 @@ class COMPONENT_EXPORT(OZONE_BASE) GpuPlatformSupportHost {
GpuPlatformSupportHost();
virtual ~GpuPlatformSupportHost();
- // Called when the GPU process is spun up.
- // This is called from browser IO thread.
- virtual void OnGpuProcessLaunched(
- int host_id,
- scoped_refptr<base::SingleThreadTaskRunner> ui_runner,
- scoped_refptr<base::SingleThreadTaskRunner> send_runner,
- base::RepeatingCallback<void(IPC::Message*)> sender) = 0;
-
// Called when the GPU process is destroyed.
// This is called from browser UI thread.
virtual void OnChannelDestroyed(int host_id) = 0;
- // Called to handle an IPC message. Note that this can be called from any
- // thread.
- virtual void OnMessageReceived(const IPC::Message& message) = 0;
-
// Called when the GPU service is launched.
// Called from the browser IO thread.
virtual void OnGpuServiceLaunched(
diff --git a/chromium/ui/ozone/public/ozone_gpu_test_helper.cc b/chromium/ui/ozone/public/ozone_gpu_test_helper.cc
index 3718472a05b..1e5e9883c3e 100644
--- a/chromium/ui/ozone/public/ozone_gpu_test_helper.cc
+++ b/chromium/ui/ozone/public/ozone_gpu_test_helper.cc
@@ -9,89 +9,45 @@
#include "base/run_loop.h"
#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h"
-#include "ipc/ipc_listener.h"
-#include "ipc/ipc_message.h"
-#include "ipc/ipc_sender.h"
-#include "ipc/message_filter.h"
#include "ui/ozone/public/gpu_platform_support_host.h"
#include "ui/ozone/public/ozone_platform.h"
namespace ui {
namespace {
-
const int kGpuProcessHostId = 1;
-
-void DispatchToGpuPlatformSupportHostTask(IPC::Message* msg) {
- ui::OzonePlatform::GetInstance()
- ->GetGpuPlatformSupportHost()
- ->OnMessageReceived(*msg);
- delete msg;
-}
-
-void DispatchToGpuPlatformSupportTaskOnIO(IPC::Message* msg) {
- IPC::MessageFilter* filter =
- ui::OzonePlatform::GetInstance()->GetGpuMessageFilter();
- if (filter)
- filter->OnMessageReceived(*msg);
- delete msg;
-}
-
} // namespace
-class FakeGpuProcess : public IPC::Channel {
- public:
- FakeGpuProcess(
- const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner)
- : ui_task_runner_(ui_task_runner) {}
- ~FakeGpuProcess() override {}
-
- void InitOnIO() {
- IPC::MessageFilter* filter =
- ui::OzonePlatform::GetInstance()->GetGpuMessageFilter();
-
- if (filter)
- filter->OnFilterAdded(this);
- }
-
- // IPC::Channel implementation:
- bool Send(IPC::Message* msg) override {
- ui_task_runner_->PostTask(
- FROM_HERE, base::BindOnce(&DispatchToGpuPlatformSupportHostTask, msg));
- return true;
- }
-
- bool Connect() override {
- NOTREACHED();
- return false;
- }
-
- void Close() override { NOTREACHED(); }
-
- private:
- scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
-};
-
-class FakeGpuProcessHost {
+class FakeGpuConnection {
public:
- FakeGpuProcessHost(
+ FakeGpuConnection(
const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& gpu_io_task_runner)
: ui_task_runner_(ui_task_runner),
gpu_io_task_runner_(gpu_io_task_runner) {}
- ~FakeGpuProcessHost() {}
+ ~FakeGpuConnection() {}
+
+ void BindInterface(const std::string& interface_name,
+ mojo::ScopedMessagePipeHandle interface_pipe) {
+ mojo::GenericPendingReceiver receiver =
+ mojo::GenericPendingReceiver(interface_name, std::move(interface_pipe));
+ CHECK(binders_.TryBind(&receiver))
+ << "Unable to find mojo interface " << interface_name;
+ }
void InitOnIO() {
- base::RepeatingCallback<void(IPC::Message*)> sender =
- base::BindRepeating(&DispatchToGpuPlatformSupportTaskOnIO);
-
+ ui::OzonePlatform::GetInstance()->AddInterfaces(&binders_);
+ auto interface_binder = base::BindRepeating(
+ &FakeGpuConnection::BindInterface, base::Unretained(this));
ui::OzonePlatform::GetInstance()
->GetGpuPlatformSupportHost()
- ->OnGpuProcessLaunched(kGpuProcessHostId, ui_task_runner_,
- gpu_io_task_runner_, std::move(sender));
+ ->OnGpuServiceLaunched(kGpuProcessHostId, ui_task_runner_,
+ gpu_io_task_runner_, interface_binder,
+ base::DoNothing());
}
private:
+ mojo::BinderMap binders_;
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> gpu_io_task_runner_;
};
@@ -109,17 +65,11 @@ bool OzoneGpuTestHelper::Initialize(
base::Thread::Options(base::MessagePumpType::IO, 0)))
return false;
- fake_gpu_process_ = std::make_unique<FakeGpuProcess>(ui_task_runner);
- io_helper_thread_->task_runner()->PostTask(
- FROM_HERE, base::BindOnce(&FakeGpuProcess::InitOnIO,
- base::Unretained(fake_gpu_process_.get())));
-
- fake_gpu_process_host_ = std::make_unique<FakeGpuProcessHost>(
+ fake_gpu_connection_ = std::make_unique<FakeGpuConnection>(
ui_task_runner, io_helper_thread_->task_runner());
io_helper_thread_->task_runner()->PostTask(
- FROM_HERE,
- base::BindOnce(&FakeGpuProcessHost::InitOnIO,
- base::Unretained(fake_gpu_process_host_.get())));
+ FROM_HERE, base::BindOnce(&FakeGpuConnection::InitOnIO,
+ base::Unretained(fake_gpu_connection_.get())));
io_helper_thread_->FlushForTesting();
// Give the UI thread a chance to run any tasks posted from the IO thread
diff --git a/chromium/ui/ozone/public/ozone_gpu_test_helper.h b/chromium/ui/ozone/public/ozone_gpu_test_helper.h
index aba343f57e2..09f70d66c17 100644
--- a/chromium/ui/ozone/public/ozone_gpu_test_helper.h
+++ b/chromium/ui/ozone/public/ozone_gpu_test_helper.h
@@ -18,25 +18,23 @@ class Thread;
namespace ui {
-class FakeGpuProcess;
-class FakeGpuProcessHost;
+class FakeGpuConnection;
// Helper class for applications that do not have a dedicated GPU channel.
//
-// This sets up message forwarding between the "gpu" and "ui" threads.
+// This sets up mojo pipe between the "gpu" and "ui" threads. It is not needed
+// if in Mojo single-thread mode.
class COMPONENT_EXPORT(OZONE) OzoneGpuTestHelper {
public:
OzoneGpuTestHelper();
virtual ~OzoneGpuTestHelper();
- // Start processing gpu messages. The "gpu" process will be using the
- // |ui_task_runner| to post messages intended for the "ui" thread.
+ // Binds mojo endpoints on "gpu" and "ui".
bool Initialize(
const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner);
private:
- std::unique_ptr<FakeGpuProcess> fake_gpu_process_;
- std::unique_ptr<FakeGpuProcessHost> fake_gpu_process_host_;
+ std::unique_ptr<FakeGpuConnection> fake_gpu_connection_;
std::unique_ptr<base::Thread> io_helper_thread_;
DISALLOW_COPY_AND_ASSIGN(OzoneGpuTestHelper);
diff --git a/chromium/ui/ozone/public/ozone_platform.cc b/chromium/ui/ozone/public/ozone_platform.cc
index 35bae772a45..0309fc67128 100644
--- a/chromium/ui/ozone/public/ozone_platform.cc
+++ b/chromium/ui/ozone/public/ozone_platform.cc
@@ -7,7 +7,7 @@
#include <memory>
#include <utility>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/no_destructor.h"
#include "base/trace_event/trace_event.h"
#include "ui/events/devices/device_data_manager.h"
@@ -78,12 +78,12 @@ const char* OzonePlatform::GetPlatformName() {
return GetOzonePlatformName();
}
-IPC::MessageFilter* OzonePlatform::GetGpuMessageFilter() {
+PlatformClipboard* OzonePlatform::GetPlatformClipboard() {
+ // Platforms that support system clipboard must override this method.
return nullptr;
}
-PlatformClipboard* OzonePlatform::GetPlatformClipboard() {
- // Platforms that support system clipboard must override this method.
+PlatformGLEGLUtility* OzonePlatform::GetPlatformGLEGLUtility() {
return nullptr;
}
diff --git a/chromium/ui/ozone/public/ozone_platform.h b/chromium/ui/ozone/public/ozone_platform.h
index c1d82b8ba5c..afb9099af3b 100644
--- a/chromium/ui/ozone/public/ozone_platform.h
+++ b/chromium/ui/ozone/public/ozone_platform.h
@@ -22,10 +22,6 @@ namespace display {
class NativeDisplayDelegate;
}
-namespace IPC {
-class MessageFilter;
-}
-
namespace ui {
class CursorFactoryOzone;
@@ -36,6 +32,7 @@ class PlatformScreen;
class SurfaceFactoryOzone;
class SystemInputInjector;
class PlatformClipboard;
+class PlatformGLEGLUtility;
namespace internal {
class InputMethodDelegate;
@@ -70,14 +67,6 @@ class COMPONENT_EXPORT(OZONE) OzonePlatform {
// operate as a single process for platforms (i.e. drm) that are usually
// split between a host and viz specific portion.
bool single_process = false;
-
- // Setting this to true indicates that the platform implementation should
- // use mojo. Setting this to true requires calling |AddInterfaces|
- // afterwards in the Viz process. Note that this param is only checked in
- // Ozone DRM. Other platforms either never use mojo or always use mojo
- // regardless of this param.
- // TODO(crbug.com/806092): Remove after legacy IPC-based Ozone is removed.
- bool using_mojo = false;
};
// Struct used to indicate platform properties.
@@ -94,14 +83,17 @@ class COMPONENT_EXPORT(OZONE) OzonePlatform {
// supported.
bool use_system_title_bar = false;
- // Determines if the platform requires mojo communication for the IPC.
- // Currently used only by the Ozone/Wayland platform.
- bool requires_mojo = false;
-
// Determines the type of message pump that should be used for GPU main
// thread.
base::MessagePumpType message_pump_type_for_gpu =
base::MessagePumpType::DEFAULT;
+
+ // Determines if the platform supports vulkan swap chain.
+ bool supports_vulkan_swap_chain = false;
+
+ // Wayland only: determines if the client must ignore the screen bounds when
+ // calculating bounds of menu windows.
+ bool ignore_screen_bounds_for_menus = false;
};
// Properties available in the host process after initialization.
@@ -139,7 +131,6 @@ class COMPONENT_EXPORT(OZONE) OzonePlatform {
virtual ui::OverlayManagerOzone* GetOverlayManager() = 0;
virtual ui::CursorFactoryOzone* GetCursorFactoryOzone() = 0;
virtual ui::InputController* GetInputController() = 0;
- virtual IPC::MessageFilter* GetGpuMessageFilter();
virtual ui::GpuPlatformSupportHost* GetGpuPlatformSupportHost() = 0;
virtual std::unique_ptr<SystemInputInjector> CreateSystemInputInjector() = 0;
virtual std::unique_ptr<PlatformWindow> CreatePlatformWindow(
@@ -152,6 +143,7 @@ class COMPONENT_EXPORT(OZONE) OzonePlatform {
virtual std::unique_ptr<InputMethod> CreateInputMethod(
internal::InputMethodDelegate* delegate,
gfx::AcceleratedWidget widget) = 0;
+ virtual PlatformGLEGLUtility* GetPlatformGLEGLUtility();
// Returns true if the specified buffer format is supported.
virtual bool IsNativePixmapConfigSupported(gfx::BufferFormat format,
diff --git a/chromium/ui/ozone/public/platform_gl_egl_utility.h b/chromium/ui/ozone/public/platform_gl_egl_utility.h
new file mode 100644
index 00000000000..704dc178404
--- /dev/null
+++ b/chromium/ui/ozone/public/platform_gl_egl_utility.h
@@ -0,0 +1,34 @@
+// Copyright 2020 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 UI_OZONE_PUBLIC_PLATFORM_GL_EGL_UTILITY_H_
+#define UI_OZONE_PUBLIC_PLATFORM_GL_EGL_UTILITY_H_
+
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include "base/component_export.h"
+#include "third_party/khronos/EGL/egl.h"
+
+namespace ui {
+
+// Provides platform specific EGL attributes/configs.
+class COMPONENT_EXPORT(OZONE_BASE) PlatformGLEGLUtility {
+ public:
+ virtual ~PlatformGLEGLUtility() = default;
+
+ // Gets additional display attributes based on |platform_type|.
+ virtual void GetAdditionalEGLAttributes(
+ EGLenum platform_type,
+ std::vector<EGLAttrib>* display_attributes) = 0;
+
+ // Chooses alpha and buffer size values.
+ virtual void ChooseEGLAlphaAndBufferSize(EGLint* alpha_size,
+ EGLint* buffer_size) = 0;
+};
+
+} // namespace ui
+
+#endif // UI_OZONE_PUBLIC_PLATFORM_GL_EGL_UTILITY_H_
diff --git a/chromium/ui/ozone/public/platform_screen.cc b/chromium/ui/ozone/public/platform_screen.cc
index af4dc57fcd1..a95cfae1322 100644
--- a/chromium/ui/ozone/public/platform_screen.cc
+++ b/chromium/ui/ozone/public/platform_screen.cc
@@ -4,11 +4,20 @@
#include "ui/ozone/public/platform_screen.h"
+#include "base/logging.h"
+
namespace ui {
PlatformScreen::PlatformScreen() = default;
PlatformScreen::~PlatformScreen() = default;
+gfx::AcceleratedWidget PlatformScreen::GetLocalProcessWidgetAtPoint(
+ const gfx::Point& point,
+ const std::set<gfx::AcceleratedWidget>& ignore) const {
+ NOTIMPLEMENTED_LOG_ONCE();
+ return gfx::kNullAcceleratedWidget;
+}
+
std::string PlatformScreen::GetCurrentWorkspace() {
NOTIMPLEMENTED_LOG_ONCE();
return {};
diff --git a/chromium/ui/ozone/public/platform_screen.h b/chromium/ui/ozone/public/platform_screen.h
index de464218855..9ce293c0aff 100644
--- a/chromium/ui/ozone/public/platform_screen.h
+++ b/chromium/ui/ozone/public/platform_screen.h
@@ -5,7 +5,11 @@
#ifndef UI_OZONE_PUBLIC_PLATFORM_SCREEN_H_
#define UI_OZONE_PUBLIC_PLATFORM_SCREEN_H_
+#include <set>
+#include <string>
+
#include "base/component_export.h"
+#include "base/macros.h"
#include "ui/gfx/native_widget_types.h"
namespace display {
@@ -57,6 +61,11 @@ class COMPONENT_EXPORT(OZONE_BASE) PlatformScreen {
virtual gfx::AcceleratedWidget GetAcceleratedWidgetAtScreenPoint(
const gfx::Point& point) const = 0;
+ // Returns top level accelerated widget at |point| ignoring |ignore|.
+ virtual gfx::AcceleratedWidget GetLocalProcessWidgetAtPoint(
+ const gfx::Point& point,
+ const std::set<gfx::AcceleratedWidget>& ignore) const;
+
// Returns the |Display| nearest the specified point. |point| must be in DIPs.
virtual display::Display GetDisplayNearestPoint(
const gfx::Point& point) const = 0;
@@ -81,4 +90,4 @@ class COMPONENT_EXPORT(OZONE_BASE) PlatformScreen {
} // namespace ui
-#endif // UI_OZONE_PUBLIC_PLATFORM_SCREEN_H_ \ No newline at end of file
+#endif // UI_OZONE_PUBLIC_PLATFORM_SCREEN_H_
diff --git a/chromium/ui/ozone/public/surface_ozone_canvas.cc b/chromium/ui/ozone/public/surface_ozone_canvas.cc
index 624454fa399..d8a6522d97b 100644
--- a/chromium/ui/ozone/public/surface_ozone_canvas.cc
+++ b/chromium/ui/ozone/public/surface_ozone_canvas.cc
@@ -4,7 +4,7 @@
#include "ui/ozone/public/surface_ozone_canvas.h"
-#include "base/logging.h"
+#include "base/notreached.h"
namespace ui {
diff --git a/chromium/ui/ozone/test/mock_platform_window_delegate.h b/chromium/ui/ozone/test/mock_platform_window_delegate.h
index fbc42619375..a44afac163c 100644
--- a/chromium/ui/ozone/test/mock_platform_window_delegate.h
+++ b/chromium/ui/ozone/test/mock_platform_window_delegate.h
@@ -5,6 +5,7 @@
#ifndef UI_OZONE_TEST_MOCK_PLATFORM_WINDOW_DELEGATE_H_
#define UI_OZONE_TEST_MOCK_PLATFORM_WINDOW_DELEGATE_H_
+#include "base/macros.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/platform_window/platform_window_delegate.h"
diff --git a/chromium/ui/platform_window/extensions/x11_extension.h b/chromium/ui/platform_window/extensions/x11_extension.h
index e39c9f66c64..d1525ba4987 100644
--- a/chromium/ui/platform_window/extensions/x11_extension.h
+++ b/chromium/ui/platform_window/extensions/x11_extension.h
@@ -15,6 +15,8 @@ class X11ExtensionDelegate;
// Linux extensions that linux platforms can use to extend the platform windows
// APIs. Please refer to README for more details.
+//
+// The extension mustn't be called until PlatformWindow is initialized.
class COMPONENT_EXPORT(EXTENSIONS) X11Extension {
public:
// Returns whether an XSync extension is available at the current platform.
diff --git a/chromium/ui/platform_window/extensions/x11_extension_delegate.h b/chromium/ui/platform_window/extensions/x11_extension_delegate.h
index 71411d2f6f7..e5ad90bf7b2 100644
--- a/chromium/ui/platform_window/extensions/x11_extension_delegate.h
+++ b/chromium/ui/platform_window/extensions/x11_extension_delegate.h
@@ -39,8 +39,11 @@ class COMPONENT_EXPORT(EXTENSIONS) X11ExtensionDelegate {
#endif
// Returns true if this window should be in a forced override-redirect state
- // (not maanged by the window manager).
- virtual bool IsOverrideRedirect() const = 0;
+ // (not managed by the window manager). If |is_tiling_wm| is set to true, the
+ // underlaying window manager is tiling. If it is set to false, the wm is
+ // stacking. The delegate can use this information to determine the value
+ // returned for override-redirect.
+ virtual bool IsOverrideRedirect(bool is_tiling_wm) const = 0;
protected:
virtual ~X11ExtensionDelegate() = default;
diff --git a/chromium/ui/platform_window/platform_window_handler/BUILD.gn b/chromium/ui/platform_window/platform_window_handler/BUILD.gn
index 10e53a48646..bcb0f855ab3 100644
--- a/chromium/ui/platform_window/platform_window_handler/BUILD.gn
+++ b/chromium/ui/platform_window/platform_window_handler/BUILD.gn
@@ -12,6 +12,8 @@ jumbo_component("platform_window_handler") {
"wm_drag_handler.h",
"wm_drop_handler.cc",
"wm_drop_handler.h",
+ "wm_move_loop_handler.cc",
+ "wm_move_loop_handler.h",
"wm_move_resize_handler.cc",
"wm_move_resize_handler.h",
"wm_platform_export.h",
diff --git a/chromium/ui/platform_window/platform_window_handler/wm_move_loop_handler.cc b/chromium/ui/platform_window/platform_window_handler/wm_move_loop_handler.cc
new file mode 100644
index 00000000000..94192b3ebff
--- /dev/null
+++ b/chromium/ui/platform_window/platform_window_handler/wm_move_loop_handler.cc
@@ -0,0 +1,25 @@
+// Copyright 2020 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 "ui/platform_window/platform_window_handler/wm_move_loop_handler.h"
+
+#include "ui/base/class_property.h"
+#include "ui/platform_window/platform_window.h"
+
+DEFINE_UI_CLASS_PROPERTY_TYPE(ui::WmMoveLoopHandler*)
+
+namespace ui {
+
+DEFINE_UI_CLASS_PROPERTY_KEY(WmMoveLoopHandler*, kWmMoveLoopHandlerKey, nullptr)
+
+void SetWmMoveLoopHandler(PlatformWindow* platform_window,
+ WmMoveLoopHandler* drag_handler) {
+ platform_window->SetProperty(kWmMoveLoopHandlerKey, drag_handler);
+}
+
+WmMoveLoopHandler* GetWmMoveLoopHandler(const PlatformWindow& platform_window) {
+ return platform_window.GetProperty(kWmMoveLoopHandlerKey);
+}
+
+} // namespace ui
diff --git a/chromium/ui/platform_window/platform_window_handler/wm_move_loop_handler.h b/chromium/ui/platform_window/platform_window_handler/wm_move_loop_handler.h
new file mode 100644
index 00000000000..98b1fc405c9
--- /dev/null
+++ b/chromium/ui/platform_window/platform_window_handler/wm_move_loop_handler.h
@@ -0,0 +1,39 @@
+// Copyright 2020 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 UI_PLATFORM_WINDOW_PLATFORM_WINDOW_HANDLER_WM_MOVE_LOOP_HANDLER_H_
+#define UI_PLATFORM_WINDOW_PLATFORM_WINDOW_HANDLER_WM_MOVE_LOOP_HANDLER_H_
+
+#include "ui/platform_window/platform_window_handler/wm_platform_export.h"
+
+namespace gfx {
+class Vector2d;
+}
+
+namespace ui {
+
+class PlatformWindow;
+
+// Handler that starts interactive move loop for the PlatformWindow.
+class WM_PLATFORM_EXPORT WmMoveLoopHandler {
+ public:
+ // Starts a move loop for tab drag controller. Returns true on success or
+ // false on fail/cancel.
+ virtual bool RunMoveLoop(const gfx::Vector2d& drag_offset) = 0;
+
+ // Ends the move loop.
+ virtual void EndMoveLoop() = 0;
+
+ protected:
+ virtual ~WmMoveLoopHandler() {}
+};
+
+WM_PLATFORM_EXPORT void SetWmMoveLoopHandler(PlatformWindow* platform_window,
+ WmMoveLoopHandler* drag_handler);
+WM_PLATFORM_EXPORT WmMoveLoopHandler* GetWmMoveLoopHandler(
+ const PlatformWindow& platform_window);
+
+} // namespace ui
+
+#endif // UI_PLATFORM_WINDOW_PLATFORM_WINDOW_HANDLER_WM_MOVE_LOOP_HANDLER_H_
diff --git a/chromium/ui/platform_window/x11/BUILD.gn b/chromium/ui/platform_window/x11/BUILD.gn
index fb66bf511d7..60228f2c548 100644
--- a/chromium/ui/platform_window/x11/BUILD.gn
+++ b/chromium/ui/platform_window/x11/BUILD.gn
@@ -28,11 +28,11 @@ jumbo_component("x11") {
"//ui/platform_window/platform_window_handler",
]
- configs += [ "//build/config/linux:x11" ]
-
defines = [ "X11_WINDOW_IMPLEMENTATION" ]
sources = [
+ "x11_topmost_window_finder.cc",
+ "x11_topmost_window_finder.h",
"x11_window.cc",
"x11_window.h",
"x11_window_export.h",
diff --git a/chromium/ui/platform_window/x11/OWNERS b/chromium/ui/platform_window/x11/OWNERS
new file mode 100644
index 00000000000..68f3068ef27
--- /dev/null
+++ b/chromium/ui/platform_window/x11/OWNERS
@@ -0,0 +1,3 @@
+msisov@igalia.com
+nickdiego@igalia.com
+thomasanderson@chromium.org
diff --git a/chromium/ui/platform_window/x11/atk_event_conversion.cc b/chromium/ui/platform_window/x11/atk_event_conversion.cc
index 71930fdf061..b79fff06bb0 100644
--- a/chromium/ui/platform_window/x11/atk_event_conversion.cc
+++ b/chromium/ui/platform_window/x11/atk_event_conversion.cc
@@ -4,6 +4,8 @@
#include "ui/platform_window/x11/atk_event_conversion.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "ui/events/x/events_x_utils.h"
namespace ui {
diff --git a/chromium/ui/platform_window/x11/x11_topmost_window_finder.cc b/chromium/ui/platform_window/x11/x11_topmost_window_finder.cc
new file mode 100644
index 00000000000..4163e3b9db3
--- /dev/null
+++ b/chromium/ui/platform_window/x11/x11_topmost_window_finder.cc
@@ -0,0 +1,84 @@
+// 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 "ui/platform_window/x11/x11_topmost_window_finder.h"
+
+#include <stddef.h>
+
+#include <vector>
+
+#include "ui/platform_window/x11/x11_window.h"
+#include "ui/platform_window/x11/x11_window_manager.h"
+
+namespace ui {
+
+X11TopmostWindowFinder::X11TopmostWindowFinder() = default;
+
+X11TopmostWindowFinder::~X11TopmostWindowFinder() = default;
+
+XID X11TopmostWindowFinder::FindLocalProcessWindowAt(
+ const gfx::Point& screen_loc_in_pixels,
+ const std::set<gfx::AcceleratedWidget>& ignore) {
+ screen_loc_in_pixels_ = screen_loc_in_pixels;
+ ignore_ = ignore;
+
+ std::vector<X11Window*> local_process_windows =
+ X11WindowManager::GetInstance()->GetAllOpenWindows();
+ if (std::none_of(local_process_windows.cbegin(), local_process_windows.cend(),
+ [this](auto* window) {
+ return ShouldStopIteratingAtLocalProcessWindow(window);
+ }))
+ return gfx::kNullAcceleratedWidget;
+
+ EnumerateTopLevelWindows(this);
+ return toplevel_;
+}
+
+XID X11TopmostWindowFinder::FindWindowAt(
+ const gfx::Point& screen_loc_in_pixels) {
+ screen_loc_in_pixels_ = screen_loc_in_pixels;
+ EnumerateTopLevelWindows(this);
+ return toplevel_;
+}
+
+bool X11TopmostWindowFinder::ShouldStopIterating(XID xid) {
+ if (!IsWindowVisible(xid))
+ return false;
+
+ auto* window = X11WindowManager::GetInstance()->GetWindow(xid);
+ if (window) {
+ if (ShouldStopIteratingAtLocalProcessWindow(window)) {
+ toplevel_ = xid;
+ return true;
+ }
+ return false;
+ }
+
+ if (WindowContainsPoint(xid, screen_loc_in_pixels_)) {
+ toplevel_ = xid;
+ return true;
+ }
+ return false;
+}
+
+bool X11TopmostWindowFinder::ShouldStopIteratingAtLocalProcessWindow(
+ X11Window* window) {
+ if (ignore_.find(window->GetWidget()) != ignore_.end())
+ return false;
+
+ // Currently |window|->IsVisible() always returns true.
+ // TODO(pkotwicz): Fix this. crbug.com/353038
+ if (!window->IsVisible())
+ return false;
+
+ gfx::Rect window_bounds = window->GetOutterBounds();
+ if (!window_bounds.Contains(screen_loc_in_pixels_))
+ return false;
+
+ gfx::Point window_point(screen_loc_in_pixels_);
+ window_point.Offset(-window_bounds.origin().x(), -window_bounds.origin().y());
+ return window->ContainsPointInXRegion(window_point);
+}
+
+} // namespace ui
diff --git a/chromium/ui/views/widget/desktop_aura/x11_topmost_window_finder.h b/chromium/ui/platform_window/x11/x11_topmost_window_finder.h
index 0d9e535153a..62c9e138d72 100644
--- a/chromium/ui/views/widget/desktop_aura/x11_topmost_window_finder.h
+++ b/chromium/ui/platform_window/x11/x11_topmost_window_finder.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_X11_TOPMOST_WINDOW_FINDER_H_
-#define UI_VIEWS_WIDGET_DESKTOP_AURA_X11_TOPMOST_WINDOW_FINDER_H_
+#ifndef UI_PLATFORM_WINDOW_X11_X11_TOPMOST_WINDOW_FINDER_H_
+#define UI_PLATFORM_WINDOW_X11_X11_TOPMOST_WINDOW_FINDER_H_
#include <set>
@@ -11,27 +11,27 @@
#include "ui/base/x/x11_topmost_window_finder.h"
#include "ui/base/x/x11_util.h"
#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/x11.h"
-#include "ui/views/views_export.h"
+#include "ui/platform_window/x11/x11_window_export.h"
-namespace aura {
-class Window;
-}
+namespace ui {
-namespace views {
+class X11Window;
// Utility class for finding the topmost window at a given screen position.
-class VIEWS_EXPORT X11TopmostWindowFinder : public ui::EnumerateWindowsDelegate,
- public ui::XTopmostWindowFinder {
+class X11_WINDOW_EXPORT X11TopmostWindowFinder
+ : public ui::EnumerateWindowsDelegate,
+ public ui::XTopmostWindowFinder {
public:
X11TopmostWindowFinder();
~X11TopmostWindowFinder() override;
// Returns the topmost window at |screen_loc_in_pixels|, ignoring the windows
- // in |ignore|. Returns NULL if the topmost window at |screen_loc_in_pixels|
- // does not belong to Chrome.
- aura::Window* FindLocalProcessWindowAt(const gfx::Point& screen_loc_in_pixels,
- const std::set<aura::Window*>& ignore);
+ // in |ignore|. Returns null widget if the topmost window at
+ // |screen_loc_in_pixels| does not belong to Chrome.
+ XID FindLocalProcessWindowAt(const gfx::Point& screen_loc_in_pixels,
+ const std::set<gfx::AcceleratedWidget>& ignore);
// Returns the topmost window at |screen_loc_in_pixels|.
XID FindWindowAt(const gfx::Point& screen_loc_in_pixels) override;
@@ -42,15 +42,15 @@ class VIEWS_EXPORT X11TopmostWindowFinder : public ui::EnumerateWindowsDelegate,
// Returns true if |window| does not not belong to |ignore|, is visible and
// contains |screen_loc_|.
- bool ShouldStopIteratingAtLocalProcessWindow(aura::Window* window);
+ bool ShouldStopIteratingAtLocalProcessWindow(ui::X11Window* window);
gfx::Point screen_loc_in_pixels_;
- std::set<aura::Window*> ignore_;
+ std::set<gfx::AcceleratedWidget> ignore_;
XID toplevel_ = x11::None;
DISALLOW_COPY_AND_ASSIGN(X11TopmostWindowFinder);
};
-} // namespace views
+} // namespace ui
-#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_X11_TOPMOST_WINDOW_FINDER_H_
+#endif // UI_PLATFORM_WINDOW_X11_X11_TOPMOST_WINDOW_FINDER_H_
diff --git a/chromium/ui/platform_window/x11/x11_window.cc b/chromium/ui/platform_window/x11/x11_window.cc
index 98b442ee756..c9fc5e2670d 100644
--- a/chromium/ui/platform_window/x11/x11_window.cc
+++ b/chromium/ui/platform_window/x11/x11_window.cc
@@ -7,6 +7,7 @@
#include "base/strings/string_number_conversions.h"
#include "base/trace_event/trace_event.h"
#include "ui/base/buildflags.h"
+#include "ui/base/x/x11_desktop_window_move_client.h"
#include "ui/base/x/x11_util.h"
#include "ui/base/x/x11_util_internal.h"
#include "ui/display/screen.h"
@@ -24,7 +25,7 @@
#if defined(USE_OZONE)
#include "ui/events/ozone/events_ozone.h"
-#endif
+#endif // defined(USE_OZONE)
#if BUILDFLAG(USE_ATK)
#include "ui/platform_window/x11/atk_event_conversion.h"
@@ -61,7 +62,6 @@ XWindow::WindowType GetXWindowType(PlatformWindowType window_type) {
return WindowType::kPopup;
case PlatformWindowType::kDrag:
return WindowType::kDrag;
- break;
case PlatformWindowType::kBubble:
return WindowType::kBubble;
}
@@ -129,7 +129,7 @@ void X11Window::Initialize(PlatformWindowInitProperties properties) {
config.bounds.set_size(adjusted_size_in_pixels);
config.override_redirect =
properties.x11_extension_delegate &&
- properties.x11_extension_delegate->IsOverrideRedirect();
+ properties.x11_extension_delegate->IsOverrideRedirect(IsWmTiling());
workspace_extension_delegate_ = properties.workspace_extension_delegate;
x11_extension_delegate_ = properties.x11_extension_delegate;
@@ -209,11 +209,6 @@ void X11Window::SetBounds(const gfx::Rect& bounds) {
// (possibly synthetic) ConfigureNotify about the actual size and correct
// |bounds_| later.
XWindow::SetBounds(bounds_in_pixels);
-
- // Even if the pixel bounds didn't change this call to the delegate should
- // still happen. The device scale factor may have changed which effectively
- // changes the bounds.
- platform_window_delegate_->OnBoundsChanged(bounds_in_pixels);
}
gfx::Rect X11Window::GetBounds() {
@@ -576,6 +571,9 @@ void X11Window::DispatchUiEvent(ui::Event* event, XEvent* xev) {
auto* window_manager = X11WindowManager::GetInstance();
DCHECK(window_manager);
+ if (DispatchDraggingUiEvent(event))
+ return;
+
// Process X11-specific bits
if (XWindow::IsTargetedBy(*xev))
XWindow::ProcessEvent(xev);
@@ -632,9 +630,20 @@ void X11Window::OnXWindowCreated() {
DCHECK(X11EventSource::HasInstance());
X11EventSource::GetInstance()->AddXEventDispatcher(this);
+ x11_window_move_client_ =
+ std::make_unique<ui::X11DesktopWindowMoveClient>(this);
+
+ // Set a class property key, which allows |this| to be used for move loop aka
+ // tab dragging.
+ SetWmMoveLoopHandler(this, static_cast<WmMoveLoopHandler*>(this));
+
platform_window_delegate_->OnAcceleratedWidgetAvailable(GetWidget());
}
+bool X11Window::DispatchDraggingUiEvent(ui::Event* event) {
+ return false;
+}
+
void X11Window::OnXWindowStateChanged() {
// Determine the new window state information to be propagated to the client.
// Note that the order of checks is important here, because window can have
@@ -749,6 +758,14 @@ void X11Window::DispatchHostWindowDragMovement(
XWindow::WmMoveResize(hittest, pointer_location_in_px);
}
+bool X11Window::RunMoveLoop(const gfx::Vector2d& drag_offset) {
+ return x11_window_move_client_->RunMoveLoop(!HasCapture(), drag_offset);
+}
+
+void X11Window::EndMoveLoop() {
+ x11_window_move_client_->EndMoveLoop();
+}
+
gfx::Size X11Window::AdjustSizeForDisplay(
const gfx::Size& requested_size_in_pixels) {
#if defined(OS_CHROMEOS)
diff --git a/chromium/ui/platform_window/x11/x11_window.h b/chromium/ui/platform_window/x11/x11_window.h
index 69990826d33..378512c1676 100644
--- a/chromium/ui/platform_window/x11/x11_window.h
+++ b/chromium/ui/platform_window/x11/x11_window.h
@@ -12,6 +12,7 @@
#include "ui/platform_window/extensions/workspace_extension.h"
#include "ui/platform_window/extensions/x11_extension.h"
#include "ui/platform_window/platform_window.h"
+#include "ui/platform_window/platform_window_handler/wm_move_loop_handler.h"
#include "ui/platform_window/platform_window_handler/wm_move_resize_handler.h"
#include "ui/platform_window/platform_window_init_properties.h"
#include "ui/platform_window/x11/x11_window_export.h"
@@ -19,6 +20,7 @@
namespace ui {
class X11ExtensionDelegate;
+class X11DesktopWindowMoveClient;
class LocatedEvent;
class WorkspaceExtensionDelegate;
@@ -41,12 +43,13 @@ class X11_WINDOW_EXPORT X11Window : public PlatformWindow,
public PlatformEventDispatcher,
public XEventDispatcher,
public WorkspaceExtension,
- public X11Extension {
+ public X11Extension,
+ public WmMoveLoopHandler {
public:
explicit X11Window(PlatformWindowDelegate* platform_window_delegate);
~X11Window() override;
- void Initialize(PlatformWindowInitProperties properties);
+ virtual void Initialize(PlatformWindowInitProperties properties);
void SetXEventDelegate(XEventDelegate* delegate);
@@ -132,10 +135,7 @@ class X11_WINDOW_EXPORT X11Window : public PlatformWindow,
// XWindow:
void OnXWindowCreated() override;
- private:
- // PlatformEventDispatcher:
- bool CanDispatchEvent(const PlatformEvent& event) override;
- uint32_t DispatchEvent(const PlatformEvent& event) override;
+ virtual bool DispatchDraggingUiEvent(ui::Event* event);
// XWindow:
void OnXWindowStateChanged() override;
@@ -152,6 +152,11 @@ class X11_WINDOW_EXPORT X11Window : public PlatformWindow,
void GetWindowMaskForXWindow(const gfx::Size& size,
SkPath* window_mask) override;
+ private:
+ // PlatformEventDispatcher:
+ bool CanDispatchEvent(const PlatformEvent& event) override;
+ uint32_t DispatchEvent(const PlatformEvent& event) override;
+
void DispatchUiEvent(ui::Event* event, XEvent* xev);
// WmMoveResizeHandler
@@ -159,6 +164,10 @@ class X11_WINDOW_EXPORT X11Window : public PlatformWindow,
int hittest,
const gfx::Point& pointer_location_in_px) override;
+ // WmMoveLoopHandler:
+ bool RunMoveLoop(const gfx::Vector2d& drag_offset) override;
+ void EndMoveLoop() override;
+
// Handles |xevent| as a Atk Key Event
bool HandleAsAtkEvent(XEvent* xevent);
@@ -200,6 +209,8 @@ class X11_WINDOW_EXPORT X11Window : public PlatformWindow,
// target.
XEvent* current_xevent_ = nullptr;
+ std::unique_ptr<X11DesktopWindowMoveClient> x11_window_move_client_;
+
DISALLOW_COPY_AND_ASSIGN(X11Window);
};
diff --git a/chromium/ui/platform_window/x11/x11_window_manager.cc b/chromium/ui/platform_window/x11/x11_window_manager.cc
index 47df862f06d..5aef03785b8 100644
--- a/chromium/ui/platform_window/x11/x11_window_manager.cc
+++ b/chromium/ui/platform_window/x11/x11_window_manager.cc
@@ -100,4 +100,11 @@ void X11WindowManager::MouseOnWindow(X11Window* window) {
window->OnMouseEnter();
}
+std::vector<X11Window*> X11WindowManager::GetAllOpenWindows() const {
+ std::vector<X11Window*> all_windows;
+ for (const auto& item : windows_)
+ all_windows.push_back(item.second);
+ return all_windows;
+}
+
} // namespace ui
diff --git a/chromium/ui/platform_window/x11/x11_window_manager.h b/chromium/ui/platform_window/x11/x11_window_manager.h
index ea6c4960300..1ac932b2004 100644
--- a/chromium/ui/platform_window/x11/x11_window_manager.h
+++ b/chromium/ui/platform_window/x11/x11_window_manager.h
@@ -45,6 +45,8 @@ class X11_WINDOW_EXPORT X11WindowManager {
return window_mouse_currently_on_;
}
+ std::vector<X11Window*> GetAllOpenWindows() const;
+
private:
X11Window* located_events_grabber_ = nullptr;
X11Window* window_mouse_currently_on_ = nullptr;
diff --git a/chromium/ui/resources/cursors/none.cur b/chromium/ui/resources/cursors/none.cur
deleted file mode 100644
index 8fb6e5e75e6..00000000000
--- a/chromium/ui/resources/cursors/none.cur
+++ /dev/null
Binary files differ
diff --git a/chromium/ui/resources/ui_unscaled_resources.grd b/chromium/ui/resources/ui_unscaled_resources.grd
index 0243529b191..e1b99717871 100644
--- a/chromium/ui/resources/ui_unscaled_resources.grd
+++ b/chromium/ui/resources/ui_unscaled_resources.grd
@@ -13,7 +13,6 @@
<include name="IDC_CELL" file="cursors/cell.cur" type="CURSOR" />
<include name="IDC_COLRESIZE" file="cursors/col_resize.cur" type="CURSOR" />
<include name="IDC_COPYCUR" file="cursors/copy.cur" type="CURSOR" />
- <include name="IDC_CURSOR_NONE" file="cursors/none.cur" type="CURSOR" />
<include name="IDC_HAND_GRAB" file="cursors/hand_grab.cur" type="CURSOR" />
<include name="IDC_HAND_GRABBING" file="cursors/hand_grabbing.cur" type="CURSOR" />
<include name="IDC_PAN_EAST" file="cursors/pan_east.cur" type="CURSOR" />
diff --git a/chromium/ui/shell_dialogs/fake_select_file_dialog.cc b/chromium/ui/shell_dialogs/fake_select_file_dialog.cc
index 10187985095..d70a3e090d2 100644
--- a/chromium/ui/shell_dialogs/fake_select_file_dialog.cc
+++ b/chromium/ui/shell_dialogs/fake_select_file_dialog.cc
@@ -4,7 +4,6 @@
#include "ui/shell_dialogs/fake_select_file_dialog.h"
-#include "base/logging.h"
#include "ui/shell_dialogs/select_file_policy.h"
namespace ui {
diff --git a/chromium/ui/shell_dialogs/select_file_dialog.cc b/chromium/ui/shell_dialogs/select_file_dialog.cc
index 70163ef65e1..96e589f8980 100644
--- a/chromium/ui/shell_dialogs/select_file_dialog.cc
+++ b/chromium/ui/shell_dialogs/select_file_dialog.cc
@@ -8,8 +8,8 @@
#include <algorithm>
#include "base/bind.h"
+#include "base/check.h"
#include "base/location.h"
-#include "base/logging.h"
#include "base/single_thread_task_runner.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
diff --git a/chromium/ui/shell_dialogs/select_file_dialog_android.cc b/chromium/ui/shell_dialogs/select_file_dialog_android.cc
index 9dbd5f0c862..0a0c2989ea3 100644
--- a/chromium/ui/shell_dialogs/select_file_dialog_android.cc
+++ b/chromium/ui/shell_dialogs/select_file_dialog_android.cc
@@ -8,7 +8,8 @@
#include "base/android/jni_array.h"
#include "base/android/jni_string.h"
#include "base/android/scoped_java_ref.h"
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chromium/ui/shell_dialogs/select_file_dialog_fuchsia.cc b/chromium/ui/shell_dialogs/select_file_dialog_fuchsia.cc
index ff3e29eeea3..9bd4939bc6e 100644
--- a/chromium/ui/shell_dialogs/select_file_dialog_fuchsia.cc
+++ b/chromium/ui/shell_dialogs/select_file_dialog_fuchsia.cc
@@ -4,7 +4,7 @@
#include "ui/shell_dialogs/select_file_dialog.h"
-#include "base/logging.h"
+#include "base/notreached.h"
namespace ui {
diff --git a/chromium/ui/shell_dialogs/select_file_dialog_mac.mm b/chromium/ui/shell_dialogs/select_file_dialog_mac.mm
index da278d62639..1b48a3a0be3 100644
--- a/chromium/ui/shell_dialogs/select_file_dialog_mac.mm
+++ b/chromium/ui/shell_dialogs/select_file_dialog_mac.mm
@@ -5,7 +5,8 @@
#include "ui/shell_dialogs/select_file_dialog_mac.h"
#include "base/bind.h"
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "base/threading/thread_restrictions.h"
#include "components/remote_cocoa/app_shim/select_file_dialog_bridge.h"
#include "components/remote_cocoa/browser/window.h"
diff --git a/chromium/ui/shell_dialogs/select_file_dialog_win.cc b/chromium/ui/shell_dialogs/select_file_dialog_win.cc
index d36de175bad..e85d95fc680 100644
--- a/chromium/ui/shell_dialogs/select_file_dialog_win.cc
+++ b/chromium/ui/shell_dialogs/select_file_dialog_win.cc
@@ -8,11 +8,12 @@
#include <memory>
#include "base/bind.h"
+#include "base/check_op.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/i18n/case_conversion.h"
-#include "base/logging.h"
#include "base/macros.h"
+#include "base/notreached.h"
#include "base/single_thread_task_runner.h"
#include "base/task_runner_util.h"
#include "base/threading/thread_task_runner_handle.h"
diff --git a/chromium/ui/shell_dialogs/select_file_dialog_win_unittest.cc b/chromium/ui/shell_dialogs/select_file_dialog_win_unittest.cc
index a05b74596f0..90e29c495e7 100644
--- a/chromium/ui/shell_dialogs/select_file_dialog_win_unittest.cc
+++ b/chromium/ui/shell_dialogs/select_file_dialog_win_unittest.cc
@@ -283,8 +283,7 @@ TEST_F(SelectFileDialogWinTest, SpecifyTitle) {
// Create an existing file since it is required.
base::FilePath default_path = scoped_temp_dir.GetPath().Append(L"foo.txt");
std::string contents = "Hello test!";
- ASSERT_EQ(base::WriteFile(default_path, contents.c_str(), contents.length()),
- static_cast<int>(contents.length()));
+ ASSERT_TRUE(base::WriteFile(default_path, contents));
scoped_refptr<ui::SelectFileDialog> dialog =
ui::SelectFileDialog::Create(this, nullptr);
@@ -312,8 +311,7 @@ TEST_F(SelectFileDialogWinTest, TestSelectFile) {
// Create an existing file since it is required.
base::FilePath default_path = scoped_temp_dir.GetPath().Append(L"foo.txt");
std::string contents = "Hello test!";
- ASSERT_EQ(base::WriteFile(default_path, contents.c_str(), contents.length()),
- static_cast<int>(contents.length()));
+ ASSERT_TRUE(base::WriteFile(default_path, contents));
scoped_refptr<ui::SelectFileDialog> dialog =
ui::SelectFileDialog::Create(this, nullptr);
@@ -415,8 +413,7 @@ TEST_F(SelectFileDialogWinTest, OpenFileDifferentExtension) {
base::FilePath default_path = scoped_temp_dir.GetPath().Append(L"foo.txt");
std::string contents = "Hello test!";
- ASSERT_EQ(base::WriteFile(default_path, contents.c_str(), contents.length()),
- static_cast<int>(contents.length()));
+ ASSERT_TRUE(base::WriteFile(default_path, contents));
ui::SelectFileDialog::FileTypeInfo file_type_info;
file_type_info.extensions.push_back({L"exe"});
@@ -475,8 +472,7 @@ TEST_F(SelectFileDialogWinTest, SaveFileOverwritePrompt) {
base::FilePath default_path = scoped_temp_dir.GetPath().Append(L"foo.txt");
std::string contents = "Hello test!";
- ASSERT_EQ(base::WriteFile(default_path, contents.c_str(), contents.length()),
- static_cast<int>(contents.length()));
+ ASSERT_TRUE(base::WriteFile(default_path, contents));
ui::SelectFileDialog::FileTypeInfo file_type_info;
file_type_info.extensions.push_back({L"txt"});
diff --git a/chromium/ui/shell_dialogs/shell_dialog_linux.cc b/chromium/ui/shell_dialogs/shell_dialog_linux.cc
index 046c430dd46..f5999fb0cf0 100644
--- a/chromium/ui/shell_dialogs/shell_dialog_linux.cc
+++ b/chromium/ui/shell_dialogs/shell_dialog_linux.cc
@@ -4,6 +4,7 @@
#include "ui/shell_dialogs/shell_dialog_linux.h"
+#include "base/notreached.h"
#include "ui/shell_dialogs/select_file_policy.h"
namespace {
diff --git a/chromium/ui/snapshot/snapshot_mac.mm b/chromium/ui/snapshot/snapshot_mac.mm
index 66f1fb2492d..9d7f1efda4b 100644
--- a/chromium/ui/snapshot/snapshot_mac.mm
+++ b/chromium/ui/snapshot/snapshot_mac.mm
@@ -7,7 +7,7 @@
#import <Cocoa/Cocoa.h>
#include "base/callback.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/mac/scoped_cftyperef.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/image/image.h"
diff --git a/chromium/ui/strings/app_locale_settings.grd b/chromium/ui/strings/app_locale_settings.grd
index c07b66b53af..62ccf7adf29 100644
--- a/chromium/ui/strings/app_locale_settings.grd
+++ b/chromium/ui/strings/app_locale_settings.grd
@@ -28,6 +28,7 @@
<output filename="app_locale_settings_pa.pak" type="data_package" lang="pa" />
<output filename="app_locale_settings_si.pak" type="data_package" lang="si" />
<output filename="app_locale_settings_sq.pak" type="data_package" lang="sq" />
+ <output filename="app_locale_settings_sr-Latn.pak" type="data_package" lang="sr-Latn" />
<output filename="app_locale_settings_ur.pak" type="data_package" lang="ur" />
<output filename="app_locale_settings_uz.pak" type="data_package" lang="uz" />
<output filename="app_locale_settings_zh-HK.pak" type="data_package" lang="zh-HK" />
diff --git a/chromium/ui/strings/translations/ui_strings_ar.xtb b/chromium/ui/strings/translations/ui_strings_ar.xtb
index dd2101792e8..5b6cf00971e 100644
--- a/chromium/ui/strings/translations/ui_strings_ar.xtb
+++ b/chromium/ui/strings/translations/ui_strings_ar.xtb
@@ -100,7 +100,7 @@
<translation id="3740362395218339114"><ph name="QUANTITY" /> غيغابايت/ثانية</translation>
<translation id="3757388668994797779"><ph name="QUANTITY" /> غيغابايت</translation>
<translation id="3842239759367498783">متابعة القراءة من جهازك الجوّال <ph name="TITLE" /></translation>
-<translation id="385051799172605136">الرجوع إلى الوراء</translation>
+<translation id="385051799172605136">رجوع</translation>
<translation id="3889424535448813030">مفتاح سهم إلى اليمين</translation>
<translation id="3897092660631435901">قائمة</translation>
<translation id="3909791450649380159">&amp;قص</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_as.xtb b/chromium/ui/strings/translations/ui_strings_as.xtb
index fba571dd2fb..4ad11b378a9 100644
--- a/chromium/ui/strings/translations/ui_strings_as.xtb
+++ b/chromium/ui/strings/translations/ui_strings_as.xtb
@@ -17,7 +17,7 @@
<translation id="1293699935367580298">Esc</translation>
<translation id="1306549533752902673">চুপাৰিছ কৰা এপ্‌</translation>
<translation id="1368832886055348810">বাওঁফালৰ পৰা সোঁফাললৈ</translation>
-<translation id="1383876407941801731">সন্ধান</translation>
+<translation id="1383876407941801731">Search</translation>
<translation id="1398853756734560583">সৰ্বাধিক মাত্ৰালৈ বঢ়াওক</translation>
<translation id="1414271762428216854"><ph name="APP_NAME" />, ইনষ্টল হৈ থকা এপ্‌</translation>
<translation id="1450753235335490080"><ph name="CONTENT_TYPE" /> শ্বেয়াৰ কৰিব নোৱাৰি</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_bn.xtb b/chromium/ui/strings/translations/ui_strings_bn.xtb
index 84d0973263f..04b70eaa7d9 100644
--- a/chromium/ui/strings/translations/ui_strings_bn.xtb
+++ b/chromium/ui/strings/translations/ui_strings_bn.xtb
@@ -7,7 +7,7 @@
<translation id="1156623771253174079">{SECONDS,plural, =1{১ মিনিট আগে}one{# মিনিট আগে}other{# মিনিট আগে}}</translation>
<translation id="1169783199079129864">{MINUTES,plural, =1{১ মিনিট}one{# মিনিট}other{# মিনিট}}</translation>
<translation id="1181037720776840403">সরান</translation>
-<translation id="1201402288615127009">পরবর্তী</translation>
+<translation id="1201402288615127009">পরের</translation>
<translation id="1218444235442067213"><ph name="APP_NAME" />, Play Store অ্যাপ</translation>
<translation id="1243314992276662751">আপলোড</translation>
<translation id="1266864766717917324"><ph name="CONTENT_TYPE" /> শেয়ার করা যায়নি</translation>
@@ -17,7 +17,7 @@
<translation id="1293699935367580298">Esc</translation>
<translation id="1306549533752902673">প্রস্তাবিত অ্যাপ</translation>
<translation id="1368832886055348810">বাঁ থেকে ডান</translation>
-<translation id="1383876407941801731">সার্চ করুন</translation>
+<translation id="1383876407941801731">Search</translation>
<translation id="1398853756734560583">বড় করুন</translation>
<translation id="1414271762428216854"><ph name="APP_NAME" />, ইনস্টল করা অ্যাপ</translation>
<translation id="1450753235335490080"><ph name="CONTENT_TYPE" /> শেয়ার করা যাচ্ছে না</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_bs.xtb b/chromium/ui/strings/translations/ui_strings_bs.xtb
index 8f54910671a..985ced59676 100644
--- a/chromium/ui/strings/translations/ui_strings_bs.xtb
+++ b/chromium/ui/strings/translations/ui_strings_bs.xtb
@@ -250,7 +250,7 @@
<translation id="9161053988251441839">PREDLOŽENE APLIKACIJE</translation>
<translation id="9170848237812810038">&amp;Poništi</translation>
<translation id="9178475906033259337">Prikaz 1 rezultata za upit <ph name="QUERY" /></translation>
-<translation id="932327136139879170">Početna stranica</translation>
+<translation id="932327136139879170">Dom</translation>
<translation id="944069440740578670">Nepročitana obavještenja</translation>
<translation id="974545358917229949">Prikaz <ph name="RESULT_COUNT" /> rezultata za upit <ph name="QUERY" /></translation>
</translationbundle> \ No newline at end of file
diff --git a/chromium/ui/strings/translations/ui_strings_da.xtb b/chromium/ui/strings/translations/ui_strings_da.xtb
index beb30e5b569..40441af95ba 100644
--- a/chromium/ui/strings/translations/ui_strings_da.xtb
+++ b/chromium/ui/strings/translations/ui_strings_da.xtb
@@ -218,7 +218,7 @@
<translation id="815598010540052116">Scroll Down</translation>
<translation id="8179976553408161302">Enter</translation>
<translation id="8210608804940886430">Side ned</translation>
-<translation id="8245914219290430011">Tab-tast</translation>
+<translation id="8245914219290430011">Tab</translation>
<translation id="8247998213073982446"><ph name="APP_NAME" />, app</translation>
<translation id="8259556432390118667">Hex-farveværdi</translation>
<translation id="8328145009876646418">Venstre kant</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_de.xtb b/chromium/ui/strings/translations/ui_strings_de.xtb
index 47f2b9e533a..e1b4b988535 100644
--- a/chromium/ui/strings/translations/ui_strings_de.xtb
+++ b/chromium/ui/strings/translations/ui_strings_de.xtb
@@ -5,7 +5,7 @@
<translation id="111910763555783249">Benachrichtigungseinstellungen</translation>
<translation id="1127811143501539442">{DAYS,plural, =1{1 Tag her}other{# Tage her}}</translation>
<translation id="1156623771253174079">{SECONDS,plural, =1{vor 1 Minute}other{vor # Minuten}}</translation>
-<translation id="1169783199079129864">{MINUTES,plural, =1{1 Min.}other{# Min.}}</translation>
+<translation id="1169783199079129864">{MINUTES,plural, =1{1 min}other{# min}}</translation>
<translation id="1181037720776840403">Entfernen</translation>
<translation id="1201402288615127009">Weiter</translation>
<translation id="1218444235442067213"><ph name="APP_NAME" />, Play Store-App</translation>
@@ -17,8 +17,8 @@
<translation id="1293699935367580298">Esc</translation>
<translation id="1306549533752902673">EMPFOHLENE APPS</translation>
<translation id="1368832886055348810">Rechtsläufig</translation>
-<translation id="1383876407941801731">Suchen</translation>
-<translation id="1398853756734560583">Vergrößern</translation>
+<translation id="1383876407941801731">Durchsuchen</translation>
+<translation id="1398853756734560583">Maximieren</translation>
<translation id="1414271762428216854"><ph name="APP_NAME" />, installierte App</translation>
<translation id="1450753235335490080"><ph name="CONTENT_TYPE" /> kann nicht geteilt werden</translation>
<translation id="1487931858675166540"><ph name="FIRST_ITEM_TITLE" /> und <ph name="SECOND_ITEM_TITLE" /> haben die Plätze getauscht</translation>
@@ -139,19 +139,19 @@
<translation id="5583640892426849032">Rücktaste</translation>
<translation id="5613020302032141669">Linkspfeil</translation>
<translation id="5675363643668471212">Ablageartikel</translation>
-<translation id="5754277640426581776">{MINUTES,plural, =1{1 Min.}other{# Min.}}</translation>
+<translation id="5754277640426581776">{MINUTES,plural, =1{1 min}other{# min}}</translation>
<translation id="5763338081255973061">{DAYS,plural, =0{Heute aktiv}=1{Vor 1 Tag aktiv}other{Vor # Tagen aktiv}}</translation>
<translation id="5768079895599174203">{DAYS,plural, =1{1 Tag und }other{# Tage und }}</translation>
<translation id="5789643057113097023">.</translation>
<translation id="5866104238061687188">{YEARS,plural, =1{in 1 J.}other{in # J.}}</translation>
<translation id="5906667377645263094">{SECONDS,plural, =1{1 Sekunde übrig}other{# Sekunden übrig}}</translation>
-<translation id="5941711191222866238">Verkleinern</translation>
+<translation id="5941711191222866238">Minimieren</translation>
<translation id="5943826764092288734">{HOURS,plural, =1{1 Stunde}other{# Stunden}}</translation>
<translation id="6012623610530968780">Seite <ph name="SELECTED_PAGE" /> von <ph name="TOTAL_PAGE_NUM" /></translation>
<translation id="6022924867608035986">Text im Suchfeld löschen</translation>
<translation id="6040143037577758943">Schließen</translation>
<translation id="6119846243427417423">aktivieren</translation>
-<translation id="6129953537138746214">Leerzeichen</translation>
+<translation id="6129953537138746214">Leertaste</translation>
<translation id="6135826906199951471">Entf</translation>
<translation id="6142413573757616983"><ph name="QUANTITY" /> Byte/s</translation>
<translation id="6156262341071374681">Maximieren und alle Apps anzeigen</translation>
@@ -161,7 +161,7 @@
<translation id="6364916375976753737">Nach links blättern</translation>
<translation id="6394627529324717982">Komma</translation>
<translation id="6397363302884558537">Sprachausgabe stoppen</translation>
-<translation id="6404817160109697034">{SECONDS,plural, =1{1 Sek. her}other{# Sek. her}}</translation>
+<translation id="6404817160109697034">{SECONDS,plural, =1{Vor 1 s}other{Vor # s}}</translation>
<translation id="6417265370957905582">Google Assistant</translation>
<translation id="6430678249303439055">Alle Benachrichtigungen von dieser App blockieren</translation>
<translation id="6483402905448010557">{SECONDS,plural, =1{Vor 1 Sekunde}other{Vor # Sekunden}}</translation>
@@ -190,10 +190,10 @@
<translation id="7130207228079676353">HOHE WAHRSCHEINLICHKEIT</translation>
<translation id="7170202025028120564">Die Displayeinstellungen Ihrer App werden beim nächsten Neustart übernommen.</translation>
<translation id="7222373446505536781">F11</translation>
-<translation id="7238427729722629793">{MINUTES,plural, =1{1 Min. übrig}other{# Min. übrig}}</translation>
+<translation id="7238427729722629793">{MINUTES,plural, =1{1 min übrig}other{# min übrig}}</translation>
<translation id="7319740667687257810">Übersicht, Teilansicht</translation>
<translation id="7352651011704765696">Ein Problem ist aufgetreten.</translation>
-<translation id="7365057348334984696">{MINUTES,plural, =1{vor 1 Min.}other{vor # Min.}}</translation>
+<translation id="7365057348334984696">{MINUTES,plural, =1{vor 1 min}other{vor # min}}</translation>
<translation id="7389409599945284130">– <ph name="MESSAGE" /></translation>
<translation id="7410957453383678442">{MINUTES,plural, =1{1 Minute übrig}other{# Minuten übrig}}</translation>
<translation id="7430878839542012341">Diese Suchanfrage aus dem Verlauf löschen?</translation>
@@ -207,11 +207,11 @@
<translation id="7907591526440419938">Datei öffnen</translation>
<translation id="7969046989155602842">Befehl</translation>
<translation id="8074552109918343525">{MAX_UNREAD_NOTIFICATIONS,plural, =1{Mehr als 1 ungelesene Benachrichtigung}other{Mehr als # ungelesene Benachrichtigungen}}</translation>
-<translation id="8086866675552927481">{MINUTES,plural, =1{in 1 Min.}other{in # Min.}}</translation>
+<translation id="8086866675552927481">{MINUTES,plural, =1{in 1 min}other{in # min}}</translation>
<translation id="8087772101393322318"><ph name="KEY_MODIFIER_NAME" /> + <ph name="KEY_COMBO_NAME" /></translation>
<translation id="8090736967111090568">Zahl von <ph name="ORIGIN" /></translation>
<translation id="8106081041558092062">{HOURS,plural, =1{1 Stunde her}other{# Stunden her}}</translation>
-<translation id="8131263257437993507">{SECONDS,plural, =1{1 Sek. übrig}other{# Sek. übrig}}</translation>
+<translation id="8131263257437993507">{SECONDS,plural, =1{Noch 1 s}other{Noch # s}}</translation>
<translation id="8134065097954893699">Diese Seite neu laden</translation>
<translation id="8144660977431427332">Ihre Suchanfragen werden mit Google Assistant durchgeführt. <ph name="LEARN_MORE" /></translation>
<translation id="8152264887680882389"><ph name="TEXT" />, automatische Vervollständigung</translation>
@@ -234,7 +234,7 @@
<translation id="8725488761726303204">+<ph name="NUMBER" /> weitere</translation>
<translation id="8730621377337864115">Fertig</translation>
<translation id="8772073294905169192">{HOURS,plural, =1{1 h}other{# h}}</translation>
-<translation id="8798099450830957504">Standardeinstellung</translation>
+<translation id="8798099450830957504">Standard</translation>
<translation id="8806053966018712535">Ordner <ph name="FOLDER_NAME" /></translation>
<translation id="883911313571074303">Bild mit Anmerkung versehen</translation>
<translation id="8841375032071747811">Schaltfläche "Zurück"</translation>
@@ -244,7 +244,7 @@
<translation id="8926951137623668982">Ablage immer ausgeblendet</translation>
<translation id="8996630695507351249">Prüfen Sie, ob "<ph name="TARGET_DEVICE_NAME" />" mit dem Internet verbunden ist.</translation>
<translation id="9002566407876343676">Öffnen</translation>
-<translation id="9044832324875206639">{SECONDS,plural, =1{1 Sek.}other{# Sek.}}</translation>
+<translation id="9044832324875206639">{SECONDS,plural, =1{1 s}other{# s}}</translation>
<translation id="9059834730836941392">Benachrichtigung minimieren</translation>
<translation id="9150735707954472829">Tab</translation>
<translation id="9161053988251441839">VORGESCHLAGENE APPS</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_es.xtb b/chromium/ui/strings/translations/ui_strings_es.xtb
index df6907302f6..28decd8b3bf 100644
--- a/chromium/ui/strings/translations/ui_strings_es.xtb
+++ b/chromium/ui/strings/translations/ui_strings_es.xtb
@@ -100,7 +100,7 @@
<translation id="3740362395218339114"><ph name="QUANTITY" /> GB/s</translation>
<translation id="3757388668994797779"><ph name="QUANTITY" /> GB</translation>
<translation id="3842239759367498783">Continúa leyendo en tu dispositivo móvil <ph name="TITLE" /></translation>
-<translation id="385051799172605136">Atrás</translation>
+<translation id="385051799172605136">Volver</translation>
<translation id="3889424535448813030">Flecha derecha</translation>
<translation id="3897092660631435901">Menú</translation>
<translation id="3909791450649380159">Cor&amp;tar</translation>
@@ -196,7 +196,7 @@
<translation id="7365057348334984696">{MINUTES,plural, =1{Hace 1 min}other{Hace # min}}</translation>
<translation id="7389409599945284130">- <ph name="MESSAGE" /></translation>
<translation id="7410957453383678442">{MINUTES,plural, =1{Queda 1 minuto}other{Quedan # minutos}}</translation>
-<translation id="7430878839542012341">¿Quieres eliminar esta búsqueda de tu historial?</translation>
+<translation id="7430878839542012341">¿Eliminar esta búsqueda de tu historial?</translation>
<translation id="7460907917090416791"><ph name="QUANTITY" /> TB</translation>
<translation id="7507604095951736240">Emoji</translation>
<translation id="7658239707568436148">Cancelar</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_et.xtb b/chromium/ui/strings/translations/ui_strings_et.xtb
index 4fea851bc62..fb176475f0d 100644
--- a/chromium/ui/strings/translations/ui_strings_et.xtb
+++ b/chromium/ui/strings/translations/ui_strings_et.xtb
@@ -7,7 +7,7 @@
<translation id="1156623771253174079">{SECONDS,plural, =1{1 minut tagasi}other{# minutit tagasi}}</translation>
<translation id="1169783199079129864">{MINUTES,plural, =1{1m}other{#m}}</translation>
<translation id="1181037720776840403">Eemalda</translation>
-<translation id="1201402288615127009">Edasi</translation>
+<translation id="1201402288615127009">Järgmine</translation>
<translation id="1218444235442067213"><ph name="APP_NAME" />, Play poe rakendus</translation>
<translation id="1243314992276662751">Laadi üles</translation>
<translation id="1266864766717917324">Üksust <ph name="CONTENT_TYPE" /> ei õnnestunud jagada</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_fi.xtb b/chromium/ui/strings/translations/ui_strings_fi.xtb
index 13b775119e2..7a8049602f7 100644
--- a/chromium/ui/strings/translations/ui_strings_fi.xtb
+++ b/chromium/ui/strings/translations/ui_strings_fi.xtb
@@ -100,7 +100,7 @@
<translation id="3740362395218339114"><ph name="QUANTITY" /> Gt/s</translation>
<translation id="3757388668994797779"><ph name="QUANTITY" /> Gt</translation>
<translation id="3842239759367498783">Jatka lukemista mobiililaitteella <ph name="TITLE" /></translation>
-<translation id="385051799172605136">Edellinen</translation>
+<translation id="385051799172605136">Takaisin</translation>
<translation id="3889424535448813030">Nuoli oik.</translation>
<translation id="3897092660631435901">Valikko</translation>
<translation id="3909791450649380159">L&amp;eikkaa</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_fr.xtb b/chromium/ui/strings/translations/ui_strings_fr.xtb
index 820f4846d73..56f8f0b1a26 100644
--- a/chromium/ui/strings/translations/ui_strings_fr.xtb
+++ b/chromium/ui/strings/translations/ui_strings_fr.xtb
@@ -247,7 +247,7 @@
<translation id="9044832324875206639">{SECONDS,plural, =1{1 s}one{# s}other{# s}}</translation>
<translation id="9059834730836941392">Réduire la notification</translation>
<translation id="9150735707954472829">Onglet</translation>
-<translation id="9161053988251441839">APPLICATIONS SUGGÉRÉES</translation>
+<translation id="9161053988251441839">SUGGESTIONS D'APPLICATIONS</translation>
<translation id="9170848237812810038">Ann&amp;uler</translation>
<translation id="9178475906033259337">1 résultat pour <ph name="QUERY" /></translation>
<translation id="932327136139879170">Accueil</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_gu.xtb b/chromium/ui/strings/translations/ui_strings_gu.xtb
index 1599523d415..b2533b4b1ec 100644
--- a/chromium/ui/strings/translations/ui_strings_gu.xtb
+++ b/chromium/ui/strings/translations/ui_strings_gu.xtb
@@ -58,7 +58,7 @@
<translation id="2388990488038464401">તમારા ફોન વડે આ નંબર પર કૉલ કરીએ?</translation>
<translation id="24452542372838207">નોટિફિકેશન વિસ્તૃત કરો</translation>
<translation id="2445449901874883781">વધારે ઘનતાનો ઉપયોગ કરો</translation>
-<translation id="2482878487686419369">સૂચનાઓ</translation>
+<translation id="2482878487686419369">નોટિફિકેશનો</translation>
<translation id="2497284189126895209">બધી ફાઇલો</translation>
<translation id="2515586267016047495">Alt</translation>
<translation id="2522350507219695259">કૅલિબ્રેશન પૂર્ણ થયું</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_hi.xtb b/chromium/ui/strings/translations/ui_strings_hi.xtb
index cc14d30bee3..e5ac8baf2c9 100644
--- a/chromium/ui/strings/translations/ui_strings_hi.xtb
+++ b/chromium/ui/strings/translations/ui_strings_hi.xtb
@@ -17,7 +17,7 @@
<translation id="1293699935367580298">Esc</translation>
<translation id="1306549533752902673">सुझाए गए ऐप्लिकेशन</translation>
<translation id="1368832886055348810">बाएं से दाएं</translation>
-<translation id="1383876407941801731">खोजें</translation>
+<translation id="1383876407941801731">Search</translation>
<translation id="1398853756734560583">बड़ा करें</translation>
<translation id="1414271762428216854"><ph name="APP_NAME" />, इंस्टॉल किए गए ऐप्लिकेशन</translation>
<translation id="1450753235335490080"><ph name="CONTENT_TYPE" /> शेयर नहीं किया जा सकता</translation>
@@ -100,7 +100,7 @@
<translation id="3740362395218339114"><ph name="QUANTITY" /> जीबी/सेकंड</translation>
<translation id="3757388668994797779"><ph name="QUANTITY" /> जीबी</translation>
<translation id="3842239759367498783">अपने मोबाइल डिवाइस से <ph name="TITLE" /> पढ़ना जारी रखें</translation>
-<translation id="385051799172605136">वापस</translation>
+<translation id="385051799172605136">वापस जाएं</translation>
<translation id="3889424535448813030">दायां तीर</translation>
<translation id="3897092660631435901">मेन्यू</translation>
<translation id="3909791450649380159">&amp;काटें</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_hy.xtb b/chromium/ui/strings/translations/ui_strings_hy.xtb
index 8dc683b37da..3e327981b95 100644
--- a/chromium/ui/strings/translations/ui_strings_hy.xtb
+++ b/chromium/ui/strings/translations/ui_strings_hy.xtb
@@ -48,7 +48,7 @@
<translation id="2161656808144014275">Տեքստ</translation>
<translation id="2168039046890040389">Էջը վեր</translation>
<translation id="2190355936436201913">(դատարկ)</translation>
-<translation id="2192232475740621500">Ցուցադրել ավելի քիչ պատուհաններ</translation>
+<translation id="2192232475740621500">Ցույց տալ ավելի քիչ պատուհաններ</translation>
<translation id="219905428774326614">Գործարկիչ, բոլոր հավելվածները</translation>
<translation id="2267918077332197517">Արգելափակել այս կայքի բոլոր ծանուցումները</translation>
<translation id="2289052229480071835">Ձեր էկրանին հպեք ինտերակտիվ տարրերին:</translation>
@@ -57,7 +57,7 @@
<translation id="2353636109065292463">Ինտերնետ կապի ստուգում</translation>
<translation id="2388990488038464401">Զանգե՞լ այս համարին ձեր հեռախոսից</translation>
<translation id="24452542372838207">Ընդարձակել</translation>
-<translation id="2445449901874883781">Ցուցադրել ավելի շատ պատուհաններ</translation>
+<translation id="2445449901874883781">Ցույց տալ ավելի շատ պատուհաններ</translation>
<translation id="2482878487686419369">Ծանուցումներ</translation>
<translation id="2497284189126895209">Բոլոր ֆայլերը</translation>
<translation id="2515586267016047495">Alt</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_id.xtb b/chromium/ui/strings/translations/ui_strings_id.xtb
index 497df787cec..dc1ab9af24d 100644
--- a/chromium/ui/strings/translations/ui_strings_id.xtb
+++ b/chromium/ui/strings/translations/ui_strings_id.xtb
@@ -100,7 +100,7 @@
<translation id="3740362395218339114"><ph name="QUANTITY" /> GB/dtk</translation>
<translation id="3757388668994797779"><ph name="QUANTITY" /> GB</translation>
<translation id="3842239759367498783">Lanjutkan membaca dari perangkat seluler <ph name="TITLE" /></translation>
-<translation id="385051799172605136">Mundur</translation>
+<translation id="385051799172605136">Kembali</translation>
<translation id="3889424535448813030">Panah Kanan</translation>
<translation id="3897092660631435901">Menu</translation>
<translation id="3909791450649380159">Po&amp;tong</translation>
@@ -155,7 +155,7 @@
<translation id="6135826906199951471">Del</translation>
<translation id="6142413573757616983"><ph name="QUANTITY" /> B/dtk</translation>
<translation id="6156262341071374681">Tampilkan semua aplikasi</translation>
-<translation id="6165508094623778733">Pelajari lebih lanjut</translation>
+<translation id="6165508094623778733">Pelajari selengkapnya</translation>
<translation id="6264365405983206840">Pilih Semu&amp;a</translation>
<translation id="6351032674660237738">SARAN APLIKASI</translation>
<translation id="6364916375976753737">Gulir ke Kiri</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_kk.xtb b/chromium/ui/strings/translations/ui_strings_kk.xtb
index 30793b6890a..db897f0f342 100644
--- a/chromium/ui/strings/translations/ui_strings_kk.xtb
+++ b/chromium/ui/strings/translations/ui_strings_kk.xtb
@@ -58,7 +58,7 @@
<translation id="2388990488038464401">Осы нөмірге телефоныңыздан қоңырау шалынсын ба?</translation>
<translation id="24452542372838207">Хабарландыруды жаю</translation>
<translation id="2445449901874883781">Жоғары тығыздықты пайдалану</translation>
-<translation id="2482878487686419369">Хабарламалар</translation>
+<translation id="2482878487686419369">Хабарландырулар</translation>
<translation id="2497284189126895209">Барлық файлдар</translation>
<translation id="2515586267016047495">Alt</translation>
<translation id="2522350507219695259">Калибрлеу аяқталды</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_kn.xtb b/chromium/ui/strings/translations/ui_strings_kn.xtb
index 40f852e2401..8573b7d1cc9 100644
--- a/chromium/ui/strings/translations/ui_strings_kn.xtb
+++ b/chromium/ui/strings/translations/ui_strings_kn.xtb
@@ -17,7 +17,7 @@
<translation id="1293699935367580298">Esc</translation>
<translation id="1306549533752902673">ಶಿಫಾರಸು ಮಾಡಲಾದ ಅಪ್ಲಿಕೇಶನ್‌ಗಳು</translation>
<translation id="1368832886055348810">ಎಡದಿಂದ ಬಲಕ್ಕೆ</translation>
-<translation id="1383876407941801731">ಹುಡುಕಾಟ</translation>
+<translation id="1383876407941801731">Search</translation>
<translation id="1398853756734560583">ಗರಿಷ್ಠಗೊಳಿಸು</translation>
<translation id="1414271762428216854"><ph name="APP_NAME" />, ಇನ್‌ಸ್ಟಾಲ್ ಮಾಡಿದ ಆ್ಯಪ್</translation>
<translation id="1450753235335490080"><ph name="CONTENT_TYPE" />ವನ್ನು ಹಂಚಿಕೊಳ್ಳಲು ಸಾಧ್ಯವಾಗುತ್ತಿಲ್ಲ</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_lv.xtb b/chromium/ui/strings/translations/ui_strings_lv.xtb
index 2c321d3deaa..a9eca465e8c 100644
--- a/chromium/ui/strings/translations/ui_strings_lv.xtb
+++ b/chromium/ui/strings/translations/ui_strings_lv.xtb
@@ -155,7 +155,7 @@
<translation id="6135826906199951471">Dzēst</translation>
<translation id="6142413573757616983"><ph name="QUANTITY" /> B/s</translation>
<translation id="6156262341071374681">Skatīt visas lietotnes</translation>
-<translation id="6165508094623778733">Uzziniet vairāk</translation>
+<translation id="6165508094623778733">Uzzināt vairāk</translation>
<translation id="6264365405983206840">&amp;Atlasīt visu</translation>
<translation id="6351032674660237738">LIETOTŅU IETEIKUMI</translation>
<translation id="6364916375976753737">Ritināt pa kreisi</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_ml.xtb b/chromium/ui/strings/translations/ui_strings_ml.xtb
index 2b99545d3fe..9dcea7f76bd 100644
--- a/chromium/ui/strings/translations/ui_strings_ml.xtb
+++ b/chromium/ui/strings/translations/ui_strings_ml.xtb
@@ -17,7 +17,7 @@
<translation id="1293699935367580298">Esc</translation>
<translation id="1306549533752902673">ശുപാർശിത ആപ്പുകൾ</translation>
<translation id="1368832886055348810">ഇടതുനിന്ന് വലത്തേക്ക്</translation>
-<translation id="1383876407941801731">തിരയുക</translation>
+<translation id="1383876407941801731">Search</translation>
<translation id="1398853756734560583">വലുതാക്കുക</translation>
<translation id="1414271762428216854"><ph name="APP_NAME" />, ഇൻസ്‌റ്റാൾ ചെയ്‌ത ആപ്പ്</translation>
<translation id="1450753235335490080"><ph name="CONTENT_TYPE" /> പങ്കിടാനാവുന്നില്ല</translation>
@@ -58,7 +58,7 @@
<translation id="2388990488038464401">നിങ്ങളുടെ ഫോണിൽ നിന്ന് ഈ നമ്പറിലേക്ക് വിളിക്കണോ?</translation>
<translation id="24452542372838207">അറിയിപ്പ് വികസിപ്പിക്കുക</translation>
<translation id="2445449901874883781">കൂടിയ സാന്ദ്രത ഉപയോഗിക്കുക</translation>
-<translation id="2482878487686419369">വിജ്ഞാപനങ്ങള്‍‌</translation>
+<translation id="2482878487686419369">അറിയിപ്പുകൾ</translation>
<translation id="2497284189126895209">എല്ലാ ഫയലുകളും</translation>
<translation id="2515586267016047495">Alt</translation>
<translation id="2522350507219695259">കാലിബറേഷൻ പൂർത്തിയായി</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_mr.xtb b/chromium/ui/strings/translations/ui_strings_mr.xtb
index b502b198bea..bfffd0474da 100644
--- a/chromium/ui/strings/translations/ui_strings_mr.xtb
+++ b/chromium/ui/strings/translations/ui_strings_mr.xtb
@@ -17,7 +17,7 @@
<translation id="1293699935367580298">Esc</translation>
<translation id="1306549533752902673">शिफारस केलेले अ‍ॅप्स</translation>
<translation id="1368832886055348810">डावीकडून उजवीकडे</translation>
-<translation id="1383876407941801731">शोधा</translation>
+<translation id="1383876407941801731">Search</translation>
<translation id="1398853756734560583">वाढवा</translation>
<translation id="1414271762428216854"><ph name="APP_NAME" />, इंस्टॉल केलेले अ‍ॅप</translation>
<translation id="1450753235335490080"><ph name="CONTENT_TYPE" /> शेअर करू शकत नाही</translation>
@@ -75,7 +75,7 @@
<translation id="2907671656515444832">{DAYS,plural, =1{१दि मध्ये}other{#दि मध्ये}}</translation>
<translation id="2931838996092594335">क्लिक करा</translation>
<translation id="2981684127883932071">सूचना दाखवत आहे</translation>
-<translation id="3036649622769666520">फायली उघडा</translation>
+<translation id="3036649622769666520">फाइल उघडा</translation>
<translation id="3049748772180311791"><ph name="QUANTITY" /> MB</translation>
<translation id="3068711042108640621">शेल्फ डावीकडे आहे</translation>
<translation id="3087734570205094154">तळाकडील</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_my.xtb b/chromium/ui/strings/translations/ui_strings_my.xtb
index f4d73d875ba..cbab5923fe2 100644
--- a/chromium/ui/strings/translations/ui_strings_my.xtb
+++ b/chromium/ui/strings/translations/ui_strings_my.xtb
@@ -58,7 +58,7 @@
<translation id="2388990488038464401">သင့်ဖုန်းမှနေ၍ ဤနံပါတ်ကို ခေါ်လိုပါသလား။</translation>
<translation id="24452542372838207">အကြောင်းကြားချက်ကို ချဲ့ရန်</translation>
<translation id="2445449901874883781">သိပ်သည်းဆအမြင့် သုံးရန်</translation>
-<translation id="2482878487686419369">အကြောင်းကြားချက်များ</translation>
+<translation id="2482878487686419369">အကြောင်းကြားစာ</translation>
<translation id="2497284189126895209">ဖိုင်များ အားလုံး</translation>
<translation id="2515586267016047495">Alt</translation>
<translation id="2522350507219695259">စံကိုက်ချိန်ညှိ ပြီးပါပြီ</translation>
@@ -248,7 +248,7 @@
<translation id="9059834730836941392">အကြောင်းကြားချက်ကို လျှော့ပြရန်</translation>
<translation id="9150735707954472829">တဘ်</translation>
<translation id="9161053988251441839">အကြံပြုထားသည့် အက်ပ်များ</translation>
-<translation id="9170848237812810038">&amp;ပြန်ဖျက်ရန်</translation>
+<translation id="9170848237812810038">&amp;တစ်ဆင့်နောက်ပြန်ရန်</translation>
<translation id="9178475906033259337"><ph name="QUERY" /> အတွက် ရလဒ် ၁ ခုကို ပြနေသည်</translation>
<translation id="932327136139879170">ပင်မ</translation>
<translation id="944069440740578670">မဖတ်ရသေးသော အကြောင်းကြားချက်များ</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_nl.xtb b/chromium/ui/strings/translations/ui_strings_nl.xtb
index ae48729a370..6594b0daa54 100644
--- a/chromium/ui/strings/translations/ui_strings_nl.xtb
+++ b/chromium/ui/strings/translations/ui_strings_nl.xtb
@@ -100,7 +100,7 @@
<translation id="3740362395218339114"><ph name="QUANTITY" /> GB/s</translation>
<translation id="3757388668994797779"><ph name="QUANTITY" /> GB</translation>
<translation id="3842239759367498783">Verder lezen vanaf je mobiele apparaat <ph name="TITLE" /></translation>
-<translation id="385051799172605136">Vorige</translation>
+<translation id="385051799172605136">Terug</translation>
<translation id="3889424535448813030">Pijl-rechts</translation>
<translation id="3897092660631435901">Menu</translation>
<translation id="3909791450649380159">&amp;Knippen</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_or.xtb b/chromium/ui/strings/translations/ui_strings_or.xtb
index 35b0b0d7c3a..89a1a6d2711 100644
--- a/chromium/ui/strings/translations/ui_strings_or.xtb
+++ b/chromium/ui/strings/translations/ui_strings_or.xtb
@@ -17,7 +17,7 @@
<translation id="1293699935367580298">Esc</translation>
<translation id="1306549533752902673">ସୁପାରିଶ୍ କରାଯାଇଥିବା ଆପ୍‍ଗୁଡ଼ିକ</translation>
<translation id="1368832886055348810">ବାମରୁ ଡାହାଣ</translation>
-<translation id="1383876407941801731">ସନ୍ଧାନ</translation>
+<translation id="1383876407941801731">Search</translation>
<translation id="1398853756734560583">ସର୍ବାଧିକ କରନ୍ତୁ</translation>
<translation id="1414271762428216854"><ph name="APP_NAME" />, ଇନ୍‌ଷ୍ଟଲ୍ କରାଯାଇଥିବା ଆପ୍</translation>
<translation id="1450753235335490080"><ph name="CONTENT_TYPE" /> ସେୟାର୍ କରାଯାଇ ପାରିବ ନାହିଁ</translation>
@@ -58,7 +58,7 @@
<translation id="2388990488038464401">ଆପଣଙ୍କ ଫୋନ୍‌ରୁ ଏହି ନମ୍ବର୍‍କୁ କଲ୍ କରିବେ?</translation>
<translation id="24452542372838207">ବିଜ୍ଞପ୍ତି ସଂପ୍ରସାରଣ କରନ୍ତୁ</translation>
<translation id="2445449901874883781">ଉଚ୍ଚ ସାନ୍ଧ୍ରତା ବ୍ୟବହାର କରନ୍ତୁ</translation>
-<translation id="2482878487686419369">ବିଜ୍ଞପ୍ତିଗୁଡ଼ିକ</translation>
+<translation id="2482878487686419369">ବିଜ୍ଞପ୍ତି</translation>
<translation id="2497284189126895209">ସମସ୍ତ ଫାଇଲଗୁଡିକ</translation>
<translation id="2515586267016047495">Alt</translation>
<translation id="2522350507219695259">କାଲିବ୍ରାସନ୍‍ ସମ୍ପୂର୍ଣ୍ଣ ହୋ‍ଇଛି</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_pl.xtb b/chromium/ui/strings/translations/ui_strings_pl.xtb
index 98c1b804e1e..8ab68c4217e 100644
--- a/chromium/ui/strings/translations/ui_strings_pl.xtb
+++ b/chromium/ui/strings/translations/ui_strings_pl.xtb
@@ -85,7 +85,7 @@
<translation id="3234408098842461169">Strzałka w dół</translation>
<translation id="3291688615589870984">{DAYS,plural, =1{1 dzień}few{# dni}many{# dni}other{# dnia}}</translation>
<translation id="3295886253693811851">Zadzwoń z:</translation>
-<translation id="3306688585798492231">Wbudowany wyświetlacz</translation>
+<translation id="3306688585798492231">Wyświetlacz wbudowany</translation>
<translation id="335581015389089642">Mowa</translation>
<translation id="3389286852084373014">Tekst jest za długi</translation>
<translation id="348799646910989694">Półka ukryta automatycznie</translation>
@@ -155,7 +155,7 @@
<translation id="6135826906199951471">Del</translation>
<translation id="6142413573757616983"><ph name="QUANTITY" /> B/s</translation>
<translation id="6156262341071374681">Rozwiń, by wyświetlić wszystkie aplikacje</translation>
-<translation id="6165508094623778733">Więcej informacji</translation>
+<translation id="6165508094623778733">Dowiedz się więcej</translation>
<translation id="6264365405983206840">Wybierz &amp;wszystko</translation>
<translation id="6351032674660237738">SUGEROWANE APLIKACJE</translation>
<translation id="6364916375976753737">Przewiń w lewo</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_ru.xtb b/chromium/ui/strings/translations/ui_strings_ru.xtb
index 5377dcb8a47..e0832270221 100644
--- a/chromium/ui/strings/translations/ui_strings_ru.xtb
+++ b/chromium/ui/strings/translations/ui_strings_ru.xtb
@@ -155,7 +155,7 @@
<translation id="6135826906199951471">Del</translation>
<translation id="6142413573757616983"><ph name="QUANTITY" /> Б/с</translation>
<translation id="6156262341071374681">Просмотреть все приложения</translation>
-<translation id="6165508094623778733">Подробнее...</translation>
+<translation id="6165508094623778733">Подробнее</translation>
<translation id="6264365405983206840">Выделить все</translation>
<translation id="6351032674660237738">ПРЕДЛАГАЕМЫЕ ПРИЛОЖЕНИЯ</translation>
<translation id="6364916375976753737">Прокрутка влево</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_sk.xtb b/chromium/ui/strings/translations/ui_strings_sk.xtb
index a65a404c0e7..dc2fcfa2010 100644
--- a/chromium/ui/strings/translations/ui_strings_sk.xtb
+++ b/chromium/ui/strings/translations/ui_strings_sk.xtb
@@ -100,7 +100,7 @@
<translation id="3740362395218339114"><ph name="QUANTITY" /> GB/s</translation>
<translation id="3757388668994797779"><ph name="QUANTITY" /> GB</translation>
<translation id="3842239759367498783">Pokračujte v čítaní v mobilnom zariadení <ph name="TITLE" /></translation>
-<translation id="385051799172605136">Naspäť</translation>
+<translation id="385051799172605136">Späť</translation>
<translation id="3889424535448813030">Šípka doprava</translation>
<translation id="3897092660631435901">Ponuka</translation>
<translation id="3909791450649380159">&amp;Vystrihnúť</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_sv.xtb b/chromium/ui/strings/translations/ui_strings_sv.xtb
index 2e99c873bd1..d7111e15e58 100644
--- a/chromium/ui/strings/translations/ui_strings_sv.xtb
+++ b/chromium/ui/strings/translations/ui_strings_sv.xtb
@@ -100,7 +100,7 @@
<translation id="3740362395218339114"><ph name="QUANTITY" /> GB/sek</translation>
<translation id="3757388668994797779"><ph name="QUANTITY" /> GB</translation>
<translation id="3842239759367498783">Fortsätt att läsa på din mobila enhet <ph name="TITLE" /></translation>
-<translation id="385051799172605136">Bakåt</translation>
+<translation id="385051799172605136">Föregående</translation>
<translation id="3889424535448813030">Högerpil</translation>
<translation id="3897092660631435901">Meny</translation>
<translation id="3909791450649380159">&amp;Klipp ut</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_ta.xtb b/chromium/ui/strings/translations/ui_strings_ta.xtb
index 36f25619819..78b433b72ba 100644
--- a/chromium/ui/strings/translations/ui_strings_ta.xtb
+++ b/chromium/ui/strings/translations/ui_strings_ta.xtb
@@ -17,7 +17,7 @@
<translation id="1293699935367580298">Esc</translation>
<translation id="1306549533752902673">பரிந்துரைக்கப்படும் ஆப்ஸ்</translation>
<translation id="1368832886055348810">இடமிருந்து வலம்</translation>
-<translation id="1383876407941801731">தேடல்</translation>
+<translation id="1383876407941801731">Search</translation>
<translation id="1398853756734560583">பெரிதாக்கு</translation>
<translation id="1414271762428216854"><ph name="APP_NAME" />, நிறுவப்பட்ட ஆப்ஸ்</translation>
<translation id="1450753235335490080"><ph name="CONTENT_TYPE" />ஐப் பகிர முடியவில்லை</translation>
@@ -100,7 +100,7 @@
<translation id="3740362395218339114"><ph name="QUANTITY" /> ஜி.பை/வி</translation>
<translation id="3757388668994797779"><ph name="QUANTITY" /> GB</translation>
<translation id="3842239759367498783">உங்கள் மொபைல் ஃபோனில் தொடர்ந்து <ph name="TITLE" />ஐப் படிக்கவும்</translation>
-<translation id="385051799172605136">முந்தைய பக்கம்</translation>
+<translation id="385051799172605136">திரும்பு</translation>
<translation id="3889424535448813030">வலது அம்பு</translation>
<translation id="3897092660631435901">மெனு</translation>
<translation id="3909791450649380159">வெட்&amp;டு</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_te.xtb b/chromium/ui/strings/translations/ui_strings_te.xtb
index 5a7b2ddf2c4..5958de261d6 100644
--- a/chromium/ui/strings/translations/ui_strings_te.xtb
+++ b/chromium/ui/strings/translations/ui_strings_te.xtb
@@ -17,7 +17,7 @@
<translation id="1293699935367580298">Esc</translation>
<translation id="1306549533752902673">సిఫార్సు చేసిన యాప్‌లు</translation>
<translation id="1368832886055348810">ఎడమ నుండి కుడికి</translation>
-<translation id="1383876407941801731">వెతుకు</translation>
+<translation id="1383876407941801731">సెర్చ్</translation>
<translation id="1398853756734560583">గరిష్ఠీకరించు</translation>
<translation id="1414271762428216854"><ph name="APP_NAME" />, ఇన్‌స్టాల్ చేసిన యాప్</translation>
<translation id="1450753235335490080"><ph name="CONTENT_TYPE" /> షేర్ చేయడం సాధ్యపడలేదు</translation>
@@ -150,7 +150,7 @@
<translation id="6012623610530968780"><ph name="TOTAL_PAGE_NUM" />లో <ph name="SELECTED_PAGE" />వ పేజీ</translation>
<translation id="6022924867608035986">శోధన పెట్టె వచనాన్ని క్లియర్ చేయండి</translation>
<translation id="6040143037577758943">మూసివేయి</translation>
-<translation id="6119846243427417423">ఆక్టివేట్ చెయ్యి</translation>
+<translation id="6119846243427417423">ఆక్టివేట్ చేయి</translation>
<translation id="6129953537138746214">ఖాళీ</translation>
<translation id="6135826906199951471">Del</translation>
<translation id="6142413573757616983"><ph name="QUANTITY" /> B/s</translation>
@@ -214,7 +214,7 @@
<translation id="8131263257437993507">{SECONDS,plural, =1{1 సెక. మిగిలి ఉంది}other{# సెక. మిగిలి ఉన్నాయి}}</translation>
<translation id="8134065097954893699">ఈ పేజీని మళ్లీ లోడ్ చేస్తోంది</translation>
<translation id="8144660977431427332">మీ శోధనలు Google అసిస్టెంట్ ఆధారితంగా ఉంటాయి. <ph name="LEARN_MORE" /></translation>
-<translation id="8152264887680882389"><ph name="TEXT" />, స్వయంపూర్తి</translation>
+<translation id="8152264887680882389"><ph name="TEXT" />, ఆటోఫిల్</translation>
<translation id="815598010540052116">కిందికి స్క్రోల్ చేయి</translation>
<translation id="8179976553408161302">Enter</translation>
<translation id="8210608804940886430">పేజీ క్రిందికి</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_tr.xtb b/chromium/ui/strings/translations/ui_strings_tr.xtb
index 6ef1e9ed9ae..51c10d2e5b9 100644
--- a/chromium/ui/strings/translations/ui_strings_tr.xtb
+++ b/chromium/ui/strings/translations/ui_strings_tr.xtb
@@ -155,7 +155,7 @@
<translation id="6135826906199951471">Del</translation>
<translation id="6142413573757616983"><ph name="QUANTITY" /> B/sn</translation>
<translation id="6156262341071374681">Tüm uygulamalara genişlet</translation>
-<translation id="6165508094623778733">Daha fazla bilgi edinin</translation>
+<translation id="6165508094623778733">Daha fazla bilgi</translation>
<translation id="6264365405983206840">&amp;Tümünü Seç</translation>
<translation id="6351032674660237738">UYGULAMA ÖNERİLERİ</translation>
<translation id="6364916375976753737">Sola Kaydır</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_vi.xtb b/chromium/ui/strings/translations/ui_strings_vi.xtb
index f79041b917b..f9cf5356e7d 100644
--- a/chromium/ui/strings/translations/ui_strings_vi.xtb
+++ b/chromium/ui/strings/translations/ui_strings_vi.xtb
@@ -218,7 +218,7 @@
<translation id="815598010540052116">Cuộn Xuống</translation>
<translation id="8179976553408161302">Enter</translation>
<translation id="8210608804940886430">Trang Dưới</translation>
-<translation id="8245914219290430011">Tab</translation>
+<translation id="8245914219290430011">Thẻ</translation>
<translation id="8247998213073982446"><ph name="APP_NAME" />, Ứng dụng</translation>
<translation id="8259556432390118667">Giá trị màu hex</translation>
<translation id="8328145009876646418">Cạnh Bên trái</translation>
@@ -246,7 +246,7 @@
<translation id="9002566407876343676">mở</translation>
<translation id="9044832324875206639">{SECONDS,plural, =1{1 giây}other{# giây}}</translation>
<translation id="9059834730836941392">Thu gọn thông báo</translation>
-<translation id="9150735707954472829">Tab</translation>
+<translation id="9150735707954472829">Thẻ</translation>
<translation id="9161053988251441839">ỨNG DỤNG ĐỀ XUẤT</translation>
<translation id="9170848237812810038">H&amp;oàn tác</translation>
<translation id="9178475906033259337">Đang hiển thị 1 kết quả cho <ph name="QUERY" /></translation>
diff --git a/chromium/ui/strings/translations/ui_strings_zh-CN.xtb b/chromium/ui/strings/translations/ui_strings_zh-CN.xtb
index bbaa7a660b7..0ca6fae312c 100644
--- a/chromium/ui/strings/translations/ui_strings_zh-CN.xtb
+++ b/chromium/ui/strings/translations/ui_strings_zh-CN.xtb
@@ -6,7 +6,7 @@
<translation id="1127811143501539442">{DAYS,plural, =1{1 天前}other{# 天前}}</translation>
<translation id="1156623771253174079">{SECONDS,plural, =1{1 分钟前}other{# 分钟前}}</translation>
<translation id="1169783199079129864">{MINUTES,plural, =1{1 分钟}other{# 分钟}}</translation>
-<translation id="1181037720776840403">删除</translation>
+<translation id="1181037720776840403">移除</translation>
<translation id="1201402288615127009">下一步</translation>
<translation id="1218444235442067213"><ph name="APP_NAME" />,Play 商店应用</translation>
<translation id="1243314992276662751">上传</translation>
@@ -100,7 +100,7 @@
<translation id="3740362395218339114"><ph name="QUANTITY" /> GB/s</translation>
<translation id="3757388668994797779"><ph name="QUANTITY" /> GB</translation>
<translation id="3842239759367498783">继续在移动设备“<ph name="TITLE" />”上阅读</translation>
-<translation id="385051799172605136">后退</translation>
+<translation id="385051799172605136">返回</translation>
<translation id="3889424535448813030">向右箭头</translation>
<translation id="3897092660631435901">菜单</translation>
<translation id="3909791450649380159">剪切(&amp;T)</translation>
diff --git a/chromium/ui/strings/translations/ui_strings_zh-HK.xtb b/chromium/ui/strings/translations/ui_strings_zh-HK.xtb
index a1e0a79db60..3c1230da71a 100644
--- a/chromium/ui/strings/translations/ui_strings_zh-HK.xtb
+++ b/chromium/ui/strings/translations/ui_strings_zh-HK.xtb
@@ -107,7 +107,7 @@
<translation id="3990502903496589789">右邊緣</translation>
<translation id="40579289237549812">{UNREAD_NOTIFICATIONS,plural, =1{1 個未睇嘅通知}other{# 個未睇嘅通知}}</translation>
<translation id="4202807286478387388">跳轉</translation>
-<translation id="4250229828105606438">螢幕擷圖</translation>
+<translation id="4250229828105606438">螢幕截圖</translation>
<translation id="4266252015790371705">{MONTHS,plural, =1{1 個月前}other{# 個月前}}</translation>
<translation id="4289300219472526559">開始說</translation>
<translation id="430191667033048642">「<ph name="MOVED_APP_NAME" />」已經移咗去「<ph name="FOLDER_NAME" />」資料夾。</translation>
diff --git a/chromium/ui/strings/ui_strings.grd b/chromium/ui/strings/ui_strings.grd
index 35e7294f57d..a3fa3b94843 100644
--- a/chromium/ui/strings/ui_strings.grd
+++ b/chromium/ui/strings/ui_strings.grd
@@ -40,6 +40,7 @@ need to be translated for each locale.-->
<output filename="ui_strings_pa.pak" type="data_package" lang="pa" />
<output filename="ui_strings_si.pak" type="data_package" lang="si" />
<output filename="ui_strings_sq.pak" type="data_package" lang="sq" />
+ <output filename="ui_strings_sr-Latn.pak" type="data_package" lang="sr-Latn" />
<output filename="ui_strings_ur.pak" type="data_package" lang="ur" />
<output filename="ui_strings_uz.pak" type="data_package" lang="uz" />
<output filename="ui_strings_zh-HK.pak" type="data_package" lang="zh-HK" />
diff --git a/chromium/ui/touch_selection/touch_handle.cc b/chromium/ui/touch_selection/touch_handle.cc
index fbaff7564ea..afb1f8d0901 100644
--- a/chromium/ui/touch_selection/touch_handle.cc
+++ b/chromium/ui/touch_selection/touch_handle.cc
@@ -7,7 +7,9 @@
#include <algorithm>
#include <cmath>
+#include "base/check_op.h"
#include "base/metrics/histogram_macros.h"
+#include "base/notreached.h"
#include "base/numerics/ranges.h"
namespace ui {
diff --git a/chromium/ui/touch_selection/touch_selection_controller.cc b/chromium/ui/touch_selection/touch_selection_controller.cc
index 6a5f0e08bef..f62b1793f21 100644
--- a/chromium/ui/touch_selection/touch_selection_controller.cc
+++ b/chromium/ui/touch_selection/touch_selection_controller.cc
@@ -5,9 +5,10 @@
#include "ui/touch_selection/touch_selection_controller.h"
#include "base/auto_reset.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/user_metrics.h"
+#include "base/notreached.h"
namespace ui {
namespace {
diff --git a/chromium/ui/touch_selection/touch_selection_menu_runner.cc b/chromium/ui/touch_selection/touch_selection_menu_runner.cc
index bf70874a482..04a72f18c24 100644
--- a/chromium/ui/touch_selection/touch_selection_menu_runner.cc
+++ b/chromium/ui/touch_selection/touch_selection_menu_runner.cc
@@ -4,7 +4,7 @@
#include "ui/touch_selection/touch_selection_menu_runner.h"
-#include "base/logging.h"
+#include "base/check_op.h"
namespace ui {
namespace {
diff --git a/chromium/ui/views/BUILD.gn b/chromium/ui/views/BUILD.gn
index d3fa4cd08df..bc19dfd88f9 100644
--- a/chromium/ui/views/BUILD.gn
+++ b/chromium/ui/views/BUILD.gn
@@ -36,7 +36,6 @@ aggregate_vector_icons("views_vector_icons") {
"launch.icon",
"linux_high_density.icon",
"linux_low_density.icon",
- "linux_shutdown.icon",
"menu_check.icon",
"menu_drop_arrow.icon",
"menu_radio_empty.icon",
@@ -648,10 +647,6 @@ jumbo_component("views") {
}
if (use_x11) {
- configs += [
- "//build/config/linux:x11",
- "//build/config/linux:xrandr",
- ]
deps += [
"//ui/events/devices",
"//ui/events/devices/x11",
@@ -755,26 +750,21 @@ jumbo_component("views") {
"widget/desktop_aura/desktop_screen_position_client.cc",
"widget/desktop_aura/desktop_window_tree_host.cc",
]
- public_deps += [ "//ui/base/mojom:cursor_type" ]
+ public_deps += [ "//ui/base/cursor/mojom:cursor_type" ]
if (use_x11) {
- deps += [ "//ui/platform_window/x11" ]
+ public_deps += [
+ "//ui/base/x",
+ "//ui/platform_window/x11",
+ ]
public += [
"widget/desktop_aura/desktop_drag_drop_client_aurax11.h",
"widget/desktop_aura/desktop_screen_x11.h",
"widget/desktop_aura/desktop_window_tree_host_x11.h",
- "widget/desktop_aura/x11_desktop_window_move_client.h",
- "widget/desktop_aura/x11_move_loop.h",
- "widget/desktop_aura/x11_move_loop_delegate.h",
- "widget/desktop_aura/x11_topmost_window_finder.h",
- "widget/desktop_aura/x11_whole_screen_move_loop.h",
]
sources += [
"widget/desktop_aura/desktop_drag_drop_client_aurax11.cc",
"widget/desktop_aura/desktop_screen_x11.cc",
"widget/desktop_aura/desktop_window_tree_host_x11.cc",
- "widget/desktop_aura/x11_desktop_window_move_client.cc",
- "widget/desktop_aura/x11_topmost_window_finder.cc",
- "widget/desktop_aura/x11_whole_screen_move_loop.cc",
]
} else if (is_win) {
public += [ "widget/desktop_aura/desktop_window_tree_host_win.h" ]
@@ -788,6 +778,7 @@ jumbo_component("views") {
]
deps += [ "//ui/events:dom_keyboard_layout" ]
} else if (use_ozone) {
+ public += [ "widget/desktop_aura/desktop_screen_ozone.h" ]
sources += [
"widget/desktop_aura/desktop_drag_drop_client_ozone.cc",
"widget/desktop_aura/desktop_drag_drop_client_ozone.h",
@@ -808,9 +799,14 @@ jumbo_component("views") {
]
}
if (is_linux || is_fuchsia) {
- public += [ "widget/desktop_aura/desktop_window_tree_host_platform.h" ]
- sources +=
- [ "widget/desktop_aura/desktop_window_tree_host_platform.cc" ]
+ public += [
+ "widget/desktop_aura/desktop_window_tree_host_platform.h",
+ "widget/desktop_aura/window_move_client_platform.h",
+ ]
+ sources += [
+ "widget/desktop_aura/desktop_window_tree_host_platform.cc",
+ "widget/desktop_aura/window_move_client_platform.cc",
+ ]
deps += [ "//ui/platform_window/extensions" ]
}
if (use_atk) {
@@ -856,6 +852,10 @@ jumbo_component("views") {
if (is_fuchsia) {
sources += [ "controls/menu/menu_config_fuchsia.cc" ]
}
+
+ if (use_ozone) {
+ deps += [ "//ui/ozone" ]
+ }
}
jumbo_source_set("test_support") {
@@ -917,8 +917,6 @@ jumbo_source_set("test_support") {
"test/test_views_delegate.h",
"test/test_widget_observer.cc",
"test/test_widget_observer.h",
- "test/views_interactive_ui_test_base.cc",
- "test/views_interactive_ui_test_base.h",
"test/views_test_base.cc",
"test/views_test_base.h",
"test/views_test_helper.cc",
@@ -927,8 +925,6 @@ jumbo_source_set("test_support") {
"test/widget_test.h",
"test/widget_test_api.cc",
"test/widget_test_api.h",
- "test/x11_property_change_waiter.cc",
- "test/x11_property_change_waiter.h",
"view_test_api.h",
"views_test_suite.cc",
"views_test_suite.h",
@@ -1023,12 +1019,6 @@ jumbo_source_set("test_support") {
if (ozone_platform_x11) {
deps += [ "//ui/base/x" ]
}
- if (use_ozone || !use_x11) {
- sources -= [
- "test/x11_property_change_waiter.cc",
- "test/x11_property_change_waiter.h",
- ]
- }
}
test("views_unittests") {
@@ -1173,6 +1163,8 @@ test("views_unittests") {
"//third_party/wtl",
]
+ deps += [ "//ui/base:data_exchange" ]
+
libs = [
"imm32.lib",
"oleacc.lib",
@@ -1181,6 +1173,8 @@ test("views_unittests") {
]
sources += [
+ "accessibility/test_list_grid_view.cc",
+ "accessibility/test_list_grid_view.h",
"accessibility/view_ax_platform_node_delegate_win_unittest.cc",
"win/pen_event_processor_unittest.cc",
]
@@ -1240,7 +1234,7 @@ test("views_unittests") {
"//ui/accessibility:test_support",
"//ui/aura",
"//ui/aura:test_support",
- "//ui/base/mojom:cursor_type",
+ "//ui/base/cursor/mojom:cursor_type",
"//ui/touch_selection",
"//ui/wm",
"//ui/wm/public",
@@ -1257,10 +1251,6 @@ test("views_unittests") {
}
if (use_x11) {
- configs += [
- "//build/config/linux:x11",
- "//build/config/linux:xext",
- ]
deps += [
"//ui/events/devices",
"//ui/events/platform/x11",
@@ -1280,6 +1270,7 @@ test("views_unittests") {
"widget/desktop_aura/desktop_screen_x11_unittest.cc",
"widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc",
]
+ deps += [ "//ui/base/x:test_support" ]
}
if (is_linux || is_fuchsia) {
sources += [
@@ -1304,6 +1295,10 @@ test("views_unittests") {
[ "accessibility/view_ax_platform_node_delegate_auralinux_unittest.cc" ]
configs += [ "//build/config/linux/atk" ]
}
+
+ if (use_ozone) {
+ deps += [ "//ui/ozone" ]
+ }
}
# This target is added as a dependency of browser interactive_ui_tests. It must
@@ -1372,7 +1367,11 @@ source_set("views_interactive_ui_tests") {
"widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc",
"widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc",
]
- deps += [ "//ui/events/platform/x11:x11" ]
+ deps += [
+ "//ui/base/x:test_support",
+ "//ui/events/platform/x11:x11",
+ "//ui/platform_window/x11",
+ ]
}
if (is_chromeos) {
diff --git a/chromium/ui/views/accessibility/accessibility_alert_window.cc b/chromium/ui/views/accessibility/accessibility_alert_window.cc
index 358b295e012..4c5b0e47f60 100644
--- a/chromium/ui/views/accessibility/accessibility_alert_window.cc
+++ b/chromium/ui/views/accessibility/accessibility_alert_window.cc
@@ -5,7 +5,7 @@
#include "ui/views/accessibility/accessibility_alert_window.h"
#include "base/strings/utf_string_conversions.h"
-#include "ui/accessibility/platform/aura_window_properties.h"
+#include "ui/accessibility/aura/aura_window_properties.h"
#include "ui/aura/window.h"
#include "ui/compositor/layer_type.h"
#include "ui/views/accessibility/ax_aura_obj_cache.h"
diff --git a/chromium/ui/views/accessibility/ax_aura_obj_cache.cc b/chromium/ui/views/accessibility/ax_aura_obj_cache.cc
index 3197d2eec5c..b8f102137de 100644
--- a/chromium/ui/views/accessibility/ax_aura_obj_cache.cc
+++ b/chromium/ui/views/accessibility/ax_aura_obj_cache.cc
@@ -105,15 +105,19 @@ void AXAuraObjCache::GetTopLevelWindows(
AXAuraObjWrapper* AXAuraObjCache::GetFocus() {
View* focused_view = GetFocusedView();
- if (focused_view) {
- const ViewAccessibility& view_accessibility =
- focused_view->GetViewAccessibility();
- if (view_accessibility.FocusedVirtualChild())
- return view_accessibility.FocusedVirtualChild()->GetOrCreateWrapper(this);
+ while (focused_view && focused_view->GetViewAccessibility().IsIgnored())
+ focused_view = focused_view->parent();
- return GetOrCreate(focused_view);
+ if (!focused_view)
+ return nullptr;
+
+ if (focused_view->GetViewAccessibility().FocusedVirtualChild()) {
+ return focused_view->GetViewAccessibility()
+ .FocusedVirtualChild()
+ ->GetOrCreateWrapper(this);
}
- return nullptr;
+
+ return GetOrCreate(focused_view);
}
void AXAuraObjCache::OnFocusedViewChanged() {
diff --git a/chromium/ui/views/accessibility/ax_aura_obj_cache_unittest.cc b/chromium/ui/views/accessibility/ax_aura_obj_cache_unittest.cc
index 4008179a8bc..dcdd7515034 100644
--- a/chromium/ui/views/accessibility/ax_aura_obj_cache_unittest.cc
+++ b/chromium/ui/views/accessibility/ax_aura_obj_cache_unittest.cc
@@ -17,7 +17,9 @@
#include "ui/aura/window.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
+#include "ui/views/accessibility/ax_aura_obj_wrapper.h"
#include "ui/views/accessibility/ax_tree_source_views.h"
+#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/test/widget_test.h"
@@ -51,6 +53,12 @@ class AXAuraObjCacheTest : public WidgetTest {
public:
AXAuraObjCacheTest() = default;
~AXAuraObjCacheTest() override = default;
+
+ ui::AXNodeData GetData(AXAuraObjWrapper* wrapper) {
+ ui::AXNodeData data;
+ wrapper->Serialize(&data);
+ return data;
+ }
};
TEST_F(AXAuraObjCacheTest, TestViewRemoval) {
@@ -133,6 +141,68 @@ TEST_F(AXAuraObjCacheTest, ValidTree) {
EXPECT_TRUE(HasNodeWithName(ax_tree, "ChildButton"));
}
+TEST_F(AXAuraObjCacheTest, GetFocusIsUnignoredAncestor) {
+ AXAuraObjCache cache;
+ auto widget = std::make_unique<Widget>();
+ Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
+ params.bounds = gfx::Rect(0, 0, 200, 200);
+ params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ params.activatable = views::Widget::InitParams::ACTIVATABLE_YES;
+ widget->Init(std::move(params));
+ widget->Show();
+
+ // Note that AXAuraObjCache::GetFocusedView has some logic to force focus on
+ // the first child of the client view when one cannot be found from the
+ // FocusManager.
+ auto* client = widget->non_client_view()->client_view();
+ ASSERT_NE(nullptr, client);
+ auto* client_child = client->children().front();
+ ASSERT_NE(nullptr, client_child);
+ client_child->GetViewAccessibility().OverrideRole(ax::mojom::Role::kDialog);
+
+ View* parent = new View();
+ widget->GetRootView()->AddChildView(parent);
+ parent->GetViewAccessibility().OverrideRole(ax::mojom::Role::kTextField);
+ parent->SetFocusBehavior(View::FocusBehavior::ALWAYS);
+
+ View* child = new View();
+ parent->AddChildView(child);
+ child->GetViewAccessibility().OverrideRole(ax::mojom::Role::kGroup);
+ child->SetFocusBehavior(View::FocusBehavior::ALWAYS);
+
+ auto* ax_widget = cache.GetOrCreate(widget.get());
+ ASSERT_NE(nullptr, ax_widget);
+ auto* ax_client_child = cache.GetOrCreate(client_child);
+ ASSERT_NE(nullptr, ax_client_child);
+ auto* ax_parent = cache.GetOrCreate(parent);
+ ASSERT_NE(nullptr, ax_parent);
+ auto* ax_child = cache.GetOrCreate(child);
+ ASSERT_NE(nullptr, ax_child);
+
+ ASSERT_EQ(nullptr, cache.GetFocus());
+ cache.OnRootWindowObjCreated(widget->GetNativeWindow());
+ ASSERT_EQ(ax::mojom::Role::kDialog, GetData(cache.GetFocus()).role);
+ ASSERT_EQ(ax_client_child, cache.GetFocus());
+
+ parent->RequestFocus();
+ ASSERT_EQ(ax::mojom::Role::kTextField, GetData(cache.GetFocus()).role);
+ ASSERT_EQ(ax_parent, cache.GetFocus());
+
+ child->RequestFocus();
+ ASSERT_EQ(ax::mojom::Role::kGroup, GetData(cache.GetFocus()).role);
+ ASSERT_EQ(ax_child, cache.GetFocus());
+
+ child->GetViewAccessibility().OverrideIsIgnored(true);
+ ASSERT_EQ(ax::mojom::Role::kTextField, GetData(cache.GetFocus()).role);
+ ASSERT_EQ(ax_parent, cache.GetFocus());
+
+ parent->GetViewAccessibility().OverrideIsIgnored(true);
+ ASSERT_EQ(ax::mojom::Role::kWindow, GetData(cache.GetFocus()).role);
+ ASSERT_EQ(cache.GetOrCreate(widget->GetRootView()), cache.GetFocus());
+
+ cache.OnRootWindowObjDestroyed(widget->GetNativeWindow());
+}
+
} // namespace
} // namespace test
} // namespace views
diff --git a/chromium/ui/views/accessibility/ax_aura_obj_wrapper.h b/chromium/ui/views/accessibility/ax_aura_obj_wrapper.h
index 39ef97a6c04..6410416ce2b 100644
--- a/chromium/ui/views/accessibility/ax_aura_obj_wrapper.h
+++ b/chromium/ui/views/accessibility/ax_aura_obj_wrapper.h
@@ -37,6 +37,7 @@ class VIEWS_EXPORT AXAuraObjWrapper {
virtual void GetChildren(std::vector<AXAuraObjWrapper*>* out_children) = 0;
virtual void Serialize(ui::AXNodeData* out_node_data) = 0;
virtual int32_t GetUniqueId() const = 0;
+ virtual std::string ToString() const = 0;
// Actions.
virtual bool HandleAccessibleAction(const ui::AXActionData& action);
diff --git a/chromium/ui/views/accessibility/ax_root_obj_wrapper.cc b/chromium/ui/views/accessibility/ax_root_obj_wrapper.cc
index d741387d039..f79b6c0ec10 100644
--- a/chromium/ui/views/accessibility/ax_root_obj_wrapper.cc
+++ b/chromium/ui/views/accessibility/ax_root_obj_wrapper.cc
@@ -75,6 +75,10 @@ int32_t AXRootObjWrapper::GetUniqueId() const {
return unique_id_.Get();
}
+std::string AXRootObjWrapper::ToString() const {
+ return "root";
+}
+
void AXRootObjWrapper::OnDisplayMetricsChanged(const display::Display& display,
uint32_t changed_metrics) {
delegate_->OnEvent(this, ax::mojom::Event::kLoadComplete);
diff --git a/chromium/ui/views/accessibility/ax_root_obj_wrapper.h b/chromium/ui/views/accessibility/ax_root_obj_wrapper.h
index d259c7071d5..168138b9314 100644
--- a/chromium/ui/views/accessibility/ax_root_obj_wrapper.h
+++ b/chromium/ui/views/accessibility/ax_root_obj_wrapper.h
@@ -35,6 +35,7 @@ class VIEWS_EXPORT AXRootObjWrapper : public views::AXAuraObjWrapper,
std::vector<views::AXAuraObjWrapper*>* out_children) override;
void Serialize(ui::AXNodeData* out_node_data) override;
int32_t GetUniqueId() const override;
+ std::string ToString() const override;
private:
// display::DisplayObserver:
diff --git a/chromium/ui/views/accessibility/ax_system_caret_win_interactive_uitest.cc b/chromium/ui/views/accessibility/ax_system_caret_win_interactive_uitest.cc
index f4315d4fb58..60729545314 100644
--- a/chromium/ui/views/accessibility/ax_system_caret_win_interactive_uitest.cc
+++ b/chromium/ui/views/accessibility/ax_system_caret_win_interactive_uitest.cc
@@ -196,7 +196,7 @@ WinAccessibilityCaretEventMonitor::WinEventHookThunk(HWINEVENTHOOK handle,
}
} // namespace
-TEST_F(AXSystemCaretWinTest, DISABLED_TestOnCaretBoundsChangeInTextField) {
+TEST_F(AXSystemCaretWinTest, TestOnCaretBoundsChangeInTextField) {
TextfieldTestApi textfield_test_api(textfield_);
Microsoft::WRL::ComPtr<IAccessible> caret_accessible;
gfx::NativeWindow native_window = widget_->GetNativeWindow();
@@ -205,9 +205,12 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestOnCaretBoundsChangeInTextField) {
EXPECT_HRESULT_SUCCEEDED(AccessibleObjectFromWindow(
hwnd, static_cast<DWORD>(OBJID_CARET), IID_PPV_ARGS(&caret_accessible)));
+ gfx::Rect window_bounds = native_window->GetBoundsInScreen();
+
textfield_test_api.ExecuteTextEditCommand(
ui::TextEditCommand::MOVE_TO_BEGINNING_OF_DOCUMENT);
- gfx::Point caret_position = textfield_test_api.GetCursorViewRect().origin();
+ gfx::Point caret_position = textfield_test_api.GetCursorViewRect().origin() +
+ window_bounds.OffsetFromOrigin();
LONG x, y, width, height;
EXPECT_EQ(S_OK,
caret_accessible->accLocation(&x, &y, &width, &height, self_));
@@ -217,7 +220,8 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestOnCaretBoundsChangeInTextField) {
textfield_test_api.ExecuteTextEditCommand(
ui::TextEditCommand::MOVE_TO_END_OF_DOCUMENT);
- gfx::Point caret_position2 = textfield_test_api.GetCursorViewRect().origin();
+ gfx::Point caret_position2 = textfield_test_api.GetCursorViewRect().origin() +
+ window_bounds.OffsetFromOrigin();
EXPECT_NE(caret_position, caret_position2);
EXPECT_EQ(S_OK,
caret_accessible->accLocation(&x, &y, &width, &height, self_));
@@ -226,7 +230,7 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestOnCaretBoundsChangeInTextField) {
EXPECT_EQ(1, width);
}
-TEST_F(AXSystemCaretWinTest, DISABLED_TestOnInputTypeChangeInTextField) {
+TEST_F(AXSystemCaretWinTest, TestOnInputTypeChangeInTextField) {
Microsoft::WRL::ComPtr<IAccessible> caret_accessible;
gfx::NativeWindow native_window = widget_->GetNativeWindow();
ASSERT_NE(nullptr, native_window);
@@ -255,7 +259,7 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestOnInputTypeChangeInTextField) {
EXPECT_EQ(height, height2);
}
-TEST_F(AXSystemCaretWinTest, DISABLED_TestMovingWindow) {
+TEST_F(AXSystemCaretWinTest, TestMovingWindow) {
Microsoft::WRL::ComPtr<IAccessible> caret_accessible;
gfx::NativeWindow native_window = widget_->GetNativeWindow();
ASSERT_NE(nullptr, native_window);
@@ -268,9 +272,6 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestMovingWindow) {
widget_->SetBounds(gfx::Rect(100, 100, 500, 500));
LONG x2, y2, width2, height2;
- caret_accessible.Reset();
- EXPECT_HRESULT_SUCCEEDED(AccessibleObjectFromWindow(
- hwnd, static_cast<DWORD>(OBJID_CARET), IID_PPV_ARGS(&caret_accessible)));
EXPECT_EQ(S_OK,
caret_accessible->accLocation(&x2, &y2, &width2, &height2, self_));
EXPECT_NE(x, x2);
@@ -281,13 +282,14 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestMovingWindow) {
// Try maximizing the window.
SendMessage(hwnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0);
- LONG x3, y3, width3, height3;
- EXPECT_HRESULT_FAILED(
- caret_accessible->accLocation(&x3, &y3, &width3, &height3, self_));
- caret_accessible.Reset();
+ // On Win7, maximizing the window causes our caret object to get destroyed and
+ // re-created, so re-acquire it.
+ caret_accessible.Reset();
EXPECT_HRESULT_SUCCEEDED(AccessibleObjectFromWindow(
hwnd, static_cast<DWORD>(OBJID_CARET), IID_PPV_ARGS(&caret_accessible)));
+
+ LONG x3, y3, width3, height3;
EXPECT_EQ(S_OK,
caret_accessible->accLocation(&x3, &y3, &width3, &height3, self_));
EXPECT_NE(x2, x3);
@@ -297,7 +299,7 @@ TEST_F(AXSystemCaretWinTest, DISABLED_TestMovingWindow) {
EXPECT_EQ(height, height3);
}
-TEST_F(AXSystemCaretWinTest, DISABLED_TestCaretMSAAEvents) {
+TEST_F(AXSystemCaretWinTest, TestCaretMSAAEvents) {
TextfieldTestApi textfield_test_api(textfield_);
Microsoft::WRL::ComPtr<IAccessible> caret_accessible;
gfx::NativeWindow native_window = widget_->GetNativeWindow();
diff --git a/chromium/ui/views/accessibility/ax_tree_source_views.cc b/chromium/ui/views/accessibility/ax_tree_source_views.cc
index fbbca160b51..8733f5e1ebe 100644
--- a/chromium/ui/views/accessibility/ax_tree_source_views.cc
+++ b/chromium/ui/views/accessibility/ax_tree_source_views.cc
@@ -117,6 +117,10 @@ AXAuraObjWrapper* AXTreeSourceViews::GetNull() const {
return nullptr;
}
+std::string AXTreeSourceViews::GetDebugString(AXAuraObjWrapper* node) const {
+ return node->ToString();
+}
+
void AXTreeSourceViews::SerializeNode(AXAuraObjWrapper* node,
ui::AXNodeData* out_data) const {
node->Serialize(out_data);
diff --git a/chromium/ui/views/accessibility/ax_tree_source_views.h b/chromium/ui/views/accessibility/ax_tree_source_views.h
index 2640ea24442..37317b530b5 100644
--- a/chromium/ui/views/accessibility/ax_tree_source_views.h
+++ b/chromium/ui/views/accessibility/ax_tree_source_views.h
@@ -54,6 +54,7 @@ class VIEWS_EXPORT AXTreeSourceViews
bool IsValid(AXAuraObjWrapper* node) const override;
bool IsEqual(AXAuraObjWrapper* node1, AXAuraObjWrapper* node2) const override;
AXAuraObjWrapper* GetNull() const override;
+ std::string GetDebugString(AXAuraObjWrapper* node) const override;
void SerializeNode(AXAuraObjWrapper* node,
ui::AXNodeData* out_data) const override;
diff --git a/chromium/ui/views/accessibility/ax_view_obj_wrapper.cc b/chromium/ui/views/accessibility/ax_view_obj_wrapper.cc
index 64b0303bef6..53845347297 100644
--- a/chromium/ui/views/accessibility/ax_view_obj_wrapper.cc
+++ b/chromium/ui/views/accessibility/ax_view_obj_wrapper.cc
@@ -92,6 +92,10 @@ bool AXViewObjWrapper::HandleAccessibleAction(const ui::AXActionData& action) {
return view_ ? view_->HandleAccessibleAction(action) : false;
}
+std::string AXViewObjWrapper::ToString() const {
+ return std::string(view_ ? view_->GetClassName() : "Null view");
+}
+
void AXViewObjWrapper::OnViewIsDeleting(View* observed_view) {
observer_.RemoveAll();
view_ = nullptr;
diff --git a/chromium/ui/views/accessibility/ax_view_obj_wrapper.h b/chromium/ui/views/accessibility/ax_view_obj_wrapper.h
index 02717a0ebc1..758381fbf49 100644
--- a/chromium/ui/views/accessibility/ax_view_obj_wrapper.h
+++ b/chromium/ui/views/accessibility/ax_view_obj_wrapper.h
@@ -35,6 +35,7 @@ class AXViewObjWrapper : public AXAuraObjWrapper, public ViewObserver {
void Serialize(ui::AXNodeData* out_node_data) override;
int32_t GetUniqueId() const final;
bool HandleAccessibleAction(const ui::AXActionData& action) override;
+ std::string ToString() const override;
// ViewObserver overrides.
void OnViewIsDeleting(View* observed_view) override;
diff --git a/chromium/ui/views/accessibility/ax_virtual_view.cc b/chromium/ui/views/accessibility/ax_virtual_view.cc
index cf273bc4d05..a222443d37e 100644
--- a/chromium/ui/views/accessibility/ax_virtual_view.cc
+++ b/chromium/ui/views/accessibility/ax_virtual_view.cc
@@ -11,11 +11,13 @@
#include <utility>
#include "base/callback.h"
+#include "base/containers/adapters.h"
#include "base/no_destructor.h"
#include "build/build_config.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_tree_data.h"
#include "ui/accessibility/platform/ax_platform_node.h"
+#include "ui/base/layout.h"
#include "ui/base/ui_base_types.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/views/accessibility/view_accessibility.h"
@@ -236,6 +238,15 @@ const ui::AXNodeData& AXVirtualView::GetData() const {
if (populate_data_callback_ && GetOwnerView())
populate_data_callback_.Run(&node_data);
+
+ // According to the ARIA spec, the node should not be ignored if it is
+ // focusable. This is to ensure that the focusable node is both understandable
+ // and operable.
+ if (node_data.HasState(ax::mojom::State::kIgnored) &&
+ node_data.HasState(ax::mojom::State::kFocusable)) {
+ node_data.RemoveState(ax::mojom::State::kIgnored);
+ }
+
return node_data;
}
@@ -302,12 +313,24 @@ gfx::Rect AXVirtualView::GetBoundsRect(
const ui::AXCoordinateSystem coordinate_system,
const ui::AXClippingBehavior clipping_behavior,
ui::AXOffscreenResult* offscreen_result) const {
+ // We could optionally add clipping here if ever needed.
+ // TODO(nektar): Implement bounds that are relative to the parent.
+ gfx::Rect bounds = gfx::ToEnclosingRect(GetData().relative_bounds.bounds);
+ View* owner_view = GetOwnerView();
+ if (owner_view && owner_view->GetWidget())
+ View::ConvertRectToScreen(owner_view, &bounds);
switch (coordinate_system) {
case ui::AXCoordinateSystem::kScreenDIPs:
- // We could optionally add clipping here if ever needed.
- // TODO(nektar): Implement bounds that are relative to the parent.
- return gfx::ToEnclosingRect(custom_data_.relative_bounds.bounds);
- case ui::AXCoordinateSystem::kScreenPhysicalPixels:
+ return bounds;
+ case ui::AXCoordinateSystem::kScreenPhysicalPixels: {
+ float scale_factor = 1.0;
+ if (owner_view && owner_view->GetWidget()) {
+ gfx::NativeView native_view = owner_view->GetWidget()->GetNativeView();
+ if (native_view)
+ scale_factor = ui::GetScaleFactorForNativeView(native_view);
+ }
+ return gfx::ScaleToEnclosingRect(bounds, scale_factor);
+ }
case ui::AXCoordinateSystem::kRootFrame:
case ui::AXCoordinateSystem::kFrame:
NOTIMPLEMENTED();
@@ -318,27 +341,39 @@ gfx::Rect AXVirtualView::GetBoundsRect(
gfx::NativeViewAccessible AXVirtualView::HitTestSync(
int screen_physical_pixel_x,
int screen_physical_pixel_y) const {
- if (custom_data_.relative_bounds.bounds.Contains(
- static_cast<float>(screen_physical_pixel_x),
- static_cast<float>(screen_physical_pixel_y))) {
- if (!IsIgnored())
- return GetNativeObject();
- }
+ const ui::AXNodeData& node_data = GetData();
+ if (node_data.HasState(ax::mojom::State::kInvisible))
+ return nullptr;
// Check if the point is within any of the virtual children of this view.
// AXVirtualView's HitTestSync is a recursive function that will return the
// deepest child, since it does not support relative bounds.
- for (const std::unique_ptr<AXVirtualView>& child : children_) {
+ // Search the greater indices first, since they're on top in the z-order.
+ for (const std::unique_ptr<AXVirtualView>& child :
+ base::Reversed(children_)) {
gfx::NativeViewAccessible result =
child->HitTestSync(screen_physical_pixel_x, screen_physical_pixel_y);
if (result)
return result;
}
+
+ // If it's not inside any of our virtual children, and it's inside the bounds
+ // of this virtual view, then it's inside this virtual view.
+ gfx::Rect bounds_in_screen_physical_pixels =
+ GetBoundsRect(ui::AXCoordinateSystem::kScreenPhysicalPixels,
+ ui::AXClippingBehavior::kUnclipped);
+ if (bounds_in_screen_physical_pixels.Contains(
+ static_cast<float>(screen_physical_pixel_x),
+ static_cast<float>(screen_physical_pixel_y)) &&
+ !node_data.IsIgnored()) {
+ return GetNativeObject();
+ }
+
return nullptr;
}
gfx::NativeViewAccessible AXVirtualView::GetFocus() {
- auto* owner_view = GetOwnerView();
+ View* owner_view = GetOwnerView();
if (owner_view) {
if (!(owner_view->HasFocus())) {
return nullptr;
@@ -389,15 +424,7 @@ gfx::AcceleratedWidget AXVirtualView::GetTargetForNativeAccessibilityEvent() {
}
bool AXVirtualView::IsIgnored() const {
- const ui::AXNodeData& node_data = GetData();
-
- // According to the ARIA spec, the node should not be ignored if it is
- // focusable. This is to ensure that the focusable node is both understandable
- // and operable.
- if (node_data.HasState(ax::mojom::State::kFocusable))
- return false;
-
- return node_data.IsIgnored();
+ return GetData().IsIgnored();
}
bool AXVirtualView::HandleAccessibleAction(
diff --git a/chromium/ui/views/accessibility/ax_virtual_view.h b/chromium/ui/views/accessibility/ax_virtual_view.h
index c74273c6ac8..105c961b102 100644
--- a/chromium/ui/views/accessibility/ax_virtual_view.h
+++ b/chromium/ui/views/accessibility/ax_virtual_view.h
@@ -142,7 +142,7 @@ class VIEWS_EXPORT AXVirtualView : public ui::AXPlatformNodeDelegateBase {
gfx::Rect GetBoundsRect(
const ui::AXCoordinateSystem coordinate_system,
const ui::AXClippingBehavior clipping_behavior,
- ui::AXOffscreenResult* offscreen_result) const override;
+ ui::AXOffscreenResult* offscreen_result = nullptr) const override;
gfx::NativeViewAccessible HitTestSync(
int screen_physical_pixel_x,
int screen_physical_pixel_y) const override;
diff --git a/chromium/ui/views/accessibility/ax_virtual_view_unittest.cc b/chromium/ui/views/accessibility/ax_virtual_view_unittest.cc
index 3f1cb20f077..b48ada53153 100644
--- a/chromium/ui/views/accessibility/ax_virtual_view_unittest.cc
+++ b/chromium/ui/views/accessibility/ax_virtual_view_unittest.cc
@@ -626,6 +626,51 @@ TEST_F(AXVirtualViewTest, Navigation) {
EXPECT_EQ(0, virtual_child_4->GetIndexInParent());
}
+TEST_F(AXVirtualViewTest, HitTesting) {
+ ASSERT_EQ(0, virtual_label_->GetChildCount());
+
+ const gfx::Vector2d offset_from_origin =
+ button_->GetBoundsInScreen().OffsetFromOrigin();
+
+ // Test that hit testing is recursive.
+ AXVirtualView* virtual_child_1 = new AXVirtualView;
+ virtual_child_1->GetCustomData().relative_bounds.bounds =
+ gfx::RectF(0, 0, 10, 10);
+ virtual_label_->AddChildView(base::WrapUnique(virtual_child_1));
+ AXVirtualView* virtual_child_2 = new AXVirtualView;
+ virtual_child_2->GetCustomData().relative_bounds.bounds =
+ gfx::RectF(5, 5, 5, 5);
+ virtual_child_1->AddChildView(base::WrapUnique(virtual_child_2));
+ gfx::Point point_1 = gfx::Point(2, 2) + offset_from_origin;
+ EXPECT_EQ(virtual_child_1->GetNativeObject(),
+ virtual_child_1->HitTestSync(point_1.x(), point_1.y()));
+ gfx::Point point_2 = gfx::Point(7, 7) + offset_from_origin;
+ EXPECT_EQ(virtual_child_2->GetNativeObject(),
+ virtual_label_->HitTestSync(point_2.x(), point_2.y()));
+
+ // Test that hit testing follows the z-order.
+ AXVirtualView* virtual_child_3 = new AXVirtualView;
+ virtual_child_3->GetCustomData().relative_bounds.bounds =
+ gfx::RectF(5, 5, 10, 10);
+ virtual_label_->AddChildView(base::WrapUnique(virtual_child_3));
+ AXVirtualView* virtual_child_4 = new AXVirtualView;
+ virtual_child_4->GetCustomData().relative_bounds.bounds =
+ gfx::RectF(10, 10, 10, 10);
+ virtual_child_3->AddChildView(base::WrapUnique(virtual_child_4));
+ EXPECT_EQ(virtual_child_3->GetNativeObject(),
+ virtual_label_->HitTestSync(point_2.x(), point_2.y()));
+ gfx::Point point_3 = gfx::Point(12, 12) + offset_from_origin;
+ EXPECT_EQ(virtual_child_4->GetNativeObject(),
+ virtual_label_->HitTestSync(point_3.x(), point_3.y()));
+
+ // Test that hit testing skips ignored nodes but not their descendants.
+ virtual_child_3->GetCustomData().AddState(ax::mojom::State::kIgnored);
+ EXPECT_EQ(virtual_child_2->GetNativeObject(),
+ virtual_label_->HitTestSync(point_2.x(), point_2.y()));
+ EXPECT_EQ(virtual_child_4->GetNativeObject(),
+ virtual_label_->HitTestSync(point_3.x(), point_3.y()));
+}
+
// Test for GetTargetForNativeAccessibilityEvent().
#if defined(OS_WIN)
TEST_F(AXVirtualViewTest, GetTargetForEvents) {
diff --git a/chromium/ui/views/accessibility/ax_virtual_view_wrapper.cc b/chromium/ui/views/accessibility/ax_virtual_view_wrapper.cc
index 65a7b57edac..dffc373da1a 100644
--- a/chromium/ui/views/accessibility/ax_virtual_view_wrapper.cc
+++ b/chromium/ui/views/accessibility/ax_virtual_view_wrapper.cc
@@ -51,4 +51,9 @@ bool AXVirtualViewWrapper::HandleAccessibleAction(
return virtual_view_->HandleAccessibleAction(action);
}
+std::string AXVirtualViewWrapper::ToString() const {
+ std::string description = "Virtual view child of ";
+ return description + virtual_view_->GetOwnerView()->GetClassName();
+}
+
} // namespace views
diff --git a/chromium/ui/views/accessibility/ax_virtual_view_wrapper.h b/chromium/ui/views/accessibility/ax_virtual_view_wrapper.h
index f6121f041b3..7588a5ffbba 100644
--- a/chromium/ui/views/accessibility/ax_virtual_view_wrapper.h
+++ b/chromium/ui/views/accessibility/ax_virtual_view_wrapper.h
@@ -31,6 +31,7 @@ class AXVirtualViewWrapper : public AXAuraObjWrapper {
void Serialize(ui::AXNodeData* out_node_data) override;
int32_t GetUniqueId() const override;
bool HandleAccessibleAction(const ui::AXActionData& action) override;
+ std::string ToString() const override;
private:
// Weak.
diff --git a/chromium/ui/views/accessibility/ax_widget_obj_wrapper.cc b/chromium/ui/views/accessibility/ax_widget_obj_wrapper.cc
index e9a4012c6e8..9aeeb45a0bc 100644
--- a/chromium/ui/views/accessibility/ax_widget_obj_wrapper.cc
+++ b/chromium/ui/views/accessibility/ax_widget_obj_wrapper.cc
@@ -62,6 +62,10 @@ int32_t AXWidgetObjWrapper::GetUniqueId() const {
return unique_id_.Get();
}
+std::string AXWidgetObjWrapper::ToString() const {
+ return "Widget";
+}
+
void AXWidgetObjWrapper::OnWidgetDestroying(Widget* widget) {
aura_obj_cache_->Remove(widget);
}
diff --git a/chromium/ui/views/accessibility/ax_widget_obj_wrapper.h b/chromium/ui/views/accessibility/ax_widget_obj_wrapper.h
index e5671607a61..2f6cc93f1ef 100644
--- a/chromium/ui/views/accessibility/ax_widget_obj_wrapper.h
+++ b/chromium/ui/views/accessibility/ax_widget_obj_wrapper.h
@@ -36,6 +36,7 @@ class AXWidgetObjWrapper : public AXAuraObjWrapper,
void GetChildren(std::vector<AXAuraObjWrapper*>* out_children) override;
void Serialize(ui::AXNodeData* out_node_data) override;
int32_t GetUniqueId() const final;
+ std::string ToString() const override;
// WidgetObserver overrides.
void OnWidgetDestroying(Widget* widget) override;
diff --git a/chromium/ui/views/accessibility/ax_window_obj_wrapper.cc b/chromium/ui/views/accessibility/ax_window_obj_wrapper.cc
index 8a6a8c6a83d..5e79b94b22c 100644
--- a/chromium/ui/views/accessibility/ax_window_obj_wrapper.cc
+++ b/chromium/ui/views/accessibility/ax_window_obj_wrapper.cc
@@ -10,10 +10,10 @@
#include <vector>
#include "base/strings/utf_string_conversions.h"
+#include "ui/accessibility/aura/aura_window_properties.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/ax_tree_id.h"
-#include "ui/accessibility/platform/aura_window_properties.h"
#include "ui/aura/client/focus_client.h"
#include "ui/views/accessibility/ax_aura_obj_cache.h"
#include "ui/views/widget/widget.h"
@@ -66,6 +66,13 @@ void FireLocationChangesRecursively(aura::Window* window,
FireLocationChangesRecursively(child, cache);
}
+std::string GetWindowName(aura::Window* window) {
+ std::string class_name = window->GetName();
+ if (class_name.empty())
+ class_name = "aura::Window";
+ return class_name;
+}
+
} // namespace
AXWindowObjWrapper::AXWindowObjWrapper(AXAuraObjCache* aura_obj_cache,
@@ -136,17 +143,18 @@ void AXWindowObjWrapper::Serialize(ui::AXNodeData* out_node_data) {
*child_ax_tree_id_ptr);
}
- std::string class_name = window_->GetName();
- if (class_name.empty())
- class_name = "aura::Window";
out_node_data->AddStringAttribute(ax::mojom::StringAttribute::kClassName,
- class_name);
+ GetWindowName(window_));
}
int32_t AXWindowObjWrapper::GetUniqueId() const {
return unique_id_.Get();
}
+std::string AXWindowObjWrapper::ToString() const {
+ return GetWindowName(window_);
+}
+
void AXWindowObjWrapper::OnWindowDestroyed(aura::Window* window) {
aura_obj_cache_->Remove(window, nullptr);
}
diff --git a/chromium/ui/views/accessibility/ax_window_obj_wrapper.h b/chromium/ui/views/accessibility/ax_window_obj_wrapper.h
index 1877e2ebc86..841a3d03710 100644
--- a/chromium/ui/views/accessibility/ax_window_obj_wrapper.h
+++ b/chromium/ui/views/accessibility/ax_window_obj_wrapper.h
@@ -35,6 +35,7 @@ class AXWindowObjWrapper : public AXAuraObjWrapper,
void GetChildren(std::vector<AXAuraObjWrapper*>* out_children) override;
void Serialize(ui::AXNodeData* out_node_data) override;
int32_t GetUniqueId() const final;
+ std::string ToString() const override;
// WindowObserver overrides.
void OnWindowDestroyed(aura::Window* window) override;
diff --git a/chromium/ui/views/accessibility/test_list_grid_view.cc b/chromium/ui/views/accessibility/test_list_grid_view.cc
new file mode 100644
index 00000000000..031a1194dbf
--- /dev/null
+++ b/chromium/ui/views/accessibility/test_list_grid_view.cc
@@ -0,0 +1,57 @@
+// Copyright 2020 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 "ui/views/accessibility/test_list_grid_view.h"
+
+#include "ui/accessibility/ax_enums.mojom.h"
+#include "ui/accessibility/ax_node_data.h"
+
+namespace views {
+namespace test {
+
+TestListGridView::TestListGridView() = default;
+TestListGridView::~TestListGridView() = default;
+
+void TestListGridView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
+ node_data->role = ax::mojom::Role::kListGrid;
+ if (aria_row_count) {
+ node_data->AddIntAttribute(ax::mojom::IntAttribute::kAriaRowCount,
+ *aria_row_count);
+ }
+ if (aria_column_count) {
+ node_data->AddIntAttribute(ax::mojom::IntAttribute::kAriaColumnCount,
+ *aria_column_count);
+ }
+ if (table_row_count) {
+ node_data->AddIntAttribute(ax::mojom::IntAttribute::kTableRowCount,
+ *table_row_count);
+ }
+ if (table_column_count) {
+ node_data->AddIntAttribute(ax::mojom::IntAttribute::kTableColumnCount,
+ *table_column_count);
+ }
+}
+
+void TestListGridView::SetAriaTableSize(int row_count, int column_count) {
+ aria_row_count = base::make_optional(row_count);
+ aria_column_count = base::make_optional(column_count);
+}
+
+void TestListGridView::SetTableSize(int row_count, int column_count) {
+ table_row_count = base::make_optional(row_count);
+ table_column_count = base::make_optional(column_count);
+}
+
+void TestListGridView::UnsetAriaTableSize() {
+ aria_row_count = base::nullopt;
+ aria_column_count = base::nullopt;
+}
+
+void TestListGridView::UnsetTableSize() {
+ table_row_count = base::nullopt;
+ table_column_count = base::nullopt;
+}
+
+} // namespace test
+} // namespace views
diff --git a/chromium/ui/views/accessibility/test_list_grid_view.h b/chromium/ui/views/accessibility/test_list_grid_view.h
new file mode 100644
index 00000000000..8c742ba1010
--- /dev/null
+++ b/chromium/ui/views/accessibility/test_list_grid_view.h
@@ -0,0 +1,40 @@
+// Copyright 2020 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 UI_VIEWS_ACCESSIBILITY_TEST_LIST_GRID_VIEW_H_
+#define UI_VIEWS_ACCESSIBILITY_TEST_LIST_GRID_VIEW_H_
+
+#include "ui/views/view.h"
+
+namespace ui {
+struct AXNodeData;
+} // namespace ui
+
+namespace views {
+namespace test {
+
+// Class used for testing row and column count accessibility APIs.
+class TestListGridView : public View {
+ public:
+ TestListGridView();
+ ~TestListGridView() override;
+
+ void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
+
+ void SetAriaTableSize(int row_count, int column_count);
+ void SetTableSize(int row_count, int column_count);
+ void UnsetAriaTableSize();
+ void UnsetTableSize();
+
+ private:
+ base::Optional<int> aria_row_count = base::nullopt;
+ base::Optional<int> aria_column_count = base::nullopt;
+ base::Optional<int> table_row_count = base::nullopt;
+ base::Optional<int> table_column_count = base::nullopt;
+};
+
+} // namespace test
+} // namespace views
+
+#endif // UI_VIEWS_ACCESSIBILITY_TEST_LIST_GRID_VIEW_H_
diff --git a/chromium/ui/views/accessibility/view_ax_platform_node_delegate_win_unittest.cc b/chromium/ui/views/accessibility/view_ax_platform_node_delegate_win_unittest.cc
index 8061724c841..797c0eb5482 100644
--- a/chromium/ui/views/accessibility/view_ax_platform_node_delegate_win_unittest.cc
+++ b/chromium/ui/views/accessibility/view_ax_platform_node_delegate_win_unittest.cc
@@ -12,6 +12,9 @@
#include "base/win/scoped_bstr.h"
#include "base/win/scoped_variant.h"
#include "third_party/iaccessible2/ia2_api_all.h"
+#include "ui/accessibility/ax_constants.mojom.h"
+#include "ui/accessibility/platform/ax_platform_node_win.h"
+#include "ui/views/accessibility/test_list_grid_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/textfield/textfield.h"
@@ -407,5 +410,82 @@ TEST_F(ViewAXPlatformNodeDelegateWinTest, Overrides) {
alert_accessible->get_accChild(child_index, &child_dispatch));
ASSERT_EQ(child_dispatch.Get(), nullptr);
}
+
+TEST_F(ViewAXPlatformNodeDelegateWinTest, GridRowColumnCount) {
+ Widget widget;
+ Widget::InitParams init_params = CreateParams(Widget::InitParams::TYPE_POPUP);
+ init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ widget.Init(std::move(init_params));
+
+ View* content = new View;
+ widget.SetContentsView(content);
+ TestListGridView* grid = new TestListGridView();
+ content->AddChildView(grid);
+
+ Microsoft::WRL::ComPtr<IGridProvider> grid_provider;
+ EXPECT_HRESULT_SUCCEEDED(
+ grid->GetViewAccessibility().GetNativeObject()->QueryInterface(
+ __uuidof(IGridProvider), &grid_provider));
+
+ // If set, aria row/column count takes precedence over table row/column count.
+ // Expect E_UNEXPECTED if the result is kUnknownAriaColumnOrRowCount (-1) or
+ // if neither is set.
+ int row_count;
+ int column_count;
+
+ // aria row/column count = not set
+ // table row/column count = not set
+ grid->UnsetAriaTableSize();
+ grid->UnsetTableSize();
+ EXPECT_HRESULT_SUCCEEDED(grid_provider->get_RowCount(&row_count));
+ EXPECT_HRESULT_SUCCEEDED(grid_provider->get_ColumnCount(&column_count));
+ EXPECT_EQ(0, row_count);
+ EXPECT_EQ(0, column_count);
+ // To do still: When nothing is set, currently
+ // AXPlatformNodeDelegateBase::GetTable{Row/Col}Count() returns 0 Should it
+ // return base::nullopt if the attribute is not set? Like
+ // GetTableAria{Row/Col}Count()
+ // EXPECT_EQ(E_UNEXPECTED, grid_provider->get_RowCount(&row_count));
+
+ // aria row/column count = 2
+ // table row/column count = not set
+ grid->SetAriaTableSize(2, 2);
+ EXPECT_HRESULT_SUCCEEDED(grid_provider->get_RowCount(&row_count));
+ EXPECT_HRESULT_SUCCEEDED(grid_provider->get_ColumnCount(&column_count));
+ EXPECT_EQ(2, row_count);
+ EXPECT_EQ(2, column_count);
+
+ // aria row/column count = kUnknownAriaColumnOrRowCount
+ // table row/column count = not set
+ grid->SetAriaTableSize(ax::mojom::kUnknownAriaColumnOrRowCount,
+ ax::mojom::kUnknownAriaColumnOrRowCount);
+ EXPECT_EQ(E_UNEXPECTED, grid_provider->get_RowCount(&row_count));
+ EXPECT_EQ(E_UNEXPECTED, grid_provider->get_ColumnCount(&column_count));
+
+ // aria row/column count = 3
+ // table row/column count = 4
+ grid->SetAriaTableSize(3, 3);
+ grid->SetTableSize(4, 4);
+ EXPECT_HRESULT_SUCCEEDED(grid_provider->get_RowCount(&row_count));
+ EXPECT_HRESULT_SUCCEEDED(grid_provider->get_ColumnCount(&column_count));
+ EXPECT_EQ(3, row_count);
+ EXPECT_EQ(3, column_count);
+
+ // aria row/column count = not set
+ // table row/column count = 4
+ grid->UnsetAriaTableSize();
+ grid->SetTableSize(4, 4);
+ EXPECT_HRESULT_SUCCEEDED(grid_provider->get_RowCount(&row_count));
+ EXPECT_HRESULT_SUCCEEDED(grid_provider->get_ColumnCount(&column_count));
+ EXPECT_EQ(4, row_count);
+ EXPECT_EQ(4, column_count);
+
+ // aria row/column count = not set
+ // table row/column count = kUnknownAriaColumnOrRowCount
+ grid->SetTableSize(ax::mojom::kUnknownAriaColumnOrRowCount,
+ ax::mojom::kUnknownAriaColumnOrRowCount);
+ EXPECT_EQ(E_UNEXPECTED, grid_provider->get_RowCount(&row_count));
+ EXPECT_EQ(E_UNEXPECTED, grid_provider->get_ColumnCount(&column_count));
+}
} // namespace test
} // namespace views
diff --git a/chromium/ui/views/accessibility/views_ax_tree_manager.cc b/chromium/ui/views/accessibility/views_ax_tree_manager.cc
index 15954cf453f..2b30e23ceef 100644
--- a/chromium/ui/views/accessibility/views_ax_tree_manager.cc
+++ b/chromium/ui/views/accessibility/views_ax_tree_manager.cc
@@ -8,8 +8,9 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "base/check.h"
#include "base/location.h"
-#include "base/logging.h"
+#include "base/notreached.h"
#include "base/threading/sequenced_task_runner_handle.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_enums.mojom.h"
diff --git a/chromium/ui/views/animation/bounds_animator.cc b/chromium/ui/views/animation/bounds_animator.cc
index 64fda4d79b2..cf2598680d4 100644
--- a/chromium/ui/views/animation/bounds_animator.cc
+++ b/chromium/ui/views/animation/bounds_animator.cc
@@ -44,9 +44,21 @@ void BoundsAnimator::AnimateViewTo(
Data existing_data;
if (IsAnimating(view)) {
- // Don't immediately delete the animation, that might trigger a callback
- // from the animation container.
- existing_data = RemoveFromMaps(view);
+ DCHECK(base::Contains(data_, view));
+ const bool used_transforms = data_[view].target_transform.has_value();
+ if (used_transforms) {
+ // Using transforms means a view does not have the proper bounds until an
+ // animation is complete or canceled. So here we cancel the animation so
+ // that the bounds can be updated. Note that this means that callers who
+ // want to set bounds (i.e. View::SetBoundsRect()) directly before calling
+ // this function will have to explicitly call StopAnimatingView() before
+ // doing so.
+ StopAnimatingView(view);
+ } else {
+ // Don't immediately delete the animation, that might trigger a callback
+ // from the animation container.
+ existing_data = RemoveFromMaps(view);
+ }
}
// NOTE: we don't check if the view is already at the target location. Doing
@@ -60,12 +72,20 @@ void BoundsAnimator::AnimateViewTo(
data.animation = CreateAnimation();
data.delegate = std::move(delegate);
- if (use_transforms_ && !data.start_bounds.IsEmpty()) {
+ // If the start bounds are empty we cannot derive a transform from start to
+ // target. Views with existing transforms are not supported. Default back to
+ // using the bounds update animation in these cases.
+ if (use_transforms_ && !data.start_bounds.IsEmpty() &&
+ view->GetTransform().IsIdentity()) {
// Calculate the target transform. Note that we don't reset the transform if
// there already was one, otherwise users will end up with visual bounds
// different than what they set.
+ // Note that View::SetTransform() does not handle RTL, which is different
+ // from View::SetBounds(). So mirror the start bounds and target bounds
+ // manually if necessary.
const gfx::Transform target_transform = gfx::TransformBetweenRects(
- gfx::RectF(data.start_bounds), gfx::RectF(data.target_bounds));
+ gfx::RectF(parent_->GetMirroredRect(data.start_bounds)),
+ gfx::RectF(parent_->GetMirroredRect(data.target_bounds)));
data.target_transform = target_transform;
}
@@ -89,28 +109,6 @@ gfx::Rect BoundsAnimator::GetTargetBounds(const View* view) const {
return (i == data_.end()) ? view->bounds() : i->second.target_bounds;
}
-void BoundsAnimator::SetAnimationForView(
- View* view,
- std::unique_ptr<gfx::SlideAnimation> animation) {
- DCHECK(animation);
-
- const auto i = data_.find(view);
- if (i == data_.end())
- return;
-
- // We delay deleting the animation until the end so that we don't prematurely
- // send out notification that we're done.
- std::unique_ptr<gfx::Animation> old_animation = ResetAnimationForView(view);
-
- gfx::SlideAnimation* animation_ptr = animation.get();
- i->second.animation = std::move(animation);
- animation_to_view_[animation_ptr] = view;
-
- animation_ptr->set_delegate(this);
- animation_ptr->SetContainer(container_.get());
- animation_ptr->Show();
-}
-
const gfx::SlideAnimation* BoundsAnimator::GetAnimationForView(View* view) {
const auto i = data_.find(view);
return (i == data_.end()) ? nullptr : i->second.animation.get();
@@ -224,10 +222,20 @@ void BoundsAnimator::AnimationEndedOrCanceled(const gfx::Animation* animation,
Data data = RemoveFromMaps(view);
if (data.target_transform) {
- // Set the bounds at the end of the animation and reset the transform.
- view->SetTransform(gfx::Transform());
- if (type == AnimationEndType::kEnded)
+ if (type == AnimationEndType::kEnded) {
+ // Set the bounds at the end of the animation and reset the transform.
view->SetBoundsRect(data.target_bounds);
+ } else {
+ DCHECK_EQ(AnimationEndType::kCanceled, type);
+ // Get the existing transform and apply it to the start bounds which is
+ // the current bounds of the view. This will place the bounds at the place
+ // where the animation stopped.
+ const gfx::Transform transform = view->GetTransform();
+ gfx::RectF bounds_f(view->bounds());
+ transform.TransformRect(&bounds_f);
+ view->SetBoundsRect(gfx::ToRoundedRect(bounds_f));
+ }
+ view->SetTransform(gfx::Transform());
}
if (data.delegate) {
diff --git a/chromium/ui/views/animation/bounds_animator.h b/chromium/ui/views/animation/bounds_animator.h
index 620145bce60..dff13110422 100644
--- a/chromium/ui/views/animation/bounds_animator.h
+++ b/chromium/ui/views/animation/bounds_animator.h
@@ -67,10 +67,6 @@ class VIEWS_EXPORT BoundsAnimator : public AnimationDelegateViews {
// animating its current bounds is returned.
gfx::Rect GetTargetBounds(const View* view) const;
- // Sets the animation for the specified view.
- void SetAnimationForView(View* view,
- std::unique_ptr<gfx::SlideAnimation> animation);
-
// Returns the animation for the specified view. BoundsAnimator owns the
// returned Animation.
const gfx::SlideAnimation* GetAnimationForView(View* view);
diff --git a/chromium/ui/views/animation/bounds_animator_unittest.cc b/chromium/ui/views/animation/bounds_animator_unittest.cc
index 790c74759e7..c09736c4572 100644
--- a/chromium/ui/views/animation/bounds_animator_unittest.cc
+++ b/chromium/ui/views/animation/bounds_animator_unittest.cc
@@ -6,6 +6,7 @@
#include "base/macros.h"
#include "base/run_loop.h"
+#include "base/test/icu_test_util.h"
#include "base/test/task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/animation/slide_animation.h"
@@ -78,6 +79,56 @@ class TestView : public View {
DISALLOW_COPY_AND_ASSIGN(TestView);
};
+class RTLAnimationTestDelegate : public gfx::AnimationDelegate {
+ public:
+ RTLAnimationTestDelegate(const gfx::Rect& start,
+ const gfx::Rect& target,
+ View* view,
+ base::RepeatingClosure quit_closure)
+ : start_(start),
+ target_(target),
+ view_(view),
+ quit_closure_(std::move(quit_closure)) {}
+ ~RTLAnimationTestDelegate() override = default;
+
+ private:
+ // gfx::AnimationDelegate:
+ void AnimationProgressed(const Animation* animation) override {
+ gfx::Transform transform = view_->GetTransform();
+ ASSERT_TRUE(!transform.IsIdentity());
+
+ // In this test, assume that |parent| is root view.
+ View* parent = view_->parent();
+
+ const gfx::Rect start_rect_in_screen = parent->GetMirroredRect(start_);
+ const gfx::Rect target_rect_in_screen = parent->GetMirroredRect(target_);
+
+ gfx::RectF current_bounds_in_screen(
+ parent->GetMirroredRect(view_->bounds()));
+ transform.TransformRect(&current_bounds_in_screen);
+
+ // Verify that |view_|'s current bounds in screen are valid.
+ EXPECT_GE(current_bounds_in_screen.x(),
+ std::min(start_rect_in_screen.x(), target_rect_in_screen.x()));
+ EXPECT_LE(
+ current_bounds_in_screen.right(),
+ std::max(start_rect_in_screen.right(), target_rect_in_screen.right()));
+
+ quit_closure_.Run();
+ }
+
+ // Animation initial bounds.
+ gfx::Rect start_;
+
+ // Animation target bounds.
+ gfx::Rect target_;
+
+ // view to be animated.
+ View* view_;
+
+ base::RepeatingClosure quit_closure_;
+};
+
} // namespace
class BoundsAnimatorTest : public testing::Test {
@@ -268,4 +319,64 @@ TEST_F(BoundsAnimatorTest, UseTransformsAnimateViewToEmptySrc) {
EXPECT_EQ(target_bounds, child()->bounds());
}
+// Tests that when using the transform option on the bounds animator, cancelling
+// the animation part way results in the correct bounds applied.
+TEST_F(BoundsAnimatorTest, UseTransformsCancelAnimation) {
+ RecreateAnimator(/*use_transforms=*/true);
+
+ gfx::Rect initial_bounds(0, 0, 10, 10);
+ child()->SetBoundsRect(initial_bounds);
+ gfx::Rect target_bounds(10, 10, 20, 20);
+
+ const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(200);
+ animator()->SetAnimationDuration(duration);
+ // Use a linear tween so we can estimate the expected bounds.
+ animator()->set_tween_type(gfx::Tween::LINEAR);
+ animator()->AnimateViewTo(child(), target_bounds);
+ animator()->SetAnimationDelegate(child(),
+ std::make_unique<TestAnimationDelegate>());
+ EXPECT_TRUE(animator()->IsAnimating());
+ EXPECT_TRUE(animator()->IsAnimating(child()));
+
+ // Stop halfway and cancel. The child should have its bounds updated to
+ // exactly halfway between |initial_bounds| and |target_bounds|.
+ const gfx::Rect expected_bounds(5, 5, 15, 15);
+ task_environment_.FastForwardBy(base::TimeDelta::FromMilliseconds(100));
+ EXPECT_EQ(initial_bounds, child()->bounds());
+ animator()->Cancel();
+ EXPECT_EQ(expected_bounds, child()->bounds());
+}
+
+// Verify that the bounds animation which updates the transform of views work
+// as expected under RTL (https://crbug.com/1067033).
+TEST_F(BoundsAnimatorTest, VerifyBoundsAnimatorUnderRTL) {
+ // Enable RTL.
+ base::test::ScopedRestoreICUDefaultLocale scoped_locale("he");
+
+ RecreateAnimator(/*use_transform=*/true);
+ parent()->SetBounds(0, 0, 40, 40);
+
+ const gfx::Rect initial_bounds(0, 0, 10, 10);
+ child()->SetBoundsRect(initial_bounds);
+ const gfx::Rect target_bounds(10, 10, 10, 10);
+
+ const base::TimeDelta animation_duration =
+ base::TimeDelta::FromMilliseconds(10);
+ animator()->SetAnimationDuration(animation_duration);
+ child()->set_repaint_count(0);
+ animator()->AnimateViewTo(child(), target_bounds);
+ base::RunLoop run_loop;
+ animator()->SetAnimationDelegate(
+ child(),
+ std::make_unique<RTLAnimationTestDelegate>(
+ initial_bounds, target_bounds, child(), run_loop.QuitClosure()));
+
+ // The animator should be animating now.
+ EXPECT_TRUE(animator()->IsAnimating());
+ EXPECT_TRUE(animator()->IsAnimating(child()));
+
+ run_loop.Run();
+ EXPECT_FALSE(animator()->IsAnimating(child()));
+}
+
} // namespace views
diff --git a/chromium/ui/views/animation/ink_drop.h b/chromium/ui/views/animation/ink_drop.h
index e0b95f64e99..b8692ae1330 100644
--- a/chromium/ui/views/animation/ink_drop.h
+++ b/chromium/ui/views/animation/ink_drop.h
@@ -30,6 +30,9 @@ class VIEWS_EXPORT InkDrop {
// Called by ink drop hosts when their size is changed.
virtual void HostSizeChanged(const gfx::Size& new_size) = 0;
+ // Called by ink drop hosts when their transform is changed.
+ virtual void HostTransformChanged(const gfx::Transform& new_transform) = 0;
+
// Gets the target state of the ink drop.
virtual InkDropState GetTargetInkDropState() const = 0;
diff --git a/chromium/ui/views/animation/ink_drop_animation_ended_reason.cc b/chromium/ui/views/animation/ink_drop_animation_ended_reason.cc
index 8499995cd34..f1e4c5553f5 100644
--- a/chromium/ui/views/animation/ink_drop_animation_ended_reason.cc
+++ b/chromium/ui/views/animation/ink_drop_animation_ended_reason.cc
@@ -4,7 +4,9 @@
#include "ui/views/animation/ink_drop_animation_ended_reason.h"
-#include "base/logging.h"
+#include <ostream>
+
+#include "base/notreached.h"
namespace views {
diff --git a/chromium/ui/views/animation/ink_drop_host_view.cc b/chromium/ui/views/animation/ink_drop_host_view.cc
index cb4df9bda33..48e61528b74 100644
--- a/chromium/ui/views/animation/ink_drop_host_view.cc
+++ b/chromium/ui/views/animation/ink_drop_host_view.cc
@@ -182,13 +182,26 @@ void InkDropHostView::ResetInkDropMask() {
}
bool InkDropHostView::AddInkDropClip(ui::Layer* ink_drop_layer) {
- base::Optional<HighlightPathGenerator::RoundRect> clipping_data =
+ base::Optional<gfx::RRectF> clipping_data =
HighlightPathGenerator::GetRoundRectForView(this);
if (!clipping_data)
return false;
- ink_drop_layer->SetClipRect(gfx::ToEnclosingRect(clipping_data->bounds));
- ink_drop_layer->SetRoundedCornerRadius(
- gfx::RoundedCornersF(clipping_data->corner_radius));
+
+ ink_drop_layer->SetClipRect(gfx::ToEnclosingRect(clipping_data->rect()));
+ auto get_corner_radii =
+ [&clipping_data](gfx::RRectF::Corner corner) -> float {
+ return clipping_data.value().GetCornerRadii(corner).x();
+ };
+ gfx::RoundedCornersF rounded_corners;
+ rounded_corners.set_upper_left(
+ get_corner_radii(gfx::RRectF::Corner::kUpperLeft));
+ rounded_corners.set_upper_right(
+ get_corner_radii(gfx::RRectF::Corner::kUpperRight));
+ rounded_corners.set_lower_right(
+ get_corner_radii(gfx::RRectF::Corner::kLowerRight));
+ rounded_corners.set_lower_left(
+ get_corner_radii(gfx::RRectF::Corner::kLowerLeft));
+ ink_drop_layer->SetRoundedCornerRadius(rounded_corners);
ink_drop_layer->SetIsFastRoundedCorner(true);
return true;
}
diff --git a/chromium/ui/views/animation/ink_drop_host_view_unittest.cc b/chromium/ui/views/animation/ink_drop_host_view_unittest.cc
index 390e1a991a9..303547f1bed 100644
--- a/chromium/ui/views/animation/ink_drop_host_view_unittest.cc
+++ b/chromium/ui/views/animation/ink_drop_host_view_unittest.cc
@@ -220,7 +220,7 @@ TEST_F(InkDropHostViewTest, NoInkDropOnTouchOrGestureEvents) {
ui::TouchEvent touch_event(
ui::ET_TOUCH_PRESSED, gfx::Point(5, 6), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
test_api_.AnimateInkDrop(InkDropState::ACTION_PENDING, &touch_event);
EXPECT_EQ(test_api_.GetInkDrop()->GetTargetInkDropState(),
@@ -268,7 +268,7 @@ TEST_F(InkDropHostViewTest, DismissInkDropOnTouchOrGestureEvents) {
ui::TouchEvent touch_event(
ui::ET_TOUCH_PRESSED, gfx::Point(5, 6), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
test_api_.AnimateInkDrop(InkDropState::ACTION_TRIGGERED, &touch_event);
EXPECT_EQ(test_api_.GetInkDrop()->GetTargetInkDropState(),
diff --git a/chromium/ui/views/animation/ink_drop_impl.cc b/chromium/ui/views/animation/ink_drop_impl.cc
index c5d93d3d4c4..631a69e84be 100644
--- a/chromium/ui/views/animation/ink_drop_impl.cc
+++ b/chromium/ui/views/animation/ink_drop_impl.cc
@@ -628,6 +628,12 @@ void InkDropImpl::HostSizeChanged(const gfx::Size& new_size) {
}
}
+void InkDropImpl::HostTransformChanged(const gfx::Transform& new_transform) {
+ // If the host has a transform applied, the root and its children layers
+ // should be affected too.
+ root_layer_->SetTransform(new_transform);
+}
+
InkDropState InkDropImpl::GetTargetInkDropState() const {
if (!ink_drop_ripple_)
return InkDropState::HIDDEN;
diff --git a/chromium/ui/views/animation/ink_drop_impl.h b/chromium/ui/views/animation/ink_drop_impl.h
index 46b1b305456..971f3548adc 100644
--- a/chromium/ui/views/animation/ink_drop_impl.h
+++ b/chromium/ui/views/animation/ink_drop_impl.h
@@ -70,6 +70,7 @@ class VIEWS_EXPORT InkDropImpl : public InkDrop,
// InkDrop:
void HostSizeChanged(const gfx::Size& new_size) override;
+ void HostTransformChanged(const gfx::Transform& new_transform) override;
InkDropState GetTargetInkDropState() const override;
void AnimateToState(InkDropState ink_drop_state) override;
void SetHoverHighlightFadeDuration(base::TimeDelta duration) override;
diff --git a/chromium/ui/views/animation/ink_drop_state.cc b/chromium/ui/views/animation/ink_drop_state.cc
index adbefae1a22..f06a305ca59 100644
--- a/chromium/ui/views/animation/ink_drop_state.cc
+++ b/chromium/ui/views/animation/ink_drop_state.cc
@@ -4,9 +4,10 @@
#include "ui/views/animation/ink_drop_state.h"
+#include <ostream>
#include <string>
-#include "base/logging.h"
+#include "base/notreached.h"
namespace views {
diff --git a/chromium/ui/views/animation/ink_drop_stub.cc b/chromium/ui/views/animation/ink_drop_stub.cc
index 24e6245a68e..c15af9618d1 100644
--- a/chromium/ui/views/animation/ink_drop_stub.cc
+++ b/chromium/ui/views/animation/ink_drop_stub.cc
@@ -12,6 +12,8 @@ InkDropStub::~InkDropStub() = default;
void InkDropStub::HostSizeChanged(const gfx::Size& new_size) {}
+void InkDropStub::HostTransformChanged(const gfx::Transform& new_transform) {}
+
InkDropState InkDropStub::GetTargetInkDropState() const {
return InkDropState::HIDDEN;
}
diff --git a/chromium/ui/views/animation/ink_drop_stub.h b/chromium/ui/views/animation/ink_drop_stub.h
index ba8985cc5c7..849bc196e03 100644
--- a/chromium/ui/views/animation/ink_drop_stub.h
+++ b/chromium/ui/views/animation/ink_drop_stub.h
@@ -20,6 +20,7 @@ class VIEWS_EXPORT InkDropStub : public InkDrop {
// InkDrop:
void HostSizeChanged(const gfx::Size& new_size) override;
+ void HostTransformChanged(const gfx::Transform& new_transform) override;
InkDropState GetTargetInkDropState() const override;
void AnimateToState(InkDropState state) override;
void SetHoverHighlightFadeDuration(base::TimeDelta duration) override;
diff --git a/chromium/ui/views/animation/ink_drop_util.cc b/chromium/ui/views/animation/ink_drop_util.cc
index 1e5bbb18ace..72ce6649793 100644
--- a/chromium/ui/views/animation/ink_drop_util.cc
+++ b/chromium/ui/views/animation/ink_drop_util.cc
@@ -6,7 +6,7 @@
#include <math.h>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "ui/gfx/geometry/point3_f.h"
#include "ui/gfx/geometry/safe_integer_conversions.h"
#include "ui/gfx/geometry/vector2d_f.h"
diff --git a/chromium/ui/views/animation/installable_ink_drop.cc b/chromium/ui/views/animation/installable_ink_drop.cc
index e0708a8ce9d..ee67a05be7f 100644
--- a/chromium/ui/views/animation/installable_ink_drop.cc
+++ b/chromium/ui/views/animation/installable_ink_drop.cc
@@ -6,8 +6,9 @@
#include <algorithm>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/memory/ptr_util.h"
+#include "base/notreached.h"
#include "cc/paint/paint_flags.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkPath.h"
@@ -106,6 +107,9 @@ void InstallableInkDrop::HostSizeChanged(const gfx::Size& new_size) {
animator_.SetSize(layer_->size());
}
+void InstallableInkDrop::HostTransformChanged(
+ const gfx::Transform& new_transform) {}
+
InkDropState InstallableInkDrop::GetTargetInkDropState() const {
return animator_.target_state();
}
diff --git a/chromium/ui/views/animation/installable_ink_drop.h b/chromium/ui/views/animation/installable_ink_drop.h
index 65eb6489883..1fa261a776d 100644
--- a/chromium/ui/views/animation/installable_ink_drop.h
+++ b/chromium/ui/views/animation/installable_ink_drop.h
@@ -67,6 +67,7 @@ class VIEWS_EXPORT InstallableInkDrop : public InkDrop,
// InkDrop:
void HostSizeChanged(const gfx::Size& new_size) override;
+ void HostTransformChanged(const gfx::Transform& new_transform) override;
InkDropState GetTargetInkDropState() const override;
void AnimateToState(InkDropState ink_drop_state) override;
void SetHoverHighlightFadeDuration(base::TimeDelta duration) override;
diff --git a/chromium/ui/views/animation/installable_ink_drop_animator.cc b/chromium/ui/views/animation/installable_ink_drop_animator.cc
index 54c014b6508..4acf8cfcbf5 100644
--- a/chromium/ui/views/animation/installable_ink_drop_animator.cc
+++ b/chromium/ui/views/animation/installable_ink_drop_animator.cc
@@ -7,7 +7,8 @@
#include <algorithm>
#include "base/bind.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/trace_event/trace_event.h"
#include "ui/gfx/animation/tween.h"
#include "ui/gfx/geometry/point_f.h"
diff --git a/chromium/ui/views/animation/scroll_animator.cc b/chromium/ui/views/animation/scroll_animator.cc
index 64a270d69ab..7f5a66f1e4f 100644
--- a/chromium/ui/views/animation/scroll_animator.cc
+++ b/chromium/ui/views/animation/scroll_animator.cc
@@ -7,7 +7,7 @@
#include <algorithm>
#include <cmath>
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/gfx/animation/slide_animation.h"
namespace {
diff --git a/chromium/ui/views/background.cc b/chromium/ui/views/background.cc
index d8fc6304194..ed6a43ff33e 100644
--- a/chromium/ui/views/background.cc
+++ b/chromium/ui/views/background.cc
@@ -6,7 +6,7 @@
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/macros.h"
#include "base/scoped_observer.h"
#include "build/build_config.h"
diff --git a/chromium/ui/views/border.cc b/chromium/ui/views/border.cc
index e7b20c6f2e6..041214dc717 100644
--- a/chromium/ui/views/border.cc
+++ b/chromium/ui/views/border.cc
@@ -7,7 +7,7 @@
#include <memory>
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "cc/paint/paint_flags.h"
diff --git a/chromium/ui/views/bubble/bubble_border.cc b/chromium/ui/views/bubble/bubble_border.cc
index 9b278304422..22b609a91c5 100644
--- a/chromium/ui/views/bubble/bubble_border.cc
+++ b/chromium/ui/views/bubble/bubble_border.cc
@@ -10,8 +10,9 @@
#include <utility>
#include <vector>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/no_destructor.h"
+#include "base/notreached.h"
#include "cc/paint/paint_flags.h"
#include "third_party/skia/include/core/SkDrawLooper.h"
#include "third_party/skia/include/core/SkPath.h"
diff --git a/chromium/ui/views/bubble/bubble_dialog_delegate_view.cc b/chromium/ui/views/bubble/bubble_dialog_delegate_view.cc
index 308adac42ea..be71a1d4243 100644
--- a/chromium/ui/views/bubble/bubble_dialog_delegate_view.cc
+++ b/chromium/ui/views/bubble/bubble_dialog_delegate_view.cc
@@ -12,6 +12,7 @@
#include "build/build_config.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
+#include "ui/accessibility/ax_role_properties.h"
#include "ui/base/default_style.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/color_utils.h"
@@ -153,10 +154,6 @@ class BubbleDialogDelegateView::AnchorViewObserver : public ViewObserver {
parent_->OnAnchorBoundsChanged();
}
- void OnViewAddedToWidget(View* observed_view) override {
- parent_->SetAnchorWidget(observed_view->GetWidget());
- }
-
// TODO(pbos): Consider observing View visibility changes and only updating
// view bounds when the anchor is visible.
@@ -169,6 +166,8 @@ class BubbleDialogDelegateView::AnchorViewObserver : public ViewObserver {
Widget* BubbleDialogDelegateView::CreateBubble(
BubbleDialogDelegateView* bubble_delegate) {
bubble_delegate->Init();
+ // Get the latest anchor widget from the anchor view at bubble creation time.
+ bubble_delegate->SetAnchorView(bubble_delegate->GetAnchorView());
Widget* bubble_widget = CreateBubbleWidget(bubble_delegate);
#if (defined(OS_LINUX) && !defined(OS_CHROMEOS)) || defined(OS_MACOSX)
@@ -189,6 +188,8 @@ BubbleDialogDelegateView::BubbleDialogDelegateView(View* anchor_view,
BubbleBorder::Arrow arrow,
BubbleBorder::Shadow shadow)
: shadow_(shadow) {
+ WidgetDelegate::SetShowCloseButton(false);
+
SetArrow(arrow);
LayoutProvider* provider = LayoutProvider::Get();
// An individual bubble should override these margins if its layout differs
@@ -210,10 +211,6 @@ BubbleDialogDelegateView* BubbleDialogDelegateView::AsBubbleDialogDelegate() {
return this;
}
-bool BubbleDialogDelegateView::ShouldShowCloseButton() const {
- return false;
-}
-
NonClientFrameView* BubbleDialogDelegateView::CreateNonClientFrameView(
Widget* widget) {
BubbleFrameView* frame = new BubbleDialogFrameView(title_margins_);
@@ -456,18 +453,49 @@ void BubbleDialogDelegateView::SetAnchorView(View* anchor_view) {
anchor_view_observer_.reset();
}
- SetAnchorWidget(anchor_view ? anchor_view->GetWidget() : nullptr);
- if (!anchor_view)
- return;
+ // When the anchor view gets set the associated anchor widget might
+ // change as well.
+ if (!anchor_view || anchor_widget() != anchor_view->GetWidget()) {
+ if (anchor_widget()) {
+ if (GetWidget() && GetWidget()->IsVisible())
+ UpdateHighlightedButton(false);
+ paint_as_active_lock_.reset();
+ anchor_widget_->RemoveObserver(this);
+ anchor_widget_ = nullptr;
+ }
+ if (anchor_view) {
+ anchor_widget_ = anchor_view->GetWidget();
+ if (anchor_widget_) {
+ anchor_widget_->AddObserver(this);
+ const bool visible = GetWidget() && GetWidget()->IsVisible();
+ UpdateHighlightedButton(visible);
+ // Have the anchor widget's paint-as-active state track this view's
+ // widget - lock is only required if the bubble widget is active.
+ if (anchor_widget_->GetTopLevelWidget() && GetWidget() &&
+ GetWidget()->ShouldPaintAsActive()) {
+ paint_as_active_lock_ =
+ anchor_widget_->GetTopLevelWidget()->LockPaintAsActive();
+ }
+ }
+ }
+ }
- anchor_view_observer_ =
- std::make_unique<AnchorViewObserver>(this, anchor_view);
- OnAnchorBoundsChanged();
+ if (anchor_view) {
+ anchor_view_observer_ =
+ std::make_unique<AnchorViewObserver>(this, anchor_view);
+ // Do not update anchoring for NULL views; this could indicate
+ // that our NativeWindow is being destroyed, so it would be
+ // dangerous for us to update our anchor bounds at that
+ // point. (It's safe to skip this, since if we were to update the
+ // bounds when |anchor_view| is NULL, the bubble won't move.)
+ OnAnchorBoundsChanged();
+ }
- // Make sure that focus can move into here from the anchor view (but not out,
- // focus will cycle inside the dialog once it gets here).
- if (focus_traversable_from_anchor_view_)
+ if (anchor_view && focus_traversable_from_anchor_view_) {
+ // Make sure that focus can move into here from the anchor view (but not
+ // out, focus will cycle inside the dialog once it gets here).
anchor_view->SetProperty(kAnchoredDialogKey, this);
+ }
}
void BubbleDialogDelegateView::SetAnchorRect(const gfx::Rect& rect) {
@@ -520,8 +548,7 @@ void BubbleDialogDelegateView::HandleVisibilityChanged(Widget* widget,
// the bubble in its entirety rather than just its title and initially focused
// view. See http://crbug.com/474622 for details.
if (widget == GetWidget() && visible) {
- if (GetAccessibleWindowRole() == ax::mojom::Role::kAlert ||
- GetAccessibleWindowRole() == ax::mojom::Role::kAlertDialog) {
+ if (ui::IsAlert(GetAccessibleWindowRole())) {
widget->GetRootView()->NotifyAccessibilityEvent(ax::mojom::Event::kAlert,
true);
}
@@ -533,28 +560,6 @@ void BubbleDialogDelegateView::OnDeactivate() {
GetWidget()->CloseWithReason(views::Widget::ClosedReason::kLostFocus);
}
-void BubbleDialogDelegateView::SetAnchorWidget(Widget* anchor_widget) {
- if (anchor_widget_ == anchor_widget)
- return;
-
- if (anchor_widget_)
- anchor_widget_->RemoveObserver(this);
-
- UpdateHighlightedButton(GetWidget() && GetWidget()->IsVisible() &&
- anchor_widget);
- // Have the anchor widget's paint-as-active state track this view's widget.
- // Lock is only required if the bubble widget is active.
- paint_as_active_lock_ =
- (GetWidget() && GetWidget()->ShouldPaintAsActive() && anchor_widget &&
- anchor_widget->GetTopLevelWidget())
- ? anchor_widget->GetTopLevelWidget()->LockPaintAsActive()
- : nullptr;
- anchor_widget_ = anchor_widget;
-
- if (anchor_widget_)
- anchor_widget_->AddObserver(this);
-}
-
void BubbleDialogDelegateView::UpdateHighlightedButton(bool highlighted) {
Button* button = Button::AsButton(highlighted_button_tracker_.view());
button = button ? button : Button::AsButton(GetAnchorView());
diff --git a/chromium/ui/views/bubble/bubble_dialog_delegate_view.h b/chromium/ui/views/bubble/bubble_dialog_delegate_view.h
index 862b3d89dec..c56ab1fa993 100644
--- a/chromium/ui/views/bubble/bubble_dialog_delegate_view.h
+++ b/chromium/ui/views/bubble/bubble_dialog_delegate_view.h
@@ -67,7 +67,6 @@ class VIEWS_EXPORT BubbleDialogDelegateView : public DialogDelegateView,
// DialogDelegateView:
BubbleDialogDelegateView* AsBubbleDialogDelegate() override;
- bool ShouldShowCloseButton() const override;
NonClientFrameView* CreateNonClientFrameView(Widget* widget) override;
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
@@ -213,9 +212,6 @@ class VIEWS_EXPORT BubbleDialogDelegateView : public DialogDelegateView,
// Called when a deactivation is detected.
void OnDeactivate();
- // Updates the anchoring widget.
- void SetAnchorWidget(Widget* widget);
-
// Update the button highlight, which may be the anchor view or an explicit
// view set in |highlighted_button_tracker_|. This can be overridden to
// provide different highlight effects.
diff --git a/chromium/ui/views/bubble/footnote_container_view.cc b/chromium/ui/views/bubble/footnote_container_view.cc
index 68c08db02f3..1478fc8cbbb 100644
--- a/chromium/ui/views/bubble/footnote_container_view.cc
+++ b/chromium/ui/views/bubble/footnote_container_view.cc
@@ -57,7 +57,6 @@ FootnoteContainerView::FootnoteContainerView(const gfx::Insets& margins,
SetLayoutManager(std::make_unique<BoxLayout>(
BoxLayout::Orientation::kVertical, margins, 0));
SetCornerRadius(corner_radius);
- ResetBorder();
auto* child_view_ptr = AddChildView(std::move(child_view));
SetVisible(child_view_ptr->GetVisible());
}
@@ -88,10 +87,9 @@ void FootnoteContainerView::ResetBackground() {
}
void FootnoteContainerView::ResetBorder() {
- SetBorder(CreateSolidSidedBorder(1, 0, 0, 0,
- GetNativeTheme()->ShouldUseDarkColors()
- ? gfx::kGoogleGrey900
- : gfx::kGoogleGrey200));
+ SetBorder(CreateSolidSidedBorder(
+ 1, 0, 0, 0, GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_FootnoteContainerBorder)));
}
BEGIN_METADATA(FootnoteContainerView)
diff --git a/chromium/ui/views/color_chooser/color_chooser_view.cc b/chromium/ui/views/color_chooser/color_chooser_view.cc
index 2cd1303c808..2459d40c9e2 100644
--- a/chromium/ui/views/color_chooser/color_chooser_view.cc
+++ b/chromium/ui/views/color_chooser/color_chooser_view.cc
@@ -11,7 +11,7 @@
#include <string>
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/macros.h"
#include "base/numerics/ranges.h"
#include "base/strings/string_number_conversions.h"
@@ -382,10 +382,10 @@ ColorChooserView::ColorChooserView(ColorChooserListener* listener,
container2->SetLayoutManager(std::make_unique<views::GridLayout>());
ColumnSet* columns = layout->AddColumnSet(0);
columns->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
columns->AddPaddingColumn(0, kMarginWidth);
columns->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout->StartRow(0, 0);
auto textfield = std::make_unique<Textfield>();
textfield->set_controller(this);
diff --git a/chromium/ui/views/controls/button/button_controller.cc b/chromium/ui/views/controls/button/button_controller.cc
index 3278b27d162..f639cf93c55 100644
--- a/chromium/ui/views/controls/button/button_controller.cc
+++ b/chromium/ui/views/controls/button/button_controller.cc
@@ -116,6 +116,9 @@ bool ButtonController::OnKeyReleased(const ui::KeyEvent& event) {
}
void ButtonController::OnGestureEvent(ui::GestureEvent* event) {
+ if (button_->state() == Button::STATE_DISABLED)
+ return;
+
if (event->type() == ui::ET_GESTURE_TAP &&
button_controller_delegate_->IsTriggerableEvent(*event)) {
// A GESTURE_END event is issued immediately after ET_GESTURE_TAP and will
diff --git a/chromium/ui/views/controls/button/button_unittest.cc b/chromium/ui/views/controls/button/button_unittest.cc
index 54e0cad33d1..3dfeba259fd 100644
--- a/chromium/ui/views/controls/button/button_unittest.cc
+++ b/chromium/ui/views/controls/button/button_unittest.cc
@@ -7,6 +7,8 @@
#include <memory>
#include <utility>
+#include "base/bind.h"
+#include "base/callback_forward.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
#include "base/run_loop.h"
@@ -80,6 +82,9 @@ class TestButton : public Button, public ButtonListener {
void ButtonPressed(Button* sender, const ui::Event& event) override {
pressed_ = true;
+
+ if (!on_button_pressed_handler_.is_null())
+ on_button_pressed_handler_.Run();
}
void OnClickCanceled(const ui::Event& event) override { canceled_ = true; }
@@ -103,6 +108,10 @@ class TestButton : public Button, public ButtonListener {
custom_key_click_action_ = custom_key_click_action;
}
+ void set_on_button_pressed_handler(const base::RepeatingClosure& callback) {
+ on_button_pressed_handler_ = callback;
+ }
+
void Reset() {
pressed_ = false;
canceled_ = false;
@@ -120,6 +129,9 @@ class TestButton : public Button, public ButtonListener {
KeyClickAction custom_key_click_action_ = KeyClickAction::kNone;
+ // If available, will be triggered when the button is pressed.
+ base::RepeatingClosure on_button_pressed_handler_;
+
DISALLOW_COPY_AND_ASSIGN(TestButton);
};
@@ -159,6 +171,22 @@ class TestButtonObserver : public ButtonObserver {
DISALLOW_COPY_AND_ASSIGN(TestButtonObserver);
};
+TestInkDrop* AddTestInkDrop(TestButton* button) {
+ auto owned_ink_drop = std::make_unique<TestInkDrop>();
+ TestInkDrop* ink_drop = owned_ink_drop.get();
+ InkDropHostViewTestApi(button).SetInkDrop(std::move(owned_ink_drop));
+ return ink_drop;
+}
+
+// TODO(tluk): remove when the appropriate ownership APIs have been added for
+// Widget's SetContentsView().
+template <typename T>
+T* AddContentsView(Widget* widget, std::unique_ptr<T> view) {
+ T* view_ptr = view.get();
+ widget->SetContentsView(view.release());
+ return view_ptr;
+}
+
} // namespace
class ButtonTest : public ViewsTestBase {
@@ -179,8 +207,7 @@ class ButtonTest : public ViewsTestBase {
widget_->Init(std::move(params));
widget_->Show();
- button_ = std::make_unique<TestButton>(false);
- widget_->SetContentsView(button_.get());
+ button_ = AddContentsView(widget(), std::make_unique<TestButton>(false));
event_generator_ =
std::make_unique<ui::test::EventGenerator>(GetRootWindow(widget()));
@@ -192,37 +219,35 @@ class ButtonTest : public ViewsTestBase {
button_->RemoveButtonObserver(button_observer_.get());
button_observer_.reset();
- button_.reset();
widget_.reset();
ViewsTestBase::TearDown();
}
- void CreateButtonWithInkDrop(std::unique_ptr<InkDrop> ink_drop,
- bool has_ink_drop_action_on_click) {
- button_ = std::make_unique<TestButton>(has_ink_drop_action_on_click);
- InkDropHostViewTestApi(button_.get()).SetInkDrop(std::move(ink_drop));
- widget_->SetContentsView(button_.get());
+ TestInkDrop* CreateButtonWithInkDrop(bool has_ink_drop_action_on_click) {
+ button_ = AddContentsView(
+ widget(), std::make_unique<TestButton>(has_ink_drop_action_on_click));
+ widget_->SetContentsView(button_);
+ return AddTestInkDrop(button_);
}
void CreateButtonWithRealInkDrop() {
- button_ = std::make_unique<TestButton>(false);
- InkDropHostViewTestApi(button_.get())
- .SetInkDrop(
- std::make_unique<InkDropImpl>(button_.get(), button_->size()));
- widget_->SetContentsView(button_.get());
+ button_ = AddContentsView(widget(), std::make_unique<TestButton>(false));
+ InkDropHostViewTestApi(button_).SetInkDrop(
+ std::make_unique<InkDropImpl>(button_, button_->size()));
+ widget_->SetContentsView(button_);
}
void CreateButtonWithObserver() {
- button_ = std::make_unique<TestButton>(false);
+ button_ = AddContentsView(widget(), std::make_unique<TestButton>(false));
button_observer_ = std::make_unique<TestButtonObserver>();
button_->AddButtonObserver(button_observer_.get());
- widget_->SetContentsView(button_.get());
+ widget_->SetContentsView(button_);
}
protected:
Widget* widget() { return widget_.get(); }
- TestButton* button() { return button_.get(); }
+ TestButton* button() { return button_; }
TestButtonObserver* button_observer() { return button_observer_.get(); }
ui::test::EventGenerator* event_generator() { return event_generator_.get(); }
void SetDraggedView(View* dragged_view) {
@@ -231,7 +256,7 @@ class ButtonTest : public ViewsTestBase {
private:
std::unique_ptr<Widget> widget_;
- std::unique_ptr<TestButton> button_;
+ TestButton* button_;
std::unique_ptr<TestButtonObserver> button_observer_;
std::unique_ptr<ui::test::EventGenerator> event_generator_;
@@ -419,6 +444,18 @@ TEST_F(ButtonTest, GestureEventsSetState) {
EXPECT_EQ(Button::STATE_NORMAL, button()->state());
}
+// Tests that if the button was disabled in its button press handler, gesture
+// events will not revert the disabled state back to normal.
+// https://crbug.com/1084241.
+TEST_F(ButtonTest, GestureEventsRespectDisabledState) {
+ button()->set_on_button_pressed_handler(base::BindRepeating(
+ [](TestButton* button) { button->SetEnabled(false); }, button()));
+
+ EXPECT_EQ(Button::STATE_NORMAL, button()->state());
+ event_generator()->GestureTapAt(button()->GetBoundsInScreen().CenterPoint());
+ EXPECT_EQ(Button::STATE_DISABLED, button()->state());
+}
+
#endif // !defined(OS_MACOSX) || defined(USE_AURA)
// Ensure subclasses of Button are correctly recognized as Button.
@@ -458,8 +495,7 @@ TEST_F(ButtonTest, AsButton) {
// Note: Ink drop is not hidden upon release because Button descendants
// may enter a different ink drop state.
TEST_F(ButtonTest, ButtonClickTogglesInkDrop) {
- TestInkDrop* ink_drop = new TestInkDrop();
- CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false);
+ TestInkDrop* ink_drop = CreateButtonWithInkDrop(false);
event_generator()->MoveMouseTo(button()->GetBoundsInScreen().CenterPoint());
event_generator()->PressLeftButton();
@@ -472,8 +508,7 @@ TEST_F(ButtonTest, ButtonClickTogglesInkDrop) {
// Tests that pressing a button shows and releasing capture hides ink drop.
// Releasing capture should also reset PRESSED button state to NORMAL.
TEST_F(ButtonTest, CaptureLossHidesInkDrop) {
- TestInkDrop* ink_drop = new TestInkDrop();
- CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false);
+ TestInkDrop* ink_drop = CreateButtonWithInkDrop(false);
event_generator()->MoveMouseTo(button()->GetBoundsInScreen().CenterPoint());
event_generator()->PressLeftButton();
@@ -489,8 +524,7 @@ TEST_F(ButtonTest, CaptureLossHidesInkDrop) {
}
TEST_F(ButtonTest, HideInkDropWhenShowingContextMenu) {
- TestInkDrop* ink_drop = new TestInkDrop();
- CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false);
+ TestInkDrop* ink_drop = CreateButtonWithInkDrop(false);
TestContextMenuController context_menu_controller;
button()->set_context_menu_controller(&context_menu_controller);
button()->set_hide_ink_drop_when_showing_context_menu(true);
@@ -505,8 +539,7 @@ TEST_F(ButtonTest, HideInkDropWhenShowingContextMenu) {
}
TEST_F(ButtonTest, DontHideInkDropWhenShowingContextMenu) {
- TestInkDrop* ink_drop = new TestInkDrop();
- CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false);
+ TestInkDrop* ink_drop = CreateButtonWithInkDrop(false);
TestContextMenuController context_menu_controller;
button()->set_context_menu_controller(&context_menu_controller);
button()->set_hide_ink_drop_when_showing_context_menu(false);
@@ -523,8 +556,7 @@ TEST_F(ButtonTest, DontHideInkDropWhenShowingContextMenu) {
TEST_F(ButtonTest, HideInkDropOnBlur) {
gfx::Point center(10, 10);
- TestInkDrop* ink_drop = new TestInkDrop();
- CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false);
+ TestInkDrop* ink_drop = CreateButtonWithInkDrop(false);
button()->OnFocus();
@@ -543,8 +575,7 @@ TEST_F(ButtonTest, HideInkDropOnBlur) {
}
TEST_F(ButtonTest, HideInkDropHighlightOnDisable) {
- TestInkDrop* ink_drop = new TestInkDrop();
- CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false);
+ TestInkDrop* ink_drop = CreateButtonWithInkDrop(false);
event_generator()->MoveMouseTo(button()->GetBoundsInScreen().CenterPoint());
EXPECT_TRUE(ink_drop->is_hovered());
@@ -555,8 +586,7 @@ TEST_F(ButtonTest, HideInkDropHighlightOnDisable) {
}
TEST_F(ButtonTest, InkDropAfterTryingToShowContextMenu) {
- TestInkDrop* ink_drop = new TestInkDrop();
- CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false);
+ TestInkDrop* ink_drop = CreateButtonWithInkDrop(false);
button()->set_context_menu_controller(nullptr);
ink_drop->SetHovered(true);
@@ -569,34 +599,31 @@ TEST_F(ButtonTest, InkDropAfterTryingToShowContextMenu) {
}
TEST_F(ButtonTest, HideInkDropHighlightWhenRemoved) {
- views::View test_container;
- test_container.set_owned_by_client();
- TestInkDrop* ink_drop = new TestInkDrop();
- CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false);
- // Mark the button as owned by client so we can remove it from widget()
- // without it being deleted.
- button()->set_owned_by_client();
+ View* contents_view = AddContentsView(widget(), std::make_unique<View>());
+
+ TestButton* button =
+ contents_view->AddChildView(std::make_unique<TestButton>(false));
+ button->SetBounds(0, 0, 200, 200);
+ TestInkDrop* ink_drop = AddTestInkDrop(button);
// Make sure that the button ink drop is hidden after the button gets removed.
- widget()->SetContentsView(&test_container);
- test_container.AddChildView(button());
- event_generator()->MoveMouseTo(button()->GetBoundsInScreen().origin());
+ event_generator()->MoveMouseTo(button->GetBoundsInScreen().origin());
event_generator()->MoveMouseBy(2, 2);
EXPECT_TRUE(ink_drop->is_hovered());
// Set ink-drop state to ACTIVATED to make sure that removing the container
// sets it back to HIDDEN.
ink_drop->AnimateToState(InkDropState::ACTIVATED);
- test_container.RemoveAllChildViews(false);
+ auto owned_button = contents_view->RemoveChildViewT(button);
+ button = nullptr;
+
EXPECT_FALSE(ink_drop->is_hovered());
EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState());
// Make sure hiding the ink drop happens even if the button is indirectly
// being removed.
- views::View parent_test_container;
- parent_test_container.set_owned_by_client();
- widget()->SetContentsView(&parent_test_container);
- parent_test_container.AddChildView(&test_container);
- test_container.AddChildView(button());
+ View* parent_view = contents_view->AddChildView(std::make_unique<View>());
+ parent_view->SetBounds(0, 0, 400, 400);
+ button = parent_view->AddChildView(std::move(owned_button));
// Trigger hovering and then remove from the indirect parent. This should
// propagate down to Button which should remove the highlight effect.
@@ -606,17 +633,9 @@ TEST_F(ButtonTest, HideInkDropHighlightWhenRemoved) {
// Set ink-drop state to ACTIVATED to make sure that removing the container
// sets it back to HIDDEN.
ink_drop->AnimateToState(InkDropState::ACTIVATED);
- parent_test_container.RemoveAllChildViews(false);
+ auto owned_parent = contents_view->RemoveChildViewT(parent_view);
EXPECT_EQ(InkDropState::HIDDEN, ink_drop->GetTargetInkDropState());
EXPECT_FALSE(ink_drop->is_hovered());
-
- // Remove references to and delete button() which cannot be removed by owned
- // containers as it's permanently set as owned by client.
- test_container.RemoveAllChildViews(false);
-
- // Set the widget contents view to a new View so widget() doesn't contain a
- // stale reference to the test containers that are about to go out of scope.
- widget()->SetContentsView(new View());
}
// Tests that when button is set to notify on release, dragging mouse out and
@@ -625,8 +644,7 @@ TEST_F(ButtonTest, InkDropShowHideOnMouseDraggedNotifyOnRelease) {
gfx::Point center(10, 10);
gfx::Point oob(-1, -1);
- TestInkDrop* ink_drop = new TestInkDrop();
- CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false);
+ TestInkDrop* ink_drop = CreateButtonWithInkDrop(false);
button()->button_controller()->set_notify_action(
ButtonController::NotifyAction::kOnRelease);
@@ -667,8 +685,7 @@ TEST_F(ButtonTest, InkDropShowHideOnMouseDraggedNotifyOnPress) {
gfx::Point center(10, 10);
gfx::Point oob(-1, -1);
- TestInkDrop* ink_drop = new TestInkDrop();
- CreateButtonWithInkDrop(base::WrapUnique(ink_drop), true);
+ TestInkDrop* ink_drop = CreateButtonWithInkDrop(true);
button()->button_controller()->set_notify_action(
ButtonController::NotifyAction::kOnPress);
@@ -708,8 +725,7 @@ TEST_F(ButtonTest, InkDropStaysHiddenWhileDragging) {
gfx::Point center(10, 10);
gfx::Point oob(-1, -1);
- TestInkDrop* ink_drop = new TestInkDrop();
- CreateButtonWithInkDrop(base::WrapUnique(ink_drop), false);
+ TestInkDrop* ink_drop = CreateButtonWithInkDrop(false);
button()->OnMousePressed(ui::MouseEvent(
ui::ET_MOUSE_PRESSED, center, center, ui::EventTimeForNow(),
@@ -738,35 +754,51 @@ TEST_F(ButtonTest, InkDropStaysHiddenWhileDragging) {
SetDraggedView(nullptr);
}
+// VisibilityTestButton tests to see if an ink drop or a layer has been added to
+// the button at any point during the visibility state changes of its Widget.
+class VisibilityTestButton : public TestButton {
+ public:
+ VisibilityTestButton() : TestButton(false) {}
+ ~VisibilityTestButton() override {
+ if (layer())
+ ADD_FAILURE();
+ }
+
+ // TestButton:
+ void AddInkDropLayer(ui::Layer* ink_drop_layer) override {
+ ADD_FAILURE();
+ TestButton::AddInkDropLayer(ink_drop_layer);
+ }
+ void RemoveInkDropLayer(ui::Layer* ink_drop_layer) override {
+ ADD_FAILURE();
+ TestButton::RemoveInkDropLayer(ink_drop_layer);
+ }
+};
+
// Test that hiding or closing a Widget doesn't attempt to add a layer due to
// changed visibility states.
TEST_F(ButtonTest, NoLayerAddedForWidgetVisibilityChanges) {
- CreateButtonWithRealInkDrop();
+ VisibilityTestButton* button =
+ AddContentsView(widget(), std::make_unique<VisibilityTestButton>());
- EXPECT_TRUE(button()->GetVisible());
- EXPECT_FALSE(button()->layer());
+ // Ensure no layers are created during construction.
+ EXPECT_TRUE(button->GetVisible());
+ EXPECT_FALSE(button->layer());
+ // Ensure no layers are created when hiding the widget.
widget()->Hide();
- EXPECT_FALSE(button()->layer());
- EXPECT_EQ(0, button()->ink_drop_layer_add_count());
- EXPECT_EQ(0, button()->ink_drop_layer_remove_count());
+ EXPECT_FALSE(button->layer());
+ // Ensure no layers are created when the widget is reshown.
widget()->Show();
- EXPECT_FALSE(button()->layer());
- EXPECT_EQ(0, button()->ink_drop_layer_add_count());
- EXPECT_EQ(0, button()->ink_drop_layer_remove_count());
+ EXPECT_FALSE(button->layer());
- // Allow the button to be interrogated after the view hierarchy is torn down.
- button()->set_owned_by_client();
+ // Ensure no layers are created during the closing of the Widget.
widget()->Close(); // Start an asynchronous close.
- EXPECT_FALSE(button()->layer());
- EXPECT_EQ(0, button()->ink_drop_layer_add_count());
- EXPECT_EQ(0, button()->ink_drop_layer_remove_count());
+ EXPECT_FALSE(button->layer());
+ // Ensure no layers are created following the Widget's destruction.
base::RunLoop().RunUntilIdle(); // Complete the Close().
- EXPECT_FALSE(button()->layer());
- EXPECT_EQ(0, button()->ink_drop_layer_add_count());
- EXPECT_EQ(0, button()->ink_drop_layer_remove_count());
}
// Verify that the Space key clicks the button on key-press on Mac, and
diff --git a/chromium/ui/views/controls/button/checkbox.cc b/chromium/ui/views/controls/button/checkbox.cc
index 8788ff2e07e..06050cc2479 100644
--- a/chromium/ui/views/controls/button/checkbox.cc
+++ b/chromium/ui/views/controls/button/checkbox.cc
@@ -185,7 +185,7 @@ SkPath Checkbox::GetFocusRingPath() const {
SkColor Checkbox::GetIconImageColor(int icon_state) const {
const SkColor active_color = GetNativeTheme()->GetSystemColor(
(icon_state & IconState::CHECKED)
- ? ui::NativeTheme::kColorId_ButtonEnabledColor
+ ? ui::NativeTheme::kColorId_ButtonCheckedColor
: ui::NativeTheme::kColorId_ButtonUncheckedColor);
return (icon_state & IconState::ENABLED)
? active_color
diff --git a/chromium/ui/views/controls/button/image_button_factory.cc b/chromium/ui/views/controls/button/image_button_factory.cc
index 3b492d1e9b5..5ac49262cfe 100644
--- a/chromium/ui/views/controls/button/image_button_factory.cc
+++ b/chromium/ui/views/controls/button/image_button_factory.cc
@@ -5,6 +5,7 @@
#include <memory>
+#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/gfx/vector_icon_types.h"
diff --git a/chromium/ui/views/controls/button/image_button_factory.h b/chromium/ui/views/controls/button/image_button_factory.h
index d09ae6de08a..38d7c70ad52 100644
--- a/chromium/ui/views/controls/button/image_button_factory.h
+++ b/chromium/ui/views/controls/button/image_button_factory.h
@@ -8,7 +8,6 @@
#include <memory>
#include "third_party/skia/include/core/SkColor.h"
-#include "ui/gfx/color_palette.h"
#include "ui/views/views_export.h"
namespace gfx {
@@ -68,14 +67,8 @@ VIEWS_EXPORT void SetImageFromVectorIconWithColor(ImageButton* button,
int dip_size,
SkColor icon_color);
-// As above, but sets the toggled images for a toggled image button.
-VIEWS_EXPORT void SetToggledImageFromVectorIcon(
- ToggleImageButton* button,
- const gfx::VectorIcon& icon,
- int dip_size,
- SkColor related_text_color = gfx::kGoogleGrey900);
-
-// As above, but with a given icon color instead of deriving from a text color.
+// As above, but sets the toggled images for a toggled image button
+// with a given icon color instead of deriving from a text color.
VIEWS_EXPORT void SetToggledImageFromVectorIconWithColor(
ToggleImageButton* button,
const gfx::VectorIcon& icon,
diff --git a/chromium/ui/views/controls/button/label_button_border.cc b/chromium/ui/views/controls/button/label_button_border.cc
index beaac0fba8d..6536bbf8eed 100644
--- a/chromium/ui/views/controls/button/label_button_border.cc
+++ b/chromium/ui/views/controls/button/label_button_border.cc
@@ -6,7 +6,6 @@
#include <utility>
-#include "base/logging.h"
#include "cc/paint/paint_flags.h"
#include "ui/gfx/animation/animation.h"
#include "ui/gfx/canvas.h"
diff --git a/chromium/ui/views/controls/button/md_text_button.cc b/chromium/ui/views/controls/button/md_text_button.cc
index e7ab591a2d3..b9905fc6359 100644
--- a/chromium/ui/views/controls/button/md_text_button.cc
+++ b/chromium/ui/views/controls/button/md_text_button.cc
@@ -31,30 +31,12 @@
namespace views {
// static
-std::unique_ptr<LabelButton> MdTextButton::CreateSecondaryUiButton(
- ButtonListener* listener,
- const base::string16& text) {
- return MdTextButton::Create(listener, text, style::CONTEXT_BUTTON_MD);
-}
-
-// static
-std::unique_ptr<LabelButton> MdTextButton::CreateSecondaryUiBlueButton(
- ButtonListener* listener,
- const base::string16& text) {
- auto md_button =
- MdTextButton::Create(listener, text, style::CONTEXT_BUTTON_MD);
- md_button->SetProminent(true);
- return md_button;
-}
-
-// static
std::unique_ptr<MdTextButton> MdTextButton::Create(ButtonListener* listener,
const base::string16& text,
int button_context) {
auto button = base::WrapUnique<MdTextButton>(
new MdTextButton(listener, button_context));
button->SetText(text);
- button->SetFocusForPlatform();
return button;
}
@@ -172,8 +154,7 @@ PropertyEffects MdTextButton::UpdateStyleToIndicateDefaultStatus() {
}
MdTextButton::MdTextButton(ButtonListener* listener, int button_context)
- : LabelButton(listener, base::string16(), button_context),
- is_prominent_(false) {
+ : LabelButton(listener, base::string16(), button_context) {
SetInkDropMode(InkDropMode::ON);
set_has_ink_drop_action_on_click(true);
set_show_ink_drop_when_hot_tracked(true);
@@ -259,7 +240,7 @@ void MdTextButton::UpdateColors() {
ui::NativeTheme* theme = GetNativeTheme();
SkColor bg_color =
- theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground);
+ theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonColor);
if (bg_color_override_) {
bg_color = *bg_color_override_;
@@ -274,9 +255,7 @@ void MdTextButton::UpdateColors() {
}
if (state() == STATE_PRESSED) {
- SkColor shade =
- theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonPressedShade);
- bg_color = color_utils::GetResultingPaintColor(shade, bg_color);
+ bg_color = theme->GetSystemButtonPressedColor(bg_color);
}
SkColor stroke_color;
diff --git a/chromium/ui/views/controls/button/md_text_button.h b/chromium/ui/views/controls/button/md_text_button.h
index fcd66fcd425..760ab2a80ae 100644
--- a/chromium/ui/views/controls/button/md_text_button.h
+++ b/chromium/ui/views/controls/button/md_text_button.h
@@ -19,14 +19,6 @@ class VIEWS_EXPORT MdTextButton : public LabelButton {
public:
METADATA_HEADER(MdTextButton);
- // As above, but only creates an MdTextButton if MD is enabled in the
- // secondary UI (as opposed to just "top chrome"/"primary" UI).
- static std::unique_ptr<LabelButton> CreateSecondaryUiButton(
- ButtonListener* listener,
- const base::string16& text);
- static std::unique_ptr<LabelButton> CreateSecondaryUiBlueButton(
- ButtonListener* listener,
- const base::string16& text);
static std::unique_ptr<MdTextButton> Create(
ButtonListener* listener,
const base::string16& text,
@@ -69,12 +61,12 @@ class VIEWS_EXPORT MdTextButton : public LabelButton {
void UpdateColors();
// True if this button uses prominent styling (blue fill, etc.).
- bool is_prominent_;
+ bool is_prominent_ = false;
// When set, this provides the background color.
base::Optional<SkColor> bg_color_override_;
- float corner_radius_;
+ float corner_radius_ = 0.0f;
DISALLOW_COPY_AND_ASSIGN(MdTextButton);
};
diff --git a/chromium/ui/views/controls/button/radio_button.cc b/chromium/ui/views/controls/button/radio_button.cc
index e9d8c1df6ac..7c894909eb1 100644
--- a/chromium/ui/views/controls/button/radio_button.cc
+++ b/chromium/ui/views/controls/button/radio_button.cc
@@ -4,7 +4,7 @@
#include "ui/views/controls/button/radio_button.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/resource/resource_bundle.h"
diff --git a/chromium/ui/views/controls/button/toggle_button.cc b/chromium/ui/views/controls/button/toggle_button.cc
index cc6aa145aec..bf88433d005 100644
--- a/chromium/ui/views/controls/button/toggle_button.cc
+++ b/chromium/ui/views/controls/button/toggle_button.cc
@@ -96,7 +96,7 @@ class ToggleButton::ThumbView : public InkDropHostView {
const SkColor thumb_on_color = thumb_on_color_.value_or(
theme->GetSystemColor(ui::NativeTheme::kColorId_ProminentButtonColor));
const SkColor thumb_off_color = thumb_off_color_.value_or(
- theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground));
+ theme->GetSystemColor(ui::NativeTheme::kColorId_ButtonColor));
thumb_flags.setColor(
color_utils::AlphaBlend(thumb_on_color, thumb_off_color, color_ratio_));
diff --git a/chromium/ui/views/controls/combobox/combobox.cc b/chromium/ui/views/controls/combobox/combobox.cc
index 1137efc406d..b0364bcdb3e 100644
--- a/chromium/ui/views/controls/combobox/combobox.cc
+++ b/chromium/ui/views/controls/combobox/combobox.cc
@@ -9,12 +9,13 @@
#include <utility>
#include "base/bind.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "build/build_config.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/ime/input_method.h"
+#include "ui/base/models/image_model.h"
#include "ui/base/models/menu_model.h"
#include "ui/events/event.h"
#include "ui/gfx/canvas.h"
@@ -176,7 +177,9 @@ class Combobox::ComboboxMenuModel : public ui::MenuModel {
int GetGroupIdAt(int index) const override { return -1; }
- bool GetIconAt(int index, gfx::Image* icon) const override { return false; }
+ ui::ImageModel GetIconAt(int index) const override {
+ return ui::ImageModel();
+ }
ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const override {
return nullptr;
diff --git a/chromium/ui/views/controls/editable_combobox/editable_combobox.cc b/chromium/ui/views/controls/editable_combobox/editable_combobox.cc
index 8a0fef03ad6..5f76ed0db20 100644
--- a/chromium/ui/views/controls/editable_combobox/editable_combobox.cc
+++ b/chromium/ui/views/controls/editable_combobox/editable_combobox.cc
@@ -9,8 +9,8 @@
#include <vector>
#include "base/bind.h"
+#include "base/check_op.h"
#include "base/i18n/rtl.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/strings/string16.h"
#include "build/build_config.h"
@@ -226,7 +226,9 @@ class EditableCombobox::EditableComboboxMenuModel
int GetGroupIdAt(int index) const override { return -1; }
- bool GetIconAt(int index, gfx::Image* icon) const override { return false; }
+ ui::ImageModel GetIconAt(int index) const override {
+ return ui::ImageModel();
+ }
ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const override {
return nullptr;
@@ -425,6 +427,14 @@ void EditableCombobox::RequestFocus() {
textfield_->RequestFocus();
}
+bool EditableCombobox::GetNeedsNotificationWhenVisibleBoundsChange() const {
+ return true;
+}
+
+void EditableCombobox::OnVisibleBoundsChanged() {
+ CloseMenu();
+}
+
////////////////////////////////////////////////////////////////////////////////
// EditableCombobox, TextfieldController overrides:
diff --git a/chromium/ui/views/controls/editable_combobox/editable_combobox.h b/chromium/ui/views/controls/editable_combobox/editable_combobox.h
index 7228d52463a..c0f6b26fad8 100644
--- a/chromium/ui/views/controls/editable_combobox/editable_combobox.h
+++ b/chromium/ui/views/controls/editable_combobox/editable_combobox.h
@@ -124,6 +124,8 @@ class VIEWS_EXPORT EditableCombobox : public View,
void OnThemeChanged() override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
void RequestFocus() override;
+ bool GetNeedsNotificationWhenVisibleBoundsChange() const override;
+ void OnVisibleBoundsChanged() override;
// Overridden from TextfieldController:
void ContentsChanged(Textfield* sender,
diff --git a/chromium/ui/views/controls/highlight_path_generator.cc b/chromium/ui/views/controls/highlight_path_generator.cc
index 206f850c916..01920dd775d 100644
--- a/chromium/ui/views/controls/highlight_path_generator.cc
+++ b/chromium/ui/views/controls/highlight_path_generator.cc
@@ -7,18 +7,13 @@
#include <algorithm>
#include "third_party/skia/include/core/SkRect.h"
+#include "ui/gfx/rrect_f.h"
#include "ui/gfx/skia_util.h"
#include "ui/views/view.h"
#include "ui/views/view_class_properties.h"
namespace views {
-HighlightPathGenerator::RoundRect::RoundRect() = default;
-
-HighlightPathGenerator::RoundRect::RoundRect(const gfx::RectF& bounds,
- float corner_radius)
- : bounds(bounds), corner_radius(corner_radius) {}
-
HighlightPathGenerator::HighlightPathGenerator()
: HighlightPathGenerator(gfx::Insets()) {}
@@ -35,8 +30,8 @@ void HighlightPathGenerator::Install(
}
// static
-base::Optional<HighlightPathGenerator::RoundRect>
-HighlightPathGenerator::GetRoundRectForView(const View* view) {
+base::Optional<gfx::RRectF> HighlightPathGenerator::GetRoundRectForView(
+ const View* view) {
HighlightPathGenerator* path_generator =
view->GetProperty(kHighlightPathGeneratorKey);
return path_generator ? path_generator->GetRoundRect(view) : base::nullopt;
@@ -44,28 +39,26 @@ HighlightPathGenerator::GetRoundRectForView(const View* view) {
SkPath HighlightPathGenerator::GetHighlightPath(const View* view) {
// A rounded rectangle must be supplied if using this default implementation.
- base::Optional<HighlightPathGenerator::RoundRect> round_rect =
- GetRoundRect(view);
+ base::Optional<gfx::RRectF> round_rect = GetRoundRect(view);
DCHECK(round_rect);
- return SkPath().addRRect(
- SkRRect{gfx::RRectF(round_rect->bounds, round_rect->corner_radius)});
+ return SkPath().addRRect(SkRRect{*round_rect});
}
-base::Optional<HighlightPathGenerator::RoundRect>
-HighlightPathGenerator::GetRoundRect(const gfx::RectF& rect) {
+base::Optional<gfx::RRectF> HighlightPathGenerator::GetRoundRect(
+ const gfx::RectF& rect) {
return base::nullopt;
}
-base::Optional<HighlightPathGenerator::RoundRect>
-HighlightPathGenerator::GetRoundRect(const View* view) {
+base::Optional<gfx::RRectF> HighlightPathGenerator::GetRoundRect(
+ const View* view) {
gfx::Rect bounds(view->GetLocalBounds());
bounds.Inset(insets_);
return GetRoundRect(gfx::RectF(bounds));
}
-base::Optional<HighlightPathGenerator::RoundRect>
-EmptyHighlightPathGenerator::GetRoundRect(const gfx::RectF& rect) {
- return HighlightPathGenerator::RoundRect();
+base::Optional<gfx::RRectF> EmptyHighlightPathGenerator::GetRoundRect(
+ const gfx::RectF& rect) {
+ return gfx::RRectF();
}
void InstallEmptyHighlightPathGenerator(View* view) {
@@ -73,9 +66,9 @@ void InstallEmptyHighlightPathGenerator(View* view) {
view, std::make_unique<EmptyHighlightPathGenerator>());
}
-base::Optional<HighlightPathGenerator::RoundRect>
-RectHighlightPathGenerator::GetRoundRect(const gfx::RectF& rect) {
- return HighlightPathGenerator::RoundRect{rect, /*corner_radius=*/0};
+base::Optional<gfx::RRectF> RectHighlightPathGenerator::GetRoundRect(
+ const gfx::RectF& rect) {
+ return gfx::RRectF(rect);
}
void InstallRectHighlightPathGenerator(View* view) {
@@ -87,13 +80,13 @@ CircleHighlightPathGenerator::CircleHighlightPathGenerator(
const gfx::Insets& insets)
: HighlightPathGenerator(insets) {}
-base::Optional<HighlightPathGenerator::RoundRect>
-CircleHighlightPathGenerator::GetRoundRect(const gfx::RectF& rect) {
+base::Optional<gfx::RRectF> CircleHighlightPathGenerator::GetRoundRect(
+ const gfx::RectF& rect) {
gfx::RectF bounds = rect;
const float corner_radius = std::min(bounds.width(), bounds.height()) / 2.f;
bounds.ClampToCenteredSize(
gfx::SizeF(corner_radius * 2.f, corner_radius * 2.f));
- return HighlightPathGenerator::RoundRect{bounds, corner_radius};
+ return gfx::RRectF(bounds, corner_radius);
}
void InstallCircleHighlightPathGenerator(View* view) {
@@ -124,11 +117,11 @@ FixedSizeCircleHighlightPathGenerator::FixedSizeCircleHighlightPathGenerator(
int radius)
: radius_(radius) {}
-base::Optional<HighlightPathGenerator::RoundRect>
-FixedSizeCircleHighlightPathGenerator::GetRoundRect(const gfx::RectF& rect) {
+base::Optional<gfx::RRectF> FixedSizeCircleHighlightPathGenerator::GetRoundRect(
+ const gfx::RectF& rect) {
gfx::RectF bounds = rect;
bounds.ClampToCenteredSize(gfx::SizeF(radius_ * 2, radius_ * 2));
- return HighlightPathGenerator::RoundRect{bounds, radius_};
+ return gfx::RRectF(bounds, radius_);
}
void InstallFixedSizeCircleHighlightPathGenerator(View* view, int radius) {
@@ -141,9 +134,9 @@ RoundRectHighlightPathGenerator::RoundRectHighlightPathGenerator(
int corner_radius)
: HighlightPathGenerator(insets), corner_radius_(corner_radius) {}
-base::Optional<HighlightPathGenerator::RoundRect>
-RoundRectHighlightPathGenerator::GetRoundRect(const gfx::RectF& rect) {
- return HighlightPathGenerator::RoundRect{rect, corner_radius_};
+base::Optional<gfx::RRectF> RoundRectHighlightPathGenerator::GetRoundRect(
+ const gfx::RectF& rect) {
+ return gfx::RRectF(rect, corner_radius_);
}
void InstallRoundRectHighlightPathGenerator(View* view,
diff --git a/chromium/ui/views/controls/highlight_path_generator.h b/chromium/ui/views/controls/highlight_path_generator.h
index 427c5271402..e64d0d48b1b 100644
--- a/chromium/ui/views/controls/highlight_path_generator.h
+++ b/chromium/ui/views/controls/highlight_path_generator.h
@@ -11,9 +11,12 @@
#include "third_party/skia/include/core/SkPath.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/rect_f.h"
-#include "ui/gfx/geometry/rounded_corners_f.h"
#include "ui/views/views_export.h"
+namespace gfx {
+class RRectF;
+}
+
namespace views {
class View;
@@ -23,17 +26,6 @@ class View;
// effects.
class VIEWS_EXPORT HighlightPathGenerator {
public:
- struct VIEWS_EXPORT RoundRect {
- // TODO(http://crbug.com/1056490): Remove these constructors and have
- // callsites create a gfx::RoundedCornersF explicitly, or replace this
- // struct with a gfx::RRectF.
- RoundRect();
- RoundRect(const gfx::RectF& bounds, float corner_radius);
-
- gfx::RectF bounds;
- gfx::RoundedCornersF corner_radius;
- };
-
// TODO(http://crbug.com/1056490): Remove this constructor in favor of the one
// that takes |insets|.
HighlightPathGenerator();
@@ -45,18 +37,18 @@ class VIEWS_EXPORT HighlightPathGenerator {
static void Install(View* host,
std::unique_ptr<HighlightPathGenerator> generator);
- static base::Optional<RoundRect> GetRoundRectForView(const View* view);
+ static base::Optional<gfx::RRectF> GetRoundRectForView(const View* view);
// TODO(http://crbug.com/1056490): Deprecate |GetHighlightPath()| in favor of
// |GetRoundRect()|.
virtual SkPath GetHighlightPath(const View* view);
- // Optionally returns a RoundRect struct which contains data for drawing a
+ // Optionally returns a gfx::RRectF which contains data for drawing a
// highlight. Note that |rect| is in the coordinate system of the view.
// TODO(http://crbug.com/1056490): Once |GetHighlightPath()| is deprecated,
// make this a pure virtual function and make the return not optional.
- virtual base::Optional<RoundRect> GetRoundRect(const gfx::RectF& rect);
- base::Optional<RoundRect> GetRoundRect(const View* view);
+ virtual base::Optional<gfx::RRectF> GetRoundRect(const gfx::RectF& rect);
+ base::Optional<gfx::RRectF> GetRoundRect(const View* view);
private:
const gfx::Insets insets_;
@@ -74,7 +66,7 @@ class VIEWS_EXPORT EmptyHighlightPathGenerator : public HighlightPathGenerator {
delete;
// HighlightPathGenerator:
- base::Optional<RoundRect> GetRoundRect(const gfx::RectF& rect) override;
+ base::Optional<gfx::RRectF> GetRoundRect(const gfx::RectF& rect) override;
};
void VIEWS_EXPORT InstallEmptyHighlightPathGenerator(View* view);
@@ -89,7 +81,7 @@ class VIEWS_EXPORT RectHighlightPathGenerator : public HighlightPathGenerator {
delete;
// HighlightPathGenerator:
- base::Optional<RoundRect> GetRoundRect(const gfx::RectF& rect) override;
+ base::Optional<gfx::RRectF> GetRoundRect(const gfx::RectF& rect) override;
};
void VIEWS_EXPORT InstallRectHighlightPathGenerator(View* view);
@@ -105,7 +97,7 @@ class VIEWS_EXPORT CircleHighlightPathGenerator
delete;
// HighlightPathGenerator:
- base::Optional<RoundRect> GetRoundRect(const gfx::RectF& rect) override;
+ base::Optional<gfx::RRectF> GetRoundRect(const gfx::RectF& rect) override;
};
void VIEWS_EXPORT InstallCircleHighlightPathGenerator(View* view);
@@ -143,7 +135,7 @@ class VIEWS_EXPORT FixedSizeCircleHighlightPathGenerator
const FixedSizeCircleHighlightPathGenerator&) = delete;
// HighlightPathGenerator:
- base::Optional<RoundRect> GetRoundRect(const gfx::RectF& rect) override;
+ base::Optional<gfx::RRectF> GetRoundRect(const gfx::RectF& rect) override;
private:
const int radius_;
@@ -164,7 +156,7 @@ class VIEWS_EXPORT RoundRectHighlightPathGenerator
const RoundRectHighlightPathGenerator&) = delete;
// HighlightPathGenerator:
- base::Optional<RoundRect> GetRoundRect(const gfx::RectF& rect) override;
+ base::Optional<gfx::RRectF> GetRoundRect(const gfx::RectF& rect) override;
private:
const int corner_radius_;
diff --git a/chromium/ui/views/controls/image_view.cc b/chromium/ui/views/controls/image_view.cc
index e430b58317f..4ca005dbdc9 100644
--- a/chromium/ui/views/controls/image_view.cc
+++ b/chromium/ui/views/controls/image_view.cc
@@ -6,7 +6,7 @@
#include <utility>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "cc/paint/paint_flags.h"
#include "skia/ext/image_operations.h"
#include "ui/accessibility/ax_enums.mojom.h"
diff --git a/chromium/ui/views/controls/label.cc b/chromium/ui/views/controls/label.cc
index c15c27ae75b..ad6af149e28 100644
--- a/chromium/ui/views/controls/label.cc
+++ b/chromium/ui/views/controls/label.cc
@@ -598,10 +598,6 @@ std::unique_ptr<gfx::RenderText> Label::CreateRenderText() const {
return render_text;
}
-void Label::PaintFocusRing(gfx::Canvas* canvas) const {
- // No focus ring by default.
-}
-
gfx::Rect Label::GetTextBounds() const {
MaybeBuildDisplayText();
@@ -645,8 +641,6 @@ void Label::OnBoundsChanged(const gfx::Rect& previous_bounds) {
void Label::OnPaint(gfx::Canvas* canvas) {
View::OnPaint(canvas);
PaintText(canvas);
- if (HasFocus())
- PaintFocusRing(canvas);
}
void Label::OnThemeChanged() {
@@ -895,9 +889,9 @@ bool Label::IsCommandIdChecked(int command_id) const {
bool Label::IsCommandIdEnabled(int command_id) const {
switch (command_id) {
- case IDS_APP_COPY:
+ case MenuCommands::kCopy:
return HasSelection() && !GetObscured();
- case IDS_APP_SELECT_ALL:
+ case MenuCommands::kSelectAll:
return GetRenderTextForSelectionController() && !GetText().empty();
}
return false;
@@ -905,10 +899,10 @@ bool Label::IsCommandIdEnabled(int command_id) const {
void Label::ExecuteCommand(int command_id, int event_flags) {
switch (command_id) {
- case IDS_APP_COPY:
+ case MenuCommands::kCopy:
CopyToClipboard();
break;
- case IDS_APP_SELECT_ALL:
+ case MenuCommands::kSelectAll:
SelectAll();
DCHECK(HasSelection());
UpdateSelectionClipboard();
@@ -921,11 +915,11 @@ void Label::ExecuteCommand(int command_id, int event_flags) {
bool Label::GetAcceleratorForCommandId(int command_id,
ui::Accelerator* accelerator) const {
switch (command_id) {
- case IDS_APP_COPY:
+ case MenuCommands::kCopy:
*accelerator = ui::Accelerator(ui::VKEY_C, ui::EF_CONTROL_DOWN);
return true;
- case IDS_APP_SELECT_ALL:
+ case MenuCommands::kSelectAll:
*accelerator = ui::Accelerator(ui::VKEY_A, ui::EF_CONTROL_DOWN);
return true;
@@ -1101,8 +1095,8 @@ void Label::CopyToClipboard() {
}
void Label::BuildContextMenuContents() {
- context_menu_contents_.AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY);
- context_menu_contents_.AddItemWithStringId(IDS_APP_SELECT_ALL,
+ context_menu_contents_.AddItemWithStringId(MenuCommands::kCopy, IDS_APP_COPY);
+ context_menu_contents_.AddItemWithStringId(MenuCommands::kSelectAll,
IDS_APP_SELECT_ALL);
}
diff --git a/chromium/ui/views/controls/label.h b/chromium/ui/views/controls/label.h
index 4cb533caa9c..dc690b22dc2 100644
--- a/chromium/ui/views/controls/label.h
+++ b/chromium/ui/views/controls/label.h
@@ -35,6 +35,12 @@ class VIEWS_EXPORT Label : public View,
public:
METADATA_HEADER(Label);
+ enum MenuCommands {
+ kCopy = 1,
+ kSelectAll,
+ kLastCommandId = kSelectAll,
+ };
+
// Helper to construct a Label that doesn't use the views typography spec.
// Using this causes Label to obtain colors from ui::NativeTheme and line
// spacing from gfx::FontList::GetHeight().
@@ -261,9 +267,6 @@ class VIEWS_EXPORT Label : public View,
// Create a single RenderText instance to actually be painted.
virtual std::unique_ptr<gfx::RenderText> CreateRenderText() const;
- // Draw a focus ring. The default implementation does nothing.
- virtual void PaintFocusRing(gfx::Canvas* canvas) const;
-
// Returns the preferred size and position of the text in local coordinates,
// which may exceed the local bounds of the label.
gfx::Rect GetTextBounds() const;
diff --git a/chromium/ui/views/controls/label_unittest.cc b/chromium/ui/views/controls/label_unittest.cc
index d3f01a185fe..763a169b27e 100644
--- a/chromium/ui/views/controls/label_unittest.cc
+++ b/chromium/ui/views/controls/label_unittest.cc
@@ -1384,38 +1384,38 @@ TEST_F(LabelSelectionTest, ContextMenuContents) {
label()->SetText(ASCIIToUTF16("Label context menu"));
label()->SizeToPreferredSize();
- // A non-selectable label would not show a context menu and both COPY and
- // SELECT_ALL context menu items should be disabled for it.
- EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_COPY));
- EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_SELECT_ALL));
+ // A non-selectable label should not show a context menu and both copy and
+ // select-all context menu items should be disabled for it.
+ EXPECT_FALSE(IsMenuCommandEnabled(Label::MenuCommands::kCopy));
+ EXPECT_FALSE(IsMenuCommandEnabled(Label::MenuCommands::kSelectAll));
- // For a selectable label with no selection, only SELECT_ALL should be
+ // For a selectable label with no selection, only kSelectAll should be
// enabled.
ASSERT_TRUE(label()->SetSelectable(true));
- EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_COPY));
- EXPECT_TRUE(IsMenuCommandEnabled(IDS_APP_SELECT_ALL));
+ EXPECT_FALSE(IsMenuCommandEnabled(Label::MenuCommands::kCopy));
+ EXPECT_TRUE(IsMenuCommandEnabled(Label::MenuCommands::kSelectAll));
- // For a selectable label with a selection, both COPY and SELECT_ALL should be
- // enabled.
+ // For a selectable label with a selection, both copy and select-all should
+ // be enabled.
label()->SelectRange(gfx::Range(0, 4));
- EXPECT_TRUE(IsMenuCommandEnabled(IDS_APP_COPY));
- EXPECT_TRUE(IsMenuCommandEnabled(IDS_APP_SELECT_ALL));
- // Ensure unsupported commands like PASTE are not enabled.
- EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_PASTE));
+ EXPECT_TRUE(IsMenuCommandEnabled(Label::MenuCommands::kCopy));
+ EXPECT_TRUE(IsMenuCommandEnabled(Label::MenuCommands::kSelectAll));
+ // Ensure unsupported commands are not enabled.
+ EXPECT_FALSE(IsMenuCommandEnabled(Label::MenuCommands::kLastCommandId + 1));
- // An obscured label would not show a context menu and both COPY and
- // SELECT_ALL should be disabled for it.
+ // An obscured label would not show a context menu and both copy and
+ // select-all should be disabled for it.
label()->SetObscured(true);
EXPECT_FALSE(label()->GetSelectable());
- EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_COPY));
- EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_SELECT_ALL));
+ EXPECT_FALSE(IsMenuCommandEnabled(Label::MenuCommands::kCopy));
+ EXPECT_FALSE(IsMenuCommandEnabled(Label::MenuCommands::kSelectAll));
label()->SetObscured(false);
- // For an empty label, both COPY and SELECT_ALL should be disabled.
+ // For an empty label, both copy and select-all should be disabled.
label()->SetText(base::string16());
ASSERT_TRUE(label()->SetSelectable(true));
- EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_COPY));
- EXPECT_FALSE(IsMenuCommandEnabled(IDS_APP_SELECT_ALL));
+ EXPECT_FALSE(IsMenuCommandEnabled(Label::MenuCommands::kCopy));
+ EXPECT_FALSE(IsMenuCommandEnabled(Label::MenuCommands::kSelectAll));
}
} // namespace views
diff --git a/chromium/ui/views/controls/link.cc b/chromium/ui/views/controls/link.cc
index 5c292fc21de..29348fd8a9d 100644
--- a/chromium/ui/views/controls/link.cc
+++ b/chromium/ui/views/controls/link.cc
@@ -6,7 +6,7 @@
#include "build/build_config.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
@@ -22,9 +22,6 @@
namespace views {
-// static
-constexpr gfx::Insets Link::kFocusBorderPadding;
-
Link::Link(const base::string16& title, int text_context, int text_style)
: Label(title, text_context, text_style) {
RecalculateFont();
@@ -39,12 +36,6 @@ Link::Link(const base::string16& title, int text_context, int text_style)
Link::~Link() = default;
-Link::FocusStyle Link::GetFocusStyle() const {
- // Use an underline to indicate focus unless the link is always drawn with an
- // underline.
- return underline_ ? FocusStyle::kRing : FocusStyle::kUnderline;
-}
-
SkColor Link::GetColor() const {
// TODO(tapted): Use style::GetColor().
const ui::NativeTheme* theme = GetNativeTheme();
@@ -60,25 +51,6 @@ SkColor Link::GetColor() const {
: ui::NativeTheme::kColorId_LinkEnabled);
}
-void Link::PaintFocusRing(gfx::Canvas* canvas) const {
- if (GetFocusStyle() == FocusStyle::kRing) {
- gfx::Rect focus_ring_bounds = GetTextBounds();
- focus_ring_bounds.Inset(-kFocusBorderPadding);
- focus_ring_bounds.Intersect(GetLocalBounds());
- canvas->DrawFocusRect(focus_ring_bounds);
- }
-}
-
-gfx::Insets Link::GetInsets() const {
- gfx::Insets insets = Label::GetInsets();
- if (GetFocusStyle() == FocusStyle::kRing &&
- GetFocusBehavior() != FocusBehavior::NEVER) {
- DCHECK(!GetText().empty());
- insets += kFocusBorderPadding;
- }
- return insets;
-}
-
gfx::NativeCursor Link::GetCursor(const ui::MouseEvent& event) {
if (!GetEnabled())
return gfx::kNullCursor;
@@ -214,18 +186,6 @@ bool Link::IsSelectionSupported() const {
return false;
}
-bool Link::GetUnderline() const {
- return underline_;
-}
-
-void Link::SetUnderline(bool underline) {
- if (underline_ == underline)
- return;
- underline_ = underline;
- RecalculateFont();
- OnPropertyChanged(&underline_, kPropertyEffectsPreferredSizeChanged);
-}
-
void Link::SetPressed(bool pressed) {
if (pressed_ != pressed) {
pressed_ = pressed;
@@ -236,12 +196,8 @@ void Link::SetPressed(bool pressed) {
}
void Link::RecalculateFont() {
- // Underline the link if it is enabled and |underline_| is true. Also
- // underline to indicate focus when that's the style.
const int style = font_list().GetFontStyle();
- const bool underline =
- underline_ || (HasFocus() && GetFocusStyle() == FocusStyle::kUnderline);
- const int intended_style = (GetEnabled() && underline)
+ const int intended_style = (GetEnabled() && HasFocus())
? (style | gfx::Font::UNDERLINE)
: (style & ~gfx::Font::UNDERLINE);
@@ -262,15 +218,9 @@ void Link::ConfigureFocus() {
}
}
-DEFINE_ENUM_CONVERTERS(Link::FocusStyle,
- {Link::FocusStyle::kUnderline,
- base::ASCIIToUTF16("UNDERLINE")},
- {Link::FocusStyle::kRing, base::ASCIIToUTF16("RING")})
BEGIN_METADATA(Link)
METADATA_PARENT_CLASS(Label)
ADD_READONLY_PROPERTY_METADATA(Link, SkColor, Color)
-ADD_READONLY_PROPERTY_METADATA(Link, Link::FocusStyle, FocusStyle)
-ADD_PROPERTY_METADATA(Link, bool, Underline)
END_METADATA()
} // namespace views
diff --git a/chromium/ui/views/controls/link.h b/chromium/ui/views/controls/link.h
index 684e05d7747..51b5a2341a5 100644
--- a/chromium/ui/views/controls/link.h
+++ b/chromium/ui/views/controls/link.h
@@ -35,24 +35,11 @@ class VIEWS_EXPORT Link : public Label {
using ClickedCallback =
base::RepeatingCallback<void(Link* source, int event_flags)>;
- // The padding for the focus ring border when rendering a focused Link with
- // FocusStyle::kRing.
- static constexpr gfx::Insets kFocusBorderPadding = gfx::Insets(1);
-
- // How the Link is styled when focused.
- enum class FocusStyle {
- kUnderline, // An underline style is added to the text only when focused.
- kRing, // A focus ring is drawn around the View.
- };
-
explicit Link(const base::string16& title,
int text_context = style::CONTEXT_LABEL,
int text_style = style::STYLE_LINK);
~Link() override;
- // Returns the current FocusStyle of this Link.
- FocusStyle GetFocusStyle() const;
-
// Allow providing callbacks that expect either zero or two args, since many
// callers don't care about the arguments and can avoid adapter functions this
// way.
@@ -69,8 +56,6 @@ class VIEWS_EXPORT Link : public Label {
SkColor GetColor() const;
// Label:
- void PaintFocusRing(gfx::Canvas* canvas) const override;
- gfx::Insets GetInsets() const override;
gfx::NativeCursor GetCursor(const ui::MouseEvent& event) override;
bool CanProcessEventsWithinSubtree() const override;
bool OnMousePressed(const ui::MouseEvent& event) override;
@@ -89,13 +74,6 @@ class VIEWS_EXPORT Link : public Label {
void SetEnabledColor(SkColor color) override;
bool IsSelectionSupported() const override;
- bool GetUnderline() const;
- // TODO(estade): almost all the places that call this pass false. With
- // Harmony, false is already the default so those callsites can be removed.
- // TODO(tapted): Then remove all callsites when client code sets a correct
- // typography style and derives this from style::GetFont(STYLE_LINK).
- void SetUnderline(bool underline);
-
private:
void SetPressed(bool pressed);
@@ -105,9 +83,6 @@ class VIEWS_EXPORT Link : public Label {
ClickedCallback callback_;
- // Whether the link should be underlined when enabled.
- bool underline_ = false;
-
// Whether the link is currently pressed.
bool pressed_ = false;
diff --git a/chromium/ui/views/controls/menu/menu_closure_animation_mac.mm b/chromium/ui/views/controls/menu/menu_closure_animation_mac.mm
index eaee6349d8e..f74acc5d65d 100644
--- a/chromium/ui/views/controls/menu/menu_closure_animation_mac.mm
+++ b/chromium/ui/views/controls/menu/menu_closure_animation_mac.mm
@@ -7,7 +7,8 @@
#import <Cocoa/Cocoa.h>
#include "base/bind.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ui/gfx/animation/linear_animation.h"
#include "ui/views/controls/menu/menu_item_view.h"
diff --git a/chromium/ui/views/controls/menu/menu_config.h b/chromium/ui/views/controls/menu/menu_config.h
index 9d0e8aafc84..c84d1377c94 100644
--- a/chromium/ui/views/controls/menu/menu_config.h
+++ b/chromium/ui/views/controls/menu/menu_config.h
@@ -43,9 +43,6 @@ struct VIEWS_EXPORT MenuConfig {
// Font list used by menus.
gfx::FontList font_list;
- // Color for the arrow to scroll bookmarks.
- SkColor arrow_color = SK_ColorBLACK;
-
// Menu border sizes. The vertical border size does not apply to menus with
// rounded corners - those menus always use the corner radius as the vertical
// border size.
diff --git a/chromium/ui/views/controls/menu/menu_config_win.cc b/chromium/ui/views/controls/menu/menu_config_win.cc
index 02ee472e0c4..154e8cf424f 100644
--- a/chromium/ui/views/controls/menu/menu_config_win.cc
+++ b/chromium/ui/views/controls/menu/menu_config_win.cc
@@ -9,7 +9,7 @@
#include <Vssym32.h>
#include <uxtheme.h>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/win/scoped_gdi_object.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/system_fonts_win.h"
@@ -20,7 +20,6 @@ using ui::NativeTheme;
namespace views {
void MenuConfig::Init() {
- arrow_color = color_utils::GetSysSkColor(COLOR_MENUTEXT);
font_list =
gfx::FontList(gfx::win::GetSystemFont(gfx::win::SystemFont::kMenu));
diff --git a/chromium/ui/views/controls/menu/menu_controller.cc b/chromium/ui/views/controls/menu/menu_controller.cc
index d8c09129ad9..d9938916a53 100644
--- a/chromium/ui/views/controls/menu/menu_controller.cc
+++ b/chromium/ui/views/controls/menu/menu_controller.cc
@@ -61,6 +61,10 @@
#include "ui/aura/window.h"
#endif
+#if defined(USE_OZONE)
+#include "ui/ozone/public/ozone_platform.h"
+#endif
+
using base::TimeDelta;
using ui::OSExchangeData;
@@ -100,6 +104,18 @@ bool AcceleratorShouldCancelMenu(const ui::Accelerator& accelerator) {
}
#endif
+bool ShouldIgnoreScreenBoundsForMenus() {
+#if defined(USE_OZONE)
+ // Wayland requires placing menus is screen coordinates. See comment in
+ // ozone_platform_wayland.cc.
+ return ui::OzonePlatform::GetInstance()
+ ->GetPlatformProperties()
+ .ignore_screen_bounds_for_menus;
+#else
+ return false;
+#endif
+}
+
// The amount of time the mouse should be down before a mouse release is
// considered intentional. This is to prevent spurious mouse releases from
// activating controls, especially when some UI element is revealed under the
@@ -776,19 +792,15 @@ void MenuController::OnMouseReleased(SubmenuView* source,
return;
}
}
+ const int command = part.menu->GetCommand();
if (part.menu->GetDelegate()->ShouldExecuteCommandWithoutClosingMenu(
- part.menu->GetCommand(), event)) {
- part.menu->GetDelegate()->ExecuteCommand(part.menu->GetCommand(),
- event.flags());
+ command, event)) {
+ part.menu->GetDelegate()->ExecuteCommand(command, event.flags());
return;
}
if (!part.menu->NonIconChildViewsCount() &&
part.menu->GetDelegate()->IsTriggerableEvent(part.menu, event)) {
- base::TimeDelta shown_time = base::TimeTicks::Now() - menu_start_time_;
- if (!state_.context_menu || !View::ShouldShowContextMenuOnMousePress() ||
- shown_time > menu_selection_hold_time) {
- Accept(part.menu, event.flags());
- }
+ Accept(part.menu, event.flags());
return;
}
} else if (part.type == MenuPart::MENU_ITEM) {
@@ -2226,7 +2238,7 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
menu_bounds.set_x(create_on_right ? right_of_parent : left_of_parent);
// Everything after this check requires monitor bounds to be non-empty.
- if (monitor_bounds.IsEmpty())
+ if (ShouldIgnoreScreenBoundsForMenus() || monitor_bounds.IsEmpty())
return menu_bounds;
// Menu does not actually fit where it was placed, move it to the other side
@@ -2258,7 +2270,8 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
anchor_bounds.x() + (anchor_bounds.width() - menu_bounds.width()) / 2;
menu_bounds.set_x(horizontally_centered);
menu_bounds.set_y(above_anchor - kTouchYPadding);
- if (menu_bounds.y() < monitor_bounds.y())
+ if (!ShouldIgnoreScreenBoundsForMenus() &&
+ menu_bounds.y() < monitor_bounds.y())
menu_bounds.set_y(anchor_bounds.y() + kTouchYPadding);
}
@@ -2268,7 +2281,7 @@ gfx::Rect MenuController::CalculateMenuBounds(MenuItemView* item,
}
// Everything beyond this point requires monitor bounds to be non-empty.
- if (monitor_bounds.IsEmpty())
+ if (ShouldIgnoreScreenBoundsForMenus() || monitor_bounds.IsEmpty())
return menu_bounds;
// If the menu position is below or above the anchor bounds, force it to fit
diff --git a/chromium/ui/views/controls/menu/menu_controller_unittest.cc b/chromium/ui/views/controls/menu/menu_controller_unittest.cc
index 14d45fb9dcf..3176d01e445 100644
--- a/chromium/ui/views/controls/menu/menu_controller_unittest.cc
+++ b/chromium/ui/views/controls/menu/menu_controller_unittest.cc
@@ -6,7 +6,6 @@
#include "base/bind.h"
#include "base/callback.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/message_loop/message_loop_current.h"
#include "base/single_thread_task_runner.h"
@@ -51,18 +50,34 @@
#if defined(USE_X11)
#include "ui/events/test/events_test_utils_x11.h"
-#include "ui/gfx/x/x11.h"
+#include "ui/gfx/x/x11.h" // nogncheck
#endif
#if defined(OS_CHROMEOS)
#include "ui/base/ui_base_features.h"
#endif
+#if defined(USE_OZONE)
+#include "ui/ozone/public/ozone_platform.h"
+#endif
+
namespace views {
namespace test {
namespace {
+bool ShouldIgnoreScreenBoundsForMenus() {
+#if defined(USE_OZONE)
+ // Wayland requires placing menus is screen coordinates. See comment in
+ // ozone_platform_wayland.cc.
+ return ui::OzonePlatform::GetInstance()
+ ->GetPlatformProperties()
+ .ignore_screen_bounds_for_menus;
+#else
+ return false;
+#endif
+}
+
// Test implementation of MenuControllerDelegate that only reports the values
// called of OnMenuClosed.
class TestMenuControllerDelegate : public internal::MenuControllerDelegate {
@@ -1518,7 +1533,7 @@ TEST_F(MenuControllerTest, NoTouchCloseWhenSendingGesturesToOwner) {
location.Offset(1, 1);
ui::TouchEvent touch_event(
ui::ET_TOUCH_PRESSED, location, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
controller->OnTouchEvent(sub_menu, &touch_event);
// Menu should still be visible.
@@ -1592,9 +1607,8 @@ TEST_F(MenuControllerTest, AsynchronousTouchEventRepostEvent) {
sub_menu->ShowAt(owner(), item->bounds(), false);
gfx::Point location(sub_menu->bounds().bottom_right());
location.Offset(1, 1);
- ui::TouchEvent event(
- ui::ET_TOUCH_PRESSED, location, ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
+ ui::TouchEvent event(ui::ET_TOUCH_PRESSED, location, ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 0));
controller->OnTouchEvent(sub_menu, &event);
views::test::WaitForMenuClosureAnimation();
@@ -1712,6 +1726,8 @@ TEST_F(MenuControllerTest, ArrowKeysAtEnds) {
TEST_F(MenuControllerTest, CalculateMenuBoundsBestFitTest) {
MenuBoundsOptions options;
gfx::Rect expected;
+ const bool ignore_screen_bounds_for_menus =
+ ShouldIgnoreScreenBoundsForMenus();
// Fits in all locations -> placed below.
options.anchor_bounds =
@@ -1730,9 +1746,13 @@ TEST_F(MenuControllerTest, CalculateMenuBoundsBestFitTest) {
options.monitor_bounds =
gfx::Rect(0, 0, options.anchor_bounds.right() + options.menu_size.width(),
options.anchor_bounds.bottom());
- expected = gfx::Rect(options.anchor_bounds.x(),
- options.anchor_bounds.y() - options.menu_size.height(),
- options.menu_size.width(), options.menu_size.height());
+ if (ignore_screen_bounds_for_menus) {
+ expected = gfx::Rect(options.anchor_bounds.origin(), options.menu_size);
+ } else {
+ expected = gfx::Rect(options.anchor_bounds.x(),
+ options.anchor_bounds.y() - options.menu_size.height(),
+ options.menu_size.width(), options.menu_size.height());
+ }
EXPECT_EQ(expected, CalculateMenuBounds(options));
// Fits on both sides, prefer right -> placed right.
@@ -1741,10 +1761,15 @@ TEST_F(MenuControllerTest, CalculateMenuBoundsBestFitTest) {
options.monitor_bounds =
gfx::Rect(0, 0, options.anchor_bounds.right() + options.menu_size.width(),
options.menu_size.height());
- expected =
- gfx::Rect(options.anchor_bounds.right(),
- options.monitor_bounds.bottom() - options.menu_size.height(),
- options.menu_size.width(), options.menu_size.height());
+ if (ignore_screen_bounds_for_menus) {
+ expected = gfx::Rect(options.anchor_bounds.origin(), options.menu_size);
+ } else {
+ expected =
+ gfx::Rect(options.anchor_bounds.right(),
+ options.monitor_bounds.bottom() - options.menu_size.height(),
+ options.menu_size.width(), options.menu_size.height());
+ }
+
EXPECT_EQ(expected, CalculateMenuBounds(options));
// Fits only on left -> placed left.
@@ -1752,10 +1777,14 @@ TEST_F(MenuControllerTest, CalculateMenuBoundsBestFitTest) {
options.menu_size.height() / 2, 0, 0);
options.monitor_bounds = gfx::Rect(0, 0, options.anchor_bounds.right(),
options.menu_size.height());
- expected =
- gfx::Rect(options.anchor_bounds.x() - options.menu_size.width(),
- options.monitor_bounds.bottom() - options.menu_size.height(),
- options.menu_size.width(), options.menu_size.height());
+ if (ignore_screen_bounds_for_menus) {
+ expected = gfx::Rect(options.anchor_bounds.origin(), options.menu_size);
+ } else {
+ expected =
+ gfx::Rect(options.anchor_bounds.x() - options.menu_size.width(),
+ options.monitor_bounds.bottom() - options.menu_size.height(),
+ options.menu_size.width(), options.menu_size.height());
+ }
EXPECT_EQ(expected, CalculateMenuBounds(options));
// Fits on both sides, prefer left -> placed left.
@@ -1765,10 +1794,17 @@ TEST_F(MenuControllerTest, CalculateMenuBoundsBestFitTest) {
options.monitor_bounds =
gfx::Rect(0, 0, options.anchor_bounds.right() + options.menu_size.width(),
options.menu_size.height());
- expected =
- gfx::Rect(options.anchor_bounds.x() - options.menu_size.width(),
- options.monitor_bounds.bottom() - options.menu_size.height(),
- options.menu_size.width(), options.menu_size.height());
+ if (ignore_screen_bounds_for_menus) {
+ expected =
+ gfx::Rect({options.anchor_bounds.right() - options.menu_size.width(),
+ options.anchor_bounds.origin().y()},
+ options.menu_size);
+ } else {
+ expected =
+ gfx::Rect(options.anchor_bounds.x() - options.menu_size.width(),
+ options.monitor_bounds.bottom() - options.menu_size.height(),
+ options.menu_size.width(), options.menu_size.height());
+ }
EXPECT_EQ(expected, CalculateMenuBounds(options));
// Fits only on right -> placed right.
@@ -1776,10 +1812,17 @@ TEST_F(MenuControllerTest, CalculateMenuBoundsBestFitTest) {
options.monitor_bounds =
gfx::Rect(0, 0, options.anchor_bounds.right() + options.menu_size.width(),
options.menu_size.height());
- expected =
- gfx::Rect(options.anchor_bounds.right(),
- options.monitor_bounds.bottom() - options.menu_size.height(),
- options.menu_size.width(), options.menu_size.height());
+ if (ignore_screen_bounds_for_menus) {
+ expected =
+ gfx::Rect({options.anchor_bounds.right() - options.menu_size.width(),
+ options.anchor_bounds.origin().y()},
+ options.menu_size);
+ } else {
+ expected =
+ gfx::Rect(options.anchor_bounds.right(),
+ options.monitor_bounds.bottom() - options.menu_size.height(),
+ options.menu_size.width(), options.menu_size.height());
+ }
EXPECT_EQ(expected, CalculateMenuBounds(options));
}
@@ -1816,11 +1859,20 @@ TEST_F(MenuControllerTest, CalculateMenuBoundsAnchorTest) {
// Menu does not fit above -> placed below.
options.anchor_bounds = gfx::Rect(options.menu_size.height() / 2,
options.menu_size.width(), 0, 0);
- expected = gfx::Rect(
- options.anchor_bounds.x() +
- (options.anchor_bounds.width() - options.menu_size.width()) / 2,
- options.anchor_bounds.y() + kTouchYPadding, options.menu_size.width(),
- options.menu_size.height());
+ if (ShouldIgnoreScreenBoundsForMenus()) {
+ expected = gfx::Rect(
+ options.anchor_bounds.x() +
+ (options.anchor_bounds.width() - options.menu_size.width()) / 2,
+ options.anchor_bounds.y() - options.anchor_bounds.bottom() -
+ kTouchYPadding,
+ options.menu_size.width(), options.menu_size.height());
+ } else {
+ expected = gfx::Rect(
+ options.anchor_bounds.x() +
+ (options.anchor_bounds.width() - options.menu_size.width()) / 2,
+ options.anchor_bounds.y() + kTouchYPadding, options.menu_size.width(),
+ options.menu_size.height());
+ }
EXPECT_EQ(expected, CalculateMenuBounds(options));
}
@@ -1951,6 +2003,11 @@ TEST_P(MenuControllerTest, TestSubmenuFitsOnScreen) {
// squished or move above the anchor when it grows vertically and horizontally
// beyond the monitor bounds.
TEST_F(MenuControllerTest, GrowingMenuMovesLaterallyNotVertically) {
+ // We can't know the position of windows in Wayland. Thus, this case is not
+ // valid for Wayland.
+ if (ShouldIgnoreScreenBoundsForMenus())
+ return;
+
MenuBoundsOptions options;
options.monitor_bounds = gfx::Rect(0, 0, 100, 100);
// The anchor should be near the bottom right side of the screen.
diff --git a/chromium/ui/views/controls/menu/menu_host.cc b/chromium/ui/views/controls/menu/menu_host.cc
index 232a7de1b54..0b9230bda55 100644
--- a/chromium/ui/views/controls/menu/menu_host.cc
+++ b/chromium/ui/views/controls/menu/menu_host.cc
@@ -7,7 +7,8 @@
#include <utility>
#include "base/auto_reset.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "ui/aura/window_observer.h"
diff --git a/chromium/ui/views/controls/menu/menu_host_root_view.cc b/chromium/ui/views/controls/menu/menu_host_root_view.cc
index bbb1290858d..890b56554ef 100644
--- a/chromium/ui/views/controls/menu/menu_host_root_view.cc
+++ b/chromium/ui/views/controls/menu/menu_host_root_view.cc
@@ -94,4 +94,7 @@ MenuController* MenuHostRootView::GetMenuControllerForInputEvents() {
: nullptr;
}
+BEGIN_METADATA(MenuHostRootView)
+METADATA_PARENT_CLASS(RootView)
+END_METADATA()
} // namespace views
diff --git a/chromium/ui/views/controls/menu/menu_host_root_view.h b/chromium/ui/views/controls/menu/menu_host_root_view.h
index e37dd792677..85548317aa2 100644
--- a/chromium/ui/views/controls/menu/menu_host_root_view.h
+++ b/chromium/ui/views/controls/menu/menu_host_root_view.h
@@ -21,6 +21,8 @@ class SubmenuView;
// such that when MenuHostRootView is deleted it doesn't delete the menu items.
class MenuHostRootView : public internal::RootView {
public:
+ METADATA_HEADER(MenuHostRootView);
+
MenuHostRootView(Widget* widget, SubmenuView* submenu);
void ClearSubmenu() { submenu_ = nullptr; }
diff --git a/chromium/ui/views/controls/menu/menu_item_view.cc b/chromium/ui/views/controls/menu/menu_item_view.cc
index 6f45e5ac5d1..d00618f37c3 100644
--- a/chromium/ui/views/controls/menu/menu_item_view.cc
+++ b/chromium/ui/views/controls/menu/menu_item_view.cc
@@ -923,7 +923,7 @@ void MenuItemView::PaintButton(gfx::Canvas* canvas, PaintButtonMode mode) {
const gfx::VectorIcon& radio_icon =
toggled ? kMenuRadioSelectedIcon : kMenuRadioEmptyIcon;
const SkColor radio_icon_color = GetNativeTheme()->GetSystemColor(
- toggled ? ui::NativeTheme::kColorId_ButtonEnabledColor
+ toggled ? ui::NativeTheme::kColorId_ButtonCheckedColor
: ui::NativeTheme::kColorId_ButtonUncheckedColor);
radio_check_image_view_->SetImage(
gfx::CreateVectorIcon(radio_icon, kMenuCheckSize, radio_icon_color));
diff --git a/chromium/ui/views/controls/menu/menu_model_adapter.cc b/chromium/ui/views/controls/menu/menu_model_adapter.cc
index 88a868cf6f9..79af9195b11 100644
--- a/chromium/ui/views/controls/menu/menu_model_adapter.cc
+++ b/chromium/ui/views/controls/menu/menu_model_adapter.cc
@@ -6,7 +6,8 @@
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "ui/base/models/menu_model.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/paint_vector_icon.h"
@@ -104,15 +105,17 @@ MenuItemView* MenuModelAdapter::AddMenuItemFromModelAt(ui::MenuModel* model,
model->GetSeparatorTypeAt(model_index));
}
- gfx::Image icon;
- model->GetIconAt(model_index, &icon);
+ ui::ImageModel icon = model->GetIconAt(model_index);
+ ui::ImageModel minor_icon = model->GetMinorIconAt(model_index);
return menu->AddMenuItemAt(
menu_index, item_id, model->GetLabelAt(model_index),
model->GetMinorTextAt(model_index),
- ui::ThemedVectorIcon(model->GetMinorIconAt(model_index)),
- icon.IsEmpty() ? gfx::ImageSkia() : *icon.ToImageSkia(),
- icon.IsEmpty() ? ui::ThemedVectorIcon(model->GetVectorIconAt(model_index))
- : ui::ThemedVectorIcon(),
+ minor_icon.IsVectorIcon()
+ ? ui::ThemedVectorIcon(minor_icon.GetVectorIcon())
+ : ui::ThemedVectorIcon(),
+ icon.IsImage() ? *icon.GetImage().ToImageSkia() : gfx::ImageSkia(),
+ icon.IsVectorIcon() ? ui::ThemedVectorIcon(icon.GetVectorIcon())
+ : ui::ThemedVectorIcon(),
*type, ui::NORMAL_SEPARATOR);
}
diff --git a/chromium/ui/views/controls/menu/menu_model_adapter_unittest.cc b/chromium/ui/views/controls/menu/menu_model_adapter_unittest.cc
index 7f9bb3bd850..6241a9d7916 100644
--- a/chromium/ui/views/controls/menu/menu_model_adapter_unittest.cc
+++ b/chromium/ui/views/controls/menu/menu_model_adapter_unittest.cc
@@ -66,7 +66,9 @@ class MenuModelBase : public ui::MenuModel {
int GetGroupIdAt(int index) const override { return 0; }
- bool GetIconAt(int index, gfx::Image* icon) const override { return false; }
+ ui::ImageModel GetIconAt(int index) const override {
+ return ui::ImageModel();
+ }
ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const override {
return nullptr;
diff --git a/chromium/ui/views/controls/menu/menu_runner_cocoa_unittest.mm b/chromium/ui/views/controls/menu/menu_runner_cocoa_unittest.mm
index 321308675f6..4f70db3ec4b 100644
--- a/chromium/ui/views/controls/menu/menu_runner_cocoa_unittest.mm
+++ b/chromium/ui/views/controls/menu/menu_runner_cocoa_unittest.mm
@@ -299,7 +299,8 @@ class MenuRunnerCocoaTest : public ViewsTestBase,
DISALLOW_COPY_AND_ASSIGN(MenuRunnerCocoaTest);
};
-TEST_P(MenuRunnerCocoaTest, RunMenuAndCancel) {
+// Crashes frequently, https://crbug.com/1073069
+TEST_P(MenuRunnerCocoaTest, DISABLED_RunMenuAndCancel) {
base::TimeTicks min_time = ui::EventTimeForNow();
RunMenu(base::BindOnce(&MenuRunnerCocoaTest::MenuCancelCallback,
diff --git a/chromium/ui/views/controls/menu/menu_scroll_view_container.cc b/chromium/ui/views/controls/menu/menu_scroll_view_container.cc
index 7a9d15cb206..3ba6950690e 100644
--- a/chromium/ui/views/controls/menu/menu_scroll_view_container.cc
+++ b/chromium/ui/views/controls/menu/menu_scroll_view_container.cc
@@ -22,6 +22,7 @@
#include "ui/views/controls/menu/submenu_view.h"
#include "ui/views/layout/flex_layout.h"
#include "ui/views/round_rect_painter.h"
+#include "ui/views/view.h"
#include "ui/views/view_class_properties.h"
using ui::NativeTheme;
@@ -51,6 +52,12 @@ class MenuScrollButton : public View {
pref_height_);
}
+ void OnThemeChanged() override {
+ View::OnThemeChanged();
+ arrow_color_ = GetNativeTheme()->GetSystemColor(
+ ui::NativeTheme::kColorId_EnabledMenuItemForegroundColor);
+ }
+
bool CanDrop(const OSExchangeData& data) override {
DCHECK(host_->GetMenuItem()->GetMenuController());
return true; // Always return true so that drop events are targeted to us.
@@ -108,7 +115,7 @@ class MenuScrollButton : public View {
cc::PaintFlags flags;
flags.setStyle(cc::PaintFlags::kFill_Style);
flags.setAntiAlias(true);
- flags.setColor(config.arrow_color);
+ flags.setColor(arrow_color_);
canvas->DrawPath(path, flags);
}
@@ -122,6 +129,9 @@ class MenuScrollButton : public View {
// Preferred height.
int pref_height_;
+ // Color for the arrow to scroll.
+ SkColor arrow_color_;
+
DISALLOW_COPY_AND_ASSIGN(MenuScrollButton);
};
diff --git a/chromium/ui/views/controls/menu/menu_scroll_view_container.h b/chromium/ui/views/controls/menu/menu_scroll_view_container.h
index 5f87cfa5a9b..e0dc860b3a2 100644
--- a/chromium/ui/views/controls/menu/menu_scroll_view_container.h
+++ b/chromium/ui/views/controls/menu/menu_scroll_view_container.h
@@ -31,8 +31,6 @@ class MenuScrollViewContainer : public View {
// External function to check if the bubble border is used.
bool HasBubbleBorder() const;
- void SetFootnoteView(View* view);
-
// View overrides.
gfx::Size CalculatePreferredSize() const override;
void OnPaintBackground(gfx::Canvas* canvas) override;
diff --git a/chromium/ui/views/controls/menu/native_menu_win.cc b/chromium/ui/views/controls/menu/native_menu_win.cc
index 54de8fb75e9..042ecddda20 100644
--- a/chromium/ui/views/controls/menu/native_menu_win.cc
+++ b/chromium/ui/views/controls/menu/native_menu_win.cc
@@ -6,7 +6,7 @@
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/strings/string_util.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/l10n/l10n_util.h"
diff --git a/chromium/ui/views/controls/message_box_view.cc b/chromium/ui/views/controls/message_box_view.cc
index 0d522a2ed58..bbdfc07370e 100644
--- a/chromium/ui/views/controls/message_box_view.cc
+++ b/chromium/ui/views/controls/message_box_view.cc
@@ -231,7 +231,7 @@ void MessageBoxView::ResetLayoutManager() {
constexpr int kMessageViewColumnSetId = 0;
ColumnSet* column_set = layout->AddColumnSet(kMessageViewColumnSetId);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::FIXED, message_width_, 0);
+ GridLayout::ColumnSize::kFixed, message_width_, 0);
const LayoutProvider* provider = LayoutProvider::Get();
@@ -242,7 +242,7 @@ void MessageBoxView::ResetLayoutManager() {
column_set = layout->AddColumnSet(kExtraViewColumnSetId);
column_set->AddPaddingColumn(0, horizontal_insets.left());
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddPaddingColumn(0, horizontal_insets.right());
}
diff --git a/chromium/ui/views/controls/native/native_view_host.cc b/chromium/ui/views/controls/native/native_view_host.cc
index b29553ae8f7..4779e4f07d9 100644
--- a/chromium/ui/views/controls/native/native_view_host.cc
+++ b/chromium/ui/views/controls/native/native_view_host.cc
@@ -7,7 +7,7 @@
#include <memory>
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/base/cursor/cursor.h"
#include "ui/gfx/canvas.h"
diff --git a/chromium/ui/views/controls/native/native_view_host_aura.cc b/chromium/ui/views/controls/native/native_view_host_aura.cc
index 26a4b5a55fa..2223f6e3b28 100644
--- a/chromium/ui/views/controls/native/native_view_host_aura.cc
+++ b/chromium/ui/views/controls/native/native_view_host_aura.cc
@@ -7,7 +7,7 @@
#include <memory>
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/optional.h"
#include "build/build_config.h"
#include "ui/aura/client/aura_constants.h"
diff --git a/chromium/ui/views/controls/native/native_view_host_aura_unittest.cc b/chromium/ui/views/controls/native/native_view_host_aura_unittest.cc
index 973caf4a0aa..d1d03765bf3 100644
--- a/chromium/ui/views/controls/native/native_view_host_aura_unittest.cc
+++ b/chromium/ui/views/controls/native/native_view_host_aura_unittest.cc
@@ -15,7 +15,7 @@
#include "ui/aura/window_targeter.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/cursor/cursor.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/events/event_utils.h"
#include "ui/views/controls/native/native_view_host.h"
#include "ui/views/controls/native/native_view_host_test_base.h"
diff --git a/chromium/ui/views/controls/progress_bar.cc b/chromium/ui/views/controls/progress_bar.cc
index 3801b433a4e..45e2f590995 100644
--- a/chromium/ui/views/controls/progress_bar.cc
+++ b/chromium/ui/views/controls/progress_bar.cc
@@ -9,7 +9,8 @@
#include <memory>
#include <string>
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/i18n/number_formatting.h"
#include "base/macros.h"
#include "cc/paint/paint_flags.h"
#include "third_party/skia/include/core/SkPath.h"
@@ -21,6 +22,7 @@
#include "ui/gfx/color_utils.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/metadata/metadata_impl_macros.h"
+#include "ui/views/widget/widget.h"
namespace views {
@@ -42,6 +44,10 @@ void AddPossiblyRoundRectToPath(const gfx::Rect& rectangle,
}
}
+int RoundToPercent(double fractional_value) {
+ return static_cast<int>(fractional_value * 100);
+}
+
} // namespace
ProgressBar::ProgressBar(int preferred_height, bool allow_round_corner)
@@ -54,6 +60,10 @@ ProgressBar::~ProgressBar() = default;
void ProgressBar::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ax::mojom::Role::kProgressIndicator;
+ if (IsIndeterminate())
+ node_data->RemoveStringAttribute(ax::mojom::StringAttribute::kValue);
+ else
+ node_data->SetValue(base::FormatPercent(RoundToPercent(current_value_)));
}
gfx::Size ProgressBar::CalculatePreferredSize() const {
@@ -64,6 +74,14 @@ gfx::Size ProgressBar::CalculatePreferredSize() const {
return pref_size;
}
+void ProgressBar::VisibilityChanged(View* starting_from, bool is_visible) {
+ MaybeNotifyAccessibilityValueChanged();
+}
+
+void ProgressBar::AddedToWidget() {
+ MaybeNotifyAccessibilityValueChanged();
+}
+
void ProgressBar::OnPaint(gfx::Canvas* canvas) {
if (IsIndeterminate())
return OnPaintIndeterminate(canvas);
@@ -117,6 +135,8 @@ void ProgressBar::SetValue(double value) {
indeterminate_bar_animation_.reset();
OnPropertyChanged(&current_value_, kPropertyEffectsPaint);
}
+
+ MaybeNotifyAccessibilityValueChanged();
}
SkColor ProgressBar::GetForegroundColor() const {
@@ -227,6 +247,15 @@ void ProgressBar::OnPaintIndeterminate(gfx::Canvas* canvas) {
canvas->DrawPath(slice_path, slice_flags);
}
+void ProgressBar::MaybeNotifyAccessibilityValueChanged() {
+ if (!GetWidget() || !GetWidget()->IsVisible() ||
+ RoundToPercent(current_value_) == last_announced_percentage_) {
+ return;
+ }
+ last_announced_percentage_ = RoundToPercent(current_value_);
+ NotifyAccessibilityEvent(ax::mojom::Event::kValueChanged, true);
+}
+
BEGIN_METADATA(ProgressBar)
METADATA_PARENT_CLASS(View)
ADD_PROPERTY_METADATA(ProgressBar, SkColor, ForegroundColor)
diff --git a/chromium/ui/views/controls/progress_bar.h b/chromium/ui/views/controls/progress_bar.h
index 563c15cd7cd..b57af1f1355 100644
--- a/chromium/ui/views/controls/progress_bar.h
+++ b/chromium/ui/views/controls/progress_bar.h
@@ -30,9 +30,11 @@ class VIEWS_EXPORT ProgressBar : public View, public gfx::AnimationDelegate {
bool allow_round_corner = true);
~ProgressBar() override;
- // Overridden from View:
+ // View:
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
gfx::Size CalculatePreferredSize() const override;
+ void VisibilityChanged(View* starting_from, bool is_visible) override;
+ void AddedToWidget() override;
void OnPaint(gfx::Canvas* canvas) override;
double GetValue() const;
@@ -59,6 +61,9 @@ class VIEWS_EXPORT ProgressBar : public View, public gfx::AnimationDelegate {
bool IsIndeterminate();
void OnPaintIndeterminate(gfx::Canvas* canvas);
+ // Fire an accessibility event if visible and the progress has changed.
+ void MaybeNotifyAccessibilityValueChanged();
+
// Current progress to display, should be in the range 0.0 to 1.0.
double current_value_ = 0.0;
@@ -72,6 +77,8 @@ class VIEWS_EXPORT ProgressBar : public View, public gfx::AnimationDelegate {
std::unique_ptr<gfx::LinearAnimation> indeterminate_bar_animation_;
+ int last_announced_percentage_ = -1;
+
DISALLOW_COPY_AND_ASSIGN(ProgressBar);
};
diff --git a/chromium/ui/views/controls/progress_bar_unittest.cc b/chromium/ui/views/controls/progress_bar_unittest.cc
index 280637e455d..e633e419022 100644
--- a/chromium/ui/views/controls/progress_bar_unittest.cc
+++ b/chromium/ui/views/controls/progress_bar_unittest.cc
@@ -8,38 +8,122 @@
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
+#include "ui/events/test/event_generator.h"
#include "ui/gfx/color_utils.h"
#include "ui/native_theme/native_theme.h"
+#include "ui/views/accessibility/ax_event_manager.h"
+#include "ui/views/accessibility/ax_event_observer.h"
#include "ui/views/test/views_test_base.h"
+#include "ui/views/widget/widget_utils.h"
namespace views {
-using ProgressBarTest = ViewsTestBase;
+namespace {
-TEST_F(ProgressBarTest, Accessibility) {
- ProgressBar bar;
- bar.SetValue(0.62);
+class TestAXEventObserver : public AXEventObserver {
+ public:
+ TestAXEventObserver() { AXEventManager::Get()->AddObserver(this); }
+
+ ~TestAXEventObserver() override {
+ AXEventManager::Get()->RemoveObserver(this);
+ }
+
+ TestAXEventObserver(const TestAXEventObserver&) = delete;
+ TestAXEventObserver& operator=(const TestAXEventObserver&) = delete;
+
+ int value_changed_count() const { return value_changed_count_; }
+
+ // AXEventObserver:
+ void OnViewEvent(View* view, ax::mojom::Event event_type) override {
+ if (event_type == ax::mojom::Event::kValueChanged)
+ value_changed_count_++;
+ }
+
+ private:
+ int value_changed_count_ = 0;
+};
+
+} // namespace
+
+class ProgressBarTest : public ViewsTestBase {
+ protected:
+ // ViewsTestBase:
+ void SetUp() override {
+ ViewsTestBase::SetUp();
+ bar_ = new ProgressBar;
+
+ widget_ = CreateTestWidget();
+ widget_->SetContentsView(bar_);
+ widget_->Show();
+
+ event_generator_ = std::make_unique<ui::test::EventGenerator>(
+ GetRootWindow(widget_.get()));
+ }
+
+ void TearDown() override {
+ widget_.reset();
+ ViewsTestBase::TearDown();
+ }
+
+ ProgressBar* bar_;
+ std::unique_ptr<Widget> widget_;
+
+ std::unique_ptr<ui::test::EventGenerator> event_generator_;
+};
+
+TEST_F(ProgressBarTest, AccessibleNodeData) {
+ bar_->SetValue(0.626);
ui::AXNodeData node_data;
- bar.GetAccessibleNodeData(&node_data);
+ bar_->GetAccessibleNodeData(&node_data);
EXPECT_EQ(ax::mojom::Role::kProgressIndicator, node_data.role);
EXPECT_EQ(base::string16(),
node_data.GetString16Attribute(ax::mojom::StringAttribute::kName));
+ EXPECT_EQ(std::string("62%"),
+ node_data.GetStringAttribute(ax::mojom::StringAttribute::kValue));
EXPECT_FALSE(
node_data.HasIntAttribute(ax::mojom::IntAttribute::kRestriction));
}
+// Verifies the correct a11y events are raised for an accessible progress bar.
+TEST_F(ProgressBarTest, AccessibilityEvents) {
+ TestAXEventObserver observer;
+ EXPECT_EQ(0, observer.value_changed_count());
+
+ bar_->SetValue(0.50);
+ EXPECT_EQ(1, observer.value_changed_count());
+
+ bar_->SetValue(0.63);
+ EXPECT_EQ(2, observer.value_changed_count());
+
+ bar_->SetValue(0.636);
+ EXPECT_EQ(2, observer.value_changed_count());
+
+ bar_->SetValue(0.642);
+ EXPECT_EQ(3, observer.value_changed_count());
+
+ widget_->Hide();
+ widget_->Show();
+ EXPECT_EQ(3, observer.value_changed_count());
+
+ widget_->Hide();
+ bar_->SetValue(0.8);
+ EXPECT_EQ(3, observer.value_changed_count());
+
+ widget_->Show();
+ EXPECT_EQ(4, observer.value_changed_count());
+}
+
// Test that default colors can be overridden. Used by Chromecast.
TEST_F(ProgressBarTest, OverrideDefaultColors) {
- ProgressBar bar;
- EXPECT_NE(SK_ColorRED, bar.GetForegroundColor());
- EXPECT_NE(SK_ColorGREEN, bar.GetBackgroundColor());
- EXPECT_NE(bar.GetForegroundColor(), bar.GetBackgroundColor());
-
- bar.SetForegroundColor(SK_ColorRED);
- bar.SetBackgroundColor(SK_ColorGREEN);
- EXPECT_EQ(SK_ColorRED, bar.GetForegroundColor());
- EXPECT_EQ(SK_ColorGREEN, bar.GetBackgroundColor());
+ EXPECT_NE(SK_ColorRED, bar_->GetForegroundColor());
+ EXPECT_NE(SK_ColorGREEN, bar_->GetBackgroundColor());
+ EXPECT_NE(bar_->GetForegroundColor(), bar_->GetBackgroundColor());
+
+ bar_->SetForegroundColor(SK_ColorRED);
+ bar_->SetBackgroundColor(SK_ColorGREEN);
+ EXPECT_EQ(SK_ColorRED, bar_->GetForegroundColor());
+ EXPECT_EQ(SK_ColorGREEN, bar_->GetBackgroundColor());
}
} // namespace views
diff --git a/chromium/ui/views/controls/resize_area.cc b/chromium/ui/views/controls/resize_area.cc
index a565893fdce..a83a939e050 100644
--- a/chromium/ui/views/controls/resize_area.cc
+++ b/chromium/ui/views/controls/resize_area.cc
@@ -4,7 +4,6 @@
#include "ui/views/controls/resize_area.h"
-#include "base/logging.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/cursor/cursor.h"
diff --git a/chromium/ui/views/controls/scroll_view.cc b/chromium/ui/views/controls/scroll_view.cc
index 89e642951ea..8f1244d79c2 100644
--- a/chromium/ui/views/controls/scroll_view.cc
+++ b/chromium/ui/views/controls/scroll_view.cc
@@ -7,8 +7,8 @@
#include <algorithm>
#include "base/bind.h"
+#include "base/check_op.h"
#include "base/feature_list.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/numerics/ranges.h"
#include "build/build_config.h"
diff --git a/chromium/ui/views/controls/scroll_view_unittest.cc b/chromium/ui/views/controls/scroll_view_unittest.cc
index 3d08c952fae..0359bc89ed3 100644
--- a/chromium/ui/views/controls/scroll_view_unittest.cc
+++ b/chromium/ui/views/controls/scroll_view_unittest.cc
@@ -799,6 +799,56 @@ TEST_F(ScrollViewTest, ScrollChildToVisibleOnFocus) {
EXPECT_EQ(415 - viewport_height, offset.y());
}
+// Verifies that ScrollView scrolls into view when its contents root is focused.
+TEST_F(ScrollViewTest, ScrollViewToVisibleOnContentsRootFocus) {
+ ScrollViewTestApi outer_test_api(scroll_view_.get());
+ auto outer_contents = std::make_unique<CustomView>();
+ outer_contents->SetPreferredSize(gfx::Size(500, 1000));
+ auto* outer_contents_ptr =
+ scroll_view_->SetContents(std::move(outer_contents));
+
+ auto inner_scroll_view = std::make_unique<ScrollView>();
+ auto* inner_scroll_view_ptr =
+ outer_contents_ptr->AddChildView(std::move(inner_scroll_view));
+
+ ScrollViewTestApi inner_test_api(inner_scroll_view_ptr);
+ auto inner_contents = std::make_unique<FixedView>();
+ inner_contents->SetPreferredSize(gfx::Size(500, 1000));
+ auto* inner_contents_ptr =
+ inner_scroll_view_ptr->SetContents(std::move(inner_contents));
+
+ inner_scroll_view_ptr->SetBoundsRect(gfx::Rect(0, 510, 100, 100));
+ inner_scroll_view_ptr->Layout();
+ EXPECT_EQ(gfx::Point(), inner_test_api.IntegralViewOffset());
+
+ scroll_view_->SetBoundsRect(gfx::Rect(0, 0, 200, 200));
+ scroll_view_->Layout();
+ EXPECT_EQ(gfx::Point(), outer_test_api.IntegralViewOffset());
+
+ // Scroll the inner scroll view to y=405 height=10. This should make the y
+ // position of the inner content at (405 + 10) - inner_viewport_height
+ // (scroll region bottom aligned). The outer scroll view should not scroll.
+ inner_contents_ptr->ScrollRectToVisible(gfx::Rect(0, 405, 10, 10));
+ const int inner_viewport_height =
+ inner_test_api.contents_viewport()->height();
+ gfx::ScrollOffset inner_offset = inner_test_api.CurrentOffset();
+ EXPECT_EQ(415 - inner_viewport_height, inner_offset.y());
+ gfx::ScrollOffset outer_offset = outer_test_api.CurrentOffset();
+ EXPECT_EQ(0, outer_offset.y());
+
+ // Set focus to the inner scroll view's contents root. This should cause the
+ // outer scroll view to scroll to y=510 height=100 so that the y position of
+ // the outer content is at (510 + 100) - outer_viewport_height (scroll region
+ // bottom aligned). The inner scroll view should not scroll.
+ inner_contents_ptr->SetFocus();
+ const int outer_viewport_height =
+ outer_test_api.contents_viewport()->height();
+ inner_offset = inner_test_api.CurrentOffset();
+ EXPECT_EQ(415 - inner_viewport_height, inner_offset.y());
+ outer_offset = outer_test_api.CurrentOffset();
+ EXPECT_EQ(610 - outer_viewport_height, outer_offset.y());
+}
+
// Verifies ClipHeightTo() uses the height of the content when it is between the
// minimum and maximum height values.
TEST_F(ScrollViewTest, ClipHeightToNormalContentHeight) {
diff --git a/chromium/ui/views/controls/scrollbar/scroll_bar_views.cc b/chromium/ui/views/controls/scrollbar/scroll_bar_views.cc
index 405168573ef..5da0afbd601 100644
--- a/chromium/ui/views/controls/scrollbar/scroll_bar_views.cc
+++ b/chromium/ui/views/controls/scrollbar/scroll_bar_views.cc
@@ -8,7 +8,8 @@
#include <memory>
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/canvas.h"
#include "ui/views/controls/button/button.h"
diff --git a/chromium/ui/views/controls/slider.cc b/chromium/ui/views/controls/slider.cc
index 3e03f5379e3..0f71ce43d4a 100644
--- a/chromium/ui/views/controls/slider.cc
+++ b/chromium/ui/views/controls/slider.cc
@@ -7,7 +7,7 @@
#include <algorithm>
#include <memory>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/message_loop/message_loop_current.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
diff --git a/chromium/ui/views/controls/styled_label.cc b/chromium/ui/views/controls/styled_label.cc
index 9004b93f773..5c915f9d452 100644
--- a/chromium/ui/views/controls/styled_label.cc
+++ b/chromium/ui/views/controls/styled_label.cc
@@ -556,9 +556,6 @@ std::unique_ptr<Label> StyledLabel::CreateLabel(
// Note this ignores |default_text_style_|, in favor of style::STYLE_LINK.
auto link = std::make_unique<Link>(text, text_context_);
- // Links in a StyledLabel do not get underlines.
- link->SetUnderline(false);
-
layout_views_->link_targets[link.get()] = range;
result = std::move(link);
diff --git a/chromium/ui/views/controls/tabbed_pane/tabbed_pane.cc b/chromium/ui/views/controls/tabbed_pane/tabbed_pane.cc
index 389092da35b..4fdef37e512 100644
--- a/chromium/ui/views/controls/tabbed_pane/tabbed_pane.cc
+++ b/chromium/ui/views/controls/tabbed_pane/tabbed_pane.cc
@@ -7,8 +7,8 @@
#include <algorithm>
#include <utility>
+#include "base/check_op.h"
#include "base/i18n/rtl.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "build/build_config.h"
#include "cc/paint/paint_flags.h"
diff --git a/chromium/ui/views/controls/tabbed_pane/tabbed_pane.h b/chromium/ui/views/controls/tabbed_pane/tabbed_pane.h
index e06e0db5f2b..4c42c238ecb 100644
--- a/chromium/ui/views/controls/tabbed_pane/tabbed_pane.h
+++ b/chromium/ui/views/controls/tabbed_pane/tabbed_pane.h
@@ -24,7 +24,7 @@ class TabStrip;
namespace test {
class TabbedPaneAccessibilityMacTest;
-class TabbedPaneTest;
+class TabbedPaneWithWidgetTest;
} // namespace test
// TabbedPane is a view that shows tabs. When the user clicks on a tab, the
@@ -100,7 +100,7 @@ class VIEWS_EXPORT TabbedPane : public View {
friend class FocusTraversalTest;
friend class Tab;
friend class TabStrip;
- friend class test::TabbedPaneTest;
+ friend class test::TabbedPaneWithWidgetTest;
friend class test::TabbedPaneAccessibilityMacTest;
// Adds a new tab at |index| with |title|. |contents| is the view displayed
diff --git a/chromium/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc b/chromium/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc
index 51cfc08d9ee..808afa4d777 100644
--- a/chromium/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc
+++ b/chromium/ui/views/controls/tabbed_pane/tabbed_pane_unittest.cc
@@ -43,14 +43,75 @@ ax::mojom::Role GetAccessibleRole(View* view) {
} // namespace
-class TabbedPaneTest : public ViewsTestBase {
+using TabbedPaneTest = ViewsTestBase;
+
+// Tests tab orientation.
+TEST_F(TabbedPaneTest, HorizontalOrientationDefault) {
+ auto tabbed_pane = std::make_unique<TabbedPane>();
+ EXPECT_EQ(tabbed_pane->GetOrientation(),
+ TabbedPane::Orientation::kHorizontal);
+}
+
+// Tests tab orientation.
+TEST_F(TabbedPaneTest, VerticalOrientation) {
+ auto tabbed_pane = std::make_unique<TabbedPane>(
+ TabbedPane::Orientation::kVertical, TabbedPane::TabStripStyle::kBorder);
+ EXPECT_EQ(tabbed_pane->GetOrientation(), TabbedPane::Orientation::kVertical);
+}
+
+// Tests tab strip style.
+TEST_F(TabbedPaneTest, TabStripBorderStyle) {
+ auto tabbed_pane = std::make_unique<TabbedPane>();
+ EXPECT_EQ(tabbed_pane->GetStyle(), TabbedPane::TabStripStyle::kBorder);
+}
+
+// Tests tab strip style.
+TEST_F(TabbedPaneTest, TabStripHighlightStyle) {
+ auto tabbed_pane =
+ std::make_unique<TabbedPane>(TabbedPane::Orientation::kVertical,
+ TabbedPane::TabStripStyle::kHighlight);
+ EXPECT_EQ(tabbed_pane->GetStyle(), TabbedPane::TabStripStyle::kHighlight);
+}
+
+// Tests the preferred size and layout when tabs are aligned vertically..
+TEST_F(TabbedPaneTest, SizeAndLayoutInVerticalOrientation) {
+ auto tabbed_pane = std::make_unique<TabbedPane>(
+ TabbedPane::Orientation::kVertical, TabbedPane::TabStripStyle::kBorder);
+ View* child1 =
+ tabbed_pane->AddTab(ASCIIToUTF16("tab1"),
+ std::make_unique<StaticSizedView>(gfx::Size(20, 10)));
+ View* child2 = tabbed_pane->AddTab(
+ ASCIIToUTF16("tab2"), std::make_unique<StaticSizedView>(gfx::Size(5, 5)));
+ tabbed_pane->SelectTabAt(0);
+
+ // |tabbed_pane_| reserves extra width for the tab strip in vertical mode.
+ EXPECT_GT(tabbed_pane->GetPreferredSize().width(), 20);
+ // |tabbed_pane_| height should match the largest child in vertical mode.
+ EXPECT_EQ(tabbed_pane->GetPreferredSize().height(), 10);
+
+ // The child views should resize to fit in larger tabbed panes.
+ tabbed_pane->SetBounds(0, 0, 100, 200);
+
+ EXPECT_GT(child1->bounds().width(), 0);
+ // |tabbed_pane_| reserves extra width for the tab strip. Therefore the
+ // children's width should be smaller than the |tabbed_pane_|'s width.
+ EXPECT_LT(child1->bounds().width(), 100);
+ // |tabbed_pane_| has no border. Therefore the children should be as high as
+ // the |tabbed_pane_|.
+ EXPECT_EQ(child1->bounds().height(), 200);
+
+ // If we switch to the other tab, it should get assigned the same bounds.
+ tabbed_pane->SelectTabAt(1);
+ EXPECT_EQ(child1->bounds(), child2->bounds());
+}
+
+class TabbedPaneWithWidgetTest : public ViewsTestBase {
public:
- TabbedPaneTest() = default;
+ TabbedPaneWithWidgetTest() = default;
void SetUp() override {
ViewsTestBase::SetUp();
- tabbed_pane_ = std::make_unique<TabbedPane>();
- tabbed_pane_->set_owned_by_client();
+ auto tabbed_pane = std::make_unique<TabbedPane>();
// Create a widget so that accessibility data will be returned correctly.
widget_ = std::make_unique<Widget>();
@@ -59,22 +120,17 @@ class TabbedPaneTest : public ViewsTestBase {
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(0, 0, 650, 650);
widget_->Init(std::move(params));
- widget_->SetContentsView(tabbed_pane_.get());
+ tabbed_pane_ = tabbed_pane.get();
+ widget_->SetContentsView(tabbed_pane.release());
}
void TearDown() override {
- tabbed_pane_.reset();
+ tabbed_pane_ = nullptr;
widget_.reset();
ViewsTestBase::TearDown();
}
protected:
- void MakeTabbedPane(TabbedPane::Orientation orientation,
- TabbedPane::TabStripStyle style) {
- tabbed_pane_ = std::make_unique<TabbedPane>(orientation, style);
- tabbed_pane_->set_owned_by_client();
- }
-
Tab* GetTabAt(size_t index) {
return static_cast<Tab*>(tabbed_pane_->tab_strip_->children()[index]);
}
@@ -90,41 +146,16 @@ class TabbedPaneTest : public ViewsTestBase {
}
std::unique_ptr<Widget> widget_;
- std::unique_ptr<TabbedPane> tabbed_pane_;
+ TabbedPane* tabbed_pane_;
private:
- DISALLOW_COPY_AND_ASSIGN(TabbedPaneTest);
+ DISALLOW_COPY_AND_ASSIGN(TabbedPaneWithWidgetTest);
};
-// Tests tab orientation.
-TEST_F(TabbedPaneTest, HorizontalOrientation) {
- EXPECT_EQ(tabbed_pane_->GetOrientation(),
- TabbedPane::Orientation::kHorizontal);
-}
-
-// Tests tab orientation.
-TEST_F(TabbedPaneTest, VerticalOrientation) {
- MakeTabbedPane(TabbedPane::Orientation::kVertical,
- TabbedPane::TabStripStyle::kBorder);
- EXPECT_EQ(tabbed_pane_->GetOrientation(), TabbedPane::Orientation::kVertical);
-}
-
-// Tests tab strip style.
-TEST_F(TabbedPaneTest, TabStripBorderStyle) {
- EXPECT_EQ(tabbed_pane_->GetStyle(), TabbedPane::TabStripStyle::kBorder);
-}
-
-// Tests tab strip style.
-TEST_F(TabbedPaneTest, TabStripHighlightStyle) {
- MakeTabbedPane(TabbedPane::Orientation::kVertical,
- TabbedPane::TabStripStyle::kHighlight);
- EXPECT_EQ(tabbed_pane_->GetStyle(), TabbedPane::TabStripStyle::kHighlight);
-}
-
// Tests the preferred size and layout when tabs are aligned horizontally.
// TabbedPane requests a size that fits the largest child or the minimum size
// necessary to display the tab titles, whichever is larger.
-TEST_F(TabbedPaneTest, SizeAndLayout) {
+TEST_F(TabbedPaneWithWidgetTest, SizeAndLayout) {
View* child1 = tabbed_pane_->AddTab(
ASCIIToUTF16("tab1"),
std::make_unique<StaticSizedView>(gfx::Size(20, 10)));
@@ -165,39 +196,7 @@ TEST_F(TabbedPaneTest, SizeAndLayout) {
EXPECT_EQ(child2->bounds(), child3->bounds());
}
-// Tests the preferred size and layout when tabs are aligned vertically..
-TEST_F(TabbedPaneTest, SizeAndLayoutInVerticalOrientation) {
- MakeTabbedPane(TabbedPane::Orientation::kVertical,
- TabbedPane::TabStripStyle::kBorder);
- View* child1 = tabbed_pane_->AddTab(
- ASCIIToUTF16("tab1"),
- std::make_unique<StaticSizedView>(gfx::Size(20, 10)));
- View* child2 = tabbed_pane_->AddTab(
- ASCIIToUTF16("tab2"), std::make_unique<StaticSizedView>(gfx::Size(5, 5)));
- tabbed_pane_->SelectTabAt(0);
-
- // |tabbed_pane_| reserves extra width for the tab strip in vertical mode.
- EXPECT_GT(tabbed_pane_->GetPreferredSize().width(), 20);
- // |tabbed_pane_| height should match the largest child in vertical mode.
- EXPECT_EQ(tabbed_pane_->GetPreferredSize().height(), 10);
-
- // The child views should resize to fit in larger tabbed panes.
- tabbed_pane_->SetBounds(0, 0, 100, 200);
- RunPendingMessages();
- EXPECT_GT(child1->bounds().width(), 0);
- // |tabbed_pane_| reserves extra width for the tab strip. Therefore the
- // children's width should be smaller than the |tabbed_pane_|'s width.
- EXPECT_LT(child1->bounds().width(), 100);
- // |tabbed_pane_| has no border. Therefore the children should be as high as
- // the |tabbed_pane_|.
- EXPECT_EQ(child1->bounds().height(), 200);
-
- // If we switch to the other tab, it should get assigned the same bounds.
- tabbed_pane_->SelectTabAt(1);
- EXPECT_EQ(child1->bounds(), child2->bounds());
-}
-
-TEST_F(TabbedPaneTest, AddAndSelect) {
+TEST_F(TabbedPaneWithWidgetTest, AddAndSelect) {
// Add several tabs; only the first should be selected automatically.
for (size_t i = 0; i < 3; ++i) {
tabbed_pane_->AddTab(DefaultTabTitle(), std::make_unique<View>());
@@ -218,7 +217,7 @@ TEST_F(TabbedPaneTest, AddAndSelect) {
EXPECT_NE(0u, tabbed_pane_->GetSelectedTabIndex());
}
-TEST_F(TabbedPaneTest, ArrowKeyBindings) {
+TEST_F(TabbedPaneWithWidgetTest, ArrowKeyBindings) {
// Add several tabs; only the first should be selected automatically.
for (size_t i = 0; i < 3; ++i) {
tabbed_pane_->AddTab(DefaultTabTitle(), std::make_unique<View>());
@@ -246,7 +245,7 @@ TEST_F(TabbedPaneTest, ArrowKeyBindings) {
// Use TabbedPane::HandleAccessibleAction() to select tabs and make sure their
// a11y information is correct.
-TEST_F(TabbedPaneTest, SelectTabWithAccessibleAction) {
+TEST_F(TabbedPaneWithWidgetTest, SelectTabWithAccessibleAction) {
constexpr size_t kNumTabs = 3;
for (size_t i = 0; i < kNumTabs; ++i) {
tabbed_pane_->AddTab(DefaultTabTitle(), std::make_unique<View>());
@@ -281,17 +280,17 @@ TEST_F(TabbedPaneTest, SelectTabWithAccessibleAction) {
EXPECT_EQ(1u, tabbed_pane_->GetSelectedTabIndex());
}
-TEST_F(TabbedPaneTest, AccessiblePaneTitleTracksActiveTabTitle) {
+TEST_F(TabbedPaneWithWidgetTest, AccessiblePaneTitleTracksActiveTabTitle) {
const base::string16 kFirstTitle = ASCIIToUTF16("Tab1");
const base::string16 kSecondTitle = ASCIIToUTF16("Tab2");
tabbed_pane_->AddTab(kFirstTitle, std::make_unique<View>());
tabbed_pane_->AddTab(kSecondTitle, std::make_unique<View>());
- EXPECT_EQ(kFirstTitle, GetAccessibleName(tabbed_pane_.get()));
+ EXPECT_EQ(kFirstTitle, GetAccessibleName(tabbed_pane_));
tabbed_pane_->SelectTabAt(1);
- EXPECT_EQ(kSecondTitle, GetAccessibleName(tabbed_pane_.get()));
+ EXPECT_EQ(kSecondTitle, GetAccessibleName(tabbed_pane_));
}
-TEST_F(TabbedPaneTest, AccessiblePaneContentsTitleTracksTabTitle) {
+TEST_F(TabbedPaneWithWidgetTest, AccessiblePaneContentsTitleTracksTabTitle) {
const base::string16 kFirstTitle = ASCIIToUTF16("Tab1");
const base::string16 kSecondTitle = ASCIIToUTF16("Tab2");
View* const tab1_contents =
@@ -302,7 +301,7 @@ TEST_F(TabbedPaneTest, AccessiblePaneContentsTitleTracksTabTitle) {
EXPECT_EQ(kSecondTitle, GetAccessibleName(tab2_contents));
}
-TEST_F(TabbedPaneTest, AccessiblePaneContentsRoleIsTab) {
+TEST_F(TabbedPaneWithWidgetTest, AccessiblePaneContentsRoleIsTab) {
const base::string16 kFirstTitle = ASCIIToUTF16("Tab1");
const base::string16 kSecondTitle = ASCIIToUTF16("Tab2");
View* const tab1_contents =
diff --git a/chromium/ui/views/controls/table/table_utils.cc b/chromium/ui/views/controls/table/table_utils.cc
index 36ed734a622..d6ac523212e 100644
--- a/chromium/ui/views/controls/table/table_utils.cc
+++ b/chromium/ui/views/controls/table/table_utils.cc
@@ -8,7 +8,7 @@
#include <algorithm>
-#include "base/logging.h"
+#include "base/notreached.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/text_utils.h"
diff --git a/chromium/ui/views/controls/table/table_view.cc b/chromium/ui/views/controls/table/table_view.cc
index 458e2470409..94eb7a0527c 100644
--- a/chromium/ui/views/controls/table/table_view.cc
+++ b/chromium/ui/views/controls/table/table_view.cc
@@ -1422,28 +1422,33 @@ void TableView::UpdateVirtualAccessibilityChildrenBounds() {
}
gfx::Rect TableView::CalculateHeaderRowAccessibilityBounds() const {
- return AdjustRectForAXRelativeBounds(header_->GetVisibleBounds());
+ gfx::Rect header_bounds = header_->GetVisibleBounds();
+ gfx::Point header_origin = header_bounds.origin();
+ ConvertPointToTarget(header_, this, &header_origin);
+ header_bounds.set_origin(header_origin);
+ return header_bounds;
}
gfx::Rect TableView::CalculateHeaderCellAccessibilityBounds(
const int visible_column_index) const {
+ const gfx::Rect& header_bounds = CalculateHeaderRowAccessibilityBounds();
const VisibleColumn& visible_column = visible_columns_[visible_column_index];
- gfx::Rect header_cell_bounds(visible_column.x, header_->y(),
- visible_column.width, header_->height());
- return AdjustRectForAXRelativeBounds(header_cell_bounds);
+ gfx::Rect header_cell_bounds(visible_column.x, header_bounds.y(),
+ visible_column.width, header_bounds.height());
+ return header_cell_bounds;
}
gfx::Rect TableView::CalculateTableRowAccessibilityBounds(
const int row_index) const {
gfx::Rect row_bounds = GetRowBounds(row_index);
- return AdjustRectForAXRelativeBounds(row_bounds);
+ return row_bounds;
}
gfx::Rect TableView::CalculateTableCellAccessibilityBounds(
const int row_index,
const int visible_column_index) const {
gfx::Rect cell_bounds = GetCellBounds(row_index, visible_column_index);
- return AdjustRectForAXRelativeBounds(cell_bounds);
+ return cell_bounds;
}
void TableView::UpdateAccessibilityFocus() {
@@ -1510,13 +1515,6 @@ AXVirtualView* TableView::GetVirtualAccessibilityCell(
return i->get();
}
-gfx::Rect TableView::AdjustRectForAXRelativeBounds(
- const gfx::Rect& rect) const {
- gfx::Rect converted_rect = rect;
- View::ConvertRectToScreen(this, &converted_rect);
- return converted_rect;
-}
-
DEFINE_ENUM_CONVERTERS(TableTypes,
{TableTypes::TEXT_ONLY, base::ASCIIToUTF16("TEXT_ONLY")},
{TableTypes::ICON_AND_TEXT,
diff --git a/chromium/ui/views/controls/table/table_view.h b/chromium/ui/views/controls/table/table_view.h
index 6a5546c7b74..1a640fdf53e 100644
--- a/chromium/ui/views/controls/table/table_view.h
+++ b/chromium/ui/views/controls/table/table_view.h
@@ -383,11 +383,6 @@ class VIEWS_EXPORT TableView : public views::View,
// |visible_column_index| indexes into |visible_columns_|.
AXVirtualView* GetVirtualAccessibilityCell(int row, int visible_column_index);
- // Returns |rect|, adjusted for use in AXRelativeBounds by translating it into
- // screen coordinates. The result must be converted to gfx::RectF when setting
- // into AXRelativeBounds.
- gfx::Rect AdjustRectForAXRelativeBounds(const gfx::Rect& rect) const;
-
ui::TableModel* model_ = nullptr;
std::vector<ui::TableColumn> columns_;
diff --git a/chromium/ui/views/controls/table/table_view_unittest.cc b/chromium/ui/views/controls/table/table_view_unittest.cc
index fb2a3ecc409..df538cc5d3c 100644
--- a/chromium/ui/views/controls/table/table_view_unittest.cc
+++ b/chromium/ui/views/controls/table/table_view_unittest.cc
@@ -80,23 +80,33 @@ class TableViewTestHelper {
// Generate the bounds for the header row and cells.
auto header_row = std::vector<gfx::Rect>();
- header_row.push_back(table_->CalculateHeaderRowAccessibilityBounds());
+ gfx::Rect header_row_bounds =
+ table_->CalculateHeaderRowAccessibilityBounds();
+ View::ConvertRectToScreen(table_, &header_row_bounds);
+ header_row.push_back(header_row_bounds);
for (size_t column_index = 0; column_index < visible_col_count();
column_index++) {
- header_row.push_back(
- table_->CalculateHeaderCellAccessibilityBounds(column_index));
+ gfx::Rect header_cell_bounds =
+ table_->CalculateHeaderCellAccessibilityBounds(column_index);
+ View::ConvertRectToScreen(table_, &header_cell_bounds);
+ header_row.push_back(header_cell_bounds);
}
expected_bounds.push_back(header_row);
// Generate the bounds for the table rows and cells.
for (int row_index = 0; row_index < table_->GetRowCount(); row_index++) {
auto table_row = std::vector<gfx::Rect>();
- table_row.push_back(
- table_->CalculateTableRowAccessibilityBounds(row_index));
+ gfx::Rect table_row_bounds =
+ table_->CalculateTableRowAccessibilityBounds(row_index);
+ View::ConvertRectToScreen(table_, &table_row_bounds);
+ table_row.push_back(table_row_bounds);
for (size_t column_index = 0; column_index < visible_col_count();
column_index++) {
- table_row.push_back(table_->CalculateTableCellAccessibilityBounds(
- row_index, column_index));
+ gfx::Rect table_cell_bounds =
+ table_->CalculateTableCellAccessibilityBounds(row_index,
+ column_index);
+ View::ConvertRectToScreen(table_, &table_cell_bounds);
+ table_row.push_back(table_cell_bounds);
}
expected_bounds.push_back(table_row);
}
diff --git a/chromium/ui/views/controls/textfield/textfield.cc b/chromium/ui/views/controls/textfield/textfield.cc
index 61b11e53fc3..d8e8fd0ace0 100644
--- a/chromium/ui/views/controls/textfield/textfield.cc
+++ b/chromium/ui/views/controls/textfield/textfield.cc
@@ -8,6 +8,7 @@
#include <set>
#include <string>
#include <utility>
+#include "ui/events/gesture_event_details.h"
#if defined(OS_WIN)
#include <vector>
@@ -55,6 +56,7 @@
#include "ui/views/painter.h"
#include "ui/views/style/platform_style.h"
#include "ui/views/views_delegate.h"
+#include "ui/views/views_features.h"
#include "ui/views/widget/widget.h"
#include "ui/wm/core/coordinate_conversion.h"
@@ -215,20 +217,20 @@ ui::TextEditCommand GetCommandForKeyEvent(const ui::KeyEvent& event) {
ui::TextEditCommand GetTextEditCommandFromMenuCommand(int command_id,
bool has_selection) {
switch (command_id) {
- case IDS_APP_UNDO:
+ case Textfield::kUndo:
return ui::TextEditCommand::UNDO;
- case IDS_APP_CUT:
+ case Textfield::kCut:
return ui::TextEditCommand::CUT;
- case IDS_APP_COPY:
+ case Textfield::kCopy:
return ui::TextEditCommand::COPY;
- case IDS_APP_PASTE:
+ case Textfield::kPaste:
return ui::TextEditCommand::PASTE;
- case IDS_APP_DELETE:
+ case Textfield::kDelete:
// The DELETE menu action only works in case of an active selection.
if (has_selection)
return ui::TextEditCommand::DELETE_FORWARD;
break;
- case IDS_APP_SELECT_ALL:
+ case Textfield::kSelectAll:
return ui::TextEditCommand::SELECT_ALL;
}
return ui::TextEditCommand::INVALID_COMMAND;
@@ -265,6 +267,11 @@ bool IsControlKeyModifier(int flags) {
#endif
}
+bool IsValidCharToInsert(const base::char16& ch) {
+ // Filter out all control characters, including tab and new line characters.
+ return (ch >= 0x20 && ch < 0x7F) || ch > 0x9F;
+}
+
} // namespace
// static
@@ -296,12 +303,11 @@ Textfield::Textfield()
selection_controller_(this) {
set_context_menu_controller(this);
set_drag_controller(this);
- cursor_view_.SetPaintToLayer(ui::LAYER_SOLID_COLOR);
- cursor_view_.layer()->SetColor(GetTextColor());
- // |cursor_view_| is owned by Textfield view.
- cursor_view_.set_owned_by_client();
- cursor_view_.GetViewAccessibility().OverrideIsIgnored(true);
- AddChildView(&cursor_view_);
+ auto cursor_view = std::make_unique<View>();
+ cursor_view->SetPaintToLayer(ui::LAYER_SOLID_COLOR);
+ cursor_view->layer()->SetColor(GetTextColor());
+ cursor_view->GetViewAccessibility().OverrideIsIgnored(true);
+ cursor_view_ = AddChildView(std::move(cursor_view));
GetRenderText()->SetFontList(GetDefaultFontList());
UpdateBorder();
SetFocusBehavior(FocusBehavior::ALWAYS);
@@ -388,7 +394,12 @@ const base::string16& Textfield::GetText() const {
}
void Textfield::SetText(const base::string16& new_text) {
- model_->SetText(new_text);
+ SetText(new_text, new_text.length());
+}
+
+void Textfield::SetText(const base::string16& new_text,
+ size_t cursor_position) {
+ model_->SetText(new_text, cursor_position);
OnCaretBoundsChanged();
UpdateCursorViewPosition();
UpdateCursorVisibility();
@@ -434,8 +445,8 @@ void Textfield::ClearSelection() {
UpdateAfterChange(false, true);
}
-bool Textfield::HasSelection() const {
- return !GetSelectedRange().is_empty();
+bool Textfield::HasSelection(bool primary_only) const {
+ return model_->HasSelection(primary_only);
}
SkColor Textfield::GetTextColor() const {
@@ -551,8 +562,15 @@ const gfx::Range& Textfield::GetSelectedRange() const {
}
void Textfield::SetSelectedRange(const gfx::Range& range) {
- model_->SelectRange(range);
- UpdateAfterChange(false, true);
+ SetSelectedRange(range, true);
+}
+
+void Textfield::SetSelectedRange(const gfx::Range& range, bool primary) {
+ model_->SelectRange(range, primary);
+ if (primary)
+ UpdateAfterChange(false, true);
+ else
+ SchedulePaint();
OnPropertyChanged(&model_ + kTextfieldSelectedRange, kPropertyEffectsPaint);
}
@@ -571,7 +589,7 @@ size_t Textfield::GetCursorPosition() const {
void Textfield::SetColor(SkColor value) {
GetRenderText()->SetColor(value);
- cursor_view_.layer()->SetColor(value);
+ cursor_view_->layer()->SetColor(value);
OnPropertyChanged(&model_ + kTextfieldTextColor, kPropertyEffectsPaint);
}
@@ -685,7 +703,7 @@ bool Textfield::OnMousePressed(const ui::MouseEvent& event) {
if (!handled &&
(event.IsOnlyLeftMouseButton() || event.IsOnlyRightMouseButton())) {
if (!had_focus)
- RequestFocusWithPointer(ui::EventPointerType::POINTER_TYPE_MOUSE);
+ RequestFocusWithPointer(ui::EventPointerType::kMouse);
#if !defined(OS_WIN)
ShowVirtualKeyboardIfEnabled();
#endif
@@ -693,7 +711,7 @@ bool Textfield::OnMousePressed(const ui::MouseEvent& event) {
#if defined(OS_LINUX) && !defined(OS_CHROMEOS)
if (!handled && !had_focus && event.IsOnlyMiddleMouseButton())
- RequestFocusWithPointer(ui::EventPointerType::POINTER_TYPE_MOUSE);
+ RequestFocusWithPointer(ui::EventPointerType::kMouse);
#endif
return selection_controller_.OnMousePressed(
@@ -767,29 +785,27 @@ bool Textfield::OnKeyReleased(const ui::KeyEvent& event) {
}
void Textfield::OnGestureEvent(ui::GestureEvent* event) {
- bool show_virtual_keyboard = true;
-#if defined(OS_WIN)
- show_virtual_keyboard = event->details().primary_pointer_type() ==
- ui::EventPointerType::POINTER_TYPE_TOUCH ||
- event->details().primary_pointer_type() ==
- ui::EventPointerType::POINTER_TYPE_PEN;
-#endif
+ static const bool kTakeFocusOnTapUp =
+ base::FeatureList::IsEnabled(features::kTextfieldFocusOnTapUp);
+
switch (event->type()) {
case ui::ET_GESTURE_TAP_DOWN:
- RequestFocusWithPointer(event->details().primary_pointer_type());
- if (show_virtual_keyboard)
- ShowVirtualKeyboardIfEnabled();
- event->SetHandled();
+ if (!kTakeFocusOnTapUp) {
+ RequestFocusForGesture(event->details());
+ event->SetHandled();
+ }
break;
case ui::ET_GESTURE_TAP:
+ if (kTakeFocusOnTapUp)
+ RequestFocusForGesture(event->details());
if (controller_ && controller_->HandleGestureEvent(this, *event)) {
event->SetHandled();
return;
}
if (event->details().tap_count() == 1) {
- // If tap is on the selection and touch handles are not present, handles
- // should be shown without changing selection. Otherwise, cursor should
- // be moved to the tap location.
+ // If tap is on the selection and touch handles are not present,
+ // handles should be shown without changing selection. Otherwise,
+ // cursor should be moved to the tap location.
if (touch_selection_controller_ ||
!GetRenderText()->IsPointInSelection(event->location())) {
OnBeforeUserAction();
@@ -816,15 +832,15 @@ void Textfield::OnGestureEvent(ui::GestureEvent* event) {
SelectWordAt(event->location());
OnAfterUserAction();
CreateTouchSelectionControllerAndNotifyIt();
- // If touch selection activated successfully, mark event as handled so
- // that the regular context menu is not shown.
+ // If touch selection activated successfully, mark event as handled
+ // so that the regular context menu is not shown.
if (touch_selection_controller_)
event->SetHandled();
} else {
- // If long-press happens on the selection, deactivate touch selection
- // and try to initiate drag-drop. If drag-drop is not enabled, context
- // menu will be shown. Event is not marked as handled to let Views
- // handle drag-drop or context menu.
+ // If long-press happens on the selection, deactivate touch
+ // selection and try to initiate drag-drop. If drag-drop is not
+ // enabled, context menu will be shown. Event is not marked as
+ // handled to let Views handle drag-drop or context menu.
DestroyTouchSelection();
initiating_drag_ = switches::IsTouchDragDropEnabled();
}
@@ -837,29 +853,34 @@ void Textfield::OnGestureEvent(ui::GestureEvent* event) {
event->SetHandled();
break;
case ui::ET_GESTURE_SCROLL_BEGIN:
- touch_handles_hidden_due_to_scroll_ =
- touch_selection_controller_ != nullptr;
- DestroyTouchSelection();
- drag_start_location_ = event->location();
- drag_start_display_offset_ =
- GetRenderText()->GetUpdatedDisplayOffset().x();
- event->SetHandled();
+ if (HasFocus()) {
+ touch_handles_hidden_due_to_scroll_ =
+ touch_selection_controller_ != nullptr;
+ DestroyTouchSelection();
+ drag_start_location_ = event->location();
+ drag_start_display_offset_ =
+ GetRenderText()->GetUpdatedDisplayOffset().x();
+ event->SetHandled();
+ }
break;
- case ui::ET_GESTURE_SCROLL_UPDATE: {
- int new_offset = drag_start_display_offset_ + event->location().x() -
- drag_start_location_.x();
- GetRenderText()->SetDisplayOffset(new_offset);
- SchedulePaint();
- event->SetHandled();
+ case ui::ET_GESTURE_SCROLL_UPDATE:
+ if (HasFocus()) {
+ int new_offset = drag_start_display_offset_ + event->location().x() -
+ drag_start_location_.x();
+ GetRenderText()->SetDisplayOffset(new_offset);
+ SchedulePaint();
+ event->SetHandled();
+ }
break;
- }
case ui::ET_GESTURE_SCROLL_END:
case ui::ET_SCROLL_FLING_START:
- if (touch_handles_hidden_due_to_scroll_) {
- CreateTouchSelectionControllerAndNotifyIt();
- touch_handles_hidden_due_to_scroll_ = false;
+ if (HasFocus()) {
+ if (touch_handles_hidden_due_to_scroll_) {
+ CreateTouchSelectionControllerAndNotifyIt();
+ touch_handles_hidden_due_to_scroll_ = false;
+ }
+ event->SetHandled();
}
- event->SetHandled();
break;
default:
return;
@@ -985,7 +1006,7 @@ int Textfield::OnPerformDrop(const ui::DropTargetEvent& event) {
// Adjust the drop destination if it is on or after the current selection.
size_t pos = drop_destination_model.caret_pos();
pos -= render_text->selection().Intersect(gfx::Range(0, pos)).length();
- model_->DeleteSelectionAndInsertTextAt(new_text, pos);
+ model_->DeletePrimarySelectionAndInsertTextAt(new_text, pos);
} else {
model_->MoveCursorTo(drop_destination_model);
// Drop always inserts text even if the textfield is not in insert mode.
@@ -1106,7 +1127,7 @@ void Textfield::OnFocus() {
GetRenderText()->set_focused(true);
if (ShouldShowCursor()) {
UpdateCursorViewPosition();
- cursor_view_.SetVisible(true);
+ cursor_view_->SetVisible(true);
}
if (GetInputMethod())
GetInputMethod()->SetFocusedTextInputClient(this);
@@ -1135,7 +1156,7 @@ void Textfield::OnBlur() {
#endif // defined(OS_CHROMEOS)
}
StopBlinkingCursor();
- cursor_view_.SetVisible(false);
+ cursor_view_->SetVisible(false);
DestroyTouchSelection();
@@ -1159,7 +1180,7 @@ void Textfield::OnThemeChanged() {
render_text->set_selection_color(GetSelectionTextColor());
render_text->set_selection_background_focused_color(
GetSelectionBackgroundColor());
- cursor_view_.layer()->SetColor(GetTextColor());
+ cursor_view_->layer()->SetColor(GetTextColor());
}
////////////////////////////////////////////////////////////////////////////////
@@ -1377,23 +1398,23 @@ bool Textfield::IsCommandIdEnabled(int command_id) const {
bool Textfield::GetAcceleratorForCommandId(int command_id,
ui::Accelerator* accelerator) const {
switch (command_id) {
- case IDS_APP_UNDO:
+ case kUndo:
*accelerator = ui::Accelerator(ui::VKEY_Z, ui::EF_PLATFORM_ACCELERATOR);
return true;
- case IDS_APP_CUT:
+ case kCut:
*accelerator = ui::Accelerator(ui::VKEY_X, ui::EF_PLATFORM_ACCELERATOR);
return true;
- case IDS_APP_COPY:
+ case kCopy:
*accelerator = ui::Accelerator(ui::VKEY_C, ui::EF_PLATFORM_ACCELERATOR);
return true;
- case IDS_APP_PASTE:
+ case kPaste:
*accelerator = ui::Accelerator(ui::VKEY_V, ui::EF_PLATFORM_ACCELERATOR);
return true;
- case IDS_APP_SELECT_ALL:
+ case kSelectAll:
*accelerator = ui::Accelerator(ui::VKEY_A, ui::EF_PLATFORM_ACCELERATOR);
return true;
@@ -1459,13 +1480,17 @@ void Textfield::ClearCompositionText() {
}
void Textfield::InsertText(const base::string16& new_text) {
- // TODO(suzhe): Filter invalid characters.
- if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE || new_text.empty())
+ base::string16 filtered_new_text;
+ std::copy_if(new_text.begin(), new_text.end(),
+ std::back_inserter(filtered_new_text), IsValidCharToInsert);
+
+ if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE ||
+ filtered_new_text.empty())
return;
OnBeforeUserAction();
skip_input_method_cancel_composition_ = true;
- model_->InsertText(new_text);
+ model_->InsertText(filtered_new_text);
skip_input_method_cancel_composition_ = false;
UpdateAfterChange(true, true);
OnAfterUserAction();
@@ -1477,13 +1502,12 @@ void Textfield::InsertChar(const ui::KeyEvent& event) {
return;
}
- // Filter out all control characters, including tab and new line characters,
- // and all characters with Alt modifier (and Search on ChromeOS, Ctrl on
- // Linux). But allow characters with the AltGr modifier. On Windows AltGr is
- // represented by Alt+Ctrl or Right Alt, and on Linux it's a different flag
- // that we don't care about.
+ // Filter all invalid chars and all characters with Alt modifier (and Search
+ // on ChromeOS, Ctrl on Linux). But allow characters with the AltGr modifier.
+ // On Windows AltGr is represented by Alt+Ctrl or Right Alt, and on Linux it's
+ // a different flag that we don't care about.
const base::char16 ch = event.GetCharacter();
- const bool should_insert_char = ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) &&
+ const bool should_insert_char = IsValidCharToInsert(ch) &&
!ui::IsSystemKeyModifier(event.flags()) &&
!IsControlKeyModifier(event.flags());
if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE || !should_insert_char)
@@ -1711,9 +1735,9 @@ bool Textfield::IsTextEditCommandEnabled(ui::TextEditCommand command) const {
case ui::TextEditCommand::REDO:
return editable && model_->CanRedo();
case ui::TextEditCommand::CUT:
- return editable && readable && model_->HasSelection();
+ return editable && readable && HasSelection();
case ui::TextEditCommand::COPY:
- return readable && model_->HasSelection();
+ return readable && HasSelection();
case ui::TextEditCommand::PASTE:
ui::Clipboard::GetForCurrentThread()->ReadText(
ui::ClipboardBuffer::kCopyPaste, &result);
@@ -1722,8 +1746,7 @@ bool Textfield::IsTextEditCommandEnabled(ui::TextEditCommand command) const {
return !GetText().empty() &&
GetSelectedRange().length() != GetText().length();
case ui::TextEditCommand::TRANSPOSE:
- return editable && !model_->HasSelection() &&
- !model_->HasCompositionText();
+ return editable && !HasSelection() && !model_->HasCompositionText();
case ui::TextEditCommand::YANK:
return editable;
case ui::TextEditCommand::MOVE_DOWN:
@@ -2053,13 +2076,13 @@ void Textfield::RequestFocusWithPointer(ui::EventPointerType pointer_type) {
return;
switch (pointer_type) {
- case ui::EventPointerType::POINTER_TYPE_MOUSE:
+ case ui::EventPointerType::kMouse:
focus_reason_ = ui::TextInputClient::FOCUS_REASON_MOUSE;
break;
- case ui::EventPointerType::POINTER_TYPE_PEN:
+ case ui::EventPointerType::kPen:
focus_reason_ = ui::TextInputClient::FOCUS_REASON_PEN;
break;
- case ui::EventPointerType::POINTER_TYPE_TOUCH:
+ case ui::EventPointerType::kTouch:
focus_reason_ = ui::TextInputClient::FOCUS_REASON_TOUCH;
break;
default:
@@ -2070,6 +2093,19 @@ void Textfield::RequestFocusWithPointer(ui::EventPointerType pointer_type) {
View::RequestFocus();
}
+void Textfield::RequestFocusForGesture(const ui::GestureEventDetails& details) {
+ bool show_virtual_keyboard = true;
+#if defined(OS_WIN)
+ show_virtual_keyboard =
+ details.primary_pointer_type() == ui::EventPointerType::kTouch ||
+ details.primary_pointer_type() == ui::EventPointerType::kPen;
+#endif
+
+ RequestFocusWithPointer(details.primary_pointer_type());
+ if (show_virtual_keyboard)
+ ShowVirtualKeyboardIfEnabled();
+}
+
views::PropertyChangedSubscription Textfield::AddTextChangedCallback(
views::PropertyChangedCallback callback) {
return AddPropertyChangedCallback(&model_ + kTextfieldText,
@@ -2216,7 +2252,7 @@ void Textfield::UpdateAfterChange(bool text_changed, bool cursor_changed) {
}
void Textfield::UpdateCursorVisibility() {
- cursor_view_.SetVisible(ShouldShowCursor());
+ cursor_view_->SetVisible(ShouldShowCursor());
if (ShouldBlinkCursor())
StartBlinkingCursor();
else
@@ -2229,7 +2265,7 @@ void Textfield::UpdateCursorViewPosition() {
location.set_height(
std::min(location.height(),
GetLocalBounds().height() - location.y() - location.y()));
- cursor_view_.SetBoundsRect(location);
+ cursor_view_->SetBoundsRect(location);
}
int Textfield::GetTextStyle() const {
@@ -2339,15 +2375,14 @@ void Textfield::UpdateContextMenu() {
context_menu_contents_.reset();
context_menu_contents_ = std::make_unique<ui::SimpleMenuModel>(this);
- context_menu_contents_->AddItemWithStringId(IDS_APP_UNDO, IDS_APP_UNDO);
+ context_menu_contents_->AddItemWithStringId(kUndo, IDS_APP_UNDO);
context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR);
- context_menu_contents_->AddItemWithStringId(IDS_APP_CUT, IDS_APP_CUT);
- context_menu_contents_->AddItemWithStringId(IDS_APP_COPY, IDS_APP_COPY);
- context_menu_contents_->AddItemWithStringId(IDS_APP_PASTE, IDS_APP_PASTE);
- context_menu_contents_->AddItemWithStringId(IDS_APP_DELETE, IDS_APP_DELETE);
+ context_menu_contents_->AddItemWithStringId(kCut, IDS_APP_CUT);
+ context_menu_contents_->AddItemWithStringId(kCopy, IDS_APP_COPY);
+ context_menu_contents_->AddItemWithStringId(kPaste, IDS_APP_PASTE);
+ context_menu_contents_->AddItemWithStringId(kDelete, IDS_APP_DELETE);
context_menu_contents_->AddSeparator(ui::NORMAL_SEPARATOR);
- context_menu_contents_->AddItemWithStringId(IDS_APP_SELECT_ALL,
- IDS_APP_SELECT_ALL);
+ context_menu_contents_->AddItemWithStringId(kSelectAll, IDS_APP_SELECT_ALL);
// If the controller adds menu commands, also override ExecuteCommand() and
// IsCommandIdEnabled() as appropriate, for the commands added.
@@ -2398,7 +2433,9 @@ void Textfield::OnEditFailed() {
}
bool Textfield::ShouldShowCursor() const {
- return HasFocus() && !HasSelection() && GetEnabled() && !GetReadOnly() &&
+ // Show the cursor when the primary selected range is empty; secondary
+ // selections do not affect cursor visibility.
+ return HasFocus() && !HasSelection(true) && GetEnabled() && !GetReadOnly() &&
!drop_cursor_visible_ && GetRenderText()->cursor_enabled();
}
@@ -2419,7 +2456,7 @@ void Textfield::StopBlinkingCursor() {
void Textfield::OnCursorBlinkTimerFired() {
DCHECK(ShouldBlinkCursor());
UpdateCursorViewPosition();
- cursor_view_.SetVisible(!cursor_view_.GetVisible());
+ cursor_view_->SetVisible(!cursor_view_->GetVisible());
}
void Textfield::OnEnabledChanged() {
diff --git a/chromium/ui/views/controls/textfield/textfield.h b/chromium/ui/views/controls/textfield/textfield.h
index 21bafd3fe89..825c45513cf 100644
--- a/chromium/ui/views/controls/textfield/textfield.h
+++ b/chromium/ui/views/controls/textfield/textfield.h
@@ -31,6 +31,7 @@
#include "ui/base/ime/text_input_type.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/base/pointer/touch_editing_controller.h"
+#include "ui/events/gesture_event_details.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/geometry/insets.h"
@@ -75,6 +76,13 @@ class VIEWS_EXPORT Textfield : public View,
public:
METADATA_HEADER(Textfield);
+ enum MenuCommands {
+ kUndo = kLastTouchEditableCommandId + 1,
+ kDelete,
+ kSelectAll,
+ kLastCommandId = kSelectAll,
+ };
+
// Returns the text cursor blink time, or 0 for no blinking.
static base::TimeDelta GetCaretBlinkInterval();
@@ -105,11 +113,14 @@ class VIEWS_EXPORT Textfield : public View,
// textfield.
const base::string16& GetText() const;
- // Sets the text currently displayed in the Textfield. This doesn't
- // change the cursor position if the current cursor is within the
- // new text's range, or moves the cursor to the end if the cursor is
- // out of the new text's range.
+ // Sets the text currently displayed in the Textfield and the cursor position.
+ // Calls to |SetText| are often followed by updating the selection or cursor,
+ // which does not update the edit history. I.e. the cursor position after
+ // redoing this change will be determined by |cursor_position| here and not by
+ // any subsequent calls to e.g. |SetSelectedRange|. Selections are not
+ // explicitly set here since redo's clear the selection anyways.
void SetText(const base::string16& new_text);
+ void SetText(const base::string16& new_text, size_t cursor_position);
// Appends the given string to the previously-existing text in the field.
void AppendText(const base::string16& new_text);
@@ -136,8 +147,9 @@ class VIEWS_EXPORT Textfield : public View,
// Clears the selection within the edit field and sets the caret to the end.
void ClearSelection();
- // Checks if there is any selected text.
- bool HasSelection() const;
+ // Checks if there is any selected text. |primary_only| indicates whether
+ // secondary selections should also be considered.
+ bool HasSelection(bool primary_only = false) const;
// Gets/sets the text color to be used when painting the Textfield.
SkColor GetTextColor() const;
@@ -206,6 +218,7 @@ class VIEWS_EXPORT Textfield : public View,
// Selects the specified logical text range.
void SetSelectedRange(const gfx::Range& range);
+ void SetSelectedRange(const gfx::Range& range, bool primary);
// Gets the text selection model.
const gfx::SelectionModel& GetSelectionModel() const;
@@ -413,11 +426,14 @@ class VIEWS_EXPORT Textfield : public View,
// override this to customize when the placeholder text is shown.
virtual bool ShouldShowPlaceholderText() const;
- protected:
// Like RequestFocus, but explicitly states that the focus is triggered by
// a pointer event.
void RequestFocusWithPointer(ui::EventPointerType pointer_type);
+ // Like RequestFocus, but explicitly states that the focus is triggered by a
+ // gesture event.
+ void RequestFocusForGesture(const ui::GestureEventDetails& details);
+
private:
friend class TextfieldTestApi;
@@ -641,7 +657,7 @@ class VIEWS_EXPORT Textfield : public View,
std::unique_ptr<views::MenuRunner> context_menu_runner_;
// View containing the text cursor.
- View cursor_view_;
+ View* cursor_view_ = nullptr;
#if defined(OS_MACOSX)
// Used to track active password input sessions.
diff --git a/chromium/ui/views/controls/textfield/textfield_model.cc b/chromium/ui/views/controls/textfield/textfield_model.cc
index 9e4896bf28d..d3df8334a98 100644
--- a/chromium/ui/views/controls/textfield/textfield_model.cc
+++ b/chromium/ui/views/controls/textfield/textfield_model.cc
@@ -7,7 +7,7 @@
#include <algorithm>
#include <utility>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/macros.h"
#include "base/message_loop/message_loop_current.h"
#include "base/no_destructor.h"
@@ -19,6 +19,30 @@
#include "ui/gfx/utf16_indexing.h"
#include "ui/views/style/platform_style.h"
+namespace {
+
+// Orders ranges decreasing with respect to their min index. This is useful for
+// applying text edits such that an edit doesn't offset the positions of later
+// edits. It should be reversed when undoing edits.
+void order_ranges(std::vector<gfx::Range>* ranges) {
+ std::sort(ranges->begin(), ranges->end(), [](const auto& r1, const auto& r2) {
+ return r1.GetMin() > r2.GetMin();
+ });
+}
+
+// Adjusts |position| for the deletion of |ranges|. E.g., if |position| is 10,
+// and |ranges| is {{1, 3}, {15, 18}, and {6, 13}}, this will return 4,
+// subtracting 2 (3-1), 0 (15>10), and 4 (10-6) for each range respectively.
+size_t adjust_position_for_removals(size_t position,
+ std::vector<gfx::Range> ranges) {
+ size_t adjustment = 0;
+ for (auto range : ranges)
+ adjustment += range.Intersect(gfx::Range(0, position)).length();
+ return position - adjustment;
+}
+
+} // namespace
+
namespace views {
namespace internal {
@@ -38,15 +62,26 @@ class Edit {
// Revert the change made by this edit in |model|.
void Undo(TextfieldModel* model) {
- model->ModifyText(new_text_start_, new_text_end(), old_text_,
- old_text_start_, old_selection_);
+ // Insertions must be applied in order of increasing indices since |Redo|
+ // applies them in decreasing order.
+ auto insertion_texts = old_texts_;
+ std::reverse(insertion_texts.begin(), insertion_texts.end());
+ auto insertion_text_starts = old_text_starts_;
+ std::reverse(insertion_text_starts.begin(), insertion_text_starts.end());
+ model->ModifyText({{new_text_start_, new_text_end()}}, insertion_texts,
+ insertion_text_starts, old_primary_selection_,
+ old_secondary_selections_);
}
// Apply the change of this edit to the |model|.
void Redo(TextfieldModel* model) {
- model->ModifyText(old_text_start_, old_text_end(), new_text_,
- new_text_start_,
- gfx::Range(new_cursor_pos_, new_cursor_pos_));
+ std::vector<gfx::Range> deletions;
+ for (size_t i = 0; i < old_texts_.size(); ++i) {
+ deletions.emplace_back(old_text_starts_[i],
+ old_text_starts_[i] + old_texts_[i].length());
+ }
+ model->ModifyText(deletions, {new_text_}, {new_text_start_},
+ {new_cursor_pos_, new_cursor_pos_}, {});
}
// Try to merge the |edit| into this edit and returns true on success. The
@@ -73,24 +108,27 @@ class Edit {
Edit(Type type,
MergeType merge_type,
- const base::string16& old_text,
- size_t old_text_start,
- gfx::Range old_selection,
+ std::vector<base::string16> old_texts,
+ std::vector<size_t> old_text_starts,
+ gfx::Range old_primary_selection,
+ std::vector<gfx::Range> old_secondary_selections,
bool delete_backward,
size_t new_cursor_pos,
const base::string16& new_text,
size_t new_text_start)
: type_(type),
merge_type_(merge_type),
- old_text_(old_text),
- old_text_start_(old_text_start),
- old_selection_(old_selection),
+ old_texts_(old_texts),
+ old_text_starts_(old_text_starts),
+ old_primary_selection_(old_primary_selection),
+ old_secondary_selections_(old_secondary_selections),
delete_backward_(delete_backward),
new_cursor_pos_(new_cursor_pos),
new_text_(new_text),
new_text_start_(new_text_start) {}
- // Each type of edit provides its own specific merge implementation.
+ // Each type of edit provides its own specific merge implementation. Assumes
+ // |edit| occurs after |this|.
virtual bool DoMerge(const Edit* edit) = 0;
Type type() const { return type_; }
@@ -101,9 +139,6 @@ class Edit {
// Should this edit be forcibly merged with the previous edit?
bool force_merge() const { return merge_type_ == MergeType::kForceMerge; }
- // Returns the end index of the |old_text_|.
- size_t old_text_end() const { return old_text_start_ + old_text_.length(); }
-
// Returns the end index of the |new_text_|.
size_t new_text_end() const { return new_text_start_ + new_text_.length(); }
@@ -111,32 +146,43 @@ class Edit {
// where an omnibox autocomplete string is set after a new character is typed.
void MergeReplace(const Edit* edit) {
CHECK_EQ(Type::kReplace, edit->type_);
- CHECK_EQ(0U, edit->old_text_start_);
+ CHECK_EQ(1U, edit->old_text_starts_.size());
+ CHECK_EQ(0U, edit->old_text_starts_[0]);
CHECK_EQ(0U, edit->new_text_start_);
- base::string16 old_text = edit->old_text_;
- old_text.erase(new_text_start_, new_text_.length());
- old_text.insert(old_text_start_, old_text_);
- // SetText() replaces entire text. Set |old_text_| to the entire
- // replaced text with |this| edit undone.
- old_text_ = old_text;
- old_text_start_ = edit->old_text_start_;
- delete_backward_ = false;
- new_text_ = edit->new_text_;
- new_text_start_ = edit->new_text_start_;
+ // We need to compute the merged edit's |old_texts_| by undoing this edit.
+ // Otherwise, |old_texts_| would be the autocompleted text following the
+ // user input. E.g., given goo|[gle.com], when the user types 'g', the text
+ // updates to goog|[le.com]. If we leave old_texts_ unchanged as 'gle.com',
+ // then undoing will result in 'gle.com' instead of 'goo|[gle.com]'
+ base::string16 old_texts = edit->old_texts_[0];
+ // Remove |new_text_|.
+ old_texts.erase(new_text_start_, new_text_.length());
+ // Add |old_texts_| in reverse order since we're undoing an edit.
+ for (size_t i = old_texts_.size(); i != 0; i--)
+ old_texts.insert(old_text_starts_[i - 1], old_texts_[i - 1]);
+
merge_type_ = MergeType::kDoNotMerge;
+ old_texts_ = {old_texts};
+ old_text_starts_ = {0};
+ delete_backward_ = false;
+ new_cursor_pos_ = edit->new_cursor_pos_;
+ new_text_ = edit->new_text_;
+ new_text_start_ = 0;
}
Type type_;
// The type of merging allowed.
MergeType merge_type_;
- // Deleted text by this edit.
- base::string16 old_text_;
- // The index of |old_text_|.
- size_t old_text_start_;
- // The range of the text selection prior to the edit.
- gfx::Range old_selection_;
+ // Deleted texts ordered with decreasing indices.
+ std::vector<base::string16> old_texts_;
+ // The indices of |old_texts_|.
+ std::vector<size_t> old_text_starts_;
+ // The text selection ranges prior to the edit. |old_primary_selection_|
+ // represents the selection associated with the cursor.
+ gfx::Range old_primary_selection_;
+ std::vector<gfx::Range> old_secondary_selections_;
// True if the deletion is made backward.
bool delete_backward_;
// New cursor position.
@@ -149,100 +195,128 @@ class Edit {
DISALLOW_COPY_AND_ASSIGN(Edit);
};
+// Insert text at a given position. Assumes 1) no previous selection and 2) the
+// insertion is at the cursor, which will advance by the insertion length.
class InsertEdit : public Edit {
public:
InsertEdit(bool mergeable, const base::string16& new_text, size_t at)
: Edit(Type::kInsert,
mergeable ? MergeType::kMergeable : MergeType::kDoNotMerge,
- base::string16(),
- at,
- gfx::Range(at, at),
- false /* N/A */,
- at + new_text.length() /* new cursor */,
- new_text,
- at) {}
-
- // Edit implementation.
+ {} /* old_texts */,
+ {} /* old_text_starts */,
+ {gfx::Range(at, at)} /* old_primary_selection */,
+ {} /* old_secondary_selections */,
+ false /* delete_backward */,
+ at + new_text.length() /* new_cursor_pos */,
+ new_text /* new_text */,
+ at /* new_text_start */) {}
+
+ // Merge if |edit| is an insertion continuing forward where |this| ended. E.g.
+ // If |this| changed "ab|c" to "abX|c", an edit to "abXY|c" can be merged.
bool DoMerge(const Edit* edit) override {
+ // Reject other edit types, and inserts starting somewhere other than where
+ // this insert ended.
if (edit->type() != Type::kInsert ||
new_text_end() != edit->new_text_start_)
return false;
- // If continuous edit, merge it.
- // TODO(oshima): gtk splits edits between whitespace. Find out what
- // we want to here and implement if necessary.
new_text_ += edit->new_text_;
new_cursor_pos_ = edit->new_cursor_pos_;
return true;
}
};
+// Delete one or more ranges and do a single insertion. The insertion need not
+// be adjacent to the deletions (e.g. drag & drop).
class ReplaceEdit : public Edit {
public:
ReplaceEdit(MergeType merge_type,
- const base::string16& old_text,
- size_t old_text_start,
- gfx::Range old_selection,
+ std::vector<base::string16> old_texts,
+ std::vector<size_t> old_text_starts,
+ gfx::Range old_primary_selection,
+ std::vector<gfx::Range> old_secondary_selections,
bool backward,
size_t new_cursor_pos,
const base::string16& new_text,
size_t new_text_start)
: Edit(Type::kReplace,
merge_type,
- old_text,
- old_text_start,
- old_selection,
+ old_texts,
+ old_text_starts,
+ old_primary_selection,
+ old_secondary_selections,
backward,
new_cursor_pos,
new_text,
new_text_start) {}
- // Edit implementation.
+ // Merge if |edit| is an insertion or replacement continuing forward where
+ // |this| ended. E.g. If |this| changed "a|bc" to "aX|c", edits to "aXY|" or
+ // "aXYc" can be merged. Drag and drops are marked kDoNotMerge and should not
+ // get here.
bool DoMerge(const Edit* edit) override {
- if (edit->type() == Type::kDelete ||
- new_text_end() != edit->old_text_start_ ||
- edit->old_text_start_ != edit->new_text_start_)
+ // Reject deletions, replacements deleting multiple ranges, and edits
+ // inserting or deleting text somewhere other than where this edit ended.
+ if (edit->type() == Type::kDelete || edit->old_texts_.size() > 1 ||
+ new_text_end() != edit->new_text_start_ ||
+ (!edit->old_text_starts_.empty() &&
+ new_text_end() != edit->old_text_starts_[0]))
return false;
- old_text_ += edit->old_text_;
+ if (edit->old_texts_.size() == 1)
+ old_texts_[0] += edit->old_texts_[0];
new_text_ += edit->new_text_;
new_cursor_pos_ = edit->new_cursor_pos_;
return true;
}
};
+// Delete possibly multiple texts.
class DeleteEdit : public Edit {
public:
DeleteEdit(bool mergeable,
- const base::string16& text,
- size_t text_start,
+ std::vector<base::string16> texts,
+ std::vector<size_t> text_starts,
+ gfx::Range old_primary_selection,
+ std::vector<gfx::Range> old_secondary_selections,
bool backward,
- gfx::Range old_selection)
+ size_t new_cursor_pos)
: Edit(Type::kDelete,
mergeable ? MergeType::kMergeable : MergeType::kDoNotMerge,
- text,
- text_start,
- old_selection,
+ texts,
+ text_starts,
+ old_primary_selection,
+ old_secondary_selections,
backward,
- text_start,
- base::string16(),
- text_start) {}
+ new_cursor_pos,
+ base::string16() /* new_text */,
+ 0 /* new_text_start */) {}
- // Edit implementation.
+ // Merge if |edit| is a deletion continuing in the same direction and position
+ // where |this| ended. E.g. If |this| changed "ab|c" to "a|c" an edit to "|c"
+ // can be merged.
bool DoMerge(const Edit* edit) override {
if (edit->type() != Type::kDelete)
return false;
+ // Deletions with selections are marked kDoNotMerge and should not get here.
+ DCHECK(old_secondary_selections_.empty());
+ DCHECK(old_primary_selection_.is_empty());
+ DCHECK(edit->old_secondary_selections_.empty());
+ DCHECK(edit->old_primary_selection_.is_empty());
if (delete_backward_) {
- // backspace can be merged only with backspace at the same position.
- if (!edit->delete_backward_ || old_text_start_ != edit->old_text_end())
+ // Backspace can be merged only with backspace at the same position.
+ if (!edit->delete_backward_ ||
+ old_text_starts_[0] !=
+ edit->old_text_starts_[0] + edit->old_texts_[0].length())
return false;
- old_text_start_ = edit->old_text_start_;
- old_text_ = edit->old_text_ + old_text_;
+ old_text_starts_[0] = edit->old_text_starts_[0];
+ old_texts_[0] = edit->old_texts_[0] + old_texts_[0];
new_cursor_pos_ = edit->new_cursor_pos_;
} else {
- // delete can be merged only with delete at the same position.
- if (edit->delete_backward_ || old_text_start_ != edit->old_text_start_)
+ // Delete can be merged only with delete at the same position.
+ if (edit->delete_backward_ ||
+ old_text_starts_[0] != edit->old_text_starts_[0])
return false;
- old_text_ += edit->old_text_;
+ old_texts_[0] += edit->old_texts_[0];
}
return true;
}
@@ -315,7 +389,8 @@ TextfieldModel::~TextfieldModel() {
ClearComposition();
}
-bool TextfieldModel::SetText(const base::string16& new_text) {
+bool TextfieldModel::SetText(const base::string16& new_text,
+ size_t cursor_position) {
using MergeType = internal::MergeType;
bool changed = false;
if (HasCompositionText()) {
@@ -325,14 +400,11 @@ bool TextfieldModel::SetText(const base::string16& new_text) {
if (text() != new_text) {
if (changed) // No need to remember composition.
Undo();
- // SetText moves the cursor to the end.
- size_t new_cursor = new_text.length();
// If there is a composition text, don't merge with previous edit.
// Otherwise, force merge the edits.
ExecuteAndRecordReplace(
changed ? MergeType::kDoNotMerge : MergeType::kForceMerge,
- gfx::Range(0, text().length()), new_cursor, new_text, 0U);
- render_text_->SetCursorPosition(new_cursor);
+ {gfx::Range(0, text().length())}, cursor_position, new_text, 0U);
}
ClearSelection();
return changed;
@@ -372,7 +444,7 @@ bool TextfieldModel::Delete(bool add_to_kill_buffer) {
gfx::Range range_to_delete(cursor_position, next_grapheme_index);
if (add_to_kill_buffer)
SetKillBuffer(GetTextFromRange(range_to_delete));
- ExecuteAndRecordDelete(range_to_delete, true);
+ ExecuteAndRecordDelete({range_to_delete}, true);
return true;
}
return false;
@@ -400,7 +472,7 @@ bool TextfieldModel::Backspace(bool add_to_kill_buffer) {
PlatformStyle::RangeToDeleteBackwards(text(), cursor_position));
if (add_to_kill_buffer)
SetKillBuffer(GetTextFromRange(range_to_delete));
- ExecuteAndRecordDelete(range_to_delete, true);
+ ExecuteAndRecordDelete({range_to_delete}, true);
return true;
}
return false;
@@ -446,10 +518,10 @@ base::string16 TextfieldModel::GetSelectedText() const {
return GetTextFromRange(render_text_->selection());
}
-void TextfieldModel::SelectRange(const gfx::Range& range) {
+void TextfieldModel::SelectRange(const gfx::Range& range, bool primary) {
if (HasCompositionText())
ConfirmCompositionText();
- render_text_->SelectRange(range);
+ render_text_->SelectRange(range, primary);
}
void TextfieldModel::SelectSelectionModel(const gfx::SelectionModel& sel) {
@@ -526,7 +598,8 @@ bool TextfieldModel::Redo() {
}
bool TextfieldModel::Cut() {
- if (!HasCompositionText() && HasSelection() && !render_text_->obscured()) {
+ if (!HasCompositionText() && HasSelection(true) &&
+ !render_text_->obscured()) {
ui::ScopedClipboardWriter(ui::ClipboardBuffer::kCopyPaste)
.WriteText(GetSelectedText());
DeleteSelection();
@@ -536,7 +609,8 @@ bool TextfieldModel::Cut() {
}
bool TextfieldModel::Copy() {
- if (!HasCompositionText() && HasSelection() && !render_text_->obscured()) {
+ if (!HasCompositionText() && HasSelection(true) &&
+ !render_text_->obscured()) {
ui::ScopedClipboardWriter(ui::ClipboardBuffer::kCopyPaste)
.WriteText(GetSelectedText());
return true;
@@ -605,23 +679,30 @@ bool TextfieldModel::Yank() {
return false;
}
-bool TextfieldModel::HasSelection() const {
- return !render_text_->selection().is_empty();
+bool TextfieldModel::HasSelection(bool primary_only) const {
+ if (primary_only)
+ return !render_text_->selection().is_empty();
+ auto selections = render_text_->GetAllSelections();
+ return std::any_of(
+ selections.begin(), selections.end(),
+ [](const auto& selection) { return !selection.is_empty(); });
}
void TextfieldModel::DeleteSelection() {
DCHECK(!HasCompositionText());
DCHECK(HasSelection());
- ExecuteAndRecordDelete(render_text_->selection(), false);
+ ExecuteAndRecordDelete(render_text_->GetAllSelections(), false);
}
-void TextfieldModel::DeleteSelectionAndInsertTextAt(
+void TextfieldModel::DeletePrimarySelectionAndInsertTextAt(
const base::string16& new_text,
size_t position) {
using MergeType = internal::MergeType;
if (HasCompositionText())
CancelCompositionText();
- ExecuteAndRecordReplace(MergeType::kDoNotMerge, render_text_->selection(),
+ // We don't use |ExecuteAndRecordReplaceSelection| because that assumes the
+ // insertion occurs at the cursor.
+ ExecuteAndRecordReplace(MergeType::kDoNotMerge, {render_text_->selection()},
position + new_text.length(), new_text, position);
}
@@ -774,13 +855,25 @@ void TextfieldModel::ClearRedoHistory() {
edit_history_.erase(delete_start, edit_history_.end());
}
-void TextfieldModel::ExecuteAndRecordDelete(gfx::Range range, bool mergeable) {
- size_t old_text_start = range.GetMin();
- const base::string16 old_text = text().substr(old_text_start, range.length());
- bool backward = range.is_reversed();
- gfx::Range curr_selection = render_text_->selection();
+void TextfieldModel::ExecuteAndRecordDelete(std::vector<gfx::Range> ranges,
+ bool mergeable) {
+ // We need only check replacement_ranges[0] as |delete_backwards_| is
+ // irrelevant for multi-range deletions which can't be merged anyways.
+ const bool backward = ranges[0].is_reversed();
+ order_ranges(&ranges);
+
+ std::vector<base::string16> old_texts;
+ std::vector<size_t> old_text_starts;
+ for (const auto& range : ranges) {
+ old_texts.push_back(GetTextFromRange(range));
+ old_text_starts.push_back(range.GetMin());
+ }
+
+ size_t cursor_pos = adjust_position_for_removals(GetCursorPosition(), ranges);
+
auto edit = std::make_unique<internal::DeleteEdit>(
- mergeable, old_text, old_text_start, backward, curr_selection);
+ mergeable, old_texts, old_text_starts, render_text_->selection(),
+ render_text_->secondary_selections(), backward, cursor_pos);
edit->Redo(this);
AddOrMergeEditHistory(std::move(edit));
}
@@ -788,22 +881,36 @@ void TextfieldModel::ExecuteAndRecordDelete(gfx::Range range, bool mergeable) {
void TextfieldModel::ExecuteAndRecordReplaceSelection(
internal::MergeType merge_type,
const base::string16& new_text) {
- size_t new_text_start = render_text_->selection().GetMin();
+ auto replacement_ranges = render_text_->GetAllSelections();
+ size_t new_text_start =
+ adjust_position_for_removals(GetCursorPosition(), replacement_ranges);
size_t new_cursor_pos = new_text_start + new_text.length();
- ExecuteAndRecordReplace(merge_type, render_text_->selection(), new_cursor_pos,
+
+ ExecuteAndRecordReplace(merge_type, replacement_ranges, new_cursor_pos,
new_text, new_text_start);
}
-void TextfieldModel::ExecuteAndRecordReplace(internal::MergeType merge_type,
- gfx::Range replacement_range,
- size_t new_cursor_pos,
- const base::string16& new_text,
- size_t new_text_start) {
- size_t old_text_start = replacement_range.GetMin();
- bool backward = replacement_range.is_reversed();
+void TextfieldModel::ExecuteAndRecordReplace(
+ internal::MergeType merge_type,
+ std::vector<gfx::Range> replacement_ranges,
+ size_t new_cursor_pos,
+ const base::string16& new_text,
+ size_t new_text_start) {
+ // We need only check replacement_ranges[0] as |delete_backwards_| is
+ // irrelevant for multi-range deletions which can't be merged anyways.
+ const bool backward = replacement_ranges[0].is_reversed();
+ order_ranges(&replacement_ranges);
+
+ std::vector<base::string16> old_texts;
+ std::vector<size_t> old_text_starts;
+ for (const auto& range : replacement_ranges) {
+ old_texts.push_back(GetTextFromRange(range));
+ old_text_starts.push_back(range.GetMin());
+ }
+
auto edit = std::make_unique<internal::ReplaceEdit>(
- merge_type, GetTextFromRange(replacement_range), old_text_start,
- render_text_->selection(), backward, new_cursor_pos, new_text,
+ merge_type, old_texts, old_text_starts, render_text_->selection(),
+ render_text_->secondary_selections(), backward, new_cursor_pos, new_text,
new_text_start);
edit->Redo(this);
AddOrMergeEditHistory(std::move(edit));
@@ -838,23 +945,28 @@ void TextfieldModel::AddOrMergeEditHistory(
}
}
-void TextfieldModel::ModifyText(size_t delete_from,
- size_t delete_to,
- const base::string16& new_text,
- size_t new_text_insert_at,
- gfx::Range selection) {
- DCHECK_LE(delete_from, delete_to);
+void TextfieldModel::ModifyText(
+ const std::vector<gfx::Range>& deletions,
+ const std::vector<base::string16>& insertion_texts,
+ const std::vector<size_t>& insertion_positions,
+ const gfx::Range& primary_selection,
+ const std::vector<gfx::Range>& secondary_selections) {
+ DCHECK_EQ(insertion_texts.size(), insertion_positions.size());
base::string16 old_text = text();
ClearComposition();
- if (delete_from != delete_to)
- SetRenderTextText(old_text.erase(delete_from, delete_to - delete_from));
- if (!new_text.empty())
- SetRenderTextText(old_text.insert(new_text_insert_at, new_text));
- if (selection.start() == selection.end()) {
- render_text_->SetCursorPosition(selection.start());
- } else {
- render_text_->SelectRange(selection);
- }
+
+ for (auto deletion : deletions)
+ old_text.erase(deletion.start(), deletion.length());
+ for (size_t i = 0; i < insertion_texts.size(); ++i)
+ old_text.insert(insertion_positions[i], insertion_texts[i]);
+ SetRenderTextText(old_text);
+
+ if (primary_selection.start() == primary_selection.end())
+ render_text_->SetCursorPosition(primary_selection.start());
+ else
+ render_text_->SelectRange(primary_selection);
+ for (auto secondary_selection : secondary_selections)
+ render_text_->SelectRange(secondary_selection, false);
}
void TextfieldModel::SetRenderTextText(const base::string16& text) {
diff --git a/chromium/ui/views/controls/textfield/textfield_model.h b/chromium/ui/views/controls/textfield/textfield_model.h
index 0cc866ce613..9873bc160e9 100644
--- a/chromium/ui/views/controls/textfield/textfield_model.h
+++ b/chromium/ui/views/controls/textfield/textfield_model.h
@@ -65,12 +65,17 @@ class VIEWS_EXPORT TextfieldModel {
// Edit related methods.
const base::string16& text() const { return render_text_->text(); }
- // Sets the text. Returns true if the text has been modified. The current
- // composition text will be confirmed first. Setting the same text will not
- // add edit history because it's not user visible change nor user-initiated
- // change. This allow a client code to set the same text multiple times
- // without worrying about messing edit history.
- bool SetText(const base::string16& new_text);
+ // Sets the text. Returns true if the text was modified. The current
+ // composition text will be confirmed first. Setting the same text, even with
+ // an updated |cursor_position|, will neither add edit history nor change the
+ // cursor because it's neither a user visible change nor user-initiated
+ // change. This allows clients to set the same text multiple times without
+ // messing up edit history. The resulting history edit will have
+ // |new_cursor_pos| set to |cursor_position|. This is important even if
+ // subsequent calls will override the cursor position because updating the
+ // cursor alone won't update the edit history. I.e. the cursor position after
+ // applying or redoing the edit will be determined by |cursor_position|.
+ bool SetText(const base::string16& new_text, size_t cursor_position);
gfx::RenderText* render_text() { return render_text_.get(); }
@@ -138,13 +143,15 @@ class VIEWS_EXPORT TextfieldModel {
// Selection related methods.
- // Returns the selected text.
+ // Returns the primary selected text associated with the cursor. Does not
+ // return secondary selections.
base::string16 GetSelectedText() const;
- // The current composition text will be confirmed. The selection starts with
- // the range's start position, and ends with the range's end position,
- // therefore the cursor position becomes the end position.
- void SelectRange(const gfx::Range& range);
+ // The current composition text will be confirmed. If |primary| is true, the
+ // selection starts with the range's start position and ends with the range's
+ // end position; therefore the cursor position becomes the end position. If
+ // |primary| is false, then the selection is not associated with the cursor.
+ void SelectRange(const gfx::Range& range, bool primary = true);
// The current composition text will be confirmed.
// render_text_'s selection model is set to |sel|.
@@ -200,16 +207,17 @@ class VIEWS_EXPORT TextfieldModel {
bool Yank();
// Tells if any text is selected, even if the selection is in composition
- // text.
- bool HasSelection() const;
+ // text. |primary_only| indicates whether secondary selections should also be
+ // considered.
+ bool HasSelection(bool primary_only = false) const;
// Deletes the selected text. This method shouldn't be called with
// composition text.
void DeleteSelection();
// Deletes the selected text (if any) and insert text at given position.
- void DeleteSelectionAndInsertTextAt(const base::string16& new_text,
- size_t position);
+ void DeletePrimarySelectionAndInsertTextAt(const base::string16& new_text,
+ size_t position);
// Retrieves the text content in a given range.
base::string16 GetTextFromRange(const gfx::Range& range) const;
@@ -256,23 +264,25 @@ class VIEWS_EXPORT TextfieldModel {
FRIEND_TEST_ALL_PREFIXES(TextfieldModelTest, UndoRedo_CutCopyPasteTest);
FRIEND_TEST_ALL_PREFIXES(TextfieldModelTest, UndoRedo_ReplaceTest);
- // Insert the given |new_text|. |mergeable| indicates if this insert operation
- // can be merged with previous edits in the history.
+ // Insert the given |new_text| at the cursor. |mergeable| indicates if this
+ // operation can be merged with previous edits in the history. Will delete any
+ // selected text.
void InsertTextInternal(const base::string16& new_text, bool mergeable);
- // Replace the current text with the given |new_text|. |mergeable| indicates
- // if this replace operation can be merged with previous edits in the history.
+ // Replace the current selected text with the given |new_text|. |mergeable|
+ // indicates if this operation can be merged with previous edits in the
+ // history.
void ReplaceTextInternal(const base::string16& new_text, bool mergeable);
// Clears redo history.
void ClearRedoHistory();
// Executes and records edit operations.
- void ExecuteAndRecordDelete(gfx::Range range, bool mergeable);
+ void ExecuteAndRecordDelete(std::vector<gfx::Range> ranges, bool mergeable);
void ExecuteAndRecordReplaceSelection(internal::MergeType merge_type,
const base::string16& new_text);
void ExecuteAndRecordReplace(internal::MergeType merge_type,
- gfx::Range replacement_range,
+ std::vector<gfx::Range> replacement_range,
size_t new_cursor_pos,
const base::string16& new_text,
size_t new_text_start);
@@ -282,15 +292,20 @@ class VIEWS_EXPORT TextfieldModel {
void AddOrMergeEditHistory(std::unique_ptr<internal::Edit> edit);
// Modify the text buffer in following way:
- // 1) Delete the string from |delete_from| to |delete_to|.
- // 2) Insert the |new_text| at the index |new_text_insert_at|.
- // Note that the index is after deletion.
- // 3) Select |selection|.
- void ModifyText(size_t delete_from,
- size_t delete_to,
- const base::string16& new_text,
- size_t new_text_insert_at,
- gfx::Range selection);
+ // 1) Delete the |deletions|.
+ // 2) Insert the |insertion_texts| at the |insertion_positions|.
+ // 3) Select |primary_selection| and |secondary_selections|.
+ // Deletions and insertions are applied in order and affect later edit
+ // indices. E.g., given 'xyz', inserting 'A' at 1 and 'B' at 2 will result in
+ // 'xAByz', not 'xAyBz'. On the other hand, inserting 'B' at 2 then 'A' at 1
+ // will result in 'xAyBz'. Thus, for applying or redoing edits, they should be
+ // ordered with increasing indices; while for undoing edits, they should be
+ // ordered decreasing.
+ void ModifyText(const std::vector<gfx::Range>& deletions,
+ const std::vector<base::string16>& insertion_texts,
+ const std::vector<size_t>& insertion_positions,
+ const gfx::Range& primary_selection,
+ const std::vector<gfx::Range>& secondary_selections);
// Calls render_text->SetText() and delegate's callback.
void SetRenderTextText(const base::string16& text);
diff --git a/chromium/ui/views/controls/textfield/textfield_model_unittest.cc b/chromium/ui/views/controls/textfield/textfield_model_unittest.cc
index 91d5f62a0c7..d9b29c3f0fb 100644
--- a/chromium/ui/views/controls/textfield/textfield_model_unittest.cc
+++ b/chromium/ui/views/controls/textfield/textfield_model_unittest.cc
@@ -57,10 +57,27 @@ class TextfieldModelTest : public ViewsTestBase,
protected:
void ResetModel(TextfieldModel* model) const {
- model->SetText(base::string16());
+ model->SetText(base::string16(), 0);
model->ClearEditHistory();
}
+ const std::vector<base::string16> GetAllSelectionTexts(
+ TextfieldModel* model) const {
+ std::vector<base::string16> selected_texts;
+ for (auto range : model->render_text()->GetAllSelections())
+ selected_texts.push_back(model->GetTextFromRange(range));
+ return selected_texts;
+ }
+
+ void VerifyAllSelectionTexts(
+ TextfieldModel* model,
+ std::vector<std::string> expected_selected_texts) const {
+ std::vector<base::string16> selected_texts = GetAllSelectionTexts(model);
+ EXPECT_EQ(expected_selected_texts.size(), selected_texts.size());
+ for (size_t i = 0; i < selected_texts.size(); ++i)
+ EXPECT_STR_EQ(expected_selected_texts[i], selected_texts[i]);
+ }
+
bool composition_text_confirmed_or_cleared_ = false;
private:
@@ -191,7 +208,7 @@ TEST_F(TextfieldModelTest, EditString_ComplexScript) {
#endif
// Test cursor position and deletion for Hindi Virama.
- model.SetText(base::WideToUTF16(L"\x0D38\x0D4D\x0D15\x0D16\x0D2E"));
+ model.SetText(base::WideToUTF16(L"\x0D38\x0D4D\x0D15\x0D16\x0D2E"), 0);
model.MoveCursorTo(0);
EXPECT_EQ(0U, model.GetCursorPosition());
@@ -210,7 +227,7 @@ TEST_F(TextfieldModelTest, EditString_ComplexScript) {
#endif
model.SetText(
- base::WideToUTF16(L"\x05d5\x05b7\x05D9\x05B0\x05D4\x05B4\x05D9"));
+ base::WideToUTF16(L"\x05d5\x05b7\x05D9\x05B0\x05D4\x05B4\x05D9"), 0);
model.MoveCursorTo(0);
EXPECT_TRUE(model.Delete());
EXPECT_TRUE(model.Delete());
@@ -220,7 +237,7 @@ TEST_F(TextfieldModelTest, EditString_ComplexScript) {
// The first 2 characters are not strong directionality characters.
model.SetText(
- base::WideToUTF16(L"\x002C\x0020\x05D1\x05BC\x05B7\x05E9\x05BC"));
+ base::WideToUTF16(L"\x002C\x0020\x05D1\x05BC\x05B7\x05E9\x05BC"), 0);
model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_LEFT, gfx::SELECTION_NONE);
EXPECT_TRUE(model.Backspace());
EXPECT_EQ(base::WideToUTF16(L"\x002C\x0020\x05D1\x05BC\x05B7\x05E9"),
@@ -229,7 +246,7 @@ TEST_F(TextfieldModelTest, EditString_ComplexScript) {
// Halfwidth katakana ダ:
// "HALFWIDTH KATAKANA LETTER TA" + "HALFWIDTH KATAKANA VOICED SOUND MARK"
// ("ABC" prefix as sanity check that the entire string isn't deleted).
- model.SetText(base::WideToUTF16(L"ABC\xFF80\xFF9E"));
+ model.SetText(base::WideToUTF16(L"ABC\xFF80\xFF9E"), 0);
model.MoveCursorTo(model.text().length());
model.Backspace();
#if defined(OS_MACOSX)
@@ -244,7 +261,7 @@ TEST_F(TextfieldModelTest, EditString_ComplexScript) {
// Emoji with Fitzpatrick modifier:
// 'BOY' + 'EMOJI MODIFIER FITZPATRICK TYPE-5'
- model.SetText(base::WideToUTF16(L"\U0001F466\U0001F3FE"));
+ model.SetText(base::WideToUTF16(L"\U0001F466\U0001F3FE"), 0);
model.MoveCursorTo(model.text().length());
model.Backspace();
#if defined(OS_MACOSX)
@@ -316,6 +333,23 @@ TEST_F(TextfieldModelTest, Selection) {
gfx::SELECTION_NONE);
EXPECT_EQ(3U, model.GetCursorPosition());
+ // Select multiple ranges and move cursor.
+ model.SelectRange(gfx::Range(1U, 3U));
+ model.SelectRange(gfx::Range(5U, 4U), false);
+ EXPECT_STR_EQ("EL", model.GetSelectedText());
+ EXPECT_EQ(3U, model.GetCursorPosition());
+ model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_LEFT, gfx::SELECTION_NONE);
+ EXPECT_TRUE(model.GetSelectedText().empty());
+ EXPECT_EQ(1U, model.GetCursorPosition());
+ EXPECT_TRUE(model.render_text()->secondary_selections().empty());
+ model.SelectRange(gfx::Range(1U, 3U));
+ model.SelectRange(gfx::Range(4U, 5U), false);
+ model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT,
+ gfx::SELECTION_NONE);
+ EXPECT_TRUE(model.GetSelectedText().empty());
+ EXPECT_EQ(3U, model.GetCursorPosition());
+ EXPECT_TRUE(model.render_text()->secondary_selections().empty());
+
// Select all and move cursor.
model.SelectAll(false);
model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_LEFT, gfx::SELECTION_NONE);
@@ -378,9 +412,9 @@ TEST_F(TextfieldModelTest, Selection_BidiWithNonSpacingMarks) {
// In case of "aBc", this test shows how to select "aB" or "Bc", assume 'B' is
// an RTL character.
- model.SetText(
- base::WideToUTF16(L"a\x05E9"
- L"b"));
+ model.SetText(base::WideToUTF16(L"a\x05E9"
+ L"b"),
+ 0);
model.MoveCursorTo(0);
model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_RIGHT,
gfx::SELECTION_RETAIN);
@@ -479,6 +513,56 @@ TEST_F(TextfieldModelTest, SelectionAndEdit) {
EXPECT_STR_EQ("BEE", model.text());
}
+TEST_F(TextfieldModelTest, SelectionAndEdit_WithSecondarySelection) {
+ // Backspace
+ TextfieldModel model(nullptr);
+ model.Append(base::ASCIIToUTF16("asynchronous promises make the moon spin?"));
+ model.SelectRange(gfx::Range(0U, 4U));
+ model.SelectRange(gfx::Range(17U, 19U), false);
+ model.SelectRange(gfx::Range(15U, 7U), false);
+ model.SelectRange(gfx::Range(41U, 20U), false);
+ EXPECT_TRUE(model.Backspace());
+ EXPECT_STR_EQ("chrome", model.text());
+ EXPECT_TRUE(model.GetSelectedText().empty());
+ EXPECT_EQ(0U, model.GetCursorPosition());
+ EXPECT_TRUE(model.render_text()->secondary_selections().empty());
+
+ // Delete with an empty primary selection
+ model.Append(base::ASCIIToUTF16(" is constructor overloading bad?"));
+ model.SelectRange(gfx::Range(1U, 1U));
+ model.SelectRange(gfx::Range(22U, 12U), false);
+ model.SelectRange(gfx::Range(26U, 23U), false);
+ model.SelectRange(gfx::Range(27U, 38U), false);
+ EXPECT_TRUE(model.Delete());
+ EXPECT_STR_EQ("chrome is cool", model.text());
+ EXPECT_TRUE(model.GetSelectedText().empty());
+ EXPECT_EQ(1U, model.GetCursorPosition());
+ EXPECT_TRUE(model.render_text()->secondary_selections().empty());
+
+ // Insert
+ model.Append(base::ASCIIToUTF16(" are inherited classes heavy?"));
+ model.SelectRange(gfx::Range(27U, 16U));
+ model.SelectRange(gfx::Range(41U, 34U), false);
+ model.SelectRange(gfx::Range(42U, 43U), false);
+ model.InsertChar('n');
+ EXPECT_STR_EQ("chrome is cool and classy", model.text());
+ EXPECT_TRUE(model.GetSelectedText().empty());
+ EXPECT_EQ(17U, model.GetCursorPosition());
+ EXPECT_TRUE(model.render_text()->secondary_selections().empty());
+
+ // Replace
+ model.Append(
+ base::ASCIIToUTF16("help! why can't i instantiate an abstract sun!?"));
+ model.SelectRange(gfx::Range(71U, 72U));
+ model.SelectRange(gfx::Range(30U, 70U), false);
+ model.SelectRange(gfx::Range(29U, 25U), false);
+ model.ReplaceChar('!');
+ EXPECT_STR_EQ("chrome is cool and classy!!!", model.text());
+ EXPECT_TRUE(model.GetSelectedText().empty());
+ EXPECT_EQ(28U, model.GetCursorPosition());
+ EXPECT_TRUE(model.render_text()->secondary_selections().empty());
+}
+
TEST_F(TextfieldModelTest, Word) {
TextfieldModel model(nullptr);
model.Append(
@@ -577,21 +661,33 @@ TEST_F(TextfieldModelTest, Word) {
TEST_F(TextfieldModelTest, SetText) {
TextfieldModel model(nullptr);
model.Append(base::ASCIIToUTF16("HELLO"));
+
+ // SetText moves cursor to the indicated position.
model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, gfx::SELECTION_NONE);
- model.SetText(base::ASCIIToUTF16("GOODBYE"));
+ model.SetText(base::ASCIIToUTF16("GOODBYE"), 6);
EXPECT_STR_EQ("GOODBYE", model.text());
- // SetText move the cursor to the end of the new text.
- EXPECT_EQ(7U, model.GetCursorPosition());
+ EXPECT_EQ(6U, model.GetCursorPosition());
+ model.SetText(base::ASCIIToUTF16("SUNSET"), 6);
+ EXPECT_STR_EQ("SUNSET", model.text());
+ EXPECT_EQ(6U, model.GetCursorPosition());
model.SelectAll(false);
- EXPECT_STR_EQ("GOODBYE", model.GetSelectedText());
+ EXPECT_STR_EQ("SUNSET", model.GetSelectedText());
model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, gfx::SELECTION_NONE);
- EXPECT_EQ(7U, model.GetCursorPosition());
+ EXPECT_EQ(6U, model.GetCursorPosition());
- model.SetText(base::ASCIIToUTF16("BYE"));
- // Setting shorter string moves the cursor to the end of the new string.
+ // Setting text to the current text should not modify the cursor position.
+ model.SetText(base::ASCIIToUTF16("SUNSET"), 3);
+ EXPECT_STR_EQ("SUNSET", model.text());
+ EXPECT_EQ(6U, model.GetCursorPosition());
+
+ // Setting text that's shorter than the indicated cursor moves the cursor to
+ // the text end.
+ model.SetText(base::ASCIIToUTF16("BYE"), 5);
EXPECT_EQ(3U, model.GetCursorPosition());
EXPECT_EQ(base::string16(), model.GetSelectedText());
- model.SetText(base::string16());
+
+ // SetText with empty string.
+ model.SetText(base::string16(), 0);
EXPECT_EQ(0U, model.GetCursorPosition());
}
@@ -615,7 +711,7 @@ TEST_F(TextfieldModelTest, Clipboard) {
EXPECT_EQ(11U, model.GetCursorPosition());
// Copy with an empty selection should do nothing.
- model.Copy();
+ EXPECT_FALSE(model.Copy());
clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &clipboard_text);
EXPECT_EQ(initial_clipboard_text, clipboard_text);
EXPECT_STR_EQ("HELLO WORLD", model.text());
@@ -666,6 +762,132 @@ TEST_F(TextfieldModelTest, Clipboard) {
EXPECT_TRUE(model.Paste());
EXPECT_STR_EQ("HELLO HELLOHELLO", model.text());
EXPECT_EQ(16U, model.GetCursorPosition());
+
+ // Paste should replace the selection.
+ model.render_text()->SetObscured(false);
+ model.SetText(base::ASCIIToUTF16("It's time to say goodbye."), 0);
+ model.SelectRange({17, 24});
+ EXPECT_TRUE(model.Paste());
+ clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &clipboard_text);
+ EXPECT_STR_EQ("HELLO ", clipboard_text);
+ EXPECT_STR_EQ("It's time to say HELLO.", model.text());
+ EXPECT_EQ(22U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_TRUE(model.render_text()->secondary_selections().empty());
+
+ // Paste with an empty clipboard should not replace the selection.
+ ui::Clipboard::GetForCurrentThread()->Clear(ui::ClipboardBuffer::kCopyPaste);
+ model.SelectRange({5, 8});
+ EXPECT_FALSE(model.Paste());
+ clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &clipboard_text);
+ EXPECT_TRUE(clipboard_text.empty());
+ EXPECT_STR_EQ("It's time to say HELLO.", model.text());
+ EXPECT_EQ(8U, model.GetCursorPosition());
+ EXPECT_STR_EQ("tim", model.GetSelectedText());
+}
+
+TEST_F(TextfieldModelTest, Clipboard_WithSecondarySelections) {
+ ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
+ const base::string16 initial_clipboard_text =
+ base::ASCIIToUTF16("initial text");
+ ui::ScopedClipboardWriter(ui::ClipboardBuffer::kCopyPaste)
+ .WriteText(initial_clipboard_text);
+
+ base::string16 clipboard_text;
+ TextfieldModel model(nullptr);
+ model.Append(base::ASCIIToUTF16("It's time to say HELLO."));
+
+ // Cut with multiple selections should copy only the primary selection but
+ // delete all selections.
+ model.SelectRange({0, 5});
+ model.SelectRange({13, 17}, false);
+ EXPECT_TRUE(model.Cut());
+ clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &clipboard_text);
+ EXPECT_STR_EQ("It's ", clipboard_text);
+ EXPECT_STR_EQ("time to HELLO.", model.text());
+ EXPECT_EQ(0U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_TRUE(model.render_text()->secondary_selections().empty());
+
+ // Copy with multiple selections should copy only the primary selection and
+ // retain multiple selections.
+ model.SelectRange({13, 8});
+ model.SelectRange({0, 4}, false);
+ EXPECT_TRUE(model.Copy());
+ clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &clipboard_text);
+ EXPECT_STR_EQ("HELLO", clipboard_text);
+ EXPECT_STR_EQ("time to HELLO.", model.text());
+ EXPECT_EQ(8U, model.GetCursorPosition());
+ EXPECT_TRUE(model.HasSelection());
+ VerifyAllSelectionTexts(&model, {"HELLO", "time"});
+
+ // Paste with multiple selections should paste at the primary selection and
+ // delete all selections.
+ model.SelectRange({0, 1});
+ model.SelectRange({5, 8}, false);
+ model.SelectRange({14, 14}, false);
+ EXPECT_TRUE(model.Paste());
+ clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &clipboard_text);
+ EXPECT_STR_EQ("HELLO", clipboard_text);
+ EXPECT_STR_EQ("HELLOime HELLO.", model.text());
+ EXPECT_EQ(5U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_TRUE(model.render_text()->secondary_selections().empty());
+
+ // Paste with multiple selections and an empty clipboard should not change the
+ // text or selections.
+ ui::Clipboard::GetForCurrentThread()->Clear(ui::ClipboardBuffer::kCopyPaste);
+ model.SelectRange({1, 2});
+ model.SelectRange({4, 5}, false);
+ EXPECT_FALSE(model.Paste());
+ clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &clipboard_text);
+ EXPECT_TRUE(clipboard_text.empty());
+ EXPECT_STR_EQ("HELLOime HELLO.", model.text());
+ EXPECT_EQ(2U, model.GetCursorPosition());
+ VerifyAllSelectionTexts(&model, {"E", "O"});
+
+ // Cut with an empty primary selection and nonempty secondary selections
+ // should neither delete the secondary selection nor replace the clipboard.
+ ui::ScopedClipboardWriter(ui::ClipboardBuffer::kCopyPaste)
+ .WriteText(initial_clipboard_text);
+ model.SelectRange({2, 2});
+ model.SelectRange({4, 5}, false);
+ EXPECT_FALSE(model.Cut());
+ clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &clipboard_text);
+ EXPECT_STR_EQ("initial text", clipboard_text);
+ EXPECT_STR_EQ("HELLOime HELLO.", model.text());
+ EXPECT_EQ(2U, model.GetCursorPosition());
+ VerifyAllSelectionTexts(&model, {"", "O"});
+
+ // Copy with an empty primary selection and nonempty secondary selections
+ // should not replace the clipboard.
+ EXPECT_FALSE(model.Copy());
+ clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &clipboard_text);
+ EXPECT_STR_EQ("initial text", clipboard_text);
+ EXPECT_STR_EQ("HELLOime HELLO.", model.text());
+ EXPECT_EQ(2U, model.GetCursorPosition());
+ VerifyAllSelectionTexts(&model, {"", "O"});
+
+ // Paste with an empty primary selection, nonempty secondary selection, and
+ // empty clipboard should change neither the text nor the selections.
+ ui::Clipboard::GetForCurrentThread()->Clear(ui::ClipboardBuffer::kCopyPaste);
+ EXPECT_FALSE(model.Paste());
+ clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &clipboard_text);
+ EXPECT_TRUE(clipboard_text.empty());
+ EXPECT_STR_EQ("HELLOime HELLO.", model.text());
+ EXPECT_EQ(2U, model.GetCursorPosition());
+ VerifyAllSelectionTexts(&model, {"", "O"});
+
+ // Paste with an empty primary selection and nonempty secondary selections
+ // should paste at the primary selection and delete the secondary selections.
+ ui::ScopedClipboardWriter(ui::ClipboardBuffer::kCopyPaste)
+ .WriteText(initial_clipboard_text);
+ EXPECT_TRUE(model.Paste());
+ clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &clipboard_text);
+ EXPECT_STR_EQ("initial text", clipboard_text);
+ EXPECT_STR_EQ("HEinitial textLLime HELLO.", model.text());
+ EXPECT_EQ(14U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
}
static void SelectWordTestVerifier(
@@ -734,9 +956,9 @@ TEST_F(TextfieldModelTest, SelectWordTest_MixScripts) {
word_and_cursor.emplace_back(L"\x5929", 14);
// The text consists of Ascii, Hebrew, Hindi with Virama sign, and Chinese.
- model.SetText(
- base::WideToUTF16(L"a\x05d0 \x05d1\x05d2 \x0915\x094d\x0915 "
- L"\x4E2D\x56FD\x82B1\x5929"));
+ model.SetText(base::WideToUTF16(L"a\x05d0 \x05d1\x05d2 \x0915\x094d\x0915 "
+ L"\x4E2D\x56FD\x82B1\x5929"),
+ 0);
for (size_t i = 0; i < word_and_cursor.size(); ++i) {
model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_LEFT, gfx::SELECTION_NONE);
for (size_t j = 0; j < i; ++j)
@@ -871,42 +1093,57 @@ TEST_F(TextfieldModelTest, SelectRangeTest) {
gfx::Range range(0, 6);
EXPECT_FALSE(range.is_reversed());
model.SelectRange(range);
+ EXPECT_TRUE(model.HasSelection());
EXPECT_STR_EQ("HELLO ", model.GetSelectedText());
range = gfx::Range(6, 1);
EXPECT_TRUE(range.is_reversed());
model.SelectRange(range);
+ EXPECT_TRUE(model.HasSelection());
EXPECT_STR_EQ("ELLO ", model.GetSelectedText());
range = gfx::Range(2, 1000);
EXPECT_FALSE(range.is_reversed());
model.SelectRange(range);
+ EXPECT_TRUE(model.HasSelection());
EXPECT_STR_EQ("LLO WORLD", model.GetSelectedText());
range = gfx::Range(1000, 3);
EXPECT_TRUE(range.is_reversed());
model.SelectRange(range);
+ EXPECT_TRUE(model.HasSelection());
EXPECT_STR_EQ("LO WORLD", model.GetSelectedText());
range = gfx::Range(0, 0);
EXPECT_TRUE(range.is_empty());
model.SelectRange(range);
+ EXPECT_FALSE(model.HasSelection());
EXPECT_TRUE(model.GetSelectedText().empty());
range = gfx::Range(3, 3);
EXPECT_TRUE(range.is_empty());
model.SelectRange(range);
+ EXPECT_FALSE(model.HasSelection());
EXPECT_TRUE(model.GetSelectedText().empty());
range = gfx::Range(1000, 100);
EXPECT_FALSE(range.is_empty());
model.SelectRange(range);
+ EXPECT_FALSE(model.HasSelection());
EXPECT_TRUE(model.GetSelectedText().empty());
range = gfx::Range(1000, 1000);
EXPECT_TRUE(range.is_empty());
model.SelectRange(range);
+ EXPECT_FALSE(model.HasSelection());
EXPECT_TRUE(model.GetSelectedText().empty());
+
+ EXPECT_TRUE(range.is_empty());
+ model.SelectRange({1, 5});
+ model.SelectRange({100, 7}, false);
+ EXPECT_TRUE(model.HasSelection());
+ EXPECT_STR_EQ("ELLO", model.GetSelectedText());
+ VerifyAllSelectionTexts(&model, {"ELLO", "ORLD"});
}
TEST_F(TextfieldModelTest, SelectionTest) {
@@ -994,6 +1231,16 @@ TEST_F(TextfieldModelTest, SelectSelectionModelTest) {
model.SelectSelectionModel(gfx::SelectionModel(1000, gfx::CURSOR_BACKWARD));
EXPECT_TRUE(model.GetSelectedText().empty());
+
+ gfx::SelectionModel mutliselection_selection_model{{2, 3},
+ gfx::CURSOR_BACKWARD};
+ mutliselection_selection_model.AddSecondarySelection({5, 4});
+ mutliselection_selection_model.AddSecondarySelection({1, 0});
+ mutliselection_selection_model.AddSecondarySelection({20, 9});
+ mutliselection_selection_model.AddSecondarySelection({6, 6});
+ model.SelectSelectionModel(mutliselection_selection_model);
+ EXPECT_STR_EQ("L", model.GetSelectedText());
+ VerifyAllSelectionTexts(&model, {"L", "O", "H", "LD", ""});
}
TEST_F(TextfieldModelTest, CompositionTextTest) {
@@ -1065,7 +1312,7 @@ TEST_F(TextfieldModelTest, CompositionTextTest) {
model.SetCompositionText(composition);
EXPECT_STR_EQ("1234567890", model.text());
- EXPECT_TRUE(model.SetText(base::ASCIIToUTF16("1234567890")));
+ EXPECT_TRUE(model.SetText(base::ASCIIToUTF16("1234567890"), 0));
EXPECT_TRUE(composition_text_confirmed_or_cleared_);
composition_text_confirmed_or_cleared_ = false;
model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, gfx::SELECTION_NONE);
@@ -1123,7 +1370,7 @@ TEST_F(TextfieldModelTest, CompositionTextTest) {
composition_text_confirmed_or_cleared_ = false;
EXPECT_STR_EQ("1234567890-678-", model.text());
- model.SetText(base::string16());
+ model.SetText(base::string16(), 0);
model.SetCompositionText(composition);
model.MoveCursor(gfx::CHARACTER_BREAK, gfx::CURSOR_LEFT, gfx::SELECTION_NONE);
EXPECT_TRUE(composition_text_confirmed_or_cleared_);
@@ -1145,7 +1392,7 @@ TEST_F(TextfieldModelTest, CompositionTextTest) {
composition_text_confirmed_or_cleared_ = false;
EXPECT_STR_EQ("676788678", model.text());
- model.SetText(base::string16());
+ model.SetText(base::string16(), 0);
model.SetCompositionText(composition);
model.MoveCursor(gfx::WORD_BREAK, gfx::CURSOR_RIGHT, gfx::SELECTION_NONE);
EXPECT_TRUE(composition_text_confirmed_or_cleared_);
@@ -1268,7 +1515,7 @@ TEST_F(TextfieldModelTest, UndoRedo_BasicTest) {
EXPECT_EQ(1U, model.GetCursorPosition());
// Delete ===============================
- model.SetText(base::ASCIIToUTF16("ABCDE"));
+ model.SetText(base::ASCIIToUTF16("ABCDE"), 0);
model.ClearEditHistory();
model.MoveCursorTo(2);
EXPECT_TRUE(model.Delete());
@@ -1300,31 +1547,34 @@ TEST_F(TextfieldModelTest, UndoRedo_BasicTest) {
TEST_F(TextfieldModelTest, UndoRedo_SetText) {
// This is to test the undo/redo behavior of omnibox.
TextfieldModel model(nullptr);
- model.InsertChar('w');
+ // Simulate typing www.y while www.google.com and www.youtube.com are
+ // autocompleted.
+ model.InsertChar('w'); // w|
EXPECT_STR_EQ("w", model.text());
EXPECT_EQ(1U, model.GetCursorPosition());
- model.SetText(base::ASCIIToUTF16("www.google.com"));
- EXPECT_EQ(14U, model.GetCursorPosition());
+ model.SetText(base::ASCIIToUTF16("www.google.com"), 1); // w|ww.google.com
+ model.SelectRange(gfx::Range(14, 1)); // w[ww.google.com]
+ EXPECT_EQ(1U, model.GetCursorPosition());
EXPECT_STR_EQ("www.google.com", model.text());
- model.SelectRange(gfx::Range(14, 1));
- model.InsertChar('w');
+ model.InsertChar('w'); // ww|
EXPECT_STR_EQ("ww", model.text());
- model.SetText(base::ASCIIToUTF16("www.google.com"));
- model.SelectRange(gfx::Range(14, 2));
- model.InsertChar('w');
+ model.SetText(base::ASCIIToUTF16("www.google.com"), 2); // ww|w.google.com
+ model.SelectRange(gfx::Range(14, 2)); // ww[w.google.com]
+ model.InsertChar('w'); // www|
EXPECT_STR_EQ("www", model.text());
- model.SetText(base::ASCIIToUTF16("www.google.com"));
- model.SelectRange(gfx::Range(14, 3));
- model.InsertChar('.');
+ model.SetText(base::ASCIIToUTF16("www.google.com"), 3); // www|.google.com
+ model.SelectRange(gfx::Range(14, 3)); // www[.google.com]
+ model.InsertChar('.'); // www.|
EXPECT_STR_EQ("www.", model.text());
- model.SetText(base::ASCIIToUTF16("www.google.com"));
- model.SelectRange(gfx::Range(14, 4));
- model.InsertChar('y');
+ model.SetText(base::ASCIIToUTF16("www.google.com"), 4); // www.|google.com
+ model.SelectRange(gfx::Range(14, 4)); // www.[google.com]
+ model.InsertChar('y'); // www.y|
EXPECT_STR_EQ("www.y", model.text());
- model.SetText(base::ASCIIToUTF16("www.youtube.com"));
+ model.SetText(base::ASCIIToUTF16("www.youtube.com"), 5); // www.y|outube.com
EXPECT_STR_EQ("www.youtube.com", model.text());
- EXPECT_EQ(15U, model.GetCursorPosition());
+ EXPECT_EQ(5U, model.GetCursorPosition());
+ // Undo until the initial edit.
EXPECT_TRUE(model.Undo());
EXPECT_STR_EQ("www.google.com", model.text());
EXPECT_EQ(4U, model.GetCursorPosition());
@@ -1341,6 +1591,8 @@ TEST_F(TextfieldModelTest, UndoRedo_SetText) {
EXPECT_STR_EQ("", model.text());
EXPECT_EQ(0U, model.GetCursorPosition());
EXPECT_FALSE(model.Undo());
+
+ // Redo until the last edit.
EXPECT_TRUE(model.Redo());
EXPECT_STR_EQ("www.google.com", model.text());
EXPECT_EQ(1U, model.GetCursorPosition());
@@ -1365,27 +1617,29 @@ TEST_F(TextfieldModelTest, UndoRedo_BackspaceThenSetText) {
model.InsertChar('w');
EXPECT_STR_EQ("w", model.text());
EXPECT_EQ(1U, model.GetCursorPosition());
- model.SetText(base::ASCIIToUTF16("www.google.com"));
- EXPECT_EQ(14U, model.GetCursorPosition());
+ model.SetText(base::ASCIIToUTF16("www.google.com"), 1);
EXPECT_STR_EQ("www.google.com", model.text());
- model.SetText(base::ASCIIToUTF16("www.google.com")); // Confirm the text.
+ EXPECT_EQ(1U, model.GetCursorPosition());
model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, gfx::SELECTION_NONE);
EXPECT_EQ(14U, model.GetCursorPosition());
EXPECT_TRUE(model.Backspace());
EXPECT_TRUE(model.Backspace());
EXPECT_STR_EQ("www.google.c", model.text());
// Autocomplete sets the text.
- model.SetText(base::ASCIIToUTF16("www.google.com/search=www.google.c"));
+ model.SetText(base::ASCIIToUTF16("www.google.com/search=www.google.c"), 12);
EXPECT_STR_EQ("www.google.com/search=www.google.c", model.text());
+ EXPECT_EQ(12U, model.GetCursorPosition());
EXPECT_TRUE(model.Undo());
EXPECT_STR_EQ("www.google.c", model.text());
+ EXPECT_EQ(12U, model.GetCursorPosition());
EXPECT_TRUE(model.Undo());
EXPECT_STR_EQ("www.google.com", model.text());
+ EXPECT_EQ(14U, model.GetCursorPosition());
}
TEST_F(TextfieldModelTest, UndoRedo_CutCopyPasteTest) {
TextfieldModel model(nullptr);
- model.SetText(base::ASCIIToUTF16("ABCDE"));
+ model.SetText(base::ASCIIToUTF16("ABCDE"), 5);
EXPECT_FALSE(model.Redo()); // There is nothing to redo.
// Test Cut.
model.SelectRange(gfx::Range(1, 3)); // A[BC]DE
@@ -1478,7 +1732,7 @@ TEST_F(TextfieldModelTest, UndoRedo_CutCopyPasteTest) {
gfx::Range(1, 3)));
// Test Copy.
ResetModel(&model);
- model.SetText(base::ASCIIToUTF16("12345")); // 12345|
+ model.SetText(base::ASCIIToUTF16("12345"), 5); // 12345|
EXPECT_STR_EQ("12345", model.text());
EXPECT_EQ(5U, model.GetCursorPosition());
model.SelectRange(gfx::Range(1, 3)); // 1[23]45
@@ -1553,7 +1807,7 @@ TEST_F(TextfieldModelTest, UndoRedo_CursorTest) {
TEST_F(TextfieldModelTest, Undo_SelectionTest) {
gfx::Range range = gfx::Range(2, 4);
TextfieldModel model(nullptr);
- model.SetText(base::ASCIIToUTF16("abcdef"));
+ model.SetText(base::ASCIIToUTF16("abcdef"), 0);
model.SelectRange(range);
EXPECT_EQ(model.render_text()->selection(), range);
@@ -1585,7 +1839,7 @@ TEST_F(TextfieldModelTest, Undo_SelectionTest) {
model.MoveCursorTo(model.text().length());
EXPECT_TRUE(model.Backspace());
model.SelectRange(gfx::Range(1, 3));
- model.SetText(base::ASCIIToUTF16("[set]"));
+ model.SetText(base::ASCIIToUTF16("[set]"), 0);
EXPECT_TRUE(model.Undo());
EXPECT_STR_EQ("abcde", model.text());
EXPECT_EQ(model.render_text()->selection(), gfx::Range(1, 3));
@@ -1642,28 +1896,28 @@ TEST_F(TextfieldModelTest, UndoRedo_ReplaceTest) {
{
SCOPED_TRACE("Select forwards and insert.");
TextfieldModel model(nullptr);
- model.SetText(base::ASCIIToUTF16("abcd"));
+ model.SetText(base::ASCIIToUTF16("abcd"), 4);
model.SelectRange(gfx::Range(1, 3));
RunInsertReplaceTest(&model);
}
{
SCOPED_TRACE("Select reversed and insert.");
TextfieldModel model(nullptr);
- model.SetText(base::ASCIIToUTF16("abcd"));
+ model.SetText(base::ASCIIToUTF16("abcd"), 4);
model.SelectRange(gfx::Range(3, 1));
RunInsertReplaceTest(&model);
}
{
SCOPED_TRACE("Select forwards and overwrite.");
TextfieldModel model(nullptr);
- model.SetText(base::ASCIIToUTF16("abcd"));
+ model.SetText(base::ASCIIToUTF16("abcd"), 4);
model.SelectRange(gfx::Range(1, 3));
RunOverwriteReplaceTest(&model);
}
{
SCOPED_TRACE("Select reversed and overwrite.");
TextfieldModel model(nullptr);
- model.SetText(base::ASCIIToUTF16("abcd"));
+ model.SetText(base::ASCIIToUTF16("abcd"), 4);
model.SelectRange(gfx::Range(3, 1));
RunOverwriteReplaceTest(&model);
}
@@ -1679,7 +1933,7 @@ TEST_F(TextfieldModelTest, UndoRedo_CompositionText) {
ui::ImeTextSpan::Thickness::kThin));
composition.selection = gfx::Range(2, 3);
- model.SetText(base::ASCIIToUTF16("ABCDE"));
+ model.SetText(base::ASCIIToUTF16("ABCDE"), 0);
model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, gfx::SELECTION_NONE);
model.InsertChar('x');
EXPECT_STR_EQ("ABCDEx", model.text());
@@ -1718,11 +1972,11 @@ TEST_F(TextfieldModelTest, UndoRedo_CompositionText) {
// Call SetText with the same text as the result.
ResetModel(&model);
- model.SetText(base::ASCIIToUTF16("ABCDE"));
+ model.SetText(base::ASCIIToUTF16("ABCDE"), 0);
model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, gfx::SELECTION_NONE);
model.SetCompositionText(composition);
EXPECT_STR_EQ("ABCDEabc", model.text());
- model.SetText(base::ASCIIToUTF16("ABCDEabc"));
+ model.SetText(base::ASCIIToUTF16("ABCDEabc"), 0);
EXPECT_STR_EQ("ABCDEabc", model.text());
EXPECT_TRUE(model.Undo());
EXPECT_STR_EQ("ABCDE", model.text());
@@ -1732,11 +1986,11 @@ TEST_F(TextfieldModelTest, UndoRedo_CompositionText) {
// Call SetText with a different result; the composition should be forgotten.
ResetModel(&model);
- model.SetText(base::ASCIIToUTF16("ABCDE"));
+ model.SetText(base::ASCIIToUTF16("ABCDE"), 0);
model.MoveCursor(gfx::LINE_BREAK, gfx::CURSOR_RIGHT, gfx::SELECTION_NONE);
model.SetCompositionText(composition);
EXPECT_STR_EQ("ABCDEabc", model.text());
- model.SetText(base::ASCIIToUTF16("1234"));
+ model.SetText(base::ASCIIToUTF16("1234"), 0);
EXPECT_STR_EQ("1234", model.text());
EXPECT_TRUE(model.Undo());
EXPECT_STR_EQ("ABCDE", model.text());
@@ -1747,6 +2001,298 @@ TEST_F(TextfieldModelTest, UndoRedo_CompositionText) {
// TODO(oshima): Test the behavior with an IME.
}
+TEST_F(TextfieldModelTest, UndoRedo_TypingWithSecondarySelections) {
+ TextfieldModel model(nullptr);
+
+ // Type 'ab cd' as 'prefix ab xy suffix' and 'prefix ab cd suffix' are
+ // autocompleted.
+ // Type 'a', autocomplete [prefix ]a[b xy suffix]
+ model.InsertChar('a');
+ model.SetText(base::ASCIIToUTF16("prefix ab xy suffix"), 8);
+ model.SelectRange({19, 8});
+ model.SelectRange({0, 7}, false);
+
+ // Type 'ab', autocomplete [prefix ]ab[ xy suffix]
+ model.InsertChar('b');
+ model.SetText(base::ASCIIToUTF16("prefix ab xy suffix"), 9);
+ model.SelectRange({19, 9});
+ model.SelectRange({0, 7}, false);
+
+ // Type 'ab ', autocomplete [prefix ]ab [xy suffix]
+ model.InsertChar(' ');
+ model.SetText(base::ASCIIToUTF16("prefix ab xy suffix"), 10);
+ model.SelectRange({19, 10});
+ model.SelectRange({0, 7}, false);
+
+ // Type 'ab c', autocomplete changed to [prefix ]ab c[d suffix]
+ model.InsertChar('c');
+ model.SetText(base::ASCIIToUTF16("prefix ab cd suffix"), 11);
+ model.SelectRange({19, 11});
+ model.SelectRange({0, 7}, false);
+
+ // Type 'ab cd', autocomplete [prefix ]ab cd[ suffix]
+ model.InsertChar('d');
+ model.SetText(base::ASCIIToUTF16("prefix ab cd suffix"), 12);
+ model.SelectRange({19, 12});
+ model.SelectRange({0, 7}, false);
+
+ // Undo 3 times
+ EXPECT_TRUE(model.Undo()); // [prefix ]ab c[d suffix]
+ EXPECT_STR_EQ("prefix ab cd suffix", model.text());
+ EXPECT_EQ(11U, model.GetCursorPosition());
+ VerifyAllSelectionTexts(&model, {"d suffix", "prefix "});
+
+ EXPECT_TRUE(model.Undo()); // [prefix ]ab [xy suffix]
+ EXPECT_STR_EQ("prefix ab xy suffix", model.text());
+ EXPECT_EQ(10U, model.GetCursorPosition());
+ VerifyAllSelectionTexts(&model, {"xy suffix", "prefix "});
+
+ EXPECT_TRUE(model.Undo()); // [prefix ]ab[ xy suffix]
+ EXPECT_STR_EQ("prefix ab xy suffix", model.text());
+ EXPECT_EQ(9U, model.GetCursorPosition());
+ VerifyAllSelectionTexts(&model, {" xy suffix", "prefix "});
+
+ // Redo 3 times
+ EXPECT_TRUE(model.Redo()); // [prefix ]ab [xy suffix]
+ EXPECT_STR_EQ("prefix ab xy suffix", model.text());
+ EXPECT_EQ(10U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+
+ EXPECT_TRUE(model.Redo()); // [prefix ]ab c[d suffix]
+ EXPECT_STR_EQ("prefix ab cd suffix", model.text());
+ EXPECT_EQ(11U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+
+ EXPECT_TRUE(model.Redo()); // [prefix ]ab cd[ suffix]
+ EXPECT_STR_EQ("prefix ab cd suffix", model.text());
+ EXPECT_EQ(12U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+}
+
+TEST_F(TextfieldModelTest, UndoRedo_MergingEditsWithSecondarySelections) {
+ TextfieldModel model(nullptr);
+
+ // Test all possible merge combinations involving secondary selections.
+ // I.e. an initial [replace or delete] edit with secondary selections,
+ // followed by a second and third [insert, replace, or delete] edits, which
+ // are [continuous and discontinuous] respectively. Some cases of the third,
+ // discontinuous edit have been omitted when the the second edit would not
+ // been merged anyways.
+
+ // Note, the cursor and selections depend on whether we're traversing forward
+ // or backwards through edit history. I.e., `undo(); redo();` can result in a
+ // different outcome than `redo(); undo();`. In general, if our edit history
+ // consists of 3 edits: A->B, C->D, & E->F, then undo will traverse
+ // F->E->C->A, while redo will traverse A->B->D->F. Though, B & C and D & E
+ // will have the same text, they can have different cursors and selections.
+
+ // Replacement with secondary selections followed by insertions
+ model.SetText(base::ASCIIToUTF16("prefix infix suffix"), 13);
+ model.SelectRange({18, 13});
+ model.SelectRange({1, 6}, false); // p[refix] infix [suffi]x
+ // Replace
+ model.InsertChar('1'); // p infix 1|x
+ // Continuous insert (should merge)
+ model.InsertChar('3'); // p infix 13|x
+ // Discontinuous insert (should not merge)
+ model.SelectRange({9, 9}); // p infix 1|3x
+ model.InsertChar('2'); // p infix 12|3x
+ EXPECT_STR_EQ("p infix 123x", model.text());
+ EXPECT_FALSE(model.HasSelection());
+ // Edit history should be
+ // p[refix] infix [suffi]x -> p infix 13|x
+ // p infix 1|3x -> p infix 12|3x
+ // Undo 2 times
+ EXPECT_TRUE(model.Undo()); // p infix 1|3x
+ EXPECT_STR_EQ("p infix 13x", model.text());
+ EXPECT_EQ(9U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_TRUE(model.Undo()); // p[refix] infix [suffi]x
+ EXPECT_STR_EQ("prefix infix suffix", model.text());
+ EXPECT_EQ(13U, model.GetCursorPosition());
+ VerifyAllSelectionTexts(&model, {"suffi", "refix"});
+ // Redo 2 times
+ EXPECT_TRUE(model.Redo()); // p infix 13|x
+ EXPECT_STR_EQ("p infix 13x", model.text());
+ EXPECT_EQ(10U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_TRUE(model.Redo()); // p infix 12|3x
+ EXPECT_STR_EQ("p infix 123x", model.text());
+ EXPECT_EQ(10U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_FALSE(model.Redo());
+
+ // Replacement with secondary selections followed by replacements
+ model.SetText(base::ASCIIToUTF16("prefix infix suffix"), 13);
+ model.SelectRange({15, 13});
+ model.SelectRange({1, 6}, false); // p[refix] infix [su]ffix
+ // Replace
+ model.InsertChar('1'); // p infix 1|ffix
+ // Continuous multiple characters, and backwards replace (should merge)
+ model.SelectRange({11, 9}); // p infix 1[ff]ix
+ model.InsertChar('3'); // p infix 13|ix
+ // Discontinuous but adjacent replace (should not merge)
+ model.SelectRange({10, 9}); // p infix 1[3]ix
+ model.InsertChar('2'); // p infix 12|ix
+ EXPECT_STR_EQ("p infix 12ix", model.text());
+ EXPECT_FALSE(model.HasSelection());
+ // Edit history should be
+ // p[refix] infix [su]ffix -> p infix 13|ix
+ // p infix 1[3]ix -> p infix 12|ix
+ // Undo 2 times
+ EXPECT_TRUE(model.Undo()); // p infix 1[3]ix
+ EXPECT_STR_EQ("p infix 13ix", model.text());
+ EXPECT_EQ(9U, model.GetCursorPosition());
+ VerifyAllSelectionTexts(&model, {"3"});
+ EXPECT_TRUE(model.Undo()); // p[refix] infix [su]ffix
+ EXPECT_STR_EQ("prefix infix suffix", model.text());
+ EXPECT_EQ(13U, model.GetCursorPosition());
+ VerifyAllSelectionTexts(&model, {"su", "refix"});
+ // Redo 2 times
+ EXPECT_TRUE(model.Redo()); // p infix 13|ix
+ EXPECT_STR_EQ("p infix 13ix", model.text());
+ EXPECT_EQ(10U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_TRUE(model.Redo()); // p infix 12|ix
+ EXPECT_STR_EQ("p infix 12ix", model.text());
+ EXPECT_EQ(10U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_FALSE(model.Redo());
+
+ // Replacement with secondary selections followed by deletion
+ model.SetText(base::ASCIIToUTF16("prefix infix suffix"), 13);
+ model.SelectRange({15, 13});
+ model.SelectRange({1, 6}, false); // p[refix] infix [su]ffix
+ // Replace
+ model.InsertChar('1'); // p infix 1|ffix
+ // Continuous delete (should not merge)
+ model.Delete(false); // p infix 1|fix
+ EXPECT_STR_EQ("p infix 1fix", model.text());
+ EXPECT_FALSE(model.HasSelection());
+ // Edit history should be
+ // p[refix] infix [su]ffix -> p infix 1|ffix
+ // p infix 1|ffix -> p infix 1|fix
+ // Undo 2 times
+ EXPECT_TRUE(model.Undo()); // p infix 1|ffix
+ EXPECT_STR_EQ("p infix 1ffix", model.text());
+ EXPECT_EQ(9U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_TRUE(model.Undo()); // p[refix] infix [su]ffix
+ EXPECT_STR_EQ("prefix infix suffix", model.text());
+ EXPECT_EQ(13U, model.GetCursorPosition());
+ VerifyAllSelectionTexts(&model, {"su", "refix"});
+ // Redo 2 times
+ EXPECT_TRUE(model.Redo()); // p infix 1|ffix
+ EXPECT_STR_EQ("p infix 1ffix", model.text());
+ EXPECT_EQ(9U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_TRUE(model.Redo()); // p infix 1|fix
+ EXPECT_STR_EQ("p infix 1fix", model.text());
+ EXPECT_EQ(9U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_FALSE(model.Redo());
+
+ // Deletion with secondary selections followed by insertion
+ model.SetText(base::ASCIIToUTF16("prefix infix suffix"), 13);
+ model.SelectRange({15, 13});
+ model.SelectRange({1, 6}, false); // p[refix] infix [su]ffix
+ // Delete
+ model.Delete(false); // p infix |ffix
+ // Continuous insert (should not merge)
+ model.InsertChar('1'); // p infix 1|ffix
+ EXPECT_STR_EQ("p infix 1ffix", model.text());
+ EXPECT_FALSE(model.HasSelection());
+ // Edit history should be
+ // p[refix] infix [su]ffix -> p infix |ffix
+ // p infix |ffix -> p infix 1|ffix
+ // Undo 2 times
+ EXPECT_TRUE(model.Undo()); // p infix |ffix
+ EXPECT_STR_EQ("p infix ffix", model.text());
+ EXPECT_EQ(8U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_TRUE(model.Undo()); // p[refix] infix [su]ffix
+ EXPECT_STR_EQ("prefix infix suffix", model.text());
+ EXPECT_EQ(13U, model.GetCursorPosition());
+ VerifyAllSelectionTexts(&model, {"su", "refix"});
+ // Redo 2 times
+ EXPECT_TRUE(model.Redo()); // p infix |ffix
+ EXPECT_STR_EQ("p infix ffix", model.text());
+ EXPECT_EQ(8U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_TRUE(model.Redo()); // p infix 1|ffix
+ EXPECT_STR_EQ("p infix 1ffix", model.text());
+ EXPECT_EQ(9U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_FALSE(model.Redo());
+
+ // Deletion with secondary selections followed by replacement
+ model.SetText(base::ASCIIToUTF16("prefix infix suffix"), 13);
+ model.SelectRange({15, 13});
+ model.SelectRange({1, 6}, false); // p[refix] infix [su]ffix
+ // Delete
+ model.Delete(false); // p infix |ffix
+ // Continuous replacement (should not merge)
+ model.SelectRange({8, 9}); // p infix [f]fix
+ model.InsertChar('1'); // p infix 1|fix
+ EXPECT_STR_EQ("p infix 1fix", model.text());
+ EXPECT_FALSE(model.HasSelection());
+ // Edit history should be
+ // p[refix] infix [su]ffix -> p infix |ffix
+ // p infix [f]fix -> p infix 1|fix
+ // Undo 2 times
+ EXPECT_TRUE(model.Undo()); // p infix [f]fix
+ EXPECT_STR_EQ("p infix ffix", model.text());
+ EXPECT_EQ(9U, model.GetCursorPosition());
+ VerifyAllSelectionTexts(&model, {"f"});
+ EXPECT_TRUE(model.Undo()); // p[refix] infix [su]ffix
+ EXPECT_STR_EQ("prefix infix suffix", model.text());
+ EXPECT_EQ(13U, model.GetCursorPosition());
+ VerifyAllSelectionTexts(&model, {"su", "refix"});
+ // Redo 2 times
+ EXPECT_TRUE(model.Redo()); // p infix |ffix
+ EXPECT_STR_EQ("p infix ffix", model.text());
+ EXPECT_EQ(8U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_TRUE(model.Redo()); // p infix 1|fix
+ EXPECT_STR_EQ("p infix 1fix", model.text());
+ EXPECT_EQ(9U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_FALSE(model.Redo());
+
+ // Deletion with secondary selections followed by deletion
+ model.SetText(base::ASCIIToUTF16("prefix infix suffix"), 13);
+ model.SelectRange({15, 13});
+ model.SelectRange({1, 6}, false); // p[refix] infix [su]ffix
+ // Delete
+ model.Delete(false); // p infix |ffix
+ // Continuous delete (should not merge)
+ model.Delete(false); // p infix |fix
+ EXPECT_STR_EQ("p infix fix", model.text());
+ EXPECT_FALSE(model.HasSelection());
+ // Edit history should be
+ // p[refix] infix [su]ffix -> p infix |ffix
+ // p infix |ffix -> p infix |fix
+ // Undo 2 times
+ EXPECT_TRUE(model.Undo()); // p infix |ffix
+ EXPECT_STR_EQ("p infix ffix", model.text());
+ EXPECT_EQ(8U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_TRUE(model.Undo()); // p[refix] infix [su]ffix
+ EXPECT_STR_EQ("prefix infix suffix", model.text());
+ EXPECT_EQ(13U, model.GetCursorPosition());
+ VerifyAllSelectionTexts(&model, {"su", "refix"});
+ // Redo 2 times
+ EXPECT_TRUE(model.Redo()); // p infix |ffix
+ EXPECT_STR_EQ("p infix ffix", model.text());
+ EXPECT_EQ(8U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_TRUE(model.Redo()); // p infix |fix
+ EXPECT_STR_EQ("p infix fix", model.text());
+ EXPECT_EQ(8U, model.GetCursorPosition());
+ EXPECT_FALSE(model.HasSelection());
+ EXPECT_FALSE(model.Redo());
+}
+
// Tests that clipboard text with leading, trailing and interspersed tabs
// spaces etc is pasted correctly. Leading and trailing tabs should be
// stripped. Text separated by multiple tabs/spaces should be left alone.
@@ -1902,7 +2448,7 @@ TEST_F(TextfieldModelTest, Transpose) {
const TestCase& test_case = all_tests[i][j];
- model.SetText(test_strings[i]);
+ model.SetText(test_strings[i], 0);
model.SelectRange(test_case.range);
EXPECT_EQ(test_case.range, model.render_text()->selection());
model.Transpose();
@@ -1915,32 +2461,49 @@ TEST_F(TextfieldModelTest, Transpose) {
TEST_F(TextfieldModelTest, Yank) {
TextfieldModel model(nullptr);
- model.SetText(base::ASCIIToUTF16("abcde"));
+ model.SetText(base::ASCIIToUTF16("abcdefgh"), 0);
model.SelectRange(gfx::Range(1, 3));
// Delete selection but don't add to kill buffer.
model.Delete(false);
- EXPECT_STR_EQ("ade", model.text());
+ EXPECT_STR_EQ("adefgh", model.text());
// Since the kill buffer is empty, yank should cause no change.
- model.Yank();
- EXPECT_STR_EQ("ade", model.text());
+ EXPECT_FALSE(model.Yank());
+ EXPECT_STR_EQ("adefgh", model.text());
+
+ // With a nonempty selection and an empty kill buffer, yank should delete the
+ // selection.
+ model.SelectRange(gfx::Range(4, 5));
+ EXPECT_TRUE(model.Yank());
+ EXPECT_STR_EQ("adefh", model.text());
+
+ // With multiple selections and an empty kill buffer, yank should delete the
+ // selections.
+ model.SelectRange(gfx::Range(2, 3));
+ model.SelectRange(gfx::Range(4, 5), false);
+ EXPECT_TRUE(model.Yank());
+ EXPECT_STR_EQ("adf", model.text());
+
+ // The kill buffer should remain empty after yanking without a kill buffer.
+ EXPECT_FALSE(model.Yank());
+ EXPECT_STR_EQ("adf", model.text());
// Delete selection and add to kill buffer.
model.SelectRange(gfx::Range(0, 1));
model.Delete(true);
- EXPECT_STR_EQ("de", model.text());
+ EXPECT_STR_EQ("df", model.text());
// Yank twice.
- model.Yank();
- model.Yank();
- EXPECT_STR_EQ("aade", model.text());
+ EXPECT_TRUE(model.Yank());
+ EXPECT_TRUE(model.Yank());
+ EXPECT_STR_EQ("aadf", model.text());
// Ensure an empty deletion does not modify the kill buffer.
model.SelectRange(gfx::Range(4));
model.Delete(true);
- model.Yank();
- EXPECT_STR_EQ("aadea", model.text());
+ EXPECT_TRUE(model.Yank());
+ EXPECT_STR_EQ("aadfa", model.text());
// Backspace twice but don't add to kill buffer.
model.Backspace(false);
@@ -1948,7 +2511,7 @@ TEST_F(TextfieldModelTest, Yank) {
EXPECT_STR_EQ("aad", model.text());
// Ensure kill buffer is not modified.
- model.Yank();
+ EXPECT_TRUE(model.Yank());
EXPECT_STR_EQ("aada", model.text());
// Backspace twice, each time modifying the kill buffer.
@@ -1957,13 +2520,13 @@ TEST_F(TextfieldModelTest, Yank) {
EXPECT_STR_EQ("aa", model.text());
// Ensure yanking inserts the modified kill buffer text.
- model.Yank();
+ EXPECT_TRUE(model.Yank());
EXPECT_STR_EQ("aad", model.text());
}
TEST_F(TextfieldModelTest, SetCompositionFromExistingText) {
TextfieldModel model(nullptr);
- model.SetText(base::ASCIIToUTF16("abcde"));
+ model.SetText(base::ASCIIToUTF16("abcde"), 0);
model.SetCompositionFromExistingText(gfx::Range(0, 1));
EXPECT_TRUE(model.HasCompositionText());
@@ -1979,7 +2542,7 @@ TEST_F(TextfieldModelTest, SetCompositionFromExistingText) {
TEST_F(TextfieldModelTest, SetCompositionFromExistingText_Empty) {
TextfieldModel model(nullptr);
- model.SetText(base::ASCIIToUTF16("abc"));
+ model.SetText(base::ASCIIToUTF16("abc"), 0);
model.SetCompositionFromExistingText(gfx::Range(0, 2));
EXPECT_TRUE(model.HasCompositionText());
@@ -1991,12 +2554,12 @@ TEST_F(TextfieldModelTest, SetCompositionFromExistingText_Empty) {
TEST_F(TextfieldModelTest, SetCompositionFromExistingText_OutOfBounds) {
TextfieldModel model(nullptr);
- model.SetText(base::string16());
+ model.SetText(base::string16(), 0);
model.SetCompositionFromExistingText(gfx::Range(0, 2));
EXPECT_FALSE(model.HasCompositionText());
- model.SetText(base::ASCIIToUTF16("abc"));
+ model.SetText(base::ASCIIToUTF16("abc"), 0);
model.SetCompositionFromExistingText(gfx::Range(1, 4));
EXPECT_FALSE(model.HasCompositionText());
}
diff --git a/chromium/ui/views/controls/textfield/textfield_test_api.cc b/chromium/ui/views/controls/textfield/textfield_test_api.cc
index 3f756dfaad7..099f22e9bcf 100644
--- a/chromium/ui/views/controls/textfield/textfield_test_api.cc
+++ b/chromium/ui/views/controls/textfield/textfield_test_api.cc
@@ -31,7 +31,7 @@ void TextfieldTestApi::ResetTouchSelectionController() {
}
void TextfieldTestApi::SetCursorViewRect(gfx::Rect bounds) {
- textfield_->cursor_view_.SetBoundsRect(bounds);
+ textfield_->cursor_view_->SetBoundsRect(bounds);
}
bool TextfieldTestApi::IsTextDirectionCheckedInContextMenu(
@@ -40,4 +40,8 @@ bool TextfieldTestApi::IsTextDirectionCheckedInContextMenu(
textfield_->text_services_context_menu_.get(), direction);
}
+bool TextfieldTestApi::ShouldShowCursor() const {
+ return textfield_->ShouldShowCursor();
+}
+
} // namespace views
diff --git a/chromium/ui/views/controls/textfield/textfield_test_api.h b/chromium/ui/views/controls/textfield/textfield_test_api.h
index 6f0496c5771..3f346da6059 100644
--- a/chromium/ui/views/controls/textfield/textfield_test_api.h
+++ b/chromium/ui/views/controls/textfield/textfield_test_api.h
@@ -46,14 +46,18 @@ class TextfieldTestApi {
return textfield_->cursor_blink_timer_.IsRunning();
}
- gfx::Rect GetCursorViewRect() { return textfield_->cursor_view_.bounds(); }
+ gfx::Rect GetCursorViewRect() { return textfield_->cursor_view_->bounds(); }
void SetCursorViewRect(gfx::Rect bounds);
- bool IsCursorVisible() const { return textfield_->cursor_view_.GetVisible(); }
+ bool IsCursorVisible() const {
+ return textfield_->cursor_view_->GetVisible();
+ }
bool IsTextDirectionCheckedInContextMenu(
base::i18n::TextDirection direction) const;
+ bool ShouldShowCursor() const;
+
private:
Textfield* textfield_;
diff --git a/chromium/ui/views/controls/textfield/textfield_unittest.cc b/chromium/ui/views/controls/textfield/textfield_unittest.cc
index 4a7a614b9d9..456cecaba14 100644
--- a/chromium/ui/views/controls/textfield/textfield_unittest.cc
+++ b/chromium/ui/views/controls/textfield/textfield_unittest.cc
@@ -13,6 +13,7 @@
#include <vector>
#include "base/command_line.h"
+#include "base/feature_list.h"
#include "base/format_macros.h"
#include "base/i18n/rtl.h"
#include "base/pickle.h"
@@ -53,6 +54,7 @@
#include "ui/views/test/test_views_delegate.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/test/widget_test.h"
+#include "ui/views/views_features.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_utils.h"
#include "url/gurl.h"
@@ -779,6 +781,19 @@ class TextfieldTest : public ViewsTestBase, public TextfieldController {
// an event when it updates the cursor position.
void MoveMouseTo(const gfx::Point& where) { mouse_position_ = where; }
+ // Tap on the textfield.
+ void TapAtCursor(ui::EventPointerType pointer_type) {
+ ui::GestureEventDetails tap_down_details(ui::ET_GESTURE_TAP_DOWN);
+ tap_down_details.set_primary_pointer_type(pointer_type);
+ GestureEventForTest tap_down(GetCursorPositionX(0), 0, tap_down_details);
+ textfield_->OnGestureEvent(&tap_down);
+
+ ui::GestureEventDetails tap_up_details(ui::ET_GESTURE_TAP);
+ tap_up_details.set_primary_pointer_type(pointer_type);
+ GestureEventForTest tap_up(GetCursorPositionX(0), 0, tap_up_details);
+ textfield_->OnGestureEvent(&tap_up);
+ }
+
// We need widget to populate wrapper class.
Widget* widget_ = nullptr;
@@ -1155,6 +1170,19 @@ TEST_F(TextfieldTest, MoveParagraphForwardBackwardAndModifySelection) {
#endif
}
+TEST_F(TextfieldTest, ModifySelectionWithMultipleSelections) {
+ InitTextfield();
+ textfield_->SetText(ASCIIToUTF16("0123456 89"));
+ textfield_->SetSelectedRange(gfx::Range(3, 5));
+ textfield_->SetSelectedRange(gfx::Range(8, 9), false);
+
+ test_api_->ExecuteTextEditCommand(
+ ui::TextEditCommand::MOVE_RIGHT_AND_MODIFY_SELECTION);
+ EXPECT_EQ(gfx::Range(3, 6), textfield_->GetSelectedRange());
+ EXPECT_EQ(6U, textfield_->GetCursorPosition());
+ EXPECT_EQ(0U, textfield_->GetSelectionModel().secondary_selections().size());
+}
+
TEST_F(TextfieldTest, InsertionDeletionTest) {
// Insert a test string in a textfield.
InitTextfield();
@@ -1245,6 +1273,36 @@ TEST_F(TextfieldTest, DeletionWithSelection) {
}
}
+// Test that deletion operations behave correctly with multiple selections.
+TEST_F(TextfieldTest, DeletionWithMultipleSelections) {
+ struct {
+ ui::KeyboardCode key;
+ bool shift;
+ } cases[] = {
+ {ui::VKEY_BACK, false},
+ {ui::VKEY_BACK, true},
+ {ui::VKEY_DELETE, false},
+ {ui::VKEY_DELETE, true},
+ };
+
+ InitTextfield();
+ // [Ctrl] ([Alt] on Mac) + [Delete]/[Backspace] should delete the active
+ // selection, regardless of [Shift].
+ for (size_t i = 0; i < base::size(cases); ++i) {
+ SCOPED_TRACE(base::StringPrintf("Testing cases[%" PRIuS "]", i));
+ textfield_->SetText(ASCIIToUTF16("one two three"));
+ // Select: o[ne] [two] th[re]e
+ textfield_->SetSelectedRange(gfx::Range(4, 7));
+ textfield_->SetSelectedRange(gfx::Range(10, 12), false);
+ textfield_->SetSelectedRange(gfx::Range(1, 3), false);
+ SendWordEvent(cases[i].key, cases[i].shift);
+ EXPECT_STR_EQ("o the", textfield_->GetText());
+ EXPECT_EQ(gfx::Range(2), textfield_->GetSelectedRange());
+ EXPECT_EQ(0U,
+ textfield_->GetSelectionModel().secondary_selections().size());
+ }
+}
+
// Test deletions not covered by other tests with key events.
TEST_F(TextfieldTest, DeletionWithEditCommands) {
struct {
@@ -1283,11 +1341,11 @@ TEST_F(TextfieldTest, PasswordTest) {
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, "foo");
// Cut and copy should be disabled.
- EXPECT_FALSE(textfield_->IsCommandIdEnabled(IDS_APP_CUT));
- textfield_->ExecuteCommand(IDS_APP_CUT, 0);
+ EXPECT_FALSE(textfield_->IsCommandIdEnabled(Textfield::kCut));
+ textfield_->ExecuteCommand(Textfield::kCut, 0);
SendKeyEvent(ui::VKEY_X, false, true);
- EXPECT_FALSE(textfield_->IsCommandIdEnabled(IDS_APP_COPY));
- textfield_->ExecuteCommand(IDS_APP_COPY, 0);
+ EXPECT_FALSE(textfield_->IsCommandIdEnabled(Textfield::kCopy));
+ textfield_->ExecuteCommand(Textfield::kCopy, 0);
SendKeyEvent(ui::VKEY_C, false, true);
SendAlternateCopy();
EXPECT_STR_EQ("foo", GetClipboardText(ui::ClipboardBuffer::kCopyPaste));
@@ -1297,8 +1355,8 @@ TEST_F(TextfieldTest, PasswordTest) {
SendKeyEvent(ui::VKEY_DELETE, true, false);
// Paste should work normally.
- EXPECT_TRUE(textfield_->IsCommandIdEnabled(IDS_APP_PASTE));
- textfield_->ExecuteCommand(IDS_APP_PASTE, 0);
+ EXPECT_TRUE(textfield_->IsCommandIdEnabled(Textfield::kPaste));
+ textfield_->ExecuteCommand(Textfield::kPaste, 0);
SendKeyEvent(ui::VKEY_V, false, true);
SendAlternatePaste();
EXPECT_STR_EQ("foo", GetClipboardText(ui::ClipboardBuffer::kCopyPaste));
@@ -1517,6 +1575,42 @@ TEST_F(TextfieldTest, CursorMovement) {
EXPECT_STR_EQ("one two", last_contents_);
}
+TEST_F(TextfieldTest, CursorMovementWithMultipleSelections) {
+ InitTextfield();
+ textfield_->SetText(ASCIIToUTF16("012 456 890 234 678"));
+ // [p] [s]
+ textfield_->SetSelectedRange({4, 7});
+ textfield_->SetSelectedRange({12, 15}, false);
+
+ test_api_->ExecuteTextEditCommand(ui::TextEditCommand::MOVE_LEFT);
+ EXPECT_EQ(gfx::Range(4, 4), textfield_->GetSelectedRange());
+ EXPECT_EQ(0U, textfield_->GetSelectionModel().secondary_selections().size());
+
+ textfield_->SetSelectedRange({4, 7});
+ textfield_->SetSelectedRange({12, 15}, false);
+
+ test_api_->ExecuteTextEditCommand(ui::TextEditCommand::MOVE_RIGHT);
+ EXPECT_EQ(gfx::Range(7, 7), textfield_->GetSelectedRange());
+ EXPECT_EQ(0U, textfield_->GetSelectionModel().secondary_selections().size());
+}
+
+TEST_F(TextfieldTest, ShouldShowCursor) {
+ InitTextfield();
+ textfield_->SetText(ASCIIToUTF16("word1 word2"));
+
+ // should show cursor when there's no primary selection
+ textfield_->SetSelectedRange({4, 4});
+ EXPECT_TRUE(test_api_->ShouldShowCursor());
+ textfield_->SetSelectedRange({1, 3}, false);
+ EXPECT_TRUE(test_api_->ShouldShowCursor());
+
+ // should not show cursor when there's a primary selection
+ textfield_->SetSelectedRange({4, 7});
+ EXPECT_FALSE(test_api_->ShouldShowCursor());
+ textfield_->SetSelectedRange({1, 3}, false);
+ EXPECT_FALSE(test_api_->ShouldShowCursor());
+}
+
TEST_F(TextfieldTest, FocusTraversalTest) {
InitTextfields(3);
textfield_->RequestFocus();
@@ -1760,7 +1854,7 @@ TEST_F(TextfieldTest, DragAndDrop_AcceptDrop) {
bad_data.SetPickledData(fmt, base::Pickle());
bad_data.SetFileContents(base::FilePath(L"x"), "x");
bad_data.SetHtml(base::string16(ASCIIToUTF16("x")), GURL("x.org"));
- ui::OSExchangeData::DownloadFileInfo download(base::FilePath(), nullptr);
+ ui::DownloadFileInfo download(base::FilePath(), nullptr);
bad_data.SetDownloadFileInfo(&download);
EXPECT_FALSE(textfield_->CanDrop(bad_data));
}
@@ -1964,24 +2058,24 @@ TEST_F(TextfieldTest, ReadOnlyTest) {
// Cut should be disabled.
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, "Test");
- EXPECT_FALSE(textfield_->IsCommandIdEnabled(IDS_APP_CUT));
- textfield_->ExecuteCommand(IDS_APP_CUT, 0);
+ EXPECT_FALSE(textfield_->IsCommandIdEnabled(Textfield::kCut));
+ textfield_->ExecuteCommand(Textfield::kCut, 0);
SendKeyEvent(ui::VKEY_X, false, true);
SendAlternateCut();
EXPECT_STR_EQ("Test", GetClipboardText(ui::ClipboardBuffer::kCopyPaste));
EXPECT_STR_EQ("read only", textfield_->GetText());
// Paste should be disabled.
- EXPECT_FALSE(textfield_->IsCommandIdEnabled(IDS_APP_PASTE));
- textfield_->ExecuteCommand(IDS_APP_PASTE, 0);
+ EXPECT_FALSE(textfield_->IsCommandIdEnabled(Textfield::kPaste));
+ textfield_->ExecuteCommand(Textfield::kPaste, 0);
SendKeyEvent(ui::VKEY_V, false, true);
SendAlternatePaste();
EXPECT_STR_EQ("read only", textfield_->GetText());
// Copy should work normally.
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, "Test");
- EXPECT_TRUE(textfield_->IsCommandIdEnabled(IDS_APP_COPY));
- textfield_->ExecuteCommand(IDS_APP_COPY, 0);
+ EXPECT_TRUE(textfield_->IsCommandIdEnabled(Textfield::kCopy));
+ textfield_->ExecuteCommand(Textfield::kCopy, 0);
EXPECT_STR_EQ("read only", GetClipboardText(ui::ClipboardBuffer::kCopyPaste));
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, "Test");
SendKeyEvent(ui::VKEY_C, false, true);
@@ -2297,11 +2391,11 @@ TEST_F(TextfieldTest, Yank) {
TEST_F(TextfieldTest, CutCopyPaste) {
InitTextfield();
- // Ensure IDS_APP_CUT cuts.
+ // Ensure kCut cuts.
textfield_->SetText(ASCIIToUTF16("123"));
textfield_->SelectAll(false);
- EXPECT_TRUE(textfield_->IsCommandIdEnabled(IDS_APP_CUT));
- textfield_->ExecuteCommand(IDS_APP_CUT, 0);
+ EXPECT_TRUE(textfield_->IsCommandIdEnabled(Textfield::kCut));
+ textfield_->ExecuteCommand(Textfield::kCut, 0);
EXPECT_STR_EQ("123", GetClipboardText(ui::ClipboardBuffer::kCopyPaste));
EXPECT_STR_EQ("", textfield_->GetText());
EXPECT_EQ(ui::ClipboardBuffer::kCopyPaste, GetAndResetCopiedToClipboard());
@@ -2337,11 +2431,11 @@ TEST_F(TextfieldTest, CutCopyPaste) {
EXPECT_STR_EQ("123", textfield_->GetText());
EXPECT_EQ(ui::ClipboardBuffer::kMaxValue, GetAndResetCopiedToClipboard());
- // Ensure IDS_APP_COPY copies.
+ // Ensure kCopy copies.
textfield_->SetText(ASCIIToUTF16("789"));
textfield_->SelectAll(false);
- EXPECT_TRUE(textfield_->IsCommandIdEnabled(IDS_APP_COPY));
- textfield_->ExecuteCommand(IDS_APP_COPY, 0);
+ EXPECT_TRUE(textfield_->IsCommandIdEnabled(Textfield::kCopy));
+ textfield_->ExecuteCommand(Textfield::kCopy, 0);
EXPECT_STR_EQ("789", GetClipboardText(ui::ClipboardBuffer::kCopyPaste));
EXPECT_EQ(ui::ClipboardBuffer::kCopyPaste, GetAndResetCopiedToClipboard());
@@ -2363,12 +2457,12 @@ TEST_F(TextfieldTest, CutCopyPaste) {
EXPECT_STR_EQ("345", textfield_->GetText());
EXPECT_EQ(ui::ClipboardBuffer::kCopyPaste, GetAndResetCopiedToClipboard());
- // Ensure IDS_APP_PASTE, [Ctrl]+[V], and [Shift]+[Insert] pastes;
+ // Ensure kPaste, [Ctrl]+[V], and [Shift]+[Insert] pastes;
// also ensure that [Ctrl]+[Alt]+[V] does nothing.
SetClipboardText(ui::ClipboardBuffer::kCopyPaste, "abc");
textfield_->SetText(base::string16());
- EXPECT_TRUE(textfield_->IsCommandIdEnabled(IDS_APP_PASTE));
- textfield_->ExecuteCommand(IDS_APP_PASTE, 0);
+ EXPECT_TRUE(textfield_->IsCommandIdEnabled(Textfield::kPaste));
+ textfield_->ExecuteCommand(Textfield::kPaste, 0);
EXPECT_STR_EQ("abc", textfield_->GetText());
SendKeyEvent(ui::VKEY_V, false, true);
EXPECT_STR_EQ("abcabc", textfield_->GetText());
@@ -3662,12 +3756,7 @@ TEST_F(TextfieldTest, FocusReasonTouchTap) {
EXPECT_EQ(ui::TextInputClient::FOCUS_REASON_NONE,
textfield_->GetFocusReason());
- ui::GestureEventDetails tap_details(ui::ET_GESTURE_TAP_DOWN);
- tap_details.set_primary_pointer_type(
- ui::EventPointerType::POINTER_TYPE_TOUCH);
- GestureEventForTest tap(GetCursorPositionX(0), 0, tap_details);
- textfield_->OnGestureEvent(&tap);
-
+ TapAtCursor(ui::EventPointerType::kTouch);
EXPECT_EQ(ui::TextInputClient::FOCUS_REASON_TOUCH,
textfield_->GetFocusReason());
}
@@ -3678,11 +3767,7 @@ TEST_F(TextfieldTest, FocusReasonPenTap) {
EXPECT_EQ(ui::TextInputClient::FOCUS_REASON_NONE,
textfield_->GetFocusReason());
- ui::GestureEventDetails tap_details(ui::ET_GESTURE_TAP_DOWN);
- tap_details.set_primary_pointer_type(ui::EventPointerType::POINTER_TYPE_PEN);
- GestureEventForTest tap(GetCursorPositionX(0), 0, tap_details);
- textfield_->OnGestureEvent(&tap);
-
+ TapAtCursor(ui::EventPointerType::kPen);
EXPECT_EQ(ui::TextInputClient::FOCUS_REASON_PEN,
textfield_->GetFocusReason());
}
@@ -3693,23 +3778,8 @@ TEST_F(TextfieldTest, FocusReasonMultipleEvents) {
EXPECT_EQ(ui::TextInputClient::FOCUS_REASON_NONE,
textfield_->GetFocusReason());
- // Pen tap, followed by a touch tap
- {
- ui::GestureEventDetails tap_details(ui::ET_GESTURE_TAP_DOWN);
- tap_details.set_primary_pointer_type(
- ui::EventPointerType::POINTER_TYPE_PEN);
- GestureEventForTest tap(GetCursorPositionX(0), 0, tap_details);
- textfield_->OnGestureEvent(&tap);
- }
-
- {
- ui::GestureEventDetails tap_details(ui::ET_GESTURE_TAP_DOWN);
- tap_details.set_primary_pointer_type(
- ui::EventPointerType::POINTER_TYPE_TOUCH);
- GestureEventForTest tap(GetCursorPositionX(0), 0, tap_details);
- textfield_->OnGestureEvent(&tap);
- }
-
+ TapAtCursor(ui::EventPointerType::kPen);
+ TapAtCursor(ui::EventPointerType::kTouch);
EXPECT_EQ(ui::TextInputClient::FOCUS_REASON_PEN,
textfield_->GetFocusReason());
}
@@ -3721,13 +3791,8 @@ TEST_F(TextfieldTest, FocusReasonFocusBlurFocus) {
textfield_->GetFocusReason());
// Pen tap, blur, then programmatic focus.
- ui::GestureEventDetails tap_details(ui::ET_GESTURE_TAP_DOWN);
- tap_details.set_primary_pointer_type(ui::EventPointerType::POINTER_TYPE_PEN);
- GestureEventForTest tap(GetCursorPositionX(0), 0, tap_details);
- textfield_->OnGestureEvent(&tap);
-
+ TapAtCursor(ui::EventPointerType::kPen);
widget_->GetFocusManager()->ClearFocus();
-
textfield_->RequestFocus();
EXPECT_EQ(ui::TextInputClient::FOCUS_REASON_OTHER,
@@ -3737,11 +3802,7 @@ TEST_F(TextfieldTest, FocusReasonFocusBlurFocus) {
TEST_F(TextfieldTest, KeyboardObserverForPenInput) {
InitTextfield();
- ui::GestureEventDetails tap_details(ui::ET_GESTURE_TAP_DOWN);
- tap_details.set_primary_pointer_type(ui::EventPointerType::POINTER_TYPE_PEN);
- GestureEventForTest tap(GetCursorPositionX(0), 0, tap_details);
- textfield_->OnGestureEvent(&tap);
-
+ TapAtCursor(ui::EventPointerType::kPen);
EXPECT_EQ(1, input_method_->count_show_virtual_keyboard());
}
@@ -3796,4 +3857,14 @@ TEST_F(TextfieldTest, TextChangedCallbackTest) {
EXPECT_TRUE(text_changed);
}
+// Tests that invalid characters like non-displayable characters are filtered
+// out when inserted into the text field.
+TEST_F(TextfieldTest, InsertInvalidCharsTest) {
+ InitTextfield();
+
+ textfield_->InsertText(ASCIIToUTF16("\babc\ndef\t"));
+
+ EXPECT_EQ(textfield_->GetText(), ASCIIToUTF16("abcdef"));
+}
+
} // namespace views
diff --git a/chromium/ui/views/controls/tree/tree_view.cc b/chromium/ui/views/controls/tree/tree_view.cc
index 7d26bdf9f58..bd84a3f38d7 100644
--- a/chromium/ui/views/controls/tree/tree_view.cc
+++ b/chromium/ui/views/controls/tree/tree_view.cc
@@ -41,7 +41,6 @@
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/controls/tree/tree_view_controller.h"
-#include "ui/views/layout/layout_provider.h"
#include "ui/views/style/platform_style.h"
#include "ui/views/vector_icons.h"
@@ -193,14 +192,7 @@ void TreeView::StartEditing(TreeModelNode* node) {
DCHECK(!editing_);
editing_ = true;
if (!editor_) {
- LayoutProvider* provider = LayoutProvider::Get();
- gfx::Insets text_insets(
- provider->GetDistanceMetric(DISTANCE_CONTROL_VERTICAL_TEXT_PADDING),
- provider->GetDistanceMetric(
- DISTANCE_TEXTFIELD_HORIZONTAL_TEXT_PADDING));
editor_ = new Textfield;
- editor_->SetBorder(views::CreatePaddedBorder(
- views::CreateSolidBorder(1, gfx::kGoogleBlue700), text_insets));
// Add the editor immediately as GetPreferredSize returns the wrong thing if
// not parented.
AddChildView(editor_);
@@ -895,7 +887,7 @@ void TreeView::PopulateAccessibilityData(InternalNode* node,
} else {
// !IsRoot(node)) && node->parent() != nullptr.
- if (node->parent()->is_expanded()) {
+ if (IsExpanded(node->parent()->model_node())) {
int depth = 0;
row = GetRowForInternalNode(node, &depth);
if (depth >= 0) {
@@ -922,7 +914,6 @@ void TreeView::PopulateAccessibilityData(InternalNode* node,
data->AddAction(ax::mojom::Action::kFocus);
data->AddAction(ax::mojom::Action::kScrollToMakeVisible);
gfx::Rect node_bounds = GetBackgroundBoundsForNode(node);
- View::ConvertRectToScreen(this, &node_bounds);
data->relative_bounds.bounds = gfx::RectF(node_bounds);
} else {
data->AddState(ax::mojom::State::kInvisible);
diff --git a/chromium/ui/views/controls/tree/tree_view.h b/chromium/ui/views/controls/tree/tree_view.h
index 89c559a3bfb..b03b860f7b2 100644
--- a/chromium/ui/views/controls/tree/tree_view.h
+++ b/chromium/ui/views/controls/tree/tree_view.h
@@ -134,7 +134,7 @@ class VIEWS_EXPORT TreeView : public View,
// Maps a node to a row, returns -1 if node is not valid.
int GetRowForNode(ui::TreeModelNode* node);
- views::Textfield* editor() { return editor_; }
+ Textfield* editor() { return editor_; }
// Replaces this TreeView's TreeViewDrawingProvider with |provider|.
void SetDrawingProvider(std::unique_ptr<TreeViewDrawingProvider> provider);
diff --git a/chromium/ui/views/controls/views_text_services_context_menu.cc b/chromium/ui/views/controls/views_text_services_context_menu.cc
index 5e1559e61bc..0cebc532c69 100644
--- a/chromium/ui/views/controls/views_text_services_context_menu.cc
+++ b/chromium/ui/views/controls/views_text_services_context_menu.cc
@@ -6,7 +6,7 @@
#include <memory>
-#include "base/logging.h"
+#include "base/notreached.h"
#include "ui/views/controls/views_text_services_context_menu_base.h"
namespace views {
diff --git a/chromium/ui/views/controls/webview/BUILD.gn b/chromium/ui/views/controls/webview/BUILD.gn
index b52fdbf769a..66ba75adfcc 100644
--- a/chromium/ui/views/controls/webview/BUILD.gn
+++ b/chromium/ui/views/controls/webview/BUILD.gn
@@ -59,7 +59,7 @@ jumbo_component("webview") {
"//ui/views",
]
- if (is_linux || is_android) {
+ if (is_linux || is_android || is_fuchsia) {
sources += [ "unhandled_keyboard_event_handler_default.cc" ]
}
}
diff --git a/chromium/ui/views/controls/webview/unhandled_keyboard_event_handler.cc b/chromium/ui/views/controls/webview/unhandled_keyboard_event_handler.cc
index 85a1cc6e07a..cff5956b04a 100644
--- a/chromium/ui/views/controls/webview/unhandled_keyboard_event_handler.cc
+++ b/chromium/ui/views/controls/webview/unhandled_keyboard_event_handler.cc
@@ -23,7 +23,7 @@ bool UnhandledKeyboardEventHandler::HandleKeyboardEvent(
// Previous calls to TranslateMessage can generate Char events as well as
// RawKeyDown events, even if the latter triggered an accelerator. In these
// cases, we discard the Char events.
- if (event.GetType() == blink::WebInputEvent::kChar &&
+ if (event.GetType() == blink::WebInputEvent::Type::kChar &&
ignore_next_char_event_) {
ignore_next_char_event_ = false;
return false;
@@ -32,7 +32,7 @@ bool UnhandledKeyboardEventHandler::HandleKeyboardEvent(
// always generate a Char event.
ignore_next_char_event_ = false;
- if (event.GetType() == blink::WebInputEvent::kRawKeyDown) {
+ if (event.GetType() == blink::WebInputEvent::Type::kRawKeyDown) {
ui::Accelerator accelerator =
ui::GetAcceleratorFromNativeWebKeyboardEvent(event);
diff --git a/chromium/ui/views/controls/webview/web_dialog_view.cc b/chromium/ui/views/controls/webview/web_dialog_view.cc
index a8dab41a057..f8c7d7670ef 100644
--- a/chromium/ui/views/controls/webview/web_dialog_view.cc
+++ b/chromium/ui/views/controls/webview/web_dialog_view.cc
@@ -387,13 +387,14 @@ content::WebContents* WebDialogView::OpenURLFromTab(
void WebDialogView::AddNewContents(
content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
+ const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
bool* was_blocked) {
- WebDialogWebContentsDelegate::AddNewContents(source, std::move(new_contents),
- disposition, initial_rect,
- user_gesture, was_blocked);
+ WebDialogWebContentsDelegate::AddNewContents(
+ source, std::move(new_contents), target_url, disposition, initial_rect,
+ user_gesture, was_blocked);
}
void WebDialogView::LoadingStateChanged(content::WebContents* source,
diff --git a/chromium/ui/views/controls/webview/web_dialog_view.h b/chromium/ui/views/controls/webview/web_dialog_view.h
index b2c7fed8463..5b04647c4a3 100644
--- a/chromium/ui/views/controls/webview/web_dialog_view.h
+++ b/chromium/ui/views/controls/webview/web_dialog_view.h
@@ -140,6 +140,7 @@ class WEBVIEW_EXPORT WebDialogView : public ClientView,
const content::OpenURLParams& params) override;
void AddNewContents(content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
+ const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
diff --git a/chromium/ui/views/controls/webview/web_dialog_view_unittest.cc b/chromium/ui/views/controls/webview/web_dialog_view_unittest.cc
index ceb97226b3d..cb149be77fa 100644
--- a/chromium/ui/views/controls/webview/web_dialog_view_unittest.cc
+++ b/chromium/ui/views/controls/webview/web_dialog_view_unittest.cc
@@ -14,6 +14,7 @@
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_browser_context.h"
+#include "content/public/test/test_renderer_host.h"
#include "content/test/test_content_browser_client.h"
#include "content/test/test_web_contents.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -127,6 +128,7 @@ class WebDialogViewUnitTest : public views::test::WidgetTest {
}
private:
+ content::RenderViewHostTestEnabler test_render_host_factories_;
content::TestContentBrowserClient test_browser_client_;
std::unique_ptr<content::TestBrowserContext> browser_context_;
// These are raw pointers (vs unique pointers) because the views
diff --git a/chromium/ui/views/corewm/DEPS b/chromium/ui/views/corewm/DEPS
index 1ce5357a428..059e550da2c 100644
--- a/chromium/ui/views/corewm/DEPS
+++ b/chromium/ui/views/corewm/DEPS
@@ -23,7 +23,7 @@ specific_include_rules = {
"desktop_capture_controller_unittest.cc": [
"+ui/views/test/native_widget_factory.h",
- "+ui/views/test/views_interactive_ui_test_base.h",
+ "+ui/views/test/widget_test.h",
"+ui/views/view.h",
"+ui/views/widget/desktop_aura/desktop_native_widget_aura.h",
"+ui/views/widget/desktop_aura/desktop_screen_position_client.h",
diff --git a/chromium/ui/views/corewm/desktop_capture_controller_unittest.cc b/chromium/ui/views/corewm/desktop_capture_controller_unittest.cc
index 2e4d5119392..d04c5baca0b 100644
--- a/chromium/ui/views/corewm/desktop_capture_controller_unittest.cc
+++ b/chromium/ui/views/corewm/desktop_capture_controller_unittest.cc
@@ -4,7 +4,6 @@
#include <memory>
-#include "base/logging.h"
#include "base/macros.h"
#include "ui/aura/env.h"
#include "ui/aura/test/test_window_delegate.h"
@@ -13,7 +12,7 @@
#include "ui/events/event.h"
#include "ui/events/test/event_generator.h"
#include "ui/views/test/native_widget_factory.h"
-#include "ui/views/test/views_interactive_ui_test_base.h"
+#include "ui/views/test/widget_test.h"
#include "ui/views/view.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/desktop_aura/desktop_screen_position_client.h"
@@ -26,7 +25,7 @@
namespace views {
-using DesktopCaptureControllerTest = ViewsInteractiveUITestBase;
+using DesktopCaptureControllerTest = test::DesktopWidgetTestInteractive;
// This class provides functionality to verify whether the View instance
// received the gesture event.
@@ -103,7 +102,7 @@ TEST_F(DesktopCaptureControllerTest, CaptureWindowInputEventTest) {
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(50, 50, 650, 650);
params.native_widget = test::CreatePlatformNativeWidgetImpl(
- params, widget1.get(), test::kStubCapture, nullptr);
+ widget1.get(), test::kStubCapture, nullptr);
widget1->Init(std::move(params));
internal::RootView* root1 =
static_cast<internal::RootView*>(widget1->GetRootView());
@@ -125,7 +124,7 @@ TEST_F(DesktopCaptureControllerTest, CaptureWindowInputEventTest) {
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.bounds = gfx::Rect(50, 50, 650, 650);
params.native_widget = test::CreatePlatformNativeWidgetImpl(
- params, widget2.get(), test::kStubCapture, nullptr);
+ widget2.get(), test::kStubCapture, nullptr);
widget2->Init(std::move(params));
internal::RootView* root2 =
diff --git a/chromium/ui/views/corewm/tooltip_aura.cc b/chromium/ui/views/corewm/tooltip_aura.cc
index c115ea2bf2d..2ae616b9896 100644
--- a/chromium/ui/views/corewm/tooltip_aura.cc
+++ b/chromium/ui/views/corewm/tooltip_aura.cc
@@ -54,8 +54,7 @@ bool CanUseTranslucentTooltipWidget() {
}
// Creates a widget of type TYPE_TOOLTIP
-views::Widget* CreateTooltipWidget(aura::Window* tooltip_window,
- const gfx::Rect& bounds) {
+views::Widget* CreateTooltipWidget(aura::Window* tooltip_window) {
views::Widget* widget = new views::Widget;
views::Widget::InitParams params;
// For aura, since we set the type to TYPE_TOOLTIP, the widget will get
@@ -65,7 +64,6 @@ views::Widget* CreateTooltipWidget(aura::Window* tooltip_window,
DCHECK(params.context);
params.z_order = ui::ZOrderLevel::kFloatingUIElement;
params.accept_events = false;
- params.bounds = bounds;
if (CanUseTranslucentTooltipWidget())
params.opacity = views::Widget::InitParams::WindowOpacity::kTranslucent;
params.shadow_type = views::Widget::InitParams::ShadowType::kNone;
@@ -237,15 +235,10 @@ void TooltipAura::SetText(aura::Window* window,
tooltip_view_->SetMaxWidth(GetMaxWidth(location));
tooltip_view_->SetText(tooltip_text);
- const gfx::Rect adjusted_bounds =
- GetTooltipBounds(location, tooltip_view_->GetPreferredSize());
-
if (!widget_) {
- widget_ = CreateTooltipWidget(tooltip_window_, adjusted_bounds);
+ widget_ = CreateTooltipWidget(tooltip_window_);
widget_->SetContentsView(tooltip_view_.get());
widget_->AddObserver(this);
- } else {
- widget_->SetBounds(adjusted_bounds);
}
ui::NativeTheme* native_theme = widget_->GetNativeTheme();
@@ -263,6 +256,17 @@ void TooltipAura::SetText(aura::Window* window,
color_utils::GetResultingPaintColor(foreground_color, background_color);
tooltip_view_->SetBackgroundColor(background_color, foreground_color);
tooltip_view_->SetForegroundColor(foreground_color);
+
+ // Calculate the tooltip preferred size after all tooltip attributes are
+ // updated - tooltip updates (for example setting text color) may invalidate
+ // the tooltip render text layout, which would make layout run just done to
+ // calculate the tooltip string size get immendiately disregarded.
+ // This also addresses https://crbug.com/2181825 (after color update,
+ // GetPreferredSize() will generate fresh render text layout, even if the
+ // actual tooltip text hasn't changed).
+ const gfx::Rect adjusted_bounds =
+ GetTooltipBounds(location, tooltip_view_->GetPreferredSize());
+ widget_->SetBounds(adjusted_bounds);
}
void TooltipAura::Show() {
diff --git a/chromium/ui/views/corewm/tooltip_controller.cc b/chromium/ui/views/corewm/tooltip_controller.cc
index 5b911f138a5..c19d2296ff9 100644
--- a/chromium/ui/views/corewm/tooltip_controller.cc
+++ b/chromium/ui/views/corewm/tooltip_controller.cc
@@ -141,9 +141,12 @@ int TooltipController::GetMaxWidth(const gfx::Point& location) const {
}
void TooltipController::UpdateTooltip(aura::Window* target) {
- // If tooltip is visible, we may want to hide it. If it is not, we are ok.
- if (tooltip_window_ == target && tooltip_->IsVisible())
+ // Ensure relevant tooltip is updated when it is visible or scheduled to
+ // show. Otherwise, a stale tooltip might be shown.
+ if (tooltip_window_ == target &&
+ (tooltip_->IsVisible() || tooltip_defer_timer_.IsRunning())) {
UpdateIfRequired();
+ }
// Reset |tooltip_window_at_mouse_press_| if the moving within the same window
// but over a region that has different tooltip text.
diff --git a/chromium/ui/views/corewm/tooltip_controller_test_helper.cc b/chromium/ui/views/corewm/tooltip_controller_test_helper.cc
index ebe66420ebe..d64125582fe 100644
--- a/chromium/ui/views/corewm/tooltip_controller_test_helper.cc
+++ b/chromium/ui/views/corewm/tooltip_controller_test_helper.cc
@@ -44,6 +44,11 @@ bool TooltipControllerTestHelper::IsTooltipVisible() {
return controller_->IsTooltipVisible();
}
+void TooltipControllerTestHelper::SetTooltipShowDelayEnable(
+ bool tooltip_show_delay) {
+ controller_->tooltip_show_delayed_ = tooltip_show_delay;
+}
+
TooltipTestView::TooltipTestView() = default;
TooltipTestView::~TooltipTestView() = default;
diff --git a/chromium/ui/views/corewm/tooltip_controller_test_helper.h b/chromium/ui/views/corewm/tooltip_controller_test_helper.h
index e62aaad9f23..3c2909548f2 100644
--- a/chromium/ui/views/corewm/tooltip_controller_test_helper.h
+++ b/chromium/ui/views/corewm/tooltip_controller_test_helper.h
@@ -38,6 +38,7 @@ class TooltipControllerTestHelper {
void FireTooltipShownTimer();
bool IsTooltipShownTimerRunning();
bool IsTooltipVisible();
+ void SetTooltipShowDelayEnable(bool tooltip_show_delay);
private:
TooltipController* controller_;
diff --git a/chromium/ui/views/corewm/tooltip_controller_unittest.cc b/chromium/ui/views/corewm/tooltip_controller_unittest.cc
index eee55c8bb63..30ba48c792c 100644
--- a/chromium/ui/views/corewm/tooltip_controller_unittest.cc
+++ b/chromium/ui/views/corewm/tooltip_controller_unittest.cc
@@ -325,6 +325,36 @@ TEST_F(TooltipControllerTest, DontShowEmptyTooltips) {
EXPECT_FALSE(helper_->IsTooltipVisible());
}
+TEST_F(TooltipControllerTest, TooltipUpdateWhenTooltipDeferTimerIsRunning) {
+ view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text for view 1"));
+ EXPECT_EQ(base::string16(), helper_->GetTooltipText());
+ EXPECT_EQ(nullptr, helper_->GetTooltipWindow());
+
+ TooltipTestView* view2 = PrepareSecondView();
+ view2->set_tooltip_text(ASCIIToUTF16("Tooltip Text for view 2"));
+
+ aura::Window* window = GetWindow();
+
+ // Tooltips show up with delay
+ helper_->SetTooltipShowDelayEnable(true);
+
+ // Tooltip 1 is scheduled and invisibled
+ generator_->MoveMouseRelativeTo(window, view_->bounds().CenterPoint());
+ EXPECT_FALSE(helper_->IsTooltipVisible());
+ EXPECT_FALSE(helper_->IsTooltipShownTimerRunning());
+
+ // Tooltip 2 is scheduled and invisible, the expected tooltip is tooltip 2
+ generator_->MoveMouseRelativeTo(window, view2->bounds().CenterPoint());
+ EXPECT_FALSE(helper_->IsTooltipVisible());
+ EXPECT_FALSE(helper_->IsTooltipShownTimerRunning());
+ base::string16 expected_tooltip = ASCIIToUTF16("Tooltip Text for view 2");
+ EXPECT_EQ(expected_tooltip, wm::GetTooltipText(window));
+ EXPECT_EQ(expected_tooltip, helper_->GetTooltipText());
+ EXPECT_EQ(window, helper_->GetTooltipWindow());
+
+ helper_->SetTooltipShowDelayEnable(false);
+}
+
TEST_F(TooltipControllerTest, TooltipHidesOnKeyPressAndStaysHiddenUntilChange) {
view_->set_tooltip_text(ASCIIToUTF16("Tooltip Text for view 1"));
EXPECT_EQ(base::string16(), helper_->GetTooltipText());
diff --git a/chromium/ui/views/debug_utils.cc b/chromium/ui/views/debug_utils.cc
index d176fd40a8e..63355b3b6f4 100644
--- a/chromium/ui/views/debug_utils.cc
+++ b/chromium/ui/views/debug_utils.cc
@@ -144,12 +144,16 @@ std::string PrintViewGraphImpl(const View* view) {
void PrintViewHierarchy(const View* view) {
std::ostringstream out;
- out << "View hierarchy:\n";
- PrintViewHierarchyImp(view, 0, &out);
+ PrintViewHierarchy(view, &out);
// Error so users in the field can generate and upload logs.
LOG(ERROR) << out.str();
}
+void PrintViewHierarchy(const View* view, std::ostringstream* out) {
+ *out << "View hierarchy:\n";
+ PrintViewHierarchyImp(view, 0, out);
+}
+
void PrintFocusHierarchy(const View* view) {
std::ostringstream out;
out << "Focus hierarchy:\n";
diff --git a/chromium/ui/views/debug_utils.h b/chromium/ui/views/debug_utils.h
index 3051359a207..6d0d9cd0d54 100644
--- a/chromium/ui/views/debug_utils.h
+++ b/chromium/ui/views/debug_utils.h
@@ -16,6 +16,9 @@ class View;
// Log the view hierarchy.
VIEWS_EXPORT void PrintViewHierarchy(const View* view);
+// Print the view hierarchy to |out|.
+VIEWS_EXPORT void PrintViewHierarchy(const View* view, std::ostringstream* out);
+
// Log the focus traversal hierarchy.
VIEWS_EXPORT void PrintFocusHierarchy(const View* view);
diff --git a/chromium/ui/views/event_monitor_aura.cc b/chromium/ui/views/event_monitor_aura.cc
index 8ea72524463..69edc44bc48 100644
--- a/chromium/ui/views/event_monitor_aura.cc
+++ b/chromium/ui/views/event_monitor_aura.cc
@@ -6,7 +6,7 @@
#include <memory>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/scoped_observer.h"
#include "ui/aura/env.h"
#include "ui/aura/window.h"
diff --git a/chromium/ui/views/event_monitor_mac.mm b/chromium/ui/views/event_monitor_mac.mm
index cfa72698b19..d16287300d9 100644
--- a/chromium/ui/views/event_monitor_mac.mm
+++ b/chromium/ui/views/event_monitor_mac.mm
@@ -6,7 +6,7 @@
#import <Cocoa/Cocoa.h>
-#include "base/logging.h"
+#include "base/check.h"
#include "base/memory/ptr_util.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
diff --git a/chromium/ui/views/examples/BUILD.gn b/chromium/ui/views/examples/BUILD.gn
index d2223b73a62..ba6f3d7603c 100644
--- a/chromium/ui/views/examples/BUILD.gn
+++ b/chromium/ui/views/examples/BUILD.gn
@@ -4,6 +4,8 @@
import("//build/config/jumbo.gni")
import("//build/config/ui.gni")
+import("//testing/test.gni")
+import("//tools/grit/grit_rule.gni")
jumbo_component("views_examples_lib") {
testonly = true
@@ -21,8 +23,12 @@ jumbo_component("views_examples_lib") {
"button_sticker_sheet.h",
"checkbox_example.cc",
"checkbox_example.h",
+ "colored_dialog_example.cc",
+ "colored_dialog_example.h",
"combobox_example.cc",
"combobox_example.h",
+ "create_examples.cc",
+ "create_examples.h",
"dialog_example.cc",
"dialog_example.h",
"example_base.cc",
@@ -39,6 +45,8 @@ jumbo_component("views_examples_lib") {
"layout_example_base.h",
"link_example.cc",
"link_example.h",
+ "login_bubble_dialog.cc",
+ "login_bubble_dialog.h",
"menu_example.cc",
"menu_example.h",
"message_box_example.cc",
@@ -85,6 +93,8 @@ jumbo_component("views_examples_lib") {
]
deps = [
+ ":views_examples_resources_grd",
+ ":views_examples_resources_pak",
"//base",
"//cc/paint",
"//skia",
@@ -96,6 +106,7 @@ jumbo_component("views_examples_lib") {
"//ui/native_theme",
"//ui/resources",
"//ui/resources:ui_test_pak",
+ "//ui/strings:ui_strings",
"//ui/views",
]
@@ -108,32 +119,47 @@ jumbo_component("views_examples_lib") {
}
}
-executable("views_examples_exe") {
+source_set("views_examples_proc") {
testonly = true
- sources = [ "examples_main.cc" ]
+ sources = [
+ "examples_exit_code.h",
+ "examples_main_proc.cc",
+ "examples_main_proc.h",
+ ]
deps = [
":views_examples_lib",
"//base",
- "//base:i18n",
"//base/test:test_support",
- "//build/win:default_exe_manifest",
+ "//cc/paint",
"//components/viz/host",
"//components/viz/service",
"//mojo/core/embedder",
+ "//skia",
"//ui/base",
- "//ui/base/ime/init",
"//ui/compositor",
"//ui/compositor:test_support",
"//ui/gfx",
- "//ui/gl",
- "//ui/gl/init",
- "//ui/resources:ui_test_pak",
"//ui/views",
"//ui/views:test_support",
]
+ if (is_win || is_mac || (is_linux && !is_chromeos)) {
+ sources += [
+ "examples_skia_gold_pixel_diff.cc",
+ "examples_skia_gold_pixel_diff.h",
+ ]
+ deps += [
+ "//ui/base:pixel_diff_test_support",
+ "//ui/snapshot",
+ ]
+ }
+
+ if (is_win) {
+ deps += [ "//build/win:default_exe_manifest" ]
+ }
+
if (use_aura) {
deps += [
"//ui/aura",
@@ -145,6 +171,21 @@ executable("views_examples_exe") {
}
}
+executable("views_examples") {
+ testonly = true
+
+ sources = [ "examples_main.cc" ]
+
+ deps = [
+ ":views_examples_lib",
+ ":views_examples_proc",
+ "//base",
+ "//base/test:test_support",
+ "//build/win:default_exe_manifest",
+ "//ui/resources:ui_test_pak",
+ ]
+}
+
jumbo_component("views_examples_with_content_lib") {
testonly = true
sources = [
@@ -159,6 +200,8 @@ jumbo_component("views_examples_with_content_lib") {
deps = [
":views_examples_lib",
+ ":views_examples_resources_grd",
+ ":views_examples_resources_pak",
"//base",
"//content",
"//skia",
@@ -169,10 +212,10 @@ jumbo_component("views_examples_with_content_lib") {
]
}
-executable("views_examples_with_content_exe") {
+executable("views_examples_with_content") {
testonly = true
- sources = [ "examples_with_content_main_exe.cc" ]
+ sources = [ "examples_with_content_main.cc" ]
defines = [ "VIEWS_EXAMPLES_WITH_CONTENT_IMPLEMENTATION" ]
@@ -191,6 +234,10 @@ executable("views_examples_with_content_exe") {
configs += [ "//build/config/win:windowed" ]
configs -= [ "//build/config/win:console" ]
}
+
+ if (is_mac) {
+ deps += [ "//sandbox/mac:seatbelt" ]
+ }
}
copy("copy_content_resources") {
@@ -198,3 +245,61 @@ copy("copy_content_resources") {
sources = [ "$root_gen_dir/content/content_resources.pak" ]
outputs = [ "$root_out_dir/content_resources.pak" ]
}
+
+grit("views_examples_resources_grd") {
+ testonly = true
+ source = "views_examples_resources.grd"
+ outputs = [
+ "grit/views_examples_resources.h",
+ "views_examples_resources.pak",
+ ]
+}
+
+copy("views_examples_resources_pak") {
+ testonly = true
+ sources = [ "$target_gen_dir/views_examples_resources.pak" ]
+ outputs = [ "$root_out_dir/views_examples_resources.pak" ]
+ public_deps = [ ":views_examples_resources_grd" ]
+}
+
+test("views_examples_unittests") {
+ sources = [
+ "examples_unittest.cc",
+ "examples_unittest_main.cc",
+ ]
+
+ deps = [
+ ":views_examples_lib",
+ ":views_examples_proc",
+ "//base",
+ "//base/test:test_support",
+ "//components/viz/host",
+ "//components/viz/service",
+ "//mojo/core/embedder",
+ "//ui/base",
+ "//ui/base/ime/init",
+ "//ui/compositor",
+ "//ui/compositor:test_support",
+ "//ui/gfx",
+ "//ui/gl",
+ "//ui/gl/init",
+ "//ui/resources:ui_test_pak",
+ "//ui/snapshot",
+ "//ui/views",
+ "//ui/views:test_support",
+ ]
+
+ if (use_aura) {
+ deps += [
+ "//ui/aura",
+ "//ui/wm",
+ ]
+ }
+
+ data_deps = [
+ ":views_examples_resources_pak",
+ "//ui/resources:ui_test_pak_data",
+ ]
+
+ data = [ "$root_out_dir/views_examples_resources.pak" ]
+}
diff --git a/chromium/ui/views/examples/DEPS b/chromium/ui/views/examples/DEPS
index 7d637be55cc..cf9717c4951 100644
--- a/chromium/ui/views/examples/DEPS
+++ b/chromium/ui/views/examples/DEPS
@@ -1,4 +1,5 @@
include_rules = [
+ "+components/viz/common/features.h",
"+components/viz/host",
"+components/viz/service", # In-process viz service.
"+content/public",
@@ -7,5 +8,6 @@ include_rules = [
"+sandbox",
"+ui/gl/gl_switches.h", # Disable Direct Composition Workaround.
"+ui/gl/init/gl_factory.h", # To initialize GL bindings.
+ "+ui/snapshot", # Enable Skia Gold testing
"+ui/views_content_client",
]
diff --git a/chromium/ui/views/examples/box_layout_example.cc b/chromium/ui/views/examples/box_layout_example.cc
index 61c39340f07..92665320bf8 100644
--- a/chromium/ui/views/examples/box_layout_example.cc
+++ b/chromium/ui/views/examples/box_layout_example.cc
@@ -38,25 +38,25 @@ void BoxLayoutExample::CreateAdditionalControls(int vertical_pos) {
static const char* cross_axis_values[4] = {"Stretch", "Start", "Center",
"End"};
- orientation_ = CreateCombobox(base::ASCIIToUTF16("Orientation"),
- orientation_values, 2, &vertical_pos);
- main_axis_alignment_ = CreateCombobox(base::ASCIIToUTF16("Main axis"),
- main_axis_values, 3, &vertical_pos);
- cross_axis_alignment_ = CreateCombobox(base::ASCIIToUTF16("Cross axis"),
- cross_axis_values, 4, &vertical_pos);
+ orientation_ = CreateAndAddCombobox(base::ASCIIToUTF16("Orientation"),
+ orientation_values, 2, &vertical_pos);
+ main_axis_alignment_ = CreateAndAddCombobox(
+ base::ASCIIToUTF16("Main axis"), main_axis_values, 3, &vertical_pos);
+ cross_axis_alignment_ = CreateAndAddCombobox(
+ base::ASCIIToUTF16("Cross axis"), cross_axis_values, 4, &vertical_pos);
between_child_spacing_ =
- CreateTextfield(base::ASCIIToUTF16("Child spacing"), &vertical_pos);
+ CreateAndAddTextfield(base::ASCIIToUTF16("Child spacing"), &vertical_pos);
default_flex_ =
- CreateTextfield(base::ASCIIToUTF16("Default flex"), &vertical_pos);
- min_cross_axis_size_ =
- CreateTextfield(base::ASCIIToUTF16("Min cross axis"), &vertical_pos);
+ CreateAndAddTextfield(base::ASCIIToUTF16("Default flex"), &vertical_pos);
+ min_cross_axis_size_ = CreateAndAddTextfield(
+ base::ASCIIToUTF16("Min cross axis"), &vertical_pos);
CreateMarginsTextFields(base::ASCIIToUTF16("Insets"), &border_insets_,
&vertical_pos);
- collapse_margins_ =
- CreateCheckbox(base::ASCIIToUTF16("Collapse margins"), &vertical_pos);
+ collapse_margins_ = CreateAndAddCheckbox(
+ base::ASCIIToUTF16("Collapse margins"), &vertical_pos);
UpdateLayoutManager();
}
diff --git a/chromium/ui/views/examples/bubble_example.cc b/chromium/ui/views/examples/bubble_example.cc
index f7877482ecd..040cb595a18 100644
--- a/chromium/ui/views/examples/bubble_example.cc
+++ b/chromium/ui/views/examples/bubble_example.cc
@@ -78,7 +78,7 @@ class ExampleBubble : public BubbleDialogDelegateView {
void Init() override {
SetLayoutManager(std::make_unique<BoxLayout>(
BoxLayout::Orientation::kVertical, gfx::Insets(50)));
- AddChildView(new Label(GetArrowName(arrow())));
+ AddChildView(std::make_unique<Label>(GetArrowName(arrow())));
}
private:
@@ -94,18 +94,18 @@ BubbleExample::~BubbleExample() = default;
void BubbleExample::CreateExampleView(View* container) {
container->SetLayoutManager(std::make_unique<BoxLayout>(
BoxLayout::Orientation::kHorizontal, gfx::Insets(), 10));
- no_shadow_ = new LabelButton(this, ASCIIToUTF16("No Shadow"));
- container->AddChildView(no_shadow_);
- no_shadow_opaque_ = new LabelButton(this, ASCIIToUTF16("Opaque Border"));
- container->AddChildView(no_shadow_opaque_);
- big_shadow_ = new LabelButton(this, ASCIIToUTF16("Big Shadow"));
- container->AddChildView(big_shadow_);
- small_shadow_ = new LabelButton(this, ASCIIToUTF16("Small Shadow"));
- container->AddChildView(small_shadow_);
- no_assets_ = new LabelButton(this, ASCIIToUTF16("No Assets"));
- container->AddChildView(no_assets_);
- persistent_ = new LabelButton(this, ASCIIToUTF16("Persistent"));
- container->AddChildView(persistent_);
+ no_shadow_ = container->AddChildView(
+ std::make_unique<LabelButton>(this, ASCIIToUTF16("No Shadow")));
+ no_shadow_opaque_ = container->AddChildView(
+ std::make_unique<LabelButton>(this, ASCIIToUTF16("Opaque Border")));
+ big_shadow_ = container->AddChildView(
+ std::make_unique<LabelButton>(this, ASCIIToUTF16("Big Shadow")));
+ small_shadow_ = container->AddChildView(
+ std::make_unique<LabelButton>(this, ASCIIToUTF16("Small Shadow")));
+ no_assets_ = container->AddChildView(
+ std::make_unique<LabelButton>(this, ASCIIToUTF16("No Assets")));
+ persistent_ = container->AddChildView(
+ std::make_unique<LabelButton>(this, ASCIIToUTF16("Persistent")));
}
void BubbleExample::ButtonPressed(Button* sender, const ui::Event& event) {
diff --git a/chromium/ui/views/examples/button_sticker_sheet.cc b/chromium/ui/views/examples/button_sticker_sheet.cc
index 8fca38898e1..1780375bb8b 100644
--- a/chromium/ui/views/examples/button_sticker_sheet.cc
+++ b/chromium/ui/views/examples/button_sticker_sheet.cc
@@ -33,7 +33,8 @@ GridLayout* MakeStretchyGridLayout(View* host, int ncols) {
const GridLayout::Alignment kColumnStretchesHorizontally = GridLayout::FILL;
const GridLayout::Alignment kColumnStretchesVertically = GridLayout::FILL;
const float kColumnDoesNotResize = 0.0;
- const GridLayout::SizeType kColumnUsesFixedSize = GridLayout::FIXED;
+ const GridLayout::ColumnSize kColumnUsesFixedSize =
+ GridLayout::ColumnSize::kFixed;
const int kColumnWidth = 96;
GridLayout* layout =
diff --git a/chromium/ui/views/examples/checkbox_example.cc b/chromium/ui/views/examples/checkbox_example.cc
index 953115abec5..676f0f79cc7 100644
--- a/chromium/ui/views/examples/checkbox_example.cc
+++ b/chromium/ui/views/examples/checkbox_example.cc
@@ -21,9 +21,9 @@ CheckboxExample::CheckboxExample() : ExampleBase("Checkbox") {}
CheckboxExample::~CheckboxExample() = default;
void CheckboxExample::CreateExampleView(View* container) {
- button_ = new Checkbox(base::ASCIIToUTF16("Checkbox"), this);
container->SetLayoutManager(std::make_unique<FillLayout>());
- container->AddChildView(button_);
+ button_ = container->AddChildView(
+ std::make_unique<Checkbox>(base::ASCIIToUTF16("Checkbox"), this));
}
void CheckboxExample::ButtonPressed(Button* sender, const ui::Event& event) {
diff --git a/chromium/ui/views/examples/colored_dialog_example.cc b/chromium/ui/views/examples/colored_dialog_example.cc
new file mode 100644
index 00000000000..de07088cb51
--- /dev/null
+++ b/chromium/ui/views/examples/colored_dialog_example.cc
@@ -0,0 +1,176 @@
+// Copyright 2020 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 "ui/views/examples/colored_dialog_example.h"
+
+#include <memory>
+#include <utility>
+
+#include "base/containers/adapters.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/ui_base_types.h"
+#include "ui/gfx/paint_vector_icon.h"
+#include "ui/gfx/vector_icon_types.h"
+#include "ui/native_theme/native_theme_color_id.h"
+#include "ui/views/controls/button/checkbox.h"
+#include "ui/views/controls/button/md_text_button.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/controls/textfield/textfield.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
+#include "ui/views/layout/box_layout.h"
+#include "ui/views/layout/fill_layout.h"
+#include "ui/views/layout/layout_provider.h"
+#include "ui/views/vector_icons.h"
+#include "ui/views/widget/widget.h"
+
+namespace views {
+namespace examples {
+
+class ThemeTrackingCheckbox : public views::Checkbox,
+ public views::ButtonListener {
+ public:
+ explicit ThemeTrackingCheckbox(const base::string16& label)
+ : Checkbox(label, this) {}
+ ThemeTrackingCheckbox(const ThemeTrackingCheckbox&) = delete;
+ ThemeTrackingCheckbox& operator=(const ThemeTrackingCheckbox&) = delete;
+ ~ThemeTrackingCheckbox() override = default;
+
+ // views::Checkbox
+ void OnThemeChanged() override {
+ views::Checkbox::OnThemeChanged();
+
+ SetChecked(GetNativeTheme()->ShouldUseDarkColors());
+ }
+
+ // ButtonListener
+ void ButtonPressed(views::Button* sender, const ui::Event& event) override {
+ GetNativeTheme()->set_use_dark_colors(GetChecked());
+ GetWidget()->ThemeChanged();
+ }
+};
+
+class TextVectorImageButton : public views::MdTextButton {
+ public:
+ TextVectorImageButton(ButtonListener* listener,
+ const base::string16& text,
+ const gfx::VectorIcon& icon)
+ : MdTextButton(listener, style::CONTEXT_BUTTON_MD), icon_(icon) {
+ SetText(text);
+ }
+ TextVectorImageButton(const TextVectorImageButton&) = delete;
+ TextVectorImageButton& operator=(const TextVectorImageButton&) = delete;
+ ~TextVectorImageButton() override = default;
+
+ void OnThemeChanged() override {
+ views::MdTextButton::OnThemeChanged();
+
+ // Use the text color for the associated vector image.
+ SetImage(views::Button::ButtonState::STATE_NORMAL,
+ gfx::CreateVectorIcon(icon_, label()->GetEnabledColor()));
+ }
+
+ private:
+ const gfx::VectorIcon& icon_;
+};
+
+ColoredDialog::ColoredDialog(AcceptCallback accept_callback) {
+ SetAcceptCallback(base::BindOnce(
+ [](ColoredDialog* dialog, AcceptCallback callback) {
+ std::move(callback).Run(dialog->textfield_->GetText());
+ },
+ base::Unretained(this), std::move(accept_callback)));
+
+ SetTitle(l10n_util::GetStringUTF16(IDS_COLORED_DIALOG_TITLE));
+
+ SetLayoutManager(std::make_unique<views::FillLayout>());
+ set_margins(views::LayoutProvider::Get()->GetDialogInsetsForContentType(
+ views::CONTROL, views::CONTROL));
+
+ textfield_ = AddChildView(std::make_unique<views::Textfield>());
+ textfield_->SetPlaceholderText(
+ l10n_util::GetStringUTF16(IDS_COLORED_DIALOG_TEXTFIELD_PLACEHOLDER));
+ textfield_->SetAccessibleName(
+ l10n_util::GetStringUTF16(IDS_COLORED_DIALOG_TEXTFIELD_AX_LABEL));
+ textfield_->set_controller(this);
+
+ SetButtonLabel(ui::DIALOG_BUTTON_OK,
+ l10n_util::GetStringUTF16(IDS_COLORED_DIALOG_SUBMIT_BUTTON));
+ SetButtonEnabled(ui::DIALOG_BUTTON_OK, false);
+}
+
+ColoredDialog::~ColoredDialog() = default;
+
+ui::ModalType ColoredDialog::GetModalType() const {
+ return ui::MODAL_TYPE_WINDOW;
+}
+
+bool ColoredDialog::ShouldShowCloseButton() const {
+ return false;
+}
+
+void ColoredDialog::ContentsChanged(Textfield* sender,
+ const base::string16& new_contents) {
+ SetButtonEnabled(ui::DIALOG_BUTTON_OK, !textfield_->GetText().empty());
+ DialogModelChanged();
+}
+
+ColoredDialogChooser::ColoredDialogChooser() {
+ views::LayoutProvider* provider = views::LayoutProvider::Get();
+ const int vertical_spacing =
+ provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL);
+ auto* layout = SetLayoutManager(std::make_unique<views::BoxLayout>(
+ views::BoxLayout::Orientation::kVertical, gfx::Insets(),
+ vertical_spacing));
+ layout->set_cross_axis_alignment(
+ views::BoxLayout::CrossAxisAlignment::kStart);
+
+ AddChildView(std::make_unique<ThemeTrackingCheckbox>(
+ l10n_util::GetStringUTF16(IDS_COLORED_DIALOG_CHOOSER_CHECKBOX)));
+
+ AddChildView(std::make_unique<TextVectorImageButton>(
+ this, l10n_util::GetStringUTF16(IDS_COLORED_DIALOG_CHOOSER_BUTTON),
+ views::kInfoIcon));
+
+ confirmation_label_ = AddChildView(
+ std::make_unique<views::Label>(base::string16(), style::CONTEXT_LABEL));
+ confirmation_label_->SetVisible(false);
+}
+
+ColoredDialogChooser::~ColoredDialogChooser() = default;
+
+void ColoredDialogChooser::ButtonPressed(Button* sender,
+ const ui::Event& event) {
+ // Create the colored dialog.
+ views::Widget* widget = DialogDelegate::CreateDialogWidget(
+ new ColoredDialog(base::BindOnce(&ColoredDialogChooser::OnFeedbackSubmit,
+ base::Unretained(this))),
+ nullptr, GetWidget()->GetNativeView());
+ widget->Show();
+}
+
+void ColoredDialogChooser::OnFeedbackSubmit(base::string16 text) {
+ constexpr base::TimeDelta kConfirmationDuration =
+ base::TimeDelta::FromSeconds(3);
+
+ confirmation_label_->SetText(l10n_util::GetStringFUTF16(
+ IDS_COLORED_DIALOG_CHOOSER_CONFIRM_LABEL, text));
+ confirmation_label_->SetVisible(true);
+
+ confirmation_timer_.Start(
+ FROM_HERE, kConfirmationDuration,
+ base::BindOnce([](views::View* view) { view->SetVisible(false); },
+ confirmation_label_));
+}
+
+ColoredDialogExample::ColoredDialogExample() : ExampleBase("Colored Dialog") {}
+
+ColoredDialogExample::~ColoredDialogExample() = default;
+
+void ColoredDialogExample::CreateExampleView(views::View* container) {
+ container->SetLayoutManager(std::make_unique<views::FillLayout>());
+ container->AddChildView(std::make_unique<ColoredDialogChooser>());
+}
+
+} // namespace examples
+} // namespace views
diff --git a/chromium/ui/views/examples/colored_dialog_example.h b/chromium/ui/views/examples/colored_dialog_example.h
new file mode 100644
index 00000000000..82b5c0a571c
--- /dev/null
+++ b/chromium/ui/views/examples/colored_dialog_example.h
@@ -0,0 +1,77 @@
+// Copyright 2020 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 UI_VIEWS_EXAMPLES_COLORED_DIALOG_EXAMPLE_H_
+#define UI_VIEWS_EXAMPLES_COLORED_DIALOG_EXAMPLE_H_
+
+#include "base/timer/timer.h"
+#include "ui/views/controls/button/button.h"
+#include "ui/views/controls/textfield/textfield_controller.h"
+#include "ui/views/examples/example_base.h"
+#include "ui/views/view.h"
+#include "ui/views/window/dialog_delegate.h"
+
+namespace views {
+
+class Button;
+class Label;
+
+namespace examples {
+
+class ColoredDialog : public views::DialogDelegateView,
+ public views::TextfieldController {
+ public:
+ using AcceptCallback = base::OnceCallback<void(base::string16)>;
+
+ explicit ColoredDialog(AcceptCallback accept_callback);
+ ColoredDialog(const ColoredDialog&) = delete;
+ ColoredDialog& operator=(const ColoredDialog&) = delete;
+ ~ColoredDialog() override;
+
+ protected:
+ // views::DialogDelegateView
+ ui::ModalType GetModalType() const override;
+ bool ShouldShowCloseButton() const override;
+
+ // views::TextfieldController
+ void ContentsChanged(Textfield* sender,
+ const base::string16& new_contents) override;
+
+ private:
+ views::Textfield* textfield_;
+};
+
+class ColoredDialogChooser : public views::View, public views::ButtonListener {
+ public:
+ ColoredDialogChooser();
+ ColoredDialogChooser(const ColoredDialogChooser&) = delete;
+ ColoredDialogChooser& operator=(const ColoredDialogChooser&) = delete;
+ ~ColoredDialogChooser() override;
+
+ // ButtonListener
+ void ButtonPressed(views::Button* sender, const ui::Event& event) override;
+
+ private:
+ void OnFeedbackSubmit(base::string16 text);
+
+ views::Label* confirmation_label_;
+ base::OneShotTimer confirmation_timer_;
+};
+
+// An example that exercises BubbleDialogDelegateView or DialogDelegateView.
+class VIEWS_EXAMPLES_EXPORT ColoredDialogExample : public ExampleBase {
+ public:
+ ColoredDialogExample();
+ ColoredDialogExample(const ColoredDialogExample&) = delete;
+ ColoredDialogExample& operator=(const ColoredDialogExample&) = delete;
+ ~ColoredDialogExample() override;
+
+ // ExampleBase
+ void CreateExampleView(views::View* container) override;
+};
+
+} // namespace examples
+} // namespace views
+
+#endif // UI_VIEWS_EXAMPLES_COLORED_DIALOG_EXAMPLE_H_
diff --git a/chromium/ui/views/examples/combobox_example.cc b/chromium/ui/views/examples/combobox_example.cc
index 178a465e430..dc1e8bba76f 100644
--- a/chromium/ui/views/examples/combobox_example.cc
+++ b/chromium/ui/views/examples/combobox_example.cc
@@ -41,20 +41,19 @@ ComboboxExample::ComboboxExample() : ExampleBase("Combo Box") {}
ComboboxExample::~ComboboxExample() = default;
void ComboboxExample::CreateExampleView(View* container) {
- combobox_ = new Combobox(std::make_unique<ComboboxModelExample>());
+ container->SetLayoutManager(std::make_unique<BoxLayout>(
+ BoxLayout::Orientation::kVertical, gfx::Insets(10, 0), 5));
+
+ combobox_ = container->AddChildView(
+ std::make_unique<Combobox>(std::make_unique<ComboboxModelExample>()));
combobox_->set_listener(this);
combobox_->SetSelectedIndex(3);
- auto* disabled_combobox =
- new Combobox(std::make_unique<ComboboxModelExample>());
+ auto* disabled_combobox = container->AddChildView(
+ std::make_unique<Combobox>(std::make_unique<ComboboxModelExample>()));
disabled_combobox->set_listener(this);
disabled_combobox->SetSelectedIndex(4);
disabled_combobox->SetEnabled(false);
-
- container->SetLayoutManager(std::make_unique<BoxLayout>(
- BoxLayout::Orientation::kVertical, gfx::Insets(10, 0), 5));
- container->AddChildView(combobox_);
- container->AddChildView(disabled_combobox);
}
void ComboboxExample::OnPerformAction(Combobox* combobox) {
diff --git a/chromium/ui/views/examples/create_examples.cc b/chromium/ui/views/examples/create_examples.cc
new file mode 100644
index 00000000000..b9805665713
--- /dev/null
+++ b/chromium/ui/views/examples/create_examples.cc
@@ -0,0 +1,80 @@
+// Copyright 2020 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 "ui/views/examples/create_examples.h"
+
+#include <utility>
+
+#include "ui/views/examples/ax_example.h"
+#include "ui/views/examples/box_layout_example.h"
+#include "ui/views/examples/bubble_example.h"
+#include "ui/views/examples/button_example.h"
+#include "ui/views/examples/button_sticker_sheet.h"
+#include "ui/views/examples/checkbox_example.h"
+#include "ui/views/examples/colored_dialog_example.h"
+#include "ui/views/examples/combobox_example.h"
+#include "ui/views/examples/dialog_example.h"
+#include "ui/views/examples/flex_layout_example.h"
+#include "ui/views/examples/label_example.h"
+#include "ui/views/examples/link_example.h"
+#include "ui/views/examples/login_bubble_dialog.h"
+#include "ui/views/examples/menu_example.h"
+#include "ui/views/examples/message_box_example.h"
+#include "ui/views/examples/multiline_example.h"
+#include "ui/views/examples/native_theme_example.h"
+#include "ui/views/examples/progress_bar_example.h"
+#include "ui/views/examples/radio_button_example.h"
+#include "ui/views/examples/scroll_view_example.h"
+#include "ui/views/examples/slider_example.h"
+#include "ui/views/examples/tabbed_pane_example.h"
+#include "ui/views/examples/table_example.h"
+#include "ui/views/examples/text_example.h"
+#include "ui/views/examples/textfield_example.h"
+#include "ui/views/examples/throbber_example.h"
+#include "ui/views/examples/toggle_button_example.h"
+#include "ui/views/examples/tree_view_example.h"
+#include "ui/views/examples/vector_example.h"
+#include "ui/views/examples/widget_example.h"
+
+namespace views {
+namespace examples {
+
+// Creates the default set of examples.
+ExampleVector CreateExamples(ExampleVector extra_examples) {
+ ExampleVector examples = std::move(extra_examples);
+ examples.push_back(std::make_unique<AxExample>());
+ examples.push_back(std::make_unique<BoxLayoutExample>());
+ examples.push_back(std::make_unique<BubbleExample>());
+ examples.push_back(std::make_unique<ButtonExample>());
+ examples.push_back(std::make_unique<ButtonStickerSheet>());
+ examples.push_back(std::make_unique<CheckboxExample>());
+ examples.push_back(std::make_unique<ColoredDialogExample>());
+ examples.push_back(std::make_unique<ComboboxExample>());
+ examples.push_back(std::make_unique<DialogExample>());
+ examples.push_back(std::make_unique<FlexLayoutExample>());
+ examples.push_back(std::make_unique<LabelExample>());
+ examples.push_back(std::make_unique<LinkExample>());
+ examples.push_back(std::make_unique<LoginBubbleDialogExample>());
+ examples.push_back(std::make_unique<MenuExample>());
+ examples.push_back(std::make_unique<MessageBoxExample>());
+ examples.push_back(std::make_unique<MultilineExample>());
+ examples.push_back(std::make_unique<NativeThemeExample>());
+ examples.push_back(std::make_unique<ProgressBarExample>());
+ examples.push_back(std::make_unique<RadioButtonExample>());
+ examples.push_back(std::make_unique<ScrollViewExample>());
+ examples.push_back(std::make_unique<SliderExample>());
+ examples.push_back(std::make_unique<TabbedPaneExample>());
+ examples.push_back(std::make_unique<TableExample>());
+ examples.push_back(std::make_unique<TextExample>());
+ examples.push_back(std::make_unique<TextfieldExample>());
+ examples.push_back(std::make_unique<ToggleButtonExample>());
+ examples.push_back(std::make_unique<ThrobberExample>());
+ examples.push_back(std::make_unique<TreeViewExample>());
+ examples.push_back(std::make_unique<VectorExample>());
+ examples.push_back(std::make_unique<WidgetExample>());
+ return examples;
+}
+
+} // namespace examples
+} // namespace views
diff --git a/chromium/ui/views/examples/create_examples.h b/chromium/ui/views/examples/create_examples.h
new file mode 100644
index 00000000000..39f1d02181e
--- /dev/null
+++ b/chromium/ui/views/examples/create_examples.h
@@ -0,0 +1,24 @@
+// Copyright 2020 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 UI_VIEWS_EXAMPLES_CREATE_EXAMPLES_H_
+#define UI_VIEWS_EXAMPLES_CREATE_EXAMPLES_H_
+
+#include <memory>
+#include <vector>
+
+#include "ui/views/examples/example_base.h"
+#include "ui/views/examples/views_examples_export.h"
+
+namespace views {
+namespace examples {
+
+// Creates the default set of examples.
+ExampleVector VIEWS_EXAMPLES_EXPORT
+CreateExamples(ExampleVector extra_examples = ExampleVector());
+
+} // namespace examples
+} // namespace views
+
+#endif // UI_VIEWS_EXAMPLES_CREATE_EXAMPLES_H_
diff --git a/chromium/ui/views/examples/dialog_example.cc b/chromium/ui/views/examples/dialog_example.cc
index efdc6f90351..70e7fd417d7 100644
--- a/chromium/ui/views/examples/dialog_example.cc
+++ b/chromium/ui/views/examples/dialog_example.cc
@@ -55,7 +55,7 @@ class DialogExample::Delegate : public virtual DialogType {
this->AddChildView(body);
if (parent_->has_extra_button_->GetChecked()) {
- DialogDelegate::SetExtraView(MdTextButton::CreateSecondaryUiButton(
+ DialogDelegate::SetExtraView(MdTextButton::Create(
nullptr, parent_->extra_button_label_->GetText()));
}
@@ -137,13 +137,13 @@ void DialogExample::CreateExampleView(View* container) {
container->SetLayoutManager(std::make_unique<views::GridLayout>());
ColumnSet* column_set = layout->AddColumnSet(kFieldsColumnId);
column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, kFixed,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddPaddingColumn(kFixed, horizontal_spacing);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kStretchy,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddPaddingColumn(kFixed, horizontal_spacing);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kFixed,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
StartTextfieldRow(layout, &title_, "Dialog Title", "Title");
StartTextfieldRow(layout, &body_, "Dialog Body Text", "Body Text");
@@ -169,13 +169,13 @@ void DialogExample::CreateExampleView(View* container) {
column_set = layout->AddColumnSet(kButtonsColumnId);
column_set->AddColumn(GridLayout::CENTER, GridLayout::CENTER, kStretchy,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout->StartRowWithPadding(
kFixed, kButtonsColumnId, kFixed,
provider->GetDistanceMetric(views::DISTANCE_UNRELATED_CONTROL_VERTICAL));
- show_ = layout->AddView(
- MdTextButton::CreateSecondaryUiButton(this, base::ASCIIToUTF16("Show")));
+ show_ =
+ layout->AddView(MdTextButton::Create(this, base::ASCIIToUTF16("Show")));
}
void DialogExample::StartRowWithLabel(GridLayout* layout, const char* label) {
diff --git a/chromium/ui/views/examples/example_base.h b/chromium/ui/views/examples/example_base.h
index 231011b6101..69e9105692a 100644
--- a/chromium/ui/views/examples/example_base.h
+++ b/chromium/ui/views/examples/example_base.h
@@ -6,6 +6,7 @@
#define UI_VIEWS_EXAMPLES_EXAMPLE_BASE_H_
#include <string>
+#include <vector>
#include "base/macros.h"
#include "ui/views/examples/views_examples_export.h"
@@ -38,6 +39,8 @@ class VIEWS_EXAMPLES_EXPORT ExampleBase {
DISALLOW_COPY_AND_ASSIGN(ExampleBase);
};
+using ExampleVector = std::vector<std::unique_ptr<ExampleBase>>;
+
} // namespace examples
} // namespace views
diff --git a/chromium/ui/views/examples/examples_exit_code.h b/chromium/ui/views/examples/examples_exit_code.h
new file mode 100644
index 00000000000..3ef5e79a5e5
--- /dev/null
+++ b/chromium/ui/views/examples/examples_exit_code.h
@@ -0,0 +1,25 @@
+// Copyright 2020 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 UI_VIEWS_EXAMPLES_EXAMPLES_EXIT_CODE_H_
+#define UI_VIEWS_EXAMPLES_EXAMPLES_EXIT_CODE_H_
+
+namespace views {
+namespace examples {
+
+enum class ExamplesExitCode {
+ // Comparison succeeded.
+ kSucceeded = 0,
+ // Screenshot image empty.
+ kImageEmpty,
+ // Comparison failed.
+ kFailed,
+ // No comparison attempted.
+ kNone,
+};
+
+} // namespace examples
+} // namespace views
+
+#endif // UI_VIEWS_EXAMPLES_EXAMPLES_EXIT_CODE_H_
diff --git a/chromium/ui/views/examples/examples_main.cc b/chromium/ui/views/examples/examples_main.cc
index a3e2c965c77..82ec4ab5200 100644
--- a/chromium/ui/views/examples/examples_main.cc
+++ b/chromium/ui/views/examples/examples_main.cc
@@ -2,168 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <memory>
-
#include "base/at_exit.h"
-#include "base/base_switches.h"
#include "base/command_line.h"
-#include "base/feature_list.h"
-#include "base/files/file_path.h"
-#include "base/i18n/icu_util.h"
-#include "base/memory/ptr_util.h"
-#include "base/path_service.h"
-#include "base/power_monitor/power_monitor.h"
-#include "base/power_monitor/power_monitor_device_source.h"
-#include "base/run_loop.h"
-#include "base/test/scoped_run_loop_timeout.h"
-#include "base/test/task_environment.h"
-#include "base/test/test_discardable_memory_allocator.h"
#include "base/test/test_timeouts.h"
-#include "build/build_config.h"
-#include "components/viz/host/host_frame_sink_manager.h"
-#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
-#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
-#include "mojo/core/embedder/embedder.h"
-#include "ui/base/ime/init/input_method_initializer.h"
-#include "ui/base/resource/resource_bundle.h"
-#include "ui/base/ui_base_paths.h"
-#include "ui/compositor/test/in_process_context_factory.h"
-#include "ui/display/screen.h"
-#include "ui/gfx/font_util.h"
-#include "ui/gl/gl_switches.h"
-#include "ui/gl/init/gl_factory.h"
-#include "ui/views/buildflags.h"
-#include "ui/views/examples/example_base.h"
-#include "ui/views/examples/examples_window.h"
-#include "ui/views/test/desktop_test_views_delegate.h"
-
-#if defined(USE_AURA)
-#include "ui/aura/env.h"
-#include "ui/wm/core/wm_state.h"
-#endif
-
-#if BUILDFLAG(ENABLE_DESKTOP_AURA)
-#include "ui/views/widget/desktop_aura/desktop_screen.h"
-#endif
-
-#if defined(OS_WIN)
-#include "ui/base/win/scoped_ole_initializer.h"
-#endif
-
-#if defined(USE_OZONE)
-#include "ui/ozone/public/ozone_platform.h"
-#endif
-
-#if defined(USE_X11)
-#include "ui/gfx/x/x11_connection.h" // nogncheck
-#endif
-
-base::LazyInstance<base::TestDiscardableMemoryAllocator>::DestructorAtExit
- g_discardable_memory_allocator = LAZY_INSTANCE_INITIALIZER;
+#include "ui/views/examples/examples_main_proc.h"
int main(int argc, char** argv) {
-#if defined(OS_WIN)
- ui::ScopedOleInitializer ole_initializer;
-#endif
-
base::CommandLine::Init(argc, argv);
- base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
-
- // Disabling Direct Composition works around the limitation that
- // InProcessContextFactory doesn't work with Direct Composition, causing the
- // window to not render. See http://crbug.com/936249.
- command_line->AppendSwitch(switches::kDisableDirectComposition);
-
- base::FeatureList::InitializeInstance(
- command_line->GetSwitchValueASCII(switches::kEnableFeatures),
- command_line->GetSwitchValueASCII(switches::kDisableFeatures));
-
- base::AtExitManager at_exit;
-
- mojo::core::Init();
-
-#if defined(USE_OZONE)
- ui::OzonePlatform::InitParams params;
- params.single_process = true;
- ui::OzonePlatform::InitializeForGPU(params);
-#endif
-
-#if defined(USE_X11)
- // This demo uses InProcessContextFactory which uses X on a separate Gpu
- // thread.
- gfx::InitializeThreadedX11();
-#endif
-
- gl::init::InitializeGLOneOff();
-
- // The use of base::test::TaskEnvironment below relies on the timeout
- // values from TestTimeouts. This ensures they're properly initialized.
+ // The use of base::test::TaskEnvironment in the following function relies on
+ // the timeout values from TestTimeouts.
TestTimeouts::Initialize();
- // Viz depends on the task environment to correctly tear down.
- base::test::TaskEnvironment task_environment(
- base::test::TaskEnvironment::MainThreadType::UI);
-
- // The ContextFactory must exist before any Compositors are created.
- viz::HostFrameSinkManager host_frame_sink_manager;
- viz::ServerSharedBitmapManager shared_bitmap_manager;
- viz::FrameSinkManagerImpl frame_sink_manager(&shared_bitmap_manager);
- host_frame_sink_manager.SetLocalManager(&frame_sink_manager);
- frame_sink_manager.SetLocalClient(&host_frame_sink_manager);
- auto context_factory = std::make_unique<ui::InProcessContextFactory>(
- &host_frame_sink_manager, &frame_sink_manager);
- context_factory->set_use_test_surface(false);
-
- base::i18n::InitializeICU();
-
- ui::RegisterPathProvider();
-
- base::FilePath ui_test_pak_path;
- CHECK(base::PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
- ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
-
- base::DiscardableMemoryAllocator::SetInstance(
- g_discardable_memory_allocator.Pointer());
-
- base::PowerMonitor::Initialize(
- std::make_unique<base::PowerMonitorDeviceSource>());
-
- gfx::InitializeFonts();
-
-#if defined(USE_AURA)
- std::unique_ptr<aura::Env> env = aura::Env::CreateInstance();
- aura::Env::GetInstance()->set_context_factory(context_factory.get());
-#endif
- ui::InitializeInputMethodForTesting();
-
- {
- views::DesktopTestViewsDelegate views_delegate;
-#if defined(USE_AURA)
- wm::WMState wm_state;
-#endif
-#if BUILDFLAG(ENABLE_DESKTOP_AURA)
- std::unique_ptr<display::Screen> desktop_screen(
- views::CreateDesktopScreen());
- display::Screen::SetScreenInstance(desktop_screen.get());
-#endif
-
- // This app isn't a test and shouldn't timeout.
- base::test::ScopedDisableRunLoopTimeout disable_timeout;
-
- base::RunLoop run_loop;
- views::examples::ShowExamplesWindow(run_loop.QuitClosure());
-
- run_loop.Run();
-
- ui::ResourceBundle::CleanupSharedInstance();
- }
-
- ui::ShutdownInputMethod();
-
-#if defined(USE_AURA)
- env.reset();
-#endif
+ base::AtExitManager at_exit;
- return 0;
+ return static_cast<int>(views::examples::ExamplesMainProc());
}
diff --git a/chromium/ui/views/examples/examples_main_proc.cc b/chromium/ui/views/examples/examples_main_proc.cc
new file mode 100644
index 00000000000..fe417da38a3
--- /dev/null
+++ b/chromium/ui/views/examples/examples_main_proc.cc
@@ -0,0 +1,198 @@
+// Copyright 2020 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 "ui/views/examples/examples_main_proc.h"
+
+#include <memory>
+
+#include "base/base_switches.h"
+#include "base/bind.h"
+#include "base/command_line.h"
+#include "base/feature_list.h"
+#include "base/files/file_path.h"
+#include "base/i18n/icu_util.h"
+#include "base/lazy_instance.h"
+#include "base/memory/ptr_util.h"
+#include "base/path_service.h"
+#include "base/power_monitor/power_monitor.h"
+#include "base/power_monitor/power_monitor_device_source.h"
+#include "base/run_loop.h"
+#include "base/test/scoped_run_loop_timeout.h"
+#include "base/test/task_environment.h"
+#include "base/test/test_discardable_memory_allocator.h"
+#include "base/test/test_timeouts.h"
+#include "build/build_config.h"
+#include "components/viz/host/host_frame_sink_manager.h"
+#include "components/viz/service/display_embedder/server_shared_bitmap_manager.h"
+#include "components/viz/service/frame_sinks/frame_sink_manager_impl.h"
+#include "mojo/core/embedder/embedder.h"
+#include "ui/base/ime/init/input_method_initializer.h"
+#include "ui/base/resource/resource_bundle.h"
+#include "ui/base/ui_base_paths.h"
+#include "ui/compositor/compositor_switches.h"
+#include "ui/compositor/test/in_process_context_factory.h"
+#include "ui/compositor/test/test_context_factories.h"
+#include "ui/display/screen.h"
+#include "ui/gfx/font_util.h"
+#include "ui/gfx/image/image.h"
+#include "ui/gl/gl_switches.h"
+#include "ui/gl/init/gl_factory.h"
+#include "ui/views/buildflags.h"
+#include "ui/views/examples/example_base.h"
+#include "ui/views/examples/examples_window.h"
+#include "ui/views/test/desktop_test_views_delegate.h"
+#include "ui/views/widget/any_widget_observer.h"
+#include "ui/views/widget/widget.h"
+
+#if defined(USE_AURA)
+#include "ui/aura/env.h"
+#include "ui/wm/core/wm_state.h"
+#endif
+
+#if BUILDFLAG(ENABLE_DESKTOP_AURA)
+#include "ui/views/widget/desktop_aura/desktop_screen.h"
+#endif
+
+#if defined(OS_WIN)
+#include "ui/base/win/scoped_ole_initializer.h"
+#include "ui/views/examples/examples_skia_gold_pixel_diff.h"
+#endif
+
+#if defined(USE_OZONE)
+#include "ui/ozone/public/ozone_platform.h"
+#endif
+
+namespace views {
+namespace examples {
+
+base::LazyInstance<base::TestDiscardableMemoryAllocator>::DestructorAtExit
+ g_discardable_memory_allocator = LAZY_INSTANCE_INITIALIZER;
+
+ExamplesExitCode ExamplesMainProc(bool under_test) {
+#if defined(OS_WIN)
+ ui::ScopedOleInitializer ole_initializer;
+#endif
+
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+
+ // Disabling Direct Composition works around the limitation that
+ // InProcessContextFactory doesn't work with Direct Composition, causing the
+ // window to not render. See http://crbug.com/936249.
+ command_line->AppendSwitch(switches::kDisableDirectComposition);
+
+ base::FeatureList::InitializeInstance(
+ command_line->GetSwitchValueASCII(switches::kEnableFeatures),
+ command_line->GetSwitchValueASCII(switches::kDisableFeatures));
+
+ if (under_test)
+ command_line->AppendSwitch(switches::kEnablePixelOutputInTests);
+
+ mojo::core::Init();
+
+#if defined(USE_OZONE)
+ ui::OzonePlatform::InitParams params;
+ params.single_process = true;
+ ui::OzonePlatform::InitializeForGPU(params);
+#endif
+
+ gl::init::InitializeGLOneOff();
+
+ // Viz depends on the task environment to correctly tear down.
+ base::test::TaskEnvironment task_environment(
+ base::test::TaskEnvironment::MainThreadType::UI);
+
+ // The ContextFactory must exist before any Compositors are created.
+ auto context_factories =
+ std::make_unique<ui::TestContextFactories>(under_test);
+ context_factories->SetUseTestSurface(false);
+
+ base::i18n::InitializeICU();
+
+ ui::RegisterPathProvider();
+
+ base::FilePath ui_test_pak_path;
+ CHECK(base::PathService::Get(ui::UI_TEST_PAK, &ui_test_pak_path));
+ ui::ResourceBundle::InitSharedInstanceWithPakPath(ui_test_pak_path);
+
+ base::FilePath views_examples_resources_pak_path;
+ CHECK(base::PathService::Get(base::DIR_MODULE,
+ &views_examples_resources_pak_path));
+ ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
+ views_examples_resources_pak_path.AppendASCII(
+ "views_examples_resources.pak"),
+ ui::SCALE_FACTOR_100P);
+
+ base::DiscardableMemoryAllocator::SetInstance(
+ g_discardable_memory_allocator.Pointer());
+
+ base::PowerMonitor::Initialize(
+ std::make_unique<base::PowerMonitorDeviceSource>());
+
+ gfx::InitializeFonts();
+
+#if defined(USE_AURA)
+ std::unique_ptr<aura::Env> env = aura::Env::CreateInstance();
+ aura::Env::GetInstance()->set_context_factory(
+ context_factories->GetContextFactory());
+#endif
+ ui::InitializeInputMethodForTesting();
+
+ ExamplesExitCode compare_result = ExamplesExitCode::kSucceeded;
+
+ {
+ views::DesktopTestViewsDelegate views_delegate;
+#if defined(USE_AURA)
+ wm::WMState wm_state;
+#endif
+#if BUILDFLAG(ENABLE_DESKTOP_AURA)
+ std::unique_ptr<display::Screen> desktop_screen =
+ base::WrapUnique(views::CreateDesktopScreen());
+ display::Screen::SetScreenInstance(desktop_screen.get());
+#endif
+
+ base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
+
+#if defined(OS_WIN)
+ ExamplesSkiaGoldPixelDiff pixel_diff;
+ views::AnyWidgetObserver widget_observer{
+ views::test::AnyWidgetTestPasskey()};
+
+ // If this app isn't a test, it shouldn't timeout.
+ auto disable_timeout =
+ std::make_unique<base::test::ScopedDisableRunLoopTimeout>();
+
+ if (under_test) {
+ pixel_diff.Init("ViewsExamples");
+ widget_observer.set_shown_callback(
+ base::BindRepeating(&ExamplesSkiaGoldPixelDiff::OnExamplesWindowShown,
+ base::Unretained(&pixel_diff)));
+ // Enable the timeout since we're not running in a test.
+ disable_timeout.reset();
+ }
+#else
+ base::test::ScopedDisableRunLoopTimeout disable_timeout;
+#endif
+
+ views::examples::ShowExamplesWindow(run_loop.QuitClosure());
+
+ run_loop.Run();
+
+#if defined(OS_WIN)
+ compare_result = pixel_diff.get_result();
+#endif
+
+ ui::ResourceBundle::CleanupSharedInstance();
+ }
+
+ ui::ShutdownInputMethod();
+
+#if defined(USE_AURA)
+ env.reset();
+#endif
+
+ return compare_result;
+}
+
+} // namespace examples
+} // namespace views
diff --git a/chromium/ui/views/examples/examples_main_proc.h b/chromium/ui/views/examples/examples_main_proc.h
new file mode 100644
index 00000000000..61b258f262a
--- /dev/null
+++ b/chromium/ui/views/examples/examples_main_proc.h
@@ -0,0 +1,18 @@
+// Copyright 2020 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 UI_VIEWS_EXAMPLES_EXAMPLES_MAIN_PROC_H_
+#define UI_VIEWS_EXAMPLES_EXAMPLES_MAIN_PROC_H_
+
+#include "ui/views/examples/examples_exit_code.h"
+
+namespace views {
+namespace examples {
+
+ExamplesExitCode ExamplesMainProc(bool under_test = false);
+
+} // namespace examples
+} // namespace views
+
+#endif // UI_VIEWS_EXAMPLES_EXAMPLES_MAIN_PROC_H_
diff --git a/chromium/ui/views/examples/examples_skia_gold_pixel_diff.cc b/chromium/ui/views/examples/examples_skia_gold_pixel_diff.cc
new file mode 100644
index 00000000000..ffabc89ae2b
--- /dev/null
+++ b/chromium/ui/views/examples/examples_skia_gold_pixel_diff.cc
@@ -0,0 +1,60 @@
+// Copyright 2020 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 "ui/views/examples/examples_skia_gold_pixel_diff.h"
+
+#include "base/run_loop.h"
+#include "ui/snapshot/snapshot.h"
+#include "ui/views/examples/examples_window.h"
+
+#if defined(USE_AURA)
+#include "ui/snapshot/snapshot_aura.h"
+#endif
+
+namespace views {
+namespace examples {
+
+ExamplesSkiaGoldPixelDiff::ExamplesSkiaGoldPixelDiff() = default;
+ExamplesSkiaGoldPixelDiff::~ExamplesSkiaGoldPixelDiff() = default;
+
+ExamplesExitCode ExamplesSkiaGoldPixelDiff::CompareScreenshot(
+ const std::string& screenshot_name,
+ const views::Widget* widget) const {
+ base::RunLoop run_loop(base::RunLoop::Type::kNestableTasksAllowed);
+ gfx::Rect widget_bounds = widget->GetRootView()->bounds();
+#if defined(USE_AURA)
+ ui::GrabWindowSnapshotAsyncAura(
+#else
+ ui::GrabWindowSnapshotAsync(
+#endif
+ widget->GetNativeWindow(), widget_bounds,
+ base::BindOnce(
+ [](gfx::Image* screenshot, base::OnceClosure quit_loop,
+ gfx::Image image) {
+ *screenshot = image;
+ std::move(quit_loop).Run();
+ },
+ &screenshot_, run_loop.QuitClosure()));
+ run_loop.Run();
+ if (screenshot_.IsEmpty())
+ return ExamplesExitCode::kImageEmpty;
+ return SkiaGoldPixelDiff::CompareScreenshot(screenshot_name,
+ *screenshot_.ToSkBitmap())
+ ? ExamplesExitCode::kSucceeded
+ : ExamplesExitCode::kFailed;
+}
+
+void ExamplesSkiaGoldPixelDiff::DoScreenshot(views::Widget* widget) {
+ result_ = CompareScreenshot("ExampleWindow", widget);
+ widget->Close();
+}
+
+void ExamplesSkiaGoldPixelDiff::OnExamplesWindowShown(views::Widget* widget) {
+ if (widget->GetName() == views::examples::kExamplesWidgetName) {
+ DoScreenshot(widget);
+ }
+}
+
+} // namespace examples
+} // namespace views
diff --git a/chromium/ui/views/examples/examples_skia_gold_pixel_diff.h b/chromium/ui/views/examples/examples_skia_gold_pixel_diff.h
new file mode 100644
index 00000000000..4bb102d97eb
--- /dev/null
+++ b/chromium/ui/views/examples/examples_skia_gold_pixel_diff.h
@@ -0,0 +1,39 @@
+// Copyright 2020 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 UI_VIEWS_EXAMPLES_EXAMPLES_SKIA_GOLD_PIXEL_DIFF_H_
+#define UI_VIEWS_EXAMPLES_EXAMPLES_SKIA_GOLD_PIXEL_DIFF_H_
+
+#include "ui/base/test/skia_gold_pixel_diff.h"
+
+#include "base/run_loop.h"
+#include "ui/gfx/image/image.h"
+#include "ui/views/examples/examples_exit_code.h"
+#include "ui/views/widget/widget.h"
+
+namespace views {
+namespace examples {
+
+class ExamplesSkiaGoldPixelDiff : public SkiaGoldPixelDiff {
+ public:
+ ExamplesSkiaGoldPixelDiff();
+ ~ExamplesSkiaGoldPixelDiff() override;
+
+ void OnExamplesWindowShown(views::Widget* widget);
+
+ ExamplesExitCode get_result() const { return result_; }
+
+ private:
+ ExamplesExitCode CompareScreenshot(const std::string& screenshot_name,
+ const views::Widget* widget) const;
+ void DoScreenshot(views::Widget* widget);
+
+ mutable gfx::Image screenshot_;
+ ExamplesExitCode result_ = ExamplesExitCode::kNone;
+};
+
+} // namespace examples
+} // namespace views
+
+#endif // UI_VIEWS_EXAMPLES_EXAMPLES_SKIA_GOLD_PIXEL_DIFF_H_
diff --git a/chromium/ui/views/examples/examples_unittest.cc b/chromium/ui/views/examples/examples_unittest.cc
new file mode 100644
index 00000000000..054ef30a83f
--- /dev/null
+++ b/chromium/ui/views/examples/examples_unittest.cc
@@ -0,0 +1,26 @@
+// Copyright 2020 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 "build/build_config.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/views/examples/examples_exit_code.h"
+#include "ui/views/examples/examples_main_proc.h"
+
+namespace views {
+namespace examples {
+
+#if defined(OS_WIN)
+#define TestViewsExamplesLaunches_MAYBE TestViewsExamplesLaunches
+#else
+#define TestViewsExamplesLaunches_MAYBE TestViewsExamplesLaunches_DISABLED
+#endif
+
+TEST(ExamplesTest, TestViewsExamplesLaunches_MAYBE) {
+ const ExamplesExitCode exit_code = ExamplesMainProc(true);
+ // Check the status of the Skia Gold comparison.
+ EXPECT_EQ(ExamplesExitCode::kSucceeded, exit_code);
+}
+
+} // namespace examples
+} // namespace views
diff --git a/chromium/ui/views/examples/examples_unittest_main.cc b/chromium/ui/views/examples/examples_unittest_main.cc
new file mode 100644
index 00000000000..65ed57e7fd7
--- /dev/null
+++ b/chromium/ui/views/examples/examples_unittest_main.cc
@@ -0,0 +1,14 @@
+// Copyright 2020 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 "base/test/test_suite.h"
+
+int main(int argc, char** argv) {
+ base::TestSuite test_suite(argc, argv);
+ return base::LaunchUnitTests(
+ argc, argv,
+ base::BindOnce(&base::TestSuite::Run, base::Unretained(&test_suite)));
+}
diff --git a/chromium/ui/views/examples/examples_window.cc b/chromium/ui/views/examples/examples_window.cc
index 4956b07f3ac..d2cde9bb4e0 100644
--- a/chromium/ui/views/examples/examples_window.cc
+++ b/chromium/ui/views/examples/examples_window.cc
@@ -10,43 +10,20 @@
#include <string>
#include <utility>
+#include "base/command_line.h"
#include "base/macros.h"
#include "base/run_loop.h"
+#include "base/stl_util.h"
+#include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/combobox_model.h"
#include "ui/base/ui_base_paths.h"
#include "ui/views/background.h"
#include "ui/views/controls/combobox/combobox.h"
+#include "ui/views/controls/combobox/combobox_listener.h"
#include "ui/views/controls/label.h"
-#include "ui/views/examples/ax_example.h"
-#include "ui/views/examples/box_layout_example.h"
-#include "ui/views/examples/bubble_example.h"
-#include "ui/views/examples/button_example.h"
-#include "ui/views/examples/button_sticker_sheet.h"
-#include "ui/views/examples/checkbox_example.h"
-#include "ui/views/examples/combobox_example.h"
-#include "ui/views/examples/dialog_example.h"
-#include "ui/views/examples/flex_layout_example.h"
-#include "ui/views/examples/label_example.h"
-#include "ui/views/examples/link_example.h"
-#include "ui/views/examples/menu_example.h"
-#include "ui/views/examples/message_box_example.h"
-#include "ui/views/examples/multiline_example.h"
-#include "ui/views/examples/native_theme_example.h"
-#include "ui/views/examples/progress_bar_example.h"
-#include "ui/views/examples/radio_button_example.h"
-#include "ui/views/examples/scroll_view_example.h"
-#include "ui/views/examples/slider_example.h"
-#include "ui/views/examples/tabbed_pane_example.h"
-#include "ui/views/examples/table_example.h"
-#include "ui/views/examples/text_example.h"
-#include "ui/views/examples/textfield_example.h"
-#include "ui/views/examples/throbber_example.h"
-#include "ui/views/examples/toggle_button_example.h"
-#include "ui/views/examples/tree_view_example.h"
-#include "ui/views/examples/vector_example.h"
-#include "ui/views/examples/widget_example.h"
+#include "ui/views/examples/create_examples.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/widget/widget.h"
@@ -55,55 +32,49 @@
namespace views {
namespace examples {
-using ExampleVector = std::vector<std::unique_ptr<ExampleBase>>;
+const char kExamplesWidgetName[] = "ExamplesWidget";
namespace {
-// Creates the default set of examples.
-ExampleVector CreateExamples() {
- ExampleVector examples;
- examples.push_back(std::make_unique<AxExample>());
- examples.push_back(std::make_unique<BoxLayoutExample>());
- examples.push_back(std::make_unique<BubbleExample>());
- examples.push_back(std::make_unique<ButtonExample>());
- examples.push_back(std::make_unique<ButtonStickerSheet>());
- examples.push_back(std::make_unique<CheckboxExample>());
- examples.push_back(std::make_unique<ComboboxExample>());
- examples.push_back(std::make_unique<DialogExample>());
- examples.push_back(std::make_unique<FlexLayoutExample>());
- examples.push_back(std::make_unique<LabelExample>());
- examples.push_back(std::make_unique<LinkExample>());
- examples.push_back(std::make_unique<MenuExample>());
- examples.push_back(std::make_unique<MessageBoxExample>());
- examples.push_back(std::make_unique<MultilineExample>());
- examples.push_back(std::make_unique<NativeThemeExample>());
- examples.push_back(std::make_unique<ProgressBarExample>());
- examples.push_back(std::make_unique<RadioButtonExample>());
- examples.push_back(std::make_unique<ScrollViewExample>());
- examples.push_back(std::make_unique<SliderExample>());
- examples.push_back(std::make_unique<TabbedPaneExample>());
- examples.push_back(std::make_unique<TableExample>());
- examples.push_back(std::make_unique<TextExample>());
- examples.push_back(std::make_unique<TextfieldExample>());
- examples.push_back(std::make_unique<ToggleButtonExample>());
- examples.push_back(std::make_unique<ThrobberExample>());
- examples.push_back(std::make_unique<TreeViewExample>());
- examples.push_back(std::make_unique<VectorExample>());
- examples.push_back(std::make_unique<WidgetExample>());
- return examples;
-}
+const char kEnableExamples[] = "enable-examples";
+
+ExampleVector GetExamplesToShow(ExampleVector examples) {
+ using StringVector = std::vector<std::string>;
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
-struct ExampleTitleCompare {
- bool operator()(const std::unique_ptr<ExampleBase>& a,
- const std::unique_ptr<ExampleBase>& b) {
+ std::sort(examples.begin(), examples.end(), [](const auto& a, const auto& b) {
return a->example_title() < b->example_title();
+ });
+
+ std::string enable_examples =
+ command_line->GetSwitchValueASCII(kEnableExamples);
+ if (!enable_examples.empty()) {
+ StringVector enabled =
+ base::SplitString(enable_examples, ";,", base::TRIM_WHITESPACE,
+ base::SPLIT_WANT_NONEMPTY);
+
+ // Transform list of examples to just the list of names.
+ StringVector example_names;
+ std::transform(
+ examples.begin(), examples.end(), std::back_inserter(example_names),
+ [](const auto& example) { return example->example_title(); });
+
+ std::sort(enabled.begin(), enabled.end());
+
+ // Get an intersection of list of titles between the full list and the list
+ // from the command-line.
+ StringVector valid_examples =
+ base::STLSetIntersection<StringVector>(enabled, example_names);
+
+ // If there are still example names in the list, only include the examples
+ // from the list.
+ if (!valid_examples.empty()) {
+ base::EraseIf(examples, [valid_examples](auto& example) {
+ return std::find(valid_examples.begin(), valid_examples.end(),
+ example->example_title()) == valid_examples.end();
+ });
+ }
}
-};
-
-ExampleVector GetExamplesToShow(ExampleVector extra) {
- ExampleVector examples = CreateExamples();
- std::move(extra.begin(), extra.end(), std::back_inserter(examples));
- std::sort(examples.begin(), examples.end(), ExampleTitleCompare());
for (auto& example : examples)
example->CreateExampleView(example->example_view());
@@ -158,13 +129,15 @@ class ExamplesWindowContents : public WidgetDelegateView,
ColumnSet* column_set = layout->AddColumnSet(0);
column_set->AddPaddingColumn(0, 5);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddPaddingColumn(0, 5);
layout->AddPaddingRow(0, 5);
layout->StartRow(0 /* no expand */, 0);
combobox_ = layout->AddView(std::move(combobox));
- if (combobox_model_->GetItemCount() > 0) {
+ auto item_count = combobox_model_->GetItemCount();
+ if (item_count > 0) {
+ combobox_->SetVisible(item_count > 1);
layout->StartRow(1, 0);
auto example_shown = std::make_unique<View>();
example_shown->SetLayoutManager(std::make_unique<FillLayout>());
@@ -236,17 +209,18 @@ class ExamplesWindowContents : public WidgetDelegateView,
ExamplesWindowContents* ExamplesWindowContents::instance_ = nullptr;
void ShowExamplesWindow(base::OnceClosure on_close,
- gfx::NativeWindow window_context,
- ExampleVector extra_examples) {
+ ExampleVector examples,
+ gfx::NativeWindow window_context) {
if (ExamplesWindowContents::instance()) {
ExamplesWindowContents::instance()->GetWidget()->Activate();
} else {
- ExampleVector examples = GetExamplesToShow(std::move(extra_examples));
+ examples = GetExamplesToShow(std::move(examples));
Widget* widget = new Widget;
Widget::InitParams params;
params.delegate =
new ExamplesWindowContents(std::move(on_close), std::move(examples));
params.context = window_context;
+ params.name = kExamplesWidgetName;
widget->Init(std::move(params));
widget->Show();
}
diff --git a/chromium/ui/views/examples/examples_window.h b/chromium/ui/views/examples/examples_window.h
index d7198df6a3d..93cff092763 100644
--- a/chromium/ui/views/examples/examples_window.h
+++ b/chromium/ui/views/examples/examples_window.h
@@ -9,23 +9,25 @@
#include <string>
#include <vector>
+#include "base/callback_forward.h"
#include "base/strings/stringprintf.h"
#include "ui/gfx/native_widget_types.h"
+#include "ui/views/examples/create_examples.h"
+#include "ui/views/examples/example_base.h"
#include "ui/views/examples/views_examples_export.h"
namespace views {
namespace examples {
-class VIEWS_EXAMPLES_EXPORT ExampleBase;
+VIEWS_EXAMPLES_EXPORT extern const char kExamplesWidgetName[];
// Shows a window with the views examples in it. |extra_examples| contains any
// additional examples to add. |window_context| is used to determine where the
// window should be created (see |Widget::InitParams::context| for details).
VIEWS_EXAMPLES_EXPORT void ShowExamplesWindow(
base::OnceClosure on_close,
- gfx::NativeWindow window_context = nullptr,
- std::vector<std::unique_ptr<ExampleBase>> extra_examples =
- std::vector<std::unique_ptr<ExampleBase>>());
+ ExampleVector examples = CreateExamples(),
+ gfx::NativeWindow window_context = nullptr);
// Prints |string| in the status area, at the bottom of the window.
VIEWS_EXAMPLES_EXPORT void LogStatus(const std::string& string);
diff --git a/chromium/ui/views/examples/examples_window_with_content.cc b/chromium/ui/views/examples/examples_window_with_content.cc
index c9391fa8bd8..009108cebad 100644
--- a/chromium/ui/views/examples/examples_window_with_content.cc
+++ b/chromium/ui/views/examples/examples_window_with_content.cc
@@ -9,6 +9,8 @@
#include <vector>
#include "content/public/browser/browser_context.h"
+#include "ui/views/examples/create_examples.h"
+#include "ui/views/examples/example_base.h"
#include "ui/views/examples/webview_example.h"
namespace views {
@@ -17,10 +19,10 @@ namespace examples {
void ShowExamplesWindowWithContent(base::OnceClosure on_close,
content::BrowserContext* browser_context,
gfx::NativeWindow window_context) {
- std::vector<std::unique_ptr<ExampleBase>> extra_examples;
- extra_examples.push_back(std::make_unique<WebViewExample>(browser_context));
- ShowExamplesWindow(std::move(on_close), window_context,
- std::move(extra_examples));
+ ExampleVector examples;
+ examples.push_back(std::make_unique<WebViewExample>(browser_context));
+ ShowExamplesWindow(std::move(on_close), CreateExamples(std::move(examples)),
+ window_context);
}
} // namespace examples
diff --git a/chromium/ui/views/examples/examples_window_with_content.h b/chromium/ui/views/examples/examples_window_with_content.h
index dbcb1fbd806..26ad63ac75e 100644
--- a/chromium/ui/views/examples/examples_window_with_content.h
+++ b/chromium/ui/views/examples/examples_window_with_content.h
@@ -5,6 +5,7 @@
#ifndef UI_VIEWS_EXAMPLES_EXAMPLES_WINDOW_WITH_CONTENT_H_
#define UI_VIEWS_EXAMPLES_EXAMPLES_WINDOW_WITH_CONTENT_H_
+#include "base/callback_forward.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/views/examples/examples_window.h"
#include "ui/views/examples/views_examples_with_content_export.h"
diff --git a/chromium/ui/views/examples/examples_with_content_main_exe.cc b/chromium/ui/views/examples/examples_with_content_main.cc
index 7f978cae9ec..501a2fb7131 100644
--- a/chromium/ui/views/examples/examples_with_content_main_exe.cc
+++ b/chromium/ui/views/examples/examples_with_content_main.cc
@@ -3,11 +3,19 @@
// found in the LICENSE file.
#include "base/bind.h"
+#include "base/command_line.h"
+#include "base/files/file_path.h"
+#include "base/path_service.h"
#include "build/build_config.h"
#include "content/public/browser/browser_context.h"
+#include "ui/base/resource/resource_bundle.h"
#include "ui/views/examples/examples_window_with_content.h"
#include "ui/views_content_client/views_content_client.h"
+#if defined(OS_MACOSX)
+#include "sandbox/mac/seatbelt_exec.h"
+#endif
+
#if defined(OS_WIN)
#include "content/public/app/sandbox_helper_win.h"
#include "sandbox/win/src/sandbox_types.h"
@@ -15,6 +23,16 @@
namespace {
+void OnResourcesLoaded() {
+ base::FilePath views_examples_resources_pak_path;
+ CHECK(base::PathService::Get(base::DIR_MODULE,
+ &views_examples_resources_pak_path));
+ ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
+ views_examples_resources_pak_path.AppendASCII(
+ "views_examples_resources.pak"),
+ ui::SCALE_FACTOR_100P);
+}
+
void ShowContentExampleWindow(ui::ViewsContentClient* views_content_client,
content::BrowserContext* browser_context,
gfx::NativeWindow window_context) {
@@ -43,9 +61,26 @@ int APIENTRY wWinMain(HINSTANCE instance, HINSTANCE, wchar_t*, int) {
ui::ViewsContentClient views_content_client(instance, &sandbox_info);
#else
int main(int argc, const char** argv) {
+ base::CommandLine::Init(argc, argv);
ui::ViewsContentClient views_content_client(argc, argv);
#endif
+#if defined(OS_MACOSX)
+ base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+ // ViewsContentClient expects a const char** argv and
+ // CreateFromArgumentsResult expects a regular char** argv. Given this is a
+ // test program, a refactor from either end didn't seem worth it. As a result,
+ // use a const_cast instead.
+ sandbox::SeatbeltExecServer::CreateFromArgumentsResult seatbelt =
+ sandbox::SeatbeltExecServer::CreateFromArguments(
+ command_line->GetProgram().value().c_str(), argc,
+ const_cast<char**>(argv));
+ if (seatbelt.sandbox_required)
+ CHECK(seatbelt.server->InitializeSandbox());
+#endif
+
+ views_content_client.set_on_resources_loaded_callback(
+ base::BindOnce(&OnResourcesLoaded));
views_content_client.set_on_pre_main_message_loop_run_callback(base::BindOnce(
&ShowContentExampleWindow, base::Unretained(&views_content_client)));
return views_content_client.RunMain();
diff --git a/chromium/ui/views/examples/flex_layout_example.cc b/chromium/ui/views/examples/flex_layout_example.cc
index 3049fed0c78..2dedbc6a592 100644
--- a/chromium/ui/views/examples/flex_layout_example.cc
+++ b/chromium/ui/views/examples/flex_layout_example.cc
@@ -38,12 +38,12 @@ void FlexLayoutExample::CreateAdditionalControls(int vertical_pos) {
static const char* const cross_axis_values[4] = {"Stretch", "Start", "Center",
"End"};
- orientation_ = CreateCombobox(base::ASCIIToUTF16("Orientation"),
- orientation_values, 2, &vertical_pos);
- main_axis_alignment_ = CreateCombobox(base::ASCIIToUTF16("Main axis"),
- main_axis_values, 3, &vertical_pos);
- cross_axis_alignment_ = CreateCombobox(base::ASCIIToUTF16("Cross axis"),
- cross_axis_values, 4, &vertical_pos);
+ orientation_ = CreateAndAddCombobox(base::ASCIIToUTF16("Orientation"),
+ orientation_values, 2, &vertical_pos);
+ main_axis_alignment_ = CreateAndAddCombobox(
+ base::ASCIIToUTF16("Main axis"), main_axis_values, 3, &vertical_pos);
+ cross_axis_alignment_ = CreateAndAddCombobox(
+ base::ASCIIToUTF16("Cross axis"), cross_axis_values, 4, &vertical_pos);
CreateMarginsTextFields(base::ASCIIToUTF16("Interior margin"),
&interior_margin_, &vertical_pos);
@@ -51,10 +51,10 @@ void FlexLayoutExample::CreateAdditionalControls(int vertical_pos) {
CreateMarginsTextFields(base::ASCIIToUTF16("Default margins"),
&default_child_margins_, &vertical_pos);
- collapse_margins_ =
- CreateCheckbox(base::ASCIIToUTF16("Collapse margins"), &vertical_pos);
+ collapse_margins_ = CreateAndAddCheckbox(
+ base::ASCIIToUTF16("Collapse margins"), &vertical_pos);
- ignore_default_main_axis_margins_ = CreateCheckbox(
+ ignore_default_main_axis_margins_ = CreateAndAddCheckbox(
base::ASCIIToUTF16("Ignore main axis margins"), &vertical_pos);
layout_ = layout_panel()->SetLayoutManager(std::make_unique<FlexLayout>());
diff --git a/chromium/ui/views/examples/label_example.cc b/chromium/ui/views/examples/label_example.cc
index 8ec7651301f..61c25bb995e 100644
--- a/chromium/ui/views/examples/label_example.cc
+++ b/chromium/ui/views/examples/label_example.cc
@@ -167,9 +167,9 @@ void LabelExample::AddCustomLabel(View* container) {
ColumnSet* column_set = layout->AddColumnSet(0);
column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0.0f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1.0f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout->StartRow(0, 0);
layout->AddView(std::make_unique<Label>(ASCIIToUTF16("Content: ")));
@@ -189,11 +189,11 @@ void LabelExample::AddCustomLabel(View* container) {
column_set = layout->AddColumnSet(1);
column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout->StartRow(0, 1);
multiline_ = layout->AddView(
std::make_unique<Checkbox>(base::ASCIIToUTF16("Multiline"), this));
@@ -205,7 +205,7 @@ void LabelExample::AddCustomLabel(View* container) {
column_set = layout->AddColumnSet(2);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout->StartRow(0, 2);
auto custom_label = std::make_unique<ExamplePreferredSizeLabel>();
custom_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
diff --git a/chromium/ui/views/examples/layout_example_base.cc b/chromium/ui/views/examples/layout_example_base.cc
index bb577f56a50..a2e85e23749 100644
--- a/chromium/ui/views/examples/layout_example_base.cc
+++ b/chromium/ui/views/examples/layout_example_base.cc
@@ -11,12 +11,14 @@
#include "base/strings/string16.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/views/border.h"
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/combobox/combobox.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/examples/example_combobox_model.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/view_class_properties.h"
@@ -45,6 +47,20 @@ class FullPanel : public View {
DISALLOW_COPY_AND_ASSIGN(FullPanel);
};
+std::unique_ptr<Textfield> CreateCommonTextfield(
+ int vertical_pos,
+ int horizontal_pos,
+ TextfieldController* container) {
+ auto textfield = std::make_unique<Textfield>();
+ textfield->SetPosition(gfx::Point(horizontal_pos, vertical_pos));
+ textfield->SetDefaultWidthInChars(3);
+ textfield->SetTextInputType(ui::TEXT_INPUT_TYPE_NUMBER);
+ textfield->SizeToPreferredSize();
+ textfield->SetText(base::ASCIIToUTF16("0"));
+ textfield->set_controller(container);
+ return textfield;
+}
+
} // namespace
LayoutExampleBase::ChildPanel::ChildPanel(LayoutExampleBase* example)
@@ -125,146 +141,113 @@ void LayoutExampleBase::ChildPanel::ContentsChanged(
}
Textfield* LayoutExampleBase::ChildPanel::CreateTextfield() {
- Textfield* textfield = new Textfield();
+ auto textfield = std::make_unique<Textfield>();
textfield->SetDefaultWidthInChars(3);
textfield->SizeToPreferredSize();
textfield->SetText(base::ASCIIToUTF16("0"));
textfield->set_controller(this);
textfield->SetVisible(false);
- AddChildView(textfield);
- return textfield;
+ return AddChildView(std::move(textfield));
}
LayoutExampleBase::LayoutExampleBase(const char* title) : ExampleBase(title) {}
LayoutExampleBase::~LayoutExampleBase() = default;
-Combobox* LayoutExampleBase::CreateCombobox(const base::string16& label_text,
- const char* const* items,
- int count,
- int* vertical_pos) {
- Label* label = new Label(label_text);
+Combobox* LayoutExampleBase::CreateAndAddCombobox(
+ const base::string16& label_text,
+ const char* const* items,
+ int count,
+ int* vertical_pos) {
+ auto label = std::make_unique<Label>(label_text);
label->SetPosition(gfx::Point(kLayoutExampleLeftPadding, *vertical_pos));
label->SizeToPreferredSize();
- Combobox* combo_box =
- new Combobox(std::make_unique<ExampleComboboxModel>(items, count));
+
+ auto combo_box = std::make_unique<Combobox>(
+ std::make_unique<ExampleComboboxModel>(items, count));
combo_box->SetPosition(
gfx::Point(label->x() + label->width() + kLayoutExampleVerticalSpacing,
*vertical_pos));
combo_box->SizeToPreferredSize();
combo_box->set_listener(this);
label->SetSize(gfx::Size(label->width(), combo_box->height()));
- control_panel_->AddChildView(label);
- control_panel_->AddChildView(combo_box);
- *vertical_pos += combo_box->height() + kLayoutExampleVerticalSpacing;
- return combo_box;
-}
+ control_panel_->AddChildView(std::move(label));
-Textfield* LayoutExampleBase::CreateRawTextfield(int vertical_pos,
- bool add,
- int* horizontal_pos) {
- Textfield* text_field = new Textfield();
- text_field->SetPosition(gfx::Point(*horizontal_pos, vertical_pos));
- text_field->SetDefaultWidthInChars(3);
- text_field->SetTextInputType(ui::TEXT_INPUT_TYPE_NUMBER);
- text_field->SizeToPreferredSize();
- text_field->SetText(base::ASCIIToUTF16("0"));
- text_field->set_controller(this);
- *horizontal_pos += text_field->width() + kLayoutExampleVerticalSpacing;
- if (add)
- control_panel_->AddChildView(text_field);
- return text_field;
+ auto* combo_box_ptr = control_panel_->AddChildView(std::move(combo_box));
+ *vertical_pos += combo_box_ptr->height() + kLayoutExampleVerticalSpacing;
+ return combo_box_ptr;
}
-Textfield* LayoutExampleBase::CreateTextfield(const base::string16& label_text,
- int* vertical_pos) {
- Label* label = new Label(label_text);
+Textfield* LayoutExampleBase::CreateAndAddTextfield(
+ const base::string16& label_text,
+ int* vertical_pos) {
+ auto label = std::make_unique<Label>(label_text);
label->SetPosition(gfx::Point(kLayoutExampleLeftPadding, *vertical_pos));
label->SizeToPreferredSize();
int horizontal_pos =
label->x() + label->width() + kLayoutExampleVerticalSpacing;
- Textfield* text_field =
- CreateRawTextfield(*vertical_pos, false, &horizontal_pos);
- label->SetSize(gfx::Size(label->width(), text_field->height()));
- control_panel_->AddChildView(label);
- control_panel_->AddChildView(text_field);
- *vertical_pos += text_field->height() + kLayoutExampleVerticalSpacing;
- return text_field;
-}
-
-void LayoutExampleBase::CreateMarginsTextFields(
- const base::string16& label_text,
- Textfield* textfields[4],
- int* vertical_pos) {
- textfields[0] = CreateTextfield(label_text, vertical_pos);
- int center = textfields[0]->x() + textfields[0]->width() / 2;
- int horizontal_pos = std::max(
- 0, center - (textfields[0]->width() + kLayoutExampleVerticalSpacing / 2));
- textfields[1] = CreateRawTextfield(*vertical_pos, true, &horizontal_pos);
- textfields[3] = CreateRawTextfield(*vertical_pos, true, &horizontal_pos);
- *vertical_pos = textfields[1]->y() + textfields[1]->height() +
- kLayoutExampleVerticalSpacing;
- horizontal_pos = textfields[0]->x();
- textfields[2] = CreateRawTextfield(*vertical_pos, true, &horizontal_pos);
- *vertical_pos = textfields[2]->y() + textfields[2]->height() +
- kLayoutExampleVerticalSpacing;
+ std::unique_ptr<Textfield> textfield =
+ CreateCommonTextfield(*vertical_pos, horizontal_pos, this);
+ label->SetSize(gfx::Size(label->width(), textfield->height()));
+ control_panel_->AddChildView(std::move(label));
+ auto* textfield_ptr = control_panel_->AddChildView(std::move(textfield));
+ *vertical_pos += textfield_ptr->height() + kLayoutExampleVerticalSpacing;
+ return textfield_ptr;
}
void LayoutExampleBase::CreateMarginsTextFields(
const base::string16& label_text,
InsetTextfields* textfields,
int* vertical_pos) {
- textfields->top = CreateTextfield(label_text, vertical_pos);
+ textfields->top = CreateAndAddTextfield(label_text, vertical_pos);
int center = textfields->top->x() + textfields->top->width() / 2;
int horizontal_pos = std::max(
0,
center - (textfields->top->width() + kLayoutExampleVerticalSpacing / 2));
- textfields->left = CreateRawTextfield(*vertical_pos, true, &horizontal_pos);
- textfields->right = CreateRawTextfield(*vertical_pos, true, &horizontal_pos);
+ textfields->left = CreateAndAddRawTextfield(*vertical_pos, &horizontal_pos);
+ textfields->right = CreateAndAddRawTextfield(*vertical_pos, &horizontal_pos);
*vertical_pos = textfields->left->y() + textfields->left->height() +
kLayoutExampleVerticalSpacing;
horizontal_pos = textfields->top->x();
- textfields->bottom = CreateRawTextfield(*vertical_pos, true, &horizontal_pos);
+ textfields->bottom = CreateAndAddRawTextfield(*vertical_pos, &horizontal_pos);
*vertical_pos = textfields->bottom->y() + textfields->bottom->height() +
kLayoutExampleVerticalSpacing;
}
-Checkbox* LayoutExampleBase::CreateCheckbox(const base::string16& label_text,
- int* vertical_pos) {
- Checkbox* checkbox = new Checkbox(label_text, this);
+Checkbox* LayoutExampleBase::CreateAndAddCheckbox(
+ const base::string16& label_text,
+ int* vertical_pos) {
+ auto checkbox = std::make_unique<Checkbox>(label_text, this);
checkbox->SetPosition(gfx::Point(kLayoutExampleLeftPadding, *vertical_pos));
checkbox->SizeToPreferredSize();
- control_panel_->AddChildView(checkbox);
- *vertical_pos += checkbox->height() + kLayoutExampleVerticalSpacing;
- return checkbox;
+ auto* checkbox_ptr = control_panel_->AddChildView(std::move(checkbox));
+ *vertical_pos += checkbox_ptr->height() + kLayoutExampleVerticalSpacing;
+ return checkbox_ptr;
}
void LayoutExampleBase::CreateExampleView(View* container) {
container->SetLayoutManager(std::make_unique<FillLayout>());
- View* full_panel = new FullPanel();
- container->AddChildView(full_panel);
+ View* full_panel = container->AddChildView(std::make_unique<FullPanel>());
auto* manager = full_panel->SetLayoutManager(
std::make_unique<BoxLayout>(views::BoxLayout::Orientation::kHorizontal));
- layout_panel_ = new View();
+ layout_panel_ = full_panel->AddChildView(std::make_unique<View>());
layout_panel_->SetBorder(CreateSolidBorder(1, SK_ColorLTGRAY));
- full_panel->AddChildView(layout_panel_);
manager->SetFlexForView(layout_panel_, 3);
- control_panel_ = new View();
- full_panel->AddChildView(control_panel_);
+ control_panel_ = full_panel->AddChildView(std::make_unique<View>());
manager->SetFlexForView(control_panel_, 1);
int vertical_pos = kLayoutExampleVerticalSpacing;
int horizontal_pos = kLayoutExampleLeftPadding;
- auto add_button =
- MdTextButton::CreateSecondaryUiButton(this, base::ASCIIToUTF16("Add"));
+ auto add_button = MdTextButton::Create(
+ this, l10n_util::GetStringUTF16(IDS_LAYOUT_BASE_ADD_LABEL));
add_button->SetPosition(gfx::Point(horizontal_pos, vertical_pos));
add_button->SizeToPreferredSize();
add_button_ = control_panel_->AddChildView(std::move(add_button));
horizontal_pos += add_button_->width() + kLayoutExampleVerticalSpacing;
preferred_width_view_ =
- CreateRawTextfield(vertical_pos, true, &horizontal_pos);
+ CreateAndAddRawTextfield(vertical_pos, &horizontal_pos);
preferred_width_view_->SetY(
vertical_pos +
(add_button_->height() - preferred_width_view_->height()) / 2);
@@ -272,7 +255,7 @@ void LayoutExampleBase::CreateExampleView(View* container) {
base::NumberToString16(kLayoutExampleDefaultChildSize.width()));
preferred_height_view_ =
- CreateRawTextfield(vertical_pos, true, &horizontal_pos);
+ CreateAndAddRawTextfield(vertical_pos, &horizontal_pos);
preferred_height_view_->SetY(
vertical_pos +
(add_button_->height() - preferred_height_view_->height()) / 2);
@@ -339,5 +322,13 @@ gfx::Insets LayoutExampleBase::TextfieldsToInsets(
std::max(0, right));
}
+Textfield* LayoutExampleBase::CreateAndAddRawTextfield(int vertical_pos,
+ int* horizontal_pos) {
+ std::unique_ptr<Textfield> textfield =
+ CreateCommonTextfield(vertical_pos, *horizontal_pos, this);
+ *horizontal_pos += textfield->width() + kLayoutExampleVerticalSpacing;
+ return control_panel_->AddChildView(std::move(textfield));
+}
+
} // namespace examples
} // namespace views
diff --git a/chromium/ui/views/examples/layout_example_base.h b/chromium/ui/views/examples/layout_example_base.h
index a6d1db36c49..7e41f985931 100644
--- a/chromium/ui/views/examples/layout_example_base.h
+++ b/chromium/ui/views/examples/layout_example_base.h
@@ -81,32 +81,17 @@ class VIEWS_EXAMPLES_EXPORT LayoutExampleBase : public ExampleBase,
protected:
View* layout_panel() { return layout_panel_; }
- // Creates a Combobox with a label with |label_text| to the left. Adjust
- // |vertical_pos| to |vertical_pos| + combo_box->height() + kSpacing.
- Combobox* CreateCombobox(const base::string16& label_text,
- const char* const* items,
- int count,
- int* vertical_pos);
-
- // Creates just a Textfield at the current position of |horizontal_pos| and
- // |vertical_pos|. Update |horizontal_pos| to |horizontal_pos| +
- // text_field->width() + kSpacing.
- Textfield* CreateRawTextfield(int vertical_pos,
- bool add,
- int* horizontal_pos);
-
- // Creates a Textfield with a label with |label_text| to the left. Adjust
- // |vertical_pos| to |vertical_pos| + combo_box->height() + kSpacing.
- Textfield* CreateTextfield(const base::string16& label_text,
- int* vertical_pos);
-
- // Creates a set of labeled Textfields with |label_text|, and four text fields
- // arranged at compass points representing a set of insets. |vertical_pos| is
- // updated to the bottom of the last Textfield + kSpacing, and |textfields| is
- // populated with the fieds that are created.
- void CreateMarginsTextFields(const base::string16& label_text,
- Textfield* textfields[4],
- int* vertical_pos);
+ // Creates and adds a Combobox with a label with |label_text| to the left.
+ // Adjust |vertical_pos| to |vertical_pos| + combo_box->height() + kSpacing.
+ Combobox* CreateAndAddCombobox(const base::string16& label_text,
+ const char* const* items,
+ int count,
+ int* vertical_pos);
+
+ // Creates and adds a Textfield with a label with |label_text| to the left.
+ // Adjusts |vertical_pos| to |vertical_pos| + combo_box->height() + kSpacing.
+ Textfield* CreateAndAddTextfield(const base::string16& label_text,
+ int* vertical_pos);
// Creates a set of labeled Textfields with |label_text|, and four text fields
// arranged at compass points representing a set of insets. |vertical_pos| is
@@ -116,9 +101,10 @@ class VIEWS_EXAMPLES_EXPORT LayoutExampleBase : public ExampleBase,
InsetTextfields* textfields,
int* vertical_pos);
- // Creates a Checkbox with label |label_text|. Adjust |vertical_pos| to
- // |vertical_pos| + checkbox->height() + kSpacing.
- Checkbox* CreateCheckbox(const base::string16& label_text, int* vertical_pos);
+ // Creates and adds a Checkbox with label |label_text|. Adjust |vertical_pos|
+ // to |vertical_pos| + checkbox->height() + kSpacing.
+ Checkbox* CreateAndAddCheckbox(const base::string16& label_text,
+ int* vertical_pos);
// ButtonListener:
// Be sure to call LayoutExampleBase::ButtonPressed() to ensure the "add"
@@ -145,6 +131,11 @@ class VIEWS_EXAMPLES_EXPORT LayoutExampleBase : public ExampleBase,
virtual void UpdateLayoutManager() = 0;
private:
+ // Creates and adds a Textfield at the current position of |horizontal_pos|
+ // and |vertical_pos|. Update |horizontal_pos| to |horizontal_pos| +
+ // text_field->width() + kSpacing.
+ Textfield* CreateAndAddRawTextfield(int vertical_pos, int* horizontal_pos);
+
View* layout_panel_ = nullptr;
View* control_panel_ = nullptr;
LabelButton* add_button_ = nullptr;
diff --git a/chromium/ui/views/examples/link_example.cc b/chromium/ui/views/examples/link_example.cc
index aa61e567010..553c40d0d7e 100644
--- a/chromium/ui/views/examples/link_example.cc
+++ b/chromium/ui/views/examples/link_example.cc
@@ -8,21 +8,29 @@
#include <utility>
#include "base/strings/utf_string_conversions.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/link.h"
#include "ui/views/examples/examples_window.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/view.h"
+using l10n_util::GetStringUTF16;
+using l10n_util::GetStringUTF8;
+
namespace views {
namespace examples {
-LinkExample::LinkExample() : ExampleBase("Link") {}
+LinkExample::LinkExample()
+ : ExampleBase(GetStringUTF8(IDS_LINK_SELECT_LABEL).c_str()) {}
LinkExample::~LinkExample() = default;
void LinkExample::CreateExampleView(View* container) {
- auto link = std::make_unique<Link>(base::ASCIIToUTF16("Click me!"));
- link->set_callback(base::BindRepeating(&LogStatus, "Link clicked"));
+ auto link =
+ std::make_unique<Link>(GetStringUTF16(IDS_LINK_CLICK_PROMPT_LABEL));
+ link->set_callback(base::BindRepeating(
+ &LogStatus, GetStringUTF8(IDS_LINK_CLICK_CONFIRMED_LABEL)));
container->SetLayoutManager(std::make_unique<FillLayout>());
container->AddChildView(std::move(link));
diff --git a/chromium/ui/views/examples/login_bubble_dialog.cc b/chromium/ui/views/examples/login_bubble_dialog.cc
new file mode 100644
index 00000000000..a83e00b9d78
--- /dev/null
+++ b/chromium/ui/views/examples/login_bubble_dialog.cc
@@ -0,0 +1,164 @@
+// Copyright 2020 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 "ui/views/examples/login_bubble_dialog.h"
+
+#include "base/bind.h"
+#include "base/callback_forward.h"
+#include "base/strings/strcat.h"
+#include "base/strings/string16.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/views/border.h"
+#include "ui/views/controls/button/md_text_button.h"
+#include "ui/views/controls/label.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
+#include "ui/views/layout/box_layout.h"
+#include "ui/views/layout/grid_layout.h"
+#include "ui/views/layout/layout_provider.h"
+
+using l10n_util::GetStringUTF16;
+using l10n_util::GetStringUTF8;
+
+namespace views {
+namespace examples {
+
+namespace {
+
+// Adds a label textfield pair to the login dialog's layout.
+Textfield* AddFormRow(LoginBubbleDialogView* bubble,
+ GridLayout* layout,
+ const base::string16& label_text) {
+ layout->StartRow(0, 0);
+ Label* label = layout->AddView(std::make_unique<Label>(label_text));
+ Textfield* textfield = layout->AddView(std::make_unique<Textfield>());
+ textfield->SetAssociatedLabel(label);
+ textfield->set_controller(bubble);
+ constexpr int kDefaultTextfieldWidth = 30;
+ constexpr int kMinimumTextfieldWidth = 5;
+ textfield->SetDefaultWidthInChars(kDefaultTextfieldWidth);
+ textfield->SetMinimumWidthInChars(kMinimumTextfieldWidth);
+ return textfield;
+}
+
+} // namespace
+
+// static
+void LoginBubbleDialogView::Show(View* anchor_view,
+ BubbleBorder::Arrow anchor_position,
+ OnSubmitCallback accept_callback) {
+ BubbleDialogDelegateView::CreateBubble(
+ new LoginBubbleDialogView(anchor_view, anchor_position,
+ std::move(accept_callback)))
+ ->Show();
+}
+
+LoginBubbleDialogView::~LoginBubbleDialogView() = default;
+
+void LoginBubbleDialogView::ContentsChanged(
+ Textfield* sender,
+ const base::string16& new_contents) {
+ SetButtonEnabled(ui::DIALOG_BUTTON_OK, !username_->GetText().empty() &&
+ !password_->GetText().empty());
+ DialogModelChanged();
+}
+
+LoginBubbleDialogView::LoginBubbleDialogView(
+ View* anchor_view,
+ BubbleBorder::Arrow anchor_position,
+ OnSubmitCallback accept_callback)
+ : BubbleDialogDelegateView(anchor_view, anchor_position) {
+ SetButtonEnabled(ui::DIALOG_BUTTON_OK, false);
+
+ const auto on_submit = [](const LoginBubbleDialogView* bubble_view,
+ OnSubmitCallback accept_callback) {
+ std::move(accept_callback)
+ .Run(bubble_view->username_->GetText(),
+ bubble_view->password_->GetText());
+ };
+ SetAcceptCallback(base::BindOnce(on_submit, base::Unretained(this),
+ std::move(accept_callback)));
+
+ SetTitle(l10n_util::GetStringUTF16(IDS_LOGIN_TITLE_LABEL));
+ SetButtonLabel(ui::DIALOG_BUTTON_OK,
+ l10n_util::GetStringUTF16(IDS_LOGIN_OK_BUTTON_LABEL));
+
+ const LayoutProvider* provider = LayoutProvider::Get();
+ set_margins(
+ provider->GetDialogInsetsForContentType(views::CONTROL, views::CONTROL));
+ const int related_control_padding =
+ provider->GetDistanceMetric(views::DISTANCE_RELATED_CONTROL_VERTICAL);
+ const int label_padding =
+ provider->GetDistanceMetric(views::DISTANCE_RELATED_LABEL_HORIZONTAL);
+
+ GridLayout* layout = SetLayoutManager(std::make_unique<GridLayout>());
+ ColumnSet* column_set = layout->AddColumnSet(0);
+ column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL,
+ GridLayout::kFixedSize,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
+ column_set->AddPaddingColumn(0, label_padding);
+ column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1.0,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
+
+ username_ = AddFormRow(this, layout,
+ l10n_util::GetStringUTF16(IDS_LOGIN_USERNAME_LABEL));
+
+ layout->AddPaddingRow(0, related_control_padding);
+
+ password_ = AddFormRow(this, layout,
+ l10n_util::GetStringUTF16(IDS_LOGIN_PASSWORD_LABEL));
+ password_->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
+}
+
+LoginBubbleDialogExample::LoginBubbleDialogExample()
+ : ExampleBase(GetStringUTF8(IDS_LOGIN_SELECT_LABEL).c_str()) {}
+
+LoginBubbleDialogExample::~LoginBubbleDialogExample() = default;
+
+void LoginBubbleDialogExample::CreateExampleView(View* container) {
+ const int related_control_padding = LayoutProvider::Get()->GetDistanceMetric(
+ views::DISTANCE_RELATED_CONTROL_VERTICAL);
+ const int label_padding = LayoutProvider::Get()->GetDistanceMetric(
+ views::DISTANCE_RELATED_LABEL_HORIZONTAL);
+
+ GridLayout* layout =
+ container->SetLayoutManager(std::make_unique<GridLayout>());
+ ColumnSet* column_set = layout->AddColumnSet(0);
+ column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL,
+ GridLayout::kFixedSize,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
+ column_set->AddPaddingColumn(0, label_padding);
+ column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1.0,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
+
+ layout->StartRowWithPadding(0, 0, 0, related_control_padding);
+ button_ = layout->AddView(
+ MdTextButton::Create(this, GetStringUTF16(IDS_LOGIN_SHOW_BUTTON_LABEL)));
+
+ layout->StartRowWithPadding(0, 0, 0, related_control_padding);
+ layout->AddView(std::make_unique<Label>(
+ l10n_util::GetStringUTF16(IDS_LOGIN_USERNAME_LABEL)));
+ username_label_ = layout->AddView(std::make_unique<Label>());
+
+ layout->StartRowWithPadding(0, 0, 0, related_control_padding);
+ layout->AddView(std::make_unique<Label>(
+ l10n_util::GetStringUTF16(IDS_LOGIN_PASSWORD_LABEL)));
+ password_label_ = layout->AddView(std::make_unique<Label>());
+}
+
+void LoginBubbleDialogExample::ButtonPressed(Button* sender,
+ const ui::Event& event) {
+ LoginBubbleDialogView::Show(
+ button_, BubbleBorder::TOP_LEFT,
+ base::BindOnce(&LoginBubbleDialogExample::OnSubmit,
+ base::Unretained(this)));
+}
+
+void LoginBubbleDialogExample::OnSubmit(base::string16 username,
+ base::string16 password) {
+ username_label_->SetText(username);
+ password_label_->SetText(password);
+}
+
+} // namespace examples
+} // namespace views
diff --git a/chromium/ui/views/examples/login_bubble_dialog.h b/chromium/ui/views/examples/login_bubble_dialog.h
new file mode 100644
index 00000000000..d62ad3ef64b
--- /dev/null
+++ b/chromium/ui/views/examples/login_bubble_dialog.h
@@ -0,0 +1,71 @@
+// Copyright 2020 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 UI_VIEWS_EXAMPLES_LOGIN_BUBBLE_DIALOG_H_
+#define UI_VIEWS_EXAMPLES_LOGIN_BUBBLE_DIALOG_H_
+
+#include "base/strings/string16.h"
+#include "ui/views/bubble/bubble_border.h"
+#include "ui/views/bubble/bubble_dialog_delegate_view.h"
+#include "ui/views/controls/button/button.h"
+#include "ui/views/controls/textfield/textfield.h"
+#include "ui/views/controls/textfield/textfield_controller.h"
+#include "ui/views/examples/example_base.h"
+
+namespace views {
+
+class LabelButton;
+
+namespace examples {
+
+class LoginBubbleDialogView : public BubbleDialogDelegateView,
+ public TextfieldController {
+ public:
+ using OnSubmitCallback = base::OnceCallback<void(base::string16 username,
+ base::string16 password)>;
+
+ static void Show(View* anchor_view,
+ BubbleBorder::Arrow anchor_position,
+ OnSubmitCallback accept_callback);
+
+ ~LoginBubbleDialogView() override;
+
+ // TextfieldController:
+ void ContentsChanged(Textfield* sender,
+ const base::string16& new_contents) override;
+
+ private:
+ LoginBubbleDialogView(View* anchor_view,
+ BubbleBorder::Arrow anchor_position,
+ OnSubmitCallback accept_callback);
+
+ Textfield* username_ = nullptr;
+ Textfield* password_ = nullptr;
+};
+
+// Instantiates the login dialog example.
+class LoginBubbleDialogExample : public ExampleBase, public ButtonListener {
+ public:
+ LoginBubbleDialogExample();
+ ~LoginBubbleDialogExample() override;
+
+ // ExampleBase:
+ void CreateExampleView(View* container) override;
+
+ // ButtonListener:
+ void ButtonPressed(Button* sender, const ui::Event& event) override;
+
+ // LoginBubbleDialogController:
+ void OnSubmit(base::string16 username, base::string16 password);
+
+ private:
+ LabelButton* button_ = nullptr;
+ Label* username_label_ = nullptr;
+ Label* password_label_ = nullptr;
+};
+
+} // namespace examples
+} // namespace views
+
+#endif // UI_VIEWS_EXAMPLES_LOGIN_BUBBLE_DIALOG_H_
diff --git a/chromium/ui/views/examples/menu_example.cc b/chromium/ui/views/examples/menu_example.cc
index 01a37140511..76d851f1a6b 100644
--- a/chromium/ui/views/examples/menu_example.cc
+++ b/chromium/ui/views/examples/menu_example.cc
@@ -9,15 +9,18 @@
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/base/models/simple_menu_model.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/menu/menu_runner.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
-using base::ASCIIToUTF16;
+using l10n_util::GetStringUTF16;
+using l10n_util::GetStringUTF8;
namespace views {
namespace examples {
@@ -77,23 +80,25 @@ class ExampleMenuButton : public MenuButton, public ButtonListener {
// ExampleMenuModel ---------------------------------------------------------
ExampleMenuModel::ExampleMenuModel() : ui::SimpleMenuModel(this) {
- AddItem(COMMAND_DO_SOMETHING, ASCIIToUTF16("Do Something"));
+ AddItem(COMMAND_DO_SOMETHING, GetStringUTF16(IDS_MENU_DO_SOMETHING_LABEL));
AddSeparator(ui::NORMAL_SEPARATOR);
- AddRadioItem(COMMAND_SELECT_ASCII, ASCIIToUTF16("ASCII"),
+ AddRadioItem(COMMAND_SELECT_ASCII, GetStringUTF16(IDS_MENU_ASCII_LABEL),
GROUP_MAKE_DECISION);
- AddRadioItem(COMMAND_SELECT_UTF8, ASCIIToUTF16("UTF-8"), GROUP_MAKE_DECISION);
- AddRadioItem(COMMAND_SELECT_UTF16, ASCIIToUTF16("UTF-16"),
+ AddRadioItem(COMMAND_SELECT_UTF8, GetStringUTF16(IDS_MENU_UTF8_LABEL),
+ GROUP_MAKE_DECISION);
+ AddRadioItem(COMMAND_SELECT_UTF16, GetStringUTF16(IDS_MENU_UTF16_LABEL),
GROUP_MAKE_DECISION);
AddSeparator(ui::NORMAL_SEPARATOR);
- AddCheckItem(COMMAND_CHECK_APPLE, ASCIIToUTF16("Apple"));
- AddCheckItem(COMMAND_CHECK_ORANGE, ASCIIToUTF16("Orange"));
- AddCheckItem(COMMAND_CHECK_KIWI, ASCIIToUTF16("Kiwi"));
+ AddCheckItem(COMMAND_CHECK_APPLE, GetStringUTF16(IDS_MENU_APPLE_LABEL));
+ AddCheckItem(COMMAND_CHECK_ORANGE, GetStringUTF16(IDS_MENU_ORANGE_LABEL));
+ AddCheckItem(COMMAND_CHECK_KIWI, GetStringUTF16(IDS_MENU_KIWI_LABEL));
AddSeparator(ui::NORMAL_SEPARATOR);
- AddItem(COMMAND_GO_HOME, ASCIIToUTF16("Go Home"));
+ AddItem(COMMAND_GO_HOME, GetStringUTF16(IDS_MENU_GO_HOME_LABEL));
submenu_ = std::make_unique<ui::SimpleMenuModel>(this);
- submenu_->AddItem(COMMAND_DO_SOMETHING, ASCIIToUTF16("Do Something 2"));
- AddSubMenu(0, ASCIIToUTF16("Submenu"), submenu_.get());
+ submenu_->AddItem(COMMAND_DO_SOMETHING,
+ GetStringUTF16(IDS_MENU_DO_SOMETHING_2_LABEL));
+ AddSubMenu(0, GetStringUTF16(IDS_MENU_SUBMENU_LABEL), submenu_.get());
}
bool ExampleMenuModel::IsCommandIdChecked(int command_id) const {
@@ -189,16 +194,16 @@ ui::SimpleMenuModel* ExampleMenuButton::GetMenuModel() {
} // namespace
-MenuExample::MenuExample() : ExampleBase("Menu") {}
+MenuExample::MenuExample()
+ : ExampleBase(GetStringUTF8(IDS_MENU_SELECT_LABEL).c_str()) {}
MenuExample::~MenuExample() = default;
void MenuExample::CreateExampleView(View* container) {
// We add a button to open a menu.
- ExampleMenuButton* menu_button =
- new ExampleMenuButton(ASCIIToUTF16("Open a menu"));
container->SetLayoutManager(std::make_unique<FillLayout>());
- container->AddChildView(menu_button);
+ container->AddChildView(std::make_unique<ExampleMenuButton>(
+ GetStringUTF16(IDS_MENU_BUTTON_LABEL)));
}
} // namespace examples
diff --git a/chromium/ui/views/examples/message_box_example.cc b/chromium/ui/views/examples/message_box_example.cc
index 496dfc95a29..13aa6925d66 100644
--- a/chromium/ui/views/examples/message_box_example.cc
+++ b/chromium/ui/views/examples/message_box_example.cc
@@ -8,18 +8,22 @@
#include <utility>
#include "base/strings/utf_string_conversions.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/message_box_view.h"
#include "ui/views/examples/examples_window.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/view.h"
-using base::ASCIIToUTF16;
+using l10n_util::GetStringUTF16;
+using l10n_util::GetStringUTF8;
namespace views {
namespace examples {
-MessageBoxExample::MessageBoxExample() : ExampleBase("Message Box View") {}
+MessageBoxExample::MessageBoxExample()
+ : ExampleBase(GetStringUTF8(IDS_MESSAGE_SELECT_LABEL).c_str()) {}
MessageBoxExample::~MessageBoxExample() = default;
@@ -28,38 +32,42 @@ void MessageBoxExample::CreateExampleView(View* container) {
container->SetLayoutManager(std::make_unique<views::GridLayout>());
auto message_box_view = std::make_unique<MessageBoxView>(
- MessageBoxView::InitParams(ASCIIToUTF16("Hello, world!")));
- message_box_view->SetCheckBoxLabel(ASCIIToUTF16("Check Box"));
+ MessageBoxView::InitParams(GetStringUTF16(IDS_MESSAGE_INTRO_LABEL)));
+ message_box_view->SetCheckBoxLabel(
+ GetStringUTF16(IDS_MESSAGE_CHECK_BOX_LABEL));
const int message_box_column = 0;
ColumnSet* column_set = layout->AddColumnSet(message_box_column);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout->StartRow(1 /* expand */, message_box_column);
message_box_view_ = layout->AddView(std::move(message_box_view));
const int button_column = 1;
column_set = layout->AddColumnSet(button_column);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0.5f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0.5f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout->StartRow(0 /* no expand */, button_column);
- status_ = layout->AddView(
- std::make_unique<LabelButton>(this, ASCIIToUTF16("Show Status")));
- toggle_ = layout->AddView(
- std::make_unique<LabelButton>(this, ASCIIToUTF16("Toggle Checkbox")));
+ status_ = layout->AddView(std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_MESSAGE_STATUS_LABEL)));
+ toggle_ = layout->AddView(std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_MESSAGE_TOGGLE_LABEL)));
}
void MessageBoxExample::ButtonPressed(Button* sender, const ui::Event& event) {
if (sender == status_) {
message_box_view_->SetCheckBoxLabel(
- ASCIIToUTF16(message_box_view_->IsCheckBoxSelected() ? "on" : "off"));
- LogStatus(message_box_view_->IsCheckBoxSelected()
- ? "Check Box Selected"
- : "Check Box Not Selected");
+ message_box_view_->IsCheckBoxSelected()
+ ? GetStringUTF16(IDS_MESSAGE_ON_LABEL)
+ : GetStringUTF16(IDS_MESSAGE_OFF_LABEL));
+ LogStatus(
+ message_box_view_->IsCheckBoxSelected()
+ ? GetStringUTF8(IDS_MESSAGE_CHECK_SELECTED_LABEL).c_str()
+ : GetStringUTF8(IDS_MESSAGE_CHECK_NOT_SELECTED_LABEL).c_str());
} else if (sender == toggle_) {
message_box_view_->SetCheckBoxSelected(
!message_box_view_->IsCheckBoxSelected());
diff --git a/chromium/ui/views/examples/multiline_example.cc b/chromium/ui/views/examples/multiline_example.cc
index c8b056c9cdc..dea9016b42e 100644
--- a/chromium/ui/views/examples/multiline_example.cc
+++ b/chromium/ui/views/examples/multiline_example.cc
@@ -12,6 +12,7 @@
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/events/event.h"
#include "ui/gfx/render_text.h"
#include "ui/views/background.h"
@@ -19,10 +20,12 @@
#include "ui/views/controls/button/checkbox.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/textfield/textfield.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/view.h"
-using base::ASCIIToUTF16;
+using l10n_util::GetStringUTF16;
+using l10n_util::GetStringUTF8;
namespace views {
namespace examples {
@@ -123,7 +126,8 @@ class MultilineExample::RenderTextView : public View {
DISALLOW_COPY_AND_ASSIGN(RenderTextView);
};
-MultilineExample::MultilineExample() : ExampleBase("Multiline RenderText") {}
+MultilineExample::MultilineExample()
+ : ExampleBase(GetStringUTF8(IDS_MULTILINE_SELECT_LABEL).c_str()) {}
MultilineExample::~MultilineExample() = default;
@@ -142,12 +146,12 @@ void MultilineExample::CreateExampleView(View* container) {
label->SetBorder(CreateSolidBorder(2, SK_ColorCYAN));
auto label_checkbox =
- std::make_unique<Checkbox>(ASCIIToUTF16("views::Label:"), this);
+ std::make_unique<Checkbox>(GetStringUTF16(IDS_MULTILINE_LABEL), this);
label_checkbox->SetChecked(true);
label_checkbox->set_request_focus_on_press(false);
- auto elision_checkbox =
- std::make_unique<Checkbox>(ASCIIToUTF16("elide text?"), this);
+ auto elision_checkbox = std::make_unique<Checkbox>(
+ GetStringUTF16(IDS_MULTILINE_ELIDE_LABEL), this);
elision_checkbox->SetChecked(false);
elision_checkbox->set_request_focus_on_press(false);
@@ -160,12 +164,13 @@ void MultilineExample::CreateExampleView(View* container) {
ColumnSet* column_set = layout->AddColumnSet(0);
column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0.0f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1.0f,
- GridLayout::FIXED, 0, 0);
+ GridLayout::ColumnSize::kFixed, 0, 0);
layout->StartRow(0, 0);
- layout->AddView(std::make_unique<Label>(ASCIIToUTF16("gfx::RenderText:")));
+ layout->AddView(
+ std::make_unique<Label>(GetStringUTF16(IDS_MULTILINE_RENDER_TEXT_LABEL)));
render_text_view_ = layout->AddView(std::move(render_text_view));
layout->StartRow(0, 0);
@@ -176,7 +181,8 @@ void MultilineExample::CreateExampleView(View* container) {
elision_checkbox_ = layout->AddView(std::move(elision_checkbox));
layout->StartRow(0, 0);
- layout->AddView(std::make_unique<Label>(ASCIIToUTF16("Sample Text:")));
+ layout->AddView(
+ std::make_unique<Label>(GetStringUTF16(IDS_MULTILINE_SAMPLE_TEXT_LABEL)));
textfield_ = layout->AddView(std::move(textfield));
}
diff --git a/chromium/ui/views/examples/native_theme_example.cc b/chromium/ui/views/examples/native_theme_example.cc
index f2fd54edc0c..04f32e5eb02 100644
--- a/chromium/ui/views/examples/native_theme_example.cc
+++ b/chromium/ui/views/examples/native_theme_example.cc
@@ -14,10 +14,12 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/native_theme/native_theme.h"
#include "ui/views/background.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/scroll_view.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/grid_layout.h"
@@ -69,9 +71,9 @@ std::unique_ptr<View> CreateAllColorsView() {
auto* layout = container->SetLayoutManager(std::make_unique<GridLayout>());
auto* column_set = layout->AddColumnSet(0);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1.0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1.0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
InsertColorRow(layout, COLOR_LABEL_ARGS(kColorId_WindowBackground));
InsertColorRow(layout, COLOR_LABEL_ARGS(kColorId_DialogBackground));
InsertColorRow(layout, COLOR_LABEL_ARGS(kColorId_DialogForeground));
@@ -80,7 +82,6 @@ std::unique_ptr<View> CreateAllColorsView() {
InsertColorRow(layout, COLOR_LABEL_ARGS(kColorId_UnfocusedBorderColor));
InsertColorRow(layout, COLOR_LABEL_ARGS(kColorId_ButtonEnabledColor));
InsertColorRow(layout, COLOR_LABEL_ARGS(kColorId_ButtonDisabledColor));
- InsertColorRow(layout, COLOR_LABEL_ARGS(kColorId_ButtonPressedShade));
InsertColorRow(layout, COLOR_LABEL_ARGS(kColorId_ButtonUncheckedColor));
InsertColorRow(layout, COLOR_LABEL_ARGS(kColorId_ProminentButtonColor));
InsertColorRow(layout,
@@ -101,6 +102,7 @@ std::unique_ptr<View> CreateAllColorsView() {
InsertColorRow(layout, COLOR_LABEL_ARGS(kColorId_MenuSeparatorColor));
InsertColorRow(layout, COLOR_LABEL_ARGS(kColorId_MenuBackgroundColor));
InsertColorRow(layout, COLOR_LABEL_ARGS(kColorId_MenuBorderColor));
+ InsertColorRow(layout, COLOR_LABEL_ARGS(kColorId_MenuIconColor));
InsertColorRow(layout,
COLOR_LABEL_ARGS(kColorId_HighlightedMenuItemBackgroundColor));
InsertColorRow(layout,
@@ -168,7 +170,8 @@ std::unique_ptr<View> CreateAllColorsView() {
} // namespace
-NativeThemeExample::NativeThemeExample() : ExampleBase("Native Theme Colors") {}
+NativeThemeExample::NativeThemeExample()
+ : ExampleBase(l10n_util::GetStringUTF8(IDS_THEME_SELECT_LABEL).c_str()) {}
NativeThemeExample::~NativeThemeExample() = default;
diff --git a/chromium/ui/views/examples/progress_bar_example.cc b/chromium/ui/views/examples/progress_bar_example.cc
index d59bc19b851..4879f5fe217 100644
--- a/chromium/ui/views/examples/progress_bar_example.cc
+++ b/chromium/ui/views/examples/progress_bar_example.cc
@@ -10,15 +10,21 @@
#include "base/numerics/ranges.h"
#include "base/strings/utf_string_conversions.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/progress_bar.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/view.h"
+using l10n_util::GetStringUTF16;
+using l10n_util::GetStringUTF8;
+
namespace views {
namespace examples {
-ProgressBarExample::ProgressBarExample() : ExampleBase("Progress Bar") {}
+ProgressBarExample::ProgressBarExample()
+ : ExampleBase(GetStringUTF8(IDS_PROGRESS_SELECT_LABEL).c_str()) {}
ProgressBarExample::~ProgressBarExample() = default;
@@ -28,13 +34,13 @@ void ProgressBarExample::CreateExampleView(View* container) {
ColumnSet* column_set = layout->AddColumnSet(0);
column_set->AddColumn(GridLayout::TRAILING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddPaddingColumn(0, 8);
column_set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
- GridLayout::FIXED, 200, 0);
+ GridLayout::ColumnSize::kFixed, 200, 0);
column_set->AddPaddingColumn(0, 8);
column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout->StartRow(0, 0);
minus_button_ =
@@ -45,14 +51,14 @@ void ProgressBarExample::CreateExampleView(View* container) {
layout->StartRowWithPadding(0, 0, 0, 10);
layout->AddView(
- std::make_unique<Label>(base::ASCIIToUTF16("Infinite loader:")));
+ std::make_unique<Label>(GetStringUTF16(IDS_PROGRESS_LOADER_LABEL)));
auto infinite_bar = std::make_unique<ProgressBar>();
infinite_bar->SetValue(-1);
layout->AddView(std::move(infinite_bar));
layout->StartRowWithPadding(0, 0, 0, 10);
- layout->AddView(std::make_unique<Label>(
- base::ASCIIToUTF16("Infinite loader (very short):")));
+ layout->AddView(
+ std::make_unique<Label>(GetStringUTF16(IDS_PROGRESS_LOADER_SHORT_LABEL)));
auto shorter_bar = std::make_unique<ProgressBar>(2);
shorter_bar->SetValue(-1);
layout->AddView(std::move(shorter_bar));
diff --git a/chromium/ui/views/examples/radio_button_example.cc b/chromium/ui/views/examples/radio_button_example.cc
index b9644096d1f..598c8b18a20 100644
--- a/chromium/ui/views/examples/radio_button_example.cc
+++ b/chromium/ui/views/examples/radio_button_example.cc
@@ -11,12 +11,17 @@
#include "base/stl_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/radio_button.h"
#include "ui/views/examples/examples_window.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/view.h"
+using l10n_util::GetStringUTF16;
+using l10n_util::GetStringUTF8;
+
namespace views {
namespace examples {
@@ -28,7 +33,8 @@ const char* BoolToOnOff(bool value) {
} // namespace
-RadioButtonExample::RadioButtonExample() : ExampleBase("Radio Button") {}
+RadioButtonExample::RadioButtonExample()
+ : ExampleBase(GetStringUTF8(IDS_RADIO_BUTTON_SELECT_LABEL).c_str()) {}
RadioButtonExample::~RadioButtonExample() = default;
@@ -37,7 +43,7 @@ void RadioButtonExample::CreateExampleView(View* container) {
container->SetLayoutManager(std::make_unique<views::GridLayout>());
ColumnSet* column_set = layout->AddColumnSet(0);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1.0f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
const int group = 1;
for (size_t i = 0; i < 3; ++i) {
layout->StartRow(0, 0);
@@ -48,11 +54,11 @@ void RadioButtonExample::CreateExampleView(View* container) {
}
layout->StartRow(0, 0);
- select_ = layout->AddView(
- std::make_unique<LabelButton>(this, base::ASCIIToUTF16("Select")));
+ select_ = layout->AddView(std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_RADIO_BUTTON_SELECT_BUTTON_LABEL)));
layout->StartRow(0, 0);
- status_ = layout->AddView(
- std::make_unique<LabelButton>(this, base::ASCIIToUTF16("Show Status")));
+ status_ = layout->AddView(std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_RADIO_BUTTON_STATUS_LABEL)));
}
void RadioButtonExample::ButtonPressed(Button* sender, const ui::Event& event) {
diff --git a/chromium/ui/views/examples/scroll_view_example.cc b/chromium/ui/views/examples/scroll_view_example.cc
index 48082b47df1..90a68d46c93 100644
--- a/chromium/ui/views/examples/scroll_view_example.cc
+++ b/chromium/ui/views/examples/scroll_view_example.cc
@@ -11,17 +11,20 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "cc/paint/paint_flags.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/skia_paint_util.h"
#include "ui/views/background.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/button/radio_button.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/view.h"
-using base::ASCIIToUTF16;
+using l10n_util::GetStringUTF16;
+using l10n_util::GetStringUTF8;
namespace views {
namespace examples {
@@ -42,8 +45,10 @@ class ScrollViewExample::ScrollableView : public View {
views::BoxLayout::Orientation::kVertical));
container->AddChildView(std::move(view));
};
- add_child(std::make_unique<LabelButton>(nullptr, ASCIIToUTF16("Button")));
- add_child(std::make_unique<RadioButton>(ASCIIToUTF16("Radio Button"), 0));
+ add_child(std::make_unique<LabelButton>(
+ nullptr, GetStringUTF16(IDS_SCROLL_VIEW_BUTTON_LABEL)));
+ add_child(std::make_unique<RadioButton>(
+ GetStringUTF16(IDS_SCROLL_VIEW_RADIO_BUTTON_LABEL), 0));
layout_manager->SetDefaultFlex(1);
}
@@ -67,7 +72,8 @@ class ScrollViewExample::ScrollableView : public View {
DISALLOW_COPY_AND_ASSIGN(ScrollableView);
};
-ScrollViewExample::ScrollViewExample() : ExampleBase("Scroll View") {}
+ScrollViewExample::ScrollViewExample()
+ : ExampleBase(GetStringUTF8(IDS_SCROLL_VIEW_SELECT_LABEL).c_str()) {}
ScrollViewExample::~ScrollViewExample() = default;
@@ -83,7 +89,7 @@ void ScrollViewExample::CreateExampleView(View* container) {
// Add scroll view.
ColumnSet* column_set = layout->AddColumnSet(0);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout->StartRow(1, 0);
scroll_view_ = layout->AddView(std::move(scroll_view));
@@ -91,19 +97,19 @@ void ScrollViewExample::CreateExampleView(View* container) {
column_set = layout->AddColumnSet(1);
for (size_t i = 0; i < 5; i++) {
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
}
layout->StartRow(0, 1);
- wide_ = layout->AddView(
- std::make_unique<LabelButton>(this, ASCIIToUTF16("Wide")));
- tall_ = layout->AddView(
- std::make_unique<LabelButton>(this, ASCIIToUTF16("Tall")));
- big_square_ = layout->AddView(
- std::make_unique<LabelButton>(this, ASCIIToUTF16("Big Square")));
- small_square_ = layout->AddView(
- std::make_unique<LabelButton>(this, ASCIIToUTF16("Small Square")));
- scroll_to_ = layout->AddView(
- std::make_unique<LabelButton>(this, ASCIIToUTF16("Scroll to")));
+ wide_ = layout->AddView(std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_SCROLL_VIEW_WIDE_LABEL)));
+ tall_ = layout->AddView(std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_SCROLL_VIEW_TALL_LABEL)));
+ big_square_ = layout->AddView(std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_SCROLL_VIEW_BIG_SQUARE_LABEL)));
+ small_square_ = layout->AddView(std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_SCROLL_VIEW_SMALL_SQUARE_LABEL)));
+ scroll_to_ = layout->AddView(std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_SCROLL_VIEW_SCROLL_TO_LABEL)));
}
void ScrollViewExample::ButtonPressed(Button* sender, const ui::Event& event) {
diff --git a/chromium/ui/views/examples/slider_example.cc b/chromium/ui/views/examples/slider_example.cc
index 2f151f3f5b5..4b23bee018f 100644
--- a/chromium/ui/views/examples/slider_example.cc
+++ b/chromium/ui/views/examples/slider_example.cc
@@ -8,29 +8,30 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/slider.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/view.h"
namespace views {
namespace examples {
-SliderExample::SliderExample() : ExampleBase("Slider") {}
+SliderExample::SliderExample()
+ : ExampleBase(l10n_util::GetStringUTF8(IDS_SLIDER_SELECT_LABEL).c_str()) {}
SliderExample::~SliderExample() = default;
void SliderExample::CreateExampleView(View* container) {
- label_ = new Label();
- slider_ = new views::Slider(this);
+ label_ = container->AddChildView(std::make_unique<Label>());
+ slider_ = container->AddChildView(std::make_unique<Slider>(this));
slider_->SetValue(0.5);
container->SetLayoutManager(std::make_unique<BoxLayout>(
BoxLayout::Orientation::kHorizontal, gfx::Insets(3), 3));
- container->AddChildView(slider_);
- container->AddChildView(label_);
}
void SliderExample::SliderValueChanged(Slider* sender,
diff --git a/chromium/ui/views/examples/tabbed_pane_example.cc b/chromium/ui/views/examples/tabbed_pane_example.cc
index 15fedb4ba88..b561f983ffc 100644
--- a/chromium/ui/views/examples/tabbed_pane_example.cc
+++ b/chromium/ui/views/examples/tabbed_pane_example.cc
@@ -8,27 +8,33 @@
#include <utility>
#include "base/strings/utf_string_conversions.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/tabbed_pane/tabbed_pane.h"
#include "ui/views/examples/examples_window.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/grid_layout.h"
-using base::ASCIIToUTF16;
+using l10n_util::GetStringUTF16;
+using l10n_util::GetStringUTF8;
namespace views {
namespace examples {
-TabbedPaneExample::TabbedPaneExample() : ExampleBase("Tabbed Pane") {}
+TabbedPaneExample::TabbedPaneExample()
+ : ExampleBase(GetStringUTF8(IDS_TABBED_PANE_SELECT_LABEL).c_str()) {}
TabbedPaneExample::~TabbedPaneExample() = default;
void TabbedPaneExample::CreateExampleView(View* container) {
auto tabbed_pane = std::make_unique<TabbedPane>();
tabbed_pane->set_listener(this);
- auto add = std::make_unique<LabelButton>(this, ASCIIToUTF16("Add"));
- auto add_at = std::make_unique<LabelButton>(this, ASCIIToUTF16("Add At 1"));
- auto select_at =
- std::make_unique<LabelButton>(this, ASCIIToUTF16("Select At 1"));
+ auto add = std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_TABBED_PANE_ADD_LABEL));
+ auto add_at = std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_TABBED_PANE_ADD_1_LABEL));
+ auto select_at = std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_TABBED_PANE_SELECT_1_LABEL));
GridLayout* layout =
container->SetLayoutManager(std::make_unique<views::GridLayout>());
@@ -36,21 +42,21 @@ void TabbedPaneExample::CreateExampleView(View* container) {
const int tabbed_pane_column = 0;
ColumnSet* column_set = layout->AddColumnSet(tabbed_pane_column);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1.0f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout->StartRow(1 /* expand */, tabbed_pane_column);
tabbed_pane_ = layout->AddView(std::move(tabbed_pane));
// Create a few tabs with a button first.
- AddButton("Tab 1");
- AddButton("Tab 2");
- AddButton("Tab 3");
+ AddButton(GetStringUTF16(IDS_TABBED_PANE_TAB_1_LABEL));
+ AddButton(GetStringUTF16(IDS_TABBED_PANE_TAB_2_LABEL));
+ AddButton(GetStringUTF16(IDS_TABBED_PANE_TAB_3_LABEL));
// Add control buttons horizontally.
const int button_column = 1;
column_set = layout->AddColumnSet(button_column);
for (size_t i = 0; i < 3; i++) {
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1.0f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
}
layout->StartRow(0 /* no expand */, button_column);
@@ -61,9 +67,9 @@ void TabbedPaneExample::CreateExampleView(View* container) {
void TabbedPaneExample::ButtonPressed(Button* sender, const ui::Event& event) {
if (sender == add_) {
- AddButton("Added");
+ AddButton(GetStringUTF16(IDS_TABBED_PANE_ADDED_LABEL));
} else if (sender == add_at_) {
- const base::string16 label = ASCIIToUTF16("Added at 1");
+ const base::string16 label = GetStringUTF16(IDS_TABBED_PANE_ADDED_1_LABEL);
tabbed_pane_->AddTabAtIndex(1, label,
std::make_unique<LabelButton>(nullptr, label));
} else if (sender == select_at_) {
@@ -83,9 +89,8 @@ void TabbedPaneExample::PrintCurrentStatus() {
tabbed_pane_->GetTabCount(), tabbed_pane_->GetSelectedTabIndex());
}
-void TabbedPaneExample::AddButton(const std::string& label) {
- tabbed_pane_->AddTab(ASCIIToUTF16(label), std::make_unique<LabelButton>(
- nullptr, ASCIIToUTF16(label)));
+void TabbedPaneExample::AddButton(const base::string16& label) {
+ tabbed_pane_->AddTab(label, std::make_unique<LabelButton>(nullptr, label));
}
} // namespace examples
diff --git a/chromium/ui/views/examples/tabbed_pane_example.h b/chromium/ui/views/examples/tabbed_pane_example.h
index 5806ca9c5c2..ce4fe34d4e9 100644
--- a/chromium/ui/views/examples/tabbed_pane_example.h
+++ b/chromium/ui/views/examples/tabbed_pane_example.h
@@ -38,7 +38,7 @@ class VIEWS_EXAMPLES_EXPORT TabbedPaneExample : public ExampleBase,
// Print the status of the tab in the status area.
void PrintCurrentStatus();
- void AddButton(const std::string& label);
+ void AddButton(const base::string16& label);
// The tabbed pane to be tested.
TabbedPane* tabbed_pane_;
diff --git a/chromium/ui/views/examples/table_example.cc b/chromium/ui/views/examples/table_example.cc
index e5913af4951..c272f3b3eca 100644
--- a/chromium/ui/views/examples/table_example.cc
+++ b/chromium/ui/views/examples/table_example.cc
@@ -67,20 +67,20 @@ void TableExample::CreateExampleView(View* container) {
ColumnSet* column_set = layout->AddColumnSet(0);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout->StartRow(1 /* expand */, 0);
table_ = table.get();
layout->AddView(TableView::CreateScrollViewWithTable(std::move(table)));
column_set = layout->AddColumnSet(1);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0.5f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0.5f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0.5f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0.5f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout->StartRow(0 /* no expand */, 1);
diff --git a/chromium/ui/views/examples/text_example.cc b/chromium/ui/views/examples/text_example.cc
index 61a68575fde..7e0e015d872 100644
--- a/chromium/ui/views/examples/text_example.cc
+++ b/chromium/ui/views/examples/text_example.cc
@@ -168,10 +168,10 @@ void TextExample::CreateExampleView(View* container) {
ColumnSet* column_set = layout->AddColumnSet(0);
column_set->AddPaddingColumn(0, 8);
column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0.1f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
for (int i = 0; i < kNumColumns - 1; i++)
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0.1f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddPaddingColumn(0, 8);
h_align_cb_ = AddCombobox(layout, "H-Align", kHorizontalAligments,
@@ -196,7 +196,7 @@ void TextExample::CreateExampleView(View* container) {
column_set = layout->AddColumnSet(1);
column_set->AddPaddingColumn(0, 16);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddPaddingColumn(0, 16);
layout->StartRow(1, 1);
text_view_ = layout->AddView(std::move(text_view));
diff --git a/chromium/ui/views/examples/textfield_example.cc b/chromium/ui/views/examples/textfield_example.cc
index 4daa1e35f4b..7f1d9b2ddc4 100644
--- a/chromium/ui/views/examples/textfield_example.cc
+++ b/chromium/ui/views/examples/textfield_example.cc
@@ -10,6 +10,7 @@
#include <utility>
#include "base/strings/utf_string_conversions.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/events/event.h"
#include "ui/gfx/color_palette.h"
#include "ui/gfx/range/range.h"
@@ -18,11 +19,12 @@
#include "ui/views/controls/label.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/examples/examples_window.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/grid_layout.h"
#include "ui/views/view.h"
-using base::ASCIIToUTF16;
-using base::UTF16ToUTF8;
+using l10n_util::GetStringUTF16;
+using l10n_util::GetStringUTF8;
namespace views {
namespace examples {
@@ -41,7 +43,8 @@ T* MakeRow(GridLayout* layout,
} // namespace
-TextfieldExample::TextfieldExample() : ExampleBase("Textfield") {}
+TextfieldExample::TextfieldExample()
+ : ExampleBase(GetStringUTF8(IDS_TEXTFIELD_SELECT_LABEL).c_str()) {}
TextfieldExample::~TextfieldExample() = default;
@@ -50,14 +53,15 @@ void TextfieldExample::CreateExampleView(View* container) {
name->set_controller(this);
auto password = std::make_unique<Textfield>();
password->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
- password->SetPlaceholderText(ASCIIToUTF16("password"));
+ password->SetPlaceholderText(
+ GetStringUTF16(IDS_TEXTFIELD_PASSWORD_PLACEHOLDER));
password->set_controller(this);
auto disabled = std::make_unique<Textfield>();
disabled->SetEnabled(false);
- disabled->SetText(ASCIIToUTF16("disabled"));
+ disabled->SetText(GetStringUTF16(IDS_TEXTFIELD_DISABLED_PLACEHOLDER));
auto read_only = std::make_unique<Textfield>();
read_only->SetReadOnly(true);
- read_only->SetText(ASCIIToUTF16("read only"));
+ read_only->SetText(GetStringUTF16(IDS_TEXTFFIELD_READ_ONLY_PLACEHOLDER));
auto invalid = std::make_unique<Textfield>();
invalid->SetInvalid(true);
auto rtl = std::make_unique<Textfield>();
@@ -68,57 +72,59 @@ void TextfieldExample::CreateExampleView(View* container) {
ColumnSet* column_set = layout->AddColumnSet(0);
column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0.2f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0.8f,
- GridLayout::USE_PREF, 0, 0);
-
- name_ = MakeRow(layout, std::make_unique<Label>(ASCIIToUTF16("Name:")),
- std::move(name));
- password_ =
- MakeRow(layout, std::make_unique<Label>(ASCIIToUTF16("Password:")),
- std::move(password));
- disabled_ =
- MakeRow(layout, std::make_unique<Label>(ASCIIToUTF16("Disabled:")),
- std::move(disabled));
- read_only_ =
- MakeRow(layout, std::make_unique<Label>(ASCIIToUTF16("Read Only:")),
- std::move(read_only));
- invalid_ = MakeRow(layout, std::make_unique<Label>(ASCIIToUTF16("Invalid:")),
- std::move(invalid));
- rtl_ = MakeRow(layout, std::make_unique<Label>(ASCIIToUTF16("RTL:")),
- std::move(rtl));
- MakeRow<View, Label>(layout, nullptr,
- std::make_unique<Label>(ASCIIToUTF16("Name:")));
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
+
+ name_ = MakeRow(
+ layout, std::make_unique<Label>(GetStringUTF16(IDS_TEXTFIELD_NAME_LABEL)),
+ std::move(name));
+ password_ = MakeRow(
+ layout,
+ std::make_unique<Label>(GetStringUTF16(IDS_TEXTFIELD_PASSWORD_LABEL)),
+ std::move(password));
+ disabled_ = MakeRow(
+ layout,
+ std::make_unique<Label>(GetStringUTF16(IDS_TEXTFIELD_DISABLED_LABEL)),
+ std::move(disabled));
+ read_only_ = MakeRow(
+ layout,
+ std::make_unique<Label>(GetStringUTF16(IDS_TEXTFIELD_READ_ONLY_LABEL)),
+ std::move(read_only));
+ invalid_ = MakeRow(
+ layout,
+ std::make_unique<Label>(GetStringUTF16(IDS_TEXTFIELD_INVALID_LABEL)),
+ std::move(invalid));
+ rtl_ = MakeRow(
+ layout, std::make_unique<Label>(GetStringUTF16(IDS_TEXTFIELD_RTL_LABEL)),
+ std::move(rtl));
+ MakeRow<View, Label>(
+ layout, nullptr,
+ std::make_unique<Label>(GetStringUTF16(IDS_TEXTFIELD_NAME_LABEL)));
show_password_ = MakeRow<View, LabelButton>(
layout, nullptr,
- std::make_unique<LabelButton>(this, ASCIIToUTF16("Show password")));
+ std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_TEXTFIELD_SHOW_PASSWORD_LABEL)));
set_background_ = MakeRow<View, LabelButton>(
layout, nullptr,
std::make_unique<LabelButton>(
- this, ASCIIToUTF16("Set non-default background")));
+ this, GetStringUTF16(IDS_TEXTFIELD_BACKGROUND_LABEL)));
clear_all_ = MakeRow<View, LabelButton>(
layout, nullptr,
- std::make_unique<LabelButton>(this, ASCIIToUTF16("Clear All")));
+ std::make_unique<LabelButton>(this,
+ GetStringUTF16(IDS_TEXTFIELD_CLEAR_LABEL)));
append_ = MakeRow<View, LabelButton>(
layout, nullptr,
- std::make_unique<LabelButton>(this, ASCIIToUTF16("Append")));
+ std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_TEXTFIELD_APPEND_LABEL)));
set_ = MakeRow<View, LabelButton>(
layout, nullptr,
- std::make_unique<LabelButton>(this, ASCIIToUTF16("Set")));
+ std::make_unique<LabelButton>(this,
+ GetStringUTF16(IDS_TEXTFIELD_SET_LABEL)));
set_style_ = MakeRow<View, LabelButton>(
layout, nullptr,
- std::make_unique<LabelButton>(this, ASCIIToUTF16("Set Styles")));
-}
-
-void TextfieldExample::ContentsChanged(Textfield* sender,
- const base::string16& new_contents) {
- if (sender == name_) {
- PrintStatus("Name [%s]", UTF16ToUTF8(new_contents).c_str());
- } else if (sender == password_) {
- PrintStatus("Password [%s]", UTF16ToUTF8(new_contents).c_str());
- } else {
- NOTREACHED();
- }
+ std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_TEXTFIELD_SET_STYLE_LABEL)));
}
bool TextfieldExample::HandleKeyEvent(Textfield* sender,
@@ -134,7 +140,8 @@ bool TextfieldExample::HandleMouseEvent(Textfield* sender,
void TextfieldExample::ButtonPressed(Button* sender, const ui::Event& event) {
if (sender == show_password_) {
- PrintStatus("Password [%s]", UTF16ToUTF8(password_->GetText()).c_str());
+ PrintStatus("Password [%s]",
+ base::UTF16ToUTF8(password_->GetText()).c_str());
} else if (sender == set_background_) {
password_->SetBackgroundColor(gfx::kGoogleRed300);
} else if (sender == clear_all_) {
@@ -146,19 +153,19 @@ void TextfieldExample::ButtonPressed(Button* sender, const ui::Event& event) {
invalid_->SetText(empty);
rtl_->SetText(empty);
} else if (sender == append_) {
- name_->AppendText(ASCIIToUTF16("[append]"));
- password_->AppendText(ASCIIToUTF16("[append]"));
- disabled_->SetText(ASCIIToUTF16("[append]"));
- read_only_->AppendText(ASCIIToUTF16("[append]"));
- invalid_->AppendText(ASCIIToUTF16("[append]"));
- rtl_->AppendText(ASCIIToUTF16("[append]"));
+ name_->AppendText(GetStringUTF16(IDS_TEXTFIELD_APPEND_UPDATE_TEXT));
+ password_->AppendText(GetStringUTF16(IDS_TEXTFIELD_APPEND_UPDATE_TEXT));
+ disabled_->SetText(GetStringUTF16(IDS_TEXTFIELD_APPEND_UPDATE_TEXT));
+ read_only_->AppendText(GetStringUTF16(IDS_TEXTFIELD_APPEND_UPDATE_TEXT));
+ invalid_->AppendText(GetStringUTF16(IDS_TEXTFIELD_APPEND_UPDATE_TEXT));
+ rtl_->AppendText(GetStringUTF16(IDS_TEXTFIELD_APPEND_UPDATE_TEXT));
} else if (sender == set_) {
- name_->SetText(ASCIIToUTF16("[set]"));
- password_->SetText(ASCIIToUTF16("[set]"));
- disabled_->SetText(ASCIIToUTF16("[set]"));
- read_only_->SetText(ASCIIToUTF16("[set]"));
- invalid_->SetText(ASCIIToUTF16("[set]"));
- rtl_->SetText(ASCIIToUTF16("[set]"));
+ name_->SetText(GetStringUTF16(IDS_TEXTFIELD_SET_UPDATE_TEXT));
+ password_->SetText(GetStringUTF16(IDS_TEXTFIELD_SET_UPDATE_TEXT));
+ disabled_->SetText(GetStringUTF16(IDS_TEXTFIELD_SET_UPDATE_TEXT));
+ read_only_->SetText(GetStringUTF16(IDS_TEXTFIELD_SET_UPDATE_TEXT));
+ invalid_->SetText(GetStringUTF16(IDS_TEXTFIELD_SET_UPDATE_TEXT));
+ rtl_->SetText(GetStringUTF16(IDS_TEXTFIELD_SET_UPDATE_TEXT));
} else if (sender == set_style_) {
if (!name_->GetText().empty()) {
name_->SetColor(SK_ColorGREEN);
diff --git a/chromium/ui/views/examples/textfield_example.h b/chromium/ui/views/examples/textfield_example.h
index 9ea0144b72d..6ab66ff47f9 100644
--- a/chromium/ui/views/examples/textfield_example.h
+++ b/chromium/ui/views/examples/textfield_example.h
@@ -31,8 +31,6 @@ class VIEWS_EXAMPLES_EXPORT TextfieldExample : public ExampleBase,
private:
// TextfieldController:
- void ContentsChanged(Textfield* sender,
- const base::string16& new_contents) override;
bool HandleKeyEvent(Textfield* sender,
const ui::KeyEvent& key_event) override;
bool HandleMouseEvent(Textfield* sender,
diff --git a/chromium/ui/views/examples/throbber_example.cc b/chromium/ui/views/examples/throbber_example.cc
index 6ad3f26e663..4d90b9e804c 100644
--- a/chromium/ui/views/examples/throbber_example.cc
+++ b/chromium/ui/views/examples/throbber_example.cc
@@ -7,7 +7,9 @@
#include <memory>
#include "base/macros.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/throbber.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/view.h"
@@ -18,8 +20,8 @@ namespace {
class ThrobberView : public View {
public:
- ThrobberView() : throbber_(new Throbber()) {
- AddChildView(throbber_);
+ ThrobberView() {
+ throbber_ = AddChildView(std::make_unique<Throbber>());
throbber_->Start();
}
@@ -57,13 +59,15 @@ class ThrobberView : public View {
} // namespace
-ThrobberExample::ThrobberExample() : ExampleBase("Throbber") {}
+ThrobberExample::ThrobberExample()
+ : ExampleBase(l10n_util::GetStringUTF8(IDS_THROBBER_SELECT_LABEL).c_str()) {
+}
ThrobberExample::~ThrobberExample() = default;
void ThrobberExample::CreateExampleView(View* container) {
container->SetLayoutManager(std::make_unique<FillLayout>());
- container->AddChildView(new ThrobberView());
+ container->AddChildView(std::make_unique<ThrobberView>());
}
} // namespace examples
diff --git a/chromium/ui/views/examples/toggle_button_example.cc b/chromium/ui/views/examples/toggle_button_example.cc
index 88084f387e1..3bc279ffc1e 100644
--- a/chromium/ui/views/examples/toggle_button_example.cc
+++ b/chromium/ui/views/examples/toggle_button_example.cc
@@ -9,24 +9,27 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/views/controls/button/toggle_button.h"
#include "ui/views/examples/examples_window.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/box_layout.h"
namespace views {
namespace examples {
-ToggleButtonExample::ToggleButtonExample() : ExampleBase("Toggle button") {}
+ToggleButtonExample::ToggleButtonExample()
+ : ExampleBase(
+ l10n_util::GetStringUTF8(IDS_TOGGLE_BUTTON_SELECT_LABEL).c_str()) {}
ToggleButtonExample::~ToggleButtonExample() = default;
void ToggleButtonExample::CreateExampleView(View* container) {
- button_ = new ToggleButton(this);
auto layout = std::make_unique<BoxLayout>(BoxLayout::Orientation::kVertical);
layout->set_cross_axis_alignment(BoxLayout::CrossAxisAlignment::kCenter);
container->SetLayoutManager(std::move(layout));
- container->AddChildView(button_);
+ button_ = container->AddChildView(std::make_unique<ToggleButton>(this));
}
void ToggleButtonExample::ButtonPressed(Button* sender,
diff --git a/chromium/ui/views/examples/tree_view_example.cc b/chromium/ui/views/examples/tree_view_example.cc
index 0e84bce0823..dea712ae3e9 100644
--- a/chromium/ui/views/examples/tree_view_example.cc
+++ b/chromium/ui/views/examples/tree_view_example.cc
@@ -7,15 +7,18 @@
#include <utility>
#include "base/strings/utf_string_conversions.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/controls/menu/menu_model_adapter.h"
#include "ui/views/controls/menu/menu_runner.h"
#include "ui/views/controls/scroll_view.h"
#include "ui/views/controls/tree/tree_view.h"
#include "ui/views/controls/tree/tree_view_drawing_provider.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/grid_layout.h"
-using base::ASCIIToUTF16;
+using l10n_util::GetStringUTF16;
+using l10n_util::GetStringUTF8;
namespace {
@@ -27,7 +30,7 @@ class ExampleTreeViewDrawingProvider : public views::TreeViewDrawingProvider {
base::string16 GetAuxiliaryTextForNode(views::TreeView* tree_view,
ui::TreeModelNode* node) override {
if (tree_view->GetSelectedNode() == node)
- return base::UTF8ToUTF16("Selected");
+ return GetStringUTF16(IDS_TREE_VIEW_SELECTED_LABEL);
return views::TreeViewDrawingProvider::GetAuxiliaryTextForNode(tree_view,
node);
}
@@ -44,8 +47,10 @@ namespace views {
namespace examples {
TreeViewExample::TreeViewExample()
- : ExampleBase("Tree View"),
- model_(std::make_unique<NodeType>(ASCIIToUTF16("root"), 1)) {}
+ : ExampleBase(GetStringUTF8(IDS_TREE_VIEW_SELECT_LABEL).c_str()),
+ model_(std::make_unique<NodeType>(
+ GetStringUTF16(IDS_TREE_VIEW_ROOT_NODE_LABEL),
+ 1)) {}
TreeViewExample::~TreeViewExample() {
// Remove the model from the view.
@@ -56,15 +61,29 @@ TreeViewExample::~TreeViewExample() {
void TreeViewExample::CreateExampleView(View* container) {
// Add some sample data.
NodeType* colors_node = model_.GetRoot()->Add(
- std::make_unique<NodeType>(ASCIIToUTF16("colors"), 1), 0);
- colors_node->Add(std::make_unique<NodeType>(ASCIIToUTF16("red"), 1), 0);
- colors_node->Add(std::make_unique<NodeType>(ASCIIToUTF16("green"), 1), 1);
- colors_node->Add(std::make_unique<NodeType>(ASCIIToUTF16("blue"), 1), 2);
+ std::make_unique<NodeType>(GetStringUTF16(IDS_TREE_VIEW_COLOR_NODE_LABEL),
+ 1),
+ 0);
+ colors_node->Add(std::make_unique<NodeType>(
+ GetStringUTF16(IDS_TREE_VIEW_COLOR_RED_LABEL), 1),
+ 0);
+ colors_node->Add(std::make_unique<NodeType>(
+ GetStringUTF16(IDS_TREE_VIEW_COLOR_GREEN_LABEL), 1),
+ 1);
+ colors_node->Add(std::make_unique<NodeType>(
+ GetStringUTF16(IDS_TREE_VIEW_COLOR_BLUE_LABEL), 1),
+ 2);
NodeType* sheep_node = model_.GetRoot()->Add(
- std::make_unique<NodeType>(ASCIIToUTF16("sheep"), 1), 0);
- sheep_node->Add(std::make_unique<NodeType>(ASCIIToUTF16("Sheep 1"), 1), 0);
- sheep_node->Add(std::make_unique<NodeType>(ASCIIToUTF16("Sheep 2"), 1), 1);
+ std::make_unique<NodeType>(GetStringUTF16(IDS_TREE_VIEW_SHEEP_NODE_LABEL),
+ 1),
+ 0);
+ sheep_node->Add(
+ std::make_unique<NodeType>(GetStringUTF16(IDS_TREE_VIEW_SHEEP1_LABEL), 1),
+ 0);
+ sheep_node->Add(
+ std::make_unique<NodeType>(GetStringUTF16(IDS_TREE_VIEW_SHEEP2_LABEL), 1),
+ 1);
auto tree_view = std::make_unique<TreeView>();
tree_view->set_context_menu_controller(this);
@@ -73,14 +92,16 @@ void TreeViewExample::CreateExampleView(View* container) {
tree_view->SetController(this);
tree_view->SetDrawingProvider(
std::make_unique<ExampleTreeViewDrawingProvider>());
- auto add = std::make_unique<LabelButton>(this, ASCIIToUTF16("Add"));
+ auto add = std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_TREE_VIEW_ADD_BUTTON_LABEL));
add->SetFocusForPlatform();
add->set_request_focus_on_press(true);
- auto remove = std::make_unique<LabelButton>(this, ASCIIToUTF16("Remove"));
+ auto remove = std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_TREE_VIEW_REMOVE_BUTTON_LABEL));
remove->SetFocusForPlatform();
remove->set_request_focus_on_press(true);
- auto change_title =
- std::make_unique<LabelButton>(this, ASCIIToUTF16("Change Title"));
+ auto change_title = std::make_unique<LabelButton>(
+ this, GetStringUTF16(IDS_TREE_VIEW_CHANGE_TITLE_LABEL));
change_title->SetFocusForPlatform();
change_title->set_request_focus_on_press(true);
@@ -90,7 +111,7 @@ void TreeViewExample::CreateExampleView(View* container) {
const int tree_view_column = 0;
ColumnSet* column_set = layout->AddColumnSet(tree_view_column);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1.0f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout->StartRow(1 /* expand */, tree_view_column);
tree_view_ = tree_view.get();
layout->AddView(TreeView::CreateScrollViewWithTree(std::move(tree_view)));
@@ -100,7 +121,7 @@ void TreeViewExample::CreateExampleView(View* container) {
column_set = layout->AddColumnSet(button_column);
for (size_t i = 0; i < 3; i++) {
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1.0f,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
}
layout->StartRow(0 /* no expand */, button_column);
@@ -136,7 +157,8 @@ void TreeViewExample::ButtonPressed(Button* sender, const ui::Event& event) {
} else if (sender == change_title_) {
DCHECK(selected_node);
model_.SetTitle(selected_node,
- selected_node->GetTitle() + ASCIIToUTF16("new"));
+ selected_node->GetTitle() +
+ GetStringUTF16(IDS_TREE_VIEW_NEW_NODE_LABEL));
}
}
@@ -160,9 +182,12 @@ void TreeViewExample::ShowContextMenuForViewImpl(
const gfx::Point& point,
ui::MenuSourceType source_type) {
context_menu_model_ = std::make_unique<ui::SimpleMenuModel>(this);
- context_menu_model_->AddItem(ID_EDIT, ASCIIToUTF16("Edit"));
- context_menu_model_->AddItem(ID_REMOVE, ASCIIToUTF16("Remove"));
- context_menu_model_->AddItem(ID_ADD, ASCIIToUTF16("Add"));
+ context_menu_model_->AddItem(ID_EDIT,
+ GetStringUTF16(IDS_TREE_VIEW_EDIT_BUTTON_LABEL));
+ context_menu_model_->AddItem(
+ ID_REMOVE, GetStringUTF16(IDS_TREE_VIEW_REMOVE_BUTTON_LABEL));
+ context_menu_model_->AddItem(ID_ADD,
+ GetStringUTF16(IDS_TREE_VIEW_ADD_BUTTON_LABEL));
context_menu_runner_ =
std::make_unique<MenuRunner>(context_menu_model_.get(), 0);
context_menu_runner_->RunMenuAt(source->GetWidget(), nullptr,
diff --git a/chromium/ui/views/examples/vector_example.cc b/chromium/ui/views/examples/vector_example.cc
index a3cebf68456..c447df47fcf 100644
--- a/chromium/ui/views/examples/vector_example.cc
+++ b/chromium/ui/views/examples/vector_example.cc
@@ -15,6 +15,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_restrictions.h"
#include "build/build_config.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/border.h"
@@ -23,10 +24,14 @@
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/controls/textfield/textfield_controller.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/view.h"
+using l10n_util::GetStringUTF16;
+using l10n_util::GetStringUTF8;
+
namespace views {
namespace examples {
@@ -59,20 +64,22 @@ class VectorIconGallery : public View,
auto file_chooser = std::make_unique<Textfield>();
file_chooser->SetPlaceholderText(
- base::ASCIIToUTF16("Enter a file to read"));
+ GetStringUTF16(IDS_VECTOR_FILE_SELECT_LABEL));
auto file_container = std::make_unique<View>();
BoxLayout* file_box =
file_container->SetLayoutManager(std::make_unique<BoxLayout>(
BoxLayout::Orientation::kHorizontal, gfx::Insets(10), 10));
file_chooser_ = file_container->AddChildView(std::move(file_chooser));
file_go_button_ = file_container->AddChildView(
- MdTextButton::Create(this, base::ASCIIToUTF16("Render")));
+ MdTextButton::Create(this, GetStringUTF16(IDS_VECTOR_RENDER_LABEL)));
file_box->SetFlexForView(file_chooser_, 1);
AddChildView(std::move(file_container));
- size_input_->SetPlaceholderText(base::ASCIIToUTF16("Size in dip"));
+ size_input_->SetPlaceholderText(
+ GetStringUTF16(IDS_VECTOR_DIP_SIZE_DESC_LABEL));
size_input_->set_controller(this);
- color_input_->SetPlaceholderText(base::ASCIIToUTF16("Color (AARRGGBB)"));
+ color_input_->SetPlaceholderText(
+ GetStringUTF16(IDS_VECTOR_COLOR_DESC_LABEL));
color_input_->set_controller(this);
}
@@ -105,10 +112,10 @@ class VectorIconGallery : public View,
void ButtonPressed(Button* sender, const ui::Event& event) override {
DCHECK_EQ(file_go_button_, sender);
base::ScopedAllowBlockingForTesting allow_blocking;
-#if defined(OS_POSIX)
- base::FilePath path(base::UTF16ToUTF8(file_chooser_->GetText()));
-#elif defined(OS_WIN)
+#if defined(OS_WIN)
base::FilePath path(file_chooser_->GetText());
+#else
+ base::FilePath path(base::UTF16ToUTF8(file_chooser_->GetText()));
#endif
base::ReadFileToString(path, &contents_);
// Skip over comments.
@@ -147,13 +154,14 @@ class VectorIconGallery : public View,
} // namespace
-VectorExample::VectorExample() : ExampleBase("Vector Icon") {}
+VectorExample::VectorExample()
+ : ExampleBase(GetStringUTF8(IDS_VECTOR_SELECT_LABEL).c_str()) {}
VectorExample::~VectorExample() = default;
void VectorExample::CreateExampleView(View* container) {
container->SetLayoutManager(std::make_unique<FillLayout>());
- container->AddChildView(new VectorIconGallery());
+ container->AddChildView(std::make_unique<VectorIconGallery>());
}
} // namespace examples
diff --git a/chromium/ui/views/examples/views_examples_resources.grd b/chromium/ui/views/examples/views_examples_resources.grd
new file mode 100644
index 00000000000..207bbd371cf
--- /dev/null
+++ b/chromium/ui/views/examples/views_examples_resources.grd
@@ -0,0 +1,411 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<grit base_dir="." latest_public_release="0" current_release="1"
+ output_all_resource_defines="false" source_lang_id="en" enc_check="möl">
+ <outputs>
+ <output filename="grit/views_examples_resources.h" type="rc_header">
+ <emit emit_type='prepend'></emit>
+ </output>
+ <output filename="views_examples_resources.pak" type="data_package" lang="en" />
+ </outputs>
+ <release seq="1" allow_pseudo="false">
+ <messages fallback_to_english="true">
+ <!-- colored dialog example -->
+ <message translateable="false" name="IDS_COLORED_DIALOG_CHOOSER_CHECKBOX">
+ Use Dark Theme
+ </message>
+ <message translateable="false" name="IDS_COLORED_DIALOG_CHOOSER_BUTTON">
+ Send Feedback
+ </message>
+ <message translateable="false" name="IDS_COLORED_DIALOG_CHOOSER_CONFIRM_LABEL">
+ Thank you! We received the following response: <ph name="USER_FEEDBACK">$1<ex>I like it.</ex></ph>
+ </message>
+ <message translateable="false" name="IDS_COLORED_DIALOG_TITLE">
+ Send Feedback to Chromium
+ </message>
+ <message translateable="false" name="IDS_COLORED_DIALOG_TEXTFIELD_PLACEHOLDER">
+ Please type your quick feedback here...
+ </message>
+ <message translateable="false" name="IDS_COLORED_DIALOG_TEXTFIELD_AX_LABEL">
+ Input Feedback
+ </message>
+ <message translateable="false" name="IDS_COLORED_DIALOG_SUBMIT_BUTTON">
+ Submit
+ </message>
+
+ <!-- layout base example -->
+ <message translateable="false" name="IDS_LAYOUT_BASE_ADD_LABEL">
+ Add
+ </message>
+
+ <!-- link example -->
+ <message translateable="false" name="IDS_LINK_SELECT_LABEL">
+ Link
+ </message>
+ <message translateable="false" name="IDS_LINK_CLICK_PROMPT_LABEL">
+ Click me!
+ </message>
+ <message translateable="false" name="IDS_LINK_CLICK_CONFIRMED_LABEL">
+ Link clicked
+ </message>
+
+ <!-- Login example -->
+ <message translateable="false" name="IDS_LOGIN_SELECT_LABEL">
+ Login Bubble Dialog
+ </message>
+ <message translateable="false" name="IDS_LOGIN_SHOW_BUTTON_LABEL">
+ Show
+ </message>
+ <message translateable="false" name="IDS_LOGIN_TITLE_LABEL">
+ Login Dialog
+ </message>
+ <message translateable="false" name="IDS_LOGIN_USERNAME_LABEL">
+ Username
+ </message>
+ <message translateable="false" name="IDS_LOGIN_PASSWORD_LABEL">
+ Password
+ </message>
+ <message translateable="false" name="IDS_LOGIN_OK_BUTTON_LABEL">
+ LOGIN
+ </message>
+
+ <!-- menu example -->
+ <message translateable="false" name="IDS_MENU_DO_SOMETHING_LABEL">
+ Do Something
+ </message>
+ <message translateable="false" name="IDS_MENU_ASCII_LABEL">
+ ASCII
+ </message>
+ <message translateable="false" name="IDS_MENU_UTF8_LABEL">
+ UTF-8
+ </message>
+ <message translateable="false" name="IDS_MENU_UTF16_LABEL">
+ UTF-16
+ </message>
+ <message translateable="false" name="IDS_MENU_APPLE_LABEL">
+ Apple
+ </message>
+ <message translateable="false" name="IDS_MENU_ORANGE_LABEL">
+ Orange
+ </message>
+ <message translateable="false" name="IDS_MENU_KIWI_LABEL">
+ Kiwi
+ </message>
+ <message translateable="false" name="IDS_MENU_GO_HOME_LABEL">
+ Go Home
+ </message>
+ <message translateable="false" name="IDS_MENU_DO_SOMETHING_2_LABEL">
+ Do Something 2
+ </message>
+ <message translateable="false" name="IDS_MENU_SUBMENU_LABEL">
+ Submenu
+ </message>
+ <message translateable="false" name="IDS_MENU_SELECT_LABEL">
+ Menu
+ </message>
+ <message translateable="false" name="IDS_MENU_BUTTON_LABEL">
+ Open a menu
+ </message>
+
+ <!-- message box example -->
+ <message translateable="false" name="IDS_MESSAGE_SELECT_LABEL">
+ Message Box View
+ </message>
+ <message translateable="false" name="IDS_MESSAGE_INTRO_LABEL">
+ Hello, world!
+ </message>
+ <message translateable="false" name="IDS_MESSAGE_CHECK_BOX_LABEL">
+ Check Box
+ </message>
+ <message translateable="false" name="IDS_MESSAGE_STATUS_LABEL">
+ Show Status
+ </message>
+ <message translateable="false" name="IDS_MESSAGE_TOGGLE_LABEL">
+ Toggle Checkbox
+ </message>
+ <message translateable="false" name="IDS_MESSAGE_ON_LABEL">
+ on
+ </message>
+ <message translateable="false" name="IDS_MESSAGE_OFF_LABEL">
+ off
+ </message>
+ <message translateable="false" name="IDS_MESSAGE_CHECK_SELECTED_LABEL">
+ Check Box Selected
+ </message>
+ <message translateable="false" name="IDS_MESSAGE_CHECK_NOT_SELECTED_LABEL">
+ Check Box Not Selected
+ </message>
+
+ <!-- multiline example -->
+ <message translateable="false" name="IDS_MULTILINE_SELECT_LABEL">
+ Multiline RenderText
+ </message>
+ <message translateable="false" name="IDS_MULTILINE_LABEL">
+ views::Label:
+ </message>
+ <message translateable="false" name="IDS_MULTILINE_ELIDE_LABEL">
+ elide text?
+ </message>
+ <message translateable="false" name="IDS_MULTILINE_RENDER_TEXT_LABEL">
+ gfx::RenderText:
+ </message>
+ <message translateable="false" name="IDS_MULTILINE_SAMPLE_TEXT_LABEL">
+ Sample Text:
+ </message>
+
+ <!-- native theme example -->
+ <message translateable="false" name="IDS_THEME_SELECT_LABEL">
+ Native Theme Colors
+ </message>
+
+ <!-- progress example -->
+ <message translateable="false" name="IDS_PROGRESS_SELECT_LABEL">
+ Progress Bar
+ </message>
+ <message translateable="false" name="IDS_PROGRESS_LOADER_LABEL">
+ Infinite Loader:
+ </message>
+ <message translateable="false" name="IDS_PROGRESS_LOADER_SHORT_LABEL">
+ Infinite loader (very short):
+ </message>
+
+ <!-- radio button example -->
+ <message translateable="false" name="IDS_RADIO_BUTTON_SELECT_LABEL">
+ Radio Button
+ </message>
+ <message translateable="false" name="IDS_RADIO_BUTTON_SELECT_BUTTON_LABEL">
+ Select
+ </message>
+ <message translateable="false" name="IDS_RADIO_BUTTON_STATUS_LABEL">
+ Show Status
+ </message>
+
+
+ <!-- scroll view example -->
+ <message translateable="false" name="IDS_SCROLL_VIEW_BUTTON_LABEL">
+ Button
+ </message>
+ <message translateable="false" name="IDS_SCROLL_VIEW_RADIO_BUTTON_LABEL">
+ Radio Button
+ </message>
+ <message translateable="false" name="IDS_SCROLL_VIEW_SELECT_LABEL">
+ Scroll View
+ </message>
+ <message translateable="false" name="IDS_SCROLL_VIEW_WIDE_LABEL">
+ Wide
+ </message>
+ <message translateable="false" name="IDS_SCROLL_VIEW_TALL_LABEL">
+ Tall
+ </message>
+ <message translateable="false" name="IDS_SCROLL_VIEW_BIG_SQUARE_LABEL">
+ Big Square
+ </message>
+ <message translateable="false" name="IDS_SCROLL_VIEW_SMALL_SQUARE_LABEL">
+ Small Square
+ </message>
+ <message translateable="false" name="IDS_SCROLL_VIEW_SCROLL_TO_LABEL">
+ Scroll to
+ </message>
+
+ <!-- slider example -->
+ <message translateable="false" name="IDS_SLIDER_SELECT_LABEL">
+ Slider
+ </message>
+
+ <!-- tabbed pane example -->
+ <message translateable="false" name="IDS_TABBED_PANE_SELECT_LABEL">
+ Tabbed Pane
+ </message>
+ <message translateable="false" name="IDS_TABBED_PANE_ADD_LABEL">
+ Add
+ </message>
+ <message translateable="false" name="IDS_TABBED_PANE_ADD_1_LABEL">
+ Add At 1
+ </message>
+ <message translateable="false" name="IDS_TABBED_PANE_SELECT_1_LABEL">
+ Select At 1
+ </message>
+ <message translateable="false" name="IDS_TABBED_PANE_TAB_1_LABEL">
+ Tab 1
+ </message>
+ <message translateable="false" name="IDS_TABBED_PANE_TAB_2_LABEL">
+ Tab 2
+ </message>
+ <message translateable="false" name="IDS_TABBED_PANE_TAB_3_LABEL">
+ Tab 3
+ </message>
+ <message translateable="false" name="IDS_TABBED_PANE_ADDED_LABEL">
+ Added
+ </message>
+ <message translateable="false" name="IDS_TABBED_PANE_ADDED_1_LABEL">
+ Added at 1
+ </message>
+
+ <!-- textfield example -->
+ <message translateable="false" name="IDS_TEXTFIELD_SELECT_LABEL">
+ Textfield
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_PASSWORD_PLACEHOLDER">
+ password
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_DISABLED_PLACEHOLDER">
+ disabled
+ </message>
+ <message translateable="false" name="IDS_TEXTFFIELD_READ_ONLY_PLACEHOLDER">
+ read only
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_NAME_LABEL">
+ Name:
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_PASSWORD_LABEL">
+ Password:
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_DISABLED_LABEL">
+ Disabled:
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_READ_ONLY_LABEL">
+ Read Only:
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_INVALID_LABEL">
+ Invalid:
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_RTL_LABEL">
+ RTL:
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_SHOW_PASSWORD_LABEL">
+ Show password
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_BACKGROUND_LABEL">
+ Set non-default background
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_CLEAR_LABEL">
+ Clear All
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_APPEND_LABEL">
+ Append
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_SET_LABEL">
+ Set
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_SET_STYLE_LABEL">
+ Set Styles
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_APPEND_UPDATE_TEXT">
+ [append]
+ </message>
+ <message translateable="false" name="IDS_TEXTFIELD_SET_UPDATE_TEXT">
+ [set]
+ </message>
+
+ <!-- throbber example -->
+ <message translateable="false" name="IDS_THROBBER_SELECT_LABEL">
+ Throbber
+ </message>
+
+ <!-- toggle button example -->
+ <message translateable="false" name="IDS_TOGGLE_BUTTON_SELECT_LABEL">
+ Toggle Button
+ </message>
+
+ <!-- tree view example -->
+ <message translateable="false" name="IDS_TREE_VIEW_SELECTED_LABEL">
+ Selected
+ </message>
+ <message translateable="false" name="IDS_TREE_VIEW_SELECT_LABEL">
+ Tree View
+ </message>
+ <message translateable="false" name="IDS_TREE_VIEW_ROOT_NODE_LABEL">
+ root
+ </message>
+ <message translateable="false" name="IDS_TREE_VIEW_COLOR_NODE_LABEL">
+ colors
+ </message>
+ <message translateable="false" name="IDS_TREE_VIEW_COLOR_RED_LABEL">
+ red
+ </message>
+ <message translateable="false" name="IDS_TREE_VIEW_COLOR_GREEN_LABEL">
+ green
+ </message>
+ <message translateable="false" name="IDS_TREE_VIEW_COLOR_BLUE_LABEL">
+ blue
+ </message>
+ <message translateable="false" name="IDS_TREE_VIEW_SHEEP_NODE_LABEL">
+ sheep
+ </message>
+ <message translateable="false" name="IDS_TREE_VIEW_SHEEP1_LABEL">
+ Sheep 1
+ </message>
+ <message translateable="false" name="IDS_TREE_VIEW_SHEEP2_LABEL">
+ Sheep 2
+ </message>
+ <message translateable="false" name="IDS_TREE_VIEW_ADD_BUTTON_LABEL">
+ Add
+ </message>
+ <message translateable="false" name="IDS_TREE_VIEW_REMOVE_BUTTON_LABEL">
+ Remove
+ </message>
+ <message translateable="false" name="IDS_TREE_VIEW_CHANGE_TITLE_LABEL">
+ Change Title
+ </message>
+ <message translateable="false" name="IDS_TREE_VIEW_NEW_NODE_LABEL">
+ new
+ </message>
+ <message translateable="false" name="IDS_TREE_VIEW_EDIT_BUTTON_LABEL">
+ Edit
+ </message>
+
+ <!-- vector example -->
+ <message translateable="false" name="IDS_VECTOR_FILE_SELECT_LABEL">
+ Enter a file to read
+ </message>
+ <message translateable="false" name="IDS_VECTOR_RENDER_LABEL">
+ Render
+ </message>
+ <message translateable="false" name="IDS_VECTOR_DIP_SIZE_DESC_LABEL">
+ Size in dip
+ </message>
+ <message translateable="false" name="IDS_VECTOR_COLOR_DESC_LABEL">
+ Color (AARRGGBB)
+ </message>
+ <message translateable="false" name="IDS_VECTOR_SELECT_LABEL">
+ Vector Icon
+ </message>
+
+ <!-- webview example -->
+ <message translateable="false" name="IDS_WEBVIEW_SELECT_LABEL">
+ WebView
+ </message>
+
+ <!-- widget example -->
+ <message translateable="false" name="IDS_WIDGET_EXTRA_BUTTON">
+ Extra button!
+ </message>
+ <message translateable="false" name="IDS_WIDGET_FOOTNOTE_LABEL">
+ Footnote label!
+ </message>
+ <message translateable="false" name="IDS_WIDGET_DIALOG_CONTENTS_LABEL">
+ Dialog contents label!
+ </message>
+ <message translateable="false" name="IDS_WIDGET_WINDOW_TITLE">
+ Dialog Widget Example
+ </message>
+ <message translateable="false" name="IDS_WIDGET_SELECT_LABEL">
+ Widget
+ </message>
+ <message translateable="false" name="IDS_WIDGET_POPUP_BUTTON_LABEL">
+ Popup widget
+ </message>
+ <message translateable="false" name="IDS_WIDGET_DIALOG_BUTTON_LABEL">
+ Dialog widget
+ </message>
+ <message translateable="false" name="IDS_WIDGET_MODAL_BUTTON_LABEL">
+ Modal Dialog
+ </message>
+ <message translateable="false" name="IDS_WIDGET_CHILD_WIDGET_BUTTON_LABEL">
+ Child widget
+ </message>
+ <message translateable="false" name="IDS_WIDGET_CLOSE_BUTTON_LABEL">
+ Close
+ </message>
+ </messages>
+ </release>
+</grit> \ No newline at end of file
diff --git a/chromium/ui/views/examples/webview_example.cc b/chromium/ui/views/examples/webview_example.cc
index 8058e35c25a..1571dd2fc9e 100644
--- a/chromium/ui/views/examples/webview_example.cc
+++ b/chromium/ui/views/examples/webview_example.cc
@@ -8,14 +8,16 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/views/controls/webview/webview.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/fill_layout.h"
namespace views {
namespace examples {
WebViewExample::WebViewExample(content::BrowserContext* browser_context)
- : ExampleBase("WebView"),
+ : ExampleBase(l10n_util::GetStringUTF8(IDS_WEBVIEW_SELECT_LABEL).c_str()),
webview_(nullptr),
browser_context_(browser_context) {}
diff --git a/chromium/ui/views/examples/widget_example.cc b/chromium/ui/views/examples/widget_example.cc
index a09246ab1fb..7a4106184e2 100644
--- a/chromium/ui/views/examples/widget_example.cc
+++ b/chromium/ui/views/examples/widget_example.cc
@@ -10,16 +10,19 @@
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
+#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/views/background.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/label.h"
+#include "ui/views/examples/grit/views_examples_resources.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/view.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_delegate.h"
-using base::ASCIIToUTF16;
+using l10n_util::GetStringUTF16;
+using l10n_util::GetStringUTF8;
namespace views {
namespace examples {
@@ -48,40 +51,45 @@ WidgetDialogExample::WidgetDialogExample() {
SetBackground(CreateSolidBackground(SK_ColorGRAY));
SetLayoutManager(std::make_unique<BoxLayout>(
BoxLayout::Orientation::kVertical, gfx::Insets(10), 10));
- SetExtraView(MdTextButton::CreateSecondaryUiButton(
- nullptr, ASCIIToUTF16("Extra button!")));
- SetFootnoteView(std::make_unique<Label>(ASCIIToUTF16("Footnote label!")));
- AddChildView(new Label(ASCIIToUTF16("Dialog contents label!")));
+ SetExtraView(
+ MdTextButton::Create(nullptr, GetStringUTF16(IDS_WIDGET_EXTRA_BUTTON)));
+ SetFootnoteView(
+ std::make_unique<Label>(GetStringUTF16(IDS_WIDGET_FOOTNOTE_LABEL)));
+ AddChildView(new Label(GetStringUTF16(IDS_WIDGET_DIALOG_CONTENTS_LABEL)));
}
WidgetDialogExample::~WidgetDialogExample() = default;
base::string16 WidgetDialogExample::GetWindowTitle() const {
- return ASCIIToUTF16("Dialog Widget Example");
+ return GetStringUTF16(IDS_WIDGET_WINDOW_TITLE);
}
} // namespace
-WidgetExample::WidgetExample() : ExampleBase("Widget") {}
+WidgetExample::WidgetExample()
+ : ExampleBase(GetStringUTF8(IDS_WIDGET_SELECT_LABEL).c_str()) {}
WidgetExample::~WidgetExample() = default;
void WidgetExample::CreateExampleView(View* container) {
container->SetLayoutManager(std::make_unique<BoxLayout>(
BoxLayout::Orientation::kHorizontal, gfx::Insets(), 10));
- BuildButton(container, "Popup widget", POPUP);
- BuildButton(container, "Dialog widget", DIALOG);
- BuildButton(container, "Modal Dialog", MODAL_DIALOG);
+ BuildButton(container, GetStringUTF16(IDS_WIDGET_POPUP_BUTTON_LABEL), POPUP);
+ BuildButton(container, GetStringUTF16(IDS_WIDGET_DIALOG_BUTTON_LABEL),
+ DIALOG);
+ BuildButton(container, GetStringUTF16(IDS_WIDGET_MODAL_BUTTON_LABEL),
+ MODAL_DIALOG);
#if defined(OS_LINUX)
// Windows does not support TYPE_CONTROL top-level widgets.
- BuildButton(container, "Child widget", CHILD);
+ BuildButton(container, GetStringUTF16(IDS_WIDGET_CHILD_WIDGET_BUTTON_LABEL),
+ CHILD);
#endif
}
void WidgetExample::BuildButton(View* container,
- const std::string& label,
+ const base::string16& label,
int tag) {
- LabelButton* button = new LabelButton(this, ASCIIToUTF16(label));
+ LabelButton* button = new LabelButton(this, label);
button->SetFocusForPlatform();
button->set_request_focus_on_press(true);
button->set_tag(tag);
@@ -103,7 +111,8 @@ void WidgetExample::ShowWidget(View* sender, Widget::InitParams params) {
contents->SetLayoutManager(
std::make_unique<BoxLayout>(BoxLayout::Orientation::kHorizontal));
contents->SetBackground(CreateSolidBackground(SK_ColorGRAY));
- BuildButton(contents, "Close", CLOSE_WIDGET);
+ BuildButton(contents, GetStringUTF16(IDS_WIDGET_CLOSE_BUTTON_LABEL),
+ CLOSE_WIDGET);
widget->SetContentsView(contents);
}
diff --git a/chromium/ui/views/examples/widget_example.h b/chromium/ui/views/examples/widget_example.h
index 1d8cce31d74..1094f135c01 100644
--- a/chromium/ui/views/examples/widget_example.h
+++ b/chromium/ui/views/examples/widget_example.h
@@ -36,7 +36,7 @@ class VIEWS_EXAMPLES_EXPORT WidgetExample : public ExampleBase,
};
// Construct a button with the specified |label| and |tag| in |container|.
- void BuildButton(View* container, const std::string& label, int tag);
+ void BuildButton(View* container, const base::string16& label, int tag);
// Construct a Widget for |sender|, initialize with |params|, and call Show().
void ShowWidget(View* sender, Widget::InitParams params);
diff --git a/chromium/ui/views/focus/external_focus_tracker.cc b/chromium/ui/views/focus/external_focus_tracker.cc
index 5eef3af77e3..62143e3d6c5 100644
--- a/chromium/ui/views/focus/external_focus_tracker.cc
+++ b/chromium/ui/views/focus/external_focus_tracker.cc
@@ -6,7 +6,7 @@
#include <memory>
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/views/view.h"
#include "ui/views/view_tracker.h"
diff --git a/chromium/ui/views/focus/focus_manager.cc b/chromium/ui/views/focus/focus_manager.cc
index 462a3e67c80..0b634e3f151 100644
--- a/chromium/ui/views/focus/focus_manager.cc
+++ b/chromium/ui/views/focus/focus_manager.cc
@@ -9,14 +9,15 @@
#include <vector>
#include "base/auto_reset.h"
+#include "base/check_op.h"
#include "base/i18n/rtl.h"
-#include "base/logging.h"
#include "build/build_config.h"
#include "ui/base/accelerators/accelerator.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/ime/text_input_client.h"
#include "ui/events/event.h"
#include "ui/events/keycodes/keyboard_codes.h"
+#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/focus/focus_manager_delegate.h"
#include "ui/views/focus/focus_search.h"
#include "ui/views/focus/widget_focus_manager.h"
@@ -312,7 +313,7 @@ View* FocusManager::GetNextFocusableView(View* original_starting_view,
// the starting views widget or |widget_|.
Widget* widget = starting_view ? starting_view->GetWidget()
: original_starting_view->GetWidget();
- if (widget->widget_delegate()->ShouldAdvanceFocusToTopLevelWidget())
+ if (widget->widget_delegate()->focus_traverses_out())
widget = widget_;
return GetNextFocusableView(nullptr, widget, reverse, true);
}
@@ -522,7 +523,22 @@ void FocusManager::UnregisterAccelerators(ui::AcceleratorTarget* target) {
bool FocusManager::ProcessAccelerator(const ui::Accelerator& accelerator) {
if (accelerator_manager_.Process(accelerator))
return true;
- return delegate_ && delegate_->ProcessAccelerator(accelerator);
+ if (delegate_ && delegate_->ProcessAccelerator(accelerator))
+ return true;
+
+#if defined(OS_MACOSX)
+ // On MacOS accelerators are processed when a bubble is opened without
+ // manual redirection to bubble anchor widget. Including redirect on MacOS
+ // breaks processing accelerators by the bubble itself.
+ return false;
+#else
+ return RedirectAcceleratorToBubbleAnchorWidget(accelerator);
+#endif
+}
+
+bool FocusManager::IsAcceleratorRegistered(
+ const ui::Accelerator& accelerator) const {
+ return accelerator_manager_.IsRegistered(accelerator);
}
bool FocusManager::HasPriorityHandler(
@@ -591,4 +607,25 @@ void FocusManager::OnViewIsDeleting(View* view) {
SetFocusedView(nullptr);
}
+bool FocusManager::RedirectAcceleratorToBubbleAnchorWidget(
+ const ui::Accelerator& accelerator) {
+ Widget* anchor_widget = GetBubbleAnchorWidget();
+ if (!anchor_widget)
+ return false;
+
+ FocusManager* focus_manager = anchor_widget->GetFocusManager();
+ if (!focus_manager->IsAcceleratorRegistered(accelerator))
+ return false;
+
+ // The parent view must be focused for it to process events.
+ focus_manager->SetFocusedView(anchor_widget->GetRootView());
+ return focus_manager->ProcessAccelerator(accelerator);
+}
+
+Widget* FocusManager::GetBubbleAnchorWidget() {
+ BubbleDialogDelegateView* widget_delegate =
+ widget_->widget_delegate()->AsBubbleDialogDelegate();
+ return widget_delegate ? widget_delegate->anchor_widget() : nullptr;
+}
+
} // namespace views
diff --git a/chromium/ui/views/focus/focus_manager.h b/chromium/ui/views/focus/focus_manager.h
index 909a4fee3fe..8c7888aeff3 100644
--- a/chromium/ui/views/focus/focus_manager.h
+++ b/chromium/ui/views/focus/focus_manager.h
@@ -256,6 +256,9 @@ class VIEWS_EXPORT FocusManager : public ViewObserver {
void AddFocusChangeListener(FocusChangeListener* listener);
void RemoveFocusChangeListener(FocusChangeListener* listener);
+ // Whether the given |accelerator| is registered.
+ bool IsAcceleratorRegistered(const ui::Accelerator& accelerator) const;
+
// Whether the given |accelerator| has a priority handler associated with it.
bool HasPriorityHandler(const ui::Accelerator& accelerator) const;
@@ -293,11 +296,10 @@ class VIEWS_EXPORT FocusManager : public ViewObserver {
}
// Returns the next focusable view. Traversal starts at |starting_view|. If
- // |starting_view| is NULL |starting_widget| is consuled to determine which
- // Widget to start from. See
- // WidgetDelegate::ShouldAdvanceFocusToTopLevelWidget() for details. If both
- // |starting_view| and |starting_widget| are NULL, traversal starts at
- // |widget_|.
+ // |starting_view| is null, |starting_widget| is consulted to determine which
+ // Widget to start from. See WidgetDelegate::Params::focus_traverses_out for
+ // details. If both |starting_view| and |starting_widget| are null, traversal
+ // starts at |widget_|.
View* GetNextFocusableView(View* starting_view,
Widget* starting_widget,
bool reverse,
@@ -329,6 +331,14 @@ class VIEWS_EXPORT FocusManager : public ViewObserver {
// ViewObserver:
void OnViewIsDeleting(View* view) override;
+ // Try to redirect the accelerator to bubble's anchor widget to process it if
+ // the bubble didn't.
+ bool RedirectAcceleratorToBubbleAnchorWidget(
+ const ui::Accelerator& accelerator);
+
+ // Returns bubble's anchor widget.
+ Widget* GetBubbleAnchorWidget();
+
// Whether arrow key traversal is enabled globally.
static bool arrow_key_traversal_enabled_;
diff --git a/chromium/ui/views/focus/focus_manager_unittest.cc b/chromium/ui/views/focus/focus_manager_unittest.cc
index b96e317503e..b4438b0aa46 100644
--- a/chromium/ui/views/focus/focus_manager_unittest.cc
+++ b/chromium/ui/views/focus/focus_manager_unittest.cc
@@ -54,6 +54,9 @@ class SimpleTestView : public View {
SetID(view_id);
}
+ SimpleTestView(const SimpleTestView&) = delete;
+ SimpleTestView& operator=(const SimpleTestView&) = delete;
+
void OnFocus() override {
event_list_->push_back({
ON_FOCUS,
@@ -72,8 +75,6 @@ class SimpleTestView : public View {
private:
std::vector<FocusTestEvent>* event_list_;
-
- DISALLOW_COPY_AND_ASSIGN(SimpleTestView);
};
// Tests that the appropriate Focus related methods are called when a View
@@ -379,6 +380,11 @@ class SelfUnregisteringAcceleratorTarget : public ui::TestAcceleratorTarget {
FocusManager* focus_manager)
: accelerator_(accelerator), focus_manager_(focus_manager) {}
+ SelfUnregisteringAcceleratorTarget(
+ const SelfUnregisteringAcceleratorTarget&) = delete;
+ SelfUnregisteringAcceleratorTarget& operator=(
+ const SelfUnregisteringAcceleratorTarget&) = delete;
+
// ui::TestAcceleratorTarget:
bool AcceleratorPressed(const ui::Accelerator& accelerator) override {
focus_manager_->UnregisterAccelerator(accelerator, this);
@@ -388,8 +394,6 @@ class SelfUnregisteringAcceleratorTarget : public ui::TestAcceleratorTarget {
private:
ui::Accelerator accelerator_;
FocusManager* focus_manager_;
-
- DISALLOW_COPY_AND_ASSIGN(SelfUnregisteringAcceleratorTarget);
};
TEST_F(FocusManagerTest, CallsSelfDeletingAcceleratorTarget) {
@@ -438,20 +442,22 @@ class FocusManagerDtorTest : public FocusManagerTest {
: FocusManager(widget, nullptr /* delegate */),
dtor_tracker_(dtor_tracker) {}
+ FocusManagerDtorTracked(const FocusManagerDtorTracked&) = delete;
+ FocusManagerDtorTracked& operator=(const FocusManagerDtorTracked&) = delete;
+
~FocusManagerDtorTracked() override {
dtor_tracker_->push_back("FocusManagerDtorTracked");
}
DtorTrackVector* dtor_tracker_;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(FocusManagerDtorTracked);
};
class TestFocusManagerFactory : public FocusManagerFactory {
public:
explicit TestFocusManagerFactory(DtorTrackVector* dtor_tracker)
: dtor_tracker_(dtor_tracker) {}
+ TestFocusManagerFactory(const TestFocusManagerFactory&) = delete;
+ TestFocusManagerFactory& operator=(const TestFocusManagerFactory&) = delete;
~TestFocusManagerFactory() override = default;
std::unique_ptr<FocusManager> CreateFocusManager(Widget* widget) override {
@@ -460,8 +466,6 @@ class FocusManagerDtorTest : public FocusManagerTest {
private:
DtorTrackVector* dtor_tracker_;
-
- DISALLOW_COPY_AND_ASSIGN(TestFocusManagerFactory);
};
class WindowDtorTracked : public Widget {
@@ -506,6 +510,11 @@ class FocusInAboutToRequestFocusFromTabTraversalView : public View {
public:
FocusInAboutToRequestFocusFromTabTraversalView() = default;
+ FocusInAboutToRequestFocusFromTabTraversalView(
+ const FocusInAboutToRequestFocusFromTabTraversalView&) = delete;
+ FocusInAboutToRequestFocusFromTabTraversalView& operator=(
+ const FocusInAboutToRequestFocusFromTabTraversalView&) = delete;
+
void set_view_to_focus(View* view) { view_to_focus_ = view; }
void AboutToRequestFocusFromTabTraversal(bool reverse) override {
@@ -514,8 +523,6 @@ class FocusInAboutToRequestFocusFromTabTraversalView : public View {
private:
views::View* view_to_focus_ = nullptr;
-
- DISALLOW_COPY_AND_ASSIGN(FocusInAboutToRequestFocusFromTabTraversalView);
};
} // namespace
@@ -643,6 +650,10 @@ class FocusManagerArrowKeyTraversalTest
public testing::WithParamInterface<bool> {
public:
FocusManagerArrowKeyTraversalTest() = default;
+ FocusManagerArrowKeyTraversalTest(const FocusManagerArrowKeyTraversalTest&) =
+ delete;
+ FocusManagerArrowKeyTraversalTest& operator=(
+ const FocusManagerArrowKeyTraversalTest&) = delete;
~FocusManagerArrowKeyTraversalTest() override = default;
// FocusManagerTest overrides:
@@ -671,8 +682,6 @@ class FocusManagerArrowKeyTraversalTest
base::test::ScopedRestoreICUDefaultLocale restore_locale_;
bool previous_arrow_key_traversal_enabled_ = false;
-
- DISALLOW_COPY_AND_ASSIGN(FocusManagerArrowKeyTraversalTest);
};
// Instantiate the Boolean which is used to toggle RTL in
@@ -851,26 +860,18 @@ namespace {
// ShouldAdvanceFocusToTopLevelWidget().
class AdvanceFocusWidgetDelegate : public WidgetDelegate {
public:
- explicit AdvanceFocusWidgetDelegate(Widget* widget)
- : widget_(widget), should_advance_focus_to_parent_(false) {}
+ explicit AdvanceFocusWidgetDelegate(Widget* widget) : widget_(widget) {}
+ AdvanceFocusWidgetDelegate(const AdvanceFocusWidgetDelegate&) = delete;
+ AdvanceFocusWidgetDelegate& operator=(const AdvanceFocusWidgetDelegate&) =
+ delete;
~AdvanceFocusWidgetDelegate() override = default;
- void set_should_advance_focus_to_parent(bool value) {
- should_advance_focus_to_parent_ = value;
- }
-
// WidgetDelegate:
- bool ShouldAdvanceFocusToTopLevelWidget() const override {
- return should_advance_focus_to_parent_;
- }
Widget* GetWidget() override { return widget_; }
const Widget* GetWidget() const override { return widget_; }
private:
Widget* widget_;
- bool should_advance_focus_to_parent_;
-
- DISALLOW_COPY_AND_ASSIGN(AdvanceFocusWidgetDelegate);
};
class TestBubbleDialogDelegateView : public BubbleDialogDelegateView {
@@ -879,8 +880,23 @@ class TestBubbleDialogDelegateView : public BubbleDialogDelegateView {
: BubbleDialogDelegateView(anchor, BubbleBorder::NONE) {
DialogDelegate::SetButtons(ui::DIALOG_BUTTON_NONE);
}
+ TestBubbleDialogDelegateView(const TestBubbleDialogDelegateView&) = delete;
+ TestBubbleDialogDelegateView& operator=(const TestBubbleDialogDelegateView&) =
+ delete;
~TestBubbleDialogDelegateView() override = default;
+ static TestBubbleDialogDelegateView* CreateAndShowBubble(View* anchor) {
+ TestBubbleDialogDelegateView* bubble =
+ new TestBubbleDialogDelegateView(anchor);
+ Widget* bubble_widget = BubbleDialogDelegateView::CreateBubble(bubble);
+ bubble_widget->SetFocusTraversableParent(
+ bubble->anchor_widget()->GetFocusTraversable());
+ bubble_widget->SetFocusTraversableParentView(anchor);
+ bubble->set_close_on_deactivate(false);
+ bubble_widget->Show();
+ return bubble;
+ }
+
// If this is called, the bubble will be forced to use a NativeWidgetAura.
// If not set, it might get a DesktopNativeWidgetAura depending on the
// platform and other factors.
@@ -899,8 +915,6 @@ class TestBubbleDialogDelegateView : public BubbleDialogDelegateView {
private:
bool use_native_widget_aura_ = false;
-
- DISALLOW_COPY_AND_ASSIGN(TestBubbleDialogDelegateView);
};
} // namespace
@@ -950,7 +964,7 @@ TEST_F(FocusManagerTest, AdvanceFocusStaysInWidget) {
// Allow focus to go to the parent, and focus backwards which should now move
// up |widget_view| (in the parent).
- delegate->set_should_advance_focus_to_parent(true);
+ delegate->SetFocusTraversesOut(true);
GetFocusManager()->AdvanceFocus(true);
EXPECT_EQ(widget_view, GetFocusManager()->GetFocusedView());
}
@@ -984,21 +998,15 @@ TEST_F(FocusManagerTest, NavigateIntoAnchoredDialog) {
parent3->AddChildView(new View());
BubbleDialogDelegateView* bubble_delegate =
- new TestBubbleDialogDelegateView(parent3);
- test::WidgetTest::WidgetAutoclosePtr bubble_widget(
- BubbleDialogDelegateView::CreateBubble(bubble_delegate));
- bubble_widget->SetFocusTraversableParent(
- bubble_delegate->anchor_widget()->GetFocusTraversable());
+ TestBubbleDialogDelegateView::CreateAndShowBubble(parent3);
+ Widget* bubble_widget = bubble_delegate->GetWidget();
- bubble_widget->SetFocusTraversableParentView(parent3);
View* child1 = new View();
View* child2 = new View();
child1->SetFocusBehavior(View::FocusBehavior::ALWAYS);
child2->SetFocusBehavior(View::FocusBehavior::ALWAYS);
bubble_widget->GetRootView()->AddChildView(child1);
bubble_widget->GetRootView()->AddChildView(child2);
- bubble_delegate->set_close_on_deactivate(false);
- bubble_widget->Show();
parent1->RequestFocus();
@@ -1048,20 +1056,15 @@ TEST_F(FocusManagerTest, AnchoredDialogOnContainerView) {
GetWidget()->GetRootView()->AddChildView(parent4);
BubbleDialogDelegateView* bubble_delegate =
- new TestBubbleDialogDelegateView(parent_group);
- test::WidgetTest::WidgetAutoclosePtr bubble_widget(
- BubbleDialogDelegateView::CreateBubble(bubble_delegate));
- bubble_widget->SetFocusTraversableParent(
- bubble_delegate->anchor_widget()->GetFocusTraversable());
- bubble_widget->SetFocusTraversableParentView(parent_group);
+ TestBubbleDialogDelegateView::CreateAndShowBubble(parent3);
+ Widget* bubble_widget = bubble_delegate->GetWidget();
+
View* child1 = new View();
View* child2 = new View();
child1->SetFocusBehavior(View::FocusBehavior::ALWAYS);
child2->SetFocusBehavior(View::FocusBehavior::ALWAYS);
bubble_widget->GetRootView()->AddChildView(child1);
bubble_widget->GetRootView()->AddChildView(child2);
- bubble_delegate->set_close_on_deactivate(false);
- bubble_widget->Show();
parent1->RequestFocus();
@@ -1097,14 +1100,8 @@ TEST_F(FocusManagerTest, AnchoredDialogInPane) {
View* anchor = pane->AddChildView(std::make_unique<View>());
anchor->SetFocusBehavior(View::FocusBehavior::ALWAYS);
- BubbleDialogDelegateView* bubble = new TestBubbleDialogDelegateView(anchor);
- test::WidgetTest::WidgetAutoclosePtr bubble_widget(
- BubbleDialogDelegateView::CreateBubble(bubble));
- bubble_widget->SetFocusTraversableParent(
- bubble->anchor_widget()->GetFocusTraversable());
- bubble_widget->SetFocusTraversableParentView(anchor);
- bubble->set_close_on_deactivate(false);
- bubble_widget->Show();
+ BubbleDialogDelegateView* bubble =
+ TestBubbleDialogDelegateView::CreateAndShowBubble(anchor);
// We need a focusable view inside our bubble to check that focus traverses
// in.
@@ -1127,6 +1124,9 @@ TEST_F(FocusManagerTest, AnchoredDialogInPane) {
class DesktopWidgetFocusManagerTest : public FocusManagerTest {
public:
DesktopWidgetFocusManagerTest() = default;
+ DesktopWidgetFocusManagerTest(const DesktopWidgetFocusManagerTest&) = delete;
+ DesktopWidgetFocusManagerTest& operator=(
+ const DesktopWidgetFocusManagerTest&) = delete;
~DesktopWidgetFocusManagerTest() override = default;
// FocusManagerTest:
@@ -1134,9 +1134,6 @@ class DesktopWidgetFocusManagerTest : public FocusManagerTest {
set_native_widget_type(NativeWidgetType::kDesktop);
FocusManagerTest::SetUp();
}
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DesktopWidgetFocusManagerTest);
};
TEST_F(DesktopWidgetFocusManagerTest, AnchoredDialogInDesktopNativeWidgetAura) {
@@ -1158,18 +1155,13 @@ TEST_F(DesktopWidgetFocusManagerTest, AnchoredDialogInDesktopNativeWidgetAura) {
widget.GetRootView()->AddChildView(parent2);
TestBubbleDialogDelegateView* bubble_delegate =
- new TestBubbleDialogDelegateView(parent2);
+ TestBubbleDialogDelegateView::CreateAndShowBubble(parent2);
+ Widget* bubble_widget = bubble_delegate->GetWidget();
bubble_delegate->UseNativeWidgetAura();
- test::WidgetTest::WidgetAutoclosePtr bubble_widget(
- BubbleDialogDelegateView::CreateBubble(bubble_delegate));
- bubble_widget->SetFocusTraversableParent(
- bubble_delegate->anchor_widget()->GetFocusTraversable());
- bubble_widget->SetFocusTraversableParentView(parent2);
+
View* child = new View();
child->SetFocusBehavior(View::FocusBehavior::ALWAYS);
bubble_widget->GetRootView()->AddChildView(child);
- bubble_delegate->set_close_on_deactivate(false);
- bubble_widget->Show();
widget.Activate();
parent1->RequestFocus();
@@ -1234,4 +1226,83 @@ TEST_F(FocusManagerTest, HandlesFocusCycles) {
EXPECT_FALSE(left->HasFocus());
}
+#if defined(USE_AURA)
+class RedirectToParentFocusManagerTest : public FocusManagerTest {
+ public:
+ RedirectToParentFocusManagerTest() = default;
+ RedirectToParentFocusManagerTest(const RedirectToParentFocusManagerTest&) =
+ delete;
+ RedirectToParentFocusManagerTest& operator=(
+ const RedirectToParentFocusManagerTest&) = delete;
+ ~RedirectToParentFocusManagerTest() override = default;
+
+ // FocusManagerTest:
+ void SetUp() override {
+ FocusManagerTest::SetUp();
+
+ View* anchor =
+ GetWidget()->GetRootView()->AddChildView(std::make_unique<View>());
+ anchor->SetFocusBehavior(View::FocusBehavior::ALWAYS);
+
+ BubbleDialogDelegateView* bubble_delegate =
+ TestBubbleDialogDelegateView::CreateAndShowBubble(anchor);
+ Widget* bubble_widget = bubble_delegate->GetWidget();
+
+ parent_focus_manager_ = anchor->GetFocusManager();
+ bubble_focus_manager_ = bubble_widget->GetFocusManager();
+ }
+
+ void TearDown() override {
+ FocusManagerFactory::Install(nullptr);
+ FocusManagerTest::TearDown();
+ }
+
+ protected:
+ FocusManager* parent_focus_manager_;
+ FocusManager* bubble_focus_manager_;
+};
+
+// Test that when an accelerator is sent to a bubble that isn't registered,
+// the bubble's parent handles it instead.
+TEST_F(RedirectToParentFocusManagerTest, ParentHandlesAcceleratorFromBubble) {
+ ui::Accelerator return_accelerator(ui::VKEY_RETURN, ui::EF_NONE);
+ ui::TestAcceleratorTarget parent_return_target(true);
+
+ EXPECT_EQ(0, parent_return_target.accelerator_count());
+ parent_focus_manager_->RegisterAccelerator(
+ return_accelerator, ui::AcceleratorManager::kNormalPriority,
+ &parent_return_target);
+
+ EXPECT_TRUE(
+ !bubble_focus_manager_->IsAcceleratorRegistered(return_accelerator));
+ // Accelerator was proccesed by the parent.
+ EXPECT_TRUE(bubble_focus_manager_->ProcessAccelerator(return_accelerator));
+ EXPECT_EQ(parent_return_target.accelerator_count(), 1);
+}
+
+// Test that when an accelerator is sent to a bubble that is registered on both
+// it and its parent, the bubble handles it.
+TEST_F(RedirectToParentFocusManagerTest, BubbleHandlesRegisteredAccelerators) {
+ ui::Accelerator return_accelerator(ui::VKEY_RETURN, ui::EF_NONE);
+ ui::TestAcceleratorTarget parent_return_target(true);
+ ui::TestAcceleratorTarget bubble_return_target(true);
+
+ EXPECT_EQ(0, bubble_return_target.accelerator_count());
+ EXPECT_EQ(0, parent_return_target.accelerator_count());
+
+ bubble_focus_manager_->RegisterAccelerator(
+ return_accelerator, ui::AcceleratorManager::kNormalPriority,
+ &bubble_return_target);
+ parent_focus_manager_->RegisterAccelerator(
+ return_accelerator, ui::AcceleratorManager::kNormalPriority,
+ &parent_return_target);
+
+ // Accelerator was proccesed by the bubble and not by the parent.
+ EXPECT_TRUE(bubble_focus_manager_->ProcessAccelerator(return_accelerator));
+ EXPECT_EQ(1, bubble_return_target.accelerator_count());
+ EXPECT_EQ(0, parent_return_target.accelerator_count());
+}
+
+#endif
+
} // namespace views
diff --git a/chromium/ui/views/layout/animating_layout_manager.cc b/chromium/ui/views/layout/animating_layout_manager.cc
index a2e72769780..d436f28da5e 100644
--- a/chromium/ui/views/layout/animating_layout_manager.cc
+++ b/chromium/ui/views/layout/animating_layout_manager.cc
@@ -207,10 +207,10 @@ void AnimatingLayoutManager::AnimationDelegate::AnimationEnded(
AnimatingLayoutManager::AnimatingLayoutManager() = default;
AnimatingLayoutManager::~AnimatingLayoutManager() = default;
-AnimatingLayoutManager& AnimatingLayoutManager::SetShouldAnimateBounds(
- bool should_animate_bounds) {
- if (should_animate_bounds_ != should_animate_bounds) {
- should_animate_bounds_ = should_animate_bounds;
+AnimatingLayoutManager& AnimatingLayoutManager::SetBoundsAnimationMode(
+ BoundsAnimationMode bounds_animation_mode) {
+ if (bounds_animation_mode_ != bounds_animation_mode) {
+ bounds_animation_mode_ = bounds_animation_mode;
ResetLayout();
}
return *this;
@@ -329,9 +329,21 @@ gfx::Size AnimatingLayoutManager::GetPreferredSize(const View* host) const {
if (!target_layout_manager())
return gfx::Size();
- return should_animate_bounds_
- ? current_layout_.host_size
- : target_layout_manager()->GetPreferredSize(host);
+ switch (bounds_animation_mode_) {
+ case BoundsAnimationMode::kUseHostBounds:
+ return target_layout_manager()->GetPreferredSize(host);
+ case BoundsAnimationMode::kAnimateMainAxis: {
+ // Animating only main axis, so cross axis is preferred size.
+ gfx::Size result = current_layout_.host_size;
+ SetCrossAxis(
+ &result, orientation(),
+ GetCrossAxis(orientation(),
+ target_layout_manager()->GetPreferredSize(host)));
+ return result;
+ }
+ case BoundsAnimationMode::kAnimateBothAxes:
+ return current_layout_.host_size;
+ }
}
gfx::Size AnimatingLayoutManager::GetMinimumSize(const View* host) const {
@@ -340,8 +352,20 @@ gfx::Size AnimatingLayoutManager::GetMinimumSize(const View* host) const {
// TODO(dfried): consider cases where the minimum size might not be just the
// minimum size of the embedded layout.
gfx::Size minimum_size = target_layout_manager()->GetMinimumSize(host);
- if (should_animate_bounds_)
- minimum_size.SetToMin(current_layout_.host_size);
+ switch (bounds_animation_mode_) {
+ case BoundsAnimationMode::kUseHostBounds:
+ // No modification required.
+ break;
+ case BoundsAnimationMode::kAnimateMainAxis:
+ SetMainAxis(
+ &minimum_size, orientation(),
+ std::min(GetMainAxis(orientation(), minimum_size),
+ GetMainAxis(orientation(), current_layout_.host_size)));
+ break;
+ case BoundsAnimationMode::kAnimateBothAxes:
+ minimum_size.SetToMin(current_layout_.host_size);
+ break;
+ }
return minimum_size;
}
@@ -351,9 +375,12 @@ int AnimatingLayoutManager::GetPreferredHeightForWidth(const View* host,
return 0;
// TODO(dfried): revisit this computation.
- return should_animate_bounds_
- ? current_layout_.host_size.height()
- : target_layout_manager()->GetPreferredHeightForWidth(host, width);
+ if (bounds_animation_mode_ == BoundsAnimationMode::kAnimateBothAxes ||
+ (bounds_animation_mode_ == BoundsAnimationMode::kAnimateMainAxis &&
+ orientation() == LayoutOrientation::kVertical)) {
+ return current_layout_.host_size.height();
+ }
+ return target_layout_manager()->GetPreferredHeightForWidth(host, width);
}
std::vector<View*> AnimatingLayoutManager::GetChildViewsInPaintOrder(
@@ -445,31 +472,48 @@ void AnimatingLayoutManager::LayoutImpl() {
// than an invalidation. This should reset the layout (but see the note in
// RecalculateTarget() below).
const gfx::Size host_size = host_view()->size();
- if (should_animate_bounds_) {
- // Reset the layout immediately if the current or target layout exceeds the
- // host size or the available space.
+
+ if (bounds_animation_mode_ == BoundsAnimationMode::kUseHostBounds) {
+ if (!cached_layout_size() || host_size != *cached_layout_size()) {
+ // Host size changed, so reset the layout.
+ ResetLayoutToTargetSize();
+ }
+
+ } else {
const SizeBounds available_size = GetAvailableHostSize();
- const base::Optional<int> bounds_main =
- GetMainAxis(orientation(), available_size);
- const int host_main = GetMainAxis(orientation(), host_size);
- const int current_main =
- GetMainAxis(orientation(), current_layout_.host_size);
- if (current_main > host_main ||
- (bounds_main && current_main > *bounds_main)) {
+
+ if (bounds_animation_mode_ == BoundsAnimationMode::kAnimateMainAxis &&
+ (!cached_layout_size() ||
+ GetCrossAxis(orientation(), host_size) !=
+ GetCrossAxis(orientation(), *cached_layout_size()))) {
+ // If we're fixed to the cross-axis size of the host and that size
+ // changes, we need to reset the layout.
last_available_host_size_ = available_size;
ResetLayoutToSize(host_size);
- } else if (available_size != last_available_host_size_) {
- // May need to re-trigger animation if our bounds were relaxed; let us
- // expand into the new available space.
- RecalculateTarget();
+ } else {
+ // Either both axes are animating or only the main axis is animating or
+ // the cross axis hasn't changed (because otherwise the previous condition
+ // would have executed instead).
+ const base::Optional<int> bounds_main =
+ GetMainAxis(orientation(), available_size);
+ const int host_main = GetMainAxis(orientation(), host_size);
+ const int current_main =
+ GetMainAxis(orientation(), current_layout_.host_size);
+ if (current_main > host_main ||
+ (bounds_main && current_main > *bounds_main)) {
+ // Reset the layout immediately if the current or target layout exceeds
+ // the host size or the available space.
+ last_available_host_size_ = available_size;
+ ResetLayoutToSize(host_size);
+ } else if (available_size != last_available_host_size_) {
+ // May need to re-trigger animation if our bounds were relaxed; let us
+ // expand into the new available space.
+ RecalculateTarget();
+ }
}
// Verify that the last available size has been updated.
DCHECK_EQ(available_size, last_available_host_size_);
-
- } else if (!cached_layout_size() || host_size != *cached_layout_size()) {
- // Host size changed, so reset the layout.
- ResetLayoutToTargetSize();
}
ApplyLayout(current_layout_);
@@ -529,7 +573,8 @@ bool AnimatingLayoutManager::RecalculateTarget() {
// space as adjacent child views appear/disappear. This will be useful in
// animating tab titles, which currently slide over when the favicon
// disappears.
- if (!should_animate_bounds_ && *cached_layout_size() != target_size) {
+ if (bounds_animation_mode_ == BoundsAnimationMode::kUseHostBounds &&
+ *cached_layout_size() != target_size) {
ResetLayoutToSize(target_size);
return true;
}
@@ -982,25 +1027,39 @@ ChildLayout AnimatingLayoutManager::CalculateSlideFade(
// Returns the space in which to calculate the target layout.
gfx::Size AnimatingLayoutManager::GetAvailableTargetLayoutSize() {
- if (!should_animate_bounds_)
+ if (bounds_animation_mode_ == BoundsAnimationMode::kUseHostBounds)
return host_view()->size();
const SizeBounds bounds = GetAvailableHostSize();
last_available_host_size_ = bounds;
const gfx::Size preferred_size =
target_layout_manager()->GetPreferredSize(host_view());
- if (!bounds.width() || *bounds.width() > preferred_size.width()) {
- return gfx::Size(preferred_size.width(),
- bounds.height()
- ? std::min(preferred_size.height(), *bounds.height())
- : preferred_size.height());
+
+ int width = preferred_size.width();
+
+ if (orientation() == LayoutOrientation::kVertical &&
+ bounds_animation_mode_ == BoundsAnimationMode::kAnimateMainAxis) {
+ width = host_view()->width();
+ } else if (bounds.width()) {
+ width = std::min(width, *bounds.width());
+ }
+
+ int height;
+
+ if (orientation() == LayoutOrientation::kHorizontal &&
+ bounds_animation_mode_ == BoundsAnimationMode::kAnimateMainAxis) {
+ height = host_view()->height();
+ } else {
+ height = width < preferred_size.width()
+ ? target_layout_manager()->GetPreferredHeightForWidth(
+ host_view(), width)
+ : preferred_size.height();
+ if (bounds.height()) {
+ height = std::min(height, *bounds.height());
+ }
}
- const int height = target_layout_manager()->GetPreferredHeightForWidth(
- host_view(), *bounds.width());
- return gfx::Size(*bounds.width(), bounds.height()
- ? std::min(height, *bounds.height())
- : height);
+ return gfx::Size(width, height);
}
// static
diff --git a/chromium/ui/views/layout/animating_layout_manager.h b/chromium/ui/views/layout/animating_layout_manager.h
index 207c1edef77..70561ebe5c7 100644
--- a/chromium/ui/views/layout/animating_layout_manager.h
+++ b/chromium/ui/views/layout/animating_layout_manager.h
@@ -44,7 +44,8 @@ namespace views {
//
// auto* animating_layout = button_container->SetLayoutManager(
// std::make_unique<AnimatingLayoutManager>());
-// animating_layout->SetShouldAnimateBounds(true);
+// animating_layout->SetBoundsAnimationMode(
+// AnimatingLayoutManager::BoundsAnimationMode::kAnimateMainAxis);
// auto* flex_layout = animating_layout->SetTargetLayoutManager(
// std::make_unique<FlexLayout>());
// flex_layout->SetOrientation(LayoutOrientation::kHorizontal)
@@ -71,6 +72,26 @@ class VIEWS_EXPORT AnimatingLayoutManager : public LayoutManagerBase {
bool is_animating) = 0;
};
+ // Describes if and how the bounds of the host view can be animated as part of
+ // layout animations, if the preferred size of the layout changes.
+ enum BoundsAnimationMode {
+ // Default behavior: the host view will always take the space given to it by
+ // its parent view and child views will animate within those bounds. Useful
+ // for cases where the layout is in a fixed-size container or dialog, but
+ // we want child views to be able to animate.
+ kUseHostBounds,
+ // The host view will request more or less space within the available space
+ // offered by its parent view, allowing its main axis size to animate, but
+ // will use exactly the cross-axis space provided, as it would with
+ // kUseHostBounds. Useful if the host view is in a toolbar or a dialog with
+ // fixed width but variable height or vice-versa.
+ kAnimateMainAxis,
+ // The host view will request more space or less space in both axes within
+ // the available space offered by its parent view. Useful if the host view
+ // is in e.g. a dialog that can vary in size.
+ kAnimateBothAxes
+ };
+
// Describes how a view which is appearing or disappearing during an animation
// behaves. Child views which are removed from the parent view always simply
// disappear; use one of the Fade methods below to cause a view to fade out.
@@ -96,8 +117,11 @@ class VIEWS_EXPORT AnimatingLayoutManager : public LayoutManagerBase {
AnimatingLayoutManager();
~AnimatingLayoutManager() override;
- bool should_animate_bounds() const { return should_animate_bounds_; }
- AnimatingLayoutManager& SetShouldAnimateBounds(bool should_animate_bounds);
+ BoundsAnimationMode bounds_animation_mode() const {
+ return bounds_animation_mode_;
+ }
+ AnimatingLayoutManager& SetBoundsAnimationMode(
+ BoundsAnimationMode bounds_animation_mode);
base::TimeDelta animation_duration() const { return animation_duration_; }
AnimatingLayoutManager& SetAnimationDuration(
@@ -253,11 +277,10 @@ class VIEWS_EXPORT AnimatingLayoutManager : public LayoutManagerBase {
const View* view,
const SizeBounds& size_bounds);
- // Whether or not to animate the bounds of the host view when the preferred
- // size of the layout changes. If false, the size will have to be set
- // explicitly by the host view's owner. Bounds animation is done by changing
- // the preferred size and invalidating the layout.
- bool should_animate_bounds_ = false;
+ // How to animate bounds of the host view when the preferred size of the
+ // layout changes.
+ BoundsAnimationMode bounds_animation_mode_ =
+ BoundsAnimationMode::kUseHostBounds;
// How long each animation takes. Depending on how far along an animation is,
// a new target layout will either cause the animation to restart or redirect.
diff --git a/chromium/ui/views/layout/animating_layout_manager_unittest.cc b/chromium/ui/views/layout/animating_layout_manager_unittest.cc
index 896ce78b5f5..8fc53d36838 100644
--- a/chromium/ui/views/layout/animating_layout_manager_unittest.cc
+++ b/chromium/ui/views/layout/animating_layout_manager_unittest.cc
@@ -15,6 +15,7 @@
#include "ui/gfx/animation/animation_test_api.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/flex_layout.h"
+#include "ui/views/layout/normalized_geometry.h"
#include "ui/views/test/views_test_base.h"
#include "ui/views/view.h"
#include "ui/views/view_class_properties.h"
@@ -251,7 +252,8 @@ const FlexSpecification AnimatingLayoutManagerTest::kFlex =
TEST_F(AnimatingLayoutManagerTest, SetLayoutManager_NoAnimation) {
auto test_layout = std::make_unique<TestLayoutManager>();
test_layout->SetLayout(layout1());
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetTargetLayoutManager(std::move(test_layout));
SizeAndLayout();
@@ -261,7 +263,8 @@ TEST_F(AnimatingLayoutManagerTest, SetLayoutManager_NoAnimation) {
}
TEST_F(AnimatingLayoutManagerTest, ResetLayout_NoAnimation) {
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -274,7 +277,8 @@ TEST_F(AnimatingLayoutManagerTest, ResetLayout_NoAnimation) {
}
TEST_F(AnimatingLayoutManagerTest, HostInvalidate_TriggersAnimation) {
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -293,7 +297,8 @@ TEST_F(AnimatingLayoutManagerTest, HostInvalidate_TriggersAnimation) {
TEST_F(AnimatingLayoutManagerTest,
HostInvalidate_AnimateBounds_AnimationProgresses) {
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -330,7 +335,8 @@ TEST_F(AnimatingLayoutManagerTest,
}
TEST_F(AnimatingLayoutManagerTest, HostInvalidate_NoAnimateBounds_NoAnimation) {
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -351,7 +357,8 @@ TEST_F(AnimatingLayoutManagerTest, HostInvalidate_NoAnimateBounds_NoAnimation) {
}
TEST_F(AnimatingLayoutManagerTest, HostResize_NoAnimateBounds_NoAnimation) {
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -375,7 +382,8 @@ TEST_F(AnimatingLayoutManagerTest, HostResize_NoAnimateBounds_NoAnimation) {
TEST_F(AnimatingLayoutManagerTest,
HostInvalidate_NoAnimateBounds_NewLayoutTriggersAnimation) {
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -400,7 +408,8 @@ TEST_F(AnimatingLayoutManagerTest,
TEST_F(AnimatingLayoutManagerTest,
HostInvalidate_NoAnimateBounds_AnimationProgresses) {
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -449,7 +458,8 @@ TEST_F(AnimatingLayoutManagerTest, FadeInOutMode_MiddleView_ScaleFromZero) {
{{child(0), true, {5, 5, 10, 10}},
{child(1), true, {20, 5, 10, 10}},
{child(2), true, {35, 5, 10, 10}}}};
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromZero);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
@@ -528,7 +538,8 @@ TEST_F(AnimatingLayoutManagerTest, FadeInOutMode_MiddleView_ScaleFromMinimum) {
{{child(0), true, {5, 5, 10, 10}},
{child(1), true, {20, 5, 10, 10}},
{child(2), true, {35, 5, 10, 10}}}};
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromMinimum);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
@@ -591,7 +602,8 @@ TEST_F(AnimatingLayoutManagerTest, FadeInOutMode_LeadingView_ScaleFromMinimum) {
{{child(0), true, {5, 5, 10, 10}},
{child(1), true, {20, 5, 10, 10}},
{child(2), true, {35, 5, 10, 10}}}};
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromMinimum);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
@@ -654,7 +666,8 @@ TEST_F(AnimatingLayoutManagerTest,
{child(1), true, {20, 5, 10, 10}},
{child(2), false}}};
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromMinimum);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
@@ -718,7 +731,8 @@ TEST_F(AnimatingLayoutManagerTest,
{{child(0), true, {5, 5, 10, 10}},
{child(1), true, {20, 5, 10, 10}},
{child(2), true, {35, 5, 10, 10}}}};
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromMinimum);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
@@ -782,7 +796,8 @@ TEST_F(AnimatingLayoutManagerTest,
{{child(0), true, {5, 5, 10, 10}},
{child(1), true, {5, 20, 10, 10}},
{child(2), true, {5, 35, 10, 10}}}};
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromMinimum);
layout()->SetOrientation(LayoutOrientation::kVertical);
@@ -839,7 +854,8 @@ TEST_F(AnimatingLayoutManagerTest,
TEST_F(AnimatingLayoutManagerTest,
FadeInOutMode_Hide_HidesViewDuringAnimation) {
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetDefaultFadeMode(AnimatingLayoutManager::FadeInOutMode::kHide);
layout()->SetOrientation(LayoutOrientation::kVertical);
FlexLayout* const flex_layout =
@@ -881,7 +897,8 @@ TEST_F(AnimatingLayoutManagerTest,
TEST_F(AnimatingLayoutManagerTest,
FadeInOutMode_Hide_HidesViewDuringAnimation_OneFrame) {
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetDefaultFadeMode(AnimatingLayoutManager::FadeInOutMode::kHide);
layout()->SetOrientation(LayoutOrientation::kVertical);
FlexLayout* const flex_layout =
@@ -916,7 +933,8 @@ TEST_F(AnimatingLayoutManagerTest,
TEST_F(AnimatingLayoutManagerTest,
FadeInOutMode_Hide_AnimationResetDuringHide) {
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetDefaultFadeMode(AnimatingLayoutManager::FadeInOutMode::kHide);
layout()->SetOrientation(LayoutOrientation::kVertical);
FlexLayout* const flex_layout =
@@ -957,7 +975,8 @@ TEST_F(AnimatingLayoutManagerTest, FadeInOutMode_SlideFromLeading_LastView) {
{child(1), true, {20, 5, 10, 10}},
{child(2), true, {35, 5, 10, 10}}}};
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kSlideFromLeadingEdge);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
@@ -1004,7 +1023,8 @@ TEST_F(AnimatingLayoutManagerTest, FadeInOutMode_SlideFromLeading_Vertical) {
{child(1), true, {5, 20, 10, 10}},
{child(2), true, {5, 35, 10, 10}}}};
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kSlideFromLeadingEdge);
layout()->SetOrientation(LayoutOrientation::kVertical);
@@ -1052,7 +1072,8 @@ TEST_F(AnimatingLayoutManagerTest, FadeInOutMode_SlideFromLeading_MiddleView) {
{child(1), false},
{child(2), true, {20, 5, 10, 10}}}};
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kSlideFromLeadingEdge);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
@@ -1102,7 +1123,8 @@ TEST_F(AnimatingLayoutManagerTest,
{child(1), true, {5, 5, 5, 10}},
{child(2), true, {20, 5, 10, 10}}}};
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kSlideFromLeadingEdge);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
@@ -1151,7 +1173,8 @@ TEST_F(AnimatingLayoutManagerTest, FadeInOutMode_SlideFromTrailing_MiddleView) {
{child(1), false},
{child(2), true, {20, 5, 10, 10}}}};
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kSlideFromTrailingEdge);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
@@ -1191,7 +1214,8 @@ TEST_F(AnimatingLayoutManagerTest, FadeInOutMode_SlideFromTrailing_MiddleView) {
TEST_F(AnimatingLayoutManagerTest, FlexLayout_FadeOutOnVisibilitySet) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromZero);
@@ -1247,7 +1271,8 @@ TEST_F(AnimatingLayoutManagerTest, FlexLayout_FadeOutOnVisibilitySet) {
TEST_F(AnimatingLayoutManagerTest, FlexLayout_FadeInOnVisibilitySet) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromZero);
@@ -1306,7 +1331,8 @@ TEST_F(AnimatingLayoutManagerTest, FlexLayout_FadeInOnVisibilitySet) {
TEST_F(AnimatingLayoutManagerTest,
FlexLayout_AnimateOutOnDescendentVisbilitySet) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromZero);
@@ -1368,7 +1394,8 @@ TEST_F(AnimatingLayoutManagerTest,
TEST_F(AnimatingLayoutManagerTest,
FlexLayout_AnimateInOnDescendentVisbilitySet) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromZero);
@@ -1430,7 +1457,8 @@ TEST_F(AnimatingLayoutManagerTest,
// Regression test for crbug.com/1037625: crash in SetViewVisibility() (1/2)
TEST_F(AnimatingLayoutManagerTest, FlexLayout_RemoveFadingViewDoesNotCrash) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
@@ -1473,7 +1501,8 @@ TEST_F(AnimatingLayoutManagerTest, FlexLayout_RemoveFadingViewDoesNotCrash) {
// Regression test for crbug.com/1037625: crash in SetViewVisibility() (2/2)
TEST_F(AnimatingLayoutManagerTest, FlexLayout_RemoveShowingViewDoesNotCrash) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
child(1)->SetVisible(false);
auto* const flex_layout =
@@ -1509,7 +1538,8 @@ TEST_F(AnimatingLayoutManagerTest, FlexLayout_RemoveShowingViewDoesNotCrash) {
// Regression test for crbug.com/1037947 (1/2)
TEST_F(AnimatingLayoutManagerTest, FlexLayout_DoubleSlide) {
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kSlideFromTrailingEdge);
@@ -1596,7 +1626,8 @@ TEST_F(AnimatingLayoutManagerTest, FlexLayout_DoubleSlide) {
// [A] [B]
//
TEST_F(AnimatingLayoutManagerTest, FlexLayout_RedirectAfterExchangePlaces) {
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kSlideFromLeadingEdge);
@@ -1647,7 +1678,8 @@ TEST_F(AnimatingLayoutManagerTest, FlexLayout_RedirectAfterExchangePlaces) {
TEST_F(AnimatingLayoutManagerTest,
FlexLayout_PostDelayedActionAfterFadeIn_AnimateNewViewIn) {
child(0)->SetVisible(false);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
@@ -1686,7 +1718,8 @@ TEST_F(AnimatingLayoutManagerTest,
TEST_F(AnimatingLayoutManagerTest,
FlexLayout_PostDelayedActionAfterFadeIn_SwapTwoViews) {
child(0)->SetVisible(false);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
@@ -1726,7 +1759,8 @@ TEST_F(AnimatingLayoutManagerTest,
// change and FadeIn() was called.
TEST_F(AnimatingLayoutManagerTest,
FlexLayout_PostDelayedActionAfterFadeIn_FadeInHiddenView) {
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
@@ -1779,7 +1813,8 @@ TEST_F(AnimatingLayoutManagerTest, RemoveDuringAnimationDoesntCrash) {
const ProposedLayout final_layout{
{20, 20},
{{child(0), true, {5, 5, 10, 10}}, {child(1), false}, {child(2), false}}};
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kSlideFromLeadingEdge);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
@@ -1809,7 +1844,8 @@ TEST_F(AnimatingLayoutManagerTest, RemoveDuringAnimationDoesntCrash) {
TEST_F(AnimatingLayoutManagerTest, FlexLayout_FadeInOnAdded) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromZero);
@@ -1869,7 +1905,8 @@ TEST_F(AnimatingLayoutManagerTest, FlexLayout_FadeInOnAdded) {
TEST_F(AnimatingLayoutManagerTest, FlexLayout_FadeIn) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromZero);
@@ -1926,7 +1963,8 @@ TEST_F(AnimatingLayoutManagerTest, FlexLayout_FadeIn) {
TEST_F(AnimatingLayoutManagerTest, FlexLayout_FadeOut) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromZero);
@@ -1982,7 +2020,8 @@ TEST_F(AnimatingLayoutManagerTest, FlexLayout_FadeOut) {
TEST_F(AnimatingLayoutManagerTest, FlexLayout_FadeOut_NoCrashOnRemove) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromZero);
@@ -2040,7 +2079,8 @@ TEST_F(AnimatingLayoutManagerTest, FlexLayout_FadeOut_NoCrashOnRemove) {
TEST_F(AnimatingLayoutManagerTest, FlexLayout_FadeOut_IgnoreChildView) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetOrientation(LayoutOrientation::kHorizontal);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromZero);
@@ -2094,7 +2134,8 @@ TEST_F(AnimatingLayoutManagerTest, FlexLayout_FadeOut_IgnoreChildView) {
// which is hidden, and that such a layout change triggers animation.
TEST_F(AnimatingLayoutManagerTest, FlexLayout_SlideAfterViewHidden) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -2146,7 +2187,8 @@ TEST_F(AnimatingLayoutManagerTest, FlexLayout_SlideAfterViewHidden) {
// which is removed, and that such a layout change triggers animation.
TEST_F(AnimatingLayoutManagerTest, FlexLayout_SlideAfterViewRemoved) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -2198,7 +2240,8 @@ TEST_F(AnimatingLayoutManagerTest, FlexLayout_SlideAfterViewRemoved) {
// the animation redirects.
TEST_F(AnimatingLayoutManagerTest, FlexLayout_RedirectAnimation) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -2257,7 +2300,8 @@ TEST_F(AnimatingLayoutManagerTest, FlexLayout_RedirectAnimation) {
// of the animation, the animation resets.
TEST_F(AnimatingLayoutManagerTest, FlexLayout_ResetAnimation) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -2317,7 +2361,8 @@ TEST_F(AnimatingLayoutManagerTest, FlexLayout_ResetAnimation) {
}
TEST_F(AnimatingLayoutManagerTest, TestEvents) {
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -2348,7 +2393,8 @@ TEST_F(AnimatingLayoutManagerTest, TestEvents) {
}
TEST_F(AnimatingLayoutManagerTest, PostOrQueueAction) {
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -2400,7 +2446,8 @@ TEST_F(AnimatingLayoutManagerTest, PostOrQueueAction) {
}
TEST_F(AnimatingLayoutManagerTest, PostOrQueueAction_ContinueAnimation) {
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -2462,7 +2509,8 @@ TEST_F(AnimatingLayoutManagerTest, PostOrQueueAction_ContinueAnimation) {
}
TEST_F(AnimatingLayoutManagerTest, PostOrQueueAction_NeverFinishes) {
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -2505,7 +2553,8 @@ TEST_F(AnimatingLayoutManagerTest, PostOrQueueAction_NeverFinishes) {
}
TEST_F(AnimatingLayoutManagerTest, PostOrQueueAction_MayPostImmediately) {
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -2563,7 +2612,8 @@ TEST_F(AnimatingLayoutManagerTest, ZOrder_UnchangedWhenNotAnimating) {
}
TEST_F(AnimatingLayoutManagerTest, ZOrder_UnchangedWhenNotFading) {
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -2603,7 +2653,8 @@ TEST_F(AnimatingLayoutManagerTest, ZOrder_FadingOutViewMovedToBack) {
const std::vector<View*> expected_order{child(1), child(0), child(2)};
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromZero);
auto* const test_layout =
@@ -2642,7 +2693,8 @@ TEST_F(AnimatingLayoutManagerTest, ZOrder_FadingInViewMovedToBack) {
const std::vector<View*> expected_order{child(1), child(0), child(2)};
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetDefaultFadeMode(
AnimatingLayoutManager::FadeInOutMode::kScaleFromZero);
auto* const test_layout =
@@ -2669,7 +2721,8 @@ TEST_F(AnimatingLayoutManagerTest, ZOrder_FadingInViewMovedToBack) {
}
TEST_F(AnimatingLayoutManagerTest, ConstrainedSpace_StopsAnimation) {
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -2689,7 +2742,8 @@ TEST_F(AnimatingLayoutManagerTest, ConstrainedSpace_StopsAnimation) {
}
TEST_F(AnimatingLayoutManagerTest, ConstrainedSpace_TriggersDelayedAction) {
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -2717,7 +2771,8 @@ TEST_F(AnimatingLayoutManagerTest, ConstrainedSpace_TriggersDelayedAction) {
}
TEST_F(AnimatingLayoutManagerTest, ConstrainedSpace_SubsequentAnimation) {
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const test_layout =
layout()->SetTargetLayoutManager(std::make_unique<TestLayoutManager>());
test_layout->SetLayout(layout1());
@@ -2753,12 +2808,18 @@ constexpr base::TimeDelta kMinimumAnimationTime =
// invalidated.
class ImmediateLayoutManager : public LayoutManagerBase {
public:
- explicit ImmediateLayoutManager(bool use_preferred_size,
- SizeBounds size_bounds = SizeBounds())
- : use_preferred_size_(use_preferred_size),
- size_bounds_(std::move(size_bounds)) {
- DCHECK(use_preferred_size_ || size_bounds == SizeBounds());
- }
+ ImmediateLayoutManager()
+ : ImmediateLayoutManager(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes,
+ LayoutOrientation::kHorizontal) {}
+
+ ImmediateLayoutManager(
+ AnimatingLayoutManager::BoundsAnimationMode bounds_animation_mode,
+ LayoutOrientation orientation,
+ SizeBounds size_bounds = SizeBounds())
+ : bounds_animation_mode_(bounds_animation_mode),
+ orientation_(orientation),
+ size_bounds_(std::move(size_bounds)) {}
// LayoutManager:
@@ -2777,11 +2838,23 @@ class ImmediateLayoutManager : public LayoutManagerBase {
child_layout.child_view = child;
child_layout.visible = child->GetVisible();
child_layout.available_size = size_bounds_;
- if (use_preferred_size_) {
- child_layout.bounds = gfx::Rect(
- ConstrainSizeToBounds(child->GetPreferredSize(), size_bounds_));
- } else {
- child_layout.bounds = child->bounds();
+ switch (bounds_animation_mode_) {
+ case AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes:
+ child_layout.bounds = gfx::Rect(
+ ConstrainSizeToBounds(child->GetPreferredSize(), size_bounds_));
+ break;
+ case AnimatingLayoutManager::BoundsAnimationMode::kAnimateMainAxis: {
+ // Start with the preferred size constrained to the bounds, then force
+ // the cross axis.
+ gfx::Size size =
+ ConstrainSizeToBounds(child->GetPreferredSize(), size_bounds_);
+ SetCrossAxis(&size, orientation_,
+ GetCrossAxis(orientation_, child->bounds().size()));
+ child_layout.bounds = gfx::Rect(size);
+ } break;
+ case AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds:
+ child_layout.bounds = child->bounds();
+ break;
}
layout.host_size.SetToMax(child_layout.bounds.size());
layout.child_layouts.push_back(child_layout);
@@ -2796,7 +2869,8 @@ class ImmediateLayoutManager : public LayoutManagerBase {
}
private:
- const bool use_preferred_size_;
+ const AnimatingLayoutManager::BoundsAnimationMode bounds_animation_mode_;
+ const LayoutOrientation orientation_;
SizeBounds size_bounds_;
};
@@ -2865,7 +2939,7 @@ class AnimatingLayoutManagerAvailableSizeTest
void InitRootView() {
root_layout_ =
root_view()->SetLayoutManager(std::make_unique<ImmediateLayoutManager>(
- layout()->should_animate_bounds()));
+ layout()->bounds_animation_mode(), layout()->orientation()));
}
ImmediateLayoutManager* root_layout() { return root_layout_; }
@@ -2876,7 +2950,8 @@ class AnimatingLayoutManagerAvailableSizeTest
TEST_F(AnimatingLayoutManagerAvailableSizeTest, AvailableSize_LimitsExpansion) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -2924,7 +2999,8 @@ TEST_F(AnimatingLayoutManagerAvailableSizeTest, AvailableSize_LimitsExpansion) {
TEST_F(AnimatingLayoutManagerAvailableSizeTest,
AvailableSize_RestartsAnimation) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -2966,7 +3042,8 @@ TEST_F(AnimatingLayoutManagerAvailableSizeTest,
TEST_F(AnimatingLayoutManagerAvailableSizeTest,
AvailableSize_RestartsAnimation_Vertical) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kVertical);
@@ -3019,7 +3096,8 @@ TEST_F(AnimatingLayoutManagerAvailableSizeTest,
TEST_F(AnimatingLayoutManagerAvailableSizeTest,
AvailableSize_RedirectsAnimation) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -3064,7 +3142,8 @@ TEST_F(AnimatingLayoutManagerAvailableSizeTest,
TEST_F(AnimatingLayoutManagerAvailableSizeTest, AvailableSize_StopsAnimation) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -3103,7 +3182,8 @@ TEST_F(AnimatingLayoutManagerAvailableSizeTest, AvailableSize_StopsAnimation) {
TEST_F(AnimatingLayoutManagerAvailableSizeTest, AvailableSize_ImmediateResize) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -3131,7 +3211,8 @@ TEST_F(AnimatingLayoutManagerAvailableSizeTest, AvailableSize_ImmediateResize) {
TEST_F(AnimatingLayoutManagerAvailableSizeTest, AvailableSize_StepDownStepUp) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -3173,7 +3254,8 @@ TEST_F(AnimatingLayoutManagerAvailableSizeTest, AvailableSize_StepDownStepUp) {
TEST_F(AnimatingLayoutManagerAvailableSizeTest,
AvailableSize_ConstraintRemovedStartsAnimation) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -3213,7 +3295,8 @@ TEST_F(AnimatingLayoutManagerAvailableSizeTest,
TEST_F(AnimatingLayoutManagerAvailableSizeTest,
AvailableSize_LimitsExpansion_WithFlex) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -3263,7 +3346,8 @@ TEST_F(AnimatingLayoutManagerAvailableSizeTest,
TEST_F(AnimatingLayoutManagerAvailableSizeTest,
AvailableSize_RestartsAnimation_WithFlex) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -3306,7 +3390,8 @@ TEST_F(AnimatingLayoutManagerAvailableSizeTest,
TEST_F(AnimatingLayoutManagerAvailableSizeTest,
AvailableSize_RedirectsAnimation_WithFlex) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -3354,7 +3439,8 @@ TEST_F(AnimatingLayoutManagerAvailableSizeTest,
TEST_F(AnimatingLayoutManagerAvailableSizeTest,
AvailableSize_StopsAnimation_WithFlex) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -3395,7 +3481,8 @@ TEST_F(AnimatingLayoutManagerAvailableSizeTest,
TEST_F(AnimatingLayoutManagerAvailableSizeTest,
AvailableSize_ImmediateResize_WithFlex) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -3425,7 +3512,8 @@ TEST_F(AnimatingLayoutManagerAvailableSizeTest,
TEST_F(AnimatingLayoutManagerAvailableSizeTest,
AvailableSize_StepDownStepUp_WithFlex) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -3467,7 +3555,8 @@ TEST_F(AnimatingLayoutManagerAvailableSizeTest,
TEST_F(AnimatingLayoutManagerAvailableSizeTest,
AvailableSize_ConstraintRemovedStartsAnimation_WithFlex) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
flex_layout->SetOrientation(LayoutOrientation::kHorizontal);
@@ -3506,6 +3595,330 @@ TEST_F(AnimatingLayoutManagerAvailableSizeTest,
EXPECT_EQ(expected_events, logger.events());
}
+TEST_F(AnimatingLayoutManagerAvailableSizeTest,
+ AnimateMainAxis_Horizontal_MainAxisAnimates) {
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateMainAxis);
+ auto* const flex_layout =
+ layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
+ flex_layout->SetOrientation(LayoutOrientation::kHorizontal)
+ .SetCrossAxisAlignment(LayoutAlignment::kStart)
+ .SetDefault(kFlexBehaviorKey,
+ FlexSpecification(LayoutOrientation::kHorizontal,
+ MinimumFlexSizeRule::kPreferred,
+ MaximumFlexSizeRule::kPreferred, false,
+ MinimumFlexSizeRule::kScaleToZero));
+ view()->SetBoundsRect(gfx::Rect(0, 0, 5, 5));
+ InitRootView();
+ layout()->ResetLayout();
+ root_view()->Layout();
+
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(30, 5), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 0, 10, 5), child(0)->bounds());
+ EXPECT_TRUE(child(1)->GetVisible());
+ EXPECT_EQ(gfx::Rect(10, 0, 10, 5), child(1)->bounds());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(20, 0, 10, 5), child(2)->bounds());
+
+ child(1)->SetVisible(false);
+ EXPECT_TRUE(layout()->is_animating());
+
+ // Advance the animation halfway.
+ animation_api()->IncrementTime(base::TimeDelta::FromMilliseconds(500));
+ EXPECT_TRUE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(25, 5), view()->size());
+
+ // Finish the animation.
+ animation_api()->IncrementTime(base::TimeDelta::FromMilliseconds(500));
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(20, 5), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 0, 10, 5), child(0)->bounds());
+ EXPECT_FALSE(child(1)->GetVisible());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(10, 0, 10, 5), child(2)->bounds());
+}
+
+TEST_F(AnimatingLayoutManagerAvailableSizeTest,
+ AnimateMainAxis_Vertical_MainAxisAnimates) {
+ layout()
+ ->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateMainAxis)
+ .SetOrientation(LayoutOrientation::kVertical);
+ auto* const flex_layout =
+ layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
+ flex_layout->SetOrientation(LayoutOrientation::kVertical)
+ .SetCrossAxisAlignment(LayoutAlignment::kStart)
+ .SetDefault(kFlexBehaviorKey,
+ FlexSpecification(LayoutOrientation::kVertical,
+ MinimumFlexSizeRule::kPreferred,
+ MaximumFlexSizeRule::kPreferred, false,
+ MinimumFlexSizeRule::kScaleToZero));
+ view()->SetBoundsRect(gfx::Rect(0, 0, 5, 5));
+ InitRootView();
+ layout()->ResetLayout();
+ root_view()->Layout();
+
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(5, 30), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 0, 5, 10), child(0)->bounds());
+ EXPECT_TRUE(child(1)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 10, 5, 10), child(1)->bounds());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 20, 5, 10), child(2)->bounds());
+
+ child(1)->SetVisible(false);
+ EXPECT_TRUE(layout()->is_animating());
+
+ // Advance the animation halfway.
+ animation_api()->IncrementTime(base::TimeDelta::FromMilliseconds(500));
+ EXPECT_TRUE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(5, 25), view()->size());
+
+ // Finish the animation.
+ animation_api()->IncrementTime(base::TimeDelta::FromMilliseconds(500));
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(5, 20), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 0, 5, 10), child(0)->bounds());
+ EXPECT_FALSE(child(1)->GetVisible());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 10, 5, 10), child(2)->bounds());
+}
+
+TEST_F(AnimatingLayoutManagerAvailableSizeTest,
+ AnimateMainAxis_Horizontal_CrossAxisSizeChangeResetsLayout) {
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateMainAxis);
+ auto* const flex_layout =
+ layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
+ flex_layout->SetOrientation(LayoutOrientation::kHorizontal)
+ .SetCrossAxisAlignment(LayoutAlignment::kStart)
+ .SetDefault(kFlexBehaviorKey,
+ FlexSpecification(LayoutOrientation::kHorizontal,
+ MinimumFlexSizeRule::kPreferred,
+ MaximumFlexSizeRule::kPreferred, false,
+ MinimumFlexSizeRule::kScaleToZero));
+ view()->SetBoundsRect(gfx::Rect(0, 0, 5, 5));
+ InitRootView();
+ layout()->ResetLayout();
+ root_view()->Layout();
+
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(30, 5), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 0, 10, 5), child(0)->bounds());
+ EXPECT_TRUE(child(1)->GetVisible());
+ EXPECT_EQ(gfx::Rect(10, 0, 10, 5), child(1)->bounds());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(20, 0, 10, 5), child(2)->bounds());
+
+ child(1)->SetVisible(false);
+ EXPECT_TRUE(layout()->is_animating());
+
+ // Advance the animation halfway.
+ animation_api()->IncrementTime(base::TimeDelta::FromMilliseconds(500));
+ EXPECT_TRUE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(25, 5), view()->size());
+
+ // Change the cross-axis size.
+ view()->SetSize(gfx::Size(25, 7));
+ view()->InvalidateLayout();
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(20, 7), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 0, 10, 7), child(0)->bounds());
+ EXPECT_FALSE(child(1)->GetVisible());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(10, 0, 10, 7), child(2)->bounds());
+}
+
+TEST_F(AnimatingLayoutManagerAvailableSizeTest,
+ AnimateMainAxis_Vertical_CrossAxisSizeChangeResetsLayout) {
+ layout()
+ ->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateMainAxis)
+ .SetOrientation(LayoutOrientation::kVertical);
+ auto* const flex_layout =
+ layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
+ flex_layout->SetOrientation(LayoutOrientation::kVertical)
+ .SetCrossAxisAlignment(LayoutAlignment::kStart)
+ .SetDefault(kFlexBehaviorKey,
+ FlexSpecification(LayoutOrientation::kVertical,
+ MinimumFlexSizeRule::kPreferred,
+ MaximumFlexSizeRule::kPreferred, false,
+ MinimumFlexSizeRule::kScaleToZero));
+ view()->SetBoundsRect(gfx::Rect(0, 0, 5, 5));
+ InitRootView();
+ layout()->ResetLayout();
+ root_view()->Layout();
+
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(5, 30), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 0, 5, 10), child(0)->bounds());
+ EXPECT_TRUE(child(1)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 10, 5, 10), child(1)->bounds());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 20, 5, 10), child(2)->bounds());
+
+ child(1)->SetVisible(false);
+ EXPECT_TRUE(layout()->is_animating());
+
+ // Advance the animation halfway.
+ animation_api()->IncrementTime(base::TimeDelta::FromMilliseconds(500));
+ EXPECT_TRUE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(5, 25), view()->size());
+
+ // Change the cross-axis size.
+ view()->SetSize(gfx::Size(7, 25));
+ view()->InvalidateLayout();
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(7, 20), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 0, 7, 10), child(0)->bounds());
+ EXPECT_FALSE(child(1)->GetVisible());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 10, 7, 10), child(2)->bounds());
+}
+
+TEST_F(AnimatingLayoutManagerAvailableSizeTest,
+ AnimateMainAxis_Horizontal_CrossAxisAlignmentWorks) {
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateMainAxis);
+ auto* const flex_layout =
+ layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
+ flex_layout->SetOrientation(LayoutOrientation::kHorizontal)
+ .SetCrossAxisAlignment(LayoutAlignment::kStart);
+ // Pick an arbitrary (wrong) main-axis size.
+ view()->SetBoundsRect(gfx::Rect(0, 0, 20, 20));
+ InitRootView();
+ layout()->ResetLayout();
+ root_view()->Layout();
+
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(30, 20), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 0, 10, 10), child(0)->bounds());
+ EXPECT_TRUE(child(1)->GetVisible());
+ EXPECT_EQ(gfx::Rect(10, 0, 10, 10), child(1)->bounds());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(20, 0, 10, 10), child(2)->bounds());
+
+ flex_layout->SetCrossAxisAlignment(LayoutAlignment::kCenter);
+ EXPECT_TRUE(layout()->is_animating());
+
+ // Finish the animation.
+ animation_api()->IncrementTime(base::TimeDelta::FromMilliseconds(1000));
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(30, 20), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 5, 10, 10), child(0)->bounds());
+ EXPECT_TRUE(child(1)->GetVisible());
+ EXPECT_EQ(gfx::Rect(10, 5, 10, 10), child(1)->bounds());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(20, 5, 10, 10), child(2)->bounds());
+
+ flex_layout->SetCrossAxisAlignment(LayoutAlignment::kEnd);
+ EXPECT_TRUE(layout()->is_animating());
+
+ // Finish the animation.
+ animation_api()->IncrementTime(base::TimeDelta::FromMilliseconds(1000));
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(30, 20), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 10, 10, 10), child(0)->bounds());
+ EXPECT_TRUE(child(1)->GetVisible());
+ EXPECT_EQ(gfx::Rect(10, 10, 10, 10), child(1)->bounds());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(20, 10, 10, 10), child(2)->bounds());
+
+ flex_layout->SetCrossAxisAlignment(LayoutAlignment::kStretch);
+ EXPECT_TRUE(layout()->is_animating());
+
+ // Finish the animation.
+ animation_api()->IncrementTime(base::TimeDelta::FromMilliseconds(1000));
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(30, 20), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 0, 10, 20), child(0)->bounds());
+ EXPECT_TRUE(child(1)->GetVisible());
+ EXPECT_EQ(gfx::Rect(10, 0, 10, 20), child(1)->bounds());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(20, 0, 10, 20), child(2)->bounds());
+}
+
+TEST_F(AnimatingLayoutManagerAvailableSizeTest,
+ AnimateMainAxis_Vertical_CrossAxisAlignmentWorks) {
+ layout()
+ ->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateMainAxis)
+ .SetOrientation(LayoutOrientation::kVertical);
+ auto* const flex_layout =
+ layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
+ flex_layout->SetOrientation(LayoutOrientation::kVertical)
+ .SetCrossAxisAlignment(LayoutAlignment::kStart);
+ // Pick an arbitrary (wrong) main-axis size.
+ view()->SetBoundsRect(gfx::Rect(0, 0, 20, 20));
+ InitRootView();
+ layout()->ResetLayout();
+ root_view()->Layout();
+
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(20, 30), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 0, 10, 10), child(0)->bounds());
+ EXPECT_TRUE(child(1)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 10, 10, 10), child(1)->bounds());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 20, 10, 10), child(2)->bounds());
+
+ flex_layout->SetCrossAxisAlignment(LayoutAlignment::kCenter);
+ EXPECT_TRUE(layout()->is_animating());
+
+ // Finish the animation.
+ animation_api()->IncrementTime(base::TimeDelta::FromMilliseconds(1000));
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(20, 30), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(5, 0, 10, 10), child(0)->bounds());
+ EXPECT_TRUE(child(1)->GetVisible());
+ EXPECT_EQ(gfx::Rect(5, 10, 10, 10), child(1)->bounds());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(5, 20, 10, 10), child(2)->bounds());
+
+ flex_layout->SetCrossAxisAlignment(LayoutAlignment::kEnd);
+ EXPECT_TRUE(layout()->is_animating());
+
+ // Finish the animation.
+ animation_api()->IncrementTime(base::TimeDelta::FromMilliseconds(1000));
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(20, 30), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(10, 0, 10, 10), child(0)->bounds());
+ EXPECT_TRUE(child(1)->GetVisible());
+ EXPECT_EQ(gfx::Rect(10, 10, 10, 10), child(1)->bounds());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(10, 20, 10, 10), child(2)->bounds());
+
+ flex_layout->SetCrossAxisAlignment(LayoutAlignment::kStretch);
+ EXPECT_TRUE(layout()->is_animating());
+
+ // Finish the animation.
+ animation_api()->IncrementTime(base::TimeDelta::FromMilliseconds(1000));
+ EXPECT_FALSE(layout()->is_animating());
+ EXPECT_EQ(gfx::Size(20, 30), view()->size());
+ EXPECT_TRUE(child(0)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 0, 20, 10), child(0)->bounds());
+ EXPECT_TRUE(child(1)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 10, 20, 10), child(1)->bounds());
+ EXPECT_TRUE(child(2)->GetVisible());
+ EXPECT_EQ(gfx::Rect(0, 20, 20, 10), child(2)->bounds());
+}
+
// Flex Rule Tests -------------------------------------------------------------
class AnimatingLayoutManagerFlexRuleTest : public AnimatingLayoutManagerTest {
@@ -3699,7 +4112,8 @@ class AnimatingLayoutManagerInFlexLayoutTest
protected:
void SetUp() override {
AnimatingLayoutManagerRootViewTest::SetUp();
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
root_layout_ =
root_view()->SetLayoutManager(std::make_unique<FlexLayout>());
root_layout_->SetOrientation(LayoutOrientation::kHorizontal)
@@ -4137,7 +4551,8 @@ class AnimatingLayoutManagerRealtimeTest
protected:
void InitRootView(SizeBounds bounds = SizeBounds()) {
root_view()->SetLayoutManager(std::make_unique<ImmediateLayoutManager>(
- layout()->should_animate_bounds(), std::move(bounds)));
+ layout()->bounds_animation_mode(), layout()->orientation(),
+ std::move(bounds)));
layout()->EnableAnimationForTesting();
}
@@ -4149,7 +4564,8 @@ class AnimatingLayoutManagerRealtimeTest
TEST_F(AnimatingLayoutManagerRealtimeTest, TestAnimateSlide) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetAnimationDuration(kMinimumAnimationTime);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
@@ -4187,7 +4603,8 @@ TEST_F(AnimatingLayoutManagerRealtimeTest, TestAnimateSlide) {
TEST_F(AnimatingLayoutManagerRealtimeTest, TestAnimateStretch) {
constexpr gfx::Insets kChildMargins(5);
- layout()->SetShouldAnimateBounds(false);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kUseHostBounds);
layout()->SetAnimationDuration(kMinimumAnimationTime);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
@@ -4227,7 +4644,8 @@ TEST_F(AnimatingLayoutManagerRealtimeTest, TestAnimateStretch) {
TEST_F(AnimatingLayoutManagerRealtimeTest, TestConstrainedSpaceStopsAnimation) {
constexpr gfx::Insets kChildMargins(5);
constexpr SizeBounds kSizeBounds(45, base::nullopt);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetAnimationDuration(kMinimumAnimationTime);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
@@ -4271,7 +4689,8 @@ TEST_F(AnimatingLayoutManagerRealtimeTest, TestConstrainedSpaceStopsAnimation) {
TEST_F(AnimatingLayoutManagerRealtimeTest, TestConstrainedSpaceDoesNotRestart) {
constexpr gfx::Insets kChildMargins(5);
constexpr SizeBounds kSizeBounds(45, base::nullopt);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetAnimationDuration(kMinimumAnimationTime);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
@@ -4319,7 +4738,8 @@ TEST_F(AnimatingLayoutManagerRealtimeTest,
TestConstrainedSpaceRestartedAnimationSucceeds) {
constexpr gfx::Insets kChildMargins(5);
constexpr SizeBounds kSizeBounds(45, base::nullopt);
- layout()->SetShouldAnimateBounds(true);
+ layout()->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
layout()->SetAnimationDuration(kMinimumAnimationTime);
auto* const flex_layout =
layout()->SetTargetLayoutManager(std::make_unique<FlexLayout>());
@@ -4392,7 +4812,7 @@ class AnimatingLayoutManagerSequenceTest : public ViewsTestBase {
parent_view_ptr_ = std::make_unique<View>();
parent_view_ptr_->SetLayoutManager(
- std::make_unique<ImmediateLayoutManager>(true));
+ std::make_unique<ImmediateLayoutManager>());
parent_view_ = parent_view_ptr_.get();
layout_view_ptr_ = std::make_unique<View>();
@@ -4416,7 +4836,8 @@ class AnimatingLayoutManagerSequenceTest : public ViewsTestBase {
flex_layout->SetCollapseMargins(true);
flex_layout->SetCrossAxisAlignment(LayoutAlignment::kStart);
flex_layout->SetDefault(kMarginsKey, gfx::Insets(5));
- layout_manager_->SetShouldAnimateBounds(true);
+ layout_manager_->SetBoundsAnimationMode(
+ AnimatingLayoutManager::BoundsAnimationMode::kAnimateBothAxes);
}
void AddViewToParent() {
diff --git a/chromium/ui/views/layout/box_layout.cc b/chromium/ui/views/layout/box_layout.cc
index 255ca1c2f97..6dec3c98612 100644
--- a/chromium/ui/views/layout/box_layout.cc
+++ b/chromium/ui/views/layout/box_layout.cc
@@ -16,14 +16,14 @@ namespace {
// Returns the maximum of the given insets along the given |axis|.
// NOTE: |axis| is different from |orientation_|; it specifies the actual
// desired axis.
-enum Axis { HORIZONTAL_AXIS, VERTICAL_AXIS };
+enum class Axis { kHorizontal, kVertical };
gfx::Insets MaxAxisInsets(Axis axis,
const gfx::Insets& leading1,
const gfx::Insets& leading2,
const gfx::Insets& trailing1,
const gfx::Insets& trailing2) {
- if (axis == HORIZONTAL_AXIS) {
+ if (axis == Axis::kHorizontal) {
return gfx::Insets(0, std::max(leading1.left(), leading2.left()), 0,
std::max(trailing1.right(), trailing2.right()));
}
@@ -201,11 +201,11 @@ void BoxLayout::Layout(View* host) {
gfx::Rect min_child_area(child_area);
gfx::Insets child_margins;
if (collapse_margins_spacing_) {
- child_margins =
- MaxAxisInsets(orientation_ == Orientation::kVertical ? HORIZONTAL_AXIS
- : VERTICAL_AXIS,
- child.margins(), inside_border_insets_, child.margins(),
- inside_border_insets_);
+ child_margins = MaxAxisInsets(orientation_ == Orientation::kVertical
+ ? Axis::kHorizontal
+ : Axis::kVertical,
+ child.margins(), inside_border_insets_,
+ child.margins(), inside_border_insets_);
} else {
child_margins = child.margins();
}
@@ -307,7 +307,7 @@ gfx::Size BoxLayout::GetPreferredSize(const View* host) const {
gfx::Size child_size = child.view()->GetPreferredSize();
gfx::Insets child_margins;
if (collapse_margins_spacing_) {
- child_margins = MaxAxisInsets(HORIZONTAL_AXIS, child.margins(),
+ child_margins = MaxAxisInsets(Axis::kHorizontal, child.margins(),
inside_border_insets_, child.margins(),
inside_border_insets_);
} else {
@@ -474,14 +474,14 @@ gfx::Insets BoxLayout::MainAxisOuterMargin() const {
const ViewWrapper first(this, FirstVisibleView());
const ViewWrapper last(this, LastVisibleView());
return MaxAxisInsets(orientation_ == Orientation::kHorizontal
- ? HORIZONTAL_AXIS
- : VERTICAL_AXIS,
+ ? Axis::kHorizontal
+ : Axis::kVertical,
inside_border_insets_, first.margins(),
inside_border_insets_, last.margins());
}
return MaxAxisInsets(orientation_ == Orientation::kHorizontal
- ? HORIZONTAL_AXIS
- : VERTICAL_AXIS,
+ ? Axis::kHorizontal
+ : Axis::kVertical,
inside_border_insets_, gfx::Insets(),
inside_border_insets_, gfx::Insets());
}
@@ -569,9 +569,9 @@ gfx::Size BoxLayout::GetPreferredSizeForChildWidth(const View* host,
size.height());
gfx::Insets child_margins;
if (collapse_margins_spacing_)
- child_margins =
- MaxAxisInsets(VERTICAL_AXIS, child.margins(), inside_border_insets_,
- child.margins(), inside_border_insets_);
+ child_margins = MaxAxisInsets(Axis::kVertical, child.margins(),
+ inside_border_insets_, child.margins(),
+ inside_border_insets_);
else
child_margins = child.margins();
diff --git a/chromium/ui/views/layout/flex_layout.cc b/chromium/ui/views/layout/flex_layout.cc
index dee1daf861f..18131f8c984 100644
--- a/chromium/ui/views/layout/flex_layout.cc
+++ b/chromium/ui/views/layout/flex_layout.cc
@@ -13,7 +13,8 @@
#include "base/bind.h"
#include "base/callback.h"
-#include "base/logging.h"
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/stringprintf.h"
#include "ui/events/event_target.h"
diff --git a/chromium/ui/views/layout/grid_layout.cc b/chromium/ui/views/layout/grid_layout.cc
index aa028983659..58004fb9ee0 100644
--- a/chromium/ui/views/layout/grid_layout.cc
+++ b/chromium/ui/views/layout/grid_layout.cc
@@ -158,7 +158,7 @@ class Column : public LayoutElement {
Column(GridLayout::Alignment h_align,
GridLayout::Alignment v_align,
float resize_percent,
- GridLayout::SizeType size_type,
+ GridLayout::ColumnSize size_type,
int fixed_width,
int min_width,
bool is_padding)
@@ -194,7 +194,7 @@ class Column : public LayoutElement {
const GridLayout::Alignment h_align_;
const GridLayout::Alignment v_align_;
- const GridLayout::SizeType size_type_;
+ const GridLayout::ColumnSize size_type_;
int same_size_column_;
const int fixed_width_;
const int min_width_;
@@ -216,7 +216,7 @@ class Column : public LayoutElement {
};
void Column::ResetSize() {
- if (size_type_ == GridLayout::FIXED) {
+ if (size_type_ == GridLayout::ColumnSize::kFixed) {
SetSize(fixed_width_);
} else {
SetSize(min_width_);
@@ -249,7 +249,7 @@ void Column::UnifyLinkedColumnSizes(int size_limit) {
}
void Column::AdjustSize(int size) {
- if (size_type_ == GridLayout::USE_PREF)
+ if (size_type_ == GridLayout::ColumnSize::kUsePreferred)
LayoutElement::AdjustSize(size);
}
@@ -382,13 +382,13 @@ ColumnSet::~ColumnSet() = default;
void ColumnSet::AddPaddingColumn(float resize_percent, int width) {
AddColumn(GridLayout::FILL, GridLayout::FILL, resize_percent,
- GridLayout::FIXED, width, width, true);
+ GridLayout::ColumnSize::kFixed, width, width, true);
}
void ColumnSet::AddColumn(GridLayout::Alignment h_align,
GridLayout::Alignment v_align,
float resize_percent,
- GridLayout::SizeType size_type,
+ GridLayout::ColumnSize size_type,
int fixed_width,
int min_width) {
AddColumn(h_align, v_align, resize_percent, size_type, fixed_width, min_width,
@@ -411,7 +411,7 @@ void ColumnSet::LinkColumnSizes(const std::vector<int>& columns) {
void ColumnSet::AddColumn(GridLayout::Alignment h_align,
GridLayout::Alignment v_align,
float resize_percent,
- GridLayout::SizeType size_type,
+ GridLayout::ColumnSize size_type,
int fixed_width,
int min_width,
bool is_padding) {
@@ -533,7 +533,8 @@ void ColumnSet::DistributeRemainingWidth(ViewState* view_state) {
if (columns_[i]->IsResizable()) {
total_resize += columns_[i]->ResizePercent();
resizable_columns++;
- } else if (columns_[i]->size_type_ == GridLayout::USE_PREF) {
+ } else if (columns_[i]->size_type_ ==
+ GridLayout::ColumnSize::kUsePreferred) {
pref_size_columns++;
}
}
@@ -559,7 +560,7 @@ void ColumnSet::DistributeRemainingWidth(ViewState* view_state) {
// that use the preferred size.
int to_distribute = width / pref_size_columns;
for (int i = start_col; i < max_col; ++i) {
- if (columns_[i]->size_type_ == GridLayout::USE_PREF) {
+ if (columns_[i]->size_type_ == GridLayout::ColumnSize::kUsePreferred) {
width -= to_distribute;
if (width < to_distribute)
to_distribute += width;
@@ -740,7 +741,8 @@ void ColumnSet::ResizeUsingMin(int total_delta) {
bool ColumnSet::CanUseMinimum(const ViewState& view_state) const {
const auto resizable = [](const auto& col) {
- return col->ResizePercent() > 0 && col->size_type_ != GridLayout::FIXED;
+ return col->ResizePercent() > 0 &&
+ col->size_type_ != GridLayout::ColumnSize::kFixed;
};
return std::all_of(
columns_.cbegin() + view_state.start_col,
diff --git a/chromium/ui/views/layout/grid_layout.h b/chromium/ui/views/layout/grid_layout.h
index 118431d13d5..5e64d647a62 100644
--- a/chromium/ui/views/layout/grid_layout.h
+++ b/chromium/ui/views/layout/grid_layout.h
@@ -26,12 +26,14 @@
// FILL, // Views starting in this column are vertically
// // resized.
// 1.0, // This column has a resize weight of 1.
-// USE_PREF, // Use the preferred size of the view.
-// 0, // Ignored for USE_PREF.
+// ColumnSize::kUsePreferred, // Use the preferred size of
+// the
+// // view.
+// 0, // Ignored for kUsePref.
// 0); // A minimum width of 0.
// columns->AddPaddingColumn(kFixedSize, // The padding column is not resizable.
// 10); // And has a width of 10 pixels.
-// columns->AddColumn(FILL, FILL, kFixedSize, USE_PREF, 0, 0);
+// columns->AddColumn(FILL, FILL, kFixedSize, ColumnSize::kUsePreferred, 0, 0);
// Now add the views:
// // First start a row.
// layout->StartRow(kFixedSize, // This row isn't vertically resizable.
@@ -104,12 +106,12 @@ class VIEWS_EXPORT GridLayout : public LayoutManager {
};
// An enumeration of the possible ways the size of a column may be obtained.
- enum SizeType {
+ enum class ColumnSize {
// The column size is fixed.
- FIXED,
+ kFixed,
// The preferred size of the view is used to determine the column size.
- USE_PREF
+ kUsePreferred
};
GridLayout();
@@ -129,7 +131,7 @@ class VIEWS_EXPORT GridLayout : public LayoutManager {
// Returns the column set for the specified id, or NULL if one doesn't exist.
ColumnSet* GetColumnSet(int id);
- // Adds a padding row. Padding rows typically don't have any views, and
+ // Adds a padding row. Padding rows typically don't have any views,
// but are used to provide vertical white space between views.
// Size specifies the height of the row.
void AddPaddingRow(float vertical_resize, int size);
@@ -330,7 +332,7 @@ class VIEWS_EXPORT ColumnSet {
void AddColumn(GridLayout::Alignment h_align,
GridLayout::Alignment v_align,
float resize_percent,
- GridLayout::SizeType size_type,
+ GridLayout::ColumnSize size_type,
int fixed_width,
int min_width);
@@ -358,7 +360,7 @@ class VIEWS_EXPORT ColumnSet {
void AddColumn(GridLayout::Alignment h_align,
GridLayout::Alignment v_align,
float resize_percent,
- GridLayout::SizeType size_type,
+ GridLayout::ColumnSize size_type,
int fixed_width,
int min_width,
bool is_padding);
diff --git a/chromium/ui/views/layout/grid_layout_unittest.cc b/chromium/ui/views/layout/grid_layout_unittest.cc
index d93dc7ec67d..76a94e7d169 100644
--- a/chromium/ui/views/layout/grid_layout_unittest.cc
+++ b/chromium/ui/views/layout/grid_layout_unittest.cc
@@ -126,7 +126,8 @@ class GridLayoutAlignmentTest : public testing::Test {
auto v1 = std::make_unique<View>();
v1->SetPreferredSize(gfx::Size(10, 20));
ColumnSet* c1 = layout_->AddColumnSet(0);
- c1->AddColumn(alignment, alignment, 1, GridLayout::USE_PREF, 0, 0);
+ c1->AddColumn(alignment, alignment, 1,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout_->StartRow(1, 0);
auto* v1_ptr = layout_->AddView(std::move(v1));
gfx::Size pref = layout_->GetPreferredSize(host_.get());
@@ -173,9 +174,9 @@ TEST_F(GridLayoutTest, TwoColumns) {
auto v2 = CreateSizedView(gfx::Size(20, 20));
ColumnSet* c1 = layout()->AddColumnSet(0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
auto* v1_ptr = layout()->AddView(std::move(v1));
auto* v2_ptr = layout()->AddView(std::move(v2));
@@ -194,12 +195,12 @@ TEST_F(GridLayoutTest, LinkedSizes) {
ColumnSet* c1 = layout()->AddColumnSet(0);
// Fill widths.
- c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 0, GridLayout::USE_PREF,
- 0, 0);
- c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 0, GridLayout::USE_PREF,
- 0, 0);
- c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 0, GridLayout::USE_PREF,
- 0, 0);
+ c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 0,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
+ c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 0,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
+ c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 0,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
auto* v1 = layout()->AddView(CreateSizedView(gfx::Size(10, 20)));
@@ -257,9 +258,9 @@ TEST_F(GridLayoutTest, LinkedSizes) {
TEST_F(GridLayoutTest, ColSpan1) {
ColumnSet* c1 = layout()->AddColumnSet(0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 1,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
auto* v1 = layout()->AddView(CreateSizedView(gfx::Size(100, 20)), 2, 1);
layout()->StartRow(0, 0);
@@ -277,9 +278,9 @@ TEST_F(GridLayoutTest, ColSpan1) {
TEST_F(GridLayoutTest, ColSpan2) {
ColumnSet* c1 = layout()->AddColumnSet(0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 1,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
auto* v1 = layout()->AddView(CreateSizedView(gfx::Size(100, 20)), 2, 1);
layout()->StartRow(0, 0);
@@ -298,9 +299,9 @@ TEST_F(GridLayoutTest, ColSpan2) {
TEST_F(GridLayoutTest, ColSpan3) {
ColumnSet* c1 = layout()->AddColumnSet(0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
auto* v1 = layout()->AddView(CreateSizedView(gfx::Size(100, 20)), 2, 1);
layout()->StartRow(0, 0);
@@ -321,9 +322,9 @@ TEST_F(GridLayoutTest, ColSpan4) {
ColumnSet* set = layout()->AddColumnSet(0);
set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
auto* v1 = layout()->AddView(CreateSizedView(gfx::Size(10, 10)));
@@ -346,12 +347,12 @@ TEST_F(GridLayoutTest, ColSpan4) {
TEST_F(GridLayoutTest, ColSpanStartSecondColumn) {
ColumnSet* set = layout()->AddColumnSet(0);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, GridLayout::USE_PREF, 0,
- 0);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, GridLayout::USE_PREF, 0,
- 0);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, GridLayout::FIXED, 10,
- 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0,
+ GridLayout::ColumnSize::kFixed, 10, 0);
layout()->StartRow(0, 0);
auto* v1 = layout()->AddView(CreateSizedView(gfx::Size(10, 10)));
@@ -369,9 +370,9 @@ TEST_F(GridLayoutTest, ColSpanStartSecondColumn) {
TEST_F(GridLayoutTest, SameSizeColumns) {
ColumnSet* c1 = layout()->AddColumnSet(0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
c1->LinkColumnSizes({0, 1});
layout()->StartRow(0, 0);
auto* v1 = layout()->AddView(CreateSizedView(gfx::Size(50, 20)));
@@ -388,10 +389,10 @@ TEST_F(GridLayoutTest, SameSizeColumns) {
TEST_F(GridLayoutTest, HorizontalResizeTest1) {
ColumnSet* c1 = layout()->AddColumnSet(0);
- c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 1, GridLayout::USE_PREF,
- 0, 0);
+ c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 1,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
auto* v1 = layout()->AddView(CreateSizedView(gfx::Size(50, 20)));
auto* v2 = layout()->AddView(CreateSizedView(gfx::Size(10, 10)));
@@ -404,10 +405,10 @@ TEST_F(GridLayoutTest, HorizontalResizeTest1) {
TEST_F(GridLayoutTest, HorizontalResizeTest2) {
ColumnSet* c1 = layout()->AddColumnSet(0);
- c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 1, GridLayout::USE_PREF,
- 0, 0);
+ c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 1,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
c1->AddColumn(GridLayout::TRAILING, GridLayout::LEADING, 1,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
auto* v1 = layout()->AddView(CreateSizedView(gfx::Size(50, 20)));
auto* v2 = layout()->AddView(CreateSizedView(gfx::Size(10, 10)));
@@ -422,12 +423,12 @@ TEST_F(GridLayoutTest, HorizontalResizeTest2) {
// resizable column.
TEST_F(GridLayoutTest, HorizontalResizeTest3) {
ColumnSet* c1 = layout()->AddColumnSet(0);
- c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 1, GridLayout::USE_PREF,
- 0, 0);
- c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 1, GridLayout::USE_PREF,
- 0, 0);
+ c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 1,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
+ c1->AddColumn(GridLayout::FILL, GridLayout::LEADING, 1,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
c1->AddColumn(GridLayout::TRAILING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
auto* v1 = layout()->AddView(CreateSizedView(gfx::Size(10, 10)));
auto* v2 = layout()->AddView(CreateSizedView(gfx::Size(10, 10)));
@@ -442,8 +443,8 @@ TEST_F(GridLayoutTest, HorizontalResizeTest3) {
TEST_F(GridLayoutTest, TestVerticalResize1) {
ColumnSet* c1 = layout()->AddColumnSet(0);
- c1->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, GridLayout::USE_PREF, 0,
- 0);
+ c1->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(1, 0);
auto* v1 = layout()->AddView(CreateSizedView(gfx::Size(50, 20)));
layout()->StartRow(0, 0);
@@ -462,7 +463,7 @@ TEST_F(GridLayoutTest, Border) {
host()->SetBorder(CreateEmptyBorder(1, 2, 3, 4));
ColumnSet* c1 = layout()->AddColumnSet(0);
c1->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
auto* v1 = layout()->AddView(CreateSizedView(gfx::Size(10, 20)));
@@ -486,8 +487,8 @@ TEST_F(GridLayoutTest, FixedSize) {
constexpr int kPrefHeight = 20;
for (size_t i = 0; i < kColumnCount; ++i) {
- set->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 0, GridLayout::FIXED,
- kTitleWidth, kTitleWidth);
+ set->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 0,
+ GridLayout::ColumnSize::kFixed, kTitleWidth, kTitleWidth);
}
for (size_t row = 0; row < kRowCount; ++row) {
@@ -515,8 +516,8 @@ TEST_F(GridLayoutTest, FixedSize) {
TEST_F(GridLayoutTest, RowSpanWithPaddingRow) {
ColumnSet* set = layout()->AddColumnSet(0);
- set->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 0, GridLayout::FIXED,
- 10, 10);
+ set->AddColumn(GridLayout::CENTER, GridLayout::CENTER, 0,
+ GridLayout::ColumnSize::kFixed, 10, 10);
layout()->StartRow(0, 0);
layout()->AddView(CreateSizedView(gfx::Size(10, 10)), 1, 2);
@@ -527,9 +528,9 @@ TEST_F(GridLayoutTest, RowSpan) {
ColumnSet* set = layout()->AddColumnSet(0);
set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
layout()->AddView(CreateSizedView(gfx::Size(20, 10)));
@@ -549,9 +550,9 @@ TEST_F(GridLayoutTest, RowSpan2) {
ColumnSet* set = layout()->AddColumnSet(0);
set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
layout()->AddView(CreateSizedView(gfx::Size(20, 20)));
@@ -574,9 +575,9 @@ TEST_F(GridLayoutTest, FixedViewWidth) {
ColumnSet* set = layout()->AddColumnSet(0);
set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
auto* view =
@@ -596,9 +597,9 @@ TEST_F(GridLayoutTest, FixedViewHeight) {
ColumnSet* set = layout()->AddColumnSet(0);
set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
set->AddColumn(GridLayout::LEADING, GridLayout::LEADING, 0,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
auto* view =
@@ -619,10 +620,10 @@ TEST_F(GridLayoutTest, FixedViewHeight) {
TEST_F(GridLayoutTest, ColumnSpanResizing) {
ColumnSet* set = layout()->AddColumnSet(0);
- set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 2, GridLayout::USE_PREF,
- 0, 0);
- set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 4, GridLayout::USE_PREF,
- 0, 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 2,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 4,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
// span_view spans two columns and is twice as big the views added below.
@@ -653,16 +654,16 @@ TEST_F(GridLayoutTest, ColumnSpanResizing) {
// preferred sizes.
TEST_F(GridLayoutTest, ColumnResizingOnGetPreferredSize) {
ColumnSet* set = layout()->AddColumnSet(0);
- set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, GridLayout::USE_PREF,
- 0, 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
set = layout()->AddColumnSet(1);
- set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, GridLayout::USE_PREF,
- 0, 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
set = layout()->AddColumnSet(2);
- set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1, GridLayout::USE_PREF,
- 0, 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::CENTER, 1,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
// Make a row containing a flexible view that trades width for height.
layout()->StartRow(0, 0);
@@ -689,8 +690,8 @@ TEST_F(GridLayoutTest, ColumnResizingOnGetPreferredSize) {
TEST_F(GridLayoutTest, MinimumPreferredSize) {
ColumnSet* set = layout()->AddColumnSet(0);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, GridLayout::USE_PREF, 0,
- 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
layout()->AddView(CreateSizedView(gfx::Size(10, 20)));
@@ -707,8 +708,8 @@ TEST_F(GridLayoutTest, MinimumPreferredSize) {
// structures it uses to calculate Layout, so will give bogus results.
TEST_F(GridLayoutTest, LayoutOnAddDeath) {
ColumnSet* set = layout()->AddColumnSet(0);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0, GridLayout::USE_PREF, 0,
- 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 0,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
auto view = std::make_unique<LayoutOnAddView>();
EXPECT_DCHECK_DEATH(layout()->AddView(std::move(view)));
@@ -725,8 +726,8 @@ TEST_F(GridLayoutTest, ColumnMinForcesPreferredWidth) {
// Column's min width is greater than views preferred/min width. This should
// force the preferred width to the min width of the column.
ColumnSet* set = layout()->AddColumnSet(0);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 5, GridLayout::USE_PREF, 0,
- 100);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 5,
+ GridLayout::ColumnSize::kUsePreferred, 0, 100);
layout()->StartRow(0, 0);
layout()->AddView(CreateSizedView(gfx::Size(20, 10)));
@@ -739,10 +740,10 @@ TEST_F(GridLayoutTest, HonorsColumnMin) {
// Verifies that a column with a min width is never shrunk smaller than the
// minw width.
ColumnSet* set = layout()->AddColumnSet(0);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 5, GridLayout::USE_PREF, 0,
- 100);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 5, GridLayout::USE_PREF, 0,
- 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 5,
+ GridLayout::ColumnSize::kUsePreferred, 0, 100);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 5,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
View* view1 = layout()->AddView(
CreateViewWithMinAndPref(gfx::Size(10, 10), gfx::Size(125, 10)));
@@ -772,10 +773,10 @@ TEST_F(GridLayoutTest, TwoViewsOneSizeSmallerThanMinimum) {
// Two columns, equally resizable with two views. Only the first view is
// resizable.
ColumnSet* set = layout()->AddColumnSet(0);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 5, GridLayout::USE_PREF, 0,
- 0);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 5, GridLayout::USE_PREF, 0,
- 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 5,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 5,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
View* view1 = layout()->AddView(
CreateViewWithMinAndPref(gfx::Size(20, 10), gfx::Size(100, 10)));
@@ -793,10 +794,10 @@ TEST_F(GridLayoutTest, TwoViewsBothSmallerThanMinimumDifferentResizeWeights) {
// Two columns, equally resizable with two views. Only the first view is
// resizable.
ColumnSet* set = layout()->AddColumnSet(0);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 8, GridLayout::USE_PREF, 0,
- 0);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 2, GridLayout::USE_PREF, 0,
- 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 8,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 2,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
View* view1 = layout()->AddView(
CreateViewWithMinAndPref(gfx::Size(91, 10), gfx::Size(100, 10)));
@@ -842,10 +843,10 @@ TEST_F(GridLayoutTest, TwoViewsBothSmallerThanMinimumDifferentResizeWeights) {
TEST_F(GridLayoutTest, TwoViewsOneColumnUsePrefOtherFixed) {
layout()->set_honors_min_width(true);
ColumnSet* set = layout()->AddColumnSet(0);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 8, GridLayout::USE_PREF, 0,
- 0);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 2, GridLayout::FIXED, 100,
- 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 8,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 2,
+ GridLayout::ColumnSize::kFixed, 100, 0);
layout()->StartRow(0, 0);
View* view1 = layout()->AddView(
CreateViewWithMinAndPref(gfx::Size(10, 10), gfx::Size(100, 10)));
@@ -867,10 +868,10 @@ TEST_F(GridLayoutTest, TwoViewsOneColumnUsePrefOtherFixed) {
TEST_F(GridLayoutTest, TwoViewsBothColumnsResizableOneViewFixedWidthMin) {
layout()->set_honors_min_width(true);
ColumnSet* set = layout()->AddColumnSet(0);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, GridLayout::USE_PREF, 0,
- 0);
- set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1, GridLayout::USE_PREF, 0,
- 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
+ set->AddColumn(GridLayout::FILL, GridLayout::FILL, 1,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
View* view1 = layout()->AddView(
CreateViewWithMinAndPref(gfx::Size(10, 10), gfx::Size(100, 10)));
@@ -910,8 +911,8 @@ class SettablePreferredHeightView : public View {
TEST_F(GridLayoutTest, HeightForWidthCalledWhenNotGivenPreferredWidth) {
ColumnSet* set = layout()->AddColumnSet(0);
- set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, GridLayout::USE_PREF,
- 0, 0);
+ set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
layout()->StartRow(0, 0);
const int pref_height = 100;
auto view = std::make_unique<SettablePreferredHeightView>(pref_height);
diff --git a/chromium/ui/views/layout/layout_manager_base.cc b/chromium/ui/views/layout/layout_manager_base.cc
index 13622be1d09..5bc27081215 100644
--- a/chromium/ui/views/layout/layout_manager_base.cc
+++ b/chromium/ui/views/layout/layout_manager_base.cc
@@ -7,7 +7,7 @@
#include <utility>
#include "base/auto_reset.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "ui/views/view.h"
namespace views {
diff --git a/chromium/ui/views/layout/layout_manager_base.h b/chromium/ui/views/layout/layout_manager_base.h
index cec6a2e6366..8812cb5a17b 100644
--- a/chromium/ui/views/layout/layout_manager_base.h
+++ b/chromium/ui/views/layout/layout_manager_base.h
@@ -11,6 +11,7 @@
#include <utility>
#include <vector>
+#include "base/macros.h"
#include "base/optional.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/gfx/geometry/rect.h"
diff --git a/chromium/ui/views/layout/proposed_layout.cc b/chromium/ui/views/layout/proposed_layout.cc
index 6a2373cfcc5..6f8f502647e 100644
--- a/chromium/ui/views/layout/proposed_layout.cc
+++ b/chromium/ui/views/layout/proposed_layout.cc
@@ -5,6 +5,7 @@
#include "ui/views/layout/proposed_layout.h"
#include <map>
+#include <sstream>
#include <string>
#include "ui/gfx/animation/tween.h"
diff --git a/chromium/ui/views/metadata/metadata_cache.cc b/chromium/ui/views/metadata/metadata_cache.cc
index 5a2f10ab864..d37abba27de 100644
--- a/chromium/ui/views/metadata/metadata_cache.cc
+++ b/chromium/ui/views/metadata/metadata_cache.cc
@@ -6,7 +6,7 @@
#include <algorithm>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/no_destructor.h"
#include "ui/views/metadata/metadata_types.h"
diff --git a/chromium/ui/views/metadata/metadata_types.cc b/chromium/ui/views/metadata/metadata_types.cc
index 0dc3a0185fe..ef38d3a8ae3 100644
--- a/chromium/ui/views/metadata/metadata_types.cc
+++ b/chromium/ui/views/metadata/metadata_types.cc
@@ -6,6 +6,8 @@
#include <utility>
+#include "base/check_op.h"
+#include "base/notreached.h"
#include "base/strings/string_util.h"
#include "ui/views/metadata/type_conversion.h"
diff --git a/chromium/ui/views/metadata/type_conversion.cc b/chromium/ui/views/metadata/type_conversion.cc
index 1ca8954dd20..d953161eff3 100644
--- a/chromium/ui/views/metadata/type_conversion.cc
+++ b/chromium/ui/views/metadata/type_conversion.cc
@@ -312,6 +312,8 @@ DEFINE_ENUM_CONVERTERS(ui::TextInputType,
base::ASCIIToUTF16("TEXT_INPUT_TYPE_CONTENT_EDITABLE")},
{ui::TextInputType::TEXT_INPUT_TYPE_DATE_TIME_FIELD,
base::ASCIIToUTF16("TEXT_INPUT_TYPE_DATE_TIME_FIELD")},
+ {ui::TextInputType::TEXT_INPUT_TYPE_NULL,
+ base::ASCIIToUTF16("TEXT_INPUT_TYPE_NULL")},
{ui::TextInputType::TEXT_INPUT_TYPE_MAX,
base::ASCIIToUTF16("TEXT_INPUT_TYPE_MAX")})
diff --git a/chromium/ui/views/native_cursor_aura.cc b/chromium/ui/views/native_cursor_aura.cc
index 2ab60bc5cd1..bd346bba61b 100644
--- a/chromium/ui/views/native_cursor_aura.cc
+++ b/chromium/ui/views/native_cursor_aura.cc
@@ -5,7 +5,7 @@
#include "ui/views/native_cursor.h"
#include "ui/base/cursor/cursor.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
namespace views {
diff --git a/chromium/ui/views/painter.cc b/chromium/ui/views/painter.cc
index 561a6653756..b0ca7de96fc 100644
--- a/chromium/ui/views/painter.cc
+++ b/chromium/ui/views/painter.cc
@@ -6,7 +6,7 @@
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_delegate.h"
#include "ui/compositor/layer_owner.h"
diff --git a/chromium/ui/views/style/typography.cc b/chromium/ui/views/style/typography.cc
index 0fc46aa6489..e269daff59a 100644
--- a/chromium/ui/views/style/typography.cc
+++ b/chromium/ui/views/style/typography.cc
@@ -4,7 +4,7 @@
#include "ui/views/style/typography.h"
-#include "base/logging.h"
+#include "base/check_op.h"
#include "ui/views/layout/layout_provider.h"
#include "ui/views/style/typography_provider.h"
diff --git a/chromium/ui/views/touchui/touch_selection_controller_impl.cc b/chromium/ui/views/touchui/touch_selection_controller_impl.cc
index 92a729807de..a2da9320fb2 100644
--- a/chromium/ui/views/touchui/touch_selection_controller_impl.cc
+++ b/chromium/ui/views/touchui/touch_selection_controller_impl.cc
@@ -7,8 +7,9 @@
#include <set>
#include <utility>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/metrics/histogram_macros.h"
+#include "base/notreached.h"
#include "base/time/time.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/env.h"
@@ -520,6 +521,13 @@ void TouchSelectionControllerImpl::HideHandles(bool quick) {
cursor_handle_->SetWidgetVisible(false, quick);
}
+void TouchSelectionControllerImpl::ShowQuickMenuImmediatelyForTesting() {
+ if (quick_menu_timer_.IsRunning()) {
+ quick_menu_timer_.Stop();
+ QuickMenuTimerFired();
+ }
+}
+
void TouchSelectionControllerImpl::SetDraggingHandle(
EditingHandleView* handle) {
dragging_handle_ = handle;
@@ -636,7 +644,7 @@ void TouchSelectionControllerImpl::OnEvent(const ui::Event& event) {
// from touch as this can clear an active selection generated by the pen.
if ((event.flags() & (ui::EF_IS_SYNTHESIZED | ui::EF_FROM_TOUCH)) ||
event.AsMouseEvent()->pointer_details().pointer_type ==
- ui::EventPointerType::POINTER_TYPE_PEN) {
+ ui::EventPointerType::kPen) {
return;
}
}
diff --git a/chromium/ui/views/touchui/touch_selection_controller_impl.h b/chromium/ui/views/touchui/touch_selection_controller_impl.h
index e748afcdbdd..af43216b179 100644
--- a/chromium/ui/views/touchui/touch_selection_controller_impl.h
+++ b/chromium/ui/views/touchui/touch_selection_controller_impl.h
@@ -21,10 +21,6 @@
namespace views {
class WidgetDelegateView;
-namespace test {
-class WidgetTestInteractive;
-}
-
// Touch specific implementation of TouchEditingControllerDeprecated.
// Responsible for displaying selection handles and menu elements relevant in a
// touch interface.
@@ -45,9 +41,10 @@ class VIEWS_EXPORT TouchSelectionControllerImpl
bool IsHandleDragInProgress() override;
void HideHandles(bool quick) override;
+ void ShowQuickMenuImmediatelyForTesting();
+
private:
friend class TouchSelectionControllerImplTest;
- friend class test::WidgetTestInteractive;
void SetDraggingHandle(EditingHandleView* handle);
diff --git a/chromium/ui/views/touchui/touch_selection_menu_views.cc b/chromium/ui/views/touchui/touch_selection_menu_views.cc
index ca02bef42d8..8b014f1386d 100644
--- a/chromium/ui/views/touchui/touch_selection_menu_views.cc
+++ b/chromium/ui/views/touchui/touch_selection_menu_views.cc
@@ -10,6 +10,7 @@
#include "base/strings/utf_string_conversions.h"
#include "ui/aura/window.h"
#include "ui/base/l10n/l10n_util.h"
+#include "ui/base/pointer/touch_editing_controller.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/gfx/canvas.h"
@@ -25,7 +26,15 @@
namespace views {
namespace {
-constexpr int kMenuCommands[] = {IDS_APP_CUT, IDS_APP_COPY, IDS_APP_PASTE};
+struct MenuCommand {
+ int command_id;
+ int message_id;
+} kMenuCommands[] = {
+ {ui::TouchEditable::kCut, IDS_APP_CUT},
+ {ui::TouchEditable::kCopy, IDS_APP_COPY},
+ {ui::TouchEditable::kPaste, IDS_APP_PASTE},
+};
+
constexpr int kSpacingBetweenButtons = 2;
constexpr int kEllipsesButtonTag = -1;
@@ -95,8 +104,8 @@ bool TouchSelectionMenuViews::IsMenuAvailable(
const ui::TouchSelectionMenuClient* client) {
DCHECK(client);
- const auto is_enabled = [client](int command) {
- return client->IsCommandIdEnabled(command);
+ const auto is_enabled = [client](MenuCommand command) {
+ return client->IsCommandIdEnabled(command.command_id);
};
return std::any_of(std::cbegin(kMenuCommands), std::cend(kMenuCommands),
is_enabled);
@@ -113,12 +122,12 @@ void TouchSelectionMenuViews::CloseMenu() {
TouchSelectionMenuViews::~TouchSelectionMenuViews() = default;
void TouchSelectionMenuViews::CreateButtons() {
- for (int command_id : kMenuCommands) {
- if (!client_->IsCommandIdEnabled(command_id))
+ for (const auto& command : kMenuCommands) {
+ if (!client_->IsCommandIdEnabled(command.command_id))
continue;
- Button* button =
- CreateButton(l10n_util::GetStringUTF16(command_id), command_id);
+ Button* button = CreateButton(l10n_util::GetStringUTF16(command.message_id),
+ command.command_id);
AddChildView(button);
}
diff --git a/chromium/ui/views/vector_icons/linux_shutdown.icon b/chromium/ui/views/vector_icons/linux_shutdown.icon
deleted file mode 100644
index 7feb96f2e3f..00000000000
--- a/chromium/ui/views/vector_icons/linux_shutdown.icon
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2019 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.
-
-CANVAS_DIMENSIONS, 20,
-MOVE_TO, 14.24f, 5.76f,
-R_ARC_TO, 1, 1, 0, 1, 1, 1.41f, -1.41f,
-R_ARC_TO, 8, 8, 0, 1, 1, -11.31f, 0,
-R_ARC_TO, 1, 1, 0, 1, 1, 1.41f, 1.41f,
-R_ARC_TO, 6, 6, 0, 1, 0, 8.49f, 0,
-CLOSE,
-MOVE_TO, 9, 3,
-R_ARC_TO, 1, 1, 0, 0, 1, 2, 0,
-R_V_LINE_TO, 8,
-R_ARC_TO, 1, 1, 0, 1, 1, -2, 0,
-CLOSE
diff --git a/chromium/ui/views/view.cc b/chromium/ui/views/view.cc
index 4cb98c1ee34..00b654c8e4f 100644
--- a/chromium/ui/views/view.cc
+++ b/chromium/ui/views/view.cc
@@ -8,11 +8,12 @@
#include <memory>
#include <utility>
+#include "base/check_op.h"
#include "base/command_line.h"
#include "base/containers/adapters.h"
#include "base/feature_list.h"
-#include "base/logging.h"
#include "base/macros.h"
+#include "base/notreached.h"
#include "base/scoped_observer.h"
#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
@@ -49,6 +50,7 @@
#include "ui/views/border.h"
#include "ui/views/buildflags.h"
#include "ui/views/context_menu_controller.h"
+#include "ui/views/controls/scroll_view.h"
#include "ui/views/drag_controller.h"
#include "ui/views/layout/layout_manager.h"
#include "ui/views/metadata/metadata_impl_macros.h"
@@ -1517,11 +1519,6 @@ void View::ShowContextMenu(const gfx::Point& p,
context_menu_controller_->ShowContextMenuForView(this, p, source_type);
}
-// static
-bool View::ShouldShowContextMenuOnMousePress() {
- return kContextMenuOnMousePress;
-}
-
gfx::Point View::GetKeyboardContextMenuLocation() {
gfx::Rect vis_bounds = GetVisibleBounds();
gfx::Point screen_point(vis_bounds.x() + vis_bounds.width() / 2,
@@ -1800,7 +1797,8 @@ void View::UpdateChildLayerVisibility(bool ancestor_visible) {
layer()->SetVisible(layers_visible);
for (ui::Layer* layer_beneath : layers_beneath_)
layer_beneath->SetVisible(layers_visible);
- } else {
+ }
+ {
internal::ScopedChildrenLock lock(this);
for (auto* child : children_)
child->UpdateChildLayerVisibility(layers_visible);
@@ -1870,6 +1868,11 @@ void View::OnPaintLayer(const ui::PaintContext& context) {
PaintFromPaintRoot(context);
}
+void View::OnLayerTransformed(const gfx::Transform& old_transform,
+ ui::PropertyChangeReason reason) {
+ NotifyAccessibilityEvent(ax::mojom::Event::kLocationChanged, false);
+}
+
void View::OnDeviceScaleFactorChanged(float old_device_scale_factor,
float new_device_scale_factor) {
snap_layer_to_pixel_boundary_ =
@@ -1977,7 +1980,14 @@ void View::OnBlur() {}
void View::Focus() {
OnFocus();
- ScrollViewToVisible();
+
+ // If this is the contents root of a |ScrollView|, focus should bring the
+ // |ScrollView| to visible rather than resetting its content scroll position.
+ ScrollView* scroll_view = ScrollView::GetScrollViewForContents(this);
+ if (scroll_view)
+ scroll_view->ScrollViewToVisible();
+ else
+ ScrollViewToVisible();
for (ViewObserver& observer : observers_)
observer.OnViewFocused(this);
diff --git a/chromium/ui/views/view.h b/chromium/ui/views/view.h
index b1dfe17e2b2..1f4f1eb78fe 100644
--- a/chromium/ui/views/view.h
+++ b/chromium/ui/views/view.h
@@ -1222,10 +1222,6 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
virtual void ShowContextMenu(const gfx::Point& p,
ui::MenuSourceType source_type);
- // On some platforms, we show context menu on mouse press instead of release.
- // This method returns true for those platforms.
- static bool ShouldShowContextMenuOnMousePress();
-
// Returns the location, in screen coordinates, to show the context menu at
// when the context menu is shown from the keyboard. This implementation
// returns the middle of the visible region of this view.
@@ -1503,6 +1499,8 @@ class VIEWS_EXPORT View : public ui::LayerDelegate,
// Overridden from ui::LayerDelegate:
void OnPaintLayer(const ui::PaintContext& context) override;
+ void OnLayerTransformed(const gfx::Transform& old_transform,
+ ui::PropertyChangeReason reason) override;
void OnDeviceScaleFactorChanged(float old_device_scale_factor,
float new_device_scale_factor) override;
diff --git a/chromium/ui/views/view_model.cc b/chromium/ui/views/view_model.cc
index 4768545b6f2..e3ba79f8cc6 100644
--- a/chromium/ui/views/view_model.cc
+++ b/chromium/ui/views/view_model.cc
@@ -6,7 +6,7 @@
#include <stddef.h>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "ui/views/view.h"
namespace views {
diff --git a/chromium/ui/views/view_unittest.cc b/chromium/ui/views/view_unittest.cc
index 16294076ab4..dd69ffe1c53 100644
--- a/chromium/ui/views/view_unittest.cc
+++ b/chromium/ui/views/view_unittest.cc
@@ -379,6 +379,22 @@ TEST_F(ViewTest, OnBoundsChanged) {
EXPECT_EQ(v.bounds(), new_rect);
}
+TEST_F(ViewTest, TransformFiresA11yEvent) {
+ TestView v;
+ v.SetPaintToLayer();
+
+ gfx::Rect bounds(0, 0, 200, 200);
+ v.last_a11y_event_ = ax::mojom::Event::kNone;
+ v.SetBoundsRect(bounds);
+ EXPECT_EQ(v.last_a11y_event_, ax::mojom::Event::kLocationChanged);
+
+ gfx::Transform transform;
+ transform.Translate(gfx::Vector2dF(10, 10));
+ v.last_a11y_event_ = ax::mojom::Event::kNone;
+ v.layer()->SetTransform(transform);
+ EXPECT_EQ(v.last_a11y_event_, ax::mojom::Event::kLocationChanged);
+}
+
////////////////////////////////////////////////////////////////////////////////
// OnStateChanged
////////////////////////////////////////////////////////////////////////////////
@@ -2012,21 +2028,21 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
//
normal->SelectAll(false);
- normal->ExecuteCommand(IDS_APP_CUT, 0);
+ normal->ExecuteCommand(Textfield::kCut, 0);
base::string16 result;
clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &result);
EXPECT_EQ(kNormalText, result);
normal->SetText(kNormalText); // Let's revert to the original content.
read_only->SelectAll(false);
- read_only->ExecuteCommand(IDS_APP_CUT, 0);
+ read_only->ExecuteCommand(Textfield::kCut, 0);
result.clear();
clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &result);
// Cut should have failed, so the clipboard content should not have changed.
EXPECT_EQ(kNormalText, result);
password->SelectAll(false);
- password->ExecuteCommand(IDS_APP_CUT, 0);
+ password->ExecuteCommand(Textfield::kCut, 0);
result.clear();
clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &result);
// Cut should have failed, so the clipboard content should not have changed.
@@ -2038,19 +2054,19 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
// Start with |read_only| to observe a change in clipboard text.
read_only->SelectAll(false);
- read_only->ExecuteCommand(IDS_APP_COPY, 0);
+ read_only->ExecuteCommand(Textfield::kCopy, 0);
result.clear();
clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &result);
EXPECT_EQ(kReadOnlyText, result);
normal->SelectAll(false);
- normal->ExecuteCommand(IDS_APP_COPY, 0);
+ normal->ExecuteCommand(Textfield::kCopy, 0);
result.clear();
clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &result);
EXPECT_EQ(kNormalText, result);
password->SelectAll(false);
- password->ExecuteCommand(IDS_APP_COPY, 0);
+ password->ExecuteCommand(Textfield::kCopy, 0);
result.clear();
clipboard->ReadText(ui::ClipboardBuffer::kCopyPaste, &result);
// Text cannot be copied from an obscured field; the clipboard won't change.
@@ -2062,18 +2078,18 @@ TEST_F(ViewTest, TextfieldCutCopyPaste) {
// Attempting to paste kNormalText in a read-only text-field should fail.
read_only->SelectAll(false);
- read_only->ExecuteCommand(IDS_APP_PASTE, 0);
+ read_only->ExecuteCommand(Textfield::kPaste, 0);
EXPECT_EQ(kReadOnlyText, read_only->GetText());
password->SelectAll(false);
- password->ExecuteCommand(IDS_APP_PASTE, 0);
+ password->ExecuteCommand(Textfield::kPaste, 0);
EXPECT_EQ(kNormalText, password->GetText());
// Copy from |read_only| to observe a change in the normal textfield text.
read_only->SelectAll(false);
- read_only->ExecuteCommand(IDS_APP_COPY, 0);
+ read_only->ExecuteCommand(Textfield::kCopy, 0);
normal->SelectAll(false);
- normal->ExecuteCommand(IDS_APP_PASTE, 0);
+ normal->ExecuteCommand(Textfield::kPaste, 0);
EXPECT_EQ(kReadOnlyText, normal->GetText());
widget->CloseNow();
}
@@ -2224,16 +2240,16 @@ TEST_F(ViewTest, HandleAccelerator) {
EXPECT_EQ(1, view->accelerator_count_map_[return_accelerator]);
// Add a child view associated with a child widget.
- TestView* child_view = new TestView();
- child_view->Reset();
- child_view->AddAccelerator(return_accelerator);
- EXPECT_EQ(child_view->accelerator_count_map_[return_accelerator], 0);
Widget* child_widget = new Widget;
Widget::InitParams child_params =
CreateParams(Widget::InitParams::TYPE_CONTROL);
child_params.parent = widget->GetNativeView();
child_widget->Init(std::move(child_params));
- child_widget->SetContentsView(child_view);
+ TestView* child_view =
+ child_widget->SetContentsView(std::make_unique<TestView>());
+ child_view->Reset();
+ child_view->AddAccelerator(return_accelerator);
+ EXPECT_EQ(child_view->accelerator_count_map_[return_accelerator], 0);
FocusManager* child_focus_manager = child_widget->GetFocusManager();
ASSERT_TRUE(child_focus_manager);
@@ -2526,10 +2542,11 @@ TEST_F(ViewTest, NativeViewHierarchyChanged) {
child_params.parent = toplevel1->GetNativeView();
child->Init(std::move(child_params));
- ToplevelWidgetObserverView* observer_view = new ToplevelWidgetObserverView();
- EXPECT_EQ(nullptr, observer_view->toplevel());
+ auto owning_observer_view = std::make_unique<ToplevelWidgetObserverView>();
+ EXPECT_EQ(nullptr, owning_observer_view->toplevel());
- child->SetContentsView(observer_view);
+ ToplevelWidgetObserverView* observer_view =
+ child->SetContentsView(std::move(owning_observer_view));
EXPECT_EQ(toplevel1.get(), observer_view->toplevel());
Widget::ReparentNativeView(child->GetNativeView(),
@@ -2760,15 +2777,12 @@ TEST_F(ViewTest, TransformVisibleBound) {
widget->Init(std::move(params));
widget->GetRootView()->SetBoundsRect(viewport_bounds);
- View* viewport = new View;
- widget->SetContentsView(viewport);
- View* contents = new View;
- viewport->AddChildView(contents);
+ View* viewport = widget->SetContentsView(std::make_unique<View>());
+ View* contents = viewport->AddChildView(std::make_unique<View>());
viewport->SetBoundsRect(viewport_bounds);
contents->SetBoundsRect(gfx::Rect(0, 0, 100, 200));
- View* child = new View;
- contents->AddChildView(child);
+ View* child = contents->AddChildView(std::make_unique<View>());
child->SetBoundsRect(gfx::Rect(10, 90, 50, 50));
EXPECT_EQ(gfx::Rect(0, 0, 50, 10), child->GetVisibleBounds());
@@ -2817,17 +2831,15 @@ TEST_F(ViewTest, OnVisibleBoundsChanged) {
widget->Init(std::move(params));
widget->GetRootView()->SetBoundsRect(viewport_bounds);
- View* viewport = new View;
- widget->SetContentsView(viewport);
- View* contents = new View;
- viewport->AddChildView(contents);
+ View* viewport = widget->SetContentsView(std::make_unique<View>());
+ View* contents = viewport->AddChildView(std::make_unique<View>());
viewport->SetBoundsRect(viewport_bounds);
contents->SetBoundsRect(gfx::Rect(0, 0, 100, 200));
// Create a view that cares about visible bounds notifications, and position
// it just outside the visible bounds of the viewport.
- VisibleBoundsView* child = new VisibleBoundsView;
- contents->AddChildView(child);
+ VisibleBoundsView* child =
+ contents->AddChildView(std::make_unique<VisibleBoundsView>());
child->SetBoundsRect(gfx::Rect(10, 110, 50, 50));
// The child bound should be fully clipped.
@@ -2919,14 +2931,13 @@ TEST_F(ViewTest, AddAndRemoveSchedulePaints) {
widget->Init(std::move(params));
widget->GetRootView()->SetBoundsRect(viewport_bounds);
- TestView* parent_view = new TestView;
- widget->SetContentsView(parent_view);
+ TestView* parent_view = widget->SetContentsView(std::make_unique<TestView>());
parent_view->SetBoundsRect(viewport_bounds);
parent_view->scheduled_paint_rects_.clear();
- View* child_view = new View;
- child_view->SetBoundsRect(gfx::Rect(0, 0, 20, 20));
- parent_view->AddChildView(child_view);
+ auto owning_child_view = std::make_unique<View>();
+ owning_child_view->SetBoundsRect(gfx::Rect(0, 0, 20, 20));
+ View* child_view = parent_view->AddChildView(std::move(owning_child_view));
ASSERT_EQ(1U, parent_view->scheduled_paint_rects_.size());
EXPECT_EQ(child_view->bounds(), parent_view->scheduled_paint_rects_.front());
@@ -3982,8 +3993,7 @@ TEST_F(ViewLayerTest, LayerToggling) {
// Because we lazily create textures the calls to DrawTree are necessary to
// ensure we trigger creation of textures.
ui::Layer* root_layer = widget()->GetLayer();
- View* content_view = new View;
- widget()->SetContentsView(content_view);
+ View* content_view = widget()->SetContentsView(std::make_unique<View>());
// Create v1, give it a bounds and verify everything is set up correctly.
View* v1 = new View;
@@ -4038,8 +4048,7 @@ TEST_F(ViewLayerTest, LayerToggling) {
// Verifies turning on a layer wires up children correctly.
TEST_F(ViewLayerTest, NestedLayerToggling) {
- View* content_view = new View;
- widget()->SetContentsView(content_view);
+ View* content_view = widget()->SetContentsView(std::make_unique<View>());
// Create v1, give it a bounds and verify everything is set up correctly.
View* v1 = content_view->AddChildView(std::make_unique<View>());
@@ -4063,8 +4072,7 @@ TEST_F(ViewLayerTest, NestedLayerToggling) {
}
TEST_F(ViewLayerTest, LayerAnimator) {
- View* content_view = new View;
- widget()->SetContentsView(content_view);
+ View* content_view = widget()->SetContentsView(std::make_unique<View>());
View* v1 = content_view->AddChildView(std::make_unique<View>());
v1->SetPaintToLayer();
@@ -4083,8 +4091,7 @@ TEST_F(ViewLayerTest, LayerAnimator) {
// Verifies the bounds of a layer are updated if the bounds of ancestor that
// doesn't have a layer change.
TEST_F(ViewLayerTest, BoundsChangeWithLayer) {
- View* content_view = new View;
- widget()->SetContentsView(content_view);
+ View* content_view = widget()->SetContentsView(std::make_unique<View>());
View* v1 = content_view->AddChildView(std::make_unique<View>());
v1->SetBoundsRect(gfx::Rect(20, 30, 140, 150));
@@ -4120,8 +4127,7 @@ TEST_F(ViewLayerTest, BoundsChangeWithLayer) {
// Make sure layers are positioned correctly in RTL.
TEST_F(ViewLayerTest, BoundInRTL) {
base::test::ScopedRestoreICUDefaultLocale scoped_locale_("he");
- View* view = new View;
- widget()->SetContentsView(view);
+ View* view = widget()->SetContentsView(std::make_unique<View>());
int content_width = view->width();
@@ -4171,8 +4177,7 @@ TEST_F(ViewLayerTest, BoundInRTL) {
// Make sure that resizing a parent in RTL correctly repositions its children.
TEST_F(ViewLayerTest, ResizeParentInRTL) {
base::test::ScopedRestoreICUDefaultLocale scoped_locale_("he");
- View* view = new View;
- widget()->SetContentsView(view);
+ View* view = widget()->SetContentsView(std::make_unique<View>());
int content_width = view->width();
@@ -4218,11 +4223,10 @@ TEST_F(ViewLayerTest, ResizeParentInRTL) {
// Makes sure a transform persists after toggling the visibility.
TEST_F(ViewLayerTest, ToggleVisibilityWithTransform) {
- View* view = new View;
+ View* view = widget()->SetContentsView(std::make_unique<View>());
gfx::Transform transform;
transform.Scale(2.0, 2.0);
view->SetTransform(transform);
- widget()->SetContentsView(view);
EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0));
view->SetVisible(false);
@@ -4234,11 +4238,10 @@ TEST_F(ViewLayerTest, ToggleVisibilityWithTransform) {
// Verifies a transform persists after removing/adding a view with a transform.
TEST_F(ViewLayerTest, ResetTransformOnLayerAfterAdd) {
- View* view = new View;
+ View* view = widget()->SetContentsView(std::make_unique<View>());
gfx::Transform transform;
transform.Scale(2.0, 2.0);
view->SetTransform(transform);
- widget()->SetContentsView(view);
EXPECT_EQ(2.0f, view->GetTransform().matrix().get(0, 0));
ASSERT_TRUE(view->layer() != nullptr);
EXPECT_EQ(2.0f, view->layer()->transform().matrix().get(0, 0));
@@ -4254,8 +4257,7 @@ TEST_F(ViewLayerTest, ResetTransformOnLayerAfterAdd) {
// Makes sure that layer visibility is correct after toggling View visibility.
TEST_F(ViewLayerTest, ToggleVisibilityWithLayer) {
- View* content_view = new View;
- widget()->SetContentsView(content_view);
+ View* content_view = widget()->SetContentsView(std::make_unique<View>());
// The view isn't attached to a widget or a parent view yet. But it should
// still have a layer, but the layer should not be attached to the root
@@ -4289,8 +4291,7 @@ TEST_F(ViewLayerTest, ToggleVisibilityWithLayer) {
// Tests that the layers in the subtree are orphaned after a View is removed
// from the parent.
TEST_F(ViewLayerTest, OrphanLayerAfterViewRemove) {
- View* content_view = new View;
- widget()->SetContentsView(content_view);
+ View* content_view = widget()->SetContentsView(std::make_unique<View>());
View* v1 = new View;
content_view->AddChildView(v1);
@@ -4335,8 +4336,8 @@ class PaintTrackingView : public View {
// Makes sure child views with layers aren't painted when paint starts at an
// ancestor.
TEST_F(ViewLayerTest, DontPaintChildrenWithLayers) {
- PaintTrackingView* content_view = new PaintTrackingView;
- widget()->SetContentsView(content_view);
+ PaintTrackingView* content_view =
+ widget()->SetContentsView(std::make_unique<PaintTrackingView>());
content_view->SetPaintToLayer();
GetRootLayer()->GetCompositor()->ScheduleDraw();
ui::DrawWaiterForTest::WaitForCompositingEnded(
@@ -4403,9 +4404,8 @@ TEST_F(ViewLayerTest, NoParentPaintWhenSwitchingPaintToLayerFromTrueToTrue) {
// Tests that the visibility of child layers are updated correctly when a View's
// visibility changes.
TEST_F(ViewLayerTest, VisibilityChildLayers) {
- View* v1 = new View;
+ View* v1 = widget()->SetContentsView(std::make_unique<View>());
v1->SetPaintToLayer();
- widget()->SetContentsView(v1);
View* v2 = v1->AddChildView(std::make_unique<View>());
@@ -4448,9 +4448,8 @@ TEST_F(ViewLayerTest, VisibilityChildLayers) {
// reparents views etc. Unrelated changes can appear to break this test. So
// marking this as FLAKY.
TEST_F(ViewLayerTest, DISABLED_ViewLayerTreesInSync) {
- View* content = new View;
+ View* content = widget()->SetContentsView(std::make_unique<View>());
content->SetPaintToLayer();
- widget()->SetContentsView(content);
widget()->Show();
ConstructTree(content, 5);
@@ -4469,8 +4468,7 @@ TEST_F(ViewLayerTest, DISABLED_ViewLayerTreesInSync) {
// Verifies when views are reordered the layer is also reordered. The widget is
// providing the parent layer.
TEST_F(ViewLayerTest, ReorderUnderWidget) {
- View* content = new View;
- widget()->SetContentsView(content);
+ View* content = widget()->SetContentsView(std::make_unique<View>());
View* c1 = content->AddChildView(std::make_unique<View>());
c1->SetPaintToLayer();
View* c2 = content->AddChildView(std::make_unique<View>());
@@ -4490,8 +4488,7 @@ TEST_F(ViewLayerTest, ReorderUnderWidget) {
// Verifies that the layer of a view can be acquired properly.
TEST_F(ViewLayerTest, AcquireLayer) {
- View* content = new View;
- widget()->SetContentsView(content);
+ View* content = widget()->SetContentsView(std::make_unique<View>());
std::unique_ptr<View> c1(new View);
c1->SetPaintToLayer();
EXPECT_TRUE(c1->layer());
@@ -4537,8 +4534,7 @@ TEST_F(ViewLayerTest, RecreateLayerZOrder) {
// Verify the z-order of the layers as a result of calling RecreateLayer when
// the widget is the parent with the layer.
TEST_F(ViewLayerTest, RecreateLayerZOrderWidgetParent) {
- View* v = new View();
- widget()->SetContentsView(v);
+ View* v = widget()->SetContentsView(std::make_unique<View>());
View* v1 = v->AddChildView(std::make_unique<View>());
v1->SetPaintToLayer();
@@ -4606,12 +4602,10 @@ std::string ToString(const gfx::Vector2dF& vector) {
TEST_F(ViewLayerTest, SnapLayerToPixel) {
viz::ParentLocalSurfaceIdAllocator allocator;
allocator.GenerateId();
- View* v1 = new View;
+ View* v1 = widget()->SetContentsView(std::make_unique<View>());
View* v11 = v1->AddChildView(std::make_unique<View>());
- widget()->SetContentsView(v1);
-
const gfx::Size& size = GetRootLayer()->GetCompositor()->size();
GetRootLayer()->GetCompositor()->SetScaleAndSize(
1.25f, size, allocator.GetCurrentLocalSurfaceIdAllocation());
@@ -4699,8 +4693,7 @@ TEST_F(ViewLayerTest, LayerBeneathAtFractionalScale) {
GetRootLayer()->GetCompositor()->SetScaleAndSize(
device_scale, size, allocator.GetCurrentLocalSurfaceIdAllocation());
- View* view = new View;
- widget()->SetContentsView(view);
+ View* view = widget()->SetContentsView(std::make_unique<View>());
ui::Layer layer;
view->AddLayerBeneathView(&layer);
@@ -4828,6 +4821,31 @@ TEST_F(ViewLayerTest, LayerBeneathTransformed) {
EXPECT_TRUE(layer.transform().IsIdentity());
}
+TEST_F(ViewLayerTest, UpdateChildLayerVisibilityEvenIfLayer) {
+ View root;
+ root.SetPaintToLayer();
+
+ View* view = root.AddChildView(std::make_unique<View>());
+ view->SetPaintToLayer();
+ View* child = view->AddChildView(std::make_unique<View>());
+ child->SetPaintToLayer();
+ EXPECT_TRUE(child->layer()->GetAnimator()->GetTargetVisibility());
+
+ // Makes the view invisible then destroy the layer.
+ view->SetVisible(false);
+ view->DestroyLayer();
+ EXPECT_FALSE(child->layer()->GetAnimator()->GetTargetVisibility());
+
+ view->SetVisible(true);
+ view->SetPaintToLayer();
+ EXPECT_TRUE(child->layer()->GetAnimator()->GetTargetVisibility());
+
+ // Destroys the layer then make the view invisible.
+ view->DestroyLayer();
+ view->SetVisible(false);
+ EXPECT_FALSE(child->layer()->GetAnimator()->GetTargetVisibility());
+}
+
TEST_F(ViewLayerTest, LayerBeneathStackedCorrectly) {
using ui::test::ChildLayerNamesAsString;
@@ -4962,12 +4980,10 @@ class ViewLayerPixelCanvasTest : public ViewLayerTest {
TEST_F(ViewLayerPixelCanvasTest, SnapLayerToPixel) {
viz::ParentLocalSurfaceIdAllocator allocator;
allocator.GenerateId();
- View* v1 = new View;
+ View* v1 = widget()->SetContentsView(std::make_unique<View>());
View* v2 = v1->AddChildView(std::make_unique<View>());
PaintLayerView* v3 = v2->AddChildView(std::make_unique<PaintLayerView>());
- widget()->SetContentsView(v1);
-
const gfx::Size& size = GetRootLayer()->GetCompositor()->size();
GetRootLayer()->GetCompositor()->SetScaleAndSize(
1.6f, size, allocator.GetCurrentLocalSurfaceIdAllocation());
@@ -5034,8 +5050,7 @@ TEST_F(ViewLayerPixelCanvasTest, LayerBeneathOnPixelCanvas) {
GetRootLayer()->GetCompositor()->SetScaleAndSize(
device_scale, size, allocator.GetCurrentLocalSurfaceIdAllocation());
- View* view = new View;
- widget()->SetContentsView(view);
+ View* view = widget()->SetContentsView(std::make_unique<View>());
ui::Layer layer;
view->AddLayerBeneathView(&layer);
diff --git a/chromium/ui/views/views_features.cc b/chromium/ui/views/views_features.cc
index 210657bae32..13bf1c9f0e2 100644
--- a/chromium/ui/views/views_features.cc
+++ b/chromium/ui/views/views_features.cc
@@ -28,5 +28,11 @@ const base::Feature kEnablePlatformHighContrastInkDrop{
const base::Feature kEnableViewPaintOptimization{
"EnableViewPaintOptimization", base::FEATURE_DISABLED_BY_DEFAULT};
+// Change views::Textfield to take focus on a completed tap, rather than
+// immediately on tap down. This only affects touch input. See
+// https://crbug.com/1069634.
+const base::Feature kTextfieldFocusOnTapUp{"TextfieldFocusOnTapUp",
+ base::FEATURE_DISABLED_BY_DEFAULT};
+
} // namespace features
} // namespace views
diff --git a/chromium/ui/views/views_features.h b/chromium/ui/views/views_features.h
index 1daff6da79c..e4340bbb13a 100644
--- a/chromium/ui/views/views_features.h
+++ b/chromium/ui/views/views_features.h
@@ -17,6 +17,7 @@ namespace features {
VIEWS_EXPORT extern const base::Feature kEnableMDRoundedCornersOnDialogs;
VIEWS_EXPORT extern const base::Feature kEnablePlatformHighContrastInkDrop;
VIEWS_EXPORT extern const base::Feature kEnableViewPaintOptimization;
+VIEWS_EXPORT extern const base::Feature kTextfieldFocusOnTapUp;
} // namespace features
} // namespace views
diff --git a/chromium/ui/views/widget/any_widget_observer_unittest.cc b/chromium/ui/views/widget/any_widget_observer_unittest.cc
index 4a1bf692f57..344fd0943bd 100644
--- a/chromium/ui/views/widget/any_widget_observer_unittest.cc
+++ b/chromium/ui/views/widget/any_widget_observer_unittest.cc
@@ -83,7 +83,7 @@ class NamedWidgetShownWaiterTest : public views::test::WidgetTest {
Widget* widget = new Widget;
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
params.native_widget = views::test::CreatePlatformNativeWidgetImpl(
- params, widget, views::test::kStubCapture, nullptr);
+ widget, views::test::kStubCapture, nullptr);
params.name = name;
widget->Init(std::move(params));
return widget;
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc b/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc
index 707f2b4aa33..3ee330f3598 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc
+++ b/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.cc
@@ -18,23 +18,23 @@
#include "ui/aura/client/drag_drop_delegate.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/dragdrop/drop_target_event.h"
#include "ui/base/dragdrop/os_exchange_data.h"
-#include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h"
+#include "ui/base/dragdrop/os_exchange_data_provider_x11.h"
#include "ui/base/layout.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
#include "ui/base/x/selection_utils.h"
#include "ui/base/x/x11_drag_context.h"
#include "ui/base/x/x11_util.h"
+#include "ui/base/x/x11_whole_screen_move_loop.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/x/x11.h"
+#include "ui/platform_window/x11/x11_topmost_window_finder.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
-#include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h"
-#include "ui/views/widget/desktop_aura/x11_whole_screen_move_loop.h"
#include "ui/views/widget/widget.h"
using aura::client::DragDropDelegate;
@@ -171,8 +171,11 @@ int DesktopDragDropClientAuraX11::StartDragAndDrop(
// Windows has a specific method, DoDragDrop(), which performs the entire
// drag. We have to emulate this, so we spin off a nested runloop which will
// track all cursor movement and reroute events to a specific handler.
- move_loop_->RunMoveLoop(source_window, cursor_manager_->GetInitializedCursor(
- ui::mojom::CursorType::kGrabbing));
+ move_loop_->RunMoveLoop(
+ !source_window->HasCapture(),
+ source_window->GetHost()->last_cursor().platform(),
+ cursor_manager_->GetInitializedCursor(ui::mojom::CursorType::kGrabbing)
+ .platform());
if (alive) {
auto resulting_operation = negotiated_operation();
@@ -248,9 +251,9 @@ void DesktopDragDropClientAuraX11::OnMoveLoopEnded() {
XDragDropClient::HandleMoveLoopEnded();
}
-std::unique_ptr<X11MoveLoop> DesktopDragDropClientAuraX11::CreateMoveLoop(
+std::unique_ptr<ui::X11MoveLoop> DesktopDragDropClientAuraX11::CreateMoveLoop(
X11MoveLoopDelegate* delegate) {
- return base::WrapUnique(new X11WholeScreenMoveLoop(this));
+ return base::WrapUnique(new ui::X11WholeScreenMoveLoop(this));
}
void DesktopDragDropClientAuraX11::DragTranslate(
@@ -280,7 +283,7 @@ void DesktopDragDropClientAuraX11::DragTranslate(
DCHECK(target_current_context());
*data = std::make_unique<OSExchangeData>(
- std::make_unique<ui::OSExchangeDataProviderAuraX11>(
+ std::make_unique<ui::OSExchangeDataProviderX11>(
xwindow(), target_current_context()->fetched_targets()));
gfx::Point location = root_location;
aura::Window::ConvertPointToTarget(root_window_, target_window_, &location);
@@ -326,7 +329,7 @@ void DesktopDragDropClientAuraX11::NotifyDragLeave() {
std::unique_ptr<ui::XTopmostWindowFinder>
DesktopDragDropClientAuraX11::CreateWindowFinder() {
- return std::make_unique<X11TopmostWindowFinder>();
+ return std::make_unique<ui::X11TopmostWindowFinder>();
}
int DesktopDragDropClientAuraX11::UpdateDrag(const gfx::Point& screen_point) {
@@ -362,7 +365,8 @@ void DesktopDragDropClientAuraX11::UpdateCursor(
cursor_type = ui::mojom::CursorType::kDndLink;
break;
}
- move_loop_->UpdateCursor(cursor_manager_->GetInitializedCursor(cursor_type));
+ move_loop_->UpdateCursor(
+ cursor_manager_->GetInitializedCursor(cursor_type).platform());
}
void DesktopDragDropClientAuraX11::OnBeginForeignDrag(XID window) {
@@ -394,7 +398,7 @@ int DesktopDragDropClientAuraX11::PerformDrop() {
aura::client::GetDragDropDelegate(target_window_);
if (delegate) {
auto data(std::make_unique<ui::OSExchangeData>(
- std::make_unique<ui::OSExchangeDataProviderAuraX11>(
+ std::make_unique<ui::OSExchangeDataProviderX11>(
xwindow(), target_current_context()->fetched_targets())));
ui::DropTargetEvent drop_event(
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h b/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h
index 7ae53151b9e..a06220b1864 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h
+++ b/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h
@@ -16,6 +16,7 @@
#include "ui/base/cursor/cursor.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/x/x11_drag_drop_client.h"
+#include "ui/base/x/x11_move_loop_delegate.h"
#include "ui/events/event_constants.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/events/x/x11_window_event_manager.h"
@@ -23,7 +24,6 @@
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/x/x11.h"
#include "ui/views/views_export.h"
-#include "ui/views/widget/desktop_aura/x11_move_loop_delegate.h"
namespace aura {
namespace client {
@@ -40,12 +40,12 @@ namespace ui {
class DropTargetEvent;
class OSExchangeData;
class XTopmostWindowFinder;
+class X11MoveLoop;
} // namespace ui
namespace views {
class DesktopNativeCursorManager;
class Widget;
-class X11MoveLoop;
// Implements drag and drop on X11 for aura. On one side, this class takes raw
// X11 events forwarded from DesktopWindowTreeHostLinux, while on the other, it
@@ -56,7 +56,7 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
public aura::client::DragDropClient,
public ui::XEventDispatcher,
public aura::WindowObserver,
- public X11MoveLoopDelegate {
+ public ui::X11MoveLoopDelegate {
public:
DesktopDragDropClientAuraX11(
aura::Window* root_window,
@@ -85,7 +85,7 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
// aura::WindowObserver:
void OnWindowDestroyed(aura::Window* window) override;
- // X11MoveLoopDelegate:
+ // ui::X11MoveLoopDelegate:
void OnMouseMovement(const gfx::Point& screen_point,
int flags,
base::TimeTicks event_time) override;
@@ -97,7 +97,7 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
Widget* drag_widget() { return drag_widget_.get(); }
// Creates a move loop. Virtual for testing.
- virtual std::unique_ptr<X11MoveLoop> CreateMoveLoop(
+ virtual std::unique_ptr<ui::X11MoveLoop> CreateMoveLoop(
X11MoveLoopDelegate* delegate);
private:
@@ -125,8 +125,8 @@ class VIEWS_EXPORT DesktopDragDropClientAuraX11
void EndMoveLoop() override;
// A nested run loop that notifies this object of events through the
- // X11MoveLoopDelegate interface.
- std::unique_ptr<X11MoveLoop> move_loop_;
+ // ui::X11MoveLoopDelegate interface.
+ std::unique_ptr<ui::X11MoveLoop> move_loop_;
aura::Window* root_window_;
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc b/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc
index b188e6c9a40..68c1ba2c47d 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc
+++ b/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11_unittest.cc
@@ -20,6 +20,7 @@
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/dragdrop/os_exchange_data.h"
+#include "ui/base/x/x11_move_loop.h"
#include "ui/base/x/x11_util.h"
#include "ui/events/event_utils.h"
#include "ui/gfx/x/x11.h"
@@ -29,7 +30,6 @@
#include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h"
#include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
-#include "ui/views/widget/desktop_aura/x11_move_loop.h"
#include "ui/views/widget/widget.h"
namespace views {
@@ -66,24 +66,26 @@ class ClientMessageEventCollector {
DISALLOW_COPY_AND_ASSIGN(ClientMessageEventCollector);
};
-// An implementation of X11MoveLoop where RunMoveLoop() always starts the move
-// loop.
-class TestMoveLoop : public X11MoveLoop {
+// An implementation of ui::X11MoveLoop where RunMoveLoop() always starts the
+// move loop.
+class TestMoveLoop : public ui::X11MoveLoop {
public:
- explicit TestMoveLoop(X11MoveLoopDelegate* delegate);
+ explicit TestMoveLoop(ui::X11MoveLoopDelegate* delegate);
~TestMoveLoop() override;
// Returns true if the move loop is running.
bool IsRunning() const;
- // X11MoveLoop:
- bool RunMoveLoop(aura::Window* window, gfx::NativeCursor cursor) override;
- void UpdateCursor(gfx::NativeCursor cursor) override;
+ // ui::X11MoveLoop:
+ bool RunMoveLoop(bool can_grab_pointer,
+ ::Cursor old_cursor,
+ ::Cursor new_cursor) override;
+ void UpdateCursor(::Cursor cursor) override;
void EndMoveLoop() override;
private:
// Not owned.
- X11MoveLoopDelegate* delegate_;
+ ui::X11MoveLoopDelegate* delegate_;
// Ends the move loop.
base::OnceClosure quit_closure_;
@@ -109,8 +111,8 @@ class SimpleTestDragDropClient : public DesktopDragDropClientAuraX11 {
private:
// DesktopDragDropClientAuraX11:
- std::unique_ptr<X11MoveLoop> CreateMoveLoop(
- X11MoveLoopDelegate* delegate) override;
+ std::unique_ptr<ui::X11MoveLoop> CreateMoveLoop(
+ ui::X11MoveLoopDelegate* delegate) override;
XID FindWindowFor(const gfx::Point& screen_point) override;
// The XID of the window which is simulated to be the topmost window.
@@ -207,7 +209,7 @@ void ClientMessageEventCollector::RecordEvent(
///////////////////////////////////////////////////////////////////////////////
// TestMoveLoop
-TestMoveLoop::TestMoveLoop(X11MoveLoopDelegate* delegate)
+TestMoveLoop::TestMoveLoop(ui::X11MoveLoopDelegate* delegate)
: delegate_(delegate) {}
TestMoveLoop::~TestMoveLoop() = default;
@@ -216,7 +218,9 @@ bool TestMoveLoop::IsRunning() const {
return is_running_;
}
-bool TestMoveLoop::RunMoveLoop(aura::Window* window, gfx::NativeCursor cursor) {
+bool TestMoveLoop::RunMoveLoop(bool can_grab_pointer,
+ ::Cursor old_cursor,
+ ::Cursor new_cursor) {
is_running_ = true;
base::RunLoop run_loop;
quit_closure_ = run_loop.QuitClosure();
@@ -224,7 +228,7 @@ bool TestMoveLoop::RunMoveLoop(aura::Window* window, gfx::NativeCursor cursor) {
return true;
}
-void TestMoveLoop::UpdateCursor(gfx::NativeCursor cursor) {}
+void TestMoveLoop::UpdateCursor(::Cursor cursor) {}
void TestMoveLoop::EndMoveLoop() {
if (is_running_) {
@@ -255,8 +259,8 @@ bool SimpleTestDragDropClient::IsMoveLoopRunning() {
return loop_->IsRunning();
}
-std::unique_ptr<X11MoveLoop> SimpleTestDragDropClient::CreateMoveLoop(
- X11MoveLoopDelegate* delegate) {
+std::unique_ptr<ui::X11MoveLoop> SimpleTestDragDropClient::CreateMoveLoop(
+ ui::X11MoveLoopDelegate* delegate) {
loop_ = new TestMoveLoop(delegate);
return base::WrapUnique(loop_);
}
@@ -306,7 +310,7 @@ void TestDragDropClient::OnStatus(XID target_window,
event.data.l[2] = 0;
event.data.l[3] = 0;
event.data.l[4] = accepted_action;
- OnXdndStatus(event);
+ HandleXdndEvent(event);
}
void TestDragDropClient::OnFinished(XID target_window,
@@ -321,7 +325,7 @@ void TestDragDropClient::OnFinished(XID target_window,
event.data.l[2] = performed_action;
event.data.l[3] = 0;
event.data.l[4] = 0;
- OnXdndFinished(event);
+ HandleXdndEvent(event);
}
void TestDragDropClient::SetTopmostXWindowAndMoveMouse(::Window xid) {
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_ozone.cc b/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_ozone.cc
index 1ed740d20ce..24a959b321d 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_ozone.cc
+++ b/chromium/ui/views/widget/desktop_aura/desktop_drag_drop_client_ozone.cc
@@ -18,10 +18,10 @@
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/clipboard/clipboard.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/dragdrop/drag_drop_types.h"
#include "ui/base/dragdrop/drop_target_event.h"
#include "ui/base/dragdrop/os_exchange_data_provider_aura.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
#include "ui/platform_window/platform_window_delegate.h"
#include "ui/platform_window/platform_window_handler/wm_drag_handler.h"
#include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
@@ -239,6 +239,7 @@ void DesktopDragDropClientOzone::PerformDrop() {
drag_operation_ = drag_drop_delegate_->OnPerformDrop(
*event, std::move(os_exchange_data_));
DragDropSessionCompleted();
+ ResetDragDropTarget();
}
} // namespace views
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc b/chromium/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc
index 478b16bc606..ab7213a3889 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc
+++ b/chromium/ui/views/widget/desktop_aura/desktop_native_cursor_manager.cc
@@ -6,10 +6,11 @@
#include <utility>
+#include "base/trace_event/trace_event.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/cursor/cursor_loader.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
namespace views {
@@ -59,6 +60,8 @@ void DesktopNativeCursorManager::SetCursor(
void DesktopNativeCursorManager::SetVisibility(
bool visible,
wm::NativeCursorManagerDelegate* delegate) {
+ TRACE_EVENT1("ui,input", "DesktopNativeCursorManager::SetVisibility",
+ "visible", visible);
delegate->CommitVisibility(visible);
if (visible) {
@@ -83,6 +86,7 @@ void DesktopNativeCursorManager::SetCursorSize(
void DesktopNativeCursorManager::SetMouseEventsEnabled(
bool enabled,
wm::NativeCursorManagerDelegate* delegate) {
+ TRACE_EVENT0("ui,input", "DesktopNativeCursorManager::SetMouseEventsEnabled");
delegate->CommitMouseEventsEnabled(enabled);
// TODO(erg): In the ash version, we set the last mouse location on Env. I'm
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h b/chromium/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h
index fdb5d86b797..d926393dd7f 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h
+++ b/chromium/ui/views/widget/desktop_aura/desktop_native_cursor_manager.h
@@ -10,7 +10,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
-#include "ui/base/mojom/cursor_type.mojom-forward.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-forward.h"
#include "ui/views/views_export.h"
#include "ui/wm/core/native_cursor_manager.h"
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc b/chromium/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc
index a28f778d4a5..71e7bbc378b 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc
+++ b/chromium/ui/views/widget/desktop_aura/desktop_native_widget_aura_unittest.cc
@@ -22,7 +22,7 @@
#include "ui/aura/test/window_occlusion_tracker_test_api.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/display/screen.h"
#include "ui/events/event_processor.h"
#include "ui/events/event_utils.h"
@@ -286,8 +286,8 @@ std::unique_ptr<Widget> CreateAndShowControlWidget(aura::Window* parent) {
Widget::InitParams params(Widget::InitParams::TYPE_CONTROL);
params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params.parent = parent;
- params.native_widget = CreatePlatformNativeWidgetImpl(params, widget.get(),
- kStubCapture, nullptr);
+ params.native_widget =
+ CreatePlatformNativeWidgetImpl(widget.get(), kStubCapture, nullptr);
widget->Init(std::move(params));
widget->Show();
return widget;
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_screen_ozone.cc b/chromium/ui/views/widget/desktop_aura/desktop_screen_ozone.cc
index a8d86fd87fc..6f9d29fbcbb 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_screen_ozone.cc
+++ b/chromium/ui/views/widget/desktop_aura/desktop_screen_ozone.cc
@@ -2,13 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ui/views/widget/desktop_aura/desktop_screen_ozone.h"
+
#include "ui/aura/screen_ozone.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
+#include "ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h"
namespace views {
+DesktopScreenOzone::DesktopScreenOzone() = default;
+
+DesktopScreenOzone::~DesktopScreenOzone() = default;
+
+gfx::NativeWindow DesktopScreenOzone::GetNativeWindowFromAcceleratedWidget(
+ gfx::AcceleratedWidget widget) const {
+ if (!widget)
+ return nullptr;
+ return views::DesktopWindowTreeHostPlatform::GetContentWindowForWidget(
+ widget);
+}
+
display::Screen* CreateDesktopScreen() {
- return new aura::ScreenOzone();
+ return new DesktopScreenOzone();
}
} // namespace views
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_screen_ozone.h b/chromium/ui/views/widget/desktop_aura/desktop_screen_ozone.h
new file mode 100644
index 00000000000..e45fe4c9df0
--- /dev/null
+++ b/chromium/ui/views/widget/desktop_aura/desktop_screen_ozone.h
@@ -0,0 +1,28 @@
+// Copyright 2020 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 UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_SCREEN_OZONE_H_
+#define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_SCREEN_OZONE_H_
+
+#include "ui/aura/screen_ozone.h"
+#include "ui/views/views_export.h"
+
+namespace views {
+
+class VIEWS_EXPORT DesktopScreenOzone : public aura::ScreenOzone {
+ public:
+ DesktopScreenOzone();
+ DesktopScreenOzone(const DesktopScreenOzone&) = delete;
+ DesktopScreenOzone& operator=(const DesktopScreenOzone&) = delete;
+ ~DesktopScreenOzone() override;
+
+ private:
+ // ui::aura::ScreenOzone:
+ gfx::NativeWindow GetNativeWindowFromAcceleratedWidget(
+ gfx::AcceleratedWidget widget) const override;
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_SCREEN_OZONE_H_
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_screen_win.cc b/chromium/ui/views/widget/desktop_aura/desktop_screen_win.cc
index 70553b153c4..963e7053e7a 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_screen_win.cc
+++ b/chromium/ui/views/widget/desktop_aura/desktop_screen_win.cc
@@ -4,40 +4,26 @@
#include "ui/views/widget/desktop_aura/desktop_screen_win.h"
-#include "base/logging.h"
#include "ui/aura/window.h"
-#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host.h"
-#include "ui/display/display.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
namespace views {
-////////////////////////////////////////////////////////////////////////////////
-// DesktopScreenWin, public:
-
DesktopScreenWin::DesktopScreenWin() = default;
DesktopScreenWin::~DesktopScreenWin() = default;
-////////////////////////////////////////////////////////////////////////////////
-// DesktopScreenWin, display::win::ScreenWin implementation:
-
-display::Display DesktopScreenWin::GetDisplayMatching(
- const gfx::Rect& match_rect) const {
- return GetDisplayNearestPoint(match_rect.CenterPoint());
-}
-
-HWND DesktopScreenWin::GetHWNDFromNativeView(gfx::NativeView window) const {
+HWND DesktopScreenWin::GetHWNDFromNativeWindow(gfx::NativeWindow window) const {
aura::WindowTreeHost* host = window->GetHost();
return host ? host->GetAcceleratedWidget() : nullptr;
}
gfx::NativeWindow DesktopScreenWin::GetNativeWindowFromHWND(HWND hwnd) const {
- return (::IsWindow(hwnd))
+ return ::IsWindow(hwnd)
? DesktopWindowTreeHostWin::GetContentWindowForHWND(hwnd)
- : nullptr;
+ : gfx::kNullNativeWindow;
}
////////////////////////////////////////////////////////////////////////////////
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_screen_win.h b/chromium/ui/views/widget/desktop_aura/desktop_screen_win.h
index e17fe7611d7..97442c424d8 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_screen_win.h
+++ b/chromium/ui/views/widget/desktop_aura/desktop_screen_win.h
@@ -5,7 +5,6 @@
#ifndef UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_SCREEN_WIN_H_
#define UI_VIEWS_WIDGET_DESKTOP_AURA_DESKTOP_SCREEN_WIN_H_
-#include "base/macros.h"
#include "ui/display/win/screen_win.h"
#include "ui/views/views_export.h"
@@ -14,16 +13,14 @@ namespace views {
class VIEWS_EXPORT DesktopScreenWin : public display::win::ScreenWin {
public:
DesktopScreenWin();
+ DesktopScreenWin(const DesktopScreenWin&) = delete;
+ DesktopScreenWin& operator=(const DesktopScreenWin&) = delete;
~DesktopScreenWin() override;
private:
- // Overridden from display::win::ScreenWin:
- display::Display GetDisplayMatching(
- const gfx::Rect& match_rect) const override;
- HWND GetHWNDFromNativeView(gfx::NativeView window) const override;
+ // display::win::ScreenWin:
+ HWND GetHWNDFromNativeWindow(gfx::NativeWindow window) const override;
gfx::NativeWindow GetNativeWindowFromHWND(HWND hwnd) const override;
-
- DISALLOW_COPY_AND_ASSIGN(DesktopScreenWin);
};
} // namespace views
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_screen_x11.cc b/chromium/ui/views/widget/desktop_aura/desktop_screen_x11.cc
index 0ffdc450043..4f4a5d1c395 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_screen_x11.cc
+++ b/chromium/ui/views/widget/desktop_aura/desktop_screen_x11.cc
@@ -21,9 +21,9 @@
#include "ui/gfx/geometry/dip_util.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/switches.h"
+#include "ui/platform_window/x11/x11_topmost_window_finder.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
-#include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h"
namespace views {
@@ -60,8 +60,29 @@ bool DesktopScreenX11::IsWindowUnderCursor(gfx::NativeWindow window) {
gfx::NativeWindow DesktopScreenX11::GetWindowAtScreenPoint(
const gfx::Point& point) {
- return X11TopmostWindowFinder().FindLocalProcessWindowAt(
- gfx::ConvertPointToPixel(GetXDisplayScaleFactor(), point), {});
+ auto accelerated_widget =
+ ui::X11TopmostWindowFinder().FindLocalProcessWindowAt(
+ gfx::ConvertPointToPixel(GetXDisplayScaleFactor(), point), {});
+ return accelerated_widget
+ ? views::DesktopWindowTreeHostPlatform::GetContentWindowForWidget(
+ static_cast<gfx::AcceleratedWidget>(accelerated_widget))
+ : nullptr;
+}
+
+gfx::NativeWindow DesktopScreenX11::GetLocalProcessWindowAtPoint(
+ const gfx::Point& point,
+ const std::set<gfx::NativeWindow>& ignore) {
+ std::set<gfx::AcceleratedWidget> ignore_widgets;
+ for (auto* const window : ignore)
+ ignore_widgets.emplace(window->GetHost()->GetAcceleratedWidget());
+ auto accelerated_widget =
+ ui::X11TopmostWindowFinder().FindLocalProcessWindowAt(
+ gfx::ConvertPointToPixel(GetXDisplayScaleFactor(), point),
+ ignore_widgets);
+ return accelerated_widget
+ ? views::DesktopWindowTreeHostPlatform::GetContentWindowForWidget(
+ static_cast<gfx::AcceleratedWidget>(accelerated_widget))
+ : nullptr;
}
int DesktopScreenX11::GetNumDisplays() const {
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_screen_x11.h b/chromium/ui/views/widget/desktop_aura/desktop_screen_x11.h
index dcf3e0f725e..b391f41caf2 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_screen_x11.h
+++ b/chromium/ui/views/widget/desktop_aura/desktop_screen_x11.h
@@ -40,6 +40,9 @@ class VIEWS_EXPORT DesktopScreenX11 : public display::Screen,
gfx::Point GetCursorScreenPoint() override;
bool IsWindowUnderCursor(gfx::NativeWindow window) override;
gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override;
+ gfx::NativeWindow GetLocalProcessWindowAtPoint(
+ const gfx::Point& point,
+ const std::set<gfx::NativeWindow>& ignore) override;
int GetNumDisplays() const override;
const std::vector<display::Display>& GetAllDisplays() const override;
display::Display GetDisplayNearestWindow(
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_linux.cc b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_linux.cc
index 91cfaf77bb3..4168fa1a51f 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_linux.cc
+++ b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_linux.cc
@@ -29,17 +29,11 @@
#include "ui/accessibility/platform/atk_util_auralinux.h"
#endif
-DEFINE_UI_CLASS_PROPERTY_TYPE(views::DesktopWindowTreeHostLinux*)
-
namespace views {
std::list<gfx::AcceleratedWidget>* DesktopWindowTreeHostLinux::open_windows_ =
nullptr;
-DEFINE_UI_CLASS_PROPERTY_KEY(DesktopWindowTreeHostLinux*,
- kHostForRootWindow,
- nullptr)
-
namespace {
class SwapWithNewSizeObserverHelper : public ui::CompositorObserver {
@@ -82,30 +76,13 @@ DesktopWindowTreeHostLinux::DesktopWindowTreeHostLinux(
: DesktopWindowTreeHostPlatform(native_widget_delegate,
desktop_native_widget_aura) {}
-DesktopWindowTreeHostLinux::~DesktopWindowTreeHostLinux() {
- window()->ClearProperty(kHostForRootWindow);
-}
-
-// static
-aura::Window* DesktopWindowTreeHostLinux::GetContentWindowForWidget(
- gfx::AcceleratedWidget widget) {
- auto* host = DesktopWindowTreeHostLinux::GetHostForWidget(widget);
- return host ? host->GetContentWindow() : nullptr;
-}
-
-// static
-DesktopWindowTreeHostLinux* DesktopWindowTreeHostLinux::GetHostForWidget(
- gfx::AcceleratedWidget widget) {
- aura::WindowTreeHost* host =
- aura::WindowTreeHost::GetForAcceleratedWidget(widget);
- return host ? host->window()->GetProperty(kHostForRootWindow) : nullptr;
-}
+DesktopWindowTreeHostLinux::~DesktopWindowTreeHostLinux() = default;
// static
std::vector<aura::Window*> DesktopWindowTreeHostLinux::GetAllOpenWindows() {
std::vector<aura::Window*> windows(open_windows().size());
std::transform(open_windows().begin(), open_windows().end(), windows.begin(),
- GetContentWindowForWidget);
+ DesktopWindowTreeHostPlatform::GetContentWindowForWidget);
return windows;
}
@@ -116,7 +93,7 @@ void DesktopWindowTreeHostLinux::CleanUpWindowList(
return;
while (!open_windows_->empty()) {
gfx::AcceleratedWidget widget = open_windows_->front();
- func(GetContentWindowForWidget(widget));
+ func(DesktopWindowTreeHostPlatform::GetContentWindowForWidget(widget));
if (!open_windows_->empty() && open_windows_->front() == widget)
open_windows_->erase(open_windows_->begin());
}
@@ -175,8 +152,6 @@ void DesktopWindowTreeHostLinux::Init(const Widget::InitParams& params) {
void DesktopWindowTreeHostLinux::OnNativeWidgetCreated(
const Widget::InitParams& params) {
- window()->SetProperty(kHostForRootWindow, this);
-
CreateNonClientEventFilter();
DesktopWindowTreeHostPlatform::OnNativeWidgetCreated(params);
}
@@ -200,6 +175,15 @@ void DesktopWindowTreeHostLinux::InitModalType(ui::ModalType modal_type) {
}
}
+Widget::MoveLoopResult DesktopWindowTreeHostLinux::RunMoveLoop(
+ const gfx::Vector2d& drag_offset,
+ Widget::MoveLoopSource source,
+ Widget::MoveLoopEscapeBehavior escape_behavior) {
+ GetContentWindow()->SetCapture();
+ return DesktopWindowTreeHostPlatform::RunMoveLoop(drag_offset, source,
+ escape_behavior);
+}
+
void DesktopWindowTreeHostLinux::OnDisplayMetricsChanged(
const display::Display& display,
uint32_t changed_metrics) {
@@ -310,7 +294,7 @@ bool DesktopWindowTreeHostLinux::OnAtkKeyEvent(AtkKeyEventStruct* atk_event) {
}
#endif
-bool DesktopWindowTreeHostLinux::IsOverrideRedirect() const {
+bool DesktopWindowTreeHostLinux::IsOverrideRedirect(bool is_tiling_wm) const {
// BrowserDesktopWindowTreeHostLinux implements this for browser windows.
return false;
}
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h
index 1351c2a66c4..79bef5fe949 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h
+++ b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h
@@ -43,14 +43,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostLinux
DesktopNativeWidgetAura* desktop_native_widget_aura);
~DesktopWindowTreeHostLinux() override;
- // A way of converting a |widget| into the content_window()
- // of the associated DesktopNativeWidgetAura.
- static aura::Window* GetContentWindowForWidget(gfx::AcceleratedWidget widget);
-
- // A way of converting a |widget| into this object.
- static DesktopWindowTreeHostLinux* GetHostForWidget(
- gfx::AcceleratedWidget widget);
-
// Get all open top-level windows. This includes windows that may not be
// visible. This list is sorted in their stacking order, i.e. the first window
// is the topmost window.
@@ -82,6 +74,10 @@ class VIEWS_EXPORT DesktopWindowTreeHostLinux
void OnNativeWidgetCreated(const Widget::InitParams& params) override;
base::flat_map<std::string, std::string> GetKeyboardLayoutMap() override;
void InitModalType(ui::ModalType modal_type) override;
+ Widget::MoveLoopResult RunMoveLoop(
+ const gfx::Vector2d& drag_offset,
+ Widget::MoveLoopSource source,
+ Widget::MoveLoopEscapeBehavior escape_behavior) override;
// PlatformWindowDelegate:
void DispatchEvent(ui::Event* event) override;
@@ -117,7 +113,7 @@ class VIEWS_EXPORT DesktopWindowTreeHostLinux
#if BUILDFLAG(USE_ATK)
bool OnAtkKeyEvent(AtkKeyEventStruct* atk_key_event) override;
#endif
- bool IsOverrideRedirect() const override;
+ bool IsOverrideRedirect(bool is_tiling_wm) const override;
// Enables event listening after closing |dialog|.
void EnableEventListening();
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_linux_interactive_uitest.cc b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_linux_interactive_uitest.cc
index 0b2ab7e4538..cb61f3c0b4d 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_linux_interactive_uitest.cc
+++ b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_linux_interactive_uitest.cc
@@ -9,7 +9,7 @@
#include "ui/base/hit_test.h"
#include "ui/platform_window/platform_window.h"
#include "ui/platform_window/platform_window_handler/wm_move_resize_handler.h"
-#include "ui/views/test/views_interactive_ui_test_base.h"
+#include "ui/views/test/widget_test.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/desktop_aura/window_event_filter_linux.h"
#include "ui/views/widget/widget_delegate.h"
@@ -180,7 +180,8 @@ class TestDesktopWindowTreeHostLinux : public DesktopWindowTreeHostLinux {
} // namespace
-class DesktopWindowTreeHostLinuxTest : public ViewsInteractiveUITestBase {
+class DesktopWindowTreeHostLinuxTest
+ : public test::DesktopWidgetTestInteractive {
public:
DesktopWindowTreeHostLinuxTest() = default;
~DesktopWindowTreeHostLinuxTest() override = default;
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.cc b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.cc
index f3a3175c6c3..aaf1b482f71 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.cc
+++ b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.cc
@@ -21,6 +21,7 @@
#include "ui/gfx/geometry/dip_util.h"
#include "ui/platform_window/extensions/workspace_extension.h"
#include "ui/platform_window/platform_window.h"
+#include "ui/platform_window/platform_window_handler/wm_move_loop_handler.h"
#include "ui/platform_window/platform_window_init_properties.h"
#include "ui/views/corewm/tooltip_aura.h"
#include "ui/views/widget/desktop_aura/desktop_drag_drop_client_ozone.h"
@@ -28,9 +29,16 @@
#include "ui/views/widget/widget_aura_utils.h"
#include "ui/views/window/native_frame_view.h"
#include "ui/wm/core/window_util.h"
+#include "ui/wm/public/window_move_client.h"
+
+DEFINE_UI_CLASS_PROPERTY_TYPE(views::DesktopWindowTreeHostPlatform*)
namespace views {
+DEFINE_UI_CLASS_PROPERTY_KEY(DesktopWindowTreeHostPlatform*,
+ kHostForRootWindow,
+ nullptr)
+
namespace {
bool DetermineInactivity(ui::WindowShowState show_state) {
@@ -108,14 +116,31 @@ DesktopWindowTreeHostPlatform::DesktopWindowTreeHostPlatform(
internal::NativeWidgetDelegate* native_widget_delegate,
DesktopNativeWidgetAura* desktop_native_widget_aura)
: native_widget_delegate_(native_widget_delegate),
- desktop_native_widget_aura_(desktop_native_widget_aura) {}
+ desktop_native_widget_aura_(desktop_native_widget_aura),
+ window_move_client_(this) {}
DesktopWindowTreeHostPlatform::~DesktopWindowTreeHostPlatform() {
+ window()->ClearProperty(kHostForRootWindow);
DCHECK(!platform_window()) << "The host must be closed before destroying it.";
desktop_native_widget_aura_->OnDesktopWindowTreeHostDestroyed(this);
DestroyDispatcher();
}
+// static
+aura::Window* DesktopWindowTreeHostPlatform::GetContentWindowForWidget(
+ gfx::AcceleratedWidget widget) {
+ auto* host = DesktopWindowTreeHostPlatform::GetHostForWidget(widget);
+ return host ? host->GetContentWindow() : nullptr;
+}
+
+// static
+DesktopWindowTreeHostPlatform* DesktopWindowTreeHostPlatform::GetHostForWidget(
+ gfx::AcceleratedWidget widget) {
+ aura::WindowTreeHost* host =
+ aura::WindowTreeHost::GetForAcceleratedWidget(widget);
+ return host ? host->window()->GetProperty(kHostForRootWindow) : nullptr;
+}
+
aura::Window* DesktopWindowTreeHostPlatform::GetContentWindow() {
return desktop_native_widget_aura_->content_window();
}
@@ -160,6 +185,11 @@ void DesktopWindowTreeHostPlatform::Init(const Widget::InitParams& params) {
void DesktopWindowTreeHostPlatform::OnNativeWidgetCreated(
const Widget::InitParams& params) {
+ window()->SetProperty(kHostForRootWindow, this);
+ // This reroutes RunMoveLoop requests to the DesktopWindowTreeHostPlatform.
+ // The availability of this feature depends on a platform (PlatformWindow)
+ // that implements RunMoveLoop.
+ wm::SetWindowMoveClient(window(), &window_move_client_);
platform_window()->SetUseNativeFrame(params.type ==
Widget::InitParams::TYPE_WINDOW &&
!params.remove_standard_frame);
@@ -504,14 +534,16 @@ Widget::MoveLoopResult DesktopWindowTreeHostPlatform::RunMoveLoop(
const gfx::Vector2d& drag_offset,
Widget::MoveLoopSource source,
Widget::MoveLoopEscapeBehavior escape_behavior) {
- // TODO(crbug.com/896640): needs PlatformWindow support.
- NOTIMPLEMENTED_LOG_ONCE();
+ auto* move_loop_handler = ui::GetWmMoveLoopHandler(*platform_window());
+ if (move_loop_handler && move_loop_handler->RunMoveLoop(drag_offset))
+ return Widget::MOVE_LOOP_SUCCESSFUL;
return Widget::MOVE_LOOP_CANCELED;
}
void DesktopWindowTreeHostPlatform::EndMoveLoop() {
- // TODO(crbug.com/896640): needs PlatformWindow support.
- NOTIMPLEMENTED_LOG_ONCE();
+ auto* move_loop_handler = ui::GetWmMoveLoopHandler(*platform_window());
+ if (move_loop_handler)
+ move_loop_handler->EndMoveLoop();
}
void DesktopWindowTreeHostPlatform::SetVisibilityChangedAnimationsEnabled(
@@ -646,6 +678,7 @@ void DesktopWindowTreeHostPlatform::HideImpl() {
}
void DesktopWindowTreeHostPlatform::OnClosed() {
+ wm::SetWindowMoveClient(window(), nullptr);
SetPlatformWindow(nullptr);
desktop_native_widget_aura_->OnHostClosed();
}
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h
index 24a5fa974dd..75860eaabf1 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h
+++ b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h
@@ -16,6 +16,7 @@
#include "ui/platform_window/extensions/workspace_extension_delegate.h"
#include "ui/views/views_export.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host.h"
+#include "ui/views/widget/desktop_aura/window_move_client_platform.h"
namespace views {
@@ -29,6 +30,14 @@ class VIEWS_EXPORT DesktopWindowTreeHostPlatform
DesktopNativeWidgetAura* desktop_native_widget_aura);
~DesktopWindowTreeHostPlatform() override;
+ // A way of converting a |widget| into the content_window()
+ // of the associated DesktopNativeWidgetAura.
+ static aura::Window* GetContentWindowForWidget(gfx::AcceleratedWidget widget);
+
+ // A way of converting a |widget| into this object.
+ static DesktopWindowTreeHostPlatform* GetHostForWidget(
+ gfx::AcceleratedWidget widget);
+
// Accessor for DesktopNativeWidgetAura::content_window().
aura::Window* GetContentWindow();
const aura::Window* GetContentWindow() const;
@@ -161,6 +170,9 @@ class VIEWS_EXPORT DesktopWindowTreeHostPlatform
// normal state.
ui::PlatformWindowState old_state_ = ui::PlatformWindowState::kUnknown;
+ // Used for tab dragging in move loop requests.
+ WindowMoveClientPlatform window_move_client_;
+
base::WeakPtrFactory<DesktopWindowTreeHostPlatform> close_widget_factory_{
this};
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
index 6f576d95707..6051aadee62 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
+++ b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
@@ -12,6 +12,7 @@
#include "base/containers/flat_set.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
+#include "base/trace_event/trace_event.h"
#include "base/win/win_util.h"
#include "base/win/windows_version.h"
#include "third_party/skia/include/core/SkPath.h"
@@ -622,6 +623,8 @@ DesktopWindowTreeHostWin::GetKeyboardLayoutMap() {
}
void DesktopWindowTreeHostWin::SetCursorNative(gfx::NativeCursor cursor) {
+ TRACE_EVENT1("ui,input", "DesktopWindowTreeHostWin::SetCursorNative",
+ "cursor", cursor.type());
ui::CursorLoaderWin cursor_loader;
cursor_loader.SetPlatformCursor(&cursor);
@@ -922,8 +925,20 @@ bool DesktopWindowTreeHostWin::HandleMouseEvent(ui::MouseEvent* event) {
// marked occluded, or getting stuck in the occluded state. Event can cause
// this object to be deleted so check occlusion state before we do anything
// with the event.
- if (GetNativeWindowOcclusionState() == aura::Window::OcclusionState::OCCLUDED)
- UMA_HISTOGRAM_BOOLEAN("OccludedWindowMouseEvents", true);
+ // This stat tries to detect the user moving the mouse over a window falsely
+ // determined to be occluded, so ignore mouse events that have the same
+ // location as the first event, and exit events.
+ if (GetNativeWindowOcclusionState() ==
+ aura::Window::OcclusionState::OCCLUDED) {
+ if (occluded_window_mouse_event_loc_ != gfx::Point() &&
+ event->location() != occluded_window_mouse_event_loc_ &&
+ event->type() != ui::ET_MOUSE_EXITED) {
+ UMA_HISTOGRAM_BOOLEAN("OccludedWindowMouseEvents", true);
+ }
+ occluded_window_mouse_event_loc_ = event->location();
+ } else {
+ occluded_window_mouse_event_loc_ = gfx::Point();
+ }
SendEventToSink(event);
return event->handled();
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h
index 4b217541512..75ca9e99f2c 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h
+++ b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_win.h
@@ -307,6 +307,11 @@ class VIEWS_EXPORT DesktopWindowTreeHostWin
// become activated.
bool wants_mouse_events_when_inactive_ = false;
+ // The location of the most recent mouse event on an occluded window. This is
+ // used to generate the OccludedWindowMouseEvents stat and can be removed
+ // when that stat is no longer tracked.
+ gfx::Point occluded_window_mouse_event_loc_;
+
// The z-order level of the window; the window exhibits "always on top"
// behavior if > 0.
ui::ZOrderLevel z_order_ = ui::ZOrderLevel::kNormal;
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
index 2c94941cf27..44e9eef3492 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
+++ b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.cc
@@ -31,7 +31,7 @@
#include "ui/aura/window_event_dispatcher.h"
#include "ui/base/buildflags.h"
#include "ui/base/class_property.h"
-#include "ui/base/dragdrop/os_exchange_data_provider_aurax11.h"
+#include "ui/base/dragdrop/os_exchange_data_provider_x11.h"
#include "ui/base/hit_test.h"
#include "ui/base/ime/input_method.h"
#include "ui/base/layout.h"
@@ -57,7 +57,6 @@
#include "ui/views/widget/desktop_aura/desktop_drag_drop_client_aurax11.h"
#include "ui/views/widget/desktop_aura/desktop_native_cursor_manager.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
-#include "ui/views/widget/desktop_aura/x11_desktop_window_move_client.h"
#include "ui/views/window/native_frame_view.h"
#include "ui/wm/core/compound_event_filter.h"
#include "ui/wm/core/window_util.h"
@@ -72,12 +71,7 @@ DesktopWindowTreeHostX11::DesktopWindowTreeHostX11(
: DesktopWindowTreeHostLinux(native_widget_delegate,
desktop_native_widget_aura) {}
-DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() {
- wm::SetWindowMoveClient(window(), nullptr);
-
- // ~DWTHPlatform notifies the DestkopNativeWidgetAura about destruction and
- // also destroyes the dispatcher.
-}
+DesktopWindowTreeHostX11::~DesktopWindowTreeHostX11() = default;
////////////////////////////////////////////////////////////////////////////////
// DesktopWindowTreeHostX11, DesktopWindowTreeHost implementation:
@@ -94,14 +88,6 @@ void DesktopWindowTreeHostX11::Init(const Widget::InitParams& params) {
static_cast<ui::X11Window*>(platform_window())->SetXEventDelegate(this);
}
-void DesktopWindowTreeHostX11::OnNativeWidgetCreated(
- const Widget::InitParams& params) {
- x11_window_move_client_ = std::make_unique<X11DesktopWindowMoveClient>();
- wm::SetWindowMoveClient(window(), x11_window_move_client_.get());
-
- DesktopWindowTreeHostLinux::OnNativeWidgetCreated(params);
-}
-
std::unique_ptr<aura::client::DragDropClient>
DesktopWindowTreeHostX11::CreateDragDropClient(
DesktopNativeCursorManager* cursor_manager) {
@@ -112,25 +98,6 @@ DesktopWindowTreeHostX11::CreateDragDropClient(
return base::WrapUnique(drag_drop_client_);
}
-Widget::MoveLoopResult DesktopWindowTreeHostX11::RunMoveLoop(
- const gfx::Vector2d& drag_offset,
- Widget::MoveLoopSource source,
- Widget::MoveLoopEscapeBehavior escape_behavior) {
- wm::WindowMoveSource window_move_source =
- source == Widget::MoveLoopSource::kMouse ? wm::WINDOW_MOVE_SOURCE_MOUSE
- : wm::WINDOW_MOVE_SOURCE_TOUCH;
- if (x11_window_move_client_->RunMoveLoop(GetContentWindow(), drag_offset,
- window_move_source) ==
- wm::MOVE_SUCCESSFUL)
- return Widget::MOVE_LOOP_SUCCESSFUL;
-
- return Widget::MOVE_LOOP_CANCELED;
-}
-
-void DesktopWindowTreeHostX11::EndMoveLoop() {
- x11_window_move_client_->EndMoveLoop();
-}
-
////////////////////////////////////////////////////////////////////////////////
// DesktopWindowTreeHostX11 implementation:
@@ -143,21 +110,7 @@ void DesktopWindowTreeHostX11::OnXWindowSelectionEvent(XEvent* xev) {
void DesktopWindowTreeHostX11::OnXWindowDragDropEvent(XEvent* xev) {
DCHECK(xev);
DCHECK(drag_drop_client_);
-
- ::Atom message_type = xev->xclient.message_type;
- if (message_type == gfx::GetAtom("XdndEnter")) {
- drag_drop_client_->OnXdndEnter(xev->xclient);
- } else if (message_type == gfx::GetAtom("XdndLeave")) {
- drag_drop_client_->OnXdndLeave(xev->xclient);
- } else if (message_type == gfx::GetAtom("XdndPosition")) {
- drag_drop_client_->OnXdndPosition(xev->xclient);
- } else if (message_type == gfx::GetAtom("XdndStatus")) {
- drag_drop_client_->OnXdndStatus(xev->xclient);
- } else if (message_type == gfx::GetAtom("XdndFinished")) {
- drag_drop_client_->OnXdndFinished(xev->xclient);
- } else if (message_type == gfx::GetAtom("XdndDrop")) {
- drag_drop_client_->OnXdndDrop(xev->xclient);
- }
+ drag_drop_client_->HandleXdndEvent(xev->xclient);
}
const ui::XWindow* DesktopWindowTreeHostX11::GetXWindow() const {
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h
index 53da309c14d..8cd6b80ee1e 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h
+++ b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h
@@ -21,7 +21,6 @@ class X11Window;
namespace views {
class DesktopDragDropClientAuraX11;
-class X11DesktopWindowMoveClient;
class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
public ui::XEventDelegate {
@@ -34,14 +33,8 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
protected:
// Overridden from DesktopWindowTreeHost:
void Init(const Widget::InitParams& params) override;
- void OnNativeWidgetCreated(const Widget::InitParams& params) override;
std::unique_ptr<aura::client::DragDropClient> CreateDragDropClient(
DesktopNativeCursorManager* cursor_manager) override;
- Widget::MoveLoopResult RunMoveLoop(
- const gfx::Vector2d& drag_offset,
- Widget::MoveLoopSource source,
- Widget::MoveLoopEscapeBehavior escape_behavior) override;
- void EndMoveLoop() override;
private:
friend class DesktopWindowTreeHostX11HighDPITest;
@@ -58,8 +51,6 @@ class VIEWS_EXPORT DesktopWindowTreeHostX11 : public DesktopWindowTreeHostLinux,
DesktopDragDropClientAuraX11* drag_drop_client_ = nullptr;
- std::unique_ptr<X11DesktopWindowMoveClient> x11_window_move_client_;
-
DISALLOW_COPY_AND_ASSIGN(DesktopWindowTreeHostX11);
};
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc
index 7135ad984e3..c63bfe26350 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc
+++ b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_interactive_uitest.cc
@@ -11,6 +11,7 @@
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/ime/input_method.h"
+#include "ui/base/x/test/x11_property_change_waiter.h"
#include "ui/base/x/x11_util.h"
#include "ui/events/event_handler.h"
#include "ui/events/platform/x11/x11_event_source.h"
@@ -19,8 +20,7 @@
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/views/controls/textfield/textfield.h"
-#include "ui/views/test/views_interactive_ui_test_base.h"
-#include "ui/views/test/x11_property_change_waiter.h"
+#include "ui/views/test/widget_test.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
namespace views {
@@ -28,16 +28,17 @@ namespace views {
namespace {
// Blocks till |window| gets activated.
-class ActivationWaiter : public X11PropertyChangeWaiter {
+class ActivationWaiter : public ui::X11PropertyChangeWaiter {
public:
explicit ActivationWaiter(XID window)
- : X11PropertyChangeWaiter(ui::GetX11RootWindow(), "_NET_ACTIVE_WINDOW"),
+ : ui::X11PropertyChangeWaiter(ui::GetX11RootWindow(),
+ "_NET_ACTIVE_WINDOW"),
window_(window) {}
~ActivationWaiter() override = default;
private:
- // X11PropertyChangeWaiter:
+ // ui::X11PropertyChangeWaiter:
bool ShouldKeepOnWaiting(XEvent* event) override {
XID xid = 0;
ui::GetXIDProperty(ui::GetX11RootWindow(), "_NET_ACTIVE_WINDOW", &xid);
@@ -108,23 +109,22 @@ void DispatchMouseMotionEvent(DesktopWindowTreeHostX11* desktop_host,
} // namespace
-class DesktopWindowTreeHostX11Test : public ViewsInteractiveUITestBase {
+class DesktopWindowTreeHostX11Test : public test::DesktopWidgetTestInteractive {
public:
DesktopWindowTreeHostX11Test() = default;
~DesktopWindowTreeHostX11Test() override = default;
- // testing::Test
+ // DesktopWidgetTestInteractive
void SetUp() override {
- ViewsInteractiveUITestBase::SetUp();
-
// Make X11 synchronous for our display connection. This does not force the
// window manager to behave synchronously.
XSynchronize(gfx::GetXDisplay(), x11::True);
+ DesktopWidgetTestInteractive::SetUp();
}
void TearDown() override {
XSynchronize(gfx::GetXDisplay(), x11::False);
- ViewsInteractiveUITestBase::TearDown();
+ DesktopWidgetTestInteractive::TearDown();
}
private:
@@ -235,6 +235,12 @@ TEST_F(DesktopWindowTreeHostX11Test, CaptureEventForwarding) {
TEST_F(DesktopWindowTreeHostX11Test, InputMethodFocus) {
std::unique_ptr<Widget> widget(CreateWidget(gfx::Rect(100, 100, 100, 100)));
+
+ // Waiter should be created as early as possible so that PropertyNotify has
+ // time to be set before widget is activated.
+ ActivationWaiter waiter(
+ widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget());
+
std::unique_ptr<Textfield> textfield(new Textfield);
textfield->SetBounds(0, 0, 200, 20);
widget->GetRootView()->AddChildView(textfield.get());
@@ -247,11 +253,6 @@ TEST_F(DesktopWindowTreeHostX11Test, InputMethodFocus) {
// EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE,
// widget->GetInputMethod()->GetTextInputType());
- // Waiter should be created before widget->Activate is called. Otherwise,
- // there is a race, and waiter might not be able to set property changes mask
- // on time and miss the events.
- ActivationWaiter waiter(
- widget->GetNativeWindow()->GetHost()->GetAcceleratedWidget());
widget->Activate();
waiter.Wait();
diff --git a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc
index 88b625f1b59..1f4b3a5244c 100644
--- a/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc
+++ b/chromium/ui/views/widget/desktop_aura/desktop_window_tree_host_x11_unittest.cc
@@ -16,6 +16,7 @@
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/hit_test.h"
+#include "ui/base/x/test/x11_property_change_waiter.h"
#include "ui/base/x/x11_util.h"
#include "ui/display/display_switches.h"
#include "ui/events/devices/x11/touch_factory_x11.h"
@@ -28,7 +29,6 @@
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/views/test/views_test_base.h"
-#include "ui/views/test/x11_property_change_waiter.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
#include "ui/views/widget/widget_delegate.h"
@@ -41,10 +41,10 @@ namespace {
const int kPointerDeviceId = 1;
// Blocks till the window state hint, |hint|, is set or unset.
-class WMStateWaiter : public X11PropertyChangeWaiter {
+class WMStateWaiter : public ui::X11PropertyChangeWaiter {
public:
WMStateWaiter(XID window, const char* hint, bool wait_till_set)
- : X11PropertyChangeWaiter(window, "_NET_WM_STATE"),
+ : ui::X11PropertyChangeWaiter(window, "_NET_WM_STATE"),
hint_(hint),
wait_till_set_(wait_till_set) {}
diff --git a/chromium/ui/views/widget/desktop_aura/window_event_filter_linux.cc b/chromium/ui/views/widget/desktop_aura/window_event_filter_linux.cc
index d69da05aa30..915fa77545d 100644
--- a/chromium/ui/views/widget/desktop_aura/window_event_filter_linux.cc
+++ b/chromium/ui/views/widget/desktop_aura/window_event_filter_linux.cc
@@ -112,6 +112,10 @@ void WindowEventFilterLinux::OnClickedCaption(ui::MouseEvent* event,
if (!view || !view->context_menu_controller())
break;
gfx::Point location(event->location());
+ // Controller requires locations to be in DIP, while |this| receives the
+ // location in px.
+ desktop_window_tree_host_->GetRootTransform().TransformPointReverse(
+ &location);
views::View::ConvertPointToScreen(view, &location);
view->ShowContextMenu(location, ui::MENU_SOURCE_MOUSE);
event->SetHandled();
diff --git a/chromium/ui/views/widget/desktop_aura/window_move_client_platform.cc b/chromium/ui/views/widget/desktop_aura/window_move_client_platform.cc
new file mode 100644
index 00000000000..d561307dbca
--- /dev/null
+++ b/chromium/ui/views/widget/desktop_aura/window_move_client_platform.cc
@@ -0,0 +1,37 @@
+// Copyright 2020 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 "ui/views/widget/desktop_aura/window_move_client_platform.h"
+
+#include "ui/views/widget/desktop_aura/desktop_window_tree_host_platform.h"
+
+namespace views {
+
+WindowMoveClientPlatform::WindowMoveClientPlatform(
+ DesktopWindowTreeHostPlatform* host)
+ : host_(host) {}
+
+WindowMoveClientPlatform::~WindowMoveClientPlatform() = default;
+
+wm::WindowMoveResult WindowMoveClientPlatform::RunMoveLoop(
+ aura::Window* source,
+ const gfx::Vector2d& drag_offset,
+ wm::WindowMoveSource move_source) {
+ DCHECK(host_->GetContentWindow()->Contains(source));
+ auto move_loop_result = host_->RunMoveLoop(
+ drag_offset,
+ move_source == wm::WindowMoveSource::WINDOW_MOVE_SOURCE_MOUSE
+ ? Widget::MoveLoopSource::kMouse
+ : Widget::MoveLoopSource::kTouch,
+ Widget::MoveLoopEscapeBehavior::MOVE_LOOP_ESCAPE_BEHAVIOR_HIDE);
+
+ return move_loop_result == Widget::MOVE_LOOP_SUCCESSFUL ? wm::MOVE_SUCCESSFUL
+ : wm::MOVE_CANCELED;
+}
+
+void WindowMoveClientPlatform::EndMoveLoop() {
+ host_->EndMoveLoop();
+}
+
+} // namespace views
diff --git a/chromium/ui/views/widget/desktop_aura/window_move_client_platform.h b/chromium/ui/views/widget/desktop_aura/window_move_client_platform.h
new file mode 100644
index 00000000000..09d46399247
--- /dev/null
+++ b/chromium/ui/views/widget/desktop_aura/window_move_client_platform.h
@@ -0,0 +1,37 @@
+// Copyright 2020 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 UI_VIEWS_WIDGET_DESKTOP_AURA_WINDOW_MOVE_CLIENT_PLATFORM_H_
+#define UI_VIEWS_WIDGET_DESKTOP_AURA_WINDOW_MOVE_CLIENT_PLATFORM_H_
+
+#include "ui/views/views_export.h"
+#include "ui/wm/public/window_move_client.h"
+
+namespace views {
+
+class DesktopWindowTreeHostPlatform;
+
+// Reroutes move loop requests to DesktopWindowTreeHostPlatform.
+class VIEWS_EXPORT WindowMoveClientPlatform : public wm::WindowMoveClient {
+ public:
+ explicit WindowMoveClientPlatform(DesktopWindowTreeHostPlatform* host);
+ WindowMoveClientPlatform(const WindowMoveClientPlatform& host) = delete;
+ WindowMoveClientPlatform& operator=(const WindowMoveClientPlatform& host) =
+ delete;
+ ~WindowMoveClientPlatform() override;
+
+ // Overridden from wm::WindowMoveClient:
+ wm::WindowMoveResult RunMoveLoop(aura::Window* window,
+ const gfx::Vector2d& drag_offset,
+ wm::WindowMoveSource move_source) override;
+ void EndMoveLoop() override;
+
+ private:
+ // The RunMoveLoop request is forwarded to this host.
+ DesktopWindowTreeHostPlatform* host_ = nullptr;
+};
+
+} // namespace views
+
+#endif // UI_VIEWS_WIDGET_DESKTOP_AURA_WINDOW_MOVE_CLIENT_PLATFORM_H_
diff --git a/chromium/ui/views/widget/desktop_aura/x11_desktop_window_move_client.cc b/chromium/ui/views/widget/desktop_aura/x11_desktop_window_move_client.cc
deleted file mode 100644
index 80b34d05334..00000000000
--- a/chromium/ui/views/widget/desktop_aura/x11_desktop_window_move_client.cc
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2012 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 "ui/views/widget/desktop_aura/x11_desktop_window_move_client.h"
-
-#include "base/run_loop.h"
-#include "ui/aura/env.h"
-#include "ui/aura/window.h"
-#include "ui/aura/window_tree_host.h"
-#include "ui/base/x/x11_util.h"
-#include "ui/events/event.h"
-#include "ui/gfx/x/x11.h"
-
-namespace views {
-
-X11DesktopWindowMoveClient::X11DesktopWindowMoveClient() = default;
-
-X11DesktopWindowMoveClient::~X11DesktopWindowMoveClient() = default;
-
-void X11DesktopWindowMoveClient::OnMouseMovement(const gfx::Point& screen_point,
- int flags,
- base::TimeTicks event_time) {
- gfx::Point system_loc = screen_point - window_offset_;
- host_->SetBoundsInPixels(
- gfx::Rect(system_loc, host_->GetBoundsInPixels().size()));
-}
-
-void X11DesktopWindowMoveClient::OnMouseReleased() {
- EndMoveLoop();
-}
-
-void X11DesktopWindowMoveClient::OnMoveLoopEnded() {
- host_ = nullptr;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-// DesktopWindowTreeHostLinux, wm::WindowMoveClient implementation:
-
-wm::WindowMoveResult X11DesktopWindowMoveClient::RunMoveLoop(
- aura::Window* source,
- const gfx::Vector2d& drag_offset,
- wm::WindowMoveSource move_source) {
- window_offset_ = drag_offset;
- host_ = source->GetHost();
-
- source->SetCapture();
- bool success = move_loop_.RunMoveLoop(source, host_->last_cursor());
- return success ? wm::MOVE_SUCCESSFUL : wm::MOVE_CANCELED;
-}
-
-void X11DesktopWindowMoveClient::EndMoveLoop() {
- move_loop_.EndMoveLoop();
-}
-
-} // namespace views
diff --git a/chromium/ui/views/widget/desktop_aura/x11_topmost_window_finder.cc b/chromium/ui/views/widget/desktop_aura/x11_topmost_window_finder.cc
deleted file mode 100644
index 9acc365e582..00000000000
--- a/chromium/ui/views/widget/desktop_aura/x11_topmost_window_finder.cc
+++ /dev/null
@@ -1,92 +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 "ui/views/widget/desktop_aura/x11_topmost_window_finder.h"
-
-#include <stddef.h>
-
-#include <vector>
-
-#include "ui/aura/client/screen_position_client.h"
-#include "ui/aura/window.h"
-#include "ui/views/widget/desktop_aura/desktop_window_tree_host_x11.h"
-
-namespace views {
-
-X11TopmostWindowFinder::X11TopmostWindowFinder() = default;
-
-X11TopmostWindowFinder::~X11TopmostWindowFinder() = default;
-
-aura::Window* X11TopmostWindowFinder::FindLocalProcessWindowAt(
- const gfx::Point& screen_loc_in_pixels,
- const std::set<aura::Window*>& ignore) {
- screen_loc_in_pixels_ = screen_loc_in_pixels;
- ignore_ = ignore;
-
- std::vector<aura::Window*> local_process_windows =
- DesktopWindowTreeHostLinux::GetAllOpenWindows();
- if (std::none_of(local_process_windows.cbegin(), local_process_windows.cend(),
- [this](auto* window) {
- return ShouldStopIteratingAtLocalProcessWindow(window);
- }))
- return nullptr;
-
- ui::EnumerateTopLevelWindows(this);
- return DesktopWindowTreeHostLinux::GetContentWindowForWidget(
- static_cast<gfx::AcceleratedWidget>(toplevel_));
-}
-
-XID X11TopmostWindowFinder::FindWindowAt(
- const gfx::Point& screen_loc_in_pixels) {
- screen_loc_in_pixels_ = screen_loc_in_pixels;
- ui::EnumerateTopLevelWindows(this);
- return toplevel_;
-}
-
-bool X11TopmostWindowFinder::ShouldStopIterating(XID xid) {
- if (!ui::IsWindowVisible(xid))
- return false;
-
- auto* window = DesktopWindowTreeHostLinux::GetContentWindowForWidget(
- static_cast<gfx::AcceleratedWidget>(xid));
- if (window) {
- if (ShouldStopIteratingAtLocalProcessWindow(window)) {
- toplevel_ = xid;
- return true;
- }
- return false;
- }
-
- if (ui::WindowContainsPoint(xid, screen_loc_in_pixels_)) {
- toplevel_ = xid;
- return true;
- }
- return false;
-}
-
-bool X11TopmostWindowFinder::ShouldStopIteratingAtLocalProcessWindow(
- aura::Window* window) {
- if (ignore_.find(window) != ignore_.end())
- return false;
-
- // Currently |window|->IsVisible() always returns true.
- // TODO(pkotwicz): Fix this. crbug.com/353038
- if (!window->IsVisible())
- return false;
-
- auto* host = DesktopWindowTreeHostLinux::GetHostForWidget(
- window->GetHost()->GetAcceleratedWidget());
- if (!static_cast<DesktopWindowTreeHostX11*>(host)
- ->GetXRootWindowOuterBounds()
- .Contains(screen_loc_in_pixels_))
- return false;
-
- aura::client::ScreenPositionClient* screen_position_client =
- aura::client::GetScreenPositionClient(window->GetRootWindow());
- gfx::Point window_loc(screen_loc_in_pixels_);
- screen_position_client->ConvertPointFromScreen(window, &window_loc);
- return host->ContainsPointInXRegion(window_loc);
-}
-
-} // namespace views
diff --git a/chromium/ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc b/chromium/ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc
index ce5c9ef430d..aa249625d3f 100644
--- a/chromium/ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc
+++ b/chromium/ui/views/widget/desktop_aura/x11_topmost_window_finder_interactive_uitest.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "ui/views/widget/desktop_aura/x11_topmost_window_finder.h"
+#include "ui/platform_window/x11/x11_topmost_window_finder.h"
#include <stddef.h>
@@ -14,13 +14,14 @@
#include "third_party/skia/include/core/SkRect.h"
#include "ui/aura/window.h"
#include "ui/aura/window_tree_host.h"
+#include "ui/base/x/test/x11_property_change_waiter.h"
#include "ui/events/platform/x11/x11_event_source.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/x11_path.h"
-#include "ui/views/test/views_interactive_ui_test_base.h"
-#include "ui/views/test/x11_property_change_waiter.h"
+#include "ui/views/test/widget_test.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
+#include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h"
#include "ui/views/widget/widget.h"
namespace views {
@@ -28,15 +29,15 @@ namespace views {
namespace {
// Waits till |window| is minimized.
-class MinimizeWaiter : public X11PropertyChangeWaiter {
+class MinimizeWaiter : public ui::X11PropertyChangeWaiter {
public:
explicit MinimizeWaiter(XID window)
- : X11PropertyChangeWaiter(window, "_NET_WM_STATE") {}
+ : ui::X11PropertyChangeWaiter(window, "_NET_WM_STATE") {}
~MinimizeWaiter() override = default;
private:
- // X11PropertyChangeWaiter:
+ // ui::X11PropertyChangeWaiter:
bool ShouldKeepOnWaiting(XEvent* event) override {
std::vector<Atom> wm_states;
if (ui::GetAtomArrayProperty(xwindow(), "_NET_WM_STATE", &wm_states)) {
@@ -50,11 +51,11 @@ class MinimizeWaiter : public X11PropertyChangeWaiter {
// Waits till |_NET_CLIENT_LIST_STACKING| is updated to include
// |expected_windows|.
-class StackingClientListWaiter : public X11PropertyChangeWaiter {
+class StackingClientListWaiter : public ui::X11PropertyChangeWaiter {
public:
StackingClientListWaiter(XID* expected_windows, size_t count)
- : X11PropertyChangeWaiter(ui::GetX11RootWindow(),
- "_NET_CLIENT_LIST_STACKING"),
+ : ui::X11PropertyChangeWaiter(ui::GetX11RootWindow(),
+ "_NET_CLIENT_LIST_STACKING"),
expected_windows_(expected_windows, expected_windows + count) {}
~StackingClientListWaiter() override = default;
@@ -66,11 +67,11 @@ class StackingClientListWaiter : public X11PropertyChangeWaiter {
if (!ShouldKeepOnWaiting(nullptr))
return;
- X11PropertyChangeWaiter::Wait();
+ ui::X11PropertyChangeWaiter::Wait();
}
private:
- // X11PropertyChangeWaiter:
+ // ui::X11PropertyChangeWaiter:
bool ShouldKeepOnWaiting(XEvent* event) override {
std::vector<XID> stack;
ui::GetXWindowStack(ui::GetX11RootWindow(), &stack);
@@ -86,12 +87,24 @@ class StackingClientListWaiter : public X11PropertyChangeWaiter {
} // namespace
-class X11TopmostWindowFinderTest : public ViewsInteractiveUITestBase {
+class X11TopmostWindowFinderTest : public test::DesktopWidgetTestInteractive {
public:
X11TopmostWindowFinderTest() = default;
-
~X11TopmostWindowFinderTest() override = default;
+ // DesktopWidgetTestInteractive
+ void SetUp() override {
+ // Make X11 synchronous for our display connection. This does not force the
+ // window manager to behave synchronously.
+ XSynchronize(xdisplay(), x11::True);
+ DesktopWidgetTestInteractive::SetUp();
+ }
+
+ void TearDown() override {
+ XSynchronize(xdisplay(), x11::False);
+ DesktopWidgetTestInteractive::TearDown();
+ }
+
// Creates and shows a Widget with |bounds|. The caller takes ownership of
// the returned widget.
std::unique_ptr<Widget> CreateAndShowWidget(const gfx::Rect& bounds) {
@@ -135,16 +148,19 @@ class X11TopmostWindowFinderTest : public ViewsInteractiveUITestBase {
// Returns the topmost X window at the passed in screen position.
XID FindTopmostXWindowAt(int screen_x, int screen_y) {
- X11TopmostWindowFinder finder;
+ ui::X11TopmostWindowFinder finder;
return finder.FindWindowAt(gfx::Point(screen_x, screen_y));
}
// Returns the topmost aura::Window at the passed in screen position. Returns
// NULL if the topmost window does not have an associated aura::Window.
aura::Window* FindTopmostLocalProcessWindowAt(int screen_x, int screen_y) {
- X11TopmostWindowFinder finder;
- return finder.FindLocalProcessWindowAt(gfx::Point(screen_x, screen_y),
- std::set<aura::Window*>());
+ ui::X11TopmostWindowFinder finder;
+ auto widget =
+ finder.FindLocalProcessWindowAt(gfx::Point(screen_x, screen_y), {});
+ return widget ? DesktopWindowTreeHostPlatform::GetContentWindowForWidget(
+ static_cast<gfx::AcceleratedWidget>(widget))
+ : nullptr;
}
// Returns the topmost aura::Window at the passed in screen position ignoring
@@ -154,25 +170,14 @@ class X11TopmostWindowFinderTest : public ViewsInteractiveUITestBase {
int screen_x,
int screen_y,
aura::Window* ignore_window) {
- std::set<aura::Window*> ignore;
- ignore.insert(ignore_window);
- X11TopmostWindowFinder finder;
- return finder.FindLocalProcessWindowAt(gfx::Point(screen_x, screen_y),
- ignore);
- }
-
- // ViewsInteractiveUITestBase:
- void SetUp() override {
- ViewsInteractiveUITestBase::SetUp();
-
- // Make X11 synchronous for our display connection. This does not force the
- // window manager to behave synchronously.
- XSynchronize(xdisplay(), x11::True);
- }
-
- void TearDown() override {
- XSynchronize(xdisplay(), x11::False);
- ViewsInteractiveUITestBase::TearDown();
+ std::set<gfx::AcceleratedWidget> ignore;
+ ignore.insert(ignore_window->GetHost()->GetAcceleratedWidget());
+ ui::X11TopmostWindowFinder finder;
+ auto widget =
+ finder.FindLocalProcessWindowAt(gfx::Point(screen_x, screen_y), ignore);
+ return widget ? DesktopWindowTreeHostPlatform::GetContentWindowForWidget(
+ static_cast<gfx::AcceleratedWidget>(widget))
+ : nullptr;
}
private:
diff --git a/chromium/ui/views/widget/desktop_widget_unittest.cc b/chromium/ui/views/widget/desktop_widget_unittest.cc
index 6295852a6cb..7eb0473bb00 100644
--- a/chromium/ui/views/widget/desktop_widget_unittest.cc
+++ b/chromium/ui/views/widget/desktop_widget_unittest.cc
@@ -64,7 +64,7 @@ TEST_F(DesktopScreenPositionClientTest, PositionControlWithNonRootParent) {
params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params2.child = true;
params2.native_widget = test::CreatePlatformNativeWidgetImpl(
- params2, &widget2, test::kStubCapture, nullptr);
+ &widget2, test::kStubCapture, nullptr);
widget2.Init(std::move(params2));
Widget::InitParams params3 = CreateParams(Widget::InitParams::TYPE_CONTROL);
@@ -73,7 +73,7 @@ TEST_F(DesktopScreenPositionClientTest, PositionControlWithNonRootParent) {
params3.child = true;
params3.bounds = gfx::Rect(origin, gfx::Size(500, work_area.height() - 200));
params3.native_widget = test::CreatePlatformNativeWidgetImpl(
- params3, &widget3, test::kStubCapture, nullptr);
+ &widget3, test::kStubCapture, nullptr);
widget3.Init(std::move(params3));
// The origin of the 3rd window should be the sum of all parent origins.
@@ -147,7 +147,7 @@ TEST_F(DesktopScreenPositionClientTest, InitialBoundsConstrainedToParent) {
params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
params2.child = true;
params2.native_widget = test::CreatePlatformNativeWidgetImpl(
- params2, &widget2, test::kStubCapture, nullptr);
+ &widget2, test::kStubCapture, nullptr);
widget2.Init(std::move(params2));
// The bounds of the child window should be fully in the parent.
diff --git a/chromium/ui/views/widget/native_widget_aura.cc b/chromium/ui/views/widget/native_widget_aura.cc
index efd53803fa4..51f57997afa 100644
--- a/chromium/ui/views/widget/native_widget_aura.cc
+++ b/chromium/ui/views/widget/native_widget_aura.cc
@@ -1072,7 +1072,7 @@ void NativeWidgetAura::SetInitialFocus(ui::WindowShowState show_state) {
// Widget, public:
namespace {
-#if BUILDFLAG(ENABLE_DESKTOP_AURA)
+#if BUILDFLAG(ENABLE_DESKTOP_AURA) && (defined(OS_WIN) || defined(OS_LINUX))
void CloseWindow(aura::Window* window) {
if (window) {
Widget* widget = Widget::GetWidgetForNativeView(window);
diff --git a/chromium/ui/views/widget/native_widget_aura_interactive_uitest.cc b/chromium/ui/views/widget/native_widget_aura_interactive_uitest.cc
index 6715dff1b73..6e13e1376a9 100644
--- a/chromium/ui/views/widget/native_widget_aura_interactive_uitest.cc
+++ b/chromium/ui/views/widget/native_widget_aura_interactive_uitest.cc
@@ -7,7 +7,6 @@
#include "ui/aura/window.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/test/native_widget_factory.h"
-#include "ui/views/test/views_interactive_ui_test_base.h"
#include "ui/views/test/widget_test.h"
#include "ui/wm/core/base_focus_rules.h"
#include "ui/wm/core/focus_controller.h"
@@ -41,7 +40,7 @@ class TestFocusRules : public wm::BaseFocusRules {
} // namespace
-using NativeWidgetAuraTest = ViewsInteractiveUITestBase;
+using NativeWidgetAuraTest = DesktopWidgetTestInteractive;
// When requesting view focus from a non-active top level widget, focus is not
// instantly given. Instead, the view is firstly stored and then it is attempted
@@ -58,7 +57,7 @@ TEST_F(NativeWidgetAuraTest, NonActiveWindowRequestImeFocus) {
Widget::InitParams params1(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
params1.context = GetContext();
params1.native_widget =
- CreatePlatformNativeWidgetImpl(params1, widget1, kDefault, nullptr);
+ CreatePlatformNativeWidgetImpl(widget1, kDefault, nullptr);
params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
widget1->Init(std::move(params1));
Textfield* textfield1 = new Textfield;
@@ -68,7 +67,7 @@ TEST_F(NativeWidgetAuraTest, NonActiveWindowRequestImeFocus) {
Widget::InitParams params2(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
params2.context = GetContext();
params2.native_widget =
- CreatePlatformNativeWidgetImpl(params2, widget2, kDefault, nullptr);
+ CreatePlatformNativeWidgetImpl(widget2, kDefault, nullptr);
params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
widget2->Init(std::move(params2));
Textfield* textfield2a = new Textfield;
diff --git a/chromium/ui/views/widget/native_widget_aura_unittest.cc b/chromium/ui/views/widget/native_widget_aura_unittest.cc
index 5bd2526da57..4e9ce929364 100644
--- a/chromium/ui/views/widget/native_widget_aura_unittest.cc
+++ b/chromium/ui/views/widget/native_widget_aura_unittest.cc
@@ -413,9 +413,9 @@ TEST_F(NativeWidgetAuraTest, DontCaptureOnGesture) {
widget->SetContentsView(view);
widget->Show();
- ui::TouchEvent press(
- ui::ET_TOUCH_PRESSED, gfx::Point(41, 51), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::TouchEvent press(ui::ET_TOUCH_PRESSED, gfx::Point(41, 51),
+ ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
ui::EventDispatchDetails details = event_sink()->OnEventFromSource(&press);
ASSERT_FALSE(details.dispatcher_destroyed);
// Both views should get the press.
@@ -428,9 +428,9 @@ TEST_F(NativeWidgetAuraTest, DontCaptureOnGesture) {
// Release touch. Only |view| should get the release since that it consumed
// the press.
- ui::TouchEvent release(
- ui::ET_TOUCH_RELEASED, gfx::Point(250, 251), ui::EventTimeForNow(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(250, 251),
+ ui::EventTimeForNow(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
details = event_sink()->OnEventFromSource(&release);
ASSERT_FALSE(details.dispatcher_destroyed);
EXPECT_TRUE(view->got_gesture_event());
diff --git a/chromium/ui/views/widget/native_widget_mac_unittest.mm b/chromium/ui/views/widget/native_widget_mac_unittest.mm
index 90c111179a7..9a6b9ac6e90 100644
--- a/chromium/ui/views/widget/native_widget_mac_unittest.mm
+++ b/chromium/ui/views/widget/native_widget_mac_unittest.mm
@@ -232,30 +232,6 @@ class WidgetChangeObserver : public TestWidgetObserver {
DISALLOW_COPY_AND_ASSIGN(WidgetChangeObserver);
};
-class NativeHostHolder {
- public:
- NativeHostHolder()
- : view_([[NSView alloc] init]), host_(new NativeViewHost()) {
- host_->set_owned_by_client();
- }
-
- void AttachNativeView() {
- DCHECK(!host_->native_view());
- host_->Attach(view_.get());
- }
-
- void Detach() { host_->Detach(); }
-
- NSView* view() const { return view_.get(); }
- NativeViewHost* host() const { return host_.get(); }
-
- private:
- base::scoped_nsobject<NSView> view_;
- std::unique_ptr<NativeViewHost> host_;
-
- DISALLOW_COPY_AND_ASSIGN(NativeHostHolder);
-};
-
// This class gives public access to the protected ctor of
// BubbleDialogDelegateView.
class SimpleBubbleView : public BubbleDialogDelegateView {
@@ -1624,8 +1600,8 @@ class ParentCloseMonitor : public WidgetObserver {
Widget::InitParams init_params(Widget::InitParams::TYPE_WINDOW_FRAMELESS);
init_params.parent = parent->GetNativeView();
init_params.bounds = gfx::Rect(100, 100, 100, 100);
- init_params.native_widget = CreatePlatformNativeWidgetImpl(
- init_params, child, kStubCapture, nullptr);
+ init_params.native_widget =
+ CreatePlatformNativeWidgetImpl(child, kStubCapture, nullptr);
child->Init(std::move(init_params));
child->Show();
@@ -1814,7 +1790,7 @@ TEST_F(NativeWidgetMacTest, DISABLED_DoesHideTitle) {
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
Widget* widget = new Widget;
params.native_widget =
- CreatePlatformNativeWidgetImpl(params, widget, kStubCapture, nullptr);
+ CreatePlatformNativeWidgetImpl(widget, kStubCapture, nullptr);
CustomTitleWidgetDelegate delegate(widget);
params.delegate = &delegate;
params.bounds = gfx::Rect(0, 0, 800, 600);
@@ -2247,6 +2223,29 @@ class NativeWidgetMacViewsOrderTest : public WidgetTest {
NativeWidgetMacViewsOrderTest() {}
protected:
+ class NativeHostHolder {
+ public:
+ static std::unique_ptr<NativeHostHolder> CreateAndAddToParent(
+ View* parent) {
+ std::unique_ptr<NativeHostHolder> holder(new NativeHostHolder(
+ parent->AddChildView(std::make_unique<NativeViewHost>())));
+ holder->host()->Attach(holder->view());
+ return holder;
+ }
+
+ NSView* view() const { return view_.get(); }
+ NativeViewHost* host() const { return host_; }
+
+ private:
+ NativeHostHolder(NativeViewHost* host)
+ : host_(host), view_([[NSView alloc] init]) {}
+
+ NativeViewHost* const host_;
+ base::scoped_nsobject<NSView> view_;
+
+ DISALLOW_COPY_AND_ASSIGN(NativeHostHolder);
+ };
+
// testing::Test:
void SetUp() override {
WidgetTest::SetUp();
@@ -2261,10 +2260,8 @@ class NativeWidgetMacViewsOrderTest : public WidgetTest {
const size_t kNativeViewCount = 3;
for (size_t i = 0; i < kNativeViewCount; ++i) {
- auto holder = std::make_unique<NativeHostHolder>();
- native_host_parent_->AddChildView(holder->host());
- holder->AttachNativeView();
- hosts_.push_back(std::move(holder));
+ hosts_.push_back(
+ NativeHostHolder::CreateAndAddToParent(native_host_parent_));
}
EXPECT_EQ(kNativeViewCount, native_host_parent_->children().size());
EXPECT_NSEQ([widget_->GetNativeView().GetNativeNSView() subviews],
@@ -2275,6 +2272,7 @@ class NativeWidgetMacViewsOrderTest : public WidgetTest {
void TearDown() override {
widget_->CloseNow();
+ hosts_.clear();
WidgetTest::TearDown();
}
@@ -2296,13 +2294,14 @@ class NativeWidgetMacViewsOrderTest : public WidgetTest {
// Test that NativeViewHost::Attach()/Detach() method saves the NativeView
// z-order.
TEST_F(NativeWidgetMacViewsOrderTest, NativeViewAttached) {
- hosts_[1]->Detach();
+ NativeHostHolder* second_host = hosts_[1].get();
+ second_host->host()->Detach();
EXPECT_NSEQ([GetContentNativeView() subviews],
([GetStartingSubviews() arrayByAddingObjectsFromArray:@[
hosts_[0]->view(), hosts_[2]->view()
]]));
- hosts_[1]->AttachNativeView();
+ second_host->host()->Attach(second_host->view());
EXPECT_NSEQ([GetContentNativeView() subviews],
([GetStartingSubviews() arrayByAddingObjectsFromArray:@[
hosts_[0]->view(), hosts_[1]->view(), hosts_[2]->view()
diff --git a/chromium/ui/views/widget/tooltip_manager_aura.cc b/chromium/ui/views/widget/tooltip_manager_aura.cc
index ca24a4c51b5..2aceae76419 100644
--- a/chromium/ui/views/widget/tooltip_manager_aura.cc
+++ b/chromium/ui/views/widget/tooltip_manager_aura.cc
@@ -4,7 +4,6 @@
#include "ui/views/widget/tooltip_manager_aura.h"
-#include "base/logging.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_tree_host.h"
diff --git a/chromium/ui/views/widget/widget.cc b/chromium/ui/views/widget/widget.cc
index 6472b4210a0..ecd7be9185f 100644
--- a/chromium/ui/views/widget/widget.cc
+++ b/chromium/ui/views/widget/widget.cc
@@ -8,9 +8,10 @@
#include <utility>
#include "base/auto_reset.h"
+#include "base/check_op.h"
#include "base/containers/adapters.h"
-#include "base/logging.h"
#include "base/macros.h"
+#include "base/notreached.h"
#include "base/strings/utf_string_conversions.h"
#include "base/trace_event/trace_event.h"
#include "ui/base/cursor/cursor.h"
@@ -92,19 +93,18 @@ bool Widget::g_disable_activation_change_handling_ = false;
// WidgetDelegate is supplied.
class DefaultWidgetDelegate : public WidgetDelegate {
public:
- explicit DefaultWidgetDelegate(Widget* widget) : widget_(widget) {}
+ explicit DefaultWidgetDelegate(Widget* widget) : widget_(widget) {
+ // In most situations where a Widget is used without a delegate the Widget
+ // is used as a container, so that we want focus to advance to the top-level
+ // widget. A good example of this is the find bar.
+ SetFocusTraversesOut(true);
+ }
~DefaultWidgetDelegate() override = default;
// WidgetDelegate:
void DeleteDelegate() override { delete this; }
Widget* GetWidget() override { return widget_; }
const Widget* GetWidget() const override { return widget_; }
- bool ShouldAdvanceFocusToTopLevelWidget() const override {
- // In most situations where a Widget is used without a delegate the Widget
- // is used as a container, so that we want focus to advance to the top-level
- // widget. A good example of this is the find bar.
- return true;
- }
private:
Widget* widget_;
@@ -162,10 +162,8 @@ ui::ZOrderLevel Widget::InitParams::EffectiveZOrderLevel() const {
switch (type) {
case TYPE_MENU:
return ui::ZOrderLevel::kFloatingWindow;
- break;
case TYPE_DRAG:
return ui::ZOrderLevel::kFloatingUIElement;
- break;
default:
return ui::ZOrderLevel::kNormal;
}
@@ -769,7 +767,7 @@ bool Widget::IsVisible() const {
const ui::ThemeProvider* Widget::GetThemeProvider() const {
const Widget* root_widget = GetTopLevelWidget();
return (root_widget && root_widget != this) ? root_widget->GetThemeProvider()
- : &default_theme_provider_;
+ : nullptr;
}
FocusManager* Widget::GetFocusManager() {
diff --git a/chromium/ui/views/widget/widget.h b/chromium/ui/views/widget/widget.h
index 105fc39ed5e..0cbc349dd3d 100644
--- a/chromium/ui/views/widget/widget.h
+++ b/chromium/ui/views/widget/widget.h
@@ -16,7 +16,6 @@
#include "base/optional.h"
#include "base/scoped_observer.h"
#include "build/build_config.h"
-#include "ui/base/default_theme_provider.h"
#include "ui/base/ui_base_types.h"
#include "ui/events/event_source.h"
#include "ui/gfx/geometry/rect.h"
@@ -498,7 +497,18 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
// Sets the specified view as the contents of this Widget. There can only
// be one contents view child of this Widget's RootView. This view is sized to
// fit the entire size of the RootView. The RootView takes ownership of this
- // View, unless it is set as not being parent-owned.
+ // View, unless it is passed in as a raw pointer and set as not being
+ // parent-owned. Prefer using SetContentsView(std::unique_ptr) over passing a
+ // raw pointer for new code.
+ template <typename T>
+ T* SetContentsView(std::unique_ptr<T> view) {
+ DCHECK(!view->owned_by_client())
+ << "This should only be called if the client is passing over the "
+ "ownership of |view|.";
+ T* raw_pointer = view.get();
+ SetContentsView(view.release());
+ return raw_pointer;
+ }
void SetContentsView(View* view);
// NOTE: This may not be the same view as WidgetDelegate::GetContentsView().
@@ -1050,9 +1060,6 @@ class VIEWS_EXPORT Widget : public internal::NativeWidgetDelegate,
// must be destroyed AFTER root_view_. This is enforced in DestroyRootView().
std::unique_ptr<FocusManager> focus_manager_;
- // A theme provider to use when no other theme provider is specified.
- const ui::DefaultThemeProvider default_theme_provider_;
-
// Valid for the lifetime of RunShellDrag(), indicates the view the drag
// started from.
View* dragged_view_ = nullptr;
diff --git a/chromium/ui/views/widget/widget_aura_utils.cc b/chromium/ui/views/widget/widget_aura_utils.cc
index 85cedf9f62b..424460fe0ed 100644
--- a/chromium/ui/views/widget/widget_aura_utils.cc
+++ b/chromium/ui/views/widget/widget_aura_utils.cc
@@ -4,7 +4,7 @@
#include "ui/views/widget/widget_aura_utils.h"
-#include "base/logging.h"
+#include "base/notreached.h"
namespace views {
diff --git a/chromium/ui/views/widget/widget_delegate.cc b/chromium/ui/views/widget/widget_delegate.cc
index 1d7c735d497..4ba80f860b3 100644
--- a/chromium/ui/views/widget/widget_delegate.cc
+++ b/chromium/ui/views/widget/widget_delegate.cc
@@ -4,7 +4,7 @@
#include "ui/views/widget/widget_delegate.h"
-#include "base/logging.h"
+#include "base/check.h"
#include "base/strings/utf_string_conversions.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/display/display.h"
@@ -20,6 +20,9 @@ namespace views {
////////////////////////////////////////////////////////////////////////////////
// WidgetDelegate:
+WidgetDelegate::Params::Params() = default;
+WidgetDelegate::Params::~Params() = default;
+
WidgetDelegate::WidgetDelegate() = default;
WidgetDelegate::~WidgetDelegate() {
CHECK(can_delete_this_) << "A WidgetDelegate must outlive its Widget";
@@ -52,15 +55,15 @@ DialogDelegate* WidgetDelegate::AsDialogDelegate() {
}
bool WidgetDelegate::CanResize() const {
- return false;
+ return params_.can_resize;
}
bool WidgetDelegate::CanMaximize() const {
- return false;
+ return params_.can_maximize;
}
bool WidgetDelegate::CanMinimize() const {
- return false;
+ return params_.can_minimize;
}
bool WidgetDelegate::CanActivate() const {
@@ -80,19 +83,23 @@ base::string16 WidgetDelegate::GetAccessibleWindowTitle() const {
}
base::string16 WidgetDelegate::GetWindowTitle() const {
- return base::string16();
+ return params_.title;
}
bool WidgetDelegate::ShouldShowWindowTitle() const {
- return true;
+ return params_.show_title;
}
bool WidgetDelegate::ShouldCenterWindowTitleText() const {
+#if defined(USE_AURA)
+ return params_.center_title;
+#else
return false;
+#endif
}
bool WidgetDelegate::ShouldShowCloseButton() const {
- return true;
+ return params_.show_close_button;
}
gfx::ImageSkia WidgetDelegate::GetWindowAppIcon() {
@@ -102,11 +109,11 @@ gfx::ImageSkia WidgetDelegate::GetWindowAppIcon() {
// Returns the icon to be displayed in the window.
gfx::ImageSkia WidgetDelegate::GetWindowIcon() {
- return gfx::ImageSkia();
+ return params_.icon;
}
bool WidgetDelegate::ShouldShowWindowIcon() const {
- return false;
+ return params_.show_icon;
}
bool WidgetDelegate::ExecuteWindowsCommand(int command_id) {
@@ -145,6 +152,24 @@ bool WidgetDelegate::ShouldRestoreWindowSize() const {
return true;
}
+void WidgetDelegate::WindowWillClose() {
+ // TODO(ellyjones): For this and the other callback methods, establish whether
+ // any other code calls these methods. If not, DCHECK here and below that
+ // these methods are only called once.
+ for (auto&& callback : window_will_close_callbacks_)
+ std::move(callback).Run();
+}
+
+void WidgetDelegate::WindowClosing() {
+ for (auto&& callback : window_closing_callbacks_)
+ std::move(callback).Run();
+}
+
+void WidgetDelegate::DeleteDelegate() {
+ for (auto&& callback : delete_delegate_callbacks_)
+ std::move(callback).Run();
+}
+
View* WidgetDelegate::GetContentsView() {
if (!default_contents_view_)
default_contents_view_ = new View;
@@ -175,16 +200,72 @@ void WidgetDelegate::GetWidgetHitTestMask(SkPath* mask) const {
DCHECK(mask);
}
-bool WidgetDelegate::ShouldAdvanceFocusToTopLevelWidget() const {
- return false;
-}
-
bool WidgetDelegate::ShouldDescendIntoChildForEventHandling(
gfx::NativeView child,
const gfx::Point& location) {
return true;
}
+void WidgetDelegate::SetCanMaximize(bool can_maximize) {
+ params_.can_maximize = can_maximize;
+}
+
+void WidgetDelegate::SetCanMinimize(bool can_minimize) {
+ params_.can_minimize = can_minimize;
+}
+
+void WidgetDelegate::SetCanResize(bool can_resize) {
+ params_.can_resize = can_resize;
+}
+
+void WidgetDelegate::SetFocusTraversesOut(bool focus_traverses_out) {
+ params_.focus_traverses_out = focus_traverses_out;
+}
+
+void WidgetDelegate::SetIcon(const gfx::ImageSkia& icon) {
+ params_.icon = icon;
+}
+
+void WidgetDelegate::SetShowCloseButton(bool show_close_button) {
+ params_.show_close_button = show_close_button;
+}
+
+void WidgetDelegate::SetShowIcon(bool show_icon) {
+ params_.show_icon = show_icon;
+}
+
+void WidgetDelegate::SetShowTitle(bool show_title) {
+ params_.show_title = show_title;
+}
+
+void WidgetDelegate::SetTitle(const base::string16& title) {
+ if (params_.title == title)
+ return;
+ params_.title = title;
+ if (GetWidget())
+ GetWidget()->UpdateWindowTitle();
+}
+
+#if defined(USE_AURA)
+void WidgetDelegate::SetCenterTitle(bool center_title) {
+ params_.center_title = center_title;
+}
+#endif
+
+void WidgetDelegate::RegisterWindowWillCloseCallback(
+ base::OnceClosure callback) {
+ window_will_close_callbacks_.emplace_back(std::move(callback));
+}
+
+void WidgetDelegate::RegisterWindowClosingCallback(base::OnceClosure callback) {
+ window_closing_callbacks_.emplace_back(std::move(callback));
+}
+
+void WidgetDelegate::RegisterDeleteDelegateCallback(
+ base::OnceClosure callback) {
+ delete_delegate_callbacks_.emplace_back(std::move(callback));
+}
+
////////////////////////////////////////////////////////////////////////////////
// WidgetDelegateView:
diff --git a/chromium/ui/views/widget/widget_delegate.h b/chromium/ui/views/widget/widget_delegate.h
index a3ec229f11c..23396ad8c3a 100644
--- a/chromium/ui/views/widget/widget_delegate.h
+++ b/chromium/ui/views/widget/widget_delegate.h
@@ -29,6 +29,44 @@ class View;
// Handles events on Widgets in context-specific ways.
class VIEWS_EXPORT WidgetDelegate {
public:
+ struct Params {
+ Params();
+ ~Params();
+
+ // Whether the window should display controls for the user to minimize,
+ // maximize, or resize it.
+ bool can_maximize = false;
+ bool can_minimize = false;
+ bool can_resize = false;
+
+#if defined(USE_AURA)
+ // Whether to center the widget's title within the frame.
+ bool center_title = false;
+#endif
+
+ // Controls focus traversal past the first/last focusable view.
+ // If true, focus moves out of this Widget and to this Widget's toplevel
+ // Widget; if false, focus cycles within this Widget.
+ bool focus_traverses_out = false;
+
+ // The widget's icon, if any.
+ gfx::ImageSkia icon;
+
+ // Whether to show a close button in the widget frame.
+ bool show_close_button = true;
+
+ // Whether to show the widget's icon.
+ // TODO(ellyjones): What if this was implied by !icon.isNull()?
+ bool show_icon = false;
+
+ // Whether to display the widget's title in the frame.
+ bool show_title = true;
+
+ // The widget's title, if any.
+ // TODO(ellyjones): Should it be illegal to have show_title && !title?
+ base::string16 title;
+ };
+
WidgetDelegate();
// Sets the return value of CanActivate(). Default is true.
@@ -90,9 +128,6 @@ class VIEWS_EXPORT WidgetDelegate {
// Returns true if the window should show a title in the title bar.
virtual bool ShouldShowWindowTitle() const;
- // Returns true if the title text should be centered. Default is false.
- virtual bool ShouldCenterWindowTitleText() const;
-
// Returns true if the window should show a close button in the title bar.
virtual bool ShouldShowCloseButton() const;
@@ -146,9 +181,12 @@ class VIEWS_EXPORT WidgetDelegate {
// Close() or CloseNow().
// Important note: for OS-initiated window closes, steps 1 and 2 don't happen
// - i.e, WindowWillClose() is never invoked.
- virtual void WindowWillClose() {}
- virtual void WindowClosing() {}
- virtual void DeleteDelegate() {}
+ //
+ // The default implementations of these methods simply call the corresponding
+ // callbacks; see Set*Callback() below. If you override these it is not
+ // necessary to call the base implementations.
+ virtual void WindowClosing();
+ virtual void DeleteDelegate();
// Called when the user begins/ends to change the bounds of the window.
virtual void OnWindowBeginUserBoundsChange() {}
@@ -187,11 +225,6 @@ class VIEWS_EXPORT WidgetDelegate {
// Provides the hit-test mask if HasHitTestMask above returns true.
virtual void GetWidgetHitTestMask(SkPath* mask) const;
- // Returns true if focus should advance to the top level widget when
- // tab/shift-tab is hit and on the last/first focusable view. Default returns
- // false, which means tab/shift-tab never advance to the top level Widget.
- virtual bool ShouldAdvanceFocusToTopLevelWidget() const;
-
// Returns true if event handling should descend into |child|.
// |location| is in terms of the Window.
virtual bool ShouldDescendIntoChildForEventHandling(
@@ -202,18 +235,52 @@ class VIEWS_EXPORT WidgetDelegate {
// be cycled through with keyboard focus.
virtual void GetAccessiblePanes(std::vector<View*>* panes) {}
+ // Setters for data parameters of the WidgetDelegate. If you use these
+ // setters, there is no need to override the corresponding virtual getters.
+ void SetCanMaximize(bool can_maximize);
+ void SetCanMinimize(bool can_minimize);
+ void SetCanResize(bool can_resize);
+ void SetFocusTraversesOut(bool focus_traverses_out);
+ void SetIcon(const gfx::ImageSkia& icon);
+ void SetShowCloseButton(bool show_close_button);
+ void SetShowIcon(bool show_icon);
+ void SetShowTitle(bool show_title);
+ void SetTitle(const base::string16& title);
+#if defined(USE_AURA)
+ void SetCenterTitle(bool center_title);
+#endif
+
+ void RegisterWindowWillCloseCallback(base::OnceClosure callback);
+ void RegisterWindowClosingCallback(base::OnceClosure callback);
+ void RegisterDeleteDelegateCallback(base::OnceClosure callback);
+
+ // Call this to notify the WidgetDelegate that its Widget is about to start
+ // closing.
+ void WindowWillClose();
+
+ // Returns true if the title text should be centered.
+ bool ShouldCenterWindowTitleText() const;
+
+ bool focus_traverses_out() const { return params_.focus_traverses_out; }
+
protected:
virtual ~WidgetDelegate();
private:
friend class Widget;
+ Params params_;
+
View* default_contents_view_ = nullptr;
bool can_activate_ = true;
// Managed by Widget. Ensures |this| outlives its Widget.
bool can_delete_this_ = true;
+ std::vector<base::OnceClosure> window_will_close_callbacks_;
+ std::vector<base::OnceClosure> window_closing_callbacks_;
+ std::vector<base::OnceClosure> delete_delegate_callbacks_;
+
DISALLOW_COPY_AND_ASSIGN(WidgetDelegate);
};
diff --git a/chromium/ui/views/widget/widget_interactive_uitest.cc b/chromium/ui/views/widget/widget_interactive_uitest.cc
index 0f50819e3c4..f4ba5ba6cad 100644
--- a/chromium/ui/views/widget/widget_interactive_uitest.cc
+++ b/chromium/ui/views/widget/widget_interactive_uitest.cc
@@ -29,12 +29,12 @@
#include "ui/events/event_utils.h"
#include "ui/events/test/event_generator.h"
#include "ui/gfx/native_widget_types.h"
+#include "ui/views/bubble/bubble_dialog_delegate_view.h"
#include "ui/views/controls/textfield/textfield.h"
#include "ui/views/controls/textfield/textfield_test_api.h"
#include "ui/views/focus/focus_manager.h"
#include "ui/views/test/focus_manager_test.h"
#include "ui/views/test/native_widget_factory.h"
-#include "ui/views/test/views_interactive_ui_test_base.h"
#include "ui/views/test/widget_test.h"
#include "ui/views/touchui/touch_selection_controller_impl.h"
#include "ui/views/widget/root_view.h"
@@ -290,39 +290,6 @@ class WidgetTestInteractive : public WidgetTest {
SetUpForInteractiveTests();
WidgetTest::SetUp();
}
-
- protected:
-#if defined(USE_AURA)
- static void ShowQuickMenuImmediately(
- TouchSelectionControllerImpl* controller) {
- DCHECK(controller);
- if (controller->quick_menu_timer_.IsRunning()) {
- controller->quick_menu_timer_.Stop();
- controller->QuickMenuTimerFired();
- }
- }
-#endif // defined (USE_AURA)
-};
-
-class DesktopWidgetTestInteractive : public WidgetTestInteractive {
- public:
- DesktopWidgetTestInteractive() = default;
- ~DesktopWidgetTestInteractive() override = default;
-
- // WidgetTestInteractive:
- void SetUp() override {
- set_native_widget_type(NativeWidgetType::kDesktop);
- WidgetTestInteractive::SetUp();
- }
-
- protected:
- Widget* CreateWidget() {
- Widget* widget = CreateTopLevelNativeWidget();
- widget->SetBounds(gfx::Rect(0, 0, 200, 200));
- return widget;
- }
-
- DISALLOW_COPY_AND_ASSIGN(DesktopWidgetTestInteractive);
};
#if defined(OS_WIN)
@@ -340,10 +307,10 @@ TEST_F(DesktopWidgetTestInteractive,
// Create widget 1 and expect the active window to be its window.
View* focusable_view1 = new View;
focusable_view1->SetFocusBehavior(View::FocusBehavior::ALWAYS);
- Widget* widget1 = CreateWidget();
+ WidgetAutoclosePtr widget1(CreateTopLevelNativeWidget());
widget1->GetContentsView()->AddChildView(focusable_view1);
widget1->Show();
- aura::Window* root_window1 = GetRootWindow(widget1);
+ aura::Window* root_window1 = GetRootWindow(widget1.get());
focusable_view1->RequestFocus();
EXPECT_TRUE(root_window1 != nullptr);
@@ -354,12 +321,12 @@ TEST_F(DesktopWidgetTestInteractive,
// Create widget 2 and expect the active window to be its window.
View* focusable_view2 = new View;
- Widget* widget2 = CreateWidget();
+ WidgetAutoclosePtr widget2(CreateTopLevelNativeWidget());
widget1->GetContentsView()->AddChildView(focusable_view2);
widget2->Show();
- aura::Window* root_window2 = GetRootWindow(widget2);
+ aura::Window* root_window2 = GetRootWindow(widget2.get());
focusable_view2->RequestFocus();
- ActivatePlatformWindow(widget2);
+ ActivatePlatformWindow(widget2.get());
wm::ActivationClient* activation_client2 =
wm::GetActivationClient(root_window2);
@@ -371,13 +338,41 @@ TEST_F(DesktopWidgetTestInteractive,
// Now set focus back to widget 1 and expect the active window to be its
// window.
focusable_view1->RequestFocus();
- ActivatePlatformWindow(widget1);
+ ActivatePlatformWindow(widget1.get());
EXPECT_EQ(activation_client2->GetActiveWindow(),
reinterpret_cast<aura::Window*>(NULL));
EXPECT_EQ(activation_client1->GetActiveWindow(), widget1->GetNativeView());
+}
- widget2->CloseNow();
- widget1->CloseNow();
+// Verifies bubbles result in a focus lost when shown.
+TEST_F(DesktopWidgetTestInteractive, FocusChangesOnBubble) {
+ WidgetAutoclosePtr widget(CreateTopLevelNativeWidget());
+ View* focusable_view =
+ widget->GetContentsView()->AddChildView(std::make_unique<View>());
+ focusable_view->SetFocusBehavior(View::FocusBehavior::ALWAYS);
+ widget->Show();
+ focusable_view->RequestFocus();
+ EXPECT_TRUE(focusable_view->HasFocus());
+
+ // Show a bubble.
+ auto owned_bubble_delegate_view =
+ std::make_unique<views::BubbleDialogDelegateView>(focusable_view,
+ BubbleBorder::NONE);
+ owned_bubble_delegate_view->SetFocusBehavior(View::FocusBehavior::ALWAYS);
+ BubbleDialogDelegateView* bubble_delegate_view =
+ owned_bubble_delegate_view.get();
+ BubbleDialogDelegateView::CreateBubble(owned_bubble_delegate_view.release())
+ ->Show();
+ bubble_delegate_view->RequestFocus();
+
+ // |focusable_view| should no longer have focus.
+ EXPECT_FALSE(focusable_view->HasFocus());
+ EXPECT_TRUE(bubble_delegate_view->HasFocus());
+
+ bubble_delegate_view->GetWidget()->CloseNow();
+
+ // Closing the bubble should result in focus going back to the contents view.
+ EXPECT_TRUE(focusable_view->HasFocus());
}
class TouchEventHandler : public ui::EventHandler {
@@ -433,210 +428,23 @@ TEST_F(DesktopWidgetTestInteractive, DISABLED_TouchNoActivateWindow) {
View* focusable_view = new View;
focusable_view->SetFocusBehavior(View::FocusBehavior::ALWAYS);
- Widget* widget = CreateWidget();
+ WidgetAutoclosePtr widget(CreateTopLevelNativeWidget());
widget->GetContentsView()->AddChildView(focusable_view);
widget->Show();
{
- TouchEventHandler touch_event_handler(widget);
+ TouchEventHandler touch_event_handler(widget.get());
ASSERT_TRUE(ui_controls::SendTouchEvents(ui_controls::PRESS, 1, 100, 100));
touch_event_handler.WaitForEvents();
}
-
- widget->CloseNow();
}
#endif // defined(OS_WIN)
-TEST_F(WidgetTestInteractive, CaptureAutoReset) {
- Widget* toplevel = CreateTopLevelFramelessPlatformWidget();
- View* container = new View;
- toplevel->SetContentsView(container);
-
- EXPECT_FALSE(toplevel->HasCapture());
- toplevel->SetCapture(nullptr);
- EXPECT_TRUE(toplevel->HasCapture());
-
- // By default, mouse release removes capture.
- gfx::Point click_location(45, 15);
- ui::MouseEvent release(ui::ET_MOUSE_RELEASED, click_location, click_location,
- ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
- ui::EF_LEFT_MOUSE_BUTTON);
- toplevel->OnMouseEvent(&release);
- EXPECT_FALSE(toplevel->HasCapture());
-
- // Now a mouse release shouldn't remove capture.
- toplevel->set_auto_release_capture(false);
- toplevel->SetCapture(nullptr);
- EXPECT_TRUE(toplevel->HasCapture());
- toplevel->OnMouseEvent(&release);
- EXPECT_TRUE(toplevel->HasCapture());
- toplevel->ReleaseCapture();
- EXPECT_FALSE(toplevel->HasCapture());
-
- toplevel->Close();
- RunPendingMessages();
-}
-
-TEST_F(WidgetTestInteractive, ResetCaptureOnGestureEnd) {
- Widget* toplevel = CreateTopLevelFramelessPlatformWidget();
- View* container = new View;
- toplevel->SetContentsView(container);
-
- View* gesture = new GestureCaptureView;
- gesture->SetBounds(0, 0, 30, 30);
- container->AddChildView(gesture);
-
- MouseView* mouse = new MouseView;
- mouse->SetBounds(30, 0, 30, 30);
- container->AddChildView(mouse);
-
- toplevel->SetSize(gfx::Size(100, 100));
- toplevel->Show();
-
- // Start a gesture on |gesture|.
- ui::GestureEvent tap_down(15, 15, 0, base::TimeTicks(),
- ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN));
- ui::GestureEvent end(15, 15, 0, base::TimeTicks(),
- ui::GestureEventDetails(ui::ET_GESTURE_END));
- toplevel->OnGestureEvent(&tap_down);
-
- // Now try to click on |mouse|. Since |gesture| will have capture, |mouse|
- // will not receive the event.
- gfx::Point click_location(45, 15);
-
- ui::MouseEvent press(ui::ET_MOUSE_PRESSED, click_location, click_location,
- ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
- ui::EF_LEFT_MOUSE_BUTTON);
- ui::MouseEvent release(ui::ET_MOUSE_RELEASED, click_location, click_location,
- ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
- ui::EF_LEFT_MOUSE_BUTTON);
-
- EXPECT_TRUE(toplevel->HasCapture());
-
- toplevel->OnMouseEvent(&press);
- toplevel->OnMouseEvent(&release);
- EXPECT_EQ(0, mouse->pressed());
-
- EXPECT_FALSE(toplevel->HasCapture());
-
- // The end of the gesture should release the capture, and pressing on |mouse|
- // should now reach |mouse|.
- toplevel->OnGestureEvent(&end);
- toplevel->OnMouseEvent(&press);
- toplevel->OnMouseEvent(&release);
- EXPECT_EQ(1, mouse->pressed());
-
- toplevel->Close();
- RunPendingMessages();
-}
-
-// Checks that if a mouse-press triggers a capture on a different widget (which
-// consumes the mouse-release event), then the target of the press does not have
-// capture.
-TEST_F(WidgetTestInteractive, DisableCaptureWidgetFromMousePress) {
- // The test creates two widgets: |first| and |second|.
- // The View in |first| makes |second| visible, sets capture on it, and starts
- // a nested loop (like a menu does). The View in |second| terminates the
- // nested loop and closes the widget.
- // The test sends a mouse-press event to |first|, and posts a task to send a
- // release event to |second|, to make sure that the release event is
- // dispatched after the nested loop starts.
-
- Widget* first = CreateTopLevelFramelessPlatformWidget();
- Widget* second = CreateTopLevelFramelessPlatformWidget();
-
- NestedLoopCaptureView* container = new NestedLoopCaptureView(second);
- first->SetContentsView(container);
-
- second->SetContentsView(new ExitLoopOnRelease(container->GetQuitClosure()));
-
- first->SetSize(gfx::Size(100, 100));
- first->Show();
-
- gfx::Point location(20, 20);
- base::ThreadTaskRunnerHandle::Get()->PostTask(
- FROM_HERE,
- base::BindOnce(
- &Widget::OnMouseEvent, base::Unretained(second),
- base::Owned(new ui::MouseEvent(
- ui::ET_MOUSE_RELEASED, location, location, ui::EventTimeForNow(),
- ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON))));
- ui::MouseEvent press(ui::ET_MOUSE_PRESSED, location, location,
- ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
- ui::EF_LEFT_MOUSE_BUTTON);
- first->OnMouseEvent(&press);
- EXPECT_FALSE(first->HasCapture());
- first->Close();
- RunPendingMessages();
-}
-
-// Tests some grab/ungrab events.
-// TODO(estade): can this be enabled now that this is an interactive ui test?
-TEST_F(WidgetTestInteractive, DISABLED_GrabUngrab) {
- Widget* toplevel = CreateTopLevelPlatformWidget();
- Widget* child1 = CreateChildNativeWidgetWithParent(toplevel);
- Widget* child2 = CreateChildNativeWidgetWithParent(toplevel);
-
- toplevel->SetBounds(gfx::Rect(0, 0, 500, 500));
-
- child1->SetBounds(gfx::Rect(10, 10, 300, 300));
- View* view = new MouseView();
- view->SetBounds(0, 0, 300, 300);
- child1->GetRootView()->AddChildView(view);
-
- child2->SetBounds(gfx::Rect(200, 10, 200, 200));
- view = new MouseView();
- view->SetBounds(0, 0, 200, 200);
- child2->GetRootView()->AddChildView(view);
-
- toplevel->Show();
- RunPendingMessages();
-
- // Click on child1
- gfx::Point p1(45, 45);
- ui::MouseEvent pressed(ui::ET_MOUSE_PRESSED, p1, p1, ui::EventTimeForNow(),
- ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
- toplevel->OnMouseEvent(&pressed);
-
- EXPECT_TRUE(toplevel->HasCapture());
- EXPECT_TRUE(child1->HasCapture());
- EXPECT_FALSE(child2->HasCapture());
-
- ui::MouseEvent released(ui::ET_MOUSE_RELEASED, p1, p1, ui::EventTimeForNow(),
- ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
- toplevel->OnMouseEvent(&released);
-
- EXPECT_FALSE(toplevel->HasCapture());
- EXPECT_FALSE(child1->HasCapture());
- EXPECT_FALSE(child2->HasCapture());
-
- RunPendingMessages();
-
- // Click on child2
- gfx::Point p2(315, 45);
- ui::MouseEvent pressed2(ui::ET_MOUSE_PRESSED, p2, p2, ui::EventTimeForNow(),
- ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
- toplevel->OnMouseEvent(&pressed2);
- EXPECT_TRUE(pressed2.handled());
- EXPECT_TRUE(toplevel->HasCapture());
- EXPECT_TRUE(child2->HasCapture());
- EXPECT_FALSE(child1->HasCapture());
-
- ui::MouseEvent released2(ui::ET_MOUSE_RELEASED, p2, p2, ui::EventTimeForNow(),
- ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON);
- toplevel->OnMouseEvent(&released2);
- EXPECT_FALSE(toplevel->HasCapture());
- EXPECT_FALSE(child1->HasCapture());
- EXPECT_FALSE(child2->HasCapture());
-
- toplevel->CloseNow();
-}
-
// Tests mouse move outside of the window into the "resize controller" and back
// will still generate an OnMouseEntered and OnMouseExited event..
TEST_F(WidgetTestInteractive, CheckResizeControllerEvents) {
- Widget* toplevel = CreateTopLevelFramelessPlatformWidget();
+ WidgetAutoclosePtr toplevel(CreateTopLevelFramelessPlatformWidget());
toplevel->SetBounds(gfx::Rect(0, 0, 100, 100));
@@ -678,20 +486,16 @@ TEST_F(WidgetTestInteractive, CheckResizeControllerEvents) {
toplevel->OnMouseEvent(&moved_over);
EXPECT_EQ(1, view->EnteredCalls());
EXPECT_EQ(0, view->ExitedCalls());
-
- RunPendingMessages();
-
- toplevel->CloseNow();
}
// Test view focus restoration when a widget is deactivated and re-activated.
TEST_F(WidgetTestInteractive, ViewFocusOnWidgetActivationChanges) {
- Widget* widget1 = CreateTopLevelPlatformWidget();
+ WidgetAutoclosePtr widget1(CreateTopLevelPlatformWidget());
View* view1 = new View;
view1->SetFocusBehavior(View::FocusBehavior::ALWAYS);
widget1->GetContentsView()->AddChildView(view1);
- Widget* widget2 = CreateTopLevelPlatformWidget();
+ WidgetAutoclosePtr widget2(CreateTopLevelPlatformWidget());
View* view2a = new View;
View* view2b = new View;
view2a->SetFocusBehavior(View::FocusBehavior::ALWAYS);
@@ -699,12 +503,12 @@ TEST_F(WidgetTestInteractive, ViewFocusOnWidgetActivationChanges) {
widget2->GetContentsView()->AddChildView(view2a);
widget2->GetContentsView()->AddChildView(view2b);
- ShowSync(widget1);
+ ShowSync(widget1.get());
EXPECT_TRUE(widget1->IsActive());
view1->RequestFocus();
EXPECT_EQ(view1, widget1->GetFocusManager()->GetFocusedView());
- ShowSync(widget2);
+ ShowSync(widget2.get());
EXPECT_TRUE(widget2->IsActive());
EXPECT_FALSE(widget1->IsActive());
EXPECT_EQ(nullptr, widget1->GetFocusManager()->GetFocusedView());
@@ -713,20 +517,17 @@ TEST_F(WidgetTestInteractive, ViewFocusOnWidgetActivationChanges) {
view2b->RequestFocus();
EXPECT_EQ(view2b, widget2->GetFocusManager()->GetFocusedView());
- ActivateSync(widget1);
+ ActivateSync(widget1.get());
EXPECT_TRUE(widget1->IsActive());
EXPECT_EQ(view1, widget1->GetFocusManager()->GetFocusedView());
EXPECT_FALSE(widget2->IsActive());
EXPECT_EQ(nullptr, widget2->GetFocusManager()->GetFocusedView());
- ActivateSync(widget2);
+ ActivateSync(widget2.get());
EXPECT_TRUE(widget2->IsActive());
EXPECT_EQ(view2b, widget2->GetFocusManager()->GetFocusedView());
EXPECT_FALSE(widget1->IsActive());
EXPECT_EQ(nullptr, widget1->GetFocusManager()->GetFocusedView());
-
- widget1->CloseNow();
- widget2->CloseNow();
}
// Test z-order of child widgets relative to their parent.
@@ -801,7 +602,7 @@ TEST_F(WidgetTestInteractive, ChildStackedRelativeToParent) {
// Test view focus retention when a widget's HWND is disabled and re-enabled.
TEST_F(WidgetTestInteractive, ViewFocusOnHWNDEnabledChanges) {
- Widget* widget = CreateTopLevelFramelessPlatformWidget();
+ WidgetAutoclosePtr widget(CreateTopLevelFramelessPlatformWidget());
widget->SetContentsView(new View);
for (size_t i = 0; i < 2; ++i) {
auto child = std::make_unique<View>();
@@ -811,7 +612,7 @@ TEST_F(WidgetTestInteractive, ViewFocusOnHWNDEnabledChanges) {
widget->Show();
widget->GetNativeWindow()->GetHost()->Show();
- const HWND hwnd = HWNDForWidget(widget);
+ const HWND hwnd = HWNDForWidget(widget.get());
EXPECT_TRUE(::IsWindow(hwnd));
EXPECT_TRUE(::IsWindowEnabled(hwnd));
EXPECT_EQ(hwnd, ::GetActiveWindow());
@@ -836,8 +637,6 @@ TEST_F(WidgetTestInteractive, ViewFocusOnHWNDEnabledChanges) {
EXPECT_TRUE(widget->IsActive());
EXPECT_EQ(view, widget->GetFocusManager()->GetFocusedView());
}
-
- widget->CloseNow();
}
// This class subclasses the Widget class to listen for activation change
@@ -1089,61 +888,6 @@ TEST_F(DesktopWidgetTestInteractive, WindowModalWindowDestroyedActivationTest) {
}
#endif
-// Disabled on Mac. Desktop Mac doesn't have system modal windows since Carbon
-// was deprecated. It does have application modal windows, but only Ash requests
-// those.
-#if defined(OS_MACOSX)
-#define MAYBE_SystemModalWindowReleasesCapture \
- DISABLED_SystemModalWindowReleasesCapture
-#elif defined(OS_CHROMEOS)
-// Investigate enabling for Chrome OS. It probably requires help from the window
-// service.
-#define MAYBE_SystemModalWindowReleasesCapture \
- DISABLED_SystemModalWindowReleasesCapture
-#else
-#define MAYBE_SystemModalWindowReleasesCapture SystemModalWindowReleasesCapture
-#endif
-
-// Test that when opening a system-modal window, capture is released.
-TEST_F(DesktopWidgetTestInteractive, MAYBE_SystemModalWindowReleasesCapture) {
- TestWidgetFocusChangeListener focus_listener;
- WidgetFocusManager::GetInstance()->AddFocusChangeListener(&focus_listener);
-
- // Create a top level widget.
- Widget top_level_widget;
- Widget::InitParams init_params =
- CreateParams(Widget::InitParams::TYPE_WINDOW);
- init_params.show_state = ui::SHOW_STATE_NORMAL;
- gfx::Rect initial_bounds(0, 0, 500, 500);
- init_params.bounds = initial_bounds;
- init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- top_level_widget.Init(std::move(init_params));
- ShowSync(&top_level_widget);
-
- ASSERT_FALSE(focus_listener.focus_changes().empty());
- EXPECT_EQ(top_level_widget.GetNativeView(),
- focus_listener.focus_changes().back());
-
- EXPECT_FALSE(top_level_widget.HasCapture());
- top_level_widget.SetCapture(nullptr);
- EXPECT_TRUE(top_level_widget.HasCapture());
-
- // Create a modal dialog.
- ModalDialogDelegate* dialog_delegate =
- new ModalDialogDelegate(ui::MODAL_TYPE_SYSTEM);
-
- Widget* modal_dialog_widget = views::DialogDelegate::CreateDialogWidget(
- dialog_delegate, nullptr, top_level_widget.GetNativeView());
- modal_dialog_widget->SetBounds(gfx::Rect(100, 100, 200, 200));
- ShowSync(modal_dialog_widget);
-
- EXPECT_FALSE(top_level_widget.HasCapture());
-
- modal_dialog_widget->CloseNow();
- top_level_widget.CloseNow();
- WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(&focus_listener);
-}
-
TEST_F(DesktopWidgetTestInteractive, CanActivateFlagIsHonored) {
Widget widget;
Widget::InitParams init_params =
@@ -1171,7 +915,8 @@ TEST_F(DesktopWidgetTestInteractive, CanActivateFlagIsHonored) {
// Test that touch selection quick menu is not activated when opened.
TEST_F(DesktopWidgetTestInteractive,
MAYBE_TouchSelectionQuickMenuIsNotActivated) {
- Widget* widget = CreateWidget();
+ WidgetAutoclosePtr widget(CreateTopLevelNativeWidget());
+ widget->SetBounds(gfx::Rect(0, 0, 200, 200));
Textfield* textfield = new Textfield;
textfield->SetBounds(0, 0, 200, 20);
@@ -1185,16 +930,16 @@ TEST_F(DesktopWidgetTestInteractive,
RunPendingMessages();
- ui::test::EventGenerator generator(GetRootWindow(widget));
+ ui::test::EventGenerator generator(GetRootWindow(widget.get()));
generator.GestureTapAt(textfield->GetBoundsInScreen().origin() +
gfx::Vector2d(10, 10));
- ShowQuickMenuImmediately(static_cast<TouchSelectionControllerImpl*>(
- textfield_test_api.touch_selection_controller()));
+ static_cast<TouchSelectionControllerImpl*>(
+ textfield_test_api.touch_selection_controller())
+ ->ShowQuickMenuImmediatelyForTesting();
EXPECT_TRUE(textfield->HasFocus());
EXPECT_TRUE(widget->IsActive());
EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning());
- widget->CloseNow();
}
#endif // defined(USE_AURA)
@@ -1253,90 +998,76 @@ TEST_F(WidgetTestInteractive, DisableViewDoesNotActivateWidget) {
} // namespace test
TEST_F(WidgetTestInteractive, ShowCreatesActiveWindow) {
- Widget* widget = CreateTopLevelPlatformWidget();
-
- ShowSync(widget);
- EXPECT_EQ(GetWidgetShowState(widget), ui::SHOW_STATE_NORMAL);
+ WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget());
- widget->CloseNow();
+ ShowSync(widget.get());
+ EXPECT_EQ(GetWidgetShowState(widget.get()), ui::SHOW_STATE_NORMAL);
}
TEST_F(WidgetTestInteractive, ShowInactive) {
WidgetTest::WaitForSystemAppActivation();
- Widget* widget = CreateTopLevelPlatformWidget();
+ WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget());
- ShowInactiveSync(widget);
- EXPECT_EQ(GetWidgetShowState(widget), ui::SHOW_STATE_INACTIVE);
-
- widget->CloseNow();
+ ShowInactiveSync(widget.get());
+ EXPECT_EQ(GetWidgetShowState(widget.get()), ui::SHOW_STATE_INACTIVE);
}
TEST_F(WidgetTestInteractive, InactiveBeforeShow) {
- Widget* widget = CreateTopLevelPlatformWidget();
+ WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget());
EXPECT_FALSE(widget->IsActive());
EXPECT_FALSE(widget->IsVisible());
- ShowSync(widget);
+ ShowSync(widget.get());
EXPECT_TRUE(widget->IsActive());
EXPECT_TRUE(widget->IsVisible());
-
- widget->CloseNow();
}
TEST_F(WidgetTestInteractive, ShowInactiveAfterShow) {
// Create 2 widgets to ensure window layering does not change.
- Widget* widget = CreateTopLevelPlatformWidget();
- Widget* widget2 = CreateTopLevelPlatformWidget();
+ WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget());
+ WidgetAutoclosePtr widget2(CreateTopLevelPlatformWidget());
- ShowSync(widget2);
+ ShowSync(widget2.get());
EXPECT_FALSE(widget->IsActive());
EXPECT_TRUE(widget2->IsVisible());
EXPECT_TRUE(widget2->IsActive());
- ShowSync(widget);
+ ShowSync(widget.get());
EXPECT_TRUE(widget->IsActive());
EXPECT_FALSE(widget2->IsActive());
- ShowInactiveSync(widget);
+ ShowInactiveSync(widget.get());
EXPECT_TRUE(widget->IsActive());
EXPECT_FALSE(widget2->IsActive());
- EXPECT_EQ(GetWidgetShowState(widget), ui::SHOW_STATE_NORMAL);
-
- widget2->CloseNow();
- widget->CloseNow();
+ EXPECT_EQ(GetWidgetShowState(widget.get()), ui::SHOW_STATE_NORMAL);
}
TEST_F(WidgetTestInteractive, ShowAfterShowInactive) {
- Widget* widget = CreateTopLevelPlatformWidget();
+ WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget());
widget->SetBounds(gfx::Rect(100, 100, 100, 100));
- ShowInactiveSync(widget);
- ShowSync(widget);
- EXPECT_EQ(GetWidgetShowState(widget), ui::SHOW_STATE_NORMAL);
-
- widget->CloseNow();
+ ShowInactiveSync(widget.get());
+ ShowSync(widget.get());
+ EXPECT_EQ(GetWidgetShowState(widget.get()), ui::SHOW_STATE_NORMAL);
}
#if BUILDFLAG(ENABLE_DESKTOP_AURA) || defined(OS_MACOSX)
TEST_F(WidgetTestInteractive, InactiveWidgetDoesNotGrabActivation) {
- Widget* widget = CreateTopLevelPlatformWidget();
- ShowSync(widget);
- EXPECT_EQ(GetWidgetShowState(widget), ui::SHOW_STATE_NORMAL);
+ WidgetAutoclosePtr widget(CreateTopLevelPlatformWidget());
+ ShowSync(widget.get());
+ EXPECT_EQ(GetWidgetShowState(widget.get()), ui::SHOW_STATE_NORMAL);
- Widget widget2;
+ WidgetAutoclosePtr widget2(new Widget());
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- widget2.Init(std::move(params));
- widget2.Show();
+ widget2->Init(std::move(params));
+ widget2->Show();
RunPendingMessagesForActiveStatusChange();
- EXPECT_EQ(GetWidgetShowState(&widget2), ui::SHOW_STATE_INACTIVE);
- EXPECT_EQ(GetWidgetShowState(widget), ui::SHOW_STATE_NORMAL);
-
- widget->CloseNow();
- widget2.CloseNow();
+ EXPECT_EQ(GetWidgetShowState(widget2.get()), ui::SHOW_STATE_INACTIVE);
+ EXPECT_EQ(GetWidgetShowState(widget.get()), ui::SHOW_STATE_NORMAL);
}
#endif // BUILDFLAG(ENABLE_DESKTOP_AURA) || defined(OS_MACOSX)
@@ -1352,37 +1083,33 @@ TEST_F(WidgetTestInteractive, InactiveWidgetDoesNotGrabActivation) {
// Test that window state is not changed after getting out of full screen.
TEST_F(WidgetTestInteractive, MAYBE_ExitFullscreenRestoreState) {
- Widget* toplevel = CreateTopLevelPlatformWidget();
+ WidgetAutoclosePtr toplevel(CreateTopLevelPlatformWidget());
toplevel->Show();
RunPendingMessages();
// This should be a normal state window.
- EXPECT_EQ(ui::SHOW_STATE_NORMAL, GetWidgetShowState(toplevel));
+ EXPECT_EQ(ui::SHOW_STATE_NORMAL, GetWidgetShowState(toplevel.get()));
toplevel->SetFullscreen(true);
- EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, GetWidgetShowState(toplevel));
+ EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, GetWidgetShowState(toplevel.get()));
toplevel->SetFullscreen(false);
- EXPECT_NE(ui::SHOW_STATE_FULLSCREEN, GetWidgetShowState(toplevel));
+ EXPECT_NE(ui::SHOW_STATE_FULLSCREEN, GetWidgetShowState(toplevel.get()));
// And it should still be in normal state after getting out of full screen.
- EXPECT_EQ(ui::SHOW_STATE_NORMAL, GetWidgetShowState(toplevel));
+ EXPECT_EQ(ui::SHOW_STATE_NORMAL, GetWidgetShowState(toplevel.get()));
// Now, make it maximized.
toplevel->Maximize();
- EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, GetWidgetShowState(toplevel));
+ EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, GetWidgetShowState(toplevel.get()));
toplevel->SetFullscreen(true);
- EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, GetWidgetShowState(toplevel));
+ EXPECT_EQ(ui::SHOW_STATE_FULLSCREEN, GetWidgetShowState(toplevel.get()));
toplevel->SetFullscreen(false);
- EXPECT_NE(ui::SHOW_STATE_FULLSCREEN, GetWidgetShowState(toplevel));
+ EXPECT_NE(ui::SHOW_STATE_FULLSCREEN, GetWidgetShowState(toplevel.get()));
// And it stays maximized after getting out of full screen.
- EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, GetWidgetShowState(toplevel));
-
- // Clean up.
- toplevel->Close();
- RunPendingMessages();
+ EXPECT_EQ(ui::SHOW_STATE_MAXIMIZED, GetWidgetShowState(toplevel.get()));
}
// Testing initial focus is assigned properly for normal top-level widgets,
@@ -1412,23 +1139,21 @@ TEST_F(WidgetTestInteractive, InitialFocus) {
}
TEST_F(DesktopWidgetTestInteractive, RestoreAfterMinimize) {
- Widget* widget = CreateWidget();
- ShowSync(widget);
+ WidgetAutoclosePtr widget(CreateTopLevelNativeWidget());
+ ShowSync(widget.get());
ASSERT_FALSE(widget->IsMinimized());
PropertyWaiter minimize_waiter(
- base::BindRepeating(&Widget::IsMinimized, base::Unretained(widget)),
+ base::BindRepeating(&Widget::IsMinimized, base::Unretained(widget.get())),
true);
widget->Minimize();
EXPECT_TRUE(minimize_waiter.Wait());
PropertyWaiter restore_waiter(
- base::BindRepeating(&Widget::IsMinimized, base::Unretained(widget)),
+ base::BindRepeating(&Widget::IsMinimized, base::Unretained(widget.get())),
false);
widget->Restore();
EXPECT_TRUE(restore_waiter.Wait());
-
- widget->CloseNow();
}
#if defined(OS_WIN)
@@ -1437,14 +1162,14 @@ TEST_F(DesktopWidgetTestInteractive, RestoreAfterMinimize) {
// Tests that root window visibility toggles correctly when the desktop widget
// is minimized and maximized on Windows, and the Widget remains visible.
TEST_F(DesktopWidgetTestInteractive, RestoreAndMinimizeVisibility) {
- Widget* widget = CreateWidget();
- aura::Window* root_window = GetRootWindow(widget);
- ShowSync(widget);
+ WidgetAutoclosePtr widget(CreateTopLevelNativeWidget());
+ aura::Window* root_window = GetRootWindow(widget.get());
+ ShowSync(widget.get());
ASSERT_FALSE(widget->IsMinimized());
EXPECT_TRUE(root_window->IsVisible());
PropertyWaiter minimize_widget_waiter(
- base::BindRepeating(&Widget::IsMinimized, base::Unretained(widget)),
+ base::BindRepeating(&Widget::IsMinimized, base::Unretained(widget.get())),
true);
widget->Minimize();
EXPECT_TRUE(minimize_widget_waiter.Wait());
@@ -1452,22 +1177,21 @@ TEST_F(DesktopWidgetTestInteractive, RestoreAndMinimizeVisibility) {
EXPECT_FALSE(root_window->IsVisible());
PropertyWaiter restore_widget_waiter(
- base::BindRepeating(&Widget::IsMinimized, base::Unretained(widget)),
+ base::BindRepeating(&Widget::IsMinimized, base::Unretained(widget.get())),
false);
widget->Restore();
EXPECT_TRUE(restore_widget_waiter.Wait());
EXPECT_TRUE(widget->IsVisible());
EXPECT_TRUE(root_window->IsVisible());
- widget->CloseNow();
}
// Test that focus is restored to the widget after a minimized window
// is activated.
TEST_F(DesktopWidgetTestInteractive, MinimizeAndActivateFocus) {
- Widget* widget = CreateWidget();
- aura::Window* root_window = GetRootWindow(widget);
+ WidgetAutoclosePtr widget(CreateTopLevelNativeWidget());
+ aura::Window* root_window = GetRootWindow(widget.get());
auto* widget_window = widget->GetNativeWindow();
- ShowSync(widget);
+ ShowSync(widget.get());
ASSERT_FALSE(widget->IsMinimized());
EXPECT_TRUE(root_window->IsVisible());
widget_window->Focus();
@@ -1477,7 +1201,7 @@ TEST_F(DesktopWidgetTestInteractive, MinimizeAndActivateFocus) {
EXPECT_TRUE(widget->GetContentsView()->HasFocus());
PropertyWaiter minimize_widget_waiter(
- base::BindRepeating(&Widget::IsMinimized, base::Unretained(widget)),
+ base::BindRepeating(&Widget::IsMinimized, base::Unretained(widget.get())),
true);
widget->Minimize();
EXPECT_TRUE(minimize_widget_waiter.Wait());
@@ -1485,7 +1209,7 @@ TEST_F(DesktopWidgetTestInteractive, MinimizeAndActivateFocus) {
EXPECT_FALSE(root_window->IsVisible());
PropertyWaiter restore_widget_waiter(
- base::BindRepeating(&Widget::IsMinimized, base::Unretained(widget)),
+ base::BindRepeating(&Widget::IsMinimized, base::Unretained(widget.get())),
false);
widget->Activate();
EXPECT_TRUE(widget->GetContentsView()->HasFocus());
@@ -1493,7 +1217,6 @@ TEST_F(DesktopWidgetTestInteractive, MinimizeAndActivateFocus) {
EXPECT_TRUE(widget->IsVisible());
EXPECT_TRUE(root_window->IsVisible());
EXPECT_TRUE(widget_window->CanFocus());
- widget->CloseNow();
}
#endif // defined(OS_WIN)
@@ -1502,8 +1225,8 @@ TEST_F(DesktopWidgetTestInteractive, MinimizeAndActivateFocus) {
// Tests that minimizing a widget causes the gesture_handler
// to be cleared when the widget is minimized.
TEST_F(DesktopWidgetTestInteractive, EventHandlersClearedOnWidgetMinimize) {
- Widget* widget = CreateWidget();
- ShowSync(widget);
+ WidgetAutoclosePtr widget(CreateTopLevelNativeWidget());
+ ShowSync(widget.get());
ASSERT_FALSE(widget->IsMinimized());
View mouse_handler_view;
internal::RootView* root_view =
@@ -1515,8 +1238,6 @@ TEST_F(DesktopWidgetTestInteractive, EventHandlersClearedOnWidgetMinimize) {
widget->Minimize();
EXPECT_FALSE(GetGestureHandler(root_view));
-
- widget->CloseNow();
}
#endif
@@ -1527,16 +1248,16 @@ TEST_F(DesktopWidgetTestInteractive, EventHandlersClearedOnWidgetMinimize) {
TEST_F(DesktopWidgetTestInteractive,
DesktopNativeWidgetWithModalTransientChild) {
// Create a desktop native Widget for Widget::Deactivate().
- Widget* deactivate_widget = CreateWidget();
- ShowSync(deactivate_widget);
+ WidgetAutoclosePtr deactivate_widget(CreateTopLevelNativeWidget());
+ ShowSync(deactivate_widget.get());
// Create a top level desktop native widget.
- Widget* top_level = CreateWidget();
+ WidgetAutoclosePtr top_level(CreateTopLevelNativeWidget());
Textfield* textfield = new Textfield;
textfield->SetBounds(0, 0, 200, 20);
top_level->GetRootView()->AddChildView(textfield);
- ShowSync(top_level);
+ ShowSync(top_level.get());
textfield->RequestFocus();
EXPECT_TRUE(textfield->HasFocus());
@@ -1557,18 +1278,15 @@ TEST_F(DesktopWidgetTestInteractive,
EXPECT_TRUE(dialog_textfield->HasFocus());
EXPECT_FALSE(textfield->HasFocus());
- DeactivateSync(top_level);
+ DeactivateSync(top_level.get());
EXPECT_FALSE(dialog_textfield->HasFocus());
EXPECT_FALSE(textfield->HasFocus());
// After deactivation and activation of top level widget, only modal dialog
// should restore focused view.
- ActivateSync(top_level);
+ ActivateSync(top_level.get());
EXPECT_TRUE(dialog_textfield->HasFocus());
EXPECT_FALSE(textfield->HasFocus());
-
- top_level->CloseNow();
- deactivate_widget->CloseNow();
}
#endif // defined(OS_LINUX) && BUILDFLAG(ENABLE_DESKTOP_AURA)
@@ -1615,7 +1333,7 @@ class CaptureLostTrackingWidget : public Widget {
} // namespace
-class WidgetCaptureTest : public ViewsInteractiveUITestBase {
+class WidgetCaptureTest : public DesktopWidgetTestInteractive {
public:
WidgetCaptureTest() = default;
~WidgetCaptureTest() override = default;
@@ -1625,22 +1343,12 @@ class WidgetCaptureTest : public ViewsInteractiveUITestBase {
void TestCapture(bool use_desktop_native_widget) {
CaptureLostState capture_state1;
CaptureLostTrackingWidget widget1(&capture_state1);
- Widget::InitParams params1 =
- CreateParams(views::Widget::InitParams::TYPE_WINDOW);
- params1.native_widget =
- CreateNativeWidget(params1, use_desktop_native_widget, &widget1);
- params1.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- widget1.Init(std::move(params1));
+ InitPlatformWidget(&widget1, use_desktop_native_widget);
widget1.Show();
CaptureLostState capture_state2;
CaptureLostTrackingWidget widget2(&capture_state2);
- Widget::InitParams params2 =
- CreateParams(views::Widget::InitParams::TYPE_WINDOW);
- params2.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
- params2.native_widget =
- CreateNativeWidget(params2, use_desktop_native_widget, &widget2);
- widget2.Init(std::move(params2));
+ InitPlatformWidget(&widget2, use_desktop_native_widget);
widget2.Show();
// Set capture to widget2 and verity it gets it.
@@ -1665,13 +1373,16 @@ class WidgetCaptureTest : public ViewsInteractiveUITestBase {
EXPECT_FALSE(capture_state2.GetAndClearGotCaptureLost());
}
- NativeWidget* CreateNativeWidget(const Widget::InitParams& params,
- bool create_desktop_native_widget,
- Widget* widget) {
- // The test base class by default returns DesktopNativeWidgetAura.
- if (create_desktop_native_widget)
- return nullptr;
- return CreatePlatformNativeWidgetImpl(params, widget, kDefault, nullptr);
+ void InitPlatformWidget(Widget* widget, bool use_desktop_native_widget) {
+ Widget::InitParams params =
+ CreateParams(views::Widget::InitParams::TYPE_WINDOW);
+ // The test class by default returns DesktopNativeWidgetAura.
+ params.native_widget =
+ use_desktop_native_widget
+ ? nullptr
+ : CreatePlatformNativeWidgetImpl(widget, kDefault, nullptr);
+ params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ widget->Init(std::move(params));
}
private:
@@ -1767,6 +1478,243 @@ TEST_F(WidgetCaptureTest, FailedCaptureRequestIsNoop) {
EXPECT_TRUE(mouse_view2->pressed());
}
+TEST_F(WidgetCaptureTest, CaptureAutoReset) {
+ WidgetAutoclosePtr toplevel(CreateTopLevelFramelessPlatformWidget());
+ View* container = new View;
+ toplevel->SetContentsView(container);
+
+ EXPECT_FALSE(toplevel->HasCapture());
+ toplevel->SetCapture(nullptr);
+ EXPECT_TRUE(toplevel->HasCapture());
+
+ // By default, mouse release removes capture.
+ gfx::Point click_location(45, 15);
+ ui::MouseEvent release(ui::ET_MOUSE_RELEASED, click_location, click_location,
+ ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
+ ui::EF_LEFT_MOUSE_BUTTON);
+ toplevel->OnMouseEvent(&release);
+ EXPECT_FALSE(toplevel->HasCapture());
+
+ // Now a mouse release shouldn't remove capture.
+ toplevel->set_auto_release_capture(false);
+ toplevel->SetCapture(nullptr);
+ EXPECT_TRUE(toplevel->HasCapture());
+ toplevel->OnMouseEvent(&release);
+ EXPECT_TRUE(toplevel->HasCapture());
+ toplevel->ReleaseCapture();
+ EXPECT_FALSE(toplevel->HasCapture());
+}
+
+TEST_F(WidgetCaptureTest, ResetCaptureOnGestureEnd) {
+ WidgetAutoclosePtr toplevel(CreateTopLevelFramelessPlatformWidget());
+ View* container = new View;
+ toplevel->SetContentsView(container);
+
+ View* gesture = new GestureCaptureView;
+ gesture->SetBounds(0, 0, 30, 30);
+ container->AddChildView(gesture);
+
+ MouseView* mouse = new MouseView;
+ mouse->SetBounds(30, 0, 30, 30);
+ container->AddChildView(mouse);
+
+ toplevel->SetSize(gfx::Size(100, 100));
+ toplevel->Show();
+
+ // Start a gesture on |gesture|.
+ ui::GestureEvent tap_down(15, 15, 0, base::TimeTicks(),
+ ui::GestureEventDetails(ui::ET_GESTURE_TAP_DOWN));
+ ui::GestureEvent end(15, 15, 0, base::TimeTicks(),
+ ui::GestureEventDetails(ui::ET_GESTURE_END));
+ toplevel->OnGestureEvent(&tap_down);
+
+ // Now try to click on |mouse|. Since |gesture| will have capture, |mouse|
+ // will not receive the event.
+ gfx::Point click_location(45, 15);
+
+ ui::MouseEvent press(ui::ET_MOUSE_PRESSED, click_location, click_location,
+ ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
+ ui::EF_LEFT_MOUSE_BUTTON);
+ ui::MouseEvent release(ui::ET_MOUSE_RELEASED, click_location, click_location,
+ ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
+ ui::EF_LEFT_MOUSE_BUTTON);
+
+ EXPECT_TRUE(toplevel->HasCapture());
+
+ toplevel->OnMouseEvent(&press);
+ toplevel->OnMouseEvent(&release);
+ EXPECT_EQ(0, mouse->pressed());
+
+ EXPECT_FALSE(toplevel->HasCapture());
+
+ // The end of the gesture should release the capture, and pressing on |mouse|
+ // should now reach |mouse|.
+ toplevel->OnGestureEvent(&end);
+ toplevel->OnMouseEvent(&press);
+ toplevel->OnMouseEvent(&release);
+ EXPECT_EQ(1, mouse->pressed());
+}
+
+// Checks that if a mouse-press triggers a capture on a different widget (which
+// consumes the mouse-release event), then the target of the press does not have
+// capture.
+TEST_F(WidgetCaptureTest, DisableCaptureWidgetFromMousePress) {
+ // The test creates two widgets: |first| and |second|.
+ // The View in |first| makes |second| visible, sets capture on it, and starts
+ // a nested loop (like a menu does). The View in |second| terminates the
+ // nested loop and closes the widget.
+ // The test sends a mouse-press event to |first|, and posts a task to send a
+ // release event to |second|, to make sure that the release event is
+ // dispatched after the nested loop starts.
+
+ WidgetAutoclosePtr first(CreateTopLevelFramelessPlatformWidget());
+ Widget* second = CreateTopLevelFramelessPlatformWidget();
+
+ NestedLoopCaptureView* container = new NestedLoopCaptureView(second);
+ first->SetContentsView(container);
+
+ second->SetContentsView(new ExitLoopOnRelease(container->GetQuitClosure()));
+
+ first->SetSize(gfx::Size(100, 100));
+ first->Show();
+
+ gfx::Point location(20, 20);
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE,
+ base::BindOnce(
+ &Widget::OnMouseEvent, base::Unretained(second),
+ base::Owned(new ui::MouseEvent(
+ ui::ET_MOUSE_RELEASED, location, location, ui::EventTimeForNow(),
+ ui::EF_LEFT_MOUSE_BUTTON, ui::EF_LEFT_MOUSE_BUTTON))));
+ ui::MouseEvent press(ui::ET_MOUSE_PRESSED, location, location,
+ ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON,
+ ui::EF_LEFT_MOUSE_BUTTON);
+ first->OnMouseEvent(&press);
+ EXPECT_FALSE(first->HasCapture());
+}
+
+// Tests some grab/ungrab events. Only one Widget can have capture at any given
+// time.
+TEST_F(WidgetCaptureTest, GrabUngrab) {
+ auto top_level = CreateTestWidget();
+ top_level->SetContentsView(new MouseView());
+
+ Widget* child1 = new Widget;
+ Widget::InitParams params1 = CreateParams(Widget::InitParams::TYPE_CONTROL);
+ params1.parent = top_level->GetNativeView();
+ params1.bounds = gfx::Rect(10, 10, 100, 100);
+ child1->Init(std::move(params1));
+ child1->SetContentsView(new MouseView());
+
+ Widget* child2 = new Widget;
+ Widget::InitParams params2 = CreateParams(Widget::InitParams::TYPE_CONTROL);
+ params2.parent = top_level->GetNativeView();
+ params2.bounds = gfx::Rect(110, 10, 100, 100);
+ child2->Init(std::move(params2));
+ child2->SetContentsView(new MouseView());
+
+ top_level->Show();
+ RunPendingMessages();
+
+ // Click on child1.
+ ui::test::EventGenerator generator(GetRootWindow(top_level.get()),
+ child1->GetNativeWindow());
+ generator.PressLeftButton();
+
+ EXPECT_FALSE(top_level->HasCapture());
+ EXPECT_TRUE(child1->HasCapture());
+ EXPECT_FALSE(child2->HasCapture());
+
+ generator.ReleaseLeftButton();
+ EXPECT_FALSE(top_level->HasCapture());
+ EXPECT_FALSE(child1->HasCapture());
+ EXPECT_FALSE(child2->HasCapture());
+
+ // Click on child2.
+ generator.SetTargetWindow(child2->GetNativeWindow());
+ generator.set_current_screen_location(
+ generator.delegate()->CenterOfWindow(child2->GetNativeWindow()));
+ generator.PressLeftButton();
+
+ EXPECT_FALSE(top_level->HasCapture());
+ EXPECT_FALSE(child1->HasCapture());
+ EXPECT_TRUE(child2->HasCapture());
+
+ generator.ReleaseLeftButton();
+ EXPECT_FALSE(top_level->HasCapture());
+ EXPECT_FALSE(child1->HasCapture());
+ EXPECT_FALSE(child2->HasCapture());
+
+ // Click on top_level.
+ generator.SetTargetWindow(top_level->GetNativeWindow());
+ generator.set_current_screen_location(gfx::Point());
+ generator.PressLeftButton();
+
+ EXPECT_TRUE(top_level->HasCapture());
+ EXPECT_FALSE(child1->HasCapture());
+ EXPECT_FALSE(child2->HasCapture());
+
+ generator.ReleaseLeftButton();
+ EXPECT_FALSE(top_level->HasCapture());
+ EXPECT_FALSE(child1->HasCapture());
+ EXPECT_FALSE(child2->HasCapture());
+}
+
+// Disabled on Mac. Desktop Mac doesn't have system modal windows since Carbon
+// was deprecated. It does have application modal windows, but only Ash requests
+// those.
+#if defined(OS_MACOSX)
+#define MAYBE_SystemModalWindowReleasesCapture \
+ DISABLED_SystemModalWindowReleasesCapture
+#elif defined(OS_CHROMEOS)
+// Investigate enabling for Chrome OS. It probably requires help from the window
+// service.
+#define MAYBE_SystemModalWindowReleasesCapture \
+ DISABLED_SystemModalWindowReleasesCapture
+#else
+#define MAYBE_SystemModalWindowReleasesCapture SystemModalWindowReleasesCapture
+#endif
+
+// Test that when opening a system-modal window, capture is released.
+TEST_F(WidgetCaptureTest, MAYBE_SystemModalWindowReleasesCapture) {
+ TestWidgetFocusChangeListener focus_listener;
+ WidgetFocusManager::GetInstance()->AddFocusChangeListener(&focus_listener);
+
+ // Create a top level widget.
+ Widget top_level_widget;
+ Widget::InitParams init_params =
+ CreateParams(Widget::InitParams::TYPE_WINDOW);
+ init_params.show_state = ui::SHOW_STATE_NORMAL;
+ gfx::Rect initial_bounds(0, 0, 500, 500);
+ init_params.bounds = initial_bounds;
+ init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
+ top_level_widget.Init(std::move(init_params));
+ ShowSync(&top_level_widget);
+
+ ASSERT_FALSE(focus_listener.focus_changes().empty());
+ EXPECT_EQ(top_level_widget.GetNativeView(),
+ focus_listener.focus_changes().back());
+
+ EXPECT_FALSE(top_level_widget.HasCapture());
+ top_level_widget.SetCapture(nullptr);
+ EXPECT_TRUE(top_level_widget.HasCapture());
+
+ // Create a modal dialog.
+ ModalDialogDelegate* dialog_delegate =
+ new ModalDialogDelegate(ui::MODAL_TYPE_SYSTEM);
+
+ Widget* modal_dialog_widget = views::DialogDelegate::CreateDialogWidget(
+ dialog_delegate, nullptr, top_level_widget.GetNativeView());
+ modal_dialog_widget->SetBounds(gfx::Rect(100, 100, 200, 200));
+ ShowSync(modal_dialog_widget);
+
+ EXPECT_FALSE(top_level_widget.HasCapture());
+
+ modal_dialog_widget->CloseNow();
+ top_level_widget.CloseNow();
+ WidgetFocusManager::GetInstance()->RemoveFocusChangeListener(&focus_listener);
+}
+
// Regression test for http://crbug.com/382421 (Linux-Aura issue).
// TODO(pkotwicz): Make test pass on CrOS and Windows.
// TODO(tapted): Investigate for toolkit-views on Mac http;//crbug.com/441064.
@@ -1952,7 +1900,7 @@ class WidgetInputMethodInteractiveTest : public DesktopWidgetTestInteractive {
// On Windows, Widget::Deactivate() works by activating the next topmost
// window on the z-order stack. This only works if there is at least one
// other window, so make sure that is the case.
- deactivate_widget_ = CreateWidget();
+ deactivate_widget_ = CreateTopLevelNativeWidget();
deactivate_widget_->Show();
#endif
}
@@ -1976,33 +1924,32 @@ class WidgetInputMethodInteractiveTest : public DesktopWidgetTestInteractive {
#endif
// Test input method focus changes affected by top window activaction.
TEST_F(WidgetInputMethodInteractiveTest, MAYBE_Activation) {
- Widget* widget = CreateWidget();
+ WidgetAutoclosePtr widget(CreateTopLevelNativeWidget());
Textfield* textfield = new Textfield;
widget->GetRootView()->AddChildView(textfield);
textfield->RequestFocus();
- ShowSync(widget);
+ ShowSync(widget.get());
EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT,
widget->GetInputMethod()->GetTextInputType());
- DeactivateSync(widget);
+ DeactivateSync(widget.get());
EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE,
widget->GetInputMethod()->GetTextInputType());
- widget->CloseNow();
}
// Test input method focus changes affected by focus changes within 1 window.
TEST_F(WidgetInputMethodInteractiveTest, OneWindow) {
- Widget* widget = CreateWidget();
+ WidgetAutoclosePtr widget(CreateTopLevelNativeWidget());
Textfield* textfield1 = new Textfield;
Textfield* textfield2 = new Textfield;
textfield2->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
widget->GetRootView()->AddChildView(textfield1);
widget->GetRootView()->AddChildView(textfield2);
- ShowSync(widget);
+ ShowSync(widget.get());
textfield1->RequestFocus();
EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT,
@@ -2016,31 +1963,30 @@ TEST_F(WidgetInputMethodInteractiveTest, OneWindow) {
// DNWA (which just activates the last active window) and involves the
// AuraTestHelper which sets the input method as DummyInputMethod.
#if BUILDFLAG(ENABLE_DESKTOP_AURA) || defined(OS_MACOSX)
- DeactivateSync(widget);
+ DeactivateSync(widget.get());
EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE,
widget->GetInputMethod()->GetTextInputType());
- ActivateSync(widget);
+ ActivateSync(widget.get());
EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD,
widget->GetInputMethod()->GetTextInputType());
- DeactivateSync(widget);
+ DeactivateSync(widget.get());
textfield1->RequestFocus();
- ActivateSync(widget);
+ ActivateSync(widget.get());
EXPECT_TRUE(widget->IsActive());
EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT,
widget->GetInputMethod()->GetTextInputType());
#endif
- widget->CloseNow();
}
// Test input method focus changes affected by focus changes cross 2 windows
// which shares the same top window.
TEST_F(WidgetInputMethodInteractiveTest, TwoWindows) {
- Widget* parent = CreateWidget();
+ WidgetAutoclosePtr parent(CreateTopLevelNativeWidget());
parent->SetBounds(gfx::Rect(100, 100, 100, 100));
- Widget* child = CreateChildNativeWidgetWithParent(parent);
+ Widget* child = CreateChildNativeWidgetWithParent(parent.get());
child->SetBounds(gfx::Rect(0, 0, 50, 50));
child->Show();
@@ -2049,7 +1995,7 @@ TEST_F(WidgetInputMethodInteractiveTest, TwoWindows) {
textfield_parent->SetTextInputType(ui::TEXT_INPUT_TYPE_PASSWORD);
parent->GetRootView()->AddChildView(textfield_parent);
child->GetRootView()->AddChildView(textfield_child);
- ShowSync(parent);
+ ShowSync(parent.get());
EXPECT_EQ(parent->GetInputMethod(), child->GetInputMethod());
@@ -2065,33 +2011,31 @@ TEST_F(WidgetInputMethodInteractiveTest, TwoWindows) {
// DNWA (which just activates the last active window) and involves the
// AuraTestHelper which sets the input method as DummyInputMethod.
#if BUILDFLAG(ENABLE_DESKTOP_AURA) || defined(OS_MACOSX)
- DeactivateSync(parent);
+ DeactivateSync(parent.get());
EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE,
parent->GetInputMethod()->GetTextInputType());
- ActivateSync(parent);
+ ActivateSync(parent.get());
EXPECT_EQ(ui::TEXT_INPUT_TYPE_TEXT,
parent->GetInputMethod()->GetTextInputType());
textfield_parent->RequestFocus();
- DeactivateSync(parent);
+ DeactivateSync(parent.get());
EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE,
parent->GetInputMethod()->GetTextInputType());
- ActivateSync(parent);
+ ActivateSync(parent.get());
EXPECT_EQ(ui::TEXT_INPUT_TYPE_PASSWORD,
parent->GetInputMethod()->GetTextInputType());
#endif
-
- parent->CloseNow();
}
// Test input method focus changes affected by textfield's state changes.
TEST_F(WidgetInputMethodInteractiveTest, TextField) {
- Widget* widget = CreateWidget();
+ WidgetAutoclosePtr widget(CreateTopLevelNativeWidget());
Textfield* textfield = new Textfield;
widget->GetRootView()->AddChildView(textfield);
- ShowSync(widget);
+ ShowSync(widget.get());
EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE,
widget->GetInputMethod()->GetTextInputType());
@@ -2110,15 +2054,14 @@ TEST_F(WidgetInputMethodInteractiveTest, TextField) {
textfield->SetReadOnly(true);
EXPECT_EQ(ui::TEXT_INPUT_TYPE_NONE,
widget->GetInputMethod()->GetTextInputType());
- widget->CloseNow();
}
// Test input method should not work for accelerator.
TEST_F(WidgetInputMethodInteractiveTest, AcceleratorInTextfield) {
- Widget* widget = CreateWidget();
+ WidgetAutoclosePtr widget(CreateTopLevelNativeWidget());
Textfield* textfield = new Textfield;
widget->GetRootView()->AddChildView(textfield);
- ShowSync(widget);
+ ShowSync(widget.get());
textfield->SetTextInputType(ui::TEXT_INPUT_TYPE_TEXT);
textfield->RequestFocus();
@@ -2135,8 +2078,6 @@ TEST_F(WidgetInputMethodInteractiveTest, AcceleratorInTextfield) {
ui::KeyEvent key_event2(key_event);
widget->OnKeyEvent(&key_event2);
EXPECT_FALSE(key_event2.stopped_propagation());
-
- widget->CloseNow();
}
} // namespace test
diff --git a/chromium/ui/views/widget/widget_unittest.cc b/chromium/ui/views/widget/widget_unittest.cc
index e932006a39a..469e9150908 100644
--- a/chromium/ui/views/widget/widget_unittest.cc
+++ b/chromium/ui/views/widget/widget_unittest.cc
@@ -343,79 +343,6 @@ class OwnershipTestWidget : public Widget {
// TODO(sky): add coverage of ownership for the desktop variants.
-// Widget owns its NativeWidget, part 1: NativeWidget is a platform-native
-// widget.
-TEST_F(WidgetOwnershipTest, Ownership_WidgetOwnsPlatformNativeWidget) {
- OwnershipTestState state;
-
- auto widget = std::make_unique<OwnershipTestWidget>(&state);
- Widget::InitParams params = CreateParamsForTestWidget();
- params.native_widget = CreatePlatformNativeWidgetImpl(
- params, widget.get(), kStubCapture, &state.native_widget_deleted);
- widget->Init(std::move(params));
-
- // Now delete the Widget, which should delete the NativeWidget.
- widget.reset();
-
- EXPECT_TRUE(state.widget_deleted);
- EXPECT_TRUE(state.native_widget_deleted);
-
- // TODO(beng): write test for this ownership scenario and the NativeWidget
- // being deleted out from under the Widget.
-}
-
-// Widget owns its NativeWidget, part 2: NativeWidget is a NativeWidget.
-TEST_F(WidgetOwnershipTest, Ownership_WidgetOwnsViewsNativeWidget) {
- OwnershipTestState state;
-
- auto widget = std::make_unique<OwnershipTestWidget>(&state);
- Widget::InitParams params = CreateParamsForTestWidget();
- params.native_widget = CreatePlatformNativeWidgetImpl(
- params, widget.get(), kStubCapture, &state.native_widget_deleted);
- widget->Init(std::move(params));
-
- // Now delete the Widget, which should delete the NativeWidget.
- widget.reset();
-
- EXPECT_TRUE(state.widget_deleted);
- EXPECT_TRUE(state.native_widget_deleted);
-
- // TODO(beng): write test for this ownership scenario and the NativeWidget
- // being deleted out from under the Widget.
-}
-
-// Widget owns its NativeWidget, part 3: NativeWidget is a NativeWidget,
-// destroy the parent view.
-TEST_F(WidgetOwnershipTest,
- Ownership_WidgetOwnsViewsNativeWidget_DestroyParentView) {
- OwnershipTestState state;
-
- Widget* toplevel = CreateTopLevelPlatformWidget();
-
- auto widget = std::make_unique<OwnershipTestWidget>(&state);
- Widget::InitParams params = CreateParamsForTestWidget();
- params.parent = toplevel->GetNativeView();
- params.native_widget = CreatePlatformNativeWidgetImpl(
- params, widget.get(), kStubCapture, &state.native_widget_deleted);
- widget->Init(std::move(params));
-
- // Now close the toplevel, which deletes the view hierarchy.
- toplevel->CloseNow();
-
- RunPendingMessages();
-
- // This shouldn't delete the widget because it shouldn't be deleted
- // from the native side.
- EXPECT_FALSE(state.widget_deleted);
- EXPECT_FALSE(state.native_widget_deleted);
-
- // Now delete it explicitly.
- widget.reset();
-
- EXPECT_TRUE(state.widget_deleted);
- EXPECT_TRUE(state.native_widget_deleted);
-}
-
// NativeWidget owns its Widget, part 1: NativeWidget is a platform-native
// widget.
TEST_F(WidgetOwnershipTest, Ownership_PlatformNativeWidgetOwnsWidget) {
@@ -424,7 +351,7 @@ TEST_F(WidgetOwnershipTest, Ownership_PlatformNativeWidgetOwnsWidget) {
Widget* widget = new OwnershipTestWidget(&state);
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.native_widget = CreatePlatformNativeWidgetImpl(
- params, widget, kStubCapture, &state.native_widget_deleted);
+ widget, kStubCapture, &state.native_widget_deleted);
widget->Init(std::move(params));
// Now destroy the native widget.
@@ -444,7 +371,7 @@ TEST_F(WidgetOwnershipTest, Ownership_ViewsNativeWidgetOwnsWidget) {
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.parent = toplevel->GetNativeView();
params.native_widget = CreatePlatformNativeWidgetImpl(
- params, widget, kStubCapture, &state.native_widget_deleted);
+ widget, kStubCapture, &state.native_widget_deleted);
widget->Init(std::move(params));
// Now destroy the native widget. This is achieved by closing the toplevel.
@@ -467,7 +394,7 @@ TEST_F(WidgetOwnershipTest,
Widget* widget = new OwnershipTestWidget(&state);
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.native_widget = CreatePlatformNativeWidgetImpl(
- params, widget, kStubCapture, &state.native_widget_deleted);
+ widget, kStubCapture, &state.native_widget_deleted);
widget->Init(std::move(params));
// Now simulate a destroy of the platform native widget from the OS:
@@ -489,7 +416,7 @@ TEST_F(WidgetOwnershipTest,
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.parent = toplevel->GetNativeView();
params.native_widget = CreatePlatformNativeWidgetImpl(
- params, widget, kStubCapture, &state.native_widget_deleted);
+ widget, kStubCapture, &state.native_widget_deleted);
widget->Init(std::move(params));
// Destroy the widget (achieved by closing the toplevel).
@@ -514,7 +441,7 @@ TEST_F(WidgetOwnershipTest, Ownership_ViewsNativeWidgetOwnsWidget_Close) {
Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
params.parent = toplevel->GetNativeView();
params.native_widget = CreatePlatformNativeWidgetImpl(
- params, widget, kStubCapture, &state.native_widget_deleted);
+ widget, kStubCapture, &state.native_widget_deleted);
widget->Init(std::move(params));
// Destroy the widget.
@@ -529,26 +456,72 @@ TEST_F(WidgetOwnershipTest, Ownership_ViewsNativeWidgetOwnsWidget_Close) {
EXPECT_TRUE(state.native_widget_deleted);
}
-// Widget owns its NativeWidget and has a WidgetDelegateView as its contents.
-TEST_F(WidgetOwnershipTest,
- Ownership_WidgetOwnsNativeWidgetWithWithWidgetDelegateView) {
- OwnershipTestState state;
+class WidgetOwnsNativeWidgetTest : public WidgetOwnershipTest {
+ public:
+ WidgetOwnsNativeWidgetTest() = default;
+ ~WidgetOwnsNativeWidgetTest() override = default;
+
+ void TearDown() override {
+ EXPECT_TRUE(state_.widget_deleted);
+ EXPECT_TRUE(state_.native_widget_deleted);
- WidgetDelegateView* delegate_view = new WidgetDelegateView;
+ WidgetOwnershipTest::TearDown();
+ }
+
+ OwnershipTestState* state() { return &state_; }
- auto widget = std::make_unique<OwnershipTestWidget>(&state);
+ private:
+ OwnershipTestState state_;
+};
+
+// Widget owns its NativeWidget, part 1.
+TEST_F(WidgetOwnsNativeWidgetTest, Ownership) {
+ auto widget = std::make_unique<OwnershipTestWidget>(state());
Widget::InitParams params = CreateParamsForTestWidget();
params.native_widget = CreatePlatformNativeWidgetImpl(
- params, widget.get(), kStubCapture, &state.native_widget_deleted);
- params.delegate = delegate_view;
+ widget.get(), kStubCapture, &state()->native_widget_deleted);
widget->Init(std::move(params));
- widget->SetContentsView(delegate_view);
- // Now delete the Widget. There should be no crash or use-after-free.
+ // Now delete the Widget, which should delete the NativeWidget.
widget.reset();
- EXPECT_TRUE(state.widget_deleted);
- EXPECT_TRUE(state.native_widget_deleted);
+ // TODO(beng): write test for this ownership scenario and the NativeWidget
+ // being deleted out from under the Widget.
+}
+
+// Widget owns its NativeWidget, part 2: destroy the parent view.
+TEST_F(WidgetOwnsNativeWidgetTest, DestroyParentView) {
+ Widget* toplevel = CreateTopLevelPlatformWidget();
+
+ auto widget = std::make_unique<OwnershipTestWidget>(state());
+ Widget::InitParams params = CreateParamsForTestWidget();
+ params.parent = toplevel->GetNativeView();
+ params.native_widget = CreatePlatformNativeWidgetImpl(
+ widget.get(), kStubCapture, &state()->native_widget_deleted);
+ widget->Init(std::move(params));
+
+ // Now close the toplevel, which deletes the view hierarchy.
+ toplevel->CloseNow();
+
+ RunPendingMessages();
+
+ // This shouldn't delete the widget because it shouldn't be deleted
+ // from the native side.
+ EXPECT_FALSE(state()->widget_deleted);
+ EXPECT_FALSE(state()->native_widget_deleted);
+}
+
+// Widget owns its NativeWidget, part 3: has a WidgetDelegateView as contents.
+TEST_F(WidgetOwnsNativeWidgetTest, WidgetDelegateView) {
+ auto widget = std::make_unique<OwnershipTestWidget>(state());
+ Widget::InitParams params = CreateParamsForTestWidget();
+ params.native_widget = CreatePlatformNativeWidgetImpl(
+ widget.get(), kStubCapture, &state()->native_widget_deleted);
+ params.delegate = new WidgetDelegateView();
+ widget->Init(std::move(params));
+
+ // Allow the Widget to go out of scope. There should be no crash or
+ // use-after-free.
}
////////////////////////////////////////////////////////////////////////////////
@@ -1259,37 +1232,6 @@ TEST_F(WidgetTest, KeyboardInputEvent) {
EXPECT_FALSE(backspace_r.handled());
}
-// Verifies bubbles result in a focus lost when shown.
-// TODO(msw): this tests relies on focus, it needs to be in
-// interactive_ui_tests.
-TEST_F(DesktopWidgetTest, DISABLED_FocusChangesOnBubble) {
- // Create a widget, show and activate it and focus the contents view.
- View* contents_view = new View;
- contents_view->SetFocusBehavior(View::FocusBehavior::ALWAYS);
- std::unique_ptr<Widget> widget = CreateTestWidget();
- widget->SetContentsView(contents_view);
- widget->Show();
- widget->Activate();
- contents_view->RequestFocus();
- EXPECT_TRUE(contents_view->HasFocus());
-
- // Show a bubble.
- BubbleDialogDelegateView* bubble_delegate_view =
- new TestBubbleDialogDelegateView(contents_view);
- bubble_delegate_view->SetFocusBehavior(View::FocusBehavior::ALWAYS);
- BubbleDialogDelegateView::CreateBubble(bubble_delegate_view)->Show();
- bubble_delegate_view->RequestFocus();
-
- // |contents_view_| should no longer have focus.
- EXPECT_FALSE(contents_view->HasFocus());
- EXPECT_TRUE(bubble_delegate_view->HasFocus());
-
- bubble_delegate_view->GetWidget()->CloseNow();
-
- // Closing the bubble should result in focus going back to the contents view.
- EXPECT_TRUE(contents_view->HasFocus());
-}
-
TEST_F(WidgetTest, BubbleControlsResetOnInit) {
WidgetAutoclosePtr anchor(CreateTopLevelPlatformWidget());
anchor->Show();
@@ -1332,8 +1274,10 @@ TEST_F(DesktopWidgetTest, TestViewWidthAfterMinimizingWidget) {
// paints are expected.
class DesktopAuraTestValidPaintWidget : public Widget, public WidgetObserver {
public:
- DesktopAuraTestValidPaintWidget() { observer_.Add(this); }
-
+ explicit DesktopAuraTestValidPaintWidget(Widget::InitParams init_params)
+ : Widget(std::move(init_params)) {
+ observer_.Add(this);
+ }
~DesktopAuraTestValidPaintWidget() override = default;
bool ReadReceivedPaintAndReset() {
@@ -1385,14 +1329,12 @@ class DesktopAuraPaintWidgetTest : public DesktopWidgetTest {
std::unique_ptr<views::Widget> CreateTestWidget(
views::Widget::InitParams::Type type =
views::Widget::InitParams::TYPE_WINDOW_FRAMELESS) override {
- Widget::InitParams params = CreateParamsForTestWidget(type);
- auto widget = std::make_unique<DesktopAuraTestValidPaintWidget>();
+ auto widget = std::make_unique<DesktopAuraTestValidPaintWidget>(
+ CreateParamsForTestWidget(type));
paint_widget_ = widget.get();
- widget->Init(std::move(params));
- View* contents_view = new View;
+ View* contents_view = widget->SetContentsView(std::make_unique<View>());
contents_view->SetFocusBehavior(View::FocusBehavior::ALWAYS);
- widget->SetContentsView(contents_view);
widget->Show();
widget->Activate();
@@ -2019,8 +1961,8 @@ class WidgetWindowTitleTest : public DesktopWidgetTest {
CreateParams(Widget::InitParams::TYPE_WINDOW);
if (!desktop_native_widget) {
- init_params.native_widget = CreatePlatformNativeWidgetImpl(
- init_params, widget.get(), kStubCapture, nullptr);
+ init_params.native_widget =
+ CreatePlatformNativeWidgetImpl(widget.get(), kStubCapture, nullptr);
}
widget->Init(std::move(init_params));
@@ -2066,7 +2008,8 @@ TEST_F(WidgetTest, WidgetDeleted_InOnMousePressed) {
CreateParams(views::Widget::InitParams::TYPE_POPUP);
widget->Init(std::move(params));
- widget->SetContentsView(new CloseWidgetView(ui::ET_MOUSE_PRESSED));
+ widget->SetContentsView(
+ std::make_unique<CloseWidgetView>(ui::ET_MOUSE_PRESSED));
widget->SetSize(gfx::Size(100, 100));
widget->Show();
@@ -2091,7 +2034,8 @@ TEST_F(WidgetTest, WidgetDeleted_InDispatchGestureEvent) {
CreateParams(views::Widget::InitParams::TYPE_POPUP);
widget->Init(std::move(params));
- widget->SetContentsView(new CloseWidgetView(ui::ET_GESTURE_TAP_DOWN));
+ widget->SetContentsView(
+ std::make_unique<CloseWidgetView>(ui::ET_GESTURE_TAP_DOWN));
widget->SetSize(gfx::Size(100, 100));
widget->Show();
@@ -2131,8 +2075,8 @@ bool RunGetNativeThemeFromDestructor(Widget::InitParams params,
// Deletes itself when the Widget is destroyed.
params.delegate = new GetNativeThemeFromDestructorView;
if (!is_first_run) {
- params.native_widget = CreatePlatformNativeWidgetImpl(
- params, widget.get(), kStubCapture, nullptr);
+ params.native_widget =
+ CreatePlatformNativeWidgetImpl(widget.get(), kStubCapture, nullptr);
needs_second_run = true;
}
widget->Init(std::move(params));
@@ -3041,8 +2985,8 @@ class WidgetChildDestructionTest : public DesktopWidgetTest {
Widget::InitParams params =
CreateParams(views::Widget::InitParams::TYPE_WINDOW);
if (!top_level_has_desktop_native_widget_aura) {
- params.native_widget = CreatePlatformNativeWidgetImpl(
- params, top_level, kStubCapture, nullptr);
+ params.native_widget =
+ CreatePlatformNativeWidgetImpl(top_level, kStubCapture, nullptr);
}
top_level->Init(std::move(params));
top_level->GetRootView()->AddChildView(
@@ -3054,8 +2998,8 @@ class WidgetChildDestructionTest : public DesktopWidgetTest {
CreateParams(views::Widget::InitParams::TYPE_POPUP);
child_params.parent = top_level->GetNativeView();
if (!child_has_desktop_native_widget_aura) {
- child_params.native_widget = CreatePlatformNativeWidgetImpl(
- child_params, child, kStubCapture, nullptr);
+ child_params.native_widget =
+ CreatePlatformNativeWidgetImpl(child, kStubCapture, nullptr);
}
child->Init(std::move(child_params));
child->GetRootView()->AddChildView(
@@ -3874,48 +3818,31 @@ class ModalDialogDelegate : public DialogDelegateView {
// remaining top-level windows should be re-enabled.
TEST_F(DesktopWidgetTest, WindowModalOwnerDestroyedEnabledTest) {
// top_level_widget owns owner_dialog_widget which owns owned_dialog_widget.
-
- // Create the top level widget.
std::unique_ptr<Widget> top_level_widget = CreateTestWidget();
top_level_widget->Show();
// Create the owner modal dialog.
- // owner_dialog_delegate instance will be destroyed when the dialog
- // is destroyed.
- ModalDialogDelegate* owner_dialog_delegate =
- new ModalDialogDelegate(ui::MODAL_TYPE_WINDOW);
-
- Widget owner_dialog_widget;
- Widget::InitParams init_params =
- CreateParamsForTestWidget(Widget::InitParams::TYPE_WINDOW);
- init_params.delegate = owner_dialog_delegate;
- init_params.parent = top_level_widget->GetNativeView();
- init_params.native_widget =
- new test::TestPlatformNativeWidget<DesktopNativeWidgetAura>(
- &owner_dialog_widget, false, nullptr);
- owner_dialog_widget.Init(std::move(init_params));
-
- HWND owner_hwnd = HWNDForWidget(&owner_dialog_widget);
-
+ const auto create_params = [this](Widget* widget, gfx::NativeView parent) {
+ Widget::InitParams init_params =
+ CreateParamsForTestWidget(Widget::InitParams::TYPE_WINDOW);
+ init_params.delegate = new ModalDialogDelegate(ui::MODAL_TYPE_WINDOW);
+ init_params.parent = parent;
+ init_params.native_widget =
+ new test::TestPlatformNativeWidget<DesktopNativeWidgetAura>(
+ widget, false, nullptr);
+ return init_params;
+ };
+ Widget owner_dialog_widget(
+ create_params(&owner_dialog_widget, top_level_widget->GetNativeView()));
owner_dialog_widget.Show();
+ HWND owner_hwnd = HWNDForWidget(&owner_dialog_widget);
// Create the owned modal dialog.
- // As above, the owned_dialog_instance instance will be destroyed
- // when the dialog is destroyed.
- ModalDialogDelegate* owned_dialog_delegate =
- new ModalDialogDelegate(ui::MODAL_TYPE_WINDOW);
-
- Widget owned_dialog_widget;
- init_params.delegate = owned_dialog_delegate;
- init_params.parent = owner_dialog_widget.GetNativeView();
- init_params.native_widget =
- new test::TestPlatformNativeWidget<DesktopNativeWidgetAura>(
- &owned_dialog_widget, false, nullptr);
- owned_dialog_widget.Init(std::move(init_params));
-
+ Widget owned_dialog_widget(
+ create_params(&owned_dialog_widget, owner_dialog_widget.GetNativeView()));
+ owned_dialog_widget.Show();
HWND owned_hwnd = HWNDForWidget(&owned_dialog_widget);
- owned_dialog_widget.Show();
RunPendingMessages();
HWND top_hwnd = HWNDForWidget(top_level_widget.get());
diff --git a/chromium/ui/views/win/fullscreen_handler.cc b/chromium/ui/views/win/fullscreen_handler.cc
index 2f828618daf..8791362556f 100644
--- a/chromium/ui/views/win/fullscreen_handler.cc
+++ b/chromium/ui/views/win/fullscreen_handler.cc
@@ -6,7 +6,6 @@
#include <memory>
-#include "base/logging.h"
#include "base/win/win_util.h"
#include "ui/base/win/shell.h"
#include "ui/gfx/geometry/rect.h"
diff --git a/chromium/ui/views/win/hwnd_message_handler.cc b/chromium/ui/views/win/hwnd_message_handler.cc
index e18afe3c8c2..c981cfc6b0a 100644
--- a/chromium/ui/views/win/hwnd_message_handler.cc
+++ b/chromium/ui/views/win/hwnd_message_handler.cc
@@ -403,7 +403,6 @@ HWNDMessageHandler::HWNDMessageHandler(HWNDMessageHandlerDelegate* delegate,
use_system_default_icon_(false),
restored_enabled_(false),
current_cursor_(nullptr),
- previous_cursor_(nullptr),
dpi_(0),
called_enable_non_client_dpi_scaling_(false),
active_mouse_tracking_flags_(0),
@@ -864,13 +863,9 @@ bool HWNDMessageHandler::SetTitle(const base::string16& title) {
}
void HWNDMessageHandler::SetCursor(HCURSOR cursor) {
- if (cursor) {
- previous_cursor_ = ::SetCursor(cursor);
- current_cursor_ = cursor;
- } else if (previous_cursor_) {
- ::SetCursor(previous_cursor_);
- previous_cursor_ = nullptr;
- }
+ TRACE_EVENT1("ui,input", "HWNDMessageHandler::SetCursor", "cursor", cursor);
+ ::SetCursor(cursor);
+ current_cursor_ = cursor;
}
void HWNDMessageHandler::FrameTypeChanged() {
@@ -2386,18 +2381,42 @@ void HWNDMessageHandler::OnPaint(HDC dc) {
}
if (!IsRectEmpty(&ps.rcPaint)) {
+ HBRUSH brush = reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH));
+
if (HasChildRenderingWindow()) {
// If there's a child window that's being rendered to then clear the
// area outside it (as WS_CLIPCHILDREN is set) with transparent black.
// Otherwise, other portions of the backing store for the window can
// flicker opaque black. http://crbug.com/586454
- FillRect(ps.hdc, &ps.rcPaint,
- reinterpret_cast<HBRUSH>(GetStockObject(BLACK_BRUSH)));
+ FillRect(ps.hdc, &ps.rcPaint, brush);
+ } else if (exposed_pixels_.height() > 0 || exposed_pixels_.width() > 0) {
+ // Fill in newly exposed window client area with black to ensure Windows
+ // doesn't put something else there (eg. copying existing pixels). This
+ // isn't needed if we've just cleared the whole client area outside the
+ // child window above.
+ RECT cr;
+ if (GetClientRect(hwnd(), &cr)) {
+ if (exposed_pixels_.height() > 0) {
+ DCHECK_GE(cr.bottom, exposed_pixels_.height());
+ RECT rect = {cr.left, cr.bottom - exposed_pixels_.height(), cr.right,
+ cr.bottom};
+ FillRect(ps.hdc, &rect, brush);
+ }
+ if (exposed_pixels_.width() > 0) {
+ DCHECK_GE(cr.right, exposed_pixels_.width());
+ RECT rect = {cr.right - exposed_pixels_.width(), cr.top, cr.right,
+ cr.bottom - exposed_pixels_.height()};
+ FillRect(ps.hdc, &rect, brush);
+ }
+ }
}
+
delegate_->HandlePaintAccelerated(gfx::Rect(ps.rcPaint));
}
+ exposed_pixels_ = gfx::Size();
+
EndPaint(hwnd(), &ps);
}
@@ -2815,6 +2834,10 @@ void HWNDMessageHandler::OnWindowPosChanging(WINDOWPOS* window_pos) {
gfx::Size new_size = gfx::Size(window_pos->cx, window_pos->cy);
if ((old_size != new_size && !(window_pos->flags & SWP_NOSIZE)) ||
window_pos->flags & SWP_FRAMECHANGED) {
+ // If the window is getting larger then fill the exposed area on the next
+ // WM_PAINT.
+ exposed_pixels_ = new_size - old_size;
+
delegate_->HandleWindowSizeChanging();
sent_window_size_changing_ = true;
@@ -2827,6 +2850,9 @@ void HWNDMessageHandler::OnWindowPosChanging(WINDOWPOS* window_pos) {
// resizing. See https://crbug.com/739724
if (is_translucent_)
window_pos->flags |= SWP_NOCOPYBITS;
+ } else {
+ // The window size isn't changing so there are no exposed pixels.
+ exposed_pixels_ = gfx::Size();
}
if (ScopedFullscreenVisibility::IsHiddenForFullscreen(hwnd())) {
@@ -2867,10 +2893,13 @@ LRESULT HWNDMessageHandler::OnWindowSizingFinished(UINT message,
// received after this message was posted.
if (current_window_size_message_ != w_param)
return 0;
-
delegate_->HandleWindowSizeUnchanged();
sent_window_size_changing_ = false;
+ // The window size didn't actually change, so nothing was exposed that needs
+ // to be filled black.
+ exposed_pixels_ = gfx::Size();
+
return 0;
}
@@ -3126,9 +3155,8 @@ LRESULT HWNDMessageHandler::HandlePointerEventTypeTouch(UINT message,
ui::TouchEvent event(
event_type, touch_point, event_time,
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH,
- mapped_pointer_id, radius_x, radius_y, pressure,
- rotation_angle),
+ ui::PointerDetails(ui::EventPointerType::kTouch, mapped_pointer_id,
+ radius_x, radius_y, pressure, rotation_angle),
ui::GetModifiersFromKeyState());
event.latency()->AddLatencyNumberWithTimestamp(
@@ -3282,9 +3310,8 @@ void HWNDMessageHandler::GenerateTouchEvent(ui::EventType event_type,
size_t id,
base::TimeTicks time_stamp,
TouchEvents* touch_events) {
- ui::TouchEvent event(
- event_type, point, time_stamp,
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, id));
+ ui::TouchEvent event(event_type, point, time_stamp,
+ ui::PointerDetails(ui::EventPointerType::kTouch, id));
event.set_flags(ui::GetModifiersFromKeyState());
diff --git a/chromium/ui/views/win/hwnd_message_handler.h b/chromium/ui/views/win/hwnd_message_handler.h
index 7b56d58faff..a84076658b4 100644
--- a/chromium/ui/views/win/hwnd_message_handler.h
+++ b/chromium/ui/views/win/hwnd_message_handler.h
@@ -625,10 +625,6 @@ class VIEWS_EXPORT HWNDMessageHandler : public gfx::WindowImpl,
// The current cursor.
HCURSOR current_cursor_;
- // The last cursor that was active before the current one was selected. Saved
- // so that we can restore it.
- HCURSOR previous_cursor_;
-
// The icon created from the bitmap image of the window icon.
base::win::ScopedHICON window_icon_;
@@ -798,6 +794,11 @@ class VIEWS_EXPORT HWNDMessageHandler : public gfx::WindowImpl,
static base::LazyInstance<FullscreenWindowMonitorMap>::DestructorAtExit
fullscreen_monitor_map_;
+ // How many pixels the window is expected to grow from OnWindowPosChanging().
+ // Used to fill the newly exposed pixels black in OnPaint() before the
+ // browser compositor is able to redraw at the new window size.
+ gfx::Size exposed_pixels_;
+
// Populated if the cursor position is being mocked for testing purposes.
base::Optional<gfx::Point> mock_cursor_position_;
diff --git a/chromium/ui/views/win/pen_event_processor.cc b/chromium/ui/views/win/pen_event_processor.cc
index 3ff82e59065..46ac6b2c8f7 100644
--- a/chromium/ui/views/win/pen_event_processor.cc
+++ b/chromium/ui/views/win/pen_event_processor.cc
@@ -4,6 +4,8 @@
#include "ui/views/win/pen_event_processor.h"
+#include "base/check.h"
+#include "base/notreached.h"
#include "base/time/time.h"
#include "ui/events/event_utils.h"
@@ -40,16 +42,16 @@ std::unique_ptr<ui::Event> PenEventProcessor::GenerateEvent(
// We are now creating a fake mouse event with pointer type of pen from
// the WM_POINTER message and then setting up an associated pointer
// details in the MouseEvent which contains the pen's information.
- ui::EventPointerType input_type = ui::EventPointerType::POINTER_TYPE_PEN;
+ ui::EventPointerType input_type = ui::EventPointerType::kPen;
// For the pointerup event, the penFlags is not set to PEN_FLAG_ERASER, so we
// have to check if previously the pointer type is an eraser.
if (pointer_pen_info.penFlags & PEN_FLAG_ERASER) {
- input_type = ui::EventPointerType::POINTER_TYPE_ERASER;
+ input_type = ui::EventPointerType::kEraser;
DCHECK(!eraser_pointer_id_ || *eraser_pointer_id_ == mapped_pointer_id);
eraser_pointer_id_ = mapped_pointer_id;
} else if (eraser_pointer_id_ && *eraser_pointer_id_ == mapped_pointer_id &&
(message == WM_POINTERUP || message == WM_NCPOINTERUP)) {
- input_type = ui::EventPointerType::POINTER_TYPE_ERASER;
+ input_type = ui::EventPointerType::kEraser;
eraser_pointer_id_.reset();
}
diff --git a/chromium/ui/views/win/pen_event_processor_unittest.cc b/chromium/ui/views/win/pen_event_processor_unittest.cc
index 211a735e062..652606182df 100644
--- a/chromium/ui/views/win/pen_event_processor_unittest.cc
+++ b/chromium/ui/views/win/pen_event_processor_unittest.cc
@@ -245,7 +245,7 @@ TEST(PenProcessorTest, PenEraserFlagDMEnabled) {
ASSERT_TRUE(event);
ASSERT_TRUE(event->IsTouchEvent());
EXPECT_EQ(ui::ET_TOUCH_PRESSED, event->AsTouchEvent()->type());
- EXPECT_EQ(ui::EventPointerType::POINTER_TYPE_ERASER,
+ EXPECT_EQ(ui::EventPointerType::kEraser,
event->AsTouchEvent()->pointer_details().pointer_type);
pen_info.pointerInfo.pointerFlags = POINTER_FLAG_UP;
@@ -255,7 +255,7 @@ TEST(PenProcessorTest, PenEraserFlagDMEnabled) {
ASSERT_TRUE(event);
ASSERT_TRUE(event->IsTouchEvent());
EXPECT_EQ(ui::ET_TOUCH_RELEASED, event->AsTouchEvent()->type());
- EXPECT_EQ(ui::EventPointerType::POINTER_TYPE_ERASER,
+ EXPECT_EQ(ui::EventPointerType::kEraser,
event->AsTouchEvent()->pointer_details().pointer_type);
}
diff --git a/chromium/ui/views/win/scoped_fullscreen_visibility.cc b/chromium/ui/views/win/scoped_fullscreen_visibility.cc
index e3103243c64..4c77b7e7ee8 100644
--- a/chromium/ui/views/win/scoped_fullscreen_visibility.cc
+++ b/chromium/ui/views/win/scoped_fullscreen_visibility.cc
@@ -6,7 +6,7 @@
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
namespace views {
diff --git a/chromium/ui/views/window/caption_button_layout_constants.cc b/chromium/ui/views/window/caption_button_layout_constants.cc
index a0738471c3f..3845999821f 100644
--- a/chromium/ui/views/window/caption_button_layout_constants.cc
+++ b/chromium/ui/views/window/caption_button_layout_constants.cc
@@ -4,7 +4,6 @@
#include "ui/views/window/caption_button_layout_constants.h"
-#include "base/logging.h"
#include "ui/base/pointer/touch_ui_controller.h"
#include "ui/gfx/geometry/size.h"
diff --git a/chromium/ui/views/window/client_view.cc b/chromium/ui/views/window/client_view.cc
index c1b7d081893..13562905b1a 100644
--- a/chromium/ui/views/window/client_view.cc
+++ b/chromium/ui/views/window/client_view.cc
@@ -6,7 +6,7 @@
#include <memory>
-#include "base/logging.h"
+#include "base/check.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/base/hit_test.h"
diff --git a/chromium/ui/views/window/dialog_client_view.cc b/chromium/ui/views/window/dialog_client_view.cc
index 7c683a51ae9..64e7e523b45 100644
--- a/chromium/ui/views/window/dialog_client_view.cc
+++ b/chromium/ui/views/window/dialog_client_view.cc
@@ -266,10 +266,8 @@ void DialogClientView::UpdateDialogButton(LabelButton** member,
return;
}
- std::unique_ptr<LabelButton> button =
- is_default ? MdTextButton::CreateSecondaryUiBlueButton(this, title)
- : MdTextButton::CreateSecondaryUiButton(this, title);
-
+ auto button = MdTextButton::Create(this, title);
+ button->SetProminent(is_default);
button->SetIsDefault(is_default);
button->SetEnabled(delegate->IsDialogButtonEnabled(type));
@@ -352,13 +350,13 @@ void DialogClientView::SetupLayout() {
// into the layout. This simplifies min/max size calculations.
column_set->AddPaddingColumn(kFixed, button_row_insets_.left());
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kFixed,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddPaddingColumn(kStretchy, GetExtraViewSpacing());
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kFixed,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddPaddingColumn(kFixed, button_spacing);
column_set->AddColumn(GridLayout::FILL, GridLayout::FILL, kFixed,
- GridLayout::USE_PREF, 0, 0);
+ GridLayout::ColumnSize::kUsePreferred, 0, 0);
column_set->AddPaddingColumn(kFixed, button_row_insets_.right());
// Track which columns to link sizes under MD.
diff --git a/chromium/ui/views/window/dialog_client_view_unittest.cc b/chromium/ui/views/window/dialog_client_view_unittest.cc
index 390eac20ccd..921d7e999f8 100644
--- a/chromium/ui/views/window/dialog_client_view_unittest.cc
+++ b/chromium/ui/views/window/dialog_client_view_unittest.cc
@@ -50,6 +50,9 @@ class DialogClientViewTest : public test::WidgetTest,
params.delegate = this;
widget_->Init(std::move(params));
EXPECT_EQ(this, GetContentsView());
+ layout_provider_ = std::make_unique<test::TestLayoutProvider>();
+ layout_provider_->SetDistanceMetric(DISTANCE_BUTTON_MAX_LINKABLE_WIDTH,
+ 200);
}
void TearDown() override {
@@ -90,6 +93,11 @@ class DialogClientViewTest : public test::WidgetTest,
DialogModelChanged();
}
+ void SetDialogButtonLabel(ui::DialogButton button, const std::string& label) {
+ DialogDelegate::SetButtonLabel(button, base::UTF8ToUTF16(label));
+ DialogModelChanged();
+ }
+
// Sets the view to provide to DisownExtraView() and updates the dialog. This
// can only be called a single time because DialogClientView caches the result
// of DisownExtraView() and never calls it again.
@@ -124,14 +132,34 @@ class DialogClientViewTest : public test::WidgetTest,
DialogModelChanged();
}
+ views::Button* GetButtonByAccessibleName(views::View* root,
+ const base::string16& name) {
+ views::Button* button = Button::AsButton(root);
+ if (button && button->GetAccessibleName() == name)
+ return button;
+ for (auto* child : root->children()) {
+ button = GetButtonByAccessibleName(child, name);
+ if (button)
+ return button;
+ }
+ return nullptr;
+ }
+
+ views::Button* GetButtonByAccessibleName(const std::string& label) {
+ return GetButtonByAccessibleName(widget_->GetRootView(),
+ base::UTF8ToUTF16(label));
+ }
+
DialogClientView* client_view() {
return static_cast<DialogClientView*>(widget_->client_view());
}
Widget* widget() { return widget_; }
+ test::TestLayoutProvider* layout_provider() { return layout_provider_.get(); }
private:
// The dialog Widget.
+ std::unique_ptr<test::TestLayoutProvider> layout_provider_;
Widget* widget_ = nullptr;
gfx::Size preferred_size_;
@@ -330,8 +358,6 @@ TEST_F(DialogClientViewTest, MinMaxPreferredSize) {
// Ensure button widths are linked under MD.
TEST_F(DialogClientViewTest, LinkedWidthDoesLink) {
- test::TestLayoutProvider layout_provider;
- layout_provider.SetDistanceMetric(DISTANCE_BUTTON_MAX_LINKABLE_WIDTH, 200);
SetLongCancelLabel();
// Ensure there is no default button since getting a bold font can throw off
@@ -361,13 +387,13 @@ TEST_F(DialogClientViewTest, LinkedWidthDoesLink) {
EXPECT_EQ(cancel_button_width, client_view()->ok_button()->width());
// But not when the size of the cancel button exceeds the max linkable width.
- layout_provider.SetDistanceMetric(DISTANCE_BUTTON_MAX_LINKABLE_WIDTH, 100);
+ layout_provider()->SetDistanceMetric(DISTANCE_BUTTON_MAX_LINKABLE_WIDTH, 100);
EXPECT_GT(cancel_button_width, 100);
DialogModelChanged();
CheckContentsIsSetToPreferredSize();
EXPECT_EQ(ok_button_only_width, client_view()->ok_button()->width());
- layout_provider.SetDistanceMetric(DISTANCE_BUTTON_MAX_LINKABLE_WIDTH, 200);
+ layout_provider()->SetDistanceMetric(DISTANCE_BUTTON_MAX_LINKABLE_WIDTH, 200);
// The extra view should also match, if it's a matching button type.
View* extra_button =
@@ -377,8 +403,6 @@ TEST_F(DialogClientViewTest, LinkedWidthDoesLink) {
}
TEST_F(DialogClientViewTest, LinkedWidthDoesntLink) {
- test::TestLayoutProvider layout_provider;
- layout_provider.SetDistanceMetric(DISTANCE_BUTTON_MAX_LINKABLE_WIDTH, 200);
SetLongCancelLabel();
// Ensure there is no default button since getting a bold font can throw off
@@ -408,13 +432,13 @@ TEST_F(DialogClientViewTest, LinkedWidthDoesntLink) {
EXPECT_EQ(cancel_button_width, client_view()->ok_button()->width());
// But not when the size of the cancel button exceeds the max linkable width.
- layout_provider.SetDistanceMetric(DISTANCE_BUTTON_MAX_LINKABLE_WIDTH, 100);
+ layout_provider()->SetDistanceMetric(DISTANCE_BUTTON_MAX_LINKABLE_WIDTH, 100);
EXPECT_GT(cancel_button_width, 100);
DialogModelChanged();
CheckContentsIsSetToPreferredSize();
EXPECT_EQ(ok_button_only_width, client_view()->ok_button()->width());
- layout_provider.SetDistanceMetric(DISTANCE_BUTTON_MAX_LINKABLE_WIDTH, 200);
+ layout_provider()->SetDistanceMetric(DISTANCE_BUTTON_MAX_LINKABLE_WIDTH, 200);
// Checkbox extends LabelButton, but it should not participate in linking.
View* extra_button =
@@ -542,4 +566,74 @@ TEST_F(DialogClientViewTest, IgnorePossiblyUnintendedClicks_RepeatedClicks) {
EXPECT_TRUE(widget()->IsClosed());
}
+TEST_F(DialogClientViewTest, ButtonLayoutWithExtra) {
+ // The dialog button row's layout should look like:
+ // | <inset> [extra] <flex-margin> [cancel] <margin> [ok] <inset> |
+ // Where:
+ // 1) The two insets are linkable
+ // 2) The ok & cancel buttons have their width linked
+ // 3) The extra button has its width linked to the other two
+ // 4) The margin should be invariant as the dialog changes width
+ // 5) The flex margin should change as the dialog changes width
+ //
+ // Note that cancel & ok may swap order depending on
+ // PlatformStyle::kIsOkButtonLeading; these invariants hold for either order.
+ SetDialogButtons(ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL);
+ SetDialogButtonLabel(ui::DIALOG_BUTTON_OK, "ok");
+ SetDialogButtonLabel(ui::DIALOG_BUTTON_CANCEL, "cancel");
+ SetExtraView(
+ std::make_unique<LabelButton>(nullptr, base::UTF8ToUTF16("extra")));
+
+ widget()->Show();
+
+ Button* ok = GetButtonByAccessibleName("ok");
+ Button* cancel = GetButtonByAccessibleName("cancel");
+ Button* extra = GetButtonByAccessibleName("extra");
+
+ ASSERT_NE(ok, cancel);
+ ASSERT_NE(ok, extra);
+ ASSERT_NE(cancel, extra);
+
+ client_view()->SizeToPreferredSize();
+ client_view()->Layout();
+
+ auto bounds_left = [](View* v) { return v->GetBoundsInScreen().x(); };
+ auto bounds_right = [](View* v) { return v->GetBoundsInScreen().right(); };
+
+ // (1): left inset == right inset (and they shouldn't be 0):
+ int left_inset = bounds_left(extra) - bounds_left(this);
+ int right_inset =
+ bounds_right(this) - std::max(bounds_right(ok), bounds_right(cancel));
+ EXPECT_EQ(left_inset, right_inset);
+ EXPECT_GT(left_inset, 0);
+
+ // (2) & (3): All three buttons have their widths linked:
+ EXPECT_EQ(ok->width(), cancel->width());
+ EXPECT_EQ(ok->width(), extra->width());
+ EXPECT_GT(ok->width(), 0);
+
+ // (4): Margin between ok & cancel should be invariant as dialog width
+ // changes:
+ auto get_margin = [&]() {
+ return std::max(bounds_left(ok), bounds_left(cancel)) -
+ std::min(bounds_right(ok), bounds_right(cancel));
+ };
+
+ // (5): Flex margin between ok/cancel and extra should vary with dialog width
+ // (it should absorb 100% of the change in width)
+ auto get_flex_margin = [&]() {
+ return std::min(bounds_left(ok), bounds_left(cancel)) - bounds_right(extra);
+ };
+
+ int old_margin = get_margin();
+ int old_flex_margin = get_flex_margin();
+
+ SetSizeConstraints(gfx::Size(), gfx::Size(width() + 100, 0), gfx::Size());
+ client_view()->SizeToPreferredSize();
+ client_view()->Layout();
+
+ EXPECT_EQ(old_margin, get_margin());
+ EXPECT_EQ(old_flex_margin + 100, get_flex_margin());
+}
+
} // namespace views
diff --git a/chromium/ui/views/window/dialog_delegate.cc b/chromium/ui/views/window/dialog_delegate.cc
index 16ee3828e40..6afc661f5a2 100644
--- a/chromium/ui/views/window/dialog_delegate.cc
+++ b/chromium/ui/views/window/dialog_delegate.cc
@@ -12,6 +12,7 @@
#include "build/build_config.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
+#include "ui/accessibility/ax_role_properties.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/color_palette.h"
#include "ui/strings/grit/ui_strings.h"
@@ -42,6 +43,8 @@ DialogDelegate::Params::~Params() = default;
// DialogDelegate:
DialogDelegate::DialogDelegate() {
+ WidgetDelegate::RegisterWindowWillCloseCallback(
+ base::BindOnce(&DialogDelegate::WindowWillClose, base::Unretained(this)));
UMA_HISTOGRAM_BOOLEAN("Dialog.DialogDelegate.Create", true);
creation_time_ = base::TimeTicks::Now();
}
@@ -135,7 +138,7 @@ base::string16 DialogDelegate::GetDialogButtonLabel(
}
bool DialogDelegate::IsDialogButtonEnabled(ui::DialogButton button) const {
- return true;
+ return params_.enabled_buttons & button;
}
bool DialogDelegate::Cancel() {
@@ -324,16 +327,35 @@ void DialogDelegate::DialogModelChanged() {
}
void DialogDelegate::SetDefaultButton(int button) {
+ if (params_.default_button == button)
+ return;
params_.default_button = button;
+ DialogModelChanged();
}
void DialogDelegate::SetButtons(int buttons) {
+ if (params_.buttons == buttons)
+ return;
params_.buttons = buttons;
+ DialogModelChanged();
+}
+
+void DialogDelegate::SetButtonEnabled(ui::DialogButton button, bool enabled) {
+ if (!!(params_.enabled_buttons & button) == enabled)
+ return;
+ if (enabled)
+ params_.enabled_buttons |= button;
+ else
+ params_.enabled_buttons &= ~button;
+ DialogModelChanged();
}
void DialogDelegate::SetButtonLabel(ui::DialogButton button,
base::string16 label) {
+ if (params_.button_labels[button] == label)
+ return;
params_.button_labels[button] = label;
+ DialogModelChanged();
}
void DialogDelegate::SetAcceptCallback(base::OnceClosure callback) {
@@ -430,8 +452,7 @@ View* DialogDelegateView::GetContentsView() {
void DialogDelegateView::ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) {
if (details.is_add && details.child == this && GetWidget() &&
- (GetAccessibleWindowRole() == ax::mojom::Role::kAlert ||
- GetAccessibleWindowRole() == ax::mojom::Role::kAlertDialog)) {
+ ui::IsAlert(GetAccessibleWindowRole())) {
NotifyAccessibilityEvent(ax::mojom::Event::kAlert, true);
}
}
diff --git a/chromium/ui/views/window/dialog_delegate.h b/chromium/ui/views/window/dialog_delegate.h
index 54ea673bb33..04bc5b4cdce 100644
--- a/chromium/ui/views/window/dialog_delegate.h
+++ b/chromium/ui/views/window/dialog_delegate.h
@@ -59,6 +59,11 @@ class VIEWS_EXPORT DialogDelegate : public WidgetDelegate {
// Prefer to use this field (via SetButtonLabel) rather than override
// GetDialogButtonLabel - see https://crbug.com/1011446
base::string16 button_labels[ui::DIALOG_BUTTON_LAST + 1];
+
+ // A bitmask of buttons (from ui::DialogButton) that are enabled in this
+ // dialog. It's legal for a button to be marked enabled that isn't present
+ // in |buttons| (see above).
+ int enabled_buttons = ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
};
DialogDelegate();
@@ -130,7 +135,6 @@ class VIEWS_EXPORT DialogDelegate : public WidgetDelegate {
DialogDelegate* AsDialogDelegate() override;
ClientView* CreateClientView(Widget* widget) override;
NonClientFrameView* CreateNonClientFrameView(Widget* widget) override;
- void WindowWillClose() override;
static NonClientFrameView* CreateDialogFrameView(Widget* widget);
@@ -169,7 +173,11 @@ class VIEWS_EXPORT DialogDelegate : public WidgetDelegate {
void AddObserver(DialogObserver* observer);
void RemoveObserver(DialogObserver* observer);
- // Notifies observers when the result of the DialogModel overrides changes.
+ // Notifies DialogDelegate that the result of one of the virtual getter
+ // functions above has changed, which causes it to rebuild its layout. It is
+ // not necessary to call this unless you are overriding
+ // IsDialogButtonEnabled() or manually manipulating the dialog buttons.
+ // TODO(https://crbug.com/1011446): Make this private.
void DialogModelChanged();
void set_use_round_corners(bool round) { params_.round_corners = round; }
@@ -178,9 +186,12 @@ class VIEWS_EXPORT DialogDelegate : public WidgetDelegate {
void set_use_custom_frame(bool use) { params_.custom_frame = use; }
bool use_custom_frame() const { return params_.custom_frame; }
+ // These methods internally call DialogModelChanged() if needed, so it is not
+ // necessary to call DialogModelChanged() yourself after calling them.
void SetDefaultButton(int button);
void SetButtons(int buttons);
void SetButtonLabel(ui::DialogButton button, base::string16 label);
+ void SetButtonEnabled(ui::DialogButton button, bool enabled);
void SetAcceptCallback(base::OnceClosure callback);
void SetCancelCallback(base::OnceClosure callback);
void SetCloseCallback(base::OnceClosure callback);
@@ -243,6 +254,10 @@ class VIEWS_EXPORT DialogDelegate : public WidgetDelegate {
// dialogs use the same button row insets.
void SetButtonRowInsets(const gfx::Insets& insets);
+ // Callback for WidgetDelegate when the window this dialog is hosted in is
+ // closing. Don't call this yourself.
+ void WindowWillClose();
+
protected:
~DialogDelegate() override;
diff --git a/chromium/ui/views/window/dialog_delegate_unittest.cc b/chromium/ui/views/window/dialog_delegate_unittest.cc
index eeaf5cd23a8..6096431dc6b 100644
--- a/chromium/ui/views/window/dialog_delegate_unittest.cc
+++ b/chromium/ui/views/window/dialog_delegate_unittest.cc
@@ -427,6 +427,17 @@ TEST_F(DialogTest, UnfocusableInitialFocus) {
dialog_widget->CloseNow();
}
+TEST_F(DialogTest, ButtonEnableUpdatesState) {
+ test::WidgetTest::WidgetAutoclosePtr widget(
+ CreateDialogWidget(new DialogDelegateView));
+ auto* dialog = static_cast<DialogDelegateView*>(widget->widget_delegate());
+
+ EXPECT_TRUE(dialog->GetOkButton()->GetEnabled());
+ dialog->SetButtonEnabled(ui::DIALOG_BUTTON_OK, false);
+ dialog->DialogModelChanged();
+ EXPECT_FALSE(dialog->GetOkButton()->GetEnabled());
+}
+
using DialogDelegateCloseTest = ViewsTestBase;
TEST_F(DialogDelegateCloseTest, AnyCallbackInhibitsDefaultClose) {
diff --git a/chromium/ui/views/window/window_resize_utils.cc b/chromium/ui/views/window/window_resize_utils.cc
index 8ec1727320e..5578e3ac267 100644
--- a/chromium/ui/views/window/window_resize_utils.cc
+++ b/chromium/ui/views/window/window_resize_utils.cc
@@ -6,6 +6,7 @@
#include <algorithm>
+#include "base/check_op.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/size.h"
diff --git a/chromium/ui/views_content_client/BUILD.gn b/chromium/ui/views_content_client/BUILD.gn
index 2fd7f929eb9..813ef413a17 100644
--- a/chromium/ui/views_content_client/BUILD.gn
+++ b/chromium/ui/views_content_client/BUILD.gn
@@ -77,8 +77,4 @@ jumbo_component("views_content_client") {
"//ui/wm:test_support",
]
}
-
- if (use_x11 || ozone_platform_x11) {
- configs += [ "//build/config/linux:x11" ]
- }
}
diff --git a/chromium/ui/views_content_client/views_content_client.cc b/chromium/ui/views_content_client/views_content_client.cc
index 95e750eb1fa..31142f6f69f 100644
--- a/chromium/ui/views_content_client/views_content_client.cc
+++ b/chromium/ui/views_content_client/views_content_client.cc
@@ -48,4 +48,9 @@ void ViewsContentClient::OnPreMainMessageLoopRun(
.Run(browser_context, window_context);
}
+void ViewsContentClient::OnResourcesLoaded() {
+ if (on_resources_loaded_callback_)
+ std::move(on_resources_loaded_callback_).Run();
+}
+
} // namespace ui
diff --git a/chromium/ui/views_content_client/views_content_client.h b/chromium/ui/views_content_client/views_content_client.h
index 78971231f15..4e4fb3ecd34 100644
--- a/chromium/ui/views_content_client/views_content_client.h
+++ b/chromium/ui/views_content_client/views_content_client.h
@@ -69,12 +69,19 @@ class VIEWS_CONTENT_CLIENT_EXPORT ViewsContentClient {
on_pre_main_message_loop_run_callback_ = std::move(callback);
}
+ void set_on_resources_loaded_callback(base::OnceClosure callback) {
+ on_resources_loaded_callback_ = std::move(callback);
+ }
+
// Calls the OnPreMainMessageLoopRun callback. |browser_context| is the
// current browser context. |window_context| is a candidate root window that
// may be null.
void OnPreMainMessageLoopRun(content::BrowserContext* browser_context,
gfx::NativeWindow window_context);
+ // Calls a callback to signal resources have been loaded.
+ void OnResourcesLoaded();
+
// Called by ViewsContentClientMainParts to supply the quit-closure to use
// to exit RunMain().
void set_quit_closure(base::OnceClosure quit_closure) {
@@ -91,6 +98,7 @@ class VIEWS_CONTENT_CLIENT_EXPORT ViewsContentClient {
const char** argv_;
#endif
OnPreMainMessageLoopRunCallback on_pre_main_message_loop_run_callback_;
+ base::OnceClosure on_resources_loaded_callback_;
base::OnceClosure quit_closure_;
DISALLOW_COPY_AND_ASSIGN(ViewsContentClient);
diff --git a/chromium/ui/views_content_client/views_content_client_main_parts_desktop_aura.cc b/chromium/ui/views_content_client/views_content_client_main_parts_desktop_aura.cc
index 398cf63afca..7797e66e209 100644
--- a/chromium/ui/views_content_client/views_content_client_main_parts_desktop_aura.cc
+++ b/chromium/ui/views_content_client/views_content_client_main_parts_desktop_aura.cc
@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "base/macros.h"
#include "content/shell/browser/shell_browser_context.h"
#include "ui/display/screen.h"
#include "ui/views/widget/desktop_aura/desktop_screen.h"
@@ -19,13 +18,14 @@ class ViewsContentClientMainPartsDesktopAura
ViewsContentClientMainPartsDesktopAura(
const content::MainFunctionParams& content_params,
ViewsContentClient* views_content_client);
- ~ViewsContentClientMainPartsDesktopAura() override {}
+ ViewsContentClientMainPartsDesktopAura(
+ const ViewsContentClientMainPartsDesktopAura&) = delete;
+ ViewsContentClientMainPartsDesktopAura& operator=(
+ const ViewsContentClientMainPartsDesktopAura&) = delete;
+ ~ViewsContentClientMainPartsDesktopAura() override = default;
- // content::BrowserMainParts:
+ // ViewsContentClientMainPartsAura:
void PreMainMessageLoopRun() override;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(ViewsContentClientMainPartsDesktopAura);
};
ViewsContentClientMainPartsDesktopAura::ViewsContentClientMainPartsDesktopAura(
diff --git a/chromium/ui/views_content_client/views_content_main_delegate.cc b/chromium/ui/views_content_client/views_content_main_delegate.cc
index c2dbd99d528..8a85f930b5a 100644
--- a/chromium/ui/views_content_client/views_content_main_delegate.cc
+++ b/chromium/ui/views_content_client/views_content_main_delegate.cc
@@ -15,6 +15,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
#include "ui/views_content_client/views_content_browser_client.h"
+#include "ui/views_content_client/views_content_client.h"
#include "ui/views_content_client/views_content_client_main_parts.h"
#if defined(OS_WIN)
@@ -77,6 +78,8 @@ void ViewsContentMainDelegate::PreSandboxStartup() {
ui::ResourceBundle::GetSharedInstance().AddDataPackFromPath(
ui_test_resources_200, ui::SCALE_FACTOR_200P);
}
+
+ views_content_client_->OnResourcesLoaded();
}
void ViewsContentMainDelegate::PreCreateMainMessageLoop() {
diff --git a/chromium/ui/web_dialogs/web_dialog_web_contents_delegate.cc b/chromium/ui/web_dialogs/web_dialog_web_contents_delegate.cc
index e3396bc1bc6..62525d47d6f 100644
--- a/chromium/ui/web_dialogs/web_dialog_web_contents_delegate.cc
+++ b/chromium/ui/web_dialogs/web_dialog_web_contents_delegate.cc
@@ -6,7 +6,7 @@
#include <utility>
-#include "base/logging.h"
+#include "base/check.h"
#include "content/public/browser/web_contents.h"
#include "third_party/blink/public/common/input/web_gesture_event.h"
@@ -44,6 +44,7 @@ WebContents* WebDialogWebContentsDelegate::OpenURLFromTab(
void WebDialogWebContentsDelegate::AddNewContents(
WebContents* source,
std::unique_ptr<WebContents> new_contents,
+ const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
@@ -51,7 +52,7 @@ void WebDialogWebContentsDelegate::AddNewContents(
// TODO(erikchen): Refactor AddNewContents to take strong ownership semantics.
// https://crbug.com/832879.
handler_->AddNewContents(browser_context_, source, std::move(new_contents),
- disposition, initial_rect, user_gesture);
+ target_url, disposition, initial_rect, user_gesture);
}
bool WebDialogWebContentsDelegate::PreHandleGestureEvent(
diff --git a/chromium/ui/web_dialogs/web_dialog_web_contents_delegate.h b/chromium/ui/web_dialogs/web_dialog_web_contents_delegate.h
index 5441fc30ccc..7bb20cc0f39 100644
--- a/chromium/ui/web_dialogs/web_dialog_web_contents_delegate.h
+++ b/chromium/ui/web_dialogs/web_dialog_web_contents_delegate.h
@@ -37,6 +37,7 @@ class WEB_DIALOGS_EXPORT WebDialogWebContentsDelegate
content::BrowserContext* context,
content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
+ const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture) = 0;
@@ -63,6 +64,7 @@ class WEB_DIALOGS_EXPORT WebDialogWebContentsDelegate
const content::OpenURLParams& params) override;
void AddNewContents(content::WebContents* source,
std::unique_ptr<content::WebContents> new_contents,
+ const GURL& target_url,
WindowOpenDisposition disposition,
const gfx::Rect& initial_rect,
bool user_gesture,
diff --git a/chromium/ui/webui/BUILD.gn b/chromium/ui/webui/BUILD.gn
index 16f9b7c9a96..bc3709a4084 100644
--- a/chromium/ui/webui/BUILD.gn
+++ b/chromium/ui/webui/BUILD.gn
@@ -6,10 +6,15 @@ static_library("webui") {
sources = [
"mojo_web_ui_controller.cc",
"mojo_web_ui_controller.h",
+ "webui_allowlist.cc",
+ "webui_allowlist.h",
+ "webui_allowlist_provider.cc",
+ "webui_allowlist_provider.h",
]
deps = [
"//base",
+ "//components/content_settings/core/browser",
"//content/public/browser",
"//services/service_manager/public/cpp",
]
diff --git a/chromium/ui/webui/DEPS b/chromium/ui/webui/DEPS
index 321835281a4..b5254b64b3f 100644
--- a/chromium/ui/webui/DEPS
+++ b/chromium/ui/webui/DEPS
@@ -5,4 +5,5 @@ include_rules = [
"+services/service_manager/public/cpp/binder_registry.h",
"+ui/base",
"+ui/gfx",
+ "+components/content_settings/core"
]
diff --git a/chromium/ui/webui/PLATFORM_OWNERS b/chromium/ui/webui/PLATFORM_OWNERS
index 4b5999e219f..ecfd43c2278 100644
--- a/chromium/ui/webui/PLATFORM_OWNERS
+++ b/chromium/ui/webui/PLATFORM_OWNERS
@@ -1,5 +1,6 @@
# Please use more specific OWNERS when possible.
aee@chromium.org
+antrim@chromium.org # CET
calamity@chromium.org
dpapad@chromium.org
dschuyler@chromium.org
diff --git a/chromium/ui/webui/resources/BUILD.gn b/chromium/ui/webui/resources/BUILD.gn
index ad0963371cc..1fa92abd76e 100644
--- a/chromium/ui/webui/resources/BUILD.gn
+++ b/chromium/ui/webui/resources/BUILD.gn
@@ -6,19 +6,29 @@ import("//third_party/closure_compiler/compile_js.gni")
group("closure_compile") {
deps = [
- "cr_components:closure_compile",
- "cr_elements:closure_compile",
"js:closure_compile",
"js:closure_compile_modules",
]
+
+ if (!is_android) {
+ deps += [
+ "cr_components:closure_compile",
+ "cr_elements:closure_compile",
+ ]
+ }
}
group("modulize") {
public_deps = [
- "cr_components:polymer3_elements",
- "cr_elements:polymer3_elements",
"js:modulize",
"js/cr:modulize",
"js/cr/ui:modulize",
]
+
+ if (!is_android) {
+ public_deps += [
+ "cr_components:polymer3_elements",
+ "cr_elements:polymer3_elements",
+ ]
+ }
}
diff --git a/chromium/ui/webui/resources/cr_components/BUILD.gn b/chromium/ui/webui/resources/cr_components/BUILD.gn
index 63837cb97f9..a9eec51ac3c 100644
--- a/chromium/ui/webui/resources/cr_components/BUILD.gn
+++ b/chromium/ui/webui/resources/cr_components/BUILD.gn
@@ -6,7 +6,7 @@ import("//third_party/closure_compiler/compile_js.gni")
group("closure_compile") {
deps = [
- "certificate_manager:closure_compile",
+ "certificate_manager:closure_compile_module",
"managed_footnote:closure_compile",
"managed_footnote:closure_compile_module",
"omnibox:closure_compile",
@@ -19,9 +19,9 @@ group("closure_compile") {
group("polymer3_elements") {
public_deps = [
- "certificate_manager:polymer3_elements",
+ "certificate_manager:web_components",
"managed_footnote:managed_footnote_module",
- "omnibox:omnibox_modules",
+ "omnibox:web_components",
]
if (is_chromeos) {
public_deps += [ "chromeos:polymer3_elements" ]
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/BUILD.gn b/chromium/ui/webui/resources/cr_components/certificate_manager/BUILD.gn
index 21da554f290..46b2c6594af 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/BUILD.gn
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/BUILD.gn
@@ -3,10 +3,10 @@
# found in the LICENSE file.
import("//third_party/closure_compiler/compile_js.gni")
-import("//tools/polymer/polymer.gni")
-import("../../tools/js_modulizer.gni")
+import("//tools/polymer/html_to_js.gni")
-js_type_check("closure_compile") {
+js_type_check("closure_compile_module") {
+ is_polymer3 = true
deps = [
":ca_trust_edit_dialog",
":certificate_delete_confirmation_dialog",
@@ -20,372 +20,171 @@ js_type_check("closure_compile") {
":certificates_browser_proxy",
":certificates_error_dialog",
]
+
+ # These are Chrome OS specific but always included because of limitations
+ # around conditional imports (https://crbug.com/1071641#c10).
+ deps += [
+ ":certificate_provisioning_browser_proxy",
+ ":certificate_provisioning_details_dialog",
+ ":certificate_provisioning_entry",
+ ":certificate_provisioning_list",
+ ]
}
js_library("ca_trust_edit_dialog") {
deps = [
- ":certificate_manager_types",
":certificates_browser_proxy",
- "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
- "//ui/webui/resources/js:cr",
- "//ui/webui/resources/js:i18n_behavior",
- "//ui/webui/resources/js:load_time_data",
+ "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
+ "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m",
+ "//ui/webui/resources/js:i18n_behavior.m",
+ "//ui/webui/resources/js:load_time_data.m",
]
}
js_library("certificate_delete_confirmation_dialog") {
deps = [
- ":certificate_manager_types",
":certificates_browser_proxy",
- "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
- "//ui/webui/resources/js:cr",
- "//ui/webui/resources/js:i18n_behavior",
- "//ui/webui/resources/js:load_time_data",
+ "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
+ "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m",
+ "//ui/webui/resources/js:assert.m",
+ "//ui/webui/resources/js:i18n_behavior.m",
+ "//ui/webui/resources/js:load_time_data.m",
]
}
js_library("certificate_entry") {
deps = [
- ":certificate_manager_types",
":certificates_browser_proxy",
- "//ui/webui/resources/cr_elements/policy:cr_policy_indicator",
- "//ui/webui/resources/js:cr",
- "//ui/webui/resources/js:i18n_behavior",
+ "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
+ "//ui/webui/resources/cr_elements/policy:cr_policy_indicator_behavior.m",
+ "//ui/webui/resources/js:i18n_behavior.m",
]
}
js_library("certificate_list") {
deps = [
":certificate_manager_types",
- ":certificate_subentry",
":certificates_browser_proxy",
- "//ui/webui/resources/js:cr",
- "//ui/webui/resources/js:i18n_behavior",
+ "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
+ "//ui/webui/resources/js:i18n_behavior.m",
+ "//ui/webui/resources/js:load_time_data.m",
]
}
-js_library("certificate_manager") {
- deps = [
- ":certificate_list",
- ":certificate_manager_types",
- ":certificates_browser_proxy",
- "//ui/webui/resources/js:assert",
- "//ui/webui/resources/js:load_time_data",
- "//ui/webui/resources/js:web_ui_listener_behavior",
- "//ui/webui/resources/js/cr/ui:focus_without_ink",
- ]
+js_library("certificates_browser_proxy") {
+ deps = [ "//ui/webui/resources/js:cr.m" ]
}
js_library("certificate_manager_types") {
deps = [ ":certificates_browser_proxy" ]
}
-js_library("certificate_password_decryption_dialog") {
- deps = [
- ":certificate_manager_types",
- ":certificates_browser_proxy",
- "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
- "//ui/webui/resources/js:cr",
- "//ui/webui/resources/js:i18n_behavior",
- ]
-}
-
-js_library("certificate_password_encryption_dialog") {
- deps = [
- ":certificate_manager_types",
- ":certificates_browser_proxy",
- "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
- "//ui/webui/resources/js:cr",
- "//ui/webui/resources/js:i18n_behavior",
- ]
-}
-
-js_library("certificate_subentry") {
- deps = [
- ":certificate_manager_types",
- ":certificates_browser_proxy",
- "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu",
- "//ui/webui/resources/cr_elements/cr_lazy_render:cr_lazy_render",
- "//ui/webui/resources/cr_elements/policy:cr_policy_indicator",
- "//ui/webui/resources/js:cr",
- "//ui/webui/resources/js:i18n_behavior",
- ]
-}
-
-js_library("certificates_browser_proxy") {
- deps = [ "//ui/webui/resources/js:cr" ]
-}
-
js_library("certificates_error_dialog") {
deps = [
- ":certificate_manager_types",
":certificates_browser_proxy",
- "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog",
- "//ui/webui/resources/js:cr",
- "//ui/webui/resources/js:i18n_behavior",
- "//ui/webui/resources/js:load_time_data",
- ]
-}
-
-# Polymer 3 autogenerated version
-
-js_type_check("closure_compile_module") {
- is_polymer3 = true
- deps = [
- ":ca_trust_edit_dialog.m",
- ":certificate_delete_confirmation_dialog.m",
- ":certificate_entry.m",
- ":certificate_list.m",
- ":certificate_manager.m",
- ":certificate_manager_types.m",
- ":certificate_password_decryption_dialog.m",
- ":certificate_password_encryption_dialog.m",
- ":certificate_subentry.m",
- ":certificates_browser_proxy.m",
- ":certificates_error_dialog.m",
- ]
-}
-
-js_library("ca_trust_edit_dialog.m") {
- sources = [ "$root_gen_dir/ui/webui/resources/cr_components/certificate_manager/ca_trust_edit_dialog.m.js" ]
- deps = [
- ":certificates_browser_proxy.m",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m",
"//ui/webui/resources/js:i18n_behavior.m",
"//ui/webui/resources/js:load_time_data.m",
]
- extra_deps = [ ":ca_trust_edit_dialog_module" ]
}
-js_library("certificate_delete_confirmation_dialog.m") {
- sources = [ "$root_gen_dir/ui/webui/resources/cr_components/certificate_manager/certificate_delete_confirmation_dialog.m.js" ]
- deps = [
- ":certificates_browser_proxy.m",
- "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
- "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m",
- "//ui/webui/resources/js:assert.m",
- "//ui/webui/resources/js:i18n_behavior.m",
- "//ui/webui/resources/js:load_time_data.m",
- ]
- extra_deps = [ ":certificate_delete_confirmation_dialog_module" ]
+js_library("certificate_provisioning_browser_proxy") {
+ deps = [ "//ui/webui/resources/js:cr.m" ]
}
-js_library("certificate_entry.m") {
- sources = [ "$root_gen_dir/ui/webui/resources/cr_components/certificate_manager/certificate_entry.m.js" ]
+js_library("certificate_provisioning_details_dialog") {
deps = [
- ":certificates_browser_proxy.m",
+ ":certificate_manager_types",
+ ":certificate_provisioning_browser_proxy",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
- "//ui/webui/resources/cr_elements/policy:cr_policy_indicator_behavior.m",
+ "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m",
"//ui/webui/resources/js:i18n_behavior.m",
+ "//ui/webui/resources/js:load_time_data.m",
]
- extra_deps = [ ":certificate_entry_module" ]
}
-js_library("certificate_list.m") {
- sources = [ "$root_gen_dir/ui/webui/resources/cr_components/certificate_manager/certificate_list.m.js" ]
+js_library("certificate_provisioning_entry") {
deps = [
- ":certificate_manager_types.m",
- ":certificates_browser_proxy.m",
+ ":certificate_manager_types",
+ ":certificate_provisioning_browser_proxy",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
+ "//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu.m",
"//ui/webui/resources/js:i18n_behavior.m",
"//ui/webui/resources/js:load_time_data.m",
]
- extra_deps = [ ":certificate_list_module" ]
-}
-
-js_library("certificates_browser_proxy.m") {
- sources = [ "$root_gen_dir/ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.m.js" ]
- deps = [ "//ui/webui/resources/js:cr.m" ]
- extra_deps = [ ":modulize" ]
-}
-
-js_library("certificate_manager_types.m") {
- sources = [ "$root_gen_dir/ui/webui/resources/cr_components/certificate_manager/certificate_manager_types.m.js" ]
- deps = [ ":certificates_browser_proxy.m" ]
- extra_deps = [ ":modulize" ]
}
-js_library("certificates_error_dialog.m") {
- sources = [ "$root_gen_dir/ui/webui/resources/cr_components/certificate_manager/certificates_error_dialog.m.js" ]
+js_library("certificate_provisioning_list") {
deps = [
- ":certificates_browser_proxy.m",
+ ":certificate_provisioning_browser_proxy",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
- "//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m",
"//ui/webui/resources/js:i18n_behavior.m",
"//ui/webui/resources/js:load_time_data.m",
+ "//ui/webui/resources/js:web_ui_listener_behavior.m",
]
- extra_deps = [ ":certificates_error_dialog_module" ]
}
-js_library("certificate_password_decryption_dialog.m") {
- sources = [ "$root_gen_dir/ui/webui/resources/cr_components/certificate_manager/certificate_password_decryption_dialog.m.js" ]
+js_library("certificate_password_decryption_dialog") {
deps = [
- ":certificates_browser_proxy.m",
+ ":certificates_browser_proxy",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m",
"//ui/webui/resources/js:i18n_behavior.m",
]
- extra_deps = [ ":certificate_password_decryption_dialog_module" ]
}
-js_library("certificate_password_encryption_dialog.m") {
- sources = [ "$root_gen_dir/ui/webui/resources/cr_components/certificate_manager/certificate_password_encryption_dialog.m.js" ]
+js_library("certificate_password_encryption_dialog") {
deps = [
- ":certificates_browser_proxy.m",
+ ":certificates_browser_proxy",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/cr_elements/cr_dialog:cr_dialog.m",
"//ui/webui/resources/js:i18n_behavior.m",
]
- extra_deps = [ ":certificate_password_encryption_dialog_module" ]
}
-js_library("certificate_subentry.m") {
- sources = [ "$root_gen_dir/ui/webui/resources/cr_components/certificate_manager/certificate_subentry.m.js" ]
+js_library("certificate_subentry") {
deps = [
- ":certificate_manager_types.m",
- ":certificates_browser_proxy.m",
+ ":certificate_manager_types",
+ ":certificates_browser_proxy",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/cr_elements/cr_action_menu:cr_action_menu.m",
"//ui/webui/resources/cr_elements/policy:cr_policy_indicator_behavior.m",
"//ui/webui/resources/js:i18n_behavior.m",
]
- extra_deps = [ ":certificate_subentry_module" ]
}
-js_library("certificate_manager.m") {
- sources = [ "$root_gen_dir/ui/webui/resources/cr_components/certificate_manager/certificate_manager.m.js" ]
+js_library("certificate_manager") {
deps = [
- ":certificate_manager_types.m",
- ":certificates_browser_proxy.m",
+ ":certificate_manager_types",
+ ":certificates_browser_proxy",
"//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
"//ui/webui/resources/js:i18n_behavior.m",
"//ui/webui/resources/js:load_time_data.m",
"//ui/webui/resources/js:web_ui_listener_behavior.m",
"//ui/webui/resources/js/cr/ui:focus_without_ink.m",
]
- extra_deps = [ ":certificate_manager_module" ]
-}
-
-group("polymer3_elements") {
- public_deps = [
- ":ca_trust_edit_dialog_module",
- ":certificate_delete_confirmation_dialog_module",
- ":certificate_entry_module",
- ":certificate_list_module",
- ":certificate_manager_module",
- ":certificate_password_decryption_dialog_module",
- ":certificate_password_encryption_dialog_module",
- ":certificate_shared_css_module",
- ":certificate_subentry_module",
- ":certificates_error_dialog_module",
- ":modulize",
- ]
-}
-
-certificate_manager_rewrites =
- [ "certificate_manager.CertificatesBrowserProxy|CertificatesBrowserProxy" ]
-
-polymer_modulizer("ca_trust_edit_dialog") {
- js_file = "ca_trust_edit_dialog.js"
- html_file = "ca_trust_edit_dialog.html"
- html_type = "dom-module"
- namespace_rewrites = certificate_manager_rewrites
- auto_imports = [ "ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.html|CertificatesBrowserProxy,CertificatesBrowserProxyImpl,CertificateSubnode,NewCertificateSubNode,CaTrustInfo" ]
-}
-
-polymer_modulizer("certificate_delete_confirmation_dialog") {
- js_file = "certificate_delete_confirmation_dialog.js"
- html_file = "certificate_delete_confirmation_dialog.html"
- html_type = "dom-module"
- namespace_rewrites = certificate_manager_rewrites
- auto_imports = [
- "ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.html|CertificatesBrowserProxy,CertificatesBrowserProxyImpl,CertificateType,CertificateSubnode",
- "ui/webui/resources/html/assert.html|assertNotReached",
- ]
}
-polymer_modulizer("certificate_entry") {
- js_file = "certificate_entry.js"
- html_file = "certificate_entry.html"
- html_type = "dom-module"
- auto_imports = [
- "ui/webui/resources/cr_elements/policy/cr_policy_indicator_behavior.html|CrPolicyIndicatorType",
- "ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.html|CertificatesOrgGroup,CertificateType",
+html_to_js("web_components") {
+ js_files = [
+ "ca_trust_edit_dialog.js",
+ "certificate_delete_confirmation_dialog.js",
+ "certificate_entry.js",
+ "certificate_list.js",
+ "certificate_manager.js",
+ "certificate_password_decryption_dialog.js",
+ "certificate_password_encryption_dialog.js",
+ "certificate_shared_css.js",
+ "certificate_subentry.js",
+ "certificates_error_dialog.js",
]
-}
-
-polymer_modulizer("certificate_list") {
- js_file = "certificate_list.js"
- html_file = "certificate_list.html"
- html_type = "dom-module"
- namespace_rewrites = certificate_manager_rewrites
- auto_imports = [
- "ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.html|CertificatesBrowserProxy,CertificatesBrowserProxyImpl,CertificateType,NewCertificateSubNode,CertificatesOrgGroup",
- "ui/webui/resources/cr_components/certificate_manager/certificate_manager_types.html|CertificateAction,CertificateActionEvent,CertificateActionEventDetail",
- "ui/webui/resources/html/assert.html|assertNotReached",
- ]
-}
-polymer_modulizer("certificate_manager") {
- js_file = "certificate_manager.js"
- html_file = "certificate_manager.html"
- html_type = "dom-module"
- namespace_rewrites = certificate_manager_rewrites
- auto_imports = [
- "ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.html|CertificatesBrowserProxy,CertificatesBrowserProxyImpl,CertificateType,CertificatesOrgGroup,CertificateSubnode,CertificatesError,CertificatesImportError",
- "ui/webui/resources/cr_components/certificate_manager/certificate_manager_types.html|CertificateAction,CertificateActionEvent,CertificatesErrorEventDetail",
- "ui/webui/resources/html/assert.html|assert",
- ]
-}
-
-polymer_modulizer("certificate_password_decryption_dialog") {
- js_file = "certificate_password_decryption_dialog.js"
- html_file = "certificate_password_decryption_dialog.html"
- html_type = "dom-module"
- namespace_rewrites = certificate_manager_rewrites
- auto_imports = [ "ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.html|CertificatesBrowserProxy,CertificatesBrowserProxyImpl" ]
-}
-
-polymer_modulizer("certificate_password_encryption_dialog") {
- js_file = "certificate_password_encryption_dialog.js"
- html_file = "certificate_password_encryption_dialog.html"
- html_type = "dom-module"
- namespace_rewrites = certificate_manager_rewrites
- auto_imports = [ "ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.html|CertificatesBrowserProxy,CertificatesBrowserProxyImpl,CertificateSubnode" ]
-}
-
-polymer_modulizer("certificate_shared_css") {
- js_file = "certificate_shared_css.m.js"
- html_file = "certificate_shared_css.html"
- html_type = "style-module"
-}
-
-polymer_modulizer("certificate_subentry") {
- js_file = "certificate_subentry.js"
- html_file = "certificate_subentry.html"
- html_type = "dom-module"
- namespace_rewrites = certificate_manager_rewrites
- auto_imports = [
- "ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.html|CertificatesBrowserProxy,CertificatesBrowserProxyImpl,CertificateType,CertificateSubnode",
- "ui/webui/resources/cr_components/certificate_manager/certificate_manager_types.html|CertificateAction,CertificateActionEvent,CertificateActionEventDetail",
- "ui/webui/resources/cr_elements/policy/cr_policy_indicator_behavior.html|CrPolicyIndicatorType",
- ]
-}
-
-polymer_modulizer("certificates_error_dialog") {
- js_file = "certificates_error_dialog.js"
- html_file = "certificates_error_dialog.html"
- html_type = "dom-module"
- auto_imports = [ "ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.html|CertificatesError,CertificatesImportError" ]
-}
-
-js_modulizer("modulize") {
- input_files = [
- "certificate_manager_types.js",
- "certificates_browser_proxy.js",
- ]
- namespace_rewrites = [
- "certificate_manager.CertificatesBrowserProxy|CertificatesBrowserProxy",
+ # These are Chrome OS specific but always included because of limitations
+ # around conditional imports (https://crbug.com/1071641#c10).
+ js_files += [
+ "certificate_provisioning_details_dialog.js",
+ "certificate_provisioning_entry.js",
+ "certificate_provisioning_list.js",
]
}
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/ca_trust_edit_dialog.html b/chromium/ui/webui/resources/cr_components/certificate_manager/ca_trust_edit_dialog.html
index df1d31fa3e8..fad1c2ebf53 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/ca_trust_edit_dialog.html
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/ca_trust_edit_dialog.html
@@ -1,16 +1,3 @@
-<link rel="import" href="chrome://resources/html/polymer.html">
-
-<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
-<link rel="import" href="chrome://resources/cr_elements/cr_checkbox/cr_checkbox.html">
-<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
-<link rel="import" href="chrome://resources/html/i18n_behavior.html">
-<link rel="import" href="chrome://resources/html/load_time_data.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/paper-spinner/paper-spinner-lite.html">
-<link rel="import" href="certificate_shared_css.html">
-<link rel="import" href="certificates_browser_proxy.html">
-
-<dom-module id="ca-trust-edit-dialog">
- <template>
<style include="certificate-shared">
cr-checkbox,
#description {
@@ -47,6 +34,3 @@
</cr-button>
</div>
</cr-dialog>
- </template>
- <script src="ca_trust_edit_dialog.js"></script>
-</dom-module>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/ca_trust_edit_dialog.js b/chromium/ui/webui/resources/cr_components/certificate_manager/ca_trust_edit_dialog.js
index 11353303133..32a9d187400 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/ca_trust_edit_dialog.js
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/ca_trust_edit_dialog.js
@@ -8,9 +8,23 @@
* imported.
* - edit the trust level of an already existing certificate authority.
*/
+import 'chrome://resources/cr_elements/cr_button/cr_button.m.js';
+import 'chrome://resources/cr_elements/cr_checkbox/cr_checkbox.m.js';
+import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.m.js';
+import 'chrome://resources/polymer/v3_0/paper-spinner/paper-spinner-lite.js';
+import './certificate_shared_css.js';
+
+import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
+import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
+import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
+
+import {CaTrustInfo, CertificatesBrowserProxy, CertificatesBrowserProxyImpl, CertificateSubnode, NewCertificateSubNode} from './certificates_browser_proxy.js';
+
Polymer({
is: 'ca-trust-edit-dialog',
+ _template: html`{__html_template__}`,
+
behaviors: [I18nBehavior],
properties: {
@@ -24,13 +38,12 @@ Polymer({
explanationText_: String,
},
- /** @private {?certificate_manager.CertificatesBrowserProxy} */
+ /** @private {?CertificatesBrowserProxy} */
browserProxy_: null,
/** @override */
ready() {
- this.browserProxy_ =
- certificate_manager.CertificatesBrowserProxyImpl.getInstance();
+ this.browserProxy_ = CertificatesBrowserProxyImpl.getInstance();
},
/** @override */
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_delete_confirmation_dialog.html b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_delete_confirmation_dialog.html
index 9e4307b9ff8..ccdb8d542f8 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_delete_confirmation_dialog.html
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_delete_confirmation_dialog.html
@@ -1,15 +1,3 @@
-<link rel="import" href="chrome://resources/html/polymer.html">
-
-<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
-<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
-<link rel="import" href="chrome://resources/html/i18n_behavior.html">
-<link rel="import" href="chrome://resources/html/assert.html">
-<link rel="import" href="chrome://resources/html/load_time_data.html">
-<link rel="import" href="certificate_shared_css.html">
-<link rel="import" href="certificates_browser_proxy.html">
-
-<dom-module id="certificate-delete-confirmation-dialog">
- <template>
<style include="certificate-shared"></style>
<cr-dialog id="dialog" close-text="[[i18n('close')]]">
<div slot="title">
@@ -27,6 +15,3 @@
</cr-button>
</div>
</cr-dialog>
- </template>
- <script src="certificate_delete_confirmation_dialog.js"></script>
-</dom-module>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_delete_confirmation_dialog.js b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_delete_confirmation_dialog.js
index 0365fd18b46..05c048f2a41 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_delete_confirmation_dialog.js
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_delete_confirmation_dialog.js
@@ -6,9 +6,22 @@
* @fileoverview A confirmation dialog allowing the user to delete various types
* of certificates.
*/
+import 'chrome://resources/cr_elements/cr_button/cr_button.m.js';
+import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.m.js';
+import './certificate_shared_css.js';
+
+import {assertNotReached} from 'chrome://resources/js/assert.m.js';
+import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
+import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
+import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
+
+import {CertificatesBrowserProxy, CertificatesBrowserProxyImpl, CertificateSubnode, CertificateType} from './certificates_browser_proxy.js';
+
Polymer({
is: 'certificate-delete-confirmation-dialog',
+ _template: html`{__html_template__}`,
+
behaviors: [I18nBehavior],
properties: {
@@ -19,13 +32,12 @@ Polymer({
certificateType: String,
},
- /** @private {?certificate_manager.CertificatesBrowserProxy} */
+ /** @private {?CertificatesBrowserProxy} */
browserProxy_: null,
/** @override */
ready() {
- this.browserProxy_ =
- certificate_manager.CertificatesBrowserProxyImpl.getInstance();
+ this.browserProxy_ = CertificatesBrowserProxyImpl.getInstance();
},
/** @override */
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_entry.html b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_entry.html
index e3c9245f01c..b3fa0b940eb 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_entry.html
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_entry.html
@@ -1,16 +1,3 @@
-<link rel="import" href="chrome://resources/html/polymer.html">
-
-<link rel="import" href="chrome://resources/cr_elements/cr_expand_button/cr_expand_button.html">
-<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html">
-<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator_behavior.html">
-<link rel="import" href="chrome://resources/html/i18n_behavior.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
-<link rel="import" href="certificate_shared_css.html">
-<link rel="import" href="certificate_subentry.html">
-<link rel="import" href="certificates_browser_proxy.html">
-
-<dom-module id="certificate-entry">
- <template>
<style include="certificate-shared iron-flex">
.expand-box {
align-items: center;
@@ -38,6 +25,3 @@
</template>
</div>
</template>
- </template>
- <script src="certificate_entry.js"></script>
-</dom-module>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_entry.js b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_entry.js
index 3684444a801..319097ec3a8 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_entry.js
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_entry.js
@@ -5,9 +5,23 @@
/**
* @fileoverview An element that represents an SSL certificate entry.
*/
+import 'chrome://resources/cr_elements/cr_expand_button/cr_expand_button.m.js';
+import 'chrome://resources/cr_elements/policy/cr_policy_indicator.m.js';
+import 'chrome://resources/polymer/v3_0/iron-flex-layout/iron-flex-layout-classes.js';
+import './certificate_shared_css.js';
+import './certificate_subentry.js';
+
+import {CrPolicyIndicatorType} from 'chrome://resources/cr_elements/policy/cr_policy_indicator_behavior.m.js';
+import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
+import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
+
+import {CertificatesOrgGroup, CertificateType} from './certificates_browser_proxy.js';
+
Polymer({
is: 'certificate-entry',
+ _template: html`{__html_template__}`,
+
behaviors: [I18nBehavior],
properties: {
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_list.html b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_list.html
index 2fbbd3f3d45..e98a4ca9aff 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_list.html
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_list.html
@@ -1,17 +1,3 @@
-<link rel="import" href="chrome://resources/html/polymer.html">
-
-<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
-<link rel="import" href="chrome://resources/html/assert.html">
-<link rel="import" href="chrome://resources/html/i18n_behavior.html">
-<link rel="import" href="chrome://resources/html/load_time_data.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
-<link rel="import" href="certificate_entry.html">
-<link rel="import" href="certificate_manager_types.html">
-<link rel="import" href="certificate_shared_css.html">
-<link rel="import" href="certificates_browser_proxy.html">
-
-<dom-module id="certificate-list">
- <template>
<style include="certificate-shared iron-flex">
.button-box {
align-items: center;
@@ -44,6 +30,3 @@
certificate-type="[[certificateType]]">
</certificate-entry>
</template>
- </template>
- <script src="certificate_list.js"></script>
-</dom-module>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_list.js b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_list.js
index 5a5b6a5b278..305f056eb97 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_list.js
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_list.js
@@ -6,9 +6,24 @@
* @fileoverview 'certificate-list' is an element that displays a list of
* certificates.
*/
+import 'chrome://resources/cr_elements/cr_button/cr_button.m.js';
+import 'chrome://resources/polymer/v3_0/iron-flex-layout/iron-flex-layout-classes.js';
+import './certificate_entry.js';
+import './certificate_shared_css.js';
+
+import {assertNotReached} from 'chrome://resources/js/assert.m.js';
+import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
+import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
+import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
+
+import {CertificateAction, CertificateActionEvent, CertificateActionEventDetail} from './certificate_manager_types.js';
+import {CertificatesBrowserProxy, CertificatesBrowserProxyImpl, CertificatesOrgGroup, CertificateType, NewCertificateSubNode} from './certificates_browser_proxy.js';
+
Polymer({
is: 'certificate-list',
+ _template: html`{__html_template__}`,
+
properties: {
/** @type {!Array<!CertificatesOrgGroup>} */
certificates: {
@@ -149,8 +164,7 @@ Polymer({
* @private
*/
handleImport_(useHardwareBacked, anchor) {
- const browserProxy =
- certificate_manager.CertificatesBrowserProxyImpl.getInstance();
+ const browserProxy = CertificatesBrowserProxyImpl.getInstance();
if (this.certificateType === CertificateType.PERSONAL) {
browserProxy.importPersonalCertificate(useHardwareBacked)
.then(showPasswordPrompt => {
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager.html b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager.html
index 840655c2f54..4db93d929cb 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager.html
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager.html
@@ -1,24 +1,3 @@
-<link rel="import" href="chrome://resources/html/polymer.html">
-
-<link rel="import" href="chrome://resources/cr_elements/cr_tabs/cr_tabs.html">
-<link rel="import" href="chrome://resources/cr_elements/hidden_style_css.html">
-<link rel="import" href="chrome://resources/html/assert.html">
-<link rel="import" href="chrome://resources/html/cr/ui/focus_without_ink.html">
-<link rel="import" href="chrome://resources/html/i18n_behavior.html">
-<link rel="import" href="chrome://resources/html/load_time_data.html">
-<link rel="import" href="chrome://resources/html/web_ui_listener_behavior.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/iron-pages/iron-pages.html">
-<link rel="import" href="ca_trust_edit_dialog.html">
-<link rel="import" href="certificate_delete_confirmation_dialog.html">
-<link rel="import" href="certificate_list.html">
-<link rel="import" href="certificate_manager_types.html">
-<link rel="import" href="certificate_password_decryption_dialog.html">
-<link rel="import" href="certificate_password_encryption_dialog.html">
-<link rel="import" href="certificates_browser_proxy.html">
-<link rel="import" href="certificates_error_dialog.html">
-
-<dom-module id="certificate-manager">
- <template>
<style include="cr-hidden-style">
cr-tabs {
--cr-tabs-font-size: inherit;
@@ -59,6 +38,9 @@
certificate-type="[[certificateTypeEnum_.PERSONAL]]"
import-allowed="[[clientImportAllowed]]">
</certificate-list>
+<if expr="chromeos">
+ <certificate-provisioning-list></certificate-provisioning-list>
+</if>
</div>
<div>
<template is="dom-if" if="[[isTabSelected_(selected, 1)]]">
@@ -88,6 +70,3 @@
</template>
</div>
</iron-pages>
- </template>
- <script src="certificate_manager.js"></script>
-</dom-module>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager.js b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager.js
index f5c627d0124..98ea4179204 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager.js
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager.js
@@ -5,9 +5,32 @@
/**
* @fileoverview The 'certificate-manager' component manages SSL certificates.
*/
+import 'chrome://resources/cr_elements/cr_tabs/cr_tabs.m.js';
+import 'chrome://resources/cr_elements/hidden_style_css.m.js';
+import 'chrome://resources/polymer/v3_0/iron-pages/iron-pages.js';
+import './ca_trust_edit_dialog.js';
+import './certificate_delete_confirmation_dialog.js';
+import './certificate_list.js';
+import './certificate_password_decryption_dialog.js';
+import './certificate_password_encryption_dialog.js';
+import './certificates_error_dialog.js';
+import './certificate_provisioning_list.js';
+
+import {assert} from 'chrome://resources/js/assert.m.js';
+import {focusWithoutInk} from 'chrome://resources/js/cr/ui/focus_without_ink.m.js';
+import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
+import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
+import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js';
+import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
+
+import {CertificateAction, CertificateActionEvent, CertificatesErrorEventDetail} from './certificate_manager_types.js';
+import {CertificatesBrowserProxyImpl, CertificatesError, CertificatesImportError, CertificatesOrgGroup, CertificateSubnode, CertificateType} from './certificates_browser_proxy.js';
+
Polymer({
is: 'certificate-manager',
+ _template: html`{__html_template__}`,
+
behaviors: [I18nBehavior, WebUIListenerBehavior],
properties: {
@@ -141,8 +164,7 @@ Polymer({
this.setClientImportAllowed.bind(this));
this.addWebUIListener(
'ca-import-allowed-changed', this.setCAImportAllowed.bind(this));
- certificate_manager.CertificatesBrowserProxyImpl.getInstance()
- .refreshCertificates();
+ CertificatesBrowserProxyImpl.getInstance().refreshCertificates();
},
/** @private */
@@ -234,7 +256,7 @@ Polymer({
const dialog = this.$$(dialogTagName);
dialog.addEventListener('close', () => {
this.set(domIfBooleanName, false);
- cr.ui.focusWithoutInk(assert(this.activeDialogAnchor_));
+ focusWithoutInk(assert(this.activeDialogAnchor_));
});
});
},
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager_types.html b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager_types.html
deleted file mode 100644
index 271b2666939..00000000000
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager_types.html
+++ /dev/null
@@ -1 +0,0 @@
-<script src="certificate_manager_types.js"></script>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager_types.js b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager_types.js
index 8535ea49248..d8ee0b93621 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager_types.js
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_manager_types.js
@@ -7,7 +7,8 @@
*/
// clang-format off
-// #import {CertificateSubnode, NewCertificateSubNode, CertificateType, CertificatesError, CertificatesImportError} from './certificates_browser_proxy.m.js';
+import {CertificateProvisioningProcess} from './certificate_provisioning_browser_proxy.js';
+import {CertificatesError, CertificatesImportError,CertificateSubnode, CertificateType, NewCertificateSubNode} from './certificates_browser_proxy.js';
// clang-format on
/**
@@ -19,7 +20,7 @@
* anchor: !HTMLElement
* }}
*/
-/* #export */ let CertificateActionEventDetail;
+export let CertificateActionEventDetail;
/**
* The payload of the 'certificates-error' event.
@@ -28,13 +29,13 @@
* anchor: ?HTMLElement
* }}
*/
-/* #export */ let CertificatesErrorEventDetail;
+export let CertificatesErrorEventDetail;
/**
* Enumeration of actions that require a popup menu to be shown to the user.
* @enum {number}
*/
-/* #export */ const CertificateAction = {
+export const CertificateAction = {
DELETE: 0,
EDIT: 1,
EXPORT_PERSONAL: 2,
@@ -45,4 +46,21 @@
* The name of the event fired when a certificate action is selected from the
* dropdown menu. CertificateActionEventDetail is passed as the event detail.
*/
-/* #export */ const CertificateActionEvent = 'certificate-action';
+export const CertificateActionEvent = 'certificate-action';
+
+/**
+ * The payload of the 'certificate-provisioning-view-details-action' event.
+ * @typedef {{
+ * model: !CertificateProvisioningProcess,
+ * anchor: !HTMLElement
+ * }}
+ */
+export let CertificateProvisioningActionEventDetail;
+
+/**
+ * The name of the event fired when a the "View Details" action is selected on
+ * the dropdown menu next to a certificate provisioning process.
+ * CertificateActionEventDetail is passed as the event detail.
+ */
+export const CertificateProvisioningViewDetailsActionEvent =
+ 'certificate-provisioning-view-details-action';
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_decryption_dialog.html b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_decryption_dialog.html
index 156072305d3..41f8bdc8425 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_decryption_dialog.html
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_decryption_dialog.html
@@ -1,14 +1,3 @@
-<link rel="import" href="chrome://resources/html/polymer.html">
-
-<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
-<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
-<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html">
-<link rel="import" href="chrome://resources/html/i18n_behavior.html">
-<link rel="import" href="certificate_shared_css.html">
-<link rel="import" href="certificates_browser_proxy.html">
-
-<dom-module id="certificate-password-decryption-dialog">
- <template>
<style include="certificate-shared">
cr-input {
--cr-input-error-display: none;
@@ -33,6 +22,3 @@
</cr-button>
</div>
</cr-dialog>
- </template>
- <script src="certificate_password_decryption_dialog.js"></script>
-</dom-module>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_decryption_dialog.js b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_decryption_dialog.js
index 687aa041998..208dad02793 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_decryption_dialog.js
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_decryption_dialog.js
@@ -6,9 +6,21 @@
* @fileoverview A dialog prompting the user for a decryption password such that
* a previously exported personal certificate can be imported.
*/
+import 'chrome://resources/cr_elements/cr_button/cr_button.m.js';
+import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.m.js';
+import 'chrome://resources/cr_elements/cr_input/cr_input.m.js';
+import './certificate_shared_css.js';
+
+import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
+import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
+
+import {CertificatesBrowserProxy, CertificatesBrowserProxyImpl} from './certificates_browser_proxy.js';
+
Polymer({
is: 'certificate-password-decryption-dialog',
+ _template: html`{__html_template__}`,
+
behaviors: [I18nBehavior],
properties: {
@@ -19,13 +31,12 @@ Polymer({
},
},
- /** @private {?certificate_manager.CertificatesBrowserProxy} */
+ /** @private {?CertificatesBrowserProxy} */
browserProxy_: null,
/** @override */
ready() {
- this.browserProxy_ =
- certificate_manager.CertificatesBrowserProxyImpl.getInstance();
+ this.browserProxy_ = CertificatesBrowserProxyImpl.getInstance();
},
/** @override */
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_encryption_dialog.html b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_encryption_dialog.html
index 301aa3d1246..bee2607edbb 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_encryption_dialog.html
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_encryption_dialog.html
@@ -1,15 +1,3 @@
-<link rel="import" href="chrome://resources/html/polymer.html">
-
-<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
-<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
-<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html">
-<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
-<link rel="import" href="chrome://resources/html/i18n_behavior.html">
-<link rel="import" href="certificate_shared_css.html">
-<link rel="import" href="certificates_browser_proxy.html">
-
-<dom-module id="certificate-password-encryption-dialog">
- <template>
<style include="certificate-shared">
cr-input {
--cr-input-error-display: none;
@@ -45,6 +33,3 @@
</cr-button>
</div>
</cr-dialog>
- </template>
- <script src="certificate_password_encryption_dialog.js"></script>
-</dom-module>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_encryption_dialog.js b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_encryption_dialog.js
index 18800e4bb3b..8a5765590c6 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_encryption_dialog.js
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_password_encryption_dialog.js
@@ -6,9 +6,22 @@
* @fileoverview A dialog prompting the user to encrypt a personal certificate
* before it is exported to disk.
*/
+import 'chrome://resources/cr_elements/cr_button/cr_button.m.js';
+import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.m.js';
+import 'chrome://resources/cr_elements/cr_input/cr_input.m.js';
+import 'chrome://resources/cr_elements/shared_vars_css.m.js';
+import './certificate_shared_css.js';
+
+import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
+import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
+
+import {CertificatesBrowserProxy, CertificatesBrowserProxyImpl, CertificateSubnode} from './certificates_browser_proxy.js';
+
Polymer({
is: 'certificate-password-encryption-dialog',
+ _template: html`{__html_template__}`,
+
behaviors: [I18nBehavior],
properties: {
@@ -28,13 +41,12 @@ Polymer({
},
},
- /** @private {?certificate_manager.CertificatesBrowserProxy} */
+ /** @private {?CertificatesBrowserProxy} */
browserProxy_: null,
/** @override */
ready() {
- this.browserProxy_ =
- certificate_manager.CertificatesBrowserProxyImpl.getInstance();
+ this.browserProxy_ = CertificatesBrowserProxyImpl.getInstance();
},
/** @override */
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_browser_proxy.js b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_browser_proxy.js
new file mode 100644
index 00000000000..57e3428ec13
--- /dev/null
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_browser_proxy.js
@@ -0,0 +1,74 @@
+// Copyright 2020 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.
+
+/**
+ * @fileoverview A helper object used on Chrome OS from the "Manage
+ * certificates" section to interact with certificate provisioining processes.
+ */
+
+import {addSingletonGetter} from 'chrome://resources/js/cr.m.js';
+
+/**
+ * The 'certificate-provisioning-processes-changed' event will have an array of
+ * CertificateProvisioningProcesses as its argument. This typedef is currently
+ * declared here to be consistent with certificates_browser_proxy.js, but it is
+ * not specific to CertificateProvisioningBrowserProxy.
+ *
+ * @typedef {{
+ * certProfileId: string,
+ * isDeviceWide: boolean,
+ * status: string,
+ * stateId: number,
+ * timeSinceLastUpdate: string,
+ * publicKey: string
+ * }}
+ * @see chrome/browser/ui/webui/settings/certificates_handler.cc
+ */
+export let CertificateProvisioningProcess;
+
+/** @interface */
+export class CertificateProvisioningBrowserProxy {
+ // <if expr="chromeos">
+ // TODO(https://crbug.com/1071641): When it is possible to have conditional
+ // imports in ui/webui/resources/cr_components/, this file should be
+ // conditionally imported. Until then, it is imported unconditionally but its
+ // non-exported code is omitted for non-ChromeOS platforms.
+
+ /**
+ * Refreshes the list of client certificate processes.
+ * Triggers the 'certificate-provisioning-processes-changed' event.
+ * This is Chrome OS specific, but always present for simplicity.
+ */
+ refreshCertificateProvisioningProcesses() {}
+
+ /**
+ * Attempts to manually advance/refresh the status of the client certificate
+ * provisioning process identified by |certProfileId|.
+ * This is Chrome OS specific, but always present for simplicity.
+ * @param {string} certProfileId
+ * @param {boolean} isDeviceWide
+ */
+ triggerCertificateProvisioningProcessUpdate(certProfileId, isDeviceWide) {}
+
+ // </if>
+}
+
+/** @implements {CertificateProvisioningBrowserProxy} */
+export class CertificateProvisioningBrowserProxyImpl {
+ /** override */
+ refreshCertificateProvisioningProcesses() {
+ chrome.send('refreshCertificateProvisioningProcessses');
+ }
+
+ /** override */
+ triggerCertificateProvisioningProcessUpdate(certProfileId, isDeviceWide) {
+ chrome.send(
+ 'triggerCertificateProvisioningProcessUpdate',
+ [certProfileId, isDeviceWide]);
+ }
+}
+
+// The singleton instance_ is replaced with a test version of this wrapper
+// during testing.
+addSingletonGetter(CertificateProvisioningBrowserProxyImpl);
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_details_dialog.html b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_details_dialog.html
new file mode 100644
index 00000000000..fba5360e091
--- /dev/null
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_details_dialog.html
@@ -0,0 +1,64 @@
+<style include="iron-flex">
+ .button-box {
+ align-items: center;
+ display: flex;
+ min-height: 48px;
+ }
+
+ .label {
+ color: var(--cr-secondary-text-color);
+ font-size: 85%;
+ }
+
+
+ /* A row with two lines of text.
+ * Consistnt with chrome/browser/resources/settings/settings_shared_css.html
+ * (which can not be imported here because this is in cr_components).
+ */
+ .two-line {
+ min-height: var(--settings-row-two-line-min-height);
+ }
+
+ .value {
+ color: var(--cr-primary-text-color);
+ }
+</style>
+<cr-dialog id="dialog" show-on-attach show-close-button close-text="[[i18n('close')]]">
+ <div slot="title">
+ [[i18n('certificateProvisioningDetails')]]
+ </div>
+ <div slot="body">
+ <div class="two-line">
+ <div class="label">[[i18n('certificateProvisioningProfile')]]</div>
+ <div class="value">[[model.certProfileId]]</div>
+ </div>
+ <div class="button-box">
+ <div class="two-line flex">
+ <div class="label">[[i18n('certificateProvisioningStatus')]]</div>
+ <span class="value">[[model.status]]</span>
+ </div>
+ <cr-button id="refresh" role="button" on-click="onRefresh_">
+ [[i18n('certificateProvisioningRefresh')]]
+ </cr-button>
+ </div>
+ <div class="two-line">
+ <div class="label">[[i18n('certificateProvisioningLastUpdate')]]</div>
+ <div class="value">[[model.timeSinceLastUpdate]]</div>
+ </div>
+ <hr></hr>
+ <cr-expand-button expanded="{{advancedExpanded_}}"
+ aria-expanded$="[[boolToString_(advancedOpened)]]">
+ <div>[[i18n('certificateProvisioningAdvancedSectionTitle')]]</div>
+ </cr-expand-button>
+ <iron-collapse id="advancedInfo" opened="[[advancedExpanded_]]">
+ <div class="two-line">
+ <div class="label">[[i18n('certificateProvisioningStatusId')]]</div>
+ <div class="value">[[model.stateId]]</div>
+ </div>
+ <div class="two-line">
+ <div class="label">[[i18n('certificateProvisioningPublicKey')]]</div>
+ <div class="value">[[model.publicKey]]</div>
+ </div>
+ </iron-collapse>
+ </div>
+</cr-dialog>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_details_dialog.js b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_details_dialog.js
new file mode 100644
index 00000000000..c04422d3534
--- /dev/null
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_details_dialog.js
@@ -0,0 +1,65 @@
+// Copyright 2020 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.
+
+/**
+ * @fileoverview 'certificate-provisioning-details-dialog' allows the user to
+ * view the details of an in-progress certiifcate provisioning process.
+ */
+import 'chrome://resources/cr_elements/cr_expand_button/cr_expand_button.m.js';
+import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.m.js';
+import 'chrome://resources/polymer/v3_0/iron-flex-layout/iron-flex-layout-classes.js';
+
+import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
+import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
+
+import {CertificateProvisioningBrowserProxyImpl, CertificateProvisioningProcess} from './certificate_provisioning_browser_proxy.js';
+
+// <if expr="chromeos">
+// TODO(https://crbug.com/1071641): When it is possible to have conditional
+// imports in ui/webui/resources/cr_components/, this file should be
+// conditionally imported. Until then, it is imported unconditionally but its
+// contents are omitted for non-ChromeOS platforms.
+
+Polymer({
+ is: 'certificate-provisioning-details-dialog',
+
+ _template: html`{__html_template__}`,
+
+ behaviors: [I18nBehavior],
+
+ properties: {
+ /** @type {!CertificateProvisioningProcess} */
+ model: Object,
+
+ /** @private */
+ advancedExpanded_: Boolean,
+ },
+
+ /** @private */
+ onRefresh_() {
+ CertificateProvisioningBrowserProxyImpl.getInstance()
+ .triggerCertificateProvisioningProcessUpdate(
+ this.model.certProfileId, this.model.isDeviceWide);
+ },
+
+ /**
+ * @param {boolean} opened Whether the menu is expanded.
+ * @return {string} Which icon to use.
+ * @private
+ * */
+ arrowState_(opened) {
+ return opened ? 'cr:arrow-drop-up' : 'cr:arrow-drop-down';
+ },
+
+ /**
+ * @param {boolean} bool
+ * @return {string}
+ * @private
+ */
+ boolToString_(bool) {
+ return bool.toString();
+ },
+});
+
+// </if>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_entry.html b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_entry.html
new file mode 100644
index 00000000000..c2efcda5f2f
--- /dev/null
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_entry.html
@@ -0,0 +1,25 @@
+<style include="certificate-shared iron-flex">
+ .cert-box {
+ align-items: center;
+ border-top: var(--cr-separator-line);
+ display: flex;
+ min-height: 48px;
+ padding: 0 20px;
+ }
+</style>
+<div class="cert-box">
+ <div class="flex" tabindex="0">[[model.certProfileId]]</div>
+ <cr-icon-button class="icon-more-vert" id="dots"
+ title="[[i18n('moreActions')]]" on-click="onDotsClick_">
+ </cr-icon-button>
+ <cr-lazy-render id="menu">
+ <template>
+ <cr-action-menu role-description="[[i18n('menu')]]">
+ <button class="dropdown-item" id="details"
+ on-click="onDetailsClick_">
+ [[i18n('certificateProvisioningDetails')]]
+ </button>
+ </cr-action-menu>
+ </template>
+ </cr-lazy-render>
+</div>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_entry.js b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_entry.js
new file mode 100644
index 00000000000..711e24f43aa
--- /dev/null
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_entry.js
@@ -0,0 +1,65 @@
+// Copyright 2020 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.
+
+/**
+ * @fileoverview 'certificate-provisioning-entry' is an element that displays
+ * one certificate provisioning processes.
+ */
+import 'chrome://resources/cr_elements/cr_action_menu/cr_action_menu.m.js';
+import 'chrome://resources/cr_elements/cr_icon_button/cr_icon_button.m.js';
+import 'chrome://resources/cr_elements/cr_lazy_render/cr_lazy_render.m.js';
+import 'chrome://resources/polymer/v3_0/iron-flex-layout/iron-flex-layout-classes.js';
+import './certificate_shared_css.js';
+
+import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
+import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
+
+import {CertificateProvisioningActionEventDetail, CertificateProvisioningViewDetailsActionEvent} from './certificate_manager_types.js';
+import {CertificateProvisioningProcess} from './certificate_provisioning_browser_proxy.js';
+
+// <if expr="chromeos">
+// TODO(https://crbug.com/1071641): When it is possible to have conditional
+// imports in ui/webui/resources/cr_components/, this file should be
+// conditionally imported. Until then, it is imported unconditionally but its
+// contents are omitted for non-ChromeOS platforms.
+
+Polymer({
+ is: 'certificate-provisioning-entry',
+
+ _template: html`{__html_template__}`,
+
+ properties: {
+ /** @type {!CertificateProvisioningProcess} */
+ model: Object,
+ },
+
+ behaviors: [I18nBehavior],
+
+ /** @private */
+ closePopupMenu_() {
+ this.$$('cr-action-menu').close();
+ },
+
+ /** @private */
+ onDotsClick_() {
+ const actionMenu = /** @type {!CrActionMenuElement} */ (this.$.menu.get());
+ actionMenu.showAt(this.$.dots);
+ },
+
+ /**
+ * @param {!Event} event
+ * @private
+ */
+ onDetailsClick_(event) {
+ this.closePopupMenu_();
+ this.fire(
+ CertificateProvisioningViewDetailsActionEvent,
+ /** @type {!CertificateProvisioningActionEventDetail} */ ({
+ model: this.model,
+ anchor: this.$.dots,
+ }));
+ },
+});
+
+// </if>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_list.html b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_list.html
new file mode 100644
index 00000000000..1fae1577ef6
--- /dev/null
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_list.html
@@ -0,0 +1,29 @@
+<style include="cr-shared-style iron-flex ">
+ .header-box {
+ align-items: center;
+ display: flex;
+ margin-top: 16px;
+ min-height: 24px;
+ padding: 0 20px;
+ }
+
+ .hidden {
+ display: none;
+ }
+</style>
+
+<template is="dom-if" if="[[showProvisioningDetailsDialog_]]" restamp>
+ <certificate-provisioning-details-dialog model="[[provisioningDetailsDialogModel_]]">
+ </certificate-provisioning-details-dialog>
+</template>
+
+<div class="header-box" aria-role="heading" aria-labelledby="headingLabel"
+ hidden="[[!hasCertificateProvisioningEntries_(provisioningProcesses_)]]">
+ <span id="headingLabel" class="flex">
+ [[i18n('certificateProvisioningListHeader')]]
+ </span>
+</div>
+<template is="dom-repeat" items="[[provisioningProcesses_]]">
+ <certificate-provisioning-entry model="[[item]]">
+ </certificate-provisioning-entry>
+</template>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_list.js b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_list.js
new file mode 100644
index 00000000000..3e7d02518c5
--- /dev/null
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_list.js
@@ -0,0 +1,124 @@
+// Copyright 2020 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.
+
+/**
+ * @fileoverview 'certificate-provisioning-list' is an element that displays a
+ * list of certificate provisioning processes.
+ */
+import 'chrome://resources/cr_elements/shared_style_css.m.js';
+import 'chrome://resources/polymer/v3_0/iron-flex-layout/iron-flex-layout-classes.js';
+import './certificate_provisioning_details_dialog.js';
+import './certificate_provisioning_entry.js';
+
+import {assert} from 'chrome://resources/js/assert.m.js';
+import {focusWithoutInk} from 'chrome://resources/js/cr/ui/focus_without_ink.m.js';
+import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
+import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behavior.m.js';
+import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
+
+import {CertificateProvisioningActionEventDetail, CertificateProvisioningViewDetailsActionEvent} from './certificate_manager_types.js';
+import {CertificateProvisioningBrowserProxyImpl, CertificateProvisioningProcess} from './certificate_provisioning_browser_proxy.js';
+
+// <if expr="chromeos">
+// TODO(https://crbug.com/1071641): When it is possible to have conditional
+// imports in ui/webui/resources/cr_components/, this file should be
+// conditionally imported. Until then, it is imported unconditionally but its
+// contents are omitted for non-ChromeOS platforms.
+
+Polymer({
+ is: 'certificate-provisioning-list',
+
+ _template: html`{__html_template__}`,
+
+ behaviors: [I18nBehavior, WebUIListenerBehavior],
+
+ properties: {
+ /** @type {!Array<!CertificateProvisioningProcess>} */
+ provisioningProcesses_: {
+ type: Array,
+ value() {
+ return [];
+ }
+ },
+
+ /**
+ * The model to be passed to certificate provisioning details dialog.
+ * @private {?CertificateProvisioningProcess}
+ */
+ provisioningDetailsDialogModel_: Object,
+
+ /** @private */
+ showProvisioningDetailsDialog_: Boolean,
+ },
+
+ /**
+ * @param {!Array<!CertificateProvisioningProcess>} provisioningProcesses The
+ * list of certificate provisioning processes.
+ * @return {boolean} true if |provisioningProcesses| contains at least one
+ * entry.
+ * @private
+ */
+ hasCertificateProvisioningEntries_(provisioningProcesses) {
+ return provisioningProcesses.length !== 0;
+ },
+
+ /**
+ * @param {!Array<!CertificateProvisioningProcess>} certProvisioningProcesses
+ * The currently active certificate provisioning processes
+ * @private
+ */
+ onCertificateProvisioningProcessesChanged_(certProvisioningProcesses) {
+ this.provisioningProcesses_ = certProvisioningProcesses;
+
+ // If a cert provisioning process details dialog is being shown, update its
+ // model.
+ if (!this.provisioningDetailsDialogModel_) {
+ return;
+ }
+
+ const certProfileId = this.provisioningDetailsDialogModel_.certProfileId;
+ const newDialogModel = this.provisioningProcesses_.find((process) => {
+ return process.certProfileId === certProfileId;
+ });
+ if (newDialogModel) {
+ this.provisioningDetailsDialogModel_ = newDialogModel;
+ }
+ },
+
+ /** @override */
+ attached() {
+ this.addWebUIListener(
+ 'certificate-provisioning-processes-changed',
+ this.onCertificateProvisioningProcessesChanged_.bind(this));
+ CertificateProvisioningBrowserProxyImpl.getInstance()
+ .refreshCertificateProvisioningProcesses();
+ },
+
+ /** @override */
+ ready() {
+ this.addEventListener(
+ CertificateProvisioningViewDetailsActionEvent, event => {
+ const detail =
+ /** @type {!CertificateProvisioningActionEventDetail} */ (
+ event.detail);
+ this.provisioningDetailsDialogModel_ = detail.model;
+
+ const previousAnchor = assert(detail.anchor);
+ this.showProvisioningDetailsDialog_ = true;
+ this.async(() => {
+ const dialog = this.$$('certificate-provisioning-details-dialog');
+ // The listener is destroyed when the dialog is removed (because of
+ // 'restamp').
+ dialog.addEventListener('close', () => {
+ this.showProvisioningDetailsDialog_ = false;
+ focusWithoutInk(previousAnchor);
+ });
+ });
+
+ event.stopPropagation();
+ });
+ }
+});
+
+// </if>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_shared_css.html b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_shared_css.html
index 00f6e17a21e..015350fd677 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_shared_css.html
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_shared_css.html
@@ -1,8 +1,4 @@
-<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html">
-<!-- Common styles for certificate elements. -->
-
-<dom-module id="certificate-shared">
<template>
<style include="cr-shared-style">
/* .list-frame and .list-item match the styling in settings_shared_css. */
@@ -32,4 +28,3 @@
}
</style>
</template>
-</dom-module>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_shared_css.js b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_shared_css.js
new file mode 100644
index 00000000000..de8da595448
--- /dev/null
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_shared_css.js
@@ -0,0 +1,10 @@
+// Copyright 2020 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 'chrome://resources/cr_elements/shared_style_css.m.js';
+const template = document.createElement('template');
+template.innerHTML = `
+<dom-module id="certificate-shared">{__html_template__}</dom-module>
+`;
+document.body.appendChild(template.content.cloneNode(true));
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_subentry.html b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_subentry.html
index 5ece8d70966..81d4eb5bb59 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_subentry.html
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_subentry.html
@@ -1,18 +1,3 @@
-<link rel="import" href="chrome://resources/html/polymer.html">
-
-<link rel="import" href="chrome://resources/cr_elements/cr_action_menu/cr_action_menu.html">
-<link rel="import" href="chrome://resources/cr_elements/cr_icon_button/cr_icon_button.html">
-<link rel="import" href="chrome://resources/cr_elements/cr_lazy_render/cr_lazy_render.html">
-<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator.html">
-<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_indicator_behavior.html">
-<link rel="import" href="chrome://resources/cr_elements/icons.html">
-<link rel="import" href="chrome://resources/html/i18n_behavior.html">
-<link rel="import" href="certificate_manager_types.html">
-<link rel="import" href="certificate_shared_css.html">
-<link rel="import" href="certificates_browser_proxy.html">
-
-<dom-module id="certificate-subentry">
- <template>
<style include="certificate-shared cr-icons">
.name {
flex: auto;
@@ -65,6 +50,3 @@
</template>
</cr-lazy-render>
<div>
- </template>
- <script src="certificate_subentry.js"></script>
-</dom-module>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_subentry.js b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_subentry.js
index 29bffc5ab35..1ba7132e3e4 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_subentry.js
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificate_subentry.js
@@ -6,9 +6,25 @@
* @fileoverview certificate-subentry represents an SSL certificate sub-entry.
*/
+import 'chrome://resources/cr_elements/cr_action_menu/cr_action_menu.m.js';
+import 'chrome://resources/cr_elements/cr_icon_button/cr_icon_button.m.js';
+import 'chrome://resources/cr_elements/cr_lazy_render/cr_lazy_render.m.js';
+import 'chrome://resources/cr_elements/policy/cr_policy_indicator.m.js';
+import 'chrome://resources/cr_elements/icons.m.js';
+import './certificate_shared_css.js';
+
+import {CrPolicyIndicatorType} from 'chrome://resources/cr_elements/policy/cr_policy_indicator_behavior.m.js';
+import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
+import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
+
+import {CertificateAction, CertificateActionEvent, CertificateActionEventDetail} from './certificate_manager_types.js';
+import {CertificatesBrowserProxy, CertificatesBrowserProxyImpl, CertificateSubnode, CertificateType} from './certificates_browser_proxy.js';
+
Polymer({
is: 'certificate-subentry',
+ _template: html`{__html_template__}`,
+
behaviors: [I18nBehavior],
properties: {
@@ -19,13 +35,12 @@ Polymer({
certificateType: String,
},
- /** @private {certificate_manager.CertificatesBrowserProxy} */
+ /** @private {CertificatesBrowserProxy} */
browserProxy_: null,
/** @override */
created() {
- this.browserProxy_ =
- certificate_manager.CertificatesBrowserProxyImpl.getInstance();
+ this.browserProxy_ = CertificatesBrowserProxyImpl.getInstance();
},
/**
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.html b/chromium/ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.html
deleted file mode 100644
index 0dc7c572ff1..00000000000
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.html
+++ /dev/null
@@ -1 +0,0 @@
-<script src="certificates_browser_proxy.js"></script>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.js b/chromium/ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.js
index 6826a4fc25e..d1f146db1b2 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.js
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.js
@@ -8,7 +8,7 @@
*/
// clang-format off
-// #import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js';
+import {addSingletonGetter, sendWithPromise} from 'chrome://resources/js/cr.m.js';
// clang-format on
/**
@@ -24,7 +24,7 @@
* }}
* @see chrome/browser/ui/webui/settings/certificates_handler.cc
*/
-/* #export */ let CertificateSubnode;
+export let CertificateSubnode;
/**
* A data structure describing a certificate that is currently being imported,
@@ -33,7 +33,7 @@
* name: string,
* }}
*/
-/* #export */ let NewCertificateSubNode;
+export let NewCertificateSubNode;
/**
* Top-level grouping node in a certificate list, representing an organization
@@ -48,7 +48,7 @@
* }}
* @see chrome/browser/ui/webui/settings/certificates_handler.cc
*/
-/* #export */ let CertificatesOrgGroup;
+export let CertificatesOrgGroup;
/**
* @typedef {{
@@ -57,7 +57,7 @@
* objSign: boolean
* }}
*/
-/* #export */ let CaTrustInfo;
+export let CaTrustInfo;
/**
* Generic error returned from C++ via a Promise reject callback.
@@ -67,13 +67,13 @@
* }}
* @see chrome/browser/ui/webui/settings/certificates_handler.cc
*/
-/* #export */ let CertificatesError;
+export let CertificatesError;
/**
* Enumeration of all possible certificate types.
* @enum {string}
*/
-/* #export */ const CertificateType = {
+export const CertificateType = {
CA: 'ca',
OTHER: 'other',
PERSONAL: 'personal',
@@ -91,11 +91,10 @@
* }}
* @see chrome/browser/ui/webui/settings/certificates_handler.cc
*/
-/* #export */ let CertificatesImportError;
+export let CertificatesImportError;
-cr.define('certificate_manager', function() {
/** @interface */
- /* #export */ class CertificatesBrowserProxy {
+ export class CertificatesBrowserProxy {
/**
* Triggers 5 events in the following order
* 1x 'client-import-allowed-changed' event.
@@ -194,9 +193,9 @@ cr.define('certificate_manager', function() {
}
/**
- * @implements {certificate_manager.CertificatesBrowserProxy}
+ * @implements {CertificatesBrowserProxy}
*/
- /* #export */ class CertificatesBrowserProxyImpl {
+ export class CertificatesBrowserProxyImpl {
/** @override */
refreshCertificates() {
chrome.send('refreshCertificates');
@@ -214,45 +213,45 @@ cr.define('certificate_manager', function() {
/** @override */
deleteCertificate(id) {
- return cr.sendWithPromise('deleteCertificate', id);
+ return sendWithPromise('deleteCertificate', id);
}
/** @override */
exportPersonalCertificate(id) {
- return cr.sendWithPromise('exportPersonalCertificate', id);
+ return sendWithPromise('exportPersonalCertificate', id);
}
/** @override */
exportPersonalCertificatePasswordSelected(password) {
- return cr.sendWithPromise(
+ return sendWithPromise(
'exportPersonalCertificatePasswordSelected', password);
}
/** @override */
importPersonalCertificate(useHardwareBacked) {
- return cr.sendWithPromise('importPersonalCertificate', useHardwareBacked);
+ return sendWithPromise('importPersonalCertificate', useHardwareBacked);
}
/** @override */
importPersonalCertificatePasswordSelected(password) {
- return cr.sendWithPromise(
+ return sendWithPromise(
'importPersonalCertificatePasswordSelected', password);
}
/** @override */
getCaCertificateTrust(id) {
- return cr.sendWithPromise('getCaCertificateTrust', id);
+ return sendWithPromise('getCaCertificateTrust', id);
}
/** @override */
editCaCertificateTrust(id, ssl, email, objSign) {
- return cr.sendWithPromise(
+ return sendWithPromise(
'editCaCertificateTrust', id, ssl, email, objSign);
}
/** @override */
importCaCertificateTrustSelected(ssl, email, objSign) {
- return cr.sendWithPromise(
+ return sendWithPromise(
'importCaCertificateTrustSelected', ssl, email, objSign);
}
@@ -263,22 +262,16 @@ cr.define('certificate_manager', function() {
/** @override */
importCaCertificate() {
- return cr.sendWithPromise('importCaCertificate');
+ return sendWithPromise('importCaCertificate');
}
/** @override */
importServerCertificate() {
- return cr.sendWithPromise('importServerCertificate');
+ return sendWithPromise('importServerCertificate');
}
}
// The singleton instance_ is replaced with a test version of this wrapper
// during testing.
- cr.addSingletonGetter(CertificatesBrowserProxyImpl);
-
- // #cr_define_end
- return {
- CertificatesBrowserProxy: CertificatesBrowserProxy,
- CertificatesBrowserProxyImpl: CertificatesBrowserProxyImpl,
- };
-});
+ addSingletonGetter(CertificatesBrowserProxyImpl);
+
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificates_error_dialog.html b/chromium/ui/webui/resources/cr_components/certificate_manager/certificates_error_dialog.html
index 6bf7294f3c7..75c039c15ea 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificates_error_dialog.html
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificates_error_dialog.html
@@ -1,14 +1,3 @@
-<link rel="import" href="chrome://resources/html/polymer.html">
-
-<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
-<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
-<link rel="import" href="chrome://resources/html/i18n_behavior.html">
-<link rel="import" href="chrome://resources/html/load_time_data.html">
-<link rel="import" href="certificates_browser_proxy.html">
-<link rel="import" href="certificate_shared_css.html">
-
-<dom-module id="certificates-error-dialog">
- <template>
<style include="certificate-shared"></style>
<cr-dialog id="dialog" close-text="[[i18n('close')]]">
<div slot="title">[[model.title]]</div>
@@ -26,6 +15,3 @@
</cr-button>
</div>
</cr-dialog>
- </template>
- <script src="certificates_error_dialog.js"></script>
-</dom-module>
diff --git a/chromium/ui/webui/resources/cr_components/certificate_manager/certificates_error_dialog.js b/chromium/ui/webui/resources/cr_components/certificate_manager/certificates_error_dialog.js
index df60e74fce7..25562355152 100644
--- a/chromium/ui/webui/resources/cr_components/certificate_manager/certificates_error_dialog.js
+++ b/chromium/ui/webui/resources/cr_components/certificate_manager/certificates_error_dialog.js
@@ -6,9 +6,21 @@
* @fileoverview A dialog for showing SSL certificate related error messages.
* The user can only close the dialog, there is no other possible interaction.
*/
+import 'chrome://resources/cr_elements/cr_button/cr_button.m.js';
+import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.m.js';
+import './certificate_shared_css.js';
+
+import {I18nBehavior} from 'chrome://resources/js/i18n_behavior.m.js';
+import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
+import {html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
+
+import {CertificatesError, CertificatesImportError} from './certificates_browser_proxy.js';
+
Polymer({
is: 'certificates-error-dialog',
+ _template: html`{__html_template__}`,
+
behaviors: [I18nBehavior],
properties: {
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/BUILD.gn b/chromium/ui/webui/resources/cr_components/chromeos/BUILD.gn
index 0be7ca9387e..d96f84805d0 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/BUILD.gn
+++ b/chromium/ui/webui/resources/cr_components/chromeos/BUILD.gn
@@ -16,6 +16,9 @@ group("closure_compile") {
"smb_shares:closure_compile",
# Targets for auto-generated Polymer 3 JS Modules
+ # TODO: Uncomment as Polymer3 migration makes progress.
+ # "network:closure_compile_module",
+ # "quick_unlock:closure_compile_module",
"smb_shares:closure_compile_module",
]
}
@@ -45,7 +48,8 @@ js_library("bluetooth_dialog") {
group("polymer3_elements") {
public_deps = [
- "smb_shares:add_smb_share_dialog_module",
- "smb_shares:smb_browser_proxy_module",
+ "network:polymer3_elements",
+ "quick_unlock:polymer3_elements",
+ "smb_shares:polymer3_elements",
]
}
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/cellular_setup/button_bar.html b/chromium/ui/webui/resources/cr_components/chromeos/cellular_setup/button_bar.html
index 394cd72e68f..366552c5eaa 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/cellular_setup/button_bar.html
+++ b/chromium/ui/webui/resources/cr_components/chromeos/cellular_setup/button_bar.html
@@ -10,8 +10,8 @@
<template>
<style include="iron-flex">
:host {
- @apply --layout-horizontal;
- @apply --layout-justified;
+ display: flex;
+ justify-content: space-between;
padding: 10px 0;
}
</style>
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/cellular_setup/cellular_setup.html b/chromium/ui/webui/resources/cr_components/chromeos/cellular_setup/cellular_setup.html
index 4e36caa888a..7215cefcb97 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/cellular_setup/cellular_setup.html
+++ b/chromium/ui/webui/resources/cr_components/chromeos/cellular_setup/cellular_setup.html
@@ -14,8 +14,9 @@
<template>
<style include="iron-flex">
:host {
- @apply --layout-flex-auto;
- @apply --layout-vertical;
+ display: flex;
+ flex: 1 1 auto;
+ flex-direction: column;
padding: 10px;
}
</style>
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/multidevice_setup.html b/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/multidevice_setup.html
index 520ca792093..978dc71e9a5 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/multidevice_setup.html
+++ b/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/multidevice_setup.html
@@ -23,9 +23,10 @@
}
#container {
- @apply --layout-vertical;
box-sizing: border-box;
color: var(--google-grey-700);
+ display: flex;
+ flex-direction: column;
font-size: 13px;
height: 100%;
line-height: 16px;
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/password_page.html b/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/password_page.html
index 1dfdb8c4060..454df4da397 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/password_page.html
+++ b/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/password_page.html
@@ -10,9 +10,9 @@
<template>
<style include="multidevice-setup-shared">
#user-info-container {
- @apply --layout-horizontal;
align-items: center;
color: var(--paper-grey-600);
+ display: flex;
}
#profile-photo {
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/setup_succeeded_page.html b/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/setup_succeeded_page.html
index 0606e528b0c..c33ae7b1314 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/setup_succeeded_page.html
+++ b/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/setup_succeeded_page.html
@@ -10,8 +10,8 @@
<template>
<style include="multidevice-setup-shared">
#page-icon-container {
- @apply --layout-horizontal;
- @apply --layout-center-justified;
+ display: flex;
+ justify-content: center;
}
#page-icon {
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/start_setup_page.html b/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/start_setup_page.html
index 2fc3dcc92b3..2ade2d97506 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/start_setup_page.html
+++ b/chromium/ui/webui/resources/cr_components/chromeos/multidevice_setup/start_setup_page.html
@@ -12,7 +12,7 @@
<template>
<style include="multidevice-setup-shared">
#selector-and-details-container {
- @apply --layout-horizontal;
+ display: flex;
margin-top: 20px;
min-height: 246px;
}
@@ -31,8 +31,8 @@
}
#page-icon-container {
- @apply --layout-horizontal;
- @apply --layout-center-justified;
+ display: flex;
+ justify-content: center;
}
#page-icon {
@@ -44,14 +44,16 @@
}
#deviceSelectionContainer {
- @apply --layout-vertical;
color: var(--paper-grey-600);
+ display: flex;
+ flex-direction: column;
}
#feature-details-container {
- @apply --layout-vertical;
- @apply --layout-center-justified;
border-inline-start: 1px solid rgb(218, 220, 224);
+ display: flex;
+ flex-direction: column;
+ justify-content: center;
padding-inline-start: 24px;
}
@@ -60,9 +62,9 @@
}
.feature-detail {
- @apply --layout-horizontal;
- @apply --layout-center;
+ align-items: center;
box-sizing: border-box;
+ display: flex;
padding: 10px 0;
}
@@ -88,7 +90,8 @@
/* On devices with small screens, use a single-column layout. */
@media screen and (max-width: 767px) {
#selector-and-details-container {
- @apply --layout-vertical;
+ display: flex;
+ flex-direction: column;
margin-top: 32px;
}
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/network/BUILD.gn b/chromium/ui/webui/resources/cr_components/chromeos/network/BUILD.gn
index 30b69da246f..6e1c7b28780 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/network/BUILD.gn
+++ b/chromium/ui/webui/resources/cr_components/chromeos/network/BUILD.gn
@@ -220,3 +220,407 @@ js_library("onc_mojo") {
"//ui/webui/resources/js:load_time_data",
]
}
+
+# TODO: Uncomment as the Polymer3 migration makes progress.
+# js_type_check("closure_compile_module") {
+# is_polymer3 = true
+# deps = [
+# ":mojo_interface_provider.m",
+# ":network_apnlist.m",
+# ":network_choose_mobile.m",
+# ":network_config.m",
+# ":network_config_element_behavior.m",
+# ":network_config_input.m",
+# ":network_config_select.m",
+# ":network_config_toggle.m",
+# ":network_icon.m",
+# ":network_icons.m",
+# ":network_ip_config.m",
+# ":network_list.m",
+# ":network_list_item.m",
+# ":network_list_types.m",
+# ":network_listener_behavior.m",
+# ":network_nameservers.m",
+# ":network_password_input.m",
+# ":network_property_list_mojo.m",
+# ":network_proxy.m",
+# ":network_proxy_exclusions.m",
+# ":network_proxy_input.m",
+# ":network_select.m",
+# ":network_shared_css.m",
+# ":network_siminfo.m",
+# ":onc_mojo.m"
+# ]
+# }
+
+js_library("mojo_interface_provider.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/mojo_interface_provider.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":mojo_interface_provider_module" ]
+}
+
+js_library("network_apnlist.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_apnlist.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_apnlist_module" ]
+}
+
+js_library("network_choose_mobile.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_choose_mobile.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_choose_mobile_module" ]
+}
+
+js_library("network_config.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_config.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_config_module" ]
+}
+
+js_library("network_config_element_behavior.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_config_element_behavior.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":modulize" ]
+}
+
+js_library("network_config_input.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_config_input.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_config_input_module" ]
+}
+
+js_library("network_config_select.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_config_select.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_config_select_module" ]
+}
+
+js_library("network_config_toggle.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_config_toggle.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_config_toggle_module" ]
+}
+
+js_library("network_icon.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_icon.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_icon_module" ]
+}
+
+js_library("network_icons.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_icons.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_icons_module" ]
+}
+
+js_library("network_ip_config.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_ip_config.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_ip_config_module" ]
+}
+
+js_library("network_list.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_list.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_list_module" ]
+}
+
+js_library("network_list_item.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_list_item.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_list_item_module" ]
+}
+
+js_library("network_list_types.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_list_types.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_list_types_module" ]
+}
+
+js_library("network_listener_behavior.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_listener_behavior.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":modulize" ]
+}
+
+js_library("network_nameservers.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_nameservers.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_nameservers_module" ]
+}
+
+js_library("network_password_input.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_password_input.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_password_input_module" ]
+}
+
+js_library("network_property_list_mojo.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_property_list_mojo.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_property_list_mojo_module" ]
+}
+
+js_library("network_proxy.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_proxy.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":modulize" ]
+}
+
+js_library("network_proxy_exclusions.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_proxy_exclusions.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_proxy_exclusions_module" ]
+}
+
+js_library("network_proxy_input.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_proxy_input.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_proxy_input_module" ]
+}
+
+js_library("network_select.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_select.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_select_module" ]
+}
+
+js_library("network_shared_css.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_shared_css.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_shared_css_module" ]
+}
+
+js_library("network_siminfo.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/network_siminfo.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":network_siminfo_module" ]
+}
+
+js_library("onc_mojo.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/network/onc_mojo.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":onc_mojo_module" ]
+}
+
+import("//tools/polymer/polymer.gni")
+
+group("polymer3_elements") {
+ public_deps = [
+ ":modulize",
+ ":mojo_interface_provider_module",
+ ":network_apnlist_module",
+ ":network_choose_mobile_module",
+ ":network_config_input_module",
+ ":network_config_module",
+ ":network_config_select_module",
+ ":network_config_toggle_module",
+ ":network_icon_module",
+ ":network_icons_module",
+ ":network_ip_config_module",
+ ":network_list_item_module",
+ ":network_list_module",
+ ":network_list_types_module",
+ ":network_nameservers_module",
+ ":network_password_input_module",
+ ":network_property_list_mojo_module",
+ ":network_proxy_exclusions_module",
+ ":network_proxy_input_module",
+ ":network_select_module",
+ ":network_shared_css_module",
+ ":network_siminfo_module",
+ ":onc_mojo_module",
+ ]
+}
+
+polymer_modulizer("mojo_interface_provider") {
+ js_file = "mojo_interface_provider.js"
+ html_file = "mojo_interface_provider.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_apnlist") {
+ js_file = "network_apnlist.js"
+ html_file = "network_apnlist.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_choose_mobile") {
+ js_file = "network_choose_mobile.js"
+ html_file = "network_choose_mobile.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_config") {
+ js_file = "network_config.js"
+ html_file = "network_config.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_config_input") {
+ js_file = "network_config_input.js"
+ html_file = "network_config_input.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_config_select") {
+ js_file = "network_config_select.js"
+ html_file = "network_config_select.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_config_toggle") {
+ js_file = "network_config_toggle.js"
+ html_file = "network_config_toggle.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_icon") {
+ js_file = "network_icon.js"
+ html_file = "network_icon.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_icons") {
+ js_file = "network_icons.m.js"
+ html_file = "network_icons.html"
+ html_type = "iron-iconset"
+}
+
+polymer_modulizer("network_ip_config") {
+ js_file = "network_ip_config.js"
+ html_file = "network_ip_config.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_list") {
+ js_file = "network_list.js"
+ html_file = "network_list.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_list_item") {
+ js_file = "network_list_item.js"
+ html_file = "network_list_item.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_list_types") {
+ js_file = "network_list_types.js"
+ html_file = "network_list_types.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_nameservers") {
+ js_file = "network_nameservers.js"
+ html_file = "network_nameservers.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_password_input") {
+ js_file = "network_password_input.js"
+ html_file = "network_password_input.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_property_list_mojo") {
+ js_file = "network_property_list_mojo.js"
+ html_file = "network_property_list_mojo.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_proxy_exclusions") {
+ js_file = "network_proxy_exclusions.js"
+ html_file = "network_proxy_exclusions.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_proxy_input") {
+ js_file = "network_proxy_input.js"
+ html_file = "network_proxy_input.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_select") {
+ js_file = "network_select.js"
+ html_file = "network_select.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("network_shared_css") {
+ js_file = "network_shared_css.m.js"
+ html_file = "network_shared_css.html"
+ html_type = "style-module"
+}
+
+polymer_modulizer("network_siminfo") {
+ js_file = "network_siminfo.js"
+ html_file = "network_siminfo.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("onc_mojo") {
+ js_file = "onc_mojo.js"
+ html_file = "onc_mojo.html"
+ html_type = "dom-module"
+}
+
+import("//ui/webui/resources/tools/js_modulizer.gni")
+
+js_modulizer("modulize") {
+ input_files = [
+ "network_config_element_behavior.js",
+ "network_listener_behavior.js",
+ "network_proxy.js",
+ ]
+}
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/network/mojo_interface_provider.js b/chromium/ui/webui/resources/cr_components/chromeos/network/mojo_interface_provider.js
index f47049562c1..e83e3853d95 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/network/mojo_interface_provider.js
+++ b/chromium/ui/webui/resources/cr_components/chromeos/network/mojo_interface_provider.js
@@ -29,6 +29,7 @@ cr.define('network_config', function() {
cr.addSingletonGetter(MojoInterfaceProviderImpl);
+ // #cr_define_end
return {
MojoInterfaceProvider: MojoInterfaceProvider,
MojoInterfaceProviderImpl: MojoInterfaceProviderImpl,
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/network/network_choose_mobile.html b/chromium/ui/webui/resources/cr_components/chromeos/network/network_choose_mobile.html
index 45c5185ae56..e2c96a75082 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/network/network_choose_mobile.html
+++ b/chromium/ui/webui/resources/cr_components/chromeos/network/network_choose_mobile.html
@@ -3,12 +3,13 @@
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/cr_elements/md_select_css.html">
+<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="network_shared_css.html">
<dom-module id="network-choose-mobile">
<template>
- <style include="network-shared md-select iron-flex">
+ <style include="cr-shared-style network-shared md-select iron-flex">
/* Leave some space between button and select. */
select {
margin-inline-start: 8px;
@@ -17,7 +18,7 @@
<div class="property-box first two-line">
<div class="flex layout vertical">
<div>[[i18n('networkChooseMobile')]]</div>
- <div class="secondary">
+ <div class="cr-secondary-text">
[[getSecondaryText_(managedProperties, deviceState)]]
</div>
</div>
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/network/network_list_item.html b/chromium/ui/webui/resources/cr_components/chromeos/network/network_list_item.html
index 3ae7c98a38e..78530b34ead 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/network/network_list_item.html
+++ b/chromium/ui/webui/resources/cr_components/chromeos/network/network_list_item.html
@@ -38,9 +38,7 @@
}
#networkStateText {
- color: var(--cr-secondary-text-color);
font-size: inherit;
- font-weight: 400;
}
#networkStateText[active] {
@@ -70,6 +68,7 @@
<div id="divText" class="layout horizontal flex">
<div aria-hidden="true">[[getItemName_(item)]]</div>
<div id="networkStateText"
+ class="cr-secondary-text"
hidden$="[[!isStateTextVisible_(networkState)]]"
active$="[[isStateTextActive_(networkState,
activationUnavailable)]]">
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/network/network_property_list_mojo.html b/chromium/ui/webui/resources/cr_components/chromeos/network/network_property_list_mojo.html
index 1b69d852839..06c91836a69 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/network/network_property_list_mojo.html
+++ b/chromium/ui/webui/resources/cr_components/chromeos/network/network_property_list_mojo.html
@@ -3,13 +3,14 @@
<link rel="import" href="chrome://resources/cr_elements/cr_input/cr_input.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_network_behavior_mojo.html">
<link rel="import" href="chrome://resources/cr_elements/policy/cr_policy_network_indicator_mojo.html">
+<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-flex-layout/iron-flex-layout-classes.html">
<link rel="import" href="network_shared_css.html">
<dom-module id="network-property-list-mojo">
<template>
- <style include="network-shared iron-flex">
+ <style include="cr-shared-style network-shared iron-flex">
/* Property lists are embedded; remove the padding. */
.property-box {
padding: 0;
@@ -39,7 +40,7 @@
<!-- Uneditable property value -->
<template is="dom-if" restamp
if="[[!showEditable_(item, editFieldTypes, propertyDict)]]">
- <div class="secondary">
+ <div class="cr-secondary-text">
[[getPropertyValue_(item, prefix, propertyDict)]]
</div>
</template>
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/network/network_shared_css.html b/chromium/ui/webui/resources/cr_components/chromeos/network/network_shared_css.html
index 8d9bdc994a5..5953bebc8c2 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/network/network_shared_css.html
+++ b/chromium/ui/webui/resources/cr_components/chromeos/network/network_shared_css.html
@@ -49,10 +49,6 @@
padding-inline-start: 16px;
}
- .secondary {
- @apply --cr-secondary-text;
- }
-
cr-input {
--cr-input-error-display: none;
margin-bottom: var(--cr-form-field-bottom-spacing);
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/network/onc_mojo.js b/chromium/ui/webui/resources/cr_components/chromeos/network/onc_mojo.js
index 25016e162ae..16847b73c82 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/network/onc_mojo.js
+++ b/chromium/ui/webui/resources/cr_components/chromeos/network/onc_mojo.js
@@ -590,6 +590,7 @@ class OncMojo {
security: mojom.SecurityType.kNone,
signalStrength: 0,
ssid: '',
+ isSyncable: false,
};
break;
default:
@@ -727,6 +728,7 @@ class OncMojo {
ssid: OncMojo.createManagedString(''),
security: mojom.SecurityType.kNone,
signalStrength: 0,
+ isSyncable: false,
}
};
break;
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/BUILD.gn b/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/BUILD.gn
index 19c5cb01f9c..a27e999205e 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/BUILD.gn
+++ b/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/BUILD.gn
@@ -35,3 +35,65 @@ js_library("setup_pin_keyboard") {
externs_list = [ "$externs_path/quick_unlock_private.js" ]
extra_sources = [ "$interfaces_path/quick_unlock_private_interface.js" ]
}
+
+# TODO: Uncomment as the Polymer3 migration makes progress.
+# js_type_check("closure_compile_module") {
+# is_polymer3 = true
+# deps = [
+# ":lock_screen_constants.m",
+# ":pin_keyboard.m",
+# ":setup_pin_keyboard.m"
+# ]
+# }
+
+js_library("lock_screen_constants.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/quick_unlock/lock_screen_constants.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":lock_screen_constants_module" ]
+}
+
+js_library("pin_keyboard.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/quick_unlock/pin_keyboard.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":pin_keyboard_module" ]
+}
+
+js_library("setup_pin_keyboard.m") {
+ sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/quick_unlock/setup_pin_keyboard.m.js" ]
+ deps = [
+ # TODO: Fill those in.
+ ]
+ extra_deps = [ ":setup_pin_keyboard_module" ]
+}
+
+import("//tools/polymer/polymer.gni")
+
+group("polymer3_elements") {
+ public_deps = [
+ ":lock_screen_constants_module",
+ ":pin_keyboard_module",
+ ":setup_pin_keyboard_module",
+ ]
+}
+
+polymer_modulizer("lock_screen_constants") {
+ js_file = "lock_screen_constants.js"
+ html_file = "lock_screen_constants.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("pin_keyboard") {
+ js_file = "pin_keyboard.js"
+ html_file = "pin_keyboard.html"
+ html_type = "dom-module"
+}
+
+polymer_modulizer("setup_pin_keyboard") {
+ js_file = "setup_pin_keyboard.js"
+ html_file = "setup_pin_keyboard.html"
+ html_type = "dom-module"
+}
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/lock_screen_constants.js b/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/lock_screen_constants.js
index e5ee46e6d1a..dbc85a36812 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/lock_screen_constants.js
+++ b/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/lock_screen_constants.js
@@ -5,31 +5,29 @@
/**
* @fileoverview Constants used for logging the pin unlock setup uma.
*/
-
-/**
- * Name of the pin unlock setup uma histogram.
- * @type {string}
- */
-const PinUnlockUmaHistogramName = 'Settings.PinUnlockSetup';
-
-/**
- * Stages the user can enter while setting up pin unlock.
- * @enum {number}
- */
-const LockScreenProgress = {
- START_SCREEN_LOCK: 0,
- ENTER_PASSWORD_CORRECTLY: 1,
- CHOOSE_PIN_OR_PASSWORD: 2,
- ENTER_PIN: 3,
- CONFIRM_PIN: 4,
- MAX_BUCKET: 5
-};
-
cr.define('settings', function() {
/**
+ * Name of the pin unlock setup uma histogram.
+ * @type {string}
+ */
+ const PinUnlockUmaHistogramName = 'Settings.PinUnlockSetup';
+
+ /**
+ * Stages the user can enter while setting up pin unlock.
+ * @enum {number}
+ */
+ const LockScreenProgress = {
+ START_SCREEN_LOCK: 0,
+ ENTER_PASSWORD_CORRECTLY: 1,
+ CHOOSE_PIN_OR_PASSWORD: 2,
+ ENTER_PIN: 3,
+ CONFIRM_PIN: 4,
+ MAX_BUCKET: 5
+ };
+ /**
* Helper function to send the progress of the pin setup to be recorded in the
* histogram.
- * @param {LockScreenProgress} currentProgress
+ * @param {settings.LockScreenProgress} currentProgress
*/
const recordLockScreenProgress = function(currentProgress) {
if (currentProgress >= LockScreenProgress.MAX_BUCKET) {
@@ -43,5 +41,9 @@ cr.define('settings', function() {
]);
};
- return {recordLockScreenProgress: recordLockScreenProgress};
+ // #cr_define_end
+ return {
+ recordLockScreenProgress: recordLockScreenProgress,
+ LockScreenProgress: LockScreenProgress
+ };
});
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/pin_keyboard.html b/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/pin_keyboard.html
index b82f4431193..36d6749581c 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/pin_keyboard.html
+++ b/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/pin_keyboard.html
@@ -12,26 +12,7 @@
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/iron-iconset-svg/iron-iconset-svg.html">
-
-<iron-iconset-svg name="pin-keyboard" size="24">
- <svg>
- <defs>
- <!--
- Inlined from Polymer's iron-icons to avoid importing everything.
- See http://goo.gl/Y1OdAq for instructions on adding additional icons.
- -->
- <g id="arrow-forward">
- <path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z">
- </path>
- </g>
- <g id="backspace">
- <path d="M7.5 12.992L10.492 10 7.5 7.008l1.175-1.175 2.992 2.992 2.991-2.992 1.175 1.175L12.842 10l2.991 2.992-1.175 1.175-2.991-2.992-2.992 2.992L7.5 12.992zM17.5 5H6.667l-3.75 5 3.75 5H17.5V5zm0-1.667c.917 0 1.667.75 1.667 1.667v10c0 .917-.75 1.667-1.667 1.667H6.667c-.525 0-1.017-.25-1.334-.667l-4.5-6 4.5-6a1.677 1.677 0 011.334-.667H17.5z">
- </path>
- </g>
- </defs>
- </svg>
-</iron-iconset-svg>
+<link rel="import" href="pin_keyboard_icon.html">
<dom-module id="pin-keyboard">
<template>
@@ -109,13 +90,7 @@
width: var(--pin-button-size);
--ink-color: var(--google-grey-900);
- --paper-ripple-height: var(--pin-button-ripple-height);
- --paper-ripple-left: var(--pin-button-ripple-left);
--paper-ripple-opacity: .15;
- --paper-ripple-top: var(--pin-button-ripple-top);
- --paper-ripple-width: var(--pin-button-ripple-width);
-
- @apply --pin-keyboard-paper-ripple;
}
:host-context(.focus-outline-visible) .digit-button:focus {
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/pin_keyboard_icon.html b/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/pin_keyboard_icon.html
new file mode 100644
index 00000000000..6aaf8c5599c
--- /dev/null
+++ b/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/pin_keyboard_icon.html
@@ -0,0 +1,22 @@
+<link rel="import" href="chrome://resources/html/polymer.html">
+
+<link rel="import" href="chrome://resources/polymer/v1_0/iron-iconset-svg/iron-iconset-svg.html">
+
+<iron-iconset-svg name="pin-keyboard" size="24">
+ <svg>
+ <defs>
+ <!--
+ Inlined from Polymer's iron-icons to avoid importing everything.
+ See http://goo.gl/Y1OdAq for instructions on adding additional icons.
+ -->
+ <g id="arrow-forward">
+ <path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z">
+ </path>
+ </g>
+ <g id="backspace">
+ <path d="M7.5 12.992L10.492 10 7.5 7.008l1.175-1.175 2.992 2.992 2.991-2.992 1.175 1.175L12.842 10l2.991 2.992-1.175 1.175-2.991-2.992-2.992 2.992L7.5 12.992zM17.5 5H6.667l-3.75 5 3.75 5H17.5V5zm0-1.667c.917 0 1.667.75 1.667 1.667v10c0 .917-.75 1.667-1.667 1.667H6.667c-.525 0-1.017-.25-1.334-.667l-4.5-6 4.5-6a1.677 1.677 0 011.334-.667H17.5z">
+ </path>
+ </g>
+ </defs>
+ </svg>
+</iron-iconset-svg> \ No newline at end of file
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/setup_pin_keyboard.html b/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/setup_pin_keyboard.html
index 21c46c2fdc4..4babf0c6455 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/setup_pin_keyboard.html
+++ b/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/setup_pin_keyboard.html
@@ -1,12 +1,12 @@
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_components/chromeos/quick_unlock/lock_screen_constants.html">
-<link rel="import" href="chrome://resources/cr_components/chromeos/quick_unlock/pin_keyboard.html">
<link rel="import" href="chrome://resources/cr_elements/cr_dialog/cr_dialog.html">
<link rel="import" href="chrome://resources/cr_elements/icons.html">
<link rel="import" href="chrome://resources/cr_elements/shared_vars_css.html">
<link rel="import" href="chrome://resources/html/assert.html">
<link rel="import" href="chrome://resources/html/i18n_behavior.html">
+<link rel="import" href="pin_keyboard.html">
<!--
@@ -94,7 +94,5 @@ Where:
</div>
</pin-keyboard>
</template>
- <script
- src="chrome://resources/cr_components/chromeos/quick_unlock/setup_pin_keyboard.js">
- </script>
+ <script src="setup_pin_keyboard.js"></script>
</dom-module>
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/setup_pin_keyboard.js b/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/setup_pin_keyboard.js
index dab88079efe..1443e8fee07 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/setup_pin_keyboard.js
+++ b/chromium/ui/webui/resources/cr_components/chromeos/quick_unlock/setup_pin_keyboard.js
@@ -94,7 +94,7 @@ Polymer({
/**
* writeUma is a function that handles writing uma stats.
*
- * @type {function(LockScreenProgress)}
+ * @type {function(settings.LockScreenProgress)}
*/
writeUma: {
type: Object,
@@ -338,7 +338,7 @@ Polymer({
this.onPinChange_(new CustomEvent(
'pin-change', {detail: {pin: this.pinKeyboardValue_}}));
this.$.pinKeyboard.focusInput();
- this.writeUma(LockScreenProgress.ENTER_PIN);
+ this.writeUma(settings.LockScreenProgress.ENTER_PIN);
return;
}
// onPinSubmit gets called if the user hits enter on the PIN keyboard.
@@ -357,7 +357,7 @@ Polymer({
this.setModes.call(
null, [chrome.quickUnlockPrivate.QuickUnlockMode.PIN],
[this.pinKeyboardValue_], this.onSetModesCompleted_.bind(this));
- this.writeUma(LockScreenProgress.CONFIRM_PIN);
+ this.writeUma(settings.LockScreenProgress.CONFIRM_PIN);
},
/**
diff --git a/chromium/ui/webui/resources/cr_components/chromeos/smb_shares/BUILD.gn b/chromium/ui/webui/resources/cr_components/chromeos/smb_shares/BUILD.gn
index 7e0cd0a0454..0bf953c6789 100644
--- a/chromium/ui/webui/resources/cr_components/chromeos/smb_shares/BUILD.gn
+++ b/chromium/ui/webui/resources/cr_components/chromeos/smb_shares/BUILD.gn
@@ -60,17 +60,17 @@ js_library("add_smb_share_dialog.m") {
extra_deps = [ ":add_smb_share_dialog_module" ]
}
-js_modulizer("smb_browser_proxy_module") {
- input_files = [ "smb_browser_proxy.js" ]
- namespace_rewrites = [ "smb_shares.SmbBrowserProxy|SmbBrowserProxy" ]
-}
-
js_library("smb_browser_proxy.m") {
deps = [ "//ui/webui/resources/js:cr.m" ]
sources = [ "$root_gen_dir/ui/webui/resources/cr_components/chromeos/smb_shares/smb_browser_proxy.m.js" ]
extra_deps = [ ":smb_browser_proxy_module" ]
}
+js_modulizer("smb_browser_proxy_module") {
+ input_files = [ "smb_browser_proxy.js" ]
+ namespace_rewrites = [ "smb_shares.SmbBrowserProxy|SmbBrowserProxy" ]
+}
+
polymer_modulizer("add_smb_share_dialog") {
js_file = "add_smb_share_dialog.js"
html_file = "add_smb_share_dialog.html"
@@ -78,3 +78,10 @@ polymer_modulizer("add_smb_share_dialog") {
namespace_rewrites = [ "smb_shares.SmbBrowserProxy|SmbBrowserProxy" ]
auto_imports = [ "ui/webui/resources/cr_components/chromeos/smb_shares/smb_browser_proxy.html|SmbAuthMethod,SmbBrowserProxy,SmbBrowserProxyImpl,SmbMountResult" ]
}
+
+group("polymer3_elements") {
+ public_deps = [
+ ":add_smb_share_dialog_module",
+ ":smb_browser_proxy_module",
+ ]
+}
diff --git a/chromium/ui/webui/resources/cr_components/cr_components_resources.grdp b/chromium/ui/webui/resources/cr_components/cr_components_resources.grdp
index a3b15879b02..5b6ac7a9a3e 100644
--- a/chromium/ui/webui/resources/cr_components/cr_components_resources.grdp
+++ b/chromium/ui/webui/resources/cr_components/cr_components_resources.grdp
@@ -1,101 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<grit-part>
- <if expr="use_nss_certs">
- <structure name="IDR_WEBUI_CA_TRUST_EDIT_DIALOG_JS"
- file="cr_components/certificate_manager/ca_trust_edit_dialog.js"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CA_TRUST_EDIT_DIALOG_HTML"
- file="cr_components/certificate_manager/ca_trust_edit_dialog.html"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_DELETE_CONFIRMATION_DIALOG_JS"
- file="cr_components/certificate_manager/certificate_delete_confirmation_dialog.js"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_DELETE_CONFIRMATION_DIALOG_HTML"
- file="cr_components/certificate_manager/certificate_delete_confirmation_dialog.html"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_MANAGER_HTML"
- file="cr_components/certificate_manager/certificate_manager.html"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_MANAGER_JS"
- file="cr_components/certificate_manager/certificate_manager.js"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_PASSWORD_ENCRYPTION_DIALOG_JS"
- file="cr_components/certificate_manager/certificate_password_encryption_dialog.js"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_PASSWORD_ENCRYPTION_DIALOG_HTML"
- file="cr_components/certificate_manager/certificate_password_encryption_dialog.html"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_PASSWORD_DECRYPTION_DIALOG_JS"
- file="cr_components/certificate_manager/certificate_password_decryption_dialog.js"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_PASSWORD_DECRYPTION_DIALOG_HTML"
- file="cr_components/certificate_manager/certificate_password_decryption_dialog.html"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATES_ERROR_DIALOG_JS"
- file="cr_components/certificate_manager/certificates_error_dialog.js"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATES_ERROR_DIALOG_HTML"
- file="cr_components/certificate_manager/certificates_error_dialog.html"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_ENTRY_HTML"
- file="cr_components/certificate_manager/certificate_entry.html"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_ENTRY_JS"
- file="cr_components/certificate_manager/certificate_entry.js"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_LIST_HTML"
- file="cr_components/certificate_manager/certificate_list.html"
- preprocess="true"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_LIST_JS"
- file="cr_components/certificate_manager/certificate_list.js"
- preprocess="true"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_MANAGER_TYPES_HTML"
- file="cr_components/certificate_manager/certificate_manager_types.html"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_MANAGER_TYPES_JS"
- file="cr_components/certificate_manager/certificate_manager_types.js"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_SHARED_CSS_HTML"
- file="cr_components/certificate_manager/certificate_shared_css.html"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_SUBENTRY_HTML"
- file="cr_components/certificate_manager/certificate_subentry.html"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATE_SUBENTRY_JS"
- file="cr_components/certificate_manager/certificate_subentry.js"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATES_BROWSER_PROXY_HTML"
- file="cr_components/certificate_manager/certificates_browser_proxy.html"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_WEBUI_CERTIFICATES_BROWSER_PROXY_JS"
- file="cr_components/certificate_manager/certificates_browser_proxy.js"
- type="chrome_html"
- compress="gzip" />
- </if>
<if expr="chromeos and not optimize_webui">
<!-- Chrome OS Custom Elements. When optimize_webui is true these are -->
<!-- vulcanized and are not included individually. -->
@@ -250,6 +154,10 @@
file="cr_components/chromeos/quick_unlock/setup_pin_keyboard.html"
type="chrome_html"
compress="gzip"/>
+ <structure name="IDR_WEBUI_CHROMEOS_QUICK_UNLOCK_PIN_KEYBOARD_ICON_HTML"
+ file="cr_components/chromeos/quick_unlock/pin_keyboard_icon.html"
+ type="chrome_html"
+ compress="gzip"/>
<structure name="IDR_WEBUI_CHROMEOS_QUICK_UNLOCK_LOCK_SCREEN_CONSTANTS_JS"
file="cr_components/chromeos/quick_unlock/lock_screen_constants.js"
type="chrome_html"
diff --git a/chromium/ui/webui/resources/cr_components/cr_components_resources_v3.grdp b/chromium/ui/webui/resources/cr_components/cr_components_resources_v3.grdp
index 11b15e748fc..b4bdcad48fc 100644
--- a/chromium/ui/webui/resources/cr_components/cr_components_resources_v3.grdp
+++ b/chromium/ui/webui/resources/cr_components/cr_components_resources_v3.grdp
@@ -24,66 +24,91 @@
compress="gzip" />
</if>
<if expr="use_nss_certs">
- <include name="IDR_WEBUI_CA_TRUST_EDIT_DIALOG_M_JS"
- file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/ca_trust_edit_dialog.m.js"
+ <include name="IDR_WEBUI_CA_TRUST_EDIT_DIALOG_JS"
+ file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/ca_trust_edit_dialog.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
- <include name="IDR_WEBUI_CERTIFICATE_DELETE_CONFIRMATION_DIALOG_M_JS"
- file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_delete_confirmation_dialog.m.js"
+ <include name="IDR_WEBUI_CERTIFICATE_DELETE_CONFIRMATION_DIALOG_JS"
+ file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_delete_confirmation_dialog.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
- <include name="IDR_WEBUI_CERTIFICATE_MANAGER_M_JS"
- file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_manager.m.js"
+ <include name="IDR_WEBUI_CERTIFICATE_MANAGER_JS"
+ file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_manager.js"
use_base_dir="false"
+ preprocess="true"
type="BINDATA"
compress="gzip" />
- <include name="IDR_WEBUI_CERTIFICATE_PASSWORD_ENCRYPTION_DIALOG_M_JS"
- file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_password_encryption_dialog.m.js"
+ <include name="IDR_WEBUI_CERTIFICATE_PASSWORD_ENCRYPTION_DIALOG_JS"
+ file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_password_encryption_dialog.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
- <include name="IDR_WEBUI_CERTIFICATE_PASSWORD_DECRYPTION_DIALOG_M_JS"
- file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_password_decryption_dialog.m.js"
+ <include name="IDR_WEBUI_CERTIFICATE_PASSWORD_DECRYPTION_DIALOG_JS"
+ file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_password_decryption_dialog.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
- <include name="IDR_WEBUI_CERTIFICATES_ERROR_DIALOG_M_JS"
- file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificates_error_dialog.m.js"
+ <include name="IDR_WEBUI_CERTIFICATES_ERROR_DIALOG_JS"
+ file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificates_error_dialog.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
- <include name="IDR_WEBUI_CERTIFICATE_ENTRY_M_JS"
- file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_entry.m.js"
+ <include name="IDR_WEBUI_CERTIFICATE_ENTRY_JS"
+ file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_entry.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
- <include name="IDR_WEBUI_CERTIFICATE_LIST_M_JS"
- file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_list.m.js"
+ <include name="IDR_WEBUI_CERTIFICATE_LIST_JS"
+ file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_list.js"
use_base_dir="false"
preprocess="true"
type="BINDATA"
compress="gzip" />
- <include name="IDR_WEBUI_CERTIFICATE_MANAGER_TYPES_M_JS"
- file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_manager_types.m.js"
+ <include name="IDR_WEBUI_CERTIFICATE_MANAGER_TYPES_JS"
+ file="cr_components/certificate_manager/certificate_manager_types.js"
+ type="BINDATA"
+ compress="gzip" />
+ <include name="IDR_WEBUI_CERTIFICATE_SHARED_CSS_JS"
+ file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_shared_css.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
- <include name="IDR_WEBUI_CERTIFICATE_SHARED_CSS_M_JS"
- file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_shared_css.m.js"
+ <include name="IDR_WEBUI_CERTIFICATE_SUBENTRY_JS"
+ file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_subentry.js"
use_base_dir="false"
type="BINDATA"
compress="gzip" />
- <include name="IDR_WEBUI_CERTIFICATE_SUBENTRY_M_JS"
- file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_subentry.m.js"
+ <!-- TODO(https://crbug.com/1071641): When conditional imports are possible
+ in cr_components, only include the certificate provisioning items for
+ ChromeOS platforms. -->
+ <include name="IDR_WEBUI_CERTIFICATE_PROVISIONING_LIST_JS"
+ file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_list.js"
+ use_base_dir="false"
+ type="BINDATA"
+ preprocess="true"
+ compress="gzip" />
+ <include name="IDR_WEBUI_CERTIFICATE_PROVISIONING_ENTRY_JS"
+ file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_entry.js"
use_base_dir="false"
type="BINDATA"
+ preprocess="true"
compress="gzip" />
- <include name="IDR_WEBUI_CERTIFICATES_BROWSER_PROXY_M_JS"
- file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificates_browser_proxy.m.js"
+ <include name="IDR_WEBUI_CERTIFICATE_PROVISIONING_DETAILS_DIALOG_JS"
+ file="${root_gen_dir}/ui/webui/resources/cr_components/certificate_manager/certificate_provisioning_details_dialog.js"
use_base_dir="false"
type="BINDATA"
+ preprocess="true"
+ compress="gzip" />
+ <include name="IDR_WEBUI_CERTIFICATE_PROVISIONING_BROWSER_PROXY"
+ file="cr_components/certificate_manager/certificate_provisioning_browser_proxy.js"
+ type="BINDATA"
+ preprocess="true"
+ compress="gzip" />
+ <include name="IDR_WEBUI_CERTIFICATES_BROWSER_PROXY_JS"
+ file="cr_components/certificate_manager/certificates_browser_proxy.js"
+ type="BINDATA"
compress="gzip" />
</if>
</grit-part>
diff --git a/chromium/ui/webui/resources/cr_components/omnibox/BUILD.gn b/chromium/ui/webui/resources/cr_components/omnibox/BUILD.gn
index 94b6ed48fa7..b02454dcd94 100644
--- a/chromium/ui/webui/resources/cr_components/omnibox/BUILD.gn
+++ b/chromium/ui/webui/resources/cr_components/omnibox/BUILD.gn
@@ -3,7 +3,7 @@
# found in the LICENSE file.
import("//third_party/closure_compiler/compile_js.gni")
-import("//tools/polymer/polymer.gni")
+import("//tools/polymer/html_to_js.gni")
js_type_check("closure_compile") {
uses_js_modules = true
@@ -13,11 +13,6 @@ js_type_check("closure_compile") {
js_library("cr_autocomplete_match_list") {
}
-polymer_modulizer("cr_autocomplete_match_list") {
- js_file = "cr_autocomplete_match_list.js"
- html_file = "cr_autocomplete_match_list.html"
- html_type = "v3-ready"
-}
-group("omnibox_modules") {
- public_deps = [ ":cr_autocomplete_match_list_module" ]
+html_to_js("web_components") {
+ js_files = [ "cr_autocomplete_match_list.js" ]
}
diff --git a/chromium/ui/webui/resources/cr_elements/BUILD.gn b/chromium/ui/webui/resources/cr_elements/BUILD.gn
index 46e261a00e3..b57828b74c0 100644
--- a/chromium/ui/webui/resources/cr_elements/BUILD.gn
+++ b/chromium/ui/webui/resources/cr_elements/BUILD.gn
@@ -19,6 +19,7 @@ group("closure_compile") {
"cr_icon_button:closure_compile",
"cr_input:closure_compile",
"cr_link_row:closure_compile",
+ "cr_lottie:closure_compile",
"cr_profile_avatar_selector:closure_compile",
"cr_radio_button:closure_compile",
"cr_radio_group:closure_compile",
@@ -44,6 +45,7 @@ group("closure_compile") {
"cr_input:closure_compile_module",
"cr_lazy_render:closure_compile_module",
"cr_link_row:closure_compile_module",
+ "cr_lottie:closure_compile_module",
"cr_profile_avatar_selector:closure_compile_module",
"cr_radio_button:closure_compile_module",
"cr_radio_group:closure_compile_module",
@@ -166,11 +168,12 @@ group("polymer3_elements") {
"cr_dialog:cr_dialog_module",
"cr_drawer:cr_drawer_module",
"cr_expand_button:cr_expand_button_module",
- "cr_fingerprint:cr_fingerprint_progress_arc_module",
+ "cr_fingerprint:polymer3_elements",
"cr_icon_button:cr_icon_button_module",
"cr_input:polymer3_elements",
"cr_lazy_render:cr_lazy_render_module",
"cr_link_row:cr_link_row_module",
+ "cr_lottie:cr_lottie_module",
"cr_profile_avatar_selector:polymer3_elements",
"cr_radio_button:polymer3_elements",
"cr_radio_group:cr_radio_group_module",
diff --git a/chromium/ui/webui/resources/cr_elements/chromeos/BUILD.gn b/chromium/ui/webui/resources/cr_elements/chromeos/BUILD.gn
index ce4559bdba0..33cc937da69 100644
--- a/chromium/ui/webui/resources/cr_elements/chromeos/BUILD.gn
+++ b/chromium/ui/webui/resources/cr_elements/chromeos/BUILD.gn
@@ -9,7 +9,6 @@ assert(is_chromeos, "Only ChromeOS components belong here.")
group("closure_compile") {
deps = [
- "cr_lottie:closure_compile",
"cr_picture:closure_compile",
# Targets for auto-generated Polymer3/JS Modules
diff --git a/chromium/ui/webui/resources/cr_elements/chromeos/cr_lottie/BUILD.gn b/chromium/ui/webui/resources/cr_elements/chromeos/cr_lottie/BUILD.gn
deleted file mode 100644
index e7927334367..00000000000
--- a/chromium/ui/webui/resources/cr_elements/chromeos/cr_lottie/BUILD.gn
+++ /dev/null
@@ -1,10 +0,0 @@
-import("//third_party/closure_compiler/compile_js.gni")
-
-js_type_check("closure_compile") {
- deps = [ ":cr_lottie" ]
-}
-
-js_library("cr_lottie") {
- deps = [ "//ui/webui/resources/js:cr" ]
- externs_list = [ "$externs_path/pending.js" ]
-}
diff --git a/chromium/ui/webui/resources/cr_elements/cr_button/cr_button.js b/chromium/ui/webui/resources/cr_elements/cr_button/cr_button.js
index 6ec5d722445..90213b046fe 100644
--- a/chromium/ui/webui/resources/cr_elements/cr_button/cr_button.js
+++ b/chromium/ui/webui/resources/cr_elements/cr_button/cr_button.js
@@ -47,6 +47,7 @@ Polymer({
},
listeners: {
+ blur: 'onBlur_',
click: 'onClick_',
keydown: 'onKeyDown_',
keyup: 'onKeyUp_',
@@ -54,6 +55,17 @@ Polymer({
tap: 'onTap_',
},
+ /**
+ * It is possible to activate a tab when the space key is pressed down. When
+ * this element has focus, the keyup event for the space key should not
+ * perform a 'click'. |spaceKeyDown_| tracks when a space pressed and handled
+ * by this element. Space keyup will only result in a 'click' when
+ * |spaceKeyDown_| is true. |spaceKeyDown_| is set to false when element loses
+ * focus.
+ * @private {boolean}
+ */
+ spaceKeyDown_: false,
+
/** @private {Set<number>} */
timeoutIds_: null,
@@ -113,6 +125,11 @@ Polymer({
this.setAttribute('tabindex', value);
},
+ /** @private */
+ onBlur_() {
+ this.spaceKeyDown_ = false;
+ },
+
/**
* @param {!Event} e
* @private
@@ -136,6 +153,7 @@ Polymer({
e.stopPropagation();
if (e.repeat) {
+ this.lastKeyDownKey_ = null;
return;
}
@@ -145,6 +163,8 @@ Polymer({
// Delay was chosen manually as a good time period for the ripple to be
// visible.
this.setTimeout_(() => this.getRipple().uiUpAction(), 100);
+ } else if (e.key === ' ') {
+ this.spaceKeyDown_ = true;
}
},
@@ -160,7 +180,8 @@ Polymer({
e.preventDefault();
e.stopPropagation();
- if (e.key === ' ') {
+ if (this.spaceKeyDown_ && e.key === ' ') {
+ this.spaceKeyDown_ = false;
this.click();
this.getRipple().uiUpAction();
}
diff --git a/chromium/ui/webui/resources/cr_elements/cr_fingerprint/BUILD.gn b/chromium/ui/webui/resources/cr_elements/cr_fingerprint/BUILD.gn
index 0fab0a9cf74..7f9b6638be6 100644
--- a/chromium/ui/webui/resources/cr_elements/cr_fingerprint/BUILD.gn
+++ b/chromium/ui/webui/resources/cr_elements/cr_fingerprint/BUILD.gn
@@ -12,12 +12,25 @@ js_type_check("closure_compile") {
js_library("cr_fingerprint_progress_arc") {
}
+group("polymer3_elements") {
+ public_deps = [
+ ":cr_fingerprint_icon_module",
+ ":cr_fingerprint_progress_arc_module",
+ ]
+}
+
polymer_modulizer("cr_fingerprint_progress_arc") {
js_file = "cr_fingerprint_progress_arc.js"
html_file = "cr_fingerprint_progress_arc.html"
html_type = "dom-module"
}
+polymer_modulizer("cr_fingerprint_icon") {
+ js_file = "cr_fingerprint_icon.m.js"
+ html_file = "cr_fingerprint_icon.html"
+ html_type = "iron-iconset"
+}
+
js_type_check("closure_compile_module") {
is_polymer3 = true
deps = [ ":cr_fingerprint_progress_arc.m" ]
diff --git a/chromium/ui/webui/resources/cr_elements/cr_fingerprint/cr_fingerprint_icon.html b/chromium/ui/webui/resources/cr_elements/cr_fingerprint/cr_fingerprint_icon.html
new file mode 100644
index 00000000000..51f354315e3
--- /dev/null
+++ b/chromium/ui/webui/resources/cr_elements/cr_fingerprint/cr_fingerprint_icon.html
@@ -0,0 +1,22 @@
+<link rel="import" href="../../html/polymer.html">
+<link rel="import" href="chrome://resources/polymer/v1_0/iron-iconset-svg/iron-iconset-svg.html">
+
+<iron-iconset-svg name="cr-fingerprint-icon" size="32">
+ <svg>
+ <defs>
+ <g id="enrollment-done" viewBox="0 0 93 104">
+ <path fill="#3E82F1" d="M75.346031,12.4513714 C65.426031,7.33637143 56.8487739,5.16637143 46.5674024,5.16637143 C36.3374024,5.16637143 26.6237739,7.595 17.7896596,12.4513714 C16.5487739,13.1227429 14.9987739,12.6577429 14.276031,11.4177429 C13.6046596,10.1777429 14.0696596,8.57637143 15.3096596,7.905 C24.9196596,2.68637143 35.4596596,0 46.5674024,0 C57.5732882,0 67.1824024,2.42774286 77.7232882,7.85274286 C79.0146596,8.525 79.4796596,10.075 78.8074024,11.315 C78.3424024,12.245 77.4646596,12.7613714 76.5346596,12.7613714 C76.121031,12.7613714 75.7074024,12.6577429 75.346031,12.4513714 Z">
+ </path>
+ <path fill="#32A753" d="M1.10147387,39.4213714 C-0.0871547017,38.595 -0.344897559,36.9927429 0.480588155,35.805 C5.59647387,28.5713714 12.1055882,22.8877429 19.8555882,18.91 C36.0801024,10.54 56.8492167,10.4877429 73.1242167,18.8577429 C80.8742167,22.8363714 87.3851024,28.4677429 92.4992167,35.65 C93.3264739,36.7863714 93.0678453,38.44 91.8801024,39.2663714 C90.6914739,40.0927429 89.0892167,39.835 88.2628453,38.6463714 C83.6128453,32.1363714 77.7228453,27.0213714 70.7478453,23.4563714 C55.9192167,15.8613714 36.9578453,15.8613714 22.1805882,23.5077429 C15.1551024,27.125 9.26421673,32.2913714 4.61421673,38.8013714 C4.20147387,39.525 3.42647387,39.8863714 2.59921673,39.8863714 C2.0828453,39.8863714 1.56647387,39.7313714 1.10147387,39.4213714 Z">
+ </path>
+ <path fill="#F9BB00" d="M33.0827567,101.473097 C28.5877567,96.9780971 26.1600139,94.0844686 22.6977567,87.8330971 C19.1327567,81.4780971 17.2727567,73.7280971 17.2727567,65.4094686 C17.2727567,50.0644686 30.3963853,37.5617257 46.5163853,37.5617257 C62.6354996,37.5617257 75.7600139,50.0644686 75.7600139,65.4094686 C75.7600139,66.8567257 74.6227567,67.9930971 73.1763853,67.9930971 C71.7300139,67.9930971 70.5927567,66.8567257 70.5927567,65.4094686 C70.5927567,52.9067257 59.7941282,42.7280971 46.5163853,42.7280971 C33.2377567,42.7280971 22.4391282,52.9067257 22.4391282,65.4094686 C22.4391282,72.8494686 24.0927567,79.7217257 27.2441282,85.3017257 C30.5513853,91.2430971 32.8241282,93.7744686 36.8027567,97.8044686 C37.7850139,98.8380971 37.7850139,100.439469 36.8027567,101.473097 C36.2350139,101.989469 35.5627567,102.248097 34.8913853,102.248097 C34.2191282,102.248097 33.5477567,101.989469 33.0827567,101.473097 Z">
+ </path>
+ <path fill="#E74133" d="M55.9193939,88.0911057 C48.221651,82.8733629 43.6230224,74.3997343 43.6230224,65.4097343 C43.6230224,63.9633629 44.7593939,62.8261057 46.2057653,62.8261057 C47.6530224,62.8261057 48.7893939,63.9633629 48.7893939,65.4097343 C48.7893939,72.6947343 52.5093939,79.5661057 58.8130224,83.8033629 C62.4807653,86.2833629 66.7693939,87.4711057 71.9357653,87.4711057 C73.1757653,87.4711057 75.2421367,87.3161057 77.3093939,86.9547343 C78.7052796,86.6961057 80.0480224,87.6261057 80.3057653,89.0733629 C80.5643939,90.4683629 79.6343939,91.8111057 78.1880224,92.0697343 C75.2421367,92.6383629 72.6593939,92.6897343 71.9357653,92.6897343 C65.7880224,92.6897343 60.3630224,91.1397343 55.9193939,88.0911057 Z">
+ </path>
+ <path fill="#3E82F1" d="M60.8797482,103.229557 C52.6647482,100.955929 47.2911196,97.9081857 41.6597482,92.3795571 C34.4261196,85.1981857 30.4483767,75.6395571 30.4483767,65.4095571 C30.4483767,57.0395571 37.5783767,50.2195571 46.3611196,50.2195571 C55.1447482,50.2195571 62.2738624,57.0395571 62.2738624,65.4095571 C62.2738624,70.9381857 67.0797482,75.4331857 73.0211196,75.4331857 C78.962491,75.4331857 83.767491,70.9381857 83.767491,65.4095571 C83.767491,45.9309286 66.9761196,30.1218143 46.3097482,30.1218143 C31.6361196,30.1218143 18.2033767,38.2845571 12.157491,50.9431857 C10.142491,55.1281857 9.10974816,60.0359286 9.10974816,65.4095571 C9.10974816,69.4395571 9.47111958,75.7945571 12.5711196,84.0609286 C13.087491,85.4045571 12.4161196,86.9031857 11.0733767,87.3681857 C9.72974816,87.8845571 8.23111958,87.1609286 7.76611958,85.8695571 C5.23474816,79.1018143 3.99474816,72.3845571 3.99474816,65.4095571 C3.99474816,59.2095571 5.18249101,53.5781857 7.50749101,48.6695571 C14.3797482,34.2545571 29.6211196,24.9031857 46.3097482,24.9031857 C69.817491,24.9031857 88.9347482,43.0381857 88.9347482,65.3581857 C88.9347482,73.7281857 81.8047482,80.5481857 73.0211196,80.5481857 C64.237491,80.5481857 57.107491,73.7281857 57.107491,65.3581857 C57.107491,59.8295571 52.3033767,55.3345571 46.3611196,55.3345571 C40.4197482,55.3345571 35.6147482,59.8295571 35.6147482,65.3581857 C35.6147482,74.1931857 39.0238624,82.4595571 45.2761196,88.6595571 C50.1847482,93.5168143 54.8861196,96.2031857 62.1711196,98.2181857 C63.5661196,98.5795571 64.3411196,100.026814 63.9797482,101.369557 C63.7211196,102.558186 62.6361196,103.333186 61.5511196,103.333186 C61.3447482,103.333186 61.0861196,103.280929 60.8797482,103.229557 Z">
+ </path>
+ </g>
+ </defs>
+ </svg>
+</iron-iconset-svg>
+
diff --git a/chromium/ui/webui/resources/cr_elements/cr_fingerprint/cr_fingerprint_progress_arc.html b/chromium/ui/webui/resources/cr_elements/cr_fingerprint/cr_fingerprint_progress_arc.html
index 2a504ce2279..d76130c087c 100644
--- a/chromium/ui/webui/resources/cr_elements/cr_fingerprint/cr_fingerprint_progress_arc.html
+++ b/chromium/ui/webui/resources/cr_elements/cr_fingerprint/cr_fingerprint_progress_arc.html
@@ -1,24 +1,5 @@
<link rel="import" href="../../html/polymer.html">
-<link rel="import" href="chrome://resources/polymer/v1_0/iron-iconset-svg/iron-iconset-svg.html">
-
-<iron-iconset-svg name="cr-fingerprint-icon" size="32">
- <svg>
- <defs>
- <g id="enrollment-done" viewBox="0 0 93 104">
- <path fill="#3E82F1" d="M75.346031,12.4513714 C65.426031,7.33637143 56.8487739,5.16637143 46.5674024,5.16637143 C36.3374024,5.16637143 26.6237739,7.595 17.7896596,12.4513714 C16.5487739,13.1227429 14.9987739,12.6577429 14.276031,11.4177429 C13.6046596,10.1777429 14.0696596,8.57637143 15.3096596,7.905 C24.9196596,2.68637143 35.4596596,0 46.5674024,0 C57.5732882,0 67.1824024,2.42774286 77.7232882,7.85274286 C79.0146596,8.525 79.4796596,10.075 78.8074024,11.315 C78.3424024,12.245 77.4646596,12.7613714 76.5346596,12.7613714 C76.121031,12.7613714 75.7074024,12.6577429 75.346031,12.4513714 Z">
- </path>
- <path fill="#32A753" d="M1.10147387,39.4213714 C-0.0871547017,38.595 -0.344897559,36.9927429 0.480588155,35.805 C5.59647387,28.5713714 12.1055882,22.8877429 19.8555882,18.91 C36.0801024,10.54 56.8492167,10.4877429 73.1242167,18.8577429 C80.8742167,22.8363714 87.3851024,28.4677429 92.4992167,35.65 C93.3264739,36.7863714 93.0678453,38.44 91.8801024,39.2663714 C90.6914739,40.0927429 89.0892167,39.835 88.2628453,38.6463714 C83.6128453,32.1363714 77.7228453,27.0213714 70.7478453,23.4563714 C55.9192167,15.8613714 36.9578453,15.8613714 22.1805882,23.5077429 C15.1551024,27.125 9.26421673,32.2913714 4.61421673,38.8013714 C4.20147387,39.525 3.42647387,39.8863714 2.59921673,39.8863714 C2.0828453,39.8863714 1.56647387,39.7313714 1.10147387,39.4213714 Z">
- </path>
- <path fill="#F9BB00" d="M33.0827567,101.473097 C28.5877567,96.9780971 26.1600139,94.0844686 22.6977567,87.8330971 C19.1327567,81.4780971 17.2727567,73.7280971 17.2727567,65.4094686 C17.2727567,50.0644686 30.3963853,37.5617257 46.5163853,37.5617257 C62.6354996,37.5617257 75.7600139,50.0644686 75.7600139,65.4094686 C75.7600139,66.8567257 74.6227567,67.9930971 73.1763853,67.9930971 C71.7300139,67.9930971 70.5927567,66.8567257 70.5927567,65.4094686 C70.5927567,52.9067257 59.7941282,42.7280971 46.5163853,42.7280971 C33.2377567,42.7280971 22.4391282,52.9067257 22.4391282,65.4094686 C22.4391282,72.8494686 24.0927567,79.7217257 27.2441282,85.3017257 C30.5513853,91.2430971 32.8241282,93.7744686 36.8027567,97.8044686 C37.7850139,98.8380971 37.7850139,100.439469 36.8027567,101.473097 C36.2350139,101.989469 35.5627567,102.248097 34.8913853,102.248097 C34.2191282,102.248097 33.5477567,101.989469 33.0827567,101.473097 Z">
- </path>
- <path fill="#E74133" d="M55.9193939,88.0911057 C48.221651,82.8733629 43.6230224,74.3997343 43.6230224,65.4097343 C43.6230224,63.9633629 44.7593939,62.8261057 46.2057653,62.8261057 C47.6530224,62.8261057 48.7893939,63.9633629 48.7893939,65.4097343 C48.7893939,72.6947343 52.5093939,79.5661057 58.8130224,83.8033629 C62.4807653,86.2833629 66.7693939,87.4711057 71.9357653,87.4711057 C73.1757653,87.4711057 75.2421367,87.3161057 77.3093939,86.9547343 C78.7052796,86.6961057 80.0480224,87.6261057 80.3057653,89.0733629 C80.5643939,90.4683629 79.6343939,91.8111057 78.1880224,92.0697343 C75.2421367,92.6383629 72.6593939,92.6897343 71.9357653,92.6897343 C65.7880224,92.6897343 60.3630224,91.1397343 55.9193939,88.0911057 Z">
- </path>
- <path fill="#3E82F1" d="M60.8797482,103.229557 C52.6647482,100.955929 47.2911196,97.9081857 41.6597482,92.3795571 C34.4261196,85.1981857 30.4483767,75.6395571 30.4483767,65.4095571 C30.4483767,57.0395571 37.5783767,50.2195571 46.3611196,50.2195571 C55.1447482,50.2195571 62.2738624,57.0395571 62.2738624,65.4095571 C62.2738624,70.9381857 67.0797482,75.4331857 73.0211196,75.4331857 C78.962491,75.4331857 83.767491,70.9381857 83.767491,65.4095571 C83.767491,45.9309286 66.9761196,30.1218143 46.3097482,30.1218143 C31.6361196,30.1218143 18.2033767,38.2845571 12.157491,50.9431857 C10.142491,55.1281857 9.10974816,60.0359286 9.10974816,65.4095571 C9.10974816,69.4395571 9.47111958,75.7945571 12.5711196,84.0609286 C13.087491,85.4045571 12.4161196,86.9031857 11.0733767,87.3681857 C9.72974816,87.8845571 8.23111958,87.1609286 7.76611958,85.8695571 C5.23474816,79.1018143 3.99474816,72.3845571 3.99474816,65.4095571 C3.99474816,59.2095571 5.18249101,53.5781857 7.50749101,48.6695571 C14.3797482,34.2545571 29.6211196,24.9031857 46.3097482,24.9031857 C69.817491,24.9031857 88.9347482,43.0381857 88.9347482,65.3581857 C88.9347482,73.7281857 81.8047482,80.5481857 73.0211196,80.5481857 C64.237491,80.5481857 57.107491,73.7281857 57.107491,65.3581857 C57.107491,59.8295571 52.3033767,55.3345571 46.3611196,55.3345571 C40.4197482,55.3345571 35.6147482,59.8295571 35.6147482,65.3581857 C35.6147482,74.1931857 39.0238624,82.4595571 45.2761196,88.6595571 C50.1847482,93.5168143 54.8861196,96.2031857 62.1711196,98.2181857 C63.5661196,98.5795571 64.3411196,100.026814 63.9797482,101.369557 C63.7211196,102.558186 62.6361196,103.333186 61.5511196,103.333186 C61.3447482,103.333186 61.0861196,103.280929 60.8797482,103.229557 Z">
- </path>
- </g>
- </defs>
- </svg>
-</iron-iconset-svg>
+<link rel="import" href="cr_fingerprint_icon.html">
<dom-module id="cr-fingerprint-progress-arc">
<template>
diff --git a/chromium/ui/webui/resources/cr_elements/cr_icon_button/cr_icon_button.js b/chromium/ui/webui/resources/cr_elements/cr_icon_button/cr_icon_button.js
index e8ae6000a82..6913401d984 100644
--- a/chromium/ui/webui/resources/cr_elements/cr_icon_button/cr_icon_button.js
+++ b/chromium/ui/webui/resources/cr_elements/cr_icon_button/cr_icon_button.js
@@ -89,7 +89,7 @@ Polymer({
},
listeners: {
- blur: 'hideRipple_',
+ blur: 'onBlur_',
click: 'onClick_',
down: 'showRipple_',
focus: 'showRipple_',
@@ -99,6 +99,17 @@ Polymer({
up: 'hideRipple_',
},
+ /**
+ * It is possible to activate a tab when the space key is pressed down. When
+ * this element has focus, the keyup event for the space key should not
+ * perform a 'click'. |spaceKeyDown_| tracks when a space pressed and handled
+ * by this element. Space keyup will only result in a 'click' when
+ * |spaceKeyDown_| is true. |spaceKeyDown_| is set to false when element loses
+ * focus.
+ * @private {boolean}
+ */
+ spaceKeyDown_: false,
+
/** @private */
hideRipple_() {
if (this.hasRipple()) {
@@ -143,6 +154,12 @@ Polymer({
this.setAttribute('tabindex', value);
},
+ /** @private */
+ onBlur_() {
+ this.spaceKeyDown_ = false;
+ this.hideRipple_();
+ },
+
/**
* @param {!Event} e
* @private
@@ -192,6 +209,8 @@ Polymer({
if (e.key === 'Enter') {
this.click();
+ } else if (e.key === ' ') {
+ this.spaceKeyDown_ = true;
}
},
@@ -205,7 +224,8 @@ Polymer({
e.stopPropagation();
}
- if (e.key === ' ') {
+ if (this.spaceKeyDown_ && e.key === ' ') {
+ this.spaceKeyDown_ = false;
this.click();
}
},
diff --git a/chromium/ui/webui/resources/cr_elements/cr_icons_css.html b/chromium/ui/webui/resources/cr_elements/cr_icons_css.html
index f641fad5e7d..fd1e81e1f9f 100644
--- a/chromium/ui/webui/resources/cr_elements/cr_icons_css.html
+++ b/chromium/ui/webui/resources/cr_elements/cr_icons_css.html
@@ -73,7 +73,6 @@
}
.cr-icon {
- @apply --cr-paper-icon-button-margin;
-webkit-mask-image: var(--cr-icon-image);
-webkit-mask-position: center;
-webkit-mask-repeat: no-repeat;
@@ -81,6 +80,8 @@
background-color: var(--google-grey-refresh-700);
flex-shrink: 0;
height: var(--cr-icon-ripple-size);
+ margin-inline-end: var(--cr-icon-ripple-margin);
+ margin-inline-start: var(--cr-icon-button-margin-start);
user-select: none;
width: var(--cr-icon-ripple-size);
}
diff --git a/chromium/ui/webui/resources/cr_elements/cr_input/cr_input.js b/chromium/ui/webui/resources/cr_elements/cr_input/cr_input.js
index 75601fdf1a3..2454f4ce8b6 100644
--- a/chromium/ui/webui/resources/cr_elements/cr_input/cr_input.js
+++ b/chromium/ui/webui/resources/cr_elements/cr_input/cr_input.js
@@ -75,7 +75,7 @@ Polymer({
errorMessage: {
type: String,
value: '',
- observer: 'errorMessageChanged_',
+ observer: 'onInvalidOrErrorMessageChanged_',
},
/**
@@ -94,6 +94,7 @@ Polymer({
value: false,
notify: true,
reflectToAttribute: true,
+ observer: 'onInvalidOrErrorMessageChanged_',
},
max: {
@@ -230,9 +231,11 @@ Polymer({
* Uses IronA11yAnnouncer to notify screen readers that an error is set.
* @private
*/
- errorMessageChanged_() {
+ onInvalidOrErrorMessageChanged_() {
Polymer.IronA11yAnnouncer.requestAvailability();
- this.fire('iron-announce', {text: this.errorMessage});
+ if (this.invalid) {
+ this.fire('iron-announce', {text: this.errorMessage});
+ }
},
/**
diff --git a/chromium/ui/webui/resources/cr_elements/cr_link_row/cr_link_row.html b/chromium/ui/webui/resources/cr_elements/cr_link_row/cr_link_row.html
index 2c526a7ba9e..e5e41217d31 100644
--- a/chromium/ui/webui/resources/cr_elements/cr_link_row/cr_link_row.html
+++ b/chromium/ui/webui/resources/cr_elements/cr_link_row/cr_link_row.html
@@ -3,12 +3,13 @@
<link rel="import" href="../cr_icon_button/cr_icon_button.html">
<link rel="import" href="../hidden_style_css.html">
<link rel="import" href="../icons.html">
+<link rel="import" href="../shared_style_css.html">
<link rel="import" href="../shared_vars_css.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<dom-module id="cr-link-row">
<template strip-whitespace="">
- <style include="cr-hidden-style">
+ <style include="cr-shared-style cr-hidden-style">
:host {
align-items: center;
align-self: stretch;
@@ -63,20 +64,16 @@
#subLabel {
display: flex;
}
-
- #subLabel {
- @apply --cr-secondary-text;
- }
</style>
<iron-icon id="startIcon" icon="[[startIcon]]" hidden="[[!startIcon]]"
aria-hidden="true">
</iron-icon>
<div id="labelWrapper" hidden="[[hideLabelWrapper_]]">
- <div id="label" class="label" aria-hidden="true">
+ <div id="label" aria-hidden="true">
[[label]]
<slot name="label"></slot>
</div>
- <div id="subLabel" class="secondary label" aria-hidden="true">
+ <div id="subLabel" class="cr-secondary-text" aria-hidden="true">
[[subLabel]]
<slot name="sub-label"></slot>
</div>
diff --git a/chromium/ui/webui/resources/cr_elements/cr_lottie/BUILD.gn b/chromium/ui/webui/resources/cr_elements/cr_lottie/BUILD.gn
new file mode 100644
index 00000000000..d6fac4abfac
--- /dev/null
+++ b/chromium/ui/webui/resources/cr_elements/cr_lottie/BUILD.gn
@@ -0,0 +1,42 @@
+# Copyright 2020 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("//third_party/closure_compiler/compile_js.gni")
+import("//tools/polymer/polymer.gni")
+
+js_type_check("closure_compile") {
+ deps = [ ":cr_lottie" ]
+}
+
+js_library("cr_lottie") {
+ deps = [
+ "//ui/webui/resources/js:assert",
+ "//ui/webui/resources/js:cr",
+ ]
+ externs_list = [ "$externs_path/pending.js" ]
+}
+
+polymer_modulizer("cr_lottie") {
+ js_file = "cr_lottie.js"
+ html_file = "cr_lottie.html"
+ html_type = "dom-module"
+ auto_imports = [ "ui/webui/resources/html/assert.html|assert" ]
+}
+
+js_type_check("closure_compile_module") {
+ is_polymer3 = true
+ deps = [ ":cr_lottie.m" ]
+}
+
+js_library("cr_lottie.m") {
+ sources = [
+ "$root_gen_dir/ui/webui/resources/cr_elements/cr_lottie/cr_lottie.m.js",
+ ]
+ deps = [
+ "//third_party/polymer/v3_0/components-chromium/polymer:polymer_bundled",
+ "//ui/webui/resources/js:assert.m",
+ ]
+ extra_deps = [ ":cr_lottie_module" ]
+ externs_list = [ "$externs_path/pending.js" ]
+}
diff --git a/chromium/ui/webui/resources/cr_elements/chromeos/cr_lottie/cr_lottie.html b/chromium/ui/webui/resources/cr_elements/cr_lottie/cr_lottie.html
index 5cad0578eed..b6510ba45bd 100644
--- a/chromium/ui/webui/resources/cr_elements/chromeos/cr_lottie/cr_lottie.html
+++ b/chromium/ui/webui/resources/cr_elements/cr_lottie/cr_lottie.html
@@ -1,5 +1,5 @@
-<link rel="import" href="../../../html/assert.html">
-<link rel="import" href="../../../html/polymer.html">
+<link rel="import" href="../../html/assert.html">
+<link rel="import" href="../../html/polymer.html">
<dom-module id="cr-lottie">
<template>
diff --git a/chromium/ui/webui/resources/cr_elements/chromeos/cr_lottie/cr_lottie.js b/chromium/ui/webui/resources/cr_elements/cr_lottie/cr_lottie.js
index 2e65ac564dd..7100161c006 100644
--- a/chromium/ui/webui/resources/cr_elements/chromeos/cr_lottie/cr_lottie.js
+++ b/chromium/ui/webui/resources/cr_elements/cr_lottie/cr_lottie.js
@@ -4,7 +4,8 @@
/**
* @fileoverview 'cr-lottie' is a wrapper around the player for lottie
- * animations.
+ * animations. Since the player runs on a worker thread, 'cr-lottie' requires
+ * the document CSP to be set to "worker-src blob: 'self';".
* Fires a 'cr-lottie-initialized' event when the animation was successfully
* initialized.
* Fires a 'cr-lottie-playing' event when the animation starts playing.
diff --git a/chromium/ui/webui/resources/cr_elements/cr_searchable_drop_down/cr_searchable_drop_down.html b/chromium/ui/webui/resources/cr_elements/cr_searchable_drop_down/cr_searchable_drop_down.html
index 6e553b2ba58..0bbba48f58a 100644
--- a/chromium/ui/webui/resources/cr_elements/cr_searchable_drop_down/cr_searchable_drop_down.html
+++ b/chromium/ui/webui/resources/cr_elements/cr_searchable_drop_down/cr_searchable_drop_down.html
@@ -3,6 +3,7 @@
<link rel="import" href="../cr_input/cr_input.html">
<link rel="import" href="../hidden_style_css.html">
<link rel="import" href="../icons.html">
+<link rel="import" href="../shared_style_css.html">
<link rel="import" href="../shared_vars_css.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-dropdown/iron-dropdown.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
@@ -10,7 +11,7 @@
<dom-module id="cr-searchable-drop-down">
<template>
- <style include="cr-hidden-style">
+ <style include="cr-shared-style cr-hidden-style">
:host(:not([error-message-allowed])) cr-input {
--cr-input-error-display: none;
}
@@ -95,7 +96,6 @@
}
#loading-box div {
- @apply --cr-secondary-text;
font-size: 12px;
padding: 0 16px;
}
@@ -150,7 +150,7 @@
<div slot="dropdown-content">
<div id="loading-box" hidden="[[!showLoading]]">
<paper-spinner-lite active></paper-spinner-lite>
- <div>[[loadingMessage]]</div>
+ <div class="cr-secondary-text">[[loadingMessage]]</div>
</div>
<template is="dom-repeat" items="[[items]]"
filter="[[filterItems_(searchTerm_)]]">
diff --git a/chromium/ui/webui/resources/cr_elements/cr_slider/cr_slider.html b/chromium/ui/webui/resources/cr_elements/cr_slider/cr_slider.html
index 67492e433ba..8e19892dbd0 100644
--- a/chromium/ui/webui/resources/cr_elements/cr_slider/cr_slider.html
+++ b/chromium/ui/webui/resources/cr_elements/cr_slider/cr_slider.html
@@ -49,7 +49,12 @@
}
}
- :host([dragging]) {
+ /* TODO(crbug/1068914): For reasons I don't understand we need to set
+ touch-action: none on the container for sliders inside dialogs and on
+ the host for sliders not in dialogs. If we don't, then you can't drag
+ the slider via touch (mouse works fine).*/
+ :host([dragging]),
+ :host([dragging]) > #container {
touch-action: none;
}
diff --git a/chromium/ui/webui/resources/cr_elements/cr_toast/cr_toast.html b/chromium/ui/webui/resources/cr_elements/cr_toast/cr_toast.html
index 8b54718648d..6debee31ed0 100644
--- a/chromium/ui/webui/resources/cr_elements/cr_toast/cr_toast.html
+++ b/chromium/ui/webui/resources/cr_elements/cr_toast/cr_toast.html
@@ -1,5 +1,6 @@
<link rel="import" href="../../html/polymer.html">
+<link rel="import" href="chrome://resources/polymer/v1_0/iron-a11y-announcer/iron-a11y-announcer.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-styles/color.html">
<link rel="import" href="../shared_vars_css.html">
diff --git a/chromium/ui/webui/resources/cr_elements/cr_toast/cr_toast.js b/chromium/ui/webui/resources/cr_elements/cr_toast/cr_toast.js
index 85d797ee6aa..39ce6cc03d4 100644
--- a/chromium/ui/webui/resources/cr_elements/cr_toast/cr_toast.js
+++ b/chromium/ui/webui/resources/cr_elements/cr_toast/cr_toast.js
@@ -47,6 +47,15 @@ Polymer({
},
/**
+ * Announce a11y message
+ * @param {string} text
+ */
+ announceA11yMessage_(text) {
+ Polymer.IronA11yAnnouncer.requestAvailability();
+ this.fire('iron-announce', { text });
+ },
+
+ /**
* Shows the toast and auto-hides after |this.duration| milliseconds has
* passed. If the toast is currently being shown, any preexisting auto-hide
* is cancelled and replaced with a new auto-hide.
@@ -56,9 +65,26 @@ Polymer({
*
* When |duration| is passed in the non-negative number, |this.duration|
* is updated to that value.
+ *
+ * If text is set, replace the toast content with text,
+ * can also optionally announce a11y with text
+ *
* @param {number=} duration
+ * @param {string=} text
+ * @param {boolean=} shouldAnnounceA11y
*/
- show(duration) {
+ show(duration, text, shouldAnnounceA11y) {
+ if (text !== undefined) {
+ this.textContent = '';
+ const span = document.createElement('span');
+ span.textContent = text;
+ this.appendChild(span);
+
+ if (shouldAnnounceA11y) {
+ this.announceA11yMessage_(text);
+ }
+ }
+
// |this.resetAutoHide_| is called whenever |this.duration| or |this.open|
// is changed. If neither is changed, we will still need to reset auto-hide.
let shouldResetAutoHide = true;
diff --git a/chromium/ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.html b/chromium/ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.html
index 57e03e25251..5fdf2813701 100644
--- a/chromium/ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.html
+++ b/chromium/ui/webui/resources/cr_elements/cr_toolbar/cr_toolbar_search_field.html
@@ -28,14 +28,14 @@
--cr-icon-button-fill-color-focus: var(
--cr-toolbar-search-field-input-bg-color,
var(--cr-toolbar-background-color));
- --cr-icon-button-size: 32px;
- margin: 6px;
+ --cr-icon-button-size: var(--cr-toolbar-icon-container-size, 32px);
+ margin: var(--cr-toolbar-icon-margin, 6px);
}
@media (prefers-color-scheme: light) {
cr-icon-button {
--cr-icon-button-fill-color: var(
- --cr-toolbar-search-field-input-color,
+ --cr-toolbar-search-field-input-icon-color,
white);
}
}
@@ -43,7 +43,7 @@
@media (prefers-color-scheme: dark) {
cr-icon-button {
--cr-icon-button-fill-color: var(
- --cr-toolbar-search-field-input-color,
+ --cr-toolbar-search-field-input-icon-color,
var(--google-grey-refresh-500));
}
}
@@ -65,9 +65,9 @@
paper-spinner-lite {
--paper-spinner-color:
- var(--cr-toolbar-search-field-input-color, white);
+ var(--cr-toolbar-search-field-input-icon-color, white);
height: var(--cr-icon-size);
- margin: 0 6px;
+ margin: var(--cr-toolbar-search-field-paper-spinner-margin, 0 6px);
opacity: 0;
padding: 6px;
position: absolute;
@@ -88,8 +88,7 @@
-webkit-font-smoothing: antialiased;
flex: 1;
line-height: 185%;
- margin-inline-end: 2px;
- margin-inline-start: 2px;
+ margin: var(--cr-toolbar-search-field-term-margin, 0 2px);
position: relative;
}
@@ -112,7 +111,7 @@
-webkit-appearance: none;
background: transparent;
border: none;
- color: var(--cr-toolbar-search-field-input-color, white);
+ color: var(--cr-toolbar-search-field-input-text-color, white);
font: inherit;
outline: none;
padding: 0;
@@ -125,6 +124,11 @@
margin: 0;
}
+ :host([narrow]) {
+ border-radius:
+ var(--cr-toolbar-search-field-border-radius, 0);
+ }
+
/** Wide layout. */
:host(:not([narrow])) {
background:
@@ -141,6 +145,8 @@
}
:host(:not([narrow])) #prompt {
+ margin-inline-start:
+ var(--cr-toolbar-search-field-prompt-margin-inline-start);
opacity: var(--cr-toolbar-search-field-prompt-opacity);
}
diff --git a/chromium/ui/webui/resources/cr_elements/icons.html b/chromium/ui/webui/resources/cr_elements/icons.html
index d051c9fbc78..45ea1fcf770 100644
--- a/chromium/ui/webui/resources/cr_elements/icons.html
+++ b/chromium/ui/webui/resources/cr_elements/icons.html
@@ -17,9 +17,19 @@ blurry at 20 px). Please use 20 px icons when available.
<!--
Keep these in sorted order by id="". See also http://goo.gl/Y1OdAq
-->
- <g id="domain"><path d="M2,3 L2,17 L11.8267655,17 L13.7904799,17 L18,17 L18,7 L12,7 L12,3 L2,3 Z M8,13 L10,13 L10,15 L8,15 L8,13 Z M4,13 L6,13 L6,15 L4,15 L4,13 Z M8,9 L10,9 L10,11 L8,11 L8,9 Z M4,9 L6,9 L6,11 L4,11 L4,9 Z M12,9 L16,9 L16,15 L12,15 L12,9 Z M12,11 L14,11 L14,13 L12,13 L12,11 Z M8,5 L10,5 L10,7 L8,7 L8,5 Z M4,5 L6,5 L6,7 L4,7 L4,5 Z"></path></g>
- <g id="kite"><path d="M 10.32 2 L 4.63 8 l 4.92 7.5 l -0.4 0.6 c -0.04 0.07 -0.09 0.12 -0.14 0.18 c -0.24 0.25 -0.56 0.39 -0.9 0.39 c -0.34 0 -0.65 -0.13 -0.9 -0.39 a 1.35 1.35 0 0 1 -0.37 -0.94 a 2.72 2.72 0 0 0 -0.74 -1.88 a 2.44 2.44 0 0 0 -1.78 -0.78 H 4 v 1.38 h 0.33 c 0.34 0 0.65 0.14 0.9 0.39 c 0.24 0.26 0.37 0.59 0.37 0.95 c 0 0.71 0.26 1.38 0.74 1.88 c 0.48 0.5 1.11 0.78 1.78 0.78 c 0.67 0 1.31 -0.28 1.78 -0.78 c 0.11 -0.11 0.2 -0.23 0.28 -0.35 l 1.27 -1.94 L 16 8 L 10.32 2 z"></path></g>
- <g id="menu"><path d="M2 4h16v2H2zM2 9h16v2H2zM2 14h16v2H2z"></path></g>
+ <g id="domain">
+ <path
+ d="M2,3 L2,17 L11.8267655,17 L13.7904799,17 L18,17 L18,7 L12,7 L12,3 L2,3 Z M8,13 L10,13 L10,15 L8,15 L8,13 Z M4,13 L6,13 L6,15 L4,15 L4,13 Z M8,9 L10,9 L10,11 L8,11 L8,9 Z M4,9 L6,9 L6,11 L4,11 L4,9 Z M12,9 L16,9 L16,15 L12,15 L12,9 Z M12,11 L14,11 L14,13 L12,13 L12,11 Z M8,5 L10,5 L10,7 L8,7 L8,5 Z M4,5 L6,5 L6,7 L4,7 L4,5 Z">
+ </path>
+ </g>
+ <g id="kite">
+ <path fill-rule="evenodd" clip-rule="evenodd"
+ d="M4.6327 8.00094L10.3199 2L16 8.00094L10.1848 16.8673C10.0995 16.9873 10.0071 17.1074 9.90047 17.2199C9.42417 17.7225 8.79147 18 8.11611 18C7.44076 18 6.80806 17.7225 6.33175 17.2199C5.85545 16.7173 5.59242 16.0497 5.59242 15.3371C5.59242 14.977 5.46445 14.647 5.22275 14.3919C4.98104 14.1369 4.66825 14.0019 4.32701 14.0019H4V12.6667H4.32701C5.00237 12.6667 5.63507 12.9442 6.11137 13.4468C6.58768 13.9494 6.85071 14.617 6.85071 15.3296C6.85071 15.6896 6.97867 16.0197 7.22038 16.2747C7.46209 16.5298 7.77488 16.6648 8.11611 16.6648C8.45735 16.6648 8.77014 16.5223 9.01185 16.2747C9.02396 16.2601 9.03607 16.246 9.04808 16.2319C9.08541 16.1883 9.12176 16.1458 9.15403 16.0947L9.55213 15.4946L4.6327 8.00094ZM10.3199 13.9371L6.53802 8.17116L10.3199 4.1814L14.0963 8.17103L10.3199 13.9371Z">
+ </path>
+ </g>
+ <g id="menu">
+ <path d="M2 4h16v2H2zM2 9h16v2H2zM2 14h16v2H2z"></path>
+ </g>
</svg>
</iron-iconset-svg>
@@ -32,63 +42,220 @@ blurry at 20 px). Please use 20 px icons when available.
These icons are copied from Polymer's iron-icons and kept in sorted order.
See http://goo.gl/Y1OdAq for instructions on adding additional icons.
-->
- <g id="account-child-invert" viewBox="0 0 48 48"><path d="M24 4c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6 2.69-6 6-6z"></path><path fill="none" d="M0 0h48v48H0V0z"></path><circle fill="none" cx="24" cy="26" r="4"></circle><path d="M24 18c-6.16 0-13 3.12-13 7.23v11.54c0 2.32 2.19 4.33 5.2 5.63 2.32 1 5.12 1.59 7.8 1.59.66 0 1.33-.06 2-.14v-5.2c-.67.08-1.34.14-2 .14-2.63 0-5.39-.57-7.68-1.55.67-2.12 4.34-3.65 7.68-3.65.86 0 1.75.11 2.6.29 2.79.62 5.2 2.15 5.2 4.04v4.47c3.01-1.31 5.2-3.31 5.2-5.63V25.23C37 21.12 30.16 18 24 18zm0 12c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4z"></path></g>
- <g id="add"><path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"/></g>
- <g id="arrow-back"><path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"></path></g>
- <g id="arrow-drop-up"><path d="M7 14l5-5 5 5z"></g>
- <g id="arrow-drop-down"><path d="M7 10l5 5 5-5z"></path></g>
- <g id="arrow-forward"><path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"></path></g>
- <g id="arrow-right"><path d="M10 7l5 5-5 5z"></path></g>
-<if expr="chromeos">
- <g id="bluetooth"><path d="M17.71 7.71L12 2h-1v7.59L6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 11 14.41V22h1l5.71-5.71-4.3-4.29 4.3-4.29zM13 5.83l1.88 1.88L13 9.59V5.83zm1.88 10.46L13 18.17v-3.76l1.88 1.88z"></path></g>
- <g id="camera-alt"><circle cx="12" cy="12" r="3.2"></circle><path d="M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z"></path></g>
-</if>
- <g id="cancel"><path d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z"></path></g>
- <g id="check"><path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path></g>
- <g id="chevron-left"><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"></path></g>
- <g id="chevron-right"><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path></g>
- <g id="clear"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path></g>
- <g id="close"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"></path></g>
- <g id="computer"><path d="M20 18c1.1 0 1.99-.9 1.99-2L22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2H0v2h24v-2h-4zM4 6h16v10H4V6z"></path></g>
- <g id="delete"><path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"></path></g>
- <g id="domain"><path d="M12 7V3H2v18h20V7H12zM6 19H4v-2h2v2zm0-4H4v-2h2v2zm0-4H4V9h2v2zm0-4H4V5h2v2zm4 12H8v-2h2v2zm0-4H8v-2h2v2zm0-4H8V9h2v2zm0-4H8V5h2v2zm10 12h-8v-2h2v-2h-2v-2h2v-2h-2V9h8v10zm-2-8h-2v2h2v-2zm0 4h-2v2h2v-2z"></path></g>
- <g id="error"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"></path></g>
- <g id="error-outline"><path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"></path></g>
- <g id="expand-less"><path d="M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"></path></g>
- <g id="expand-more"><path d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"></path></g>
- <g id="extension"><path d="M20.5 11H19V7c0-1.1-.9-2-2-2h-4V3.5C13 2.12 11.88 1 10.5 1S8 2.12 8 3.5V5H4c-1.1 0-1.99.9-1.99 2v3.8H3.5c1.49 0 2.7 1.21 2.7 2.7s-1.21 2.7-2.7 2.7H2V20c0 1.1.9 2 2 2h3.8v-1.5c0-1.49 1.21-2.7 2.7-2.7 1.49 0 2.7 1.21 2.7 2.7V22H17c1.1 0 2-.9 2-2v-4h1.5c1.38 0 2.5-1.12 2.5-2.5S21.88 11 20.5 11z"></path></g>
- <g id="file-download"><path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"></path></g>
-<if expr="chromeos">
- <g id="folder-filled"><path d="M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"></path></g>
-</if>
- <g id="fullscreen"><path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"></path></g>
- <g id="group"><path d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z"></path></g>
- <g id="help-outline"><path d="M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z"></path></g>
- <g id="info"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"></path></g>
- <g id="info-outline"><path d="M11 17h2v-6h-2v6zm1-15C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zM11 9h2V7h-2v2z"></path></g>
- <g id="insert-drive-file"><path d="M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z"></path></g>
- <g id="location-on"><path d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z"></path></g>
- <g id="mic"><path d="M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z"></path></g>
- <g id="more-vert"><path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"></path></g>
- <g id="open-in-new"><path d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z"></path></g>
- <g id="person"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"></path></g>
- <g id="print"><path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"></path></g>
- <g id="search"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"></path></g>
- <g id="security"><path d="M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4zm0 10.99h7c-.53 4.12-3.28 7.79-7 8.94V12H5V6.3l7-3.11v8.8z"></path></g>
-<if expr="chromeos">
- <g id="sim-card-alert"><path d="M18 2h-8L4.02 8 4 20c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-5 15h-2v-2h2v2zm0-4h-2V8h2v5z"></path></g>
- <g id="sim-lock"><path d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z"></path></g>
- <g id="sms-connect"><path d="M20,2C21.1,2 22,2.9 22,4L22,16C22,17.1 21.1,18 20,18L6,18L2,22L2.01,4C2.01,2.9 2.9,2 4,2L20,2ZM8,8L4,12L8,16L8,13L14,13L14,11L8,11L8,8ZM19.666,7.872L16.038,4.372L16.038,6.997L10,6.997L10,9L16.038,9L16.038,11.372L19.666,7.872Z"></path></g>
-</if>
+ <g id="account-child-invert" viewBox="0 0 48 48">
+ <path d="M24 4c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6 2.69-6 6-6z"></path>
+ <path fill="none" d="M0 0h48v48H0V0z"></path>
+ <circle fill="none" cx="24" cy="26" r="4"></circle>
+ <path
+ d="M24 18c-6.16 0-13 3.12-13 7.23v11.54c0 2.32 2.19 4.33 5.2 5.63 2.32 1 5.12 1.59 7.8 1.59.66 0 1.33-.06 2-.14v-5.2c-.67.08-1.34.14-2 .14-2.63 0-5.39-.57-7.68-1.55.67-2.12 4.34-3.65 7.68-3.65.86 0 1.75.11 2.6.29 2.79.62 5.2 2.15 5.2 4.04v4.47c3.01-1.31 5.2-3.31 5.2-5.63V25.23C37 21.12 30.16 18 24 18zm0 12c-2.21 0-4-1.79-4-4s1.79-4 4-4 4 1.79 4 4-1.79 4-4 4z">
+ </path>
+ </g>
+ <g id="add">
+ <path d="M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z" />
+ </g>
+ <g id="arrow-back">
+ <path d="M20 11H7.83l5.59-5.59L12 4l-8 8 8 8 1.41-1.41L7.83 13H20v-2z"></path>
+ </g>
+ <g id="arrow-drop-up">
+ <path d="M7 14l5-5 5 5z">
+ </g>
+ <g id="arrow-drop-down">
+ <path d="M7 10l5 5 5-5z"></path>
+ </g>
+ <g id="arrow-forward">
+ <path d="M12 4l-1.41 1.41L16.17 11H4v2h12.17l-5.58 5.59L12 20l8-8z"></path>
+ </g>
+ <g id="arrow-right">
+ <path d="M10 7l5 5-5 5z"></path>
+ </g>
+ <if expr="chromeos">
+ <g id="bluetooth">
+ <path
+ d="M17.71 7.71L12 2h-1v7.59L6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 11 14.41V22h1l5.71-5.71-4.3-4.29 4.3-4.29zM13 5.83l1.88 1.88L13 9.59V5.83zm1.88 10.46L13 18.17v-3.76l1.88 1.88z">
+ </path>
+ </g>
+ <g id="camera-alt">
+ <circle cx="12" cy="12" r="3.2"></circle>
+ <path
+ d="M9 2L7.17 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2h-3.17L15 2H9zm3 15c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5z">
+ </path>
+ </g>
+ </if>
+ <g id="cancel">
+ <path
+ d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10 10-4.47 10-10S17.53 2 12 2zm5 13.59L15.59 17 12 13.41 8.41 17 7 15.59 10.59 12 7 8.41 8.41 7 12 10.59 15.59 7 17 8.41 13.41 12 17 15.59z">
+ </path>
+ </g>
+ <g id="check">
+ <path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"></path>
+ </g>
+ <g id="chevron-left">
+ <path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"></path>
+ </g>
+ <g id="chevron-right">
+ <path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path>
+ </g>
+ <g id="clear">
+ <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z">
+ </path>
+ </g>
+ <g id="close">
+ <path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z">
+ </path>
+ </g>
+ <g id="computer">
+ <path
+ d="M20 18c1.1 0 1.99-.9 1.99-2L22 6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2H0v2h24v-2h-4zM4 6h16v10H4V6z">
+ </path>
+ </g>
+ <g id="delete">
+ <path d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"></path>
+ </g>
+ <g id="domain">
+ <path
+ d="M12 7V3H2v18h20V7H12zM6 19H4v-2h2v2zm0-4H4v-2h2v2zm0-4H4V9h2v2zm0-4H4V5h2v2zm4 12H8v-2h2v2zm0-4H8v-2h2v2zm0-4H8V9h2v2zm0-4H8V5h2v2zm10 12h-8v-2h2v-2h-2v-2h2v-2h-2V9h8v10zm-2-8h-2v2h2v-2zm0 4h-2v2h2v-2z">
+ </path>
+ </g>
+ <g id="error">
+ <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z">
+ </path>
+ </g>
+ <g id="error-outline">
+ <path
+ d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z">
+ </path>
+ </g>
+ <g id="expand-less">
+ <path d="M12 8l-6 6 1.41 1.41L12 10.83l4.59 4.58L18 14z"></path>
+ </g>
+ <g id="expand-more">
+ <path d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"></path>
+ </g>
+ <g id="extension">
+ <path
+ d="M20.5 11H19V7c0-1.1-.9-2-2-2h-4V3.5C13 2.12 11.88 1 10.5 1S8 2.12 8 3.5V5H4c-1.1 0-1.99.9-1.99 2v3.8H3.5c1.49 0 2.7 1.21 2.7 2.7s-1.21 2.7-2.7 2.7H2V20c0 1.1.9 2 2 2h3.8v-1.5c0-1.49 1.21-2.7 2.7-2.7 1.49 0 2.7 1.21 2.7 2.7V22H17c1.1 0 2-.9 2-2v-4h1.5c1.38 0 2.5-1.12 2.5-2.5S21.88 11 20.5 11z">
+ </path>
+ </g>
+ <g id="file-download">
+ <path d="M19 9h-4V3H9v6H5l7 7 7-7zM5 18v2h14v-2H5z"></path>
+ </g>
+ <if expr="chromeos">
+ <g id="folder-filled">
+ <path d="M10 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"></path>
+ </g>
+ </if>
+ <g id="fullscreen">
+ <path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"></path>
+ </g>
+ <g id="group">
+ <path
+ d="M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z">
+ </path>
+ </g>
+ <g id="help-outline">
+ <path
+ d="M11 18h2v-2h-2v2zm1-16C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm0-14c-2.21 0-4 1.79-4 4h2c0-1.1.9-2 2-2s2 .9 2 2c0 2-3 1.75-3 5h2c0-2.25 3-2.5 3-5 0-2.21-1.79-4-4-4z">
+ </path>
+ </g>
+ <g id="info">
+ <path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z">
+ </path>
+ </g>
+ <g id="info-outline">
+ <path
+ d="M11 17h2v-6h-2v6zm1-15C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zM11 9h2V7h-2v2z">
+ </path>
+ </g>
+ <g id="insert-drive-file">
+ <path d="M6 2c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6H6zm7 7V3.5L18.5 9H13z">
+ </path>
+ </g>
+ <g id="location-on">
+ <path
+ d="M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5c-1.38 0-2.5-1.12-2.5-2.5s1.12-2.5 2.5-2.5 2.5 1.12 2.5 2.5-1.12 2.5-2.5 2.5z">
+ </path>
+ </g>
+ <g id="mic">
+ <path
+ d="M12 14c1.66 0 2.99-1.34 2.99-3L15 5c0-1.66-1.34-3-3-3S9 3.34 9 5v6c0 1.66 1.34 3 3 3zm5.3-3c0 3-2.54 5.1-5.3 5.1S6.7 14 6.7 11H5c0 3.41 2.72 6.23 6 6.72V21h2v-3.28c3.28-.48 6-3.3 6-6.72h-1.7z">
+ </path>
+ </g>
+ <g id="more-vert">
+ <path
+ d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z">
+ </path>
+ </g>
+ <g id="open-in-new">
+ <path
+ d="M19 19H5V5h7V3H5c-1.11 0-2 .9-2 2v14c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2v-7h-2v7zM14 3v2h3.59l-9.83 9.83 1.41 1.41L19 6.41V10h2V3h-7z">
+ </path>
+ </g>
+ <g id="person">
+ <path
+ d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z">
+ </path>
+ </g>
+ <g id="print">
+ <path
+ d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z">
+ </path>
+ </g>
+ <g id="search">
+ <path
+ d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z">
+ </path>
+ </g>
+ <g id="security">
+ <path
+ d="M12 1L3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5l-9-4zm0 10.99h7c-.53 4.12-3.28 7.79-7 8.94V12H5V6.3l7-3.11v8.8z">
+ </path>
+ </g>
+ <if expr="chromeos">
+ <g id="sim-card-alert">
+ <path
+ d="M18 2h-8L4.02 8 4 20c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-5 15h-2v-2h2v2zm0-4h-2V8h2v5z">
+ </path>
+ </g>
+ <g id="sim-lock">
+ <path
+ d="M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z">
+ </path>
+ </g>
+ <g id="sms-connect">
+ <path
+ d="M20,2C21.1,2 22,2.9 22,4L22,16C22,17.1 21.1,18 20,18L6,18L2,22L2.01,4C2.01,2.9 2.9,2 4,2L20,2ZM8,8L4,12L8,16L8,13L14,13L14,11L8,11L8,8ZM19.666,7.872L16.038,4.372L16.038,6.997L10,6.997L10,9L16.038,9L16.038,11.372L19.666,7.872Z">
+ </path>
+ </g>
+ </if>
<!-- The <g> IDs are exposed as global variables in Vulcanized mode, which
conflicts with the "settings" namespace of MD Settings. Using an "_icon"
suffix prevents the naming conflict. -->
- <g id="settings_icon"><path d="M19.43 12.98c.04-.32.07-.64.07-.98s-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.3-.61-.22l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.23-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98s.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.23.09.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z"></path></g>
- <g id="star"><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"></path></g>
- <g id="supervisor-account" viewBox="0 0 48 48"><path d="M0 0h48v48H0z" fill="none"></path><path d="M33 24c2.76 0 4.98-2.24 4.98-5s-2.22-5-4.98-5c-2.76 0-5 2.24-5 5s2.24 5 5 5zm-15-2c3.31 0 5.98-2.69 5.98-6s-2.67-6-5.98-6c-3.31 0-6 2.69-6 6s2.69 6 6 6zm15 6c-3.67 0-11 1.84-11 5.5V38h22v-4.5c0-3.66-7.33-5.5-11-5.5zm-15-2c-4.67 0-14 2.34-14 7v5h14v-4.5c0-1.7.67-4.67 4.74-6.94C21 26.19 19.31 26 18 26z"></path></g>
- <g id="sync"><path d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z"></path></g>
- <g id="videocam"><path d="M17 10.5V7c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11l-4 4z"></path></g>
- <g id="warning"><path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"></path></g>
+ <g id="settings_icon">
+ <path
+ d="M19.43 12.98c.04-.32.07-.64.07-.98s-.03-.66-.07-.98l2.11-1.65c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.3-.61-.22l-2.49 1c-.52-.4-1.08-.73-1.69-.98l-.38-2.65C14.46 2.18 14.25 2 14 2h-4c-.25 0-.46.18-.49.42l-.38 2.65c-.61.25-1.17.59-1.69.98l-2.49-1c-.23-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64l2.11 1.65c-.04.32-.07.65-.07.98s.03.66.07.98l-2.11 1.65c-.19.15-.24.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1c.52.4 1.08.73 1.69.98l.38 2.65c.03.24.24.42.49.42h4c.25 0 .46-.18.49-.42l.38-2.65c.61-.25 1.17-.59 1.69-.98l2.49 1c.23.09.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64l-2.11-1.65zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z">
+ </path>
+ </g>
+ <g id="star">
+ <path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"></path>
+ </g>
+ <g id="supervisor-account" viewBox="0 0 48 48">
+ <path d="M0 0h48v48H0z" fill="none"></path>
+ <path
+ d="M33 24c2.76 0 4.98-2.24 4.98-5s-2.22-5-4.98-5c-2.76 0-5 2.24-5 5s2.24 5 5 5zm-15-2c3.31 0 5.98-2.69 5.98-6s-2.67-6-5.98-6c-3.31 0-6 2.69-6 6s2.69 6 6 6zm15 6c-3.67 0-11 1.84-11 5.5V38h22v-4.5c0-3.66-7.33-5.5-11-5.5zm-15-2c-4.67 0-14 2.34-14 7v5h14v-4.5c0-1.7.67-4.67 4.74-6.94C21 26.19 19.31 26 18 26z">
+ </path>
+ </g>
+ <g id="sync">
+ <path
+ d="M12 4V1L8 5l4 4V6c3.31 0 6 2.69 6 6 0 1.01-.25 1.97-.7 2.8l1.46 1.46C19.54 15.03 20 13.57 20 12c0-4.42-3.58-8-8-8zm0 14c-3.31 0-6-2.69-6-6 0-1.01.25-1.97.7-2.8L5.24 7.74C4.46 8.97 4 10.43 4 12c0 4.42 3.58 8 8 8v3l4-4-4-4v3z">
+ </path>
+ </g>
+ <g id="videocam">
+ <path d="M17 10.5V7c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11l-4 4z">
+ </path>
+ </g>
+ <g id="warning">
+ <path d="M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z"></path>
+ </g>
</defs>
</svg>
</iron-iconset-svg>
diff --git a/chromium/ui/webui/resources/cr_elements/policy/cr_tooltip_icon.html b/chromium/ui/webui/resources/cr_elements/policy/cr_tooltip_icon.html
index 923f6253f0b..23962b2144f 100644
--- a/chromium/ui/webui/resources/cr_elements/policy/cr_tooltip_icon.html
+++ b/chromium/ui/webui/resources/cr_elements/policy/cr_tooltip_icon.html
@@ -1,21 +1,18 @@
<link rel="import" href="../../html/polymer.html">
<link rel="import" href="../icons.html">
+<link rel="import" href="../shared_style_css.html">
<link rel="import" href="../shared_vars_css.html">
<link rel="import" href="chrome://resources/polymer/v1_0/iron-icon/iron-icon.html">
<link rel="import" href="chrome://resources/polymer/v1_0/paper-tooltip/paper-tooltip.html">
<dom-module id="cr-tooltip-icon">
<template>
- <style>
+ <style include="cr-shared-style">
:host {
display: flex; /* Position independently from the line-height. */
}
- paper-tooltip {
- --paper-tooltip: var(--cr-tooltip);
- }
-
iron-icon {
--iron-icon-width: var(--cr-icon-size);
--iron-icon-height: var(--cr-icon-size);
@@ -23,7 +20,8 @@
</style>
<iron-icon id="indicator" tabindex="0" aria-label$="[[iconAriaLabel]]"
aria-describedby="tooltip" icon="[[iconClass]]"></iron-icon>
- <paper-tooltip id="tooltip" for="indicator" position="[[tooltipPosition]]"
+ <paper-tooltip id="tooltip"
+ for="indicator" position="[[tooltipPosition]]"
fit-to-visible-bounds part="tooltip">
[[tooltipText]]
</paper-tooltip>
diff --git a/chromium/ui/webui/resources/cr_elements/shared_style_css.html b/chromium/ui/webui/resources/cr_elements/shared_style_css.html
index 469c98149e4..e5f836283c7 100644
--- a/chromium/ui/webui/resources/cr_elements/shared_style_css.html
+++ b/chromium/ui/webui/resources/cr_elements/shared_style_css.html
@@ -63,6 +63,17 @@
cursor: pointer;
}
+ .cr-centered-card-container {
+ box-sizing: border-box;
+ display: block;
+ height: inherit;
+ margin: 0 auto;
+ max-width: var(--cr-centered-card-max-width);
+ min-width: 550px;
+ position: relative;
+ width: calc(100% * var(--cr-centered-card-width-percentage));
+ }
+
.cr-container-shadow {
box-shadow: inset 0 5px 6px -3px rgba(0, 0, 0, .4);
height: var(--cr-container-shadow-height);
@@ -89,7 +100,7 @@
opacity: var(--cr-container-shadow-max-opacity);
}
- .cr-section {
+ .cr-row {
align-items: center;
border-top: var(--cr-separator-line);
display: flex;
@@ -97,14 +108,47 @@
padding: 0 var(--cr-section-padding);
}
+ .cr-row.first,
+ .cr-row.continuation {
+ border-top: none;
+ }
+
+ .cr-row-gap {
+ padding-inline-start: 16px;
+ }
+
+ .cr-button-gap {
+ margin-inline-start: 8px;
+ }
+
+ paper-tooltip {
+ --paper-tooltip: {
+ font-size: 92.31%; /* Effectively 12px if the host default is 13px. */
+ font-weight: 500;
+ max-width: 330px;
+ min-width: var(--paper-tooltip-min-width, 200px);
+ padding: var(--paper-tooltip-padding, 10px 8px);
+ }
+ }
+
/* Typography */
+ .cr-padded-text {
+ padding-block-end: var(--cr-section-vertical-padding);
+ padding-block-start: var(--cr-section-vertical-padding);
+ }
+
.cr-title-text {
color: var(--cr-title-text-color);
font-size: 107.6923%; /* Go to 14px from 13px. */
font-weight: 500;
}
+ .cr-secondary-text {
+ color: var(--cr-secondary-text-color);
+ font-weight: 400;
+ }
+
.cr-form-field-label {
color: var(--cr-form-field-label-color);
display: block;
diff --git a/chromium/ui/webui/resources/cr_elements/shared_vars_css.html b/chromium/ui/webui/resources/cr_elements/shared_vars_css.html
index 4c9126cc34a..baf7015a329 100644
--- a/chromium/ui/webui/resources/cr_elements/shared_vars_css.html
+++ b/chromium/ui/webui/resources/cr_elements/shared_vars_css.html
@@ -129,19 +129,9 @@
--cr-icon-button-margin-start: 16px;
+ /* Shift button so ripple overlaps the end of the row. */
--cr-icon-ripple-margin: calc(var(--cr-icon-ripple-padding) * -1);
- --cr-paper-icon-button-margin: {
- /* Shift button so ripple overlaps the end of the row. */
- margin-inline-end: var(--cr-icon-ripple-margin);
- margin-inline-start: var(--cr-icon-button-margin-start);
- }
-
- --cr-secondary-text: {
- color: var(--cr-secondary-text-color);
- font-weight: 400;
- }
-
/* TODO (johntlee): re-implement with paddings instead; */
/* These are used for row items such as radio buttons, check boxes, list
* items etc. */
@@ -155,7 +145,7 @@
--cr-section-indent-padding: calc(
var(--cr-section-padding) + var(--cr-section-indent-width));
- /* TODO(crbug.com/973674): Do not use this mixin. Use the class cr-section
+ /* TODO(crbug.com/973674): Do not use this mixin. Use the class cr-row
* from shared_style_css.html instead. */
--cr-section: {
align-items: center;
@@ -169,24 +159,6 @@
--cr-centered-card-max-width: 680px;
--cr-centered-card-width-percentage: 0.96;
- --cr-centered-card-container: {
- box-sizing: border-box;
- display: block;
- height: inherit;
- margin: 0 auto;
- max-width: var(--cr-centered-card-max-width);
- min-width: 550px;
- position: relative;
- width: calc(100% * var(--cr-centered-card-width-percentage));
- }
-
- --cr-tooltip: {
- font-size: 92.31%; /* Effectively 12px if the host default is 13px. */
- font-weight: 500;
- max-width: 330px;
- min-width: 200px;
- padding: 10px 8px;
- }
--cr-hairline: 1px solid rgba(var(--cr-hairline-rgb), .14);
diff --git a/chromium/ui/webui/resources/cr_elements_images.grdp b/chromium/ui/webui/resources/cr_elements_images.grdp
index 38c77c69646..80853878b83 100644
--- a/chromium/ui/webui/resources/cr_elements_images.grdp
+++ b/chromium/ui/webui/resources/cr_elements_images.grdp
@@ -9,6 +9,8 @@
file="images/arrow_down.svg" type="BINDATA" compress="gzip" />
<include name="IDR_WEBUI_IMAGES_ARROW_RIGHT"
file="images/arrow_right.svg" type="BINDATA" compress="gzip" />
+ <include name="IDR_WEBUI_IMAGES_BUSINESS" file="images/business.svg"
+ type="BINDATA" compress="gzip" />
<include name="IDR_WEBUI_IMAGES_DARK_ARROW_DOWN"
file="images/dark/arrow_down.svg" type="BINDATA" compress="gzip" />
<include name="IDR_WEBUI_IMAGES_DARK_ICON_SEARCH"
diff --git a/chromium/ui/webui/resources/cr_elements_resources.grdp b/chromium/ui/webui/resources/cr_elements_resources.grdp
index 3cb801ba69a..8412a9dd4ba 100644
--- a/chromium/ui/webui/resources/cr_elements_resources.grdp
+++ b/chromium/ui/webui/resources/cr_elements_resources.grdp
@@ -37,6 +37,10 @@
file="cr_elements/cr_container_shadow_behavior.js"
type="chrome_html"
compress="gzip" />
+ <structure name="IDR_CR_ELEMENTS_CR_FINGERPRINT_ICON_HTML"
+ file="cr_elements/cr_fingerprint/cr_fingerprint_icon.html"
+ type="chrome_html"
+ compress="gzip" />
<structure name="IDR_CR_ELEMENTS_CR_FINGERPRINT_PROGRESS_ARC_HTML"
file="cr_elements/cr_fingerprint/cr_fingerprint_progress_arc.html"
type="chrome_html"
@@ -219,15 +223,15 @@
file="cr_elements/chromeos/cr_picture/icons.html"
type="chrome_html"
compress="gzip" />
- <structure name="IDR_CR_ELEMENTS_CHROMEOS_CR_LOTTIE_HTML"
- file="cr_elements/chromeos/cr_lottie/cr_lottie.html"
- type="chrome_html"
- compress="gzip" />
- <structure name="IDR_CR_ELEMENTS_CHROMEOS_CR_LOTTIE_JS"
- file="cr_elements/chromeos/cr_lottie/cr_lottie.js"
- type="chrome_html"
- compress="gzip" />
</if>
+ <structure name="IDR_CR_ELEMENTS_CR_LOTTIE_HTML"
+ file="cr_elements/cr_lottie/cr_lottie.html"
+ type="chrome_html"
+ compress="gzip" />
+ <structure name="IDR_CR_ELEMENTS_CR_LOTTIE_JS"
+ file="cr_elements/cr_lottie/cr_lottie.js"
+ type="chrome_html"
+ compress="gzip" />
<structure name="IDR_CR_ELEMENTS_CR_POLICY_INDICATOR_HTML"
file="cr_elements/policy/cr_policy_indicator.html"
type="chrome_html"
diff --git a/chromium/ui/webui/resources/cr_elements_resources_v3.grdp b/chromium/ui/webui/resources/cr_elements_resources_v3.grdp
index d5cf237c1b0..21351ddf893 100644
--- a/chromium/ui/webui/resources/cr_elements_resources_v3.grdp
+++ b/chromium/ui/webui/resources/cr_elements_resources_v3.grdp
@@ -36,6 +36,11 @@
use_base_dir="false"
type="BINDATA"
compress="gzip" />
+ <include name="IDR_CR_ELEMENTS_CR_FINGERPRINT_ICON_M_JS"
+ file="${root_gen_dir}/ui/webui/resources/cr_elements/cr_fingerprint/cr_fingerprint_icon.m.js"
+ use_base_dir="false"
+ type="BINDATA"
+ compress="gzip" />
<include name="IDR_CR_ELEMENTS_CR_FINGERPRINT_PROGRESS_ARC_M_JS"
file="${root_gen_dir}/ui/webui/resources/cr_elements/cr_fingerprint/cr_fingerprint_progress_arc.m.js"
use_base_dir="false"
@@ -248,4 +253,9 @@
type="BINDATA"
compress="gzip" />
</if>
+ <include name="IDR_CR_ELEMENTS_LOTTIE_M_JS"
+ file="${root_gen_dir}/ui/webui/resources/cr_elements/cr_lottie/cr_lottie.m.js"
+ use_base_dir="false"
+ type="BINDATA"
+ compress="gzip" />
</grit-part>
diff --git a/chromium/ui/webui/resources/css/cros_colors.json5 b/chromium/ui/webui/resources/css/cros_colors.json5
index ece110bfdd6..1d723c51775 100644
--- a/chromium/ui/webui/resources/css/cros_colors.json5
+++ b/chromium/ui/webui/resources/css/cros_colors.json5
@@ -5,13 +5,13 @@
/*
* Chrome OS semantic colors.
*
- * All colors used in Chrome OS WebUIs and System Web Apps should be
- * semantically represented here.
+ * Colors that are used across all Chrome OS WebUIS and System Web Apps should
+ * be semantically represented here.
*/
{
colors: {
/*
- * Recommended colors.
+ * Core colors.
*/
cros_default_text_color: {
light: "$google_grey_900",
@@ -27,11 +27,19 @@
dark: "$google_grey_900",
},
- cros_default_button_color: {
+ cros_default_icon_color_primary: {
+ light: "$google_grey_700",
+ dark: "$google_grey_200",
+ },
+
+ cros_default_icon_color_prominent: {
light: "$google_blue_600",
dark: "$google_blue_300",
},
+ /*
+ * Component colors.
+ */
cros_default_toolbar_bg_color: "#ffffff",
cros_default_toolbar_search_bg_color: "$google_grey_100",
@@ -39,13 +47,13 @@
cros_menu_button_bg_color_hover: "$google_grey_100",
cros_menu_button_outline_color_focused: "$google_blue_600",
- cros_toggle_color: "$cros_default_button_color",
+ cros_toggle_color: "$cros_default_icon_color_prominent",
cros_toggle_bg_color_inactive: "$google_grey_400",
cros_toggle_button_color_inactive: "#ffffff",
cros_toggle_ripple_color: "rgba($cros_toggle_color_rgb, .2)",
cros_toggle_ripple_color_inactive: "rgba($google_grey_600_rgb, .15)",
- cros_radio_button_color: "$cros_default_button_color",
+ cros_radio_button_color: "$cros_default_icon_color_prominent",
cros_radio_button_ripple_color: "rgba($cros_radio_button_color_rgb, .2)",
cros_radio_button_color_unchecked: "$google_grey_700",
cros_radio_button_ripple_color_unchecked: "rgba($google_grey_600_rgb, .15)",
@@ -54,9 +62,9 @@
cros_link_color: "$google_blue_700",
-
/* button-primary */
- cros_default_button_background_color_primary: "$cros_default_button_color",
+ cros_default_button_background_color_primary:
+ "$cros_default_icon_color_prominent",
cros_default_button_label_color_primary: {
light: "$google_grey_200",
dark: "$google_grey_900",
@@ -77,14 +85,15 @@
},
/* button-secondary */
- cros_default_button_label_color_secondary: "$cros_default_button_color",
+ cros_default_button_label_color_secondary:
+ "$cros_default_icon_color_prominent",
cros_default_button_stroke_color_secondary: {
light: "$google_grey_300",
dark: "$google_grey_700",
},
/* button-secondary:hover */
cros_default_button_background_color_secondary_hover:
- "rgba($cros_default_button_color_rgb, 0.04)",
+ "rgba($cros_default_icon_color_prominent_rgb, 0.04)",
/* button-secondary[disabled] */
cros_default_button_label_color_secondary_disabled: {
light: "$google_grey_600",
@@ -95,6 +104,39 @@
dark: "$google_grey_800",
},
+ /* textfield */
+ default_textfield_background_color: {
+ light: "$google_grey_100",
+ dark: "rgba(0, 0, 0, 0.3)",
+ },
+ default_texfield_label_color: {
+ light: "$google_grey_700",
+ dark: "rgba(255, 255, 255, 0.6)",
+ },
+ default_texfield_input_color: {
+ light: "$google_grey_900",
+ dark: "rgba(255, 255, 255, 0.87)",
+ },
+ /* textfield:focus */
+ default_texfield_label_color_focus: "$cros_default_icon_color_prominent",
+ /* textfield[error] */
+ default_texfield_label_color_error: {
+ light: "$google_red_600",
+ dark: "$google_red_300",
+ },
+ /* textfield[disabled] */
+ default_textfield_background_color_disabled: {
+ light: "rgba($google_grey_100_rgb, 0.38)",
+ dark: "rgba(0, 0, 0, 0.11)",
+ },
+ default_texfield_label_color_disabled: {
+ light: "rgba($google_grey_700_rgb, 0.38)",
+ dark: "rgba(0, 0, 0, 0.23)",
+ },
+ default_texfield_input_color_disabled: {
+ light: "rgba($google_grey_900_rgb, 0.38)",
+ dark: "rgba(255, 255, 255, 0.33)",
+ },
/*
* One_offs.
diff --git a/chromium/ui/webui/resources/js/cr/ui/tree.js b/chromium/ui/webui/resources/js/cr/ui/tree.js
index 758ed4cd271..87e16056481 100644
--- a/chromium/ui/webui/resources/js/cr/ui/tree.js
+++ b/chromium/ui/webui/resources/js/cr/ui/tree.js
@@ -294,12 +294,31 @@ cr.define('cr.ui', function() {
const treeItemProto = (function() {
const treeItem = document.createElement('div');
treeItem.className = 'tree-item';
- treeItem.innerHTML = '<div class="tree-row">' +
+ const htmlString = '<div class="tree-row">' +
'<span class="expand-icon"></span>' +
'<span class="tree-label-icon"></span>' +
'<span class="tree-label"></span>' +
'</div>' +
'<div class="tree-children" role="group"></div>';
+
+ if (window.trustedTypes) {
+ /**
+ * This is used to create TrustedHTML.
+ *
+ * @type {TrustedTypePolicy}
+ */
+ const staticHTMLPolicy =
+ trustedTypes.createPolicy('cr-ui-tree-js-static', {
+ createHTML: () => {
+ return htmlString;
+ },
+ });
+
+ treeItem.innerHTML = staticHTMLPolicy.createHTML('');
+ } else {
+ treeItem.innerHTML = htmlString;
+ }
+
treeItem.setAttribute('role', 'treeitem');
return treeItem;
})();
diff --git a/chromium/ui/webui/resources/webui_resources.grd b/chromium/ui/webui/resources/webui_resources.grd
index 2fc7d86994e..4ef5362273c 100644
--- a/chromium/ui/webui/resources/webui_resources.grd
+++ b/chromium/ui/webui/resources/webui_resources.grd
@@ -452,7 +452,7 @@ without changes to the corresponding grd file. -->
compress="gzip" />
</if>
- <if expr="chromeos">
+ <if expr="not is_android and not is_ios">
<structure name="IDR_LOTTIE_LOTTIE_WORKER_MIN_JS"
file="../../../third_party/lottie/lottie_worker.min.js"
type="chrome_html"
diff --git a/chromium/ui/webui/webui_allowlist.cc b/chromium/ui/webui/webui_allowlist.cc
new file mode 100644
index 00000000000..62b5ca69231
--- /dev/null
+++ b/chromium/ui/webui/webui_allowlist.cc
@@ -0,0 +1,110 @@
+// Copyright 2020 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 "ui/webui/webui_allowlist.h"
+
+#include <memory>
+
+#include "content/public/browser/browser_context.h"
+#include "content/public/common/url_constants.h"
+#include "ui/webui/webui_allowlist_provider.h"
+#include "url/gurl.h"
+
+const char kWebUIAllowlistKeyName[] = "WebUIAllowlist";
+
+namespace {
+
+class AllowlistRuleIterator : public content_settings::RuleIterator {
+ using MapType = std::map<url::Origin, ContentSetting>;
+
+ public:
+ explicit AllowlistRuleIterator(const MapType& map)
+ : it_(map.cbegin()), end_(map.cend()) {}
+ AllowlistRuleIterator(const AllowlistRuleIterator&) = delete;
+ void operator=(const AllowlistRuleIterator&) = delete;
+ ~AllowlistRuleIterator() override = default;
+
+ bool HasNext() const override { return it_ != end_; }
+
+ content_settings::Rule Next() override {
+ const auto& origin = it_->first;
+ const auto& setting = it_->second;
+ it_++;
+ return content_settings::Rule(
+ ContentSettingsPattern::FromURLNoWildcard(origin.GetURL()),
+ ContentSettingsPattern::Wildcard(), base::Value(setting), base::Time(),
+ content_settings::SessionModel::Durable);
+ }
+
+ private:
+ MapType::const_iterator it_;
+ const MapType::const_iterator end_;
+};
+
+} // namespace
+
+// static
+WebUIAllowlist* WebUIAllowlist::GetOrCreate(
+ content::BrowserContext* browser_context) {
+ if (!browser_context->GetUserData(kWebUIAllowlistKeyName)) {
+ browser_context->SetUserData(kWebUIAllowlistKeyName,
+ std::make_unique<WebUIAllowlist>());
+ }
+ return static_cast<WebUIAllowlist*>(
+ browser_context->GetUserData(kWebUIAllowlistKeyName));
+}
+
+WebUIAllowlist::WebUIAllowlist() = default;
+
+WebUIAllowlist::~WebUIAllowlist() = default;
+
+void WebUIAllowlist::RegisterAutoGrantedPermission(const url::Origin& origin,
+ ContentSettingsType type,
+ ContentSetting setting) {
+ // It doesn't make sense to grant a default content setting.
+ DCHECK_NE(CONTENT_SETTING_DEFAULT, setting);
+
+ // We only support auto-granting permissions to chrome://,
+ // chrome-untrusted://, and devtools:// schemes.
+ DCHECK(origin.scheme() == content::kChromeUIScheme ||
+ origin.scheme() == content::kChromeUIUntrustedScheme ||
+ origin.scheme() == content::kChromeDevToolsScheme);
+
+ // If the same permission is already registered, do nothing. We don't want to
+ // notify the provider of ContentSettingChange when it is unnecessary.
+ if (permissions_[type][origin] == setting)
+ return;
+
+ permissions_[type][origin] = setting;
+
+ // Notify the provider. |provider_| can be nullptr if
+ // HostContentSettingsRegistry is shutting down i.e. when Chrome shuts down.
+ if (provider_) {
+ auto primary_pattern =
+ ContentSettingsPattern::FromURLNoWildcard(origin.GetURL());
+ auto secondary_pattern = ContentSettingsPattern::Wildcard();
+ provider_->NotifyContentSettingChange(primary_pattern, secondary_pattern,
+ type);
+ }
+}
+
+void WebUIAllowlist::SetWebUIAllowlistProvider(
+ WebUIAllowlistProvider* provider) {
+ provider_ = provider;
+}
+
+void WebUIAllowlist::ResetWebUIAllowlistProvider() {
+ provider_ = nullptr;
+}
+
+std::unique_ptr<content_settings::RuleIterator> WebUIAllowlist::GetRuleIterator(
+ ContentSettingsType content_type) const {
+ const auto& type_to_origin_rules = permissions_.find(content_type);
+ if (type_to_origin_rules != permissions_.cend()) {
+ return std::make_unique<AllowlistRuleIterator>(
+ type_to_origin_rules->second);
+ }
+
+ return nullptr;
+}
diff --git a/chromium/ui/webui/webui_allowlist.h b/chromium/ui/webui/webui_allowlist.h
new file mode 100644
index 00000000000..91aec49307d
--- /dev/null
+++ b/chromium/ui/webui/webui_allowlist.h
@@ -0,0 +1,52 @@
+// Copyright 2020 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 UI_WEBUI_WEBUI_ALLOWLIST_H_
+#define UI_WEBUI_WEBUI_ALLOWLIST_H_
+
+#include <map>
+
+#include "base/supports_user_data.h"
+#include "components/content_settings/core/browser/content_settings_rule.h"
+#include "components/content_settings/core/common/content_settings.h"
+#include "components/content_settings/core/common/content_settings_types.h"
+#include "url/origin.h"
+
+namespace content {
+class BrowserContext;
+}
+class WebUIAllowlistProvider;
+
+// This class is the underlying storage for WebUIAllowlistProvider, it stores a
+// list of origins and permissions to be auto-granted to WebUIs. This class is
+// created before HostContentSettingsMap is registered and has the same lifetime
+// as the profile it's attached to. It outlives WebUIAllowlistProvider.
+class WebUIAllowlist : public base::SupportsUserData::Data {
+ public:
+ static WebUIAllowlist* GetOrCreate(content::BrowserContext* browser_context);
+
+ WebUIAllowlist();
+ WebUIAllowlist(const WebUIAllowlist&) = delete;
+ void operator=(const WebUIAllowlist&) = delete;
+ ~WebUIAllowlist() override;
+
+ // Register auto-granted |type| permission for |origin|.
+ void RegisterAutoGrantedPermission(
+ const url::Origin& origin,
+ ContentSettingsType type,
+ ContentSetting setting = CONTENT_SETTING_ALLOW);
+
+ std::unique_ptr<content_settings::RuleIterator> GetRuleIterator(
+ ContentSettingsType content_type) const;
+
+ void SetWebUIAllowlistProvider(WebUIAllowlistProvider* provider);
+ void ResetWebUIAllowlistProvider();
+
+ private:
+ std::map<ContentSettingsType, std::map<url::Origin, ContentSetting>>
+ permissions_;
+ WebUIAllowlistProvider* provider_ = nullptr;
+};
+
+#endif // UI_WEBUI_WEBUI_ALLOWLIST_H_
diff --git a/chromium/ui/webui/webui_allowlist_provider.cc b/chromium/ui/webui/webui_allowlist_provider.cc
new file mode 100644
index 00000000000..4d057b7cd6e
--- /dev/null
+++ b/chromium/ui/webui/webui_allowlist_provider.cc
@@ -0,0 +1,57 @@
+// Copyright 2020 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 "ui/webui/webui_allowlist_provider.h"
+
+#include "components/content_settings/core/common/content_settings_pattern.h"
+#include "ui/webui/webui_allowlist.h"
+
+WebUIAllowlistProvider::WebUIAllowlistProvider(WebUIAllowlist* allowlist)
+ : allowlist_(allowlist) {
+ DCHECK(allowlist_);
+ allowlist_->SetWebUIAllowlistProvider(this);
+}
+
+WebUIAllowlistProvider::~WebUIAllowlistProvider() = default;
+
+std::unique_ptr<content_settings::RuleIterator>
+WebUIAllowlistProvider::GetRuleIterator(
+ ContentSettingsType content_type,
+ const content_settings::ResourceIdentifier& /*resource_identifier*/,
+ bool incognito) const {
+ if (!allowlist_)
+ return nullptr;
+
+ return allowlist_->GetRuleIterator(content_type);
+}
+
+void WebUIAllowlistProvider::NotifyContentSettingChange(
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
+ ContentSettingsType content_type) {
+ NotifyObservers(primary_pattern, secondary_pattern, content_type,
+ /*resource_identifier*/ std::string());
+}
+
+bool WebUIAllowlistProvider::SetWebsiteSetting(
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
+ ContentSettingsType content_type,
+ const content_settings::ResourceIdentifier& /*resource_identifier*/,
+ std::unique_ptr<base::Value>&& value,
+ const content_settings::ContentSettingConstraints& constraints) {
+ // WebUIAllowlistProvider doesn't support settings Website settings.
+ return false;
+}
+
+void WebUIAllowlistProvider::ClearAllContentSettingsRules(
+ ContentSettingsType content_type) {
+ // WebUIAllowlistProvider doesn't support changing content settings directly.
+}
+
+void WebUIAllowlistProvider::ShutdownOnUIThread() {
+ RemoveAllObservers();
+ allowlist_->ResetWebUIAllowlistProvider();
+ allowlist_ = nullptr;
+}
diff --git a/chromium/ui/webui/webui_allowlist_provider.h b/chromium/ui/webui/webui_allowlist_provider.h
new file mode 100644
index 00000000000..0c95a3c7bcb
--- /dev/null
+++ b/chromium/ui/webui/webui_allowlist_provider.h
@@ -0,0 +1,48 @@
+// Copyright 2020 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 UI_WEBUI_WEBUI_ALLOWLIST_PROVIDER_H_
+#define UI_WEBUI_WEBUI_ALLOWLIST_PROVIDER_H_
+
+#include "components/content_settings/core/browser/content_settings_observable_provider.h"
+#include "components/content_settings/core/common/content_settings.h"
+#include "ui/webui/webui_allowlist.h"
+
+class ContentSettingsPattern;
+
+// A provider that supplies HostContentSettingsMap with a list of auto-granted
+// permissions from the underlying WebUIAllowlist.
+class WebUIAllowlistProvider : public content_settings::ObservableProvider {
+ public:
+ // Note, |allowlist| must outlive this instance.
+ explicit WebUIAllowlistProvider(WebUIAllowlist* allowlist);
+ WebUIAllowlistProvider(const WebUIAllowlistProvider&) = delete;
+ void operator=(const WebUIAllowlistProvider&) = delete;
+ ~WebUIAllowlistProvider() override;
+
+ void NotifyContentSettingChange(
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
+ ContentSettingsType content_type);
+
+ // content_settings::ObservableProvider:
+ std::unique_ptr<content_settings::RuleIterator> GetRuleIterator(
+ ContentSettingsType content_type,
+ const content_settings::ResourceIdentifier& /*resource_identifier*/,
+ bool incognito) const override;
+ void ShutdownOnUIThread() override;
+ bool SetWebsiteSetting(
+ const ContentSettingsPattern& primary_pattern,
+ const ContentSettingsPattern& secondary_pattern,
+ ContentSettingsType content_type,
+ const content_settings::ResourceIdentifier& /*resource_identifier*/,
+ std::unique_ptr<base::Value>&& value,
+ const content_settings::ContentSettingConstraints& constraints) override;
+ void ClearAllContentSettingsRules(ContentSettingsType content_type) override;
+
+ private:
+ WebUIAllowlist* allowlist_;
+};
+
+#endif // UI_WEBUI_WEBUI_ALLOWLIST_PROVIDER_H_
diff --git a/chromium/ui/wm/BUILD.gn b/chromium/ui/wm/BUILD.gn
index a9cac9b8f36..2281a7eaf84 100644
--- a/chromium/ui/wm/BUILD.gn
+++ b/chromium/ui/wm/BUILD.gn
@@ -70,8 +70,8 @@ jumbo_component("wm") {
"//ui/aura",
"//ui/base",
"//ui/base/cursor",
+ "//ui/base/cursor/mojom:cursor_type",
"//ui/base/ime",
- "//ui/base/mojom:cursor_type",
"//ui/compositor",
"//ui/compositor_extra",
"//ui/display",
@@ -86,11 +86,6 @@ jumbo_component("wm") {
"//ui/wm/public",
]
- if (use_x11) {
- configs += [ "//build/config/linux:x11" ]
- deps += [ "//ui/events/devices/x11" ]
- }
-
if (is_chromeos) {
sources += [
"core/ime_util_chromeos.cc",
@@ -150,8 +145,8 @@ test("wm_unittests") {
"//ui/aura:test_support",
"//ui/base:test_support",
"//ui/base/cursor",
+ "//ui/base/cursor/mojom:cursor_type",
"//ui/base/ime",
- "//ui/base/mojom:cursor_type",
"//ui/compositor:test_support",
"//ui/compositor_extra",
"//ui/events:test_support",
diff --git a/chromium/ui/wm/core/capture_controller_unittest.cc b/chromium/ui/wm/core/capture_controller_unittest.cc
index 5f13d96ade9..c515aa38d9a 100644
--- a/chromium/ui/wm/core/capture_controller_unittest.cc
+++ b/chromium/ui/wm/core/capture_controller_unittest.cc
@@ -6,7 +6,6 @@
#include <utility>
-#include "base/logging.h"
#include "base/macros.h"
#include "ui/aura/client/capture_delegate.h"
#include "ui/aura/env.h"
diff --git a/chromium/ui/wm/core/compound_event_filter.cc b/chromium/ui/wm/core/compound_event_filter.cc
index 11f1e99817a..62906aedc3e 100644
--- a/chromium/ui/wm/core/compound_event_filter.cc
+++ b/chromium/ui/wm/core/compound_event_filter.cc
@@ -4,7 +4,8 @@
#include "ui/wm/core/compound_event_filter.h"
-#include "base/logging.h"
+#include "base/check.h"
+#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/drag_drop_client.h"
@@ -12,8 +13,8 @@
#include "ui/aura/window.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_event_dispatcher.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/base/hit_test.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
#include "ui/events/event.h"
#include "ui/wm/public/activation_client.h"
@@ -157,12 +158,20 @@ void CompoundEventFilter::SetCursorVisibilityOnEvent(aura::Window* target,
void CompoundEventFilter::SetMouseEventsEnableStateOnEvent(aura::Window* target,
ui::Event* event,
bool enable) {
+ TRACE_EVENT2("ui,input",
+ "CompoundEventFilter::SetMouseEventsEnableStateOnEvent",
+ "event_flags", event->flags(), "enable", enable);
if (event->flags() & ui::EF_IS_SYNTHESIZED)
return;
aura::client::CursorClient* client =
aura::client::GetCursorClient(target->GetRootWindow());
- if (!client)
+ if (!client) {
+ TRACE_EVENT_INSTANT0(
+ "ui,input",
+ "CompoundEventFilter::SetMouseEventsEnableStateOnEvent - No Client",
+ TRACE_EVENT_SCOPE_THREAD);
return;
+ }
if (enable)
client->EnableMouseEvents();
@@ -184,6 +193,8 @@ void CompoundEventFilter::OnKeyEvent(ui::KeyEvent* event) {
}
void CompoundEventFilter::OnMouseEvent(ui::MouseEvent* event) {
+ TRACE_EVENT2("ui,input", "CompoundEventFilter::OnMouseEvent", "event_type",
+ event->type(), "event_flags", event->flags());
aura::Window* window = static_cast<aura::Window*>(event->target());
// We must always update the cursor, otherwise the cursor can get stuck if an
@@ -211,6 +222,8 @@ void CompoundEventFilter::OnScrollEvent(ui::ScrollEvent* event) {
}
void CompoundEventFilter::OnTouchEvent(ui::TouchEvent* event) {
+ TRACE_EVENT2("ui,input", "CompoundEventFilter::OnTouchEvent", "event_type",
+ event->type(), "event_handled", event->handled());
FilterTouchEvent(event);
if (!event->handled() && event->type() == ui::ET_TOUCH_PRESSED &&
ShouldHideCursorOnTouch(*event)) {
diff --git a/chromium/ui/wm/core/compound_event_filter_unittest.cc b/chromium/ui/wm/core/compound_event_filter_unittest.cc
index 8bf3070302f..3e1d5b4d604 100644
--- a/chromium/ui/wm/core/compound_event_filter_unittest.cc
+++ b/chromium/ui/wm/core/compound_event_filter_unittest.cc
@@ -130,21 +130,18 @@ TEST_F(CompoundEventFilterTest, TouchHidesCursor) {
// This press is required for the GestureRecognizer to associate a target
// with kTouchId
- ui::TouchEvent press0(
- ui::ET_TOUCH_PRESSED, gfx::Point(90, 90), GetTime(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::TouchEvent press0(ui::ET_TOUCH_PRESSED, gfx::Point(90, 90), GetTime(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
DispatchEventUsingWindowDispatcher(&press0);
EXPECT_FALSE(cursor_client.IsMouseEventsEnabled());
- ui::TouchEvent move(
- ui::ET_TOUCH_MOVED, gfx::Point(10, 10), GetTime(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::TouchEvent move(ui::ET_TOUCH_MOVED, gfx::Point(10, 10), GetTime(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
DispatchEventUsingWindowDispatcher(&move);
EXPECT_FALSE(cursor_client.IsMouseEventsEnabled());
- ui::TouchEvent release(
- ui::ET_TOUCH_RELEASED, gfx::Point(10, 10), GetTime(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::TouchEvent release(ui::ET_TOUCH_RELEASED, gfx::Point(10, 10), GetTime(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
DispatchEventUsingWindowDispatcher(&release);
EXPECT_FALSE(cursor_client.IsMouseEventsEnabled());
@@ -155,9 +152,8 @@ TEST_F(CompoundEventFilterTest, TouchHidesCursor) {
EXPECT_TRUE(cursor_client.IsMouseEventsEnabled());
// Now activate the window and press on it again.
- ui::TouchEvent press1(
- ui::ET_TOUCH_PRESSED, gfx::Point(90, 90), GetTime(),
- ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
+ ui::TouchEvent press1(ui::ET_TOUCH_PRESSED, gfx::Point(90, 90), GetTime(),
+ ui::PointerDetails(ui::EventPointerType::kTouch, 1));
GetActivationClient(root_window())->ActivateWindow(window.get());
DispatchEventUsingWindowDispatcher(&press1);
EXPECT_FALSE(cursor_client.IsMouseEventsEnabled());
diff --git a/chromium/ui/wm/core/cursor_manager.cc b/chromium/ui/wm/core/cursor_manager.cc
index c9cb1c7eafe..5f5200af888 100644
--- a/chromium/ui/wm/core/cursor_manager.cc
+++ b/chromium/ui/wm/core/cursor_manager.cc
@@ -6,11 +6,12 @@
#include <utility>
-#include "base/logging.h"
+#include "base/check_op.h"
#include "base/macros.h"
+#include "base/trace_event/trace_event.h"
#include "ui/aura/client/cursor_client_observer.h"
#include "ui/base/cursor/cursor_size.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/wm/core/native_cursor_manager.h"
#include "ui/wm/core/native_cursor_manager_delegate.h"
@@ -154,6 +155,7 @@ ui::CursorSize CursorManager::GetCursorSize() const {
}
void CursorManager::EnableMouseEvents() {
+ TRACE_EVENT0("ui,input", "CursorManager::EnableMouseEvents");
state_on_unlock_->SetMouseEventsEnabled(true);
if (cursor_lock_count_ == 0 &&
IsMouseEventsEnabled() != state_on_unlock_->mouse_events_enabled()) {
@@ -163,6 +165,7 @@ void CursorManager::EnableMouseEvents() {
}
void CursorManager::DisableMouseEvents() {
+ TRACE_EVENT0("ui,input", "CursorManager::DisableMouseEvents");
state_on_unlock_->SetMouseEventsEnabled(false);
if (cursor_lock_count_ == 0 &&
IsMouseEventsEnabled() != state_on_unlock_->mouse_events_enabled()) {
diff --git a/chromium/ui/wm/core/cursor_manager_unittest.cc b/chromium/ui/wm/core/cursor_manager_unittest.cc
index e6279efd3ee..239ea036811 100644
--- a/chromium/ui/wm/core/cursor_manager_unittest.cc
+++ b/chromium/ui/wm/core/cursor_manager_unittest.cc
@@ -9,7 +9,7 @@
#include "ui/aura/client/cursor_client_observer.h"
#include "ui/aura/test/aura_test_base.h"
#include "ui/base/cursor/cursor_size.h"
-#include "ui/base/mojom/cursor_type.mojom-shared.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/wm/core/native_cursor_manager.h"
#include "ui/wm/test/testing_cursor_client_observer.h"
diff --git a/chromium/ui/wm/core/shadow_controller.cc b/chromium/ui/wm/core/shadow_controller.cc
index 50274fafcb3..395257e38c8 100644
--- a/chromium/ui/wm/core/shadow_controller.cc
+++ b/chromium/ui/wm/core/shadow_controller.cc
@@ -6,9 +6,9 @@
#include <utility>
+#include "base/check.h"
#include "base/command_line.h"
#include "base/containers/flat_set.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/no_destructor.h"
#include "base/scoped_observer.h"
diff --git a/chromium/ui/wm/core/window_animations.cc b/chromium/ui/wm/core/window_animations.cc
index 7e0c51ff002..08477b6bc94 100644
--- a/chromium/ui/wm/core/window_animations.cc
+++ b/chromium/ui/wm/core/window_animations.cc
@@ -9,12 +9,13 @@
#include <algorithm>
#include <memory>
+#include "base/check_op.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/lazy_instance.h"
-#include "base/logging.h"
#include "base/macros.h"
#include "base/metrics/histogram_macros.h"
+#include "base/notreached.h"
#include "base/stl_util.h"
#include "base/time/time.h"
#include "ui/aura/client/aura_constants.h"