[email protected] | 60a5007 | 2012-01-11 02:05:35 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 2cff005 | 2011-03-18 16:51:44 | [diff] [blame] | 5 | #include "content/renderer/render_widget.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 6 | |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 7 | #include <cmath> |
| 8 | #include <limits> |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 9 | #include <memory> |
dcheng | 07945f63 | 2015-12-26 07:59:32 | [diff] [blame] | 10 | #include <utility> |
| 11 | |
[email protected] | c27dd4f | 2014-05-22 18:05:19 | [diff] [blame] | 12 | #include "base/auto_reset.h" |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 13 | #include "base/base_switches.h" |
[email protected] | 32876ae | 2011-11-15 22:25:21 | [diff] [blame] | 14 | #include "base/bind.h" |
[email protected] | 4fb6684 | 2009-12-04 21:41:00 | [diff] [blame] | 15 | #include "base/command_line.h" |
changwan | 7ded375 | 2016-03-09 23:25:12 | [diff] [blame] | 16 | #include "base/feature_list.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 17 | #include "base/logging.h" |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 18 | #include "base/macros.h" |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 19 | #include "base/memory/ptr_util.h" |
[email protected] | b256eca | 2013-07-11 10:57:40 | [diff] [blame] | 20 | #include "base/memory/singleton.h" |
asvitkine | 8d51e9d | 2016-09-02 23:55:43 | [diff] [blame] | 21 | #include "base/metrics/histogram_macros.h" |
[email protected] | aa4117f | 2011-12-09 22:19:21 | [diff] [blame] | 22 | #include "base/stl_util.h" |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 23 | #include "base/strings/string_number_conversions.h" |
[email protected] | 74ebfb1 | 2013-06-07 20:48:00 | [diff] [blame] | 24 | #include "base/strings/utf_string_conversions.h" |
Sebastien Marchand | 75a7cdf | 2018-11-13 23:47:03 | [diff] [blame] | 25 | #include "base/system/sys_info.h" |
fdoray | a19b770 | 2016-12-23 14:19:31 | [diff] [blame] | 26 | #include "base/threading/thread_task_runner_handle.h" |
primiano | 9e38d55 | 2015-01-28 04:18:01 | [diff] [blame] | 27 | #include "base/trace_event/trace_event.h" |
[email protected] | 661eb9d | 2009-02-03 02:11:48 | [diff] [blame] | 28 | #include "build/build_config.h" |
loyso | 6e6efc4 | 2017-01-21 02:23:03 | [diff] [blame] | 29 | #include "cc/animation/animation_host.h" |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 30 | #include "cc/base/switches.h" |
xidachen | fa0199e7 | 2017-05-11 11:34:26 | [diff] [blame] | 31 | #include "cc/input/touch_action.h" |
danakj | ba65a091 | 2017-09-21 16:38:42 | [diff] [blame] | 32 | #include "cc/trees/layer_tree_frame_sink.h" |
loyso | 6e6efc4 | 2017-01-21 02:23:03 | [diff] [blame] | 33 | #include "cc/trees/layer_tree_host.h" |
danakj | 4c98765 | 2018-07-05 15:49:41 | [diff] [blame] | 34 | #include "cc/trees/ukm_manager.h" |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 35 | #include "components/viz/common/features.h" |
Fady Samuel | c645ffe | 2017-07-24 17:28:20 | [diff] [blame] | 36 | #include "components/viz/common/frame_sinks/begin_frame_source.h" |
danakj | f20f450 | 2017-09-26 17:13:31 | [diff] [blame] | 37 | #include "components/viz/common/frame_sinks/copy_output_request.h" |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 38 | #include "components/viz/common/switches.h" |
| 39 | #include "content/common/content_switches_internal.h" |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 40 | #include "content/common/drag_event_source_info.h" |
| 41 | #include "content/common/drag_messages.h" |
jonross | a2ff4f8 | 2018-02-16 17:27:46 | [diff] [blame] | 42 | #include "content/common/render_frame_metadata.mojom.h" |
jcivelli | ae1560a | 2016-11-01 22:40:23 | [diff] [blame] | 43 | #include "content/common/render_message_filter.mojom.h" |
Nasko Oskov | f97e8b0 | 2017-07-25 02:45:42 | [diff] [blame] | 44 | #include "content/common/swapped_out_messages.h" |
Sadrul Habib Chowdhury | 8bc43cc | 2018-06-06 01:48:03 | [diff] [blame] | 45 | #include "content/common/tab_switching_time_callback.h" |
ekaramad | 9053e57b | 2016-04-26 20:00:38 | [diff] [blame] | 46 | #include "content/common/text_input_state.h" |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 47 | #include "content/common/widget_messages.h" |
mlamouri | afca06dd | 2017-01-27 23:35:18 | [diff] [blame] | 48 | #include "content/public/common/content_client.h" |
changwan | 7ded375 | 2016-03-09 23:25:12 | [diff] [blame] | 49 | #include "content/public/common/content_features.h" |
[email protected] | c08950d2 | 2011-10-13 22:20:29 | [diff] [blame] | 50 | #include "content/public/common/content_switches.h" |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 51 | #include "content/public/common/context_menu_params.h" |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 52 | #include "content/public/common/drop_data.h" |
Khushal | 3e96e66 | 2017-10-30 23:16:50 | [diff] [blame] | 53 | #include "content/public/common/service_names.mojom.h" |
Jaebaek Seo | 655110e | 2017-12-19 23:27:39 | [diff] [blame] | 54 | #include "content/public/common/use_zoom_for_dsf_policy.h" |
mlamouri | afca06dd | 2017-01-27 23:35:18 | [diff] [blame] | 55 | #include "content/public/renderer/content_renderer_client.h" |
Saman Sami | d189e5dfd | 2017-12-20 22:55:31 | [diff] [blame] | 56 | #include "content/renderer/browser_plugin/browser_plugin.h" |
[email protected] | 953bd006 | 2013-08-01 00:58:40 | [diff] [blame] | 57 | #include "content/renderer/cursor_utils.h" |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 58 | #include "content/renderer/devtools/render_widget_screen_metrics_emulator.h" |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 59 | #include "content/renderer/drop_data_builder.h" |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 60 | #include "content/renderer/external_popup_menu.h" |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 61 | #include "content/renderer/gpu/frame_swap_message_queue.h" |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 62 | #include "content/renderer/gpu/layer_tree_view.h" |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 63 | #include "content/renderer/gpu/queue_message_swap_promise.h" |
[email protected] | 66fca5bc | 2013-05-23 06:58:29 | [diff] [blame] | 64 | #include "content/renderer/ime_event_guard.h" |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 65 | #include "content/renderer/input/main_thread_event_queue.h" |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 66 | #include "content/renderer/input/widget_input_handler_manager.h" |
[email protected] | adab233 | 2013-07-25 18:04:32 | [diff] [blame] | 67 | #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 68 | #include "content/renderer/render_frame_impl.h" |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 69 | #include "content/renderer/render_frame_metadata_observer_impl.h" |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 70 | #include "content/renderer/render_frame_proxy.h" |
[email protected] | 8704f89b | 2011-04-15 00:30:05 | [diff] [blame] | 71 | #include "content/renderer/render_process.h" |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 72 | #include "content/renderer/render_thread_impl.h" |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 73 | #include "content/renderer/render_view_impl.h" |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 74 | #include "content/renderer/render_widget_owner_delegate.h" |
tfarina | 556a723 | 2014-10-05 01:02:09 | [diff] [blame] | 75 | #include "content/renderer/renderer_blink_platform_impl.h" |
[email protected] | 5b45ad4 | 2013-10-25 00:42:04 | [diff] [blame] | 76 | #include "content/renderer/resizing_mode_selector.h" |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 77 | #include "gpu/command_buffer/service/gpu_switches.h" |
ekaramad | 330ba423 | 2016-09-23 17:57:47 | [diff] [blame] | 78 | #include "ipc/ipc_message_start.h" |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 79 | #include "ipc/ipc_sync_message.h" |
Antoine Labour | e55c9ef8 | 2017-11-10 18:51:23 | [diff] [blame] | 80 | #include "ipc/ipc_sync_message_filter.h" |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 81 | #include "media/base/media_switches.h" |
Scott Violet | 02e38b9 | 2018-03-27 23:42:14 | [diff] [blame] | 82 | #include "ppapi/buildflags/buildflags.h" |
[email protected] | 661eb9d | 2009-02-03 02:11:48 | [diff] [blame] | 83 | #include "skia/ext/platform_canvas.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 84 | #include "third_party/blink/public/platform/file_path_conversion.h" |
Hajime Hoshi | 315a61f | 2018-08-14 17:27:28 | [diff] [blame] | 85 | #include "third_party/blink/public/platform/platform.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 86 | #include "third_party/blink/public/platform/scheduler/web_render_widget_scheduling_state.h" |
Yuta Kitamura | deb91bb | 2018-05-29 05:53:20 | [diff] [blame] | 87 | #include "third_party/blink/public/platform/scheduler/web_thread_scheduler.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 88 | #include "third_party/blink/public/platform/web_cursor_info.h" |
| 89 | #include "third_party/blink/public/platform/web_drag_data.h" |
| 90 | #include "third_party/blink/public/platform/web_drag_operation.h" |
| 91 | #include "third_party/blink/public/platform/web_mouse_event.h" |
| 92 | #include "third_party/blink/public/platform/web_point.h" |
| 93 | #include "third_party/blink/public/platform/web_rect.h" |
| 94 | #include "third_party/blink/public/platform/web_runtime_features.h" |
| 95 | #include "third_party/blink/public/platform/web_size.h" |
| 96 | #include "third_party/blink/public/platform/web_string.h" |
| 97 | #include "third_party/blink/public/web/web_autofill_client.h" |
| 98 | #include "third_party/blink/public/web/web_device_emulation_params.h" |
| 99 | #include "third_party/blink/public/web/web_frame_widget.h" |
| 100 | #include "third_party/blink/public/web/web_input_method_controller.h" |
| 101 | #include "third_party/blink/public/web/web_local_frame.h" |
| 102 | #include "third_party/blink/public/web/web_node.h" |
| 103 | #include "third_party/blink/public/web/web_page_popup.h" |
| 104 | #include "third_party/blink/public/web/web_popup_menu_info.h" |
| 105 | #include "third_party/blink/public/web/web_range.h" |
| 106 | #include "third_party/blink/public/web/web_settings.h" |
| 107 | #include "third_party/blink/public/web/web_view.h" |
| 108 | #include "third_party/blink/public/web/web_widget.h" |
[email protected] | d353541f | 2012-05-03 22:45:41 | [diff] [blame] | 109 | #include "third_party/skia/include/core/SkShader.h" |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 110 | #include "ui/base/clipboard/clipboard.h" |
Scott Violet | 8ff9c30 | 2018-02-22 22:28:35 | [diff] [blame] | 111 | #include "ui/base/ui_base_features.h" |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 112 | #include "ui/base/ui_base_switches.h" |
dtapuska | 97286c88 | 2017-02-24 23:14:43 | [diff] [blame] | 113 | #include "ui/events/base_event_utils.h" |
tfarina | 655f81d | 2014-12-23 02:38:50 | [diff] [blame] | 114 | #include "ui/gfx/geometry/point_conversions.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 115 | #include "ui/gfx/geometry/rect_conversions.h" |
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame] | 116 | #include "ui/gfx/geometry/size_conversions.h" |
[email protected] | 1835b9e | 2012-02-28 13:12:48 | [diff] [blame] | 117 | #include "ui/gfx/skia_util.h" |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 118 | #include "ui/gfx/switches.h" |
[email protected] | c9e2cbbb | 2012-05-12 21:17:27 | [diff] [blame] | 119 | #include "ui/gl/gl_switches.h" |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 120 | #include "ui/native_theme/native_theme_features.h" |
| 121 | #include "ui/native_theme/overlay_scrollbar_constants_aura.h" |
[email protected] | d353541f | 2012-05-03 22:45:41 | [diff] [blame] | 122 | #include "ui/surface/transport_dib.h" |
[email protected] | 661eb9d | 2009-02-03 02:11:48 | [diff] [blame] | 123 | |
[email protected] | eeb9311 | 2013-05-01 19:41:10 | [diff] [blame] | 124 | #if defined(OS_ANDROID) |
[email protected] | cefe9b15 | 2014-03-27 18:16:15 | [diff] [blame] | 125 | #include <android/keycodes.h> |
wjmaclean | 1d97062 | 2017-01-21 22:28:24 | [diff] [blame] | 126 | #include "base/time/time.h" |
[email protected] | eeb9311 | 2013-05-01 19:41:10 | [diff] [blame] | 127 | #endif |
| 128 | |
[email protected] | 661eb9d | 2009-02-03 02:11:48 | [diff] [blame] | 129 | #if defined(OS_POSIX) |
[email protected] | d5282e7 | 2009-05-13 13:16:52 | [diff] [blame] | 130 | #include "third_party/skia/include/core/SkMallocPixelRef.h" |
[email protected] | d353541f | 2012-05-03 22:45:41 | [diff] [blame] | 131 | #include "third_party/skia/include/core/SkPixelRef.h" |
[email protected] | 661eb9d | 2009-02-03 02:11:48 | [diff] [blame] | 132 | #endif // defined(OS_POSIX) |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 133 | |
sadrul | 943e3b3 | 2016-08-04 18:22:59 | [diff] [blame] | 134 | #if defined(USE_AURA) |
sadrul | 602ce136 | 2017-01-26 06:41:10 | [diff] [blame] | 135 | #include "content/renderer/mus/renderer_window_tree_client.h" |
penghuang | 28a5fa2 | 2015-12-02 17:58:19 | [diff] [blame] | 136 | #endif |
| 137 | |
ekaramad | 330ba423 | 2016-09-23 17:57:47 | [diff] [blame] | 138 | #if defined(OS_MACOSX) |
| 139 | #include "content/renderer/text_input_client_observer.h" |
| 140 | #endif |
| 141 | |
Ryan Landay | 9e42fd74 | 2017-08-12 01:59:11 | [diff] [blame] | 142 | using blink::WebImeTextSpan; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 143 | using blink::WebCursorInfo; |
[email protected] | 1919368 | 2014-04-03 15:01:43 | [diff] [blame] | 144 | using blink::WebDeviceEmulationParams; |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 145 | using blink::WebDragOperation; |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 146 | using blink::WebDragOperationsMask; |
| 147 | using blink::WebDragData; |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 148 | using blink::WebFrameWidget; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 149 | using blink::WebGestureEvent; |
| 150 | using blink::WebInputEvent; |
dtapuska | 5d2e9c3 | 2015-12-03 16:39:49 | [diff] [blame] | 151 | using blink::WebInputEventResult; |
ekaramad | 2daaf67 | 2016-11-10 20:29:01 | [diff] [blame] | 152 | using blink::WebInputMethodController; |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 153 | using blink::WebLocalFrame; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 154 | using blink::WebMouseEvent; |
| 155 | using blink::WebMouseWheelEvent; |
| 156 | using blink::WebNavigationPolicy; |
donnd | a070f3c | 2015-01-16 19:54:11 | [diff] [blame] | 157 | using blink::WebNode; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 158 | using blink::WebPagePopup; |
dglazkov | e353a37 | 2016-09-01 01:33:48 | [diff] [blame] | 159 | using blink::WebRange; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 160 | using blink::WebRect; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 161 | using blink::WebSize; |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 162 | using blink::WebString; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 163 | using blink::WebTextDirection; |
| 164 | using blink::WebTouchEvent; |
[email protected] | f8ed472 | 2013-12-03 03:27:25 | [diff] [blame] | 165 | using blink::WebTouchPoint; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 166 | using blink::WebVector; |
| 167 | using blink::WebWidget; |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 168 | |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 169 | namespace content { |
| 170 | |
[email protected] | 6a4d7f6 | 2013-01-07 21:32:13 | [diff] [blame] | 171 | namespace { |
[email protected] | b256eca | 2013-07-11 10:57:40 | [diff] [blame] | 172 | |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 173 | using RoutingIDWidgetMap = std::map<int32_t, RenderWidget*>; |
| 174 | base::LazyInstance<RoutingIDWidgetMap>::Leaky g_routing_id_widget_map = |
| 175 | LAZY_INSTANCE_INITIALIZER; |
| 176 | |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 177 | const base::Feature kUnpremultiplyAndDitherLowBitDepthTiles = { |
| 178 | "UnpremultiplyAndDitherLowBitDepthTiles", base::FEATURE_ENABLED_BY_DEFAULT}; |
| 179 | |
[email protected] | b256eca | 2013-07-11 10:57:40 | [diff] [blame] | 180 | typedef std::map<std::string, ui::TextInputMode> TextInputModeMap; |
| 181 | |
AJITH KUMAR V | 041c0b0 | 2017-08-08 10:39:20 | [diff] [blame] | 182 | static const int kInvalidNextPreviousFlagsValue = -1; |
yiyix | 6b90ef5 | 2018-10-09 19:55:30 | [diff] [blame] | 183 | static const char* kOOPIF = "OOPIF"; |
| 184 | static const char* kRenderer = "Renderer"; |
AJITH KUMAR V | 041c0b0 | 2017-08-08 10:39:20 | [diff] [blame] | 185 | |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 186 | class WebWidgetLockTarget : public content::MouseLockDispatcher::LockTarget { |
| 187 | public: |
| 188 | explicit WebWidgetLockTarget(blink::WebWidget* webwidget) |
| 189 | : webwidget_(webwidget) {} |
| 190 | |
| 191 | void OnLockMouseACK(bool succeeded) override { |
| 192 | if (succeeded) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 193 | webwidget_->DidAcquirePointerLock(); |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 194 | else |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 195 | webwidget_->DidNotAcquirePointerLock(); |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 196 | } |
| 197 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 198 | void OnMouseLockLost() override { webwidget_->DidLosePointerLock(); } |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 199 | |
| 200 | bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event) override { |
| 201 | // The WebWidget handles mouse lock in Blink's handleInputEvent(). |
| 202 | return false; |
| 203 | } |
| 204 | |
| 205 | private: |
| 206 | blink::WebWidget* webwidget_; |
| 207 | }; |
| 208 | |
dglazkov | 97b6c2b | 2016-10-25 17:35:55 | [diff] [blame] | 209 | bool IsDateTimeInput(ui::TextInputType type) { |
| 210 | return type == ui::TEXT_INPUT_TYPE_DATE || |
| 211 | type == ui::TEXT_INPUT_TYPE_DATE_TIME || |
| 212 | type == ui::TEXT_INPUT_TYPE_DATE_TIME_LOCAL || |
| 213 | type == ui::TEXT_INPUT_TYPE_MONTH || |
| 214 | type == ui::TEXT_INPUT_TYPE_TIME || type == ui::TEXT_INPUT_TYPE_WEEK; |
| 215 | } |
| 216 | |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 217 | WebDragData DropMetaDataToWebDragData( |
| 218 | const std::vector<DropData::Metadata>& drop_meta_data) { |
| 219 | std::vector<WebDragData::Item> item_list; |
| 220 | for (const auto& meta_data_item : drop_meta_data) { |
| 221 | if (meta_data_item.kind == DropData::Kind::STRING) { |
| 222 | WebDragData::Item item; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 223 | item.storage_type = WebDragData::Item::kStorageTypeString; |
| 224 | item.string_type = WebString::FromUTF16(meta_data_item.mime_type); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 225 | // Have to pass a dummy URL here instead of an empty URL because the |
| 226 | // DropData received by browser_plugins goes through a round trip: |
| 227 | // DropData::MetaData --> WebDragData-->DropData. In the end, DropData |
| 228 | // will contain an empty URL (which means no URL is dragged) if the URL in |
| 229 | // WebDragData is empty. |
| 230 | if (base::EqualsASCII(meta_data_item.mime_type, |
| 231 | ui::Clipboard::kMimeTypeURIList)) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 232 | item.string_data = WebString::FromUTF8("about:dragdrop-placeholder"); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 233 | } |
| 234 | item_list.push_back(item); |
| 235 | continue; |
| 236 | } |
| 237 | |
| 238 | // TODO(hush): crbug.com/584789. Blink needs to support creating a file with |
| 239 | // just the mimetype. This is needed to drag files to WebView on Android |
| 240 | // platform. |
| 241 | if ((meta_data_item.kind == DropData::Kind::FILENAME) && |
| 242 | !meta_data_item.filename.empty()) { |
| 243 | WebDragData::Item item; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 244 | item.storage_type = WebDragData::Item::kStorageTypeFilename; |
| 245 | item.filename_data = blink::FilePathToWebString(meta_data_item.filename); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 246 | item_list.push_back(item); |
| 247 | continue; |
| 248 | } |
| 249 | |
| 250 | if (meta_data_item.kind == DropData::Kind::FILESYSTEMFILE) { |
| 251 | WebDragData::Item item; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 252 | item.storage_type = WebDragData::Item::kStorageTypeFileSystemFile; |
| 253 | item.file_system_url = meta_data_item.file_system_url; |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 254 | item_list.push_back(item); |
| 255 | continue; |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | WebDragData result; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 260 | result.Initialize(); |
| 261 | result.SetItems(item_list); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 262 | return result; |
| 263 | } |
| 264 | |
| 265 | WebDragData DropDataToWebDragData(const DropData& drop_data) { |
| 266 | std::vector<WebDragData::Item> item_list; |
| 267 | |
| 268 | // These fields are currently unused when dragging into WebKit. |
| 269 | DCHECK(drop_data.download_metadata.empty()); |
| 270 | DCHECK(drop_data.file_contents.empty()); |
dcheng | 3dd8561 | 2017-02-08 10:46:23 | [diff] [blame] | 271 | DCHECK(drop_data.file_contents_content_disposition.empty()); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 272 | |
| 273 | if (!drop_data.text.is_null()) { |
| 274 | WebDragData::Item item; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 275 | item.storage_type = WebDragData::Item::kStorageTypeString; |
| 276 | item.string_type = WebString::FromUTF8(ui::Clipboard::kMimeTypeText); |
| 277 | item.string_data = WebString::FromUTF16(drop_data.text.string()); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 278 | item_list.push_back(item); |
| 279 | } |
| 280 | |
| 281 | if (!drop_data.url.is_empty()) { |
| 282 | WebDragData::Item item; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 283 | item.storage_type = WebDragData::Item::kStorageTypeString; |
| 284 | item.string_type = WebString::FromUTF8(ui::Clipboard::kMimeTypeURIList); |
| 285 | item.string_data = WebString::FromUTF8(drop_data.url.spec()); |
| 286 | item.title = WebString::FromUTF16(drop_data.url_title); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 287 | item_list.push_back(item); |
| 288 | } |
| 289 | |
| 290 | if (!drop_data.html.is_null()) { |
| 291 | WebDragData::Item item; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 292 | item.storage_type = WebDragData::Item::kStorageTypeString; |
| 293 | item.string_type = WebString::FromUTF8(ui::Clipboard::kMimeTypeHTML); |
| 294 | item.string_data = WebString::FromUTF16(drop_data.html.string()); |
| 295 | item.base_url = drop_data.html_base_url; |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 296 | item_list.push_back(item); |
| 297 | } |
| 298 | |
jdoerrie | 5a73d0fa | 2018-10-02 23:54:05 | [diff] [blame] | 299 | for (auto it = drop_data.filenames.begin(); it != drop_data.filenames.end(); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 300 | ++it) { |
| 301 | WebDragData::Item item; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 302 | item.storage_type = WebDragData::Item::kStorageTypeFilename; |
| 303 | item.filename_data = blink::FilePathToWebString(it->path); |
| 304 | item.display_name_data = |
kinuko | a429302 | 2017-01-27 06:43:25 | [diff] [blame] | 305 | blink::FilePathToWebString(base::FilePath(it->display_name)); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 306 | item_list.push_back(item); |
| 307 | } |
| 308 | |
jdoerrie | 5a73d0fa | 2018-10-02 23:54:05 | [diff] [blame] | 309 | for (auto it = drop_data.file_system_files.begin(); |
| 310 | it != drop_data.file_system_files.end(); ++it) { |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 311 | WebDragData::Item item; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 312 | item.storage_type = WebDragData::Item::kStorageTypeFileSystemFile; |
| 313 | item.file_system_url = it->url; |
| 314 | item.file_system_file_size = it->size; |
| 315 | item.file_system_id = blink::WebString::FromASCII(it->filesystem_id); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 316 | item_list.push_back(item); |
| 317 | } |
| 318 | |
Stuart Langley | 4830039 | 2017-11-02 03:54:44 | [diff] [blame] | 319 | for (const auto& it : drop_data.custom_data) { |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 320 | WebDragData::Item item; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 321 | item.storage_type = WebDragData::Item::kStorageTypeString; |
Stuart Langley | 4830039 | 2017-11-02 03:54:44 | [diff] [blame] | 322 | item.string_type = WebString::FromUTF16(it.first); |
| 323 | item.string_data = WebString::FromUTF16(it.second); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 324 | item_list.push_back(item); |
| 325 | } |
| 326 | |
| 327 | WebDragData result; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 328 | result.Initialize(); |
| 329 | result.SetItems(item_list); |
| 330 | result.SetFilesystemId(WebString::FromUTF16(drop_data.filesystem_id)); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 331 | return result; |
| 332 | } |
| 333 | |
dtapuska | c4dd5be | 2016-10-25 15:11:10 | [diff] [blame] | 334 | ui::TextInputType ConvertWebTextInputType(blink::WebTextInputType type) { |
| 335 | // Check the type is in the range representable by ui::TextInputType. |
| 336 | DCHECK_LE(type, static_cast<int>(ui::TEXT_INPUT_TYPE_MAX)) |
| 337 | << "blink::WebTextInputType and ui::TextInputType not synchronized"; |
| 338 | return static_cast<ui::TextInputType>(type); |
| 339 | } |
| 340 | |
| 341 | ui::TextInputMode ConvertWebTextInputMode(blink::WebTextInputMode mode) { |
| 342 | // Check the mode is in the range representable by ui::TextInputMode. |
| 343 | DCHECK_LE(mode, static_cast<int>(ui::TEXT_INPUT_MODE_MAX)) |
| 344 | << "blink::WebTextInputMode and ui::TextInputMode not synchronized"; |
| 345 | return static_cast<ui::TextInputMode>(mode); |
| 346 | } |
| 347 | |
Mitsuru Oshima | 3c07b33 | 2018-02-06 04:56:50 | [diff] [blame] | 348 | // Returns true if the device scale is high enough that losing subpixel |
| 349 | // antialiasing won't have a noticeable effect on text quality. |
| 350 | static bool DeviceScaleEnsuresTextQuality(float device_scale_factor) { |
| 351 | #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 352 | // On Android, we never have subpixel antialiasing. On Chrome OS we prefer to |
| 353 | // composite all scrollers so that we get animated overlay scrollbars. |
| 354 | return true; |
| 355 | #else |
| 356 | // 1.5 is a common touchscreen tablet device scale factor. For such |
| 357 | // devices main thread antialiasing is a heavy burden. |
| 358 | return device_scale_factor >= 1.5f; |
| 359 | #endif |
| 360 | } |
| 361 | |
| 362 | static bool PreferCompositingToLCDText(CompositorDependencies* compositor_deps, |
| 363 | float device_scale_factor) { |
| 364 | const base::CommandLine& command_line = |
| 365 | *base::CommandLine::ForCurrentProcess(); |
| 366 | if (command_line.HasSwitch(switches::kDisablePreferCompositingToLCDText)) |
| 367 | return false; |
| 368 | if (command_line.HasSwitch(switches::kEnablePreferCompositingToLCDText)) |
| 369 | return true; |
| 370 | if (!compositor_deps->IsLcdTextEnabled()) |
| 371 | return true; |
| 372 | return DeviceScaleEnsuresTextQuality(device_scale_factor); |
| 373 | } |
| 374 | |
[email protected] | b256eca | 2013-07-11 10:57:40 | [diff] [blame] | 375 | } // namespace |
| 376 | |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 377 | // RenderWidget --------------------------------------------------------------- |
| 378 | |
danakj | 829cdd14 | 2018-09-14 21:13:27 | [diff] [blame] | 379 | RenderWidget::RenderWidget(int32_t widget_routing_id, |
| 380 | CompositorDependencies* compositor_deps, |
danakj | 6a81659 | 2018-09-25 18:30:56 | [diff] [blame] | 381 | WidgetType widget_type, |
danakj | 829cdd14 | 2018-09-14 21:13:27 | [diff] [blame] | 382 | const ScreenInfo& screen_info, |
| 383 | blink::WebDisplayMode display_mode, |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 384 | bool is_frozen, |
danakj | 829cdd14 | 2018-09-14 21:13:27 | [diff] [blame] | 385 | bool hidden, |
| 386 | bool never_visible, |
| 387 | mojom::WidgetRequest widget_request) |
nick | 8331f8ad | 2016-11-15 20:42:45 | [diff] [blame] | 388 | : routing_id_(widget_routing_id), |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 389 | compositor_deps_(compositor_deps), |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 390 | webwidget_internal_(nullptr), |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 391 | owner_delegate_(nullptr), |
[email protected] | 847a258 | 2013-03-09 02:29:51 | [diff] [blame] | 392 | auto_resize_mode_(false), |
[email protected] | 1ac10dca | 2013-08-20 20:47:04 | [diff] [blame] | 393 | is_hidden_(hidden), |
sievers | 71c62dd5 | 2015-10-07 01:44:39 | [diff] [blame] | 394 | compositor_never_visible_(never_visible), |
mikhail.pozdnyakov | f2c902a | 2015-04-14 08:09:12 | [diff] [blame] | 395 | is_fullscreen_granted_(false), |
danakj | 73dd303 | 2018-07-28 17:49:53 | [diff] [blame] | 396 | display_mode_(display_mode), |
changwan | f2a707b | 2015-10-30 08:22:16 | [diff] [blame] | 397 | ime_event_guard_(nullptr), |
[email protected] | 661eb9d | 2009-02-03 02:11:48 | [diff] [blame] | 398 | closing_(false), |
danakj | 5c5269b | 2018-11-06 00:39:11 | [diff] [blame] | 399 | host_will_close_this_(false), |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 400 | is_frozen_(is_frozen), |
dglazkov | 97b6c2b | 2016-10-25 17:35:55 | [diff] [blame] | 401 | text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
[email protected] | b256eca | 2013-07-11 10:57:40 | [diff] [blame] | 402 | text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
shuchen | 82ce8c5 | 2014-10-23 01:55:20 | [diff] [blame] | 403 | text_input_flags_(0), |
AJITH KUMAR V | 041c0b0 | 2017-08-08 10:39:20 | [diff] [blame] | 404 | next_previous_flags_(kInvalidNextPreviousFlagsValue), |
[email protected] | 86ba5fcb | 2013-09-04 00:36:53 | [diff] [blame] | 405 | can_compose_inline_(true), |
nona | fa29179 | 2016-08-10 02:36:18 | [diff] [blame] | 406 | composition_range_(gfx::Range::InvalidRange()), |
danakj | 6a81659 | 2018-09-25 18:30:56 | [diff] [blame] | 407 | widget_type_(widget_type), |
[email protected] | 867125a0 | 2009-12-10 06:01:48 | [diff] [blame] | 408 | pending_window_rect_count_(0), |
Scott Violet | ae08f33 | 2018-07-27 17:37:23 | [diff] [blame] | 409 | screen_info_(screen_info), |
nona | fa29179 | 2016-08-10 02:36:18 | [diff] [blame] | 410 | monitor_composition_info_(false), |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 411 | popup_origin_scale_for_emulation_(0.f), |
samans | 26510e44 | 2017-06-01 22:29:12 | [diff] [blame] | 412 | frame_swap_message_queue_(new FrameSwapMessageQueue(routing_id_)), |
[email protected] | a09d53ce | 2014-01-31 00:46:42 | [diff] [blame] | 413 | resizing_mode_selector_(new ResizingModeSelector()), |
lfg | e0c2792ec | 2016-05-11 18:52:08 | [diff] [blame] | 414 | has_host_context_menu_location_(false), |
ekaramad | 2a46d63 | 2016-07-19 13:33:09 | [diff] [blame] | 415 | has_focus_(false), |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 416 | for_child_local_root_frame_(false), |
ekaramad | 330ba423 | 2016-09-23 17:57:47 | [diff] [blame] | 417 | #if defined(OS_MACOSX) |
| 418 | text_input_client_observer_(new TextInputClientObserver(this)), |
| 419 | #endif |
Takashi SAKAMOTO | 870f626 | 2017-08-22 04:08:27 | [diff] [blame] | 420 | first_update_visual_state_after_hidden_(false), |
tasak | b95dbb50c | 2017-02-08 18:07:50 | [diff] [blame] | 421 | was_shown_time_(base::TimeTicks::Now()), |
kenrb | 5d78b84 | 2017-03-06 21:06:01 | [diff] [blame] | 422 | current_content_source_id_(0), |
Dave Tapuska | 1bdf183 | 2017-07-07 18:07:19 | [diff] [blame] | 423 | widget_binding_(this, std::move(widget_request)), |
wjmaclean | 1d97062 | 2017-01-21 22:28:24 | [diff] [blame] | 424 | weak_ptr_factory_(this) { |
nick | 8331f8ad | 2016-11-15 20:42:45 | [diff] [blame] | 425 | DCHECK_NE(routing_id_, MSG_ROUTING_NONE); |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 426 | DCHECK(RenderThread::Get()); |
alexclarke | 7fa9394 | 2015-10-21 15:37:11 | [diff] [blame] | 427 | |
| 428 | // In tests there may not be a RenderThreadImpl. |
| 429 | if (RenderThreadImpl::current()) { |
| 430 | render_widget_scheduling_state_ = RenderThreadImpl::current() |
Yuta Kitamura | 3331f5c | 2018-04-05 11:12:25 | [diff] [blame] | 431 | ->GetWebMainThreadScheduler() |
dcheng | 07945f63 | 2015-12-26 07:59:32 | [diff] [blame] | 432 | ->NewRenderWidgetSchedulingState(); |
alexclarke | 7fa9394 | 2015-10-21 15:37:11 | [diff] [blame] | 433 | render_widget_scheduling_state_->SetHidden(is_hidden_); |
| 434 | } |
sadrul | 602ce136 | 2017-01-26 06:41:10 | [diff] [blame] | 435 | #if defined(USE_AURA) |
fsamuel | 098eade | 2017-03-21 18:06:14 | [diff] [blame] | 436 | RendererWindowTreeClient::CreateIfNecessary(routing_id_); |
Scott Violet | e46b335 | 2018-09-22 00:37:07 | [diff] [blame] | 437 | if (features::IsMultiProcessMash()) |
Scott Violet | 1098538e | 2017-10-05 19:23:33 | [diff] [blame] | 438 | RendererWindowTreeClient::Get(routing_id_)->SetVisible(!is_hidden_); |
sadrul | 602ce136 | 2017-01-26 06:41:10 | [diff] [blame] | 439 | #endif |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 440 | |
| 441 | if (routing_id_ != MSG_ROUTING_NONE) |
| 442 | g_routing_id_widget_map.Get().emplace(routing_id_, this); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | RenderWidget::~RenderWidget() { |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 446 | DCHECK(!webwidget_internal_) << "Leaking our WebWidget!"; |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 447 | // TODO(ajwong): Add in check that routing_id_ has been removed from |
| 448 | // g_routing_id_widget_map once the shutdown semantics for RenderWidget |
| 449 | // and RenderViewImpl are rationalized. Currently, too many unit and |
| 450 | // browser tests delete a RenderWidget without correclty going through |
| 451 | // the shutdown. https://crbug.com/545684 |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 452 | |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 453 | if (input_event_queue_) |
| 454 | input_event_queue_->ClearClient(); |
| 455 | |
sadrul | 8185d97 | 2017-01-31 18:30:11 | [diff] [blame] | 456 | #if defined(USE_AURA) |
fsamuel | 098eade | 2017-03-21 18:06:14 | [diff] [blame] | 457 | // It is possible for a RenderWidget to be destroyed before it was embedded |
| 458 | // in a mus window. The RendererWindowTreeClient will leak in such cases. So |
| 459 | // explicitly delete it here. |
| 460 | RendererWindowTreeClient::Destroy(routing_id_); |
sadrul | 8185d97 | 2017-01-31 18:30:11 | [diff] [blame] | 461 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 462 | } |
| 463 | |
[email protected] | 48495594 | 2010-08-19 16:13:18 | [diff] [blame] | 464 | // static |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 465 | RenderWidget* RenderWidget::FromRoutingID(int32_t routing_id) { |
| 466 | RoutingIDWidgetMap* widgets = g_routing_id_widget_map.Pointer(); |
jdoerrie | 5a73d0fa | 2018-10-02 23:54:05 | [diff] [blame] | 467 | auto it = widgets->find(routing_id); |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 468 | return it == widgets->end() ? NULL : it->second; |
| 469 | } |
| 470 | |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 471 | void RenderWidget::InitForPopup(ShowCallback show_callback, |
| 472 | blink::WebPagePopup* web_page_popup) { |
| 473 | // Init() increments the reference count on |this|, making it |
| 474 | // self-referencing. |
| 475 | Init(std::move(show_callback), web_page_popup); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 476 | } |
| 477 | |
danakj | 6a81659 | 2018-09-25 18:30:56 | [diff] [blame] | 478 | void RenderWidget::InitForChildLocalRoot( |
| 479 | blink::WebFrameWidget* web_frame_widget) { |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 480 | for_child_local_root_frame_ = true; |
danakj | 6a81659 | 2018-09-25 18:30:56 | [diff] [blame] | 481 | // Init() increments the reference count on |this|, making it |
| 482 | // self-referencing. |
| 483 | Init(base::NullCallback(), web_frame_widget); |
dcheng | da9b4bb | 2015-07-20 20:58:08 | [diff] [blame] | 484 | } |
| 485 | |
dcheng | da9b4bb | 2015-07-20 20:58:08 | [diff] [blame] | 486 | void RenderWidget::CloseForFrame() { |
dcheng | d96a27a | 2015-07-24 20:17:32 | [diff] [blame] | 487 | OnClose(); |
kenrb | a719983 | 2015-01-22 23:44:59 | [diff] [blame] | 488 | } |
| 489 | |
Scott Violet | ae08f33 | 2018-07-27 17:37:23 | [diff] [blame] | 490 | void RenderWidget::Init(ShowCallback show_callback, WebWidget* web_widget) { |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 491 | DCHECK(!webwidget_internal_); |
nick | 4df698d8 | 2016-11-11 20:39:23 | [diff] [blame] | 492 | DCHECK_NE(routing_id_, MSG_ROUTING_NONE); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 493 | |
danakj | 17216f4d | 2018-10-16 22:57:32 | [diff] [blame] | 494 | RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); |
| 495 | |
Jeremy Roman | 04f27c37 | 2017-10-27 15:20:55 | [diff] [blame] | 496 | input_handler_ = std::make_unique<RenderWidgetInputHandler>(this, this); |
nick | 8331f8ad | 2016-11-15 20:42:45 | [diff] [blame] | 497 | |
danakj | 17216f4d | 2018-10-16 22:57:32 | [diff] [blame] | 498 | LayerTreeView* layer_tree_view = InitializeLayerTreeView(); |
| 499 | web_widget->SetLayerTreeView(layer_tree_view); |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 500 | |
danakj | 31699d5b | 2018-09-18 15:39:17 | [diff] [blame] | 501 | blink::scheduler::WebThreadScheduler* main_thread_scheduler = nullptr; |
| 502 | if (render_thread_impl) |
| 503 | main_thread_scheduler = render_thread_impl->GetWebMainThreadScheduler(); |
Alexander Timin | 41e917d | 2018-07-02 16:25:35 | [diff] [blame] | 504 | blink::scheduler::WebThreadScheduler* compositor_thread_scheduler = |
| 505 | blink::scheduler::WebThreadScheduler::CompositorThreadScheduler(); |
danakj | 31699d5b | 2018-09-18 15:39:17 | [diff] [blame] | 506 | scoped_refptr<base::SingleThreadTaskRunner> compositor_input_task_runner; |
| 507 | // The |compositor_thread_scheduler| can be null in tests without a compositor |
| 508 | // thread. |
| 509 | if (compositor_thread_scheduler) { |
| 510 | // When the RenderWidget is for a frame (ie for a local root) then it uses |
danakj | bd33539 | 2018-10-10 20:17:04 | [diff] [blame] | 511 | // the compositor thread task runner. When it is for a popup or other such |
| 512 | // widgets, it does not. |
| 513 | // TODO(danakj): The |web_widget| given here should become a WebFrameWidget |
| 514 | // in the case the RenderWidget is for a RenderViewImpl, but currently the |
| 515 | // WebFrameWidget gets attached after RenderWidget init. So we have to check |
| 516 | // IsWebView() as well. |
| 517 | if (web_widget->IsWebFrameWidget() || web_widget->IsWebView()) { |
danakj | 31699d5b | 2018-09-18 15:39:17 | [diff] [blame] | 518 | compositor_input_task_runner = |
| 519 | compositor_thread_scheduler->InputTaskRunner(); |
| 520 | } |
| 521 | } |
Alexander Timin | 41e917d | 2018-07-02 16:25:35 | [diff] [blame] | 522 | |
Dave Tapuska | 04bc5ee9 | 2018-04-17 19:03:31 | [diff] [blame] | 523 | widget_input_handler_manager_ = WidgetInputHandlerManager::Create( |
danakj | 31699d5b | 2018-09-18 15:39:17 | [diff] [blame] | 524 | weak_ptr_factory_.GetWeakPtr(), std::move(compositor_input_task_runner), |
| 525 | main_thread_scheduler); |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 526 | |
danakj | df1ceb7 | 2018-07-18 20:02:25 | [diff] [blame] | 527 | show_callback_ = std::move(show_callback); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 528 | |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 529 | webwidget_internal_ = web_widget; |
| 530 | webwidget_mouse_lock_target_.reset( |
| 531 | new WebWidgetLockTarget(webwidget_internal_)); |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 532 | mouse_lock_dispatcher_.reset(new RenderWidgetMouseLockDispatcher(this)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 533 | |
nick | 4df698d8 | 2016-11-11 20:39:23 | [diff] [blame] | 534 | RenderThread::Get()->AddRoute(routing_id_, this); |
| 535 | // Take a reference on behalf of the RenderThread. This will be balanced |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 536 | // when we receive WidgetMsg_Close. |
nick | 4df698d8 | 2016-11-11 20:39:23 | [diff] [blame] | 537 | AddRef(); |
| 538 | if (RenderThreadImpl::current()) { |
| 539 | RenderThreadImpl::current()->WidgetCreated(); |
| 540 | if (is_hidden_) |
| 541 | RenderThreadImpl::current()->WidgetHidden(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 542 | } |
| 543 | } |
| 544 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 545 | void RenderWidget::ApplyEmulatedScreenMetricsForPopupWidget( |
| 546 | RenderWidget* origin_widget) { |
| 547 | RenderWidgetScreenMetricsEmulator* emulator = |
| 548 | origin_widget->screen_metrics_emulator_.get(); |
| 549 | if (!emulator) |
| 550 | return; |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 551 | popup_origin_scale_for_emulation_ = emulator->scale(); |
[email protected] | 1919368 | 2014-04-03 15:01:43 | [diff] [blame] | 552 | popup_view_origin_for_emulation_ = emulator->applied_widget_rect().origin(); |
Pavel Feldman | cc099f7 | 2017-07-20 23:09:00 | [diff] [blame] | 553 | popup_screen_origin_for_emulation_ = |
Lei Zhang | 9b359d3 | 2017-11-28 00:57:02 | [diff] [blame] | 554 | emulator->original_screen_rect().origin(); |
Fady Samuel | 1c1ad369 | 2018-11-06 23:28:40 | [diff] [blame] | 555 | UpdateSurfaceAndScreenInfo(local_surface_id_allocation_from_parent_, |
| 556 | compositor_viewport_pixel_size_, |
| 557 | emulator->original_screen_info()); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 558 | } |
| 559 | |
[email protected] | 2d6836f4 | 2014-07-02 17:25:31 | [diff] [blame] | 560 | gfx::Rect RenderWidget::AdjustValidationMessageAnchor(const gfx::Rect& anchor) { |
| 561 | if (screen_metrics_emulator_) |
| 562 | return screen_metrics_emulator_->AdjustValidationMessageAnchor(anchor); |
| 563 | return anchor; |
| 564 | } |
| 565 | |
thakis | 18e42641 | 2017-03-15 12:06:37 | [diff] [blame] | 566 | #if BUILDFLAG(USE_EXTERNAL_POPUP_MENU) |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 567 | void RenderWidget::SetExternalPopupOriginAdjustmentsForEmulation( |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 568 | ExternalPopupMenu* popup, |
| 569 | RenderWidgetScreenMetricsEmulator* emulator) { |
Pavel Feldman | cc099f7 | 2017-07-20 23:09:00 | [diff] [blame] | 570 | popup->SetOriginScaleForEmulation(emulator->scale()); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 571 | } |
[email protected] | 5390786 | 2014-03-25 15:42:40 | [diff] [blame] | 572 | #endif |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 573 | |
| 574 | void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) { |
| 575 | if (screen_metrics_emulator_) |
| 576 | screen_metrics_emulator_->OnShowContextMenu(params); |
| 577 | } |
| 578 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 579 | bool RenderWidget::OnMessageReceived(const IPC::Message& message) { |
ekaramad | 330ba423 | 2016-09-23 17:57:47 | [diff] [blame] | 580 | #if defined(OS_MACOSX) |
| 581 | if (IPC_MESSAGE_CLASS(message) == TextInputClientMsgStart) |
| 582 | return text_input_client_observer_->OnMessageReceived(message); |
| 583 | #endif |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 584 | if (mouse_lock_dispatcher_ && |
| 585 | mouse_lock_dispatcher_->OnMessageReceived(message)) |
| 586 | return true; |
| 587 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 588 | bool handled = true; |
| 589 | IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 590 | IPC_MESSAGE_HANDLER(WidgetMsg_ShowContextMenu, OnShowContextMenu) |
| 591 | IPC_MESSAGE_HANDLER(WidgetMsg_Close, OnClose) |
| 592 | IPC_MESSAGE_HANDLER(WidgetMsg_SynchronizeVisualProperties, |
Fady Samuel | 799e7219 | 2018-04-25 21:16:57 | [diff] [blame] | 593 | OnSynchronizeVisualProperties) |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 594 | IPC_MESSAGE_HANDLER(WidgetMsg_EnableDeviceEmulation, |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 595 | OnEnableDeviceEmulation) |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 596 | IPC_MESSAGE_HANDLER(WidgetMsg_DisableDeviceEmulation, |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 597 | OnDisableDeviceEmulation) |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 598 | IPC_MESSAGE_HANDLER(WidgetMsg_WasHidden, OnWasHidden) |
| 599 | IPC_MESSAGE_HANDLER(WidgetMsg_WasShown, OnWasShown) |
| 600 | IPC_MESSAGE_HANDLER(WidgetMsg_SetActive, OnSetActive) |
| 601 | IPC_MESSAGE_HANDLER(WidgetMsg_SetBackgroundOpaque, OnSetBackgroundOpaque) |
| 602 | IPC_MESSAGE_HANDLER(WidgetMsg_SetTextDirection, OnSetTextDirection) |
| 603 | IPC_MESSAGE_HANDLER(WidgetMsg_SetBounds_ACK, OnRequestSetBoundsAck) |
| 604 | IPC_MESSAGE_HANDLER(WidgetMsg_UpdateScreenRects, OnUpdateScreenRects) |
| 605 | IPC_MESSAGE_HANDLER(WidgetMsg_ForceRedraw, OnForceRedraw) |
| 606 | IPC_MESSAGE_HANDLER(WidgetMsg_SetViewportIntersection, |
kenrb | ea73179 | 2017-01-13 15:10:48 | [diff] [blame] | 607 | OnSetViewportIntersection) |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 608 | IPC_MESSAGE_HANDLER(WidgetMsg_SetIsInert, OnSetIsInert) |
| 609 | IPC_MESSAGE_HANDLER(WidgetMsg_SetInheritedEffectiveTouchAction, |
sunxd | 540a996 | 2018-05-24 22:51:06 | [diff] [blame] | 610 | OnSetInheritedEffectiveTouchAction) |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 611 | IPC_MESSAGE_HANDLER(WidgetMsg_UpdateRenderThrottlingStatus, |
Ken Buchanan | 8a319fb | 2017-11-15 18:37:12 | [diff] [blame] | 612 | OnUpdateRenderThrottlingStatus) |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 613 | IPC_MESSAGE_HANDLER(WidgetMsg_WaitForNextFrameForTests, |
lfg | 43e08e6 | 2016-02-03 18:51:37 | [diff] [blame] | 614 | OnWaitNextFrameForTests) |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 615 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
| 616 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) |
| 617 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) |
| 618 | IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) |
paulmeyer | 8fc8ea9 | 2016-11-15 05:12:21 | [diff] [blame] | 619 | IPC_MESSAGE_HANDLER(DragMsg_SourceEnded, OnDragSourceEnded) |
| 620 | IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, |
| 621 | OnDragSourceSystemDragEnded) |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 622 | IPC_MESSAGE_UNHANDLED(handled = false) |
| 623 | IPC_END_MESSAGE_MAP() |
| 624 | return handled; |
| 625 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 626 | |
| 627 | bool RenderWidget::Send(IPC::Message* message) { |
Nasko Oskov | f97e8b0 | 2017-07-25 02:45:42 | [diff] [blame] | 628 | // Don't send any messages after the browser has told us to close, and filter |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 629 | // most outgoing messages when frozen. |
| 630 | if (closing_) { |
| 631 | delete message; |
| 632 | return false; |
| 633 | } |
| 634 | if (is_frozen_ && !SwappedOutMessages::CanSendWhileSwappedOut(message)) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 635 | delete message; |
| 636 | return false; |
| 637 | } |
| 638 | |
| 639 | // If given a messsage without a routing ID, then assign our routing ID. |
| 640 | if (message->routing_id() == MSG_ROUTING_NONE) |
| 641 | message->set_routing_id(routing_id_); |
| 642 | |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 643 | return RenderThread::Get()->Send(message); |
[email protected] | 8085dbc8 | 2008-09-26 22:53:44 | [diff] [blame] | 644 | } |
| 645 | |
dtapuska | 014ed08 | 2016-11-11 21:58:48 | [diff] [blame] | 646 | void RenderWidget::SendOrCrash(IPC::Message* message) { |
| 647 | bool result = Send(message); |
| 648 | CHECK(closing_ || result) << "Failed to send message"; |
| 649 | } |
| 650 | |
ekaramad | 5aff194 | 2017-01-06 01:26:35 | [diff] [blame] | 651 | bool RenderWidget::ShouldHandleImeEvents() const { |
ekaramad | b6483a05 | 2017-02-10 02:23:26 | [diff] [blame] | 652 | // TODO(ekaramad): We track page focus in all RenderViews on the page but the |
| 653 | // RenderWidgets corresponding to OOPIFs do not get the update. For now, this |
| 654 | // method returns true when the RenderWidget is for an OOPIF, i.e., IME events |
| 655 | // will be processed regardless of page focus. We should revisit this after |
| 656 | // page focus for OOPIFs has been fully resolved (https://crbug.com/689777). |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 657 | return GetWebWidget() && GetWebWidget()->IsWebFrameWidget() && |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 658 | (has_focus_ || for_child_local_root_frame_); |
ekaramad | 5aff194 | 2017-01-06 01:26:35 | [diff] [blame] | 659 | } |
| 660 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 661 | void RenderWidget::OnClose() { |
dcheng | d96a27a | 2015-07-24 20:17:32 | [diff] [blame] | 662 | DCHECK(content::RenderThread::Get()); |
| 663 | if (closing_) |
| 664 | return; |
| 665 | NotifyOnClose(); |
| 666 | closing_ = true; |
| 667 | |
| 668 | // Browser correspondence is no longer needed at this point. |
| 669 | if (routing_id_ != MSG_ROUTING_NONE) { |
| 670 | RenderThread::Get()->RemoveRoute(routing_id_); |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 671 | g_routing_id_widget_map.Get().erase(routing_id_); |
danakj | 678f025 | 2018-11-09 21:46:34 | [diff] [blame] | 672 | if (RenderThreadImpl::current()) { |
| 673 | // RenderWidgets may be hidden when they are closed. If we were previously |
| 674 | // hidden, we are being counted as such in RenderThreadImpl. Thus we |
| 675 | // remove that count here by calling WidgetRestored() even though we're |
| 676 | // clearly not becoming visible here. |
| 677 | if (is_hidden_) |
| 678 | RenderThreadImpl::current()->WidgetRestored(); |
dcheng | d96a27a | 2015-07-24 20:17:32 | [diff] [blame] | 679 | RenderThreadImpl::current()->WidgetDestroyed(); |
danakj | 678f025 | 2018-11-09 21:46:34 | [diff] [blame] | 680 | } |
dcheng | d96a27a | 2015-07-24 20:17:32 | [diff] [blame] | 681 | } |
| 682 | |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 683 | if (for_child_local_root_frame_) { |
dcheng | d96a27a | 2015-07-24 20:17:32 | [diff] [blame] | 684 | // Widgets for frames may be created and closed at any time while the frame |
Ken Buchanan | ed449bb | 2018-02-01 21:02:05 | [diff] [blame] | 685 | // is alive. However, WebWidget must be closed synchronously because frame |
| 686 | // widgets and frames hold pointers to each other. The deferred call to |
| 687 | // Close() will complete cleanup and release |this|, but CloseWebWidget() |
| 688 | // prevents Close() from attempting to access members of an |
| 689 | // already-deleted frame. |
| 690 | CloseWebWidget(); |
dcheng | d96a27a | 2015-07-24 20:17:32 | [diff] [blame] | 691 | } |
Ken Buchanan | ed449bb | 2018-02-01 21:02:05 | [diff] [blame] | 692 | // If there is a Send call on the stack, then it could be dangerous to close |
| 693 | // now. Post a task that only gets invoked when there are no nested message |
| 694 | // loops. |
Hajime Hoshi | 315a61f | 2018-08-14 17:27:28 | [diff] [blame] | 695 | GetCleanupTaskRunner()->PostNonNestableTask( |
| 696 | FROM_HERE, base::BindOnce(&RenderWidget::Close, this)); |
dcheng | d96a27a | 2015-07-24 20:17:32 | [diff] [blame] | 697 | |
| 698 | // Balances the AddRef taken when we called AddRoute. |
| 699 | Release(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 700 | } |
| 701 | |
Fady Samuel | 799e7219 | 2018-04-25 21:16:57 | [diff] [blame] | 702 | void RenderWidget::OnSynchronizeVisualProperties( |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 703 | const VisualProperties& original_params) { |
| 704 | TRACE_EVENT0("renderer", "RenderWidget::OnSynchronizeVisualProperties"); |
EhsanK | bd2cea99 | 2017-11-23 18:49:08 | [diff] [blame] | 705 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 706 | VisualProperties params = original_params; |
| 707 | if (owner_delegate_) { |
| 708 | owner_delegate_->ApplyNewSizeForWidget(size_, params.new_size); |
| 709 | |
| 710 | if (display_mode_ != params.display_mode) { |
| 711 | display_mode_ = params.display_mode; |
| 712 | owner_delegate_->ApplyNewDisplayModeForWidget(params.display_mode); |
| 713 | } |
| 714 | |
| 715 | bool auto_resize_mode_changed = |
| 716 | auto_resize_mode_ != params.auto_resize_enabled; |
| 717 | auto_resize_mode_ = params.auto_resize_enabled; |
| 718 | min_size_for_auto_resize_ = params.min_size_for_auto_resize; |
| 719 | max_size_for_auto_resize_ = params.max_size_for_auto_resize; |
| 720 | |
| 721 | if (auto_resize_mode_) { |
| 722 | gfx::Size min_auto_size = min_size_for_auto_resize_; |
| 723 | gfx::Size max_auto_size = max_size_for_auto_resize_; |
| 724 | if (compositor_deps_->IsUseZoomForDSFEnabled()) { |
| 725 | min_auto_size = gfx::ScaleToCeiledSize( |
| 726 | min_auto_size, params.screen_info.device_scale_factor); |
| 727 | max_auto_size = gfx::ScaleToCeiledSize( |
| 728 | max_auto_size, params.screen_info.device_scale_factor); |
| 729 | } |
| 730 | owner_delegate_->ApplyAutoResizeLimitsForWidget(min_auto_size, |
| 731 | max_auto_size); |
| 732 | } else if (auto_resize_mode_changed) { |
| 733 | owner_delegate_->DisableAutoResizeForWidget(); |
| 734 | if (params.new_size.IsEmpty()) |
| 735 | return; |
| 736 | } |
| 737 | |
| 738 | browser_controls_shrink_blink_size_ = |
| 739 | params.browser_controls_shrink_blink_size; |
| 740 | top_controls_height_ = params.top_controls_height; |
| 741 | bottom_controls_height_ = params.bottom_controls_height; |
| 742 | |
| 743 | // TODO(fsamuel): Modifies the |params| that are used for |
| 744 | // SynchronizeVisualProperties(), but does not used this modified |
| 745 | // device_scale_factor for the auto-resize values, which is probably a bug. |
| 746 | if (device_scale_factor_for_testing_) { |
| 747 | params.screen_info.device_scale_factor = |
| 748 | *device_scale_factor_for_testing_; |
| 749 | params.compositor_viewport_pixel_size = gfx::ScaleToCeiledSize( |
| 750 | params.new_size, params.screen_info.device_scale_factor); |
| 751 | } |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 752 | } |
| 753 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 754 | if (!resizing_mode_selector_->ShouldAbortOnResize(this, params)) { |
| 755 | if (screen_metrics_emulator_) { |
| 756 | screen_metrics_emulator_->OnSynchronizeVisualProperties(params); |
| 757 | } else { |
| 758 | gfx::Size old_visible_viewport_size = visible_viewport_size_; |
| 759 | SynchronizeVisualProperties(params); |
| 760 | if (old_visible_viewport_size != visible_viewport_size_) { |
| 761 | for (auto& render_frame : render_frames_) |
| 762 | render_frame.DidChangeVisibleViewport(); |
| 763 | } |
| 764 | } |
Fady Samuel | 799e7219 | 2018-04-25 21:16:57 | [diff] [blame] | 765 | } |
| 766 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 767 | if (owner_delegate_ && params.scroll_focused_node_into_view) |
| 768 | owner_delegate_->ScrollFocusedNodeIntoViewForWidget(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 769 | } |
| 770 | |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 771 | void RenderWidget::OnEnableDeviceEmulation( |
Lei Zhang | 9b359d3 | 2017-11-28 00:57:02 | [diff] [blame] | 772 | const blink::WebDeviceEmulationParams& params) { |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 773 | if (!screen_metrics_emulator_) { |
Fady Samuel | 4255c18 | 2018-05-24 20:42:36 | [diff] [blame] | 774 | VisualProperties visual_properties; |
| 775 | visual_properties.screen_info = screen_info_; |
| 776 | visual_properties.new_size = size_; |
| 777 | visual_properties.compositor_viewport_pixel_size = |
Christopher Cameron | aad15a0d | 2018-03-09 03:47:33 | [diff] [blame] | 778 | compositor_viewport_pixel_size_; |
Fady Samuel | 84d8a1f7 | 2018-11-08 00:26:17 | [diff] [blame] | 779 | visual_properties.local_surface_id_allocation = |
| 780 | local_surface_id_allocation_from_parent_; |
Fady Samuel | 4255c18 | 2018-05-24 20:42:36 | [diff] [blame] | 781 | visual_properties.visible_viewport_size = visible_viewport_size_; |
| 782 | visual_properties.is_fullscreen_granted = is_fullscreen_granted_; |
| 783 | visual_properties.display_mode = display_mode_; |
W. James MacLean | 2a90bff | 2018-11-05 20:52:47 | [diff] [blame] | 784 | visual_properties.page_scale_factor = page_scale_factor_from_mainframe_; |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 785 | screen_metrics_emulator_.reset(new RenderWidgetScreenMetricsEmulator( |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 786 | this, params, visual_properties, widget_screen_rect_, |
Fady Samuel | 4255c18 | 2018-05-24 20:42:36 | [diff] [blame] | 787 | window_screen_rect_)); |
oshima | 50872a7 | 2016-03-04 13:26:18 | [diff] [blame] | 788 | screen_metrics_emulator_->Apply(); |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 789 | } else { |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 790 | screen_metrics_emulator_->ChangeEmulationParams(params); |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 791 | } |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 792 | } |
| 793 | |
| 794 | void RenderWidget::OnDisableDeviceEmulation() { |
| 795 | screen_metrics_emulator_.reset(); |
| 796 | } |
| 797 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 798 | void RenderWidget::OnWasHidden() { |
[email protected] | 9c3085f | 2011-06-09 02:10:31 | [diff] [blame] | 799 | TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden"); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 800 | // Go into a mode where we stop generating paint and scrolling events. |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 801 | SetHidden(true); |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 802 | for (auto& observer : render_frames_) |
| 803 | observer.WasHidden(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 804 | } |
| 805 | |
Saman Sami | e61e5c03 | 2018-11-05 22:11:44 | [diff] [blame] | 806 | void RenderWidget::OnWasShown(base::TimeTicks show_request_timestamp, |
| 807 | bool was_evicted) { |
[email protected] | 9e2e463 | 2012-07-27 16:38:41 | [diff] [blame] | 808 | TRACE_EVENT0("renderer", "RenderWidget::OnWasShown"); |
danakj | 73063d16 | 2018-11-13 22:51:54 | [diff] [blame] | 809 | // TODO(crbug.com/896836): CHECK to try track down why we make a frame sink |
| 810 | // for a RenderWidget without a main frame. |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 811 | CHECK(!is_frozen_); |
danakj | 678f025 | 2018-11-09 21:46:34 | [diff] [blame] | 812 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 813 | // During shutdown we can just ignore this message. |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 814 | if (!GetWebWidget()) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 815 | return; |
| 816 | |
tasak | b95dbb50c | 2017-02-08 18:07:50 | [diff] [blame] | 817 | was_shown_time_ = base::TimeTicks::Now(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 818 | // See OnWasHidden |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 819 | SetHidden(false); |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 820 | for (auto& observer : render_frames_) |
| 821 | observer.WasShown(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 822 | |
Saman Sami | e61e5c03 | 2018-11-05 22:11:44 | [diff] [blame] | 823 | if (was_evicted) { |
| 824 | for (auto& observer : render_frame_proxies_) { |
| 825 | observer.WasEvicted(); |
| 826 | } |
| 827 | } |
| 828 | |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 829 | if (layer_tree_view_ && !show_request_timestamp.is_null()) { |
| 830 | layer_tree_view_->layer_tree_host()->RequestPresentationTimeForNextFrame( |
Sadrul Habib Chowdhury | 8bc43cc | 2018-06-06 01:48:03 | [diff] [blame] | 831 | CreateTabSwitchingTimeRecorder(show_request_timestamp)); |
[email protected] | 3399dd82 | 2014-08-09 11:14:24 | [diff] [blame] | 832 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 833 | } |
| 834 | |
Avi Drissman | 014dec7 | 2018-06-07 02:34:01 | [diff] [blame] | 835 | void RenderWidget::OnRequestSetBoundsAck() { |
[email protected] | 53d3f30 | 2009-12-21 04:42:05 | [diff] [blame] | 836 | DCHECK(pending_window_rect_count_); |
| 837 | pending_window_rect_count_--; |
| 838 | } |
| 839 | |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 840 | void RenderWidget::OnForceRedraw(int snapshot_id) { |
| 841 | if (LayerTreeView* ltv = layer_tree_view()) { |
| 842 | ltv->layer_tree_host()->RequestPresentationTimeForNextFrame( |
| 843 | base::BindOnce(&RenderWidget::DidPresentForceDrawFrame, |
| 844 | weak_ptr_factory_.GetWeakPtr(), snapshot_id)); |
| 845 | ltv->SetNeedsForcedRedraw(); |
| 846 | } |
| 847 | } |
| 848 | |
| 849 | void RenderWidget::DidPresentForceDrawFrame( |
| 850 | int snapshot_id, |
| 851 | const gfx::PresentationFeedback& feedback) { |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 852 | Send(new WidgetHostMsg_ForceRedrawComplete(routing_id(), snapshot_id)); |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 853 | } |
| 854 | |
Xianzhu Wang | f02017ac | 2018-10-17 01:47:33 | [diff] [blame] | 855 | viz::FrameSinkId RenderWidget::GetFrameSinkIdAtPoint(const gfx::PointF& point, |
Ken Buchanan | 44d7e2f | 2018-08-23 14:18:05 | [diff] [blame] | 856 | gfx::PointF* local_point) { |
| 857 | return input_handler_->GetFrameSinkIdAtPoint(point, local_point); |
Navid Zolghadr | 0d86e5f | 2017-10-23 18:09:22 | [diff] [blame] | 858 | } |
| 859 | |
Dave Tapuska | ea83d3bd | 2017-06-13 16:14:55 | [diff] [blame] | 860 | void RenderWidget::HandleInputEvent( |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 861 | const blink::WebCoalescedInputEvent& input_event, |
| 862 | const ui::LatencyInfo& latency_info, |
Dave Tapuska | ea83d3bd | 2017-06-13 16:14:55 | [diff] [blame] | 863 | HandledEventCallback callback) { |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 864 | if (owner_delegate_ && is_frozen_) { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 865 | std::move(callback).Run(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, latency_info, |
| 866 | nullptr, base::nullopt); |
| 867 | return; |
| 868 | } |
Dave Tapuska | ea83d3bd | 2017-06-13 16:14:55 | [diff] [blame] | 869 | input_handler_->HandleInputEvent(input_event, latency_info, |
| 870 | std::move(callback)); |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 871 | } |
| 872 | |
dtapuska | 9d46ef7d | 2017-05-26 19:06:06 | [diff] [blame] | 873 | scoped_refptr<MainThreadEventQueue> RenderWidget::GetInputEventQueue() { |
| 874 | return input_event_queue_; |
| 875 | } |
| 876 | |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 877 | void RenderWidget::OnCursorVisibilityChange(bool is_visible) { |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 878 | if (GetWebWidget()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 879 | GetWebWidget()->SetCursorVisibilityState(is_visible); |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 880 | } |
| 881 | |
| 882 | void RenderWidget::OnMouseCaptureLost() { |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 883 | if (GetWebWidget()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 884 | GetWebWidget()->MouseCaptureLost(); |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 885 | } |
| 886 | |
alexmos | 5656749 | 2016-09-13 00:52:46 | [diff] [blame] | 887 | void RenderWidget::OnSetEditCommandsForNextKeyEvent( |
| 888 | const EditCommands& edit_commands) { |
| 889 | edit_commands_ = edit_commands; |
| 890 | } |
| 891 | |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 892 | void RenderWidget::OnSetActive(bool active) { |
| 893 | if (owner_delegate_) |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 894 | owner_delegate_->SetActiveForWidget(active); |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 895 | } |
| 896 | |
| 897 | void RenderWidget::OnSetBackgroundOpaque(bool opaque) { |
danakj | 0ba0e7b | 2018-09-25 19:37:13 | [diff] [blame] | 898 | // Background opaque-ness modification is only supported for the main frame. |
| 899 | // The |owner_delegate_| is used as proxy for this RenderWidget being attached |
| 900 | // to the main frame. |
| 901 | if (!owner_delegate_) |
| 902 | return; |
| 903 | |
| 904 | blink::WebWidget* web_widget = GetWebWidget(); |
| 905 | // This is true since we only do this for RenderWidgets attached to the main |
| 906 | // frame. |
| 907 | DCHECK(web_widget->IsWebFrameWidget()); |
| 908 | auto* web_frame_widget = static_cast<blink::WebFrameWidget*>(web_widget); |
| 909 | if (opaque) { |
| 910 | web_frame_widget->ClearBaseBackgroundColorOverride(); |
| 911 | web_frame_widget->ClearBackgroundColorOverride(); |
| 912 | } else { |
| 913 | web_frame_widget->SetBaseBackgroundColorOverride(SK_ColorTRANSPARENT); |
| 914 | web_frame_widget->SetBackgroundColorOverride(SK_ColorTRANSPARENT); |
| 915 | } |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 916 | } |
| 917 | |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 918 | void RenderWidget::OnSetFocus(bool enable) { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 919 | if (owner_delegate_) |
| 920 | owner_delegate_->DidReceiveSetFocusEventForWidget(); |
| 921 | SetFocus(enable); |
| 922 | } |
| 923 | |
| 924 | void RenderWidget::SetFocus(bool enable) { |
lfg | e0c2792ec | 2016-05-11 18:52:08 | [diff] [blame] | 925 | has_focus_ = enable; |
| 926 | |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 927 | if (GetWebWidget()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 928 | GetWebWidget()->SetFocus(enable); |
lfg | e0c2792ec | 2016-05-11 18:52:08 | [diff] [blame] | 929 | |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 930 | for (auto& observer : render_frames_) |
| 931 | observer.RenderWidgetSetFocus(enable); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 932 | |
| 933 | if (owner_delegate_) |
| 934 | owner_delegate_->DidChangeFocusForWidget(); |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 935 | } |
| 936 | |
dtapuska | 3d5624d3 | 2016-08-30 04:34:00 | [diff] [blame] | 937 | void RenderWidget::SetNeedsMainFrame() { |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 938 | LayerTreeView* ltv = layer_tree_view(); |
| 939 | if (!ltv) |
dtapuska | 3d5624d3 | 2016-08-30 04:34:00 | [diff] [blame] | 940 | return; |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 941 | ltv->SetNeedsBeginFrame(); |
dtapuska | 3d5624d3 | 2016-08-30 04:34:00 | [diff] [blame] | 942 | } |
| 943 | |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 944 | /////////////////////////////////////////////////////////////////////////////// |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 945 | // LayerTreeViewDelegate |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 946 | |
David Bokan | c8e38d0 | 2018-10-08 21:56:01 | [diff] [blame] | 947 | void RenderWidget::ApplyViewportChanges( |
| 948 | const cc::ApplyViewportChangesArgs& args) { |
Ken Buchanan | ed449bb | 2018-02-01 21:02:05 | [diff] [blame] | 949 | if (!GetWebWidget()) |
| 950 | return; |
David Bokan | c8e38d0 | 2018-10-08 21:56:01 | [diff] [blame] | 951 | GetWebWidget()->ApplyViewportChanges(args); |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 952 | } |
| 953 | |
sahel | 1b47fda7 | 2017-03-28 17:03:07 | [diff] [blame] | 954 | void RenderWidget::RecordWheelAndTouchScrollingCount( |
| 955 | bool has_scrolled_by_wheel, |
| 956 | bool has_scrolled_by_touch) { |
Ken Buchanan | ed449bb | 2018-02-01 21:02:05 | [diff] [blame] | 957 | if (!GetWebWidget()) |
| 958 | return; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 959 | GetWebWidget()->RecordWheelAndTouchScrollingCount(has_scrolled_by_wheel, |
sahel | 1b47fda7 | 2017-03-28 17:03:07 | [diff] [blame] | 960 | has_scrolled_by_touch); |
| 961 | } |
| 962 | |
Daniel Cheng | 224569ee | 2018-04-25 05:45:06 | [diff] [blame] | 963 | void RenderWidget::BeginMainFrame(base::TimeTicks frame_time) { |
Ken Buchanan | ed449bb | 2018-02-01 21:02:05 | [diff] [blame] | 964 | if (!GetWebWidget()) |
| 965 | return; |
Daniel Cheng | 224569ee | 2018-04-25 05:45:06 | [diff] [blame] | 966 | if (input_event_queue_) |
| 967 | input_event_queue_->DispatchRafAlignedInput(frame_time); |
dtapuska | 3d5624d3 | 2016-08-30 04:34:00 | [diff] [blame] | 968 | |
Daniel Cheng | 224569ee | 2018-04-25 05:45:06 | [diff] [blame] | 969 | GetWebWidget()->BeginFrame(frame_time); |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 970 | } |
| 971 | |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 972 | void RenderWidget::RequestNewLayerTreeFrameSink( |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 973 | LayerTreeFrameSinkCallback callback) { |
[email protected] | 7912e82 | 2014-04-16 02:37:03 | [diff] [blame] | 974 | // For widgets that are never visible, we don't start the compositor, so we |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 975 | // never get a request for a cc::LayerTreeFrameSink. |
sievers | 71c62dd5 | 2015-10-07 01:44:39 | [diff] [blame] | 976 | DCHECK(!compositor_never_visible_); |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 977 | // Inactive RenderWidgets should not be doing any compositing. |
| 978 | DCHECK(!is_frozen_); |
danakj | 678f025 | 2018-11-09 21:46:34 | [diff] [blame] | 979 | |
| 980 | if (is_closing()) { |
| 981 | // In this case, we drop the request which means the compositor waits |
| 982 | // forever, which is fine since we're going to destroy it. |
| 983 | return; |
| 984 | } |
jonross | a2ff4f8 | 2018-02-16 17:27:46 | [diff] [blame] | 985 | |
danakj | 73063d16 | 2018-11-13 22:51:54 | [diff] [blame] | 986 | // TODO(crbug.com/896836): CHECK to try track down why we make a frame sink |
| 987 | // for a RenderWidget without a main frame. If there's no frame widget then |
| 988 | // there is no main frame. This only applies for widgets for frames. |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 989 | CHECK(!is_frozen_); |
danakj | 73063d16 | 2018-11-13 22:51:54 | [diff] [blame] | 990 | if (owner_delegate_) |
| 991 | CHECK(GetFrameWidget()); |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 992 | if (for_child_local_root_frame_) |
danakj | 73063d16 | 2018-11-13 22:51:54 | [diff] [blame] | 993 | CHECK(GetFrameWidget()); |
| 994 | |
jonross | a2ff4f8 | 2018-02-16 17:27:46 | [diff] [blame] | 995 | // TODO(jonross): have this generated by the LayerTreeFrameSink itself, which |
| 996 | // would then handle binding. |
| 997 | mojom::RenderFrameMetadataObserverPtr ptr; |
| 998 | mojom::RenderFrameMetadataObserverRequest request = mojo::MakeRequest(&ptr); |
| 999 | mojom::RenderFrameMetadataObserverClientPtrInfo client_info; |
| 1000 | mojom::RenderFrameMetadataObserverClientRequest client_request = |
| 1001 | mojo::MakeRequest(&client_info); |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 1002 | auto render_frame_metadata_observer = |
| 1003 | std::make_unique<RenderFrameMetadataObserverImpl>(std::move(request), |
| 1004 | std::move(client_info)); |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 1005 | layer_tree_view_->SetRenderFrameObserver( |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 1006 | std::move(render_frame_metadata_observer)); |
danakj | efabf31 | 2018-10-05 19:03:07 | [diff] [blame] | 1007 | GURL url = GetWebWidget()->GetURLForDebugTrace(); |
| 1008 | // The |url| is not always available, fallback to a fixed string. |
| 1009 | if (url.is_empty()) |
| 1010 | url = GURL("chrome://gpu/RenderWidget::RequestNewLayerTreeFrameSink"); |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 1011 | // TODO(danakj): This may not be accurate, depending on the intent. A child |
| 1012 | // local root could be in the same process as the view, so if the client is |
| 1013 | // meant to designate the process type, it seems kRenderer would be the |
| 1014 | // correct choice. If client is meant to designate the widget type, then |
| 1015 | // kOOPIF would denote that it is not for the main frame. However, kRenderer |
| 1016 | // would also be used for other widgets such as popups. |
| 1017 | const char* client_name = for_child_local_root_frame_ ? kOOPIF : kRenderer; |
danakj | c7afae5 | 2017-06-20 21:12:41 | [diff] [blame] | 1018 | RenderThreadImpl::current()->RequestNewLayerTreeFrameSink( |
danakj | efabf31 | 2018-10-05 19:03:07 | [diff] [blame] | 1019 | routing_id_, frame_swap_message_queue_, std::move(url), |
yiyix | 6b90ef5 | 2018-10-09 19:55:30 | [diff] [blame] | 1020 | std::move(callback), std::move(client_request), std::move(ptr), |
| 1021 | client_name); |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 1022 | } |
| 1023 | |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 1024 | void RenderWidget::DidCommitAndDrawCompositorFrame() { |
| 1025 | // NOTE: Tests may break if this event is renamed or moved. See |
| 1026 | // tab_capture_performancetest.cc. |
| 1027 | TRACE_EVENT0("gpu", "RenderWidget::DidCommitAndDrawCompositorFrame"); |
lfg | e0c2792ec | 2016-05-11 18:52:08 | [diff] [blame] | 1028 | |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 1029 | for (auto& observer : render_frames_) |
| 1030 | observer.DidCommitAndDrawCompositorFrame(); |
lfg | e0c2792ec | 2016-05-11 18:52:08 | [diff] [blame] | 1031 | |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 1032 | // Notify subclasses that we initiated the paint operation. |
| 1033 | DidInitiatePaint(); |
Yiming Zhou | 0f8836c2 | 2018-09-13 22:22:11 | [diff] [blame] | 1034 | |
Albert J. Wong | fb64e14 | 2018-10-16 01:10:45 | [diff] [blame] | 1035 | Send(new WidgetHostMsg_DidCommitAndDrawCompositorFrame(routing_id_)); |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 1036 | } |
| 1037 | |
Saman Sami | 766e0b0 | 2018-01-31 17:19:20 | [diff] [blame] | 1038 | void RenderWidget::DidCommitCompositorFrame() { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1039 | if (owner_delegate_) |
| 1040 | owner_delegate_->DidCommitCompositorFrameForWidget(); |
Saman Sami | 766e0b0 | 2018-01-31 17:19:20 | [diff] [blame] | 1041 | } |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 1042 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1043 | void RenderWidget::DidCompletePageScaleAnimation() { |
| 1044 | if (owner_delegate_) |
| 1045 | owner_delegate_->DidCompletePageScaleAnimationForWidget(); |
| 1046 | } |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 1047 | |
danakj | 53eccbc | 2016-03-02 22:51:07 | [diff] [blame] | 1048 | void RenderWidget::RequestScheduleAnimation() { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1049 | if (owner_delegate_) { |
| 1050 | owner_delegate_->RequestScheduleAnimationForWidget(); |
| 1051 | return; |
| 1052 | } |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1053 | ScheduleAnimation(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1054 | } |
| 1055 | |
Robert Flack | 3ef2ffb | 2018-09-06 20:38:20 | [diff] [blame] | 1056 | void RenderWidget::UpdateVisualState() { |
Ken Buchanan | ed449bb | 2018-02-01 21:02:05 | [diff] [blame] | 1057 | if (!GetWebWidget()) |
| 1058 | return; |
| 1059 | |
Robert Flack | 3ef2ffb | 2018-09-06 20:38:20 | [diff] [blame] | 1060 | GetWebWidget()->UpdateLifecycle(WebWidget::LifecycleUpdate::kAll); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1061 | GetWebWidget()->SetSuppressFrameRequestsWorkaroundFor704763Only(false); |
tasak | b95dbb50c | 2017-02-08 18:07:50 | [diff] [blame] | 1062 | |
Robert Flack | 3ef2ffb | 2018-09-06 20:38:20 | [diff] [blame] | 1063 | if (first_update_visual_state_after_hidden_) { |
Takashi SAKAMOTO | 870f626 | 2017-08-22 04:08:27 | [diff] [blame] | 1064 | RecordTimeToFirstActivePaint(); |
| 1065 | first_update_visual_state_after_hidden_ = false; |
| 1066 | } |
| 1067 | } |
tasak | b95dbb50c | 2017-02-08 18:07:50 | [diff] [blame] | 1068 | |
Takashi SAKAMOTO | 870f626 | 2017-08-22 04:08:27 | [diff] [blame] | 1069 | void RenderWidget::RecordTimeToFirstActivePaint() { |
tasak | b95dbb50c | 2017-02-08 18:07:50 | [diff] [blame] | 1070 | RenderThreadImpl* render_thread_impl = RenderThreadImpl::current(); |
tasak | b95dbb50c | 2017-02-08 18:07:50 | [diff] [blame] | 1071 | base::TimeDelta sample = base::TimeTicks::Now() - was_shown_time_; |
Takashi SAKAMOTO | 870f626 | 2017-08-22 04:08:27 | [diff] [blame] | 1072 | if (render_thread_impl->NeedsToRecordFirstActivePaint(TTFAP_AFTER_PURGED)) { |
| 1073 | UMA_HISTOGRAM_TIMES("PurgeAndSuspend.Experimental.TimeToFirstActivePaint", |
| 1074 | sample); |
| 1075 | } |
| 1076 | if (render_thread_impl->NeedsToRecordFirstActivePaint( |
| 1077 | TTFAP_5MIN_AFTER_BACKGROUNDED)) { |
| 1078 | UMA_HISTOGRAM_TIMES( |
| 1079 | "PurgeAndSuspend.Experimental.TimeToFirstActivePaint." |
| 1080 | "AfterBackgrounded.5min", |
| 1081 | sample); |
| 1082 | } |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 1083 | } |
| 1084 | |
Stephen Chenney | 9879a5c | 2018-09-26 14:21:42 | [diff] [blame] | 1085 | void RenderWidget::RecordEndOfFrameMetrics(base::TimeTicks frame_begin_time) { |
| 1086 | if (!GetWebWidget()) |
| 1087 | return; |
| 1088 | |
| 1089 | GetWebWidget()->RecordEndOfFrameMetrics(frame_begin_time); |
| 1090 | } |
| 1091 | |
fsamuel | 78f86e4 | 2016-01-20 04:10:23 | [diff] [blame] | 1092 | void RenderWidget::WillBeginCompositorFrame() { |
| 1093 | TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
| 1094 | |
Ken Buchanan | ed449bb | 2018-02-01 21:02:05 | [diff] [blame] | 1095 | if (!GetWebWidget()) |
| 1096 | return; |
| 1097 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1098 | GetWebWidget()->SetSuppressFrameRequestsWorkaroundFor704763Only(true); |
alancutter | 317a8e0 | 2017-04-05 10:09:29 | [diff] [blame] | 1099 | |
dglazkov | 06854c5c | 2016-08-31 00:19:59 | [diff] [blame] | 1100 | // The UpdateTextInputState can result in further layout and possibly |
| 1101 | // enable GPU acceleration so they need to be called before any painting |
| 1102 | // is done. |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 1103 | UpdateTextInputState(); |
dglazkov | 06854c5c | 2016-08-31 00:19:59 | [diff] [blame] | 1104 | UpdateSelectionBounds(); |
| 1105 | |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 1106 | for (auto& observer : render_frame_proxies_) |
| 1107 | observer.WillBeginCompositorFrame(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1108 | } |
| 1109 | |
jbroman | 6ccbc7d47 | 2016-07-27 04:45:41 | [diff] [blame] | 1110 | std::unique_ptr<cc::SwapPromise> RenderWidget::RequestCopyOfOutputForLayoutTest( |
Fady Samuel | dfecb7d | 2017-07-26 11:41:04 | [diff] [blame] | 1111 | std::unique_ptr<viz::CopyOutputRequest> request) { |
jbroman | 6ccbc7d47 | 2016-07-27 04:45:41 | [diff] [blame] | 1112 | return RenderThreadImpl::current()->RequestCopyOfOutputForLayoutTest( |
| 1113 | routing_id_, std::move(request)); |
| 1114 | } |
| 1115 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1116 | /////////////////////////////////////////////////////////////////////////////// |
| 1117 | // RenderWidgetInputHandlerDelegate |
| 1118 | |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1119 | void RenderWidget::FocusChangeComplete() { |
Ehsan Karamad | 655d7b8a | 2018-01-12 18:38:38 | [diff] [blame] | 1120 | blink::WebFrameWidget* frame_widget = GetFrameWidget(); |
| 1121 | if (!frame_widget) |
ekaramad | 27ca69b1 | 2017-04-20 18:34:29 | [diff] [blame] | 1122 | return; |
Ehsan Karamad | 655d7b8a | 2018-01-12 18:38:38 | [diff] [blame] | 1123 | |
ekaramad | 27ca69b1 | 2017-04-20 18:34:29 | [diff] [blame] | 1124 | blink::WebLocalFrame* focused = |
Ehsan Karamad | 655d7b8a | 2018-01-12 18:38:38 | [diff] [blame] | 1125 | frame_widget->LocalRoot()->View()->FocusedFrame(); |
| 1126 | |
ekaramad | 27ca69b1 | 2017-04-20 18:34:29 | [diff] [blame] | 1127 | if (focused && focused->AutofillClient()) |
| 1128 | focused->AutofillClient()->DidCompleteFocusChangeInFrame(); |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1129 | } |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1130 | |
dtapuska | 1827dd2 | 2016-03-11 15:24:59 | [diff] [blame] | 1131 | void RenderWidget::ObserveGestureEventAndResult( |
| 1132 | const blink::WebGestureEvent& gesture_event, |
| 1133 | const gfx::Vector2dF& unused_delta, |
Sandra Sun | ac5cdd83 | 2017-12-11 03:27:13 | [diff] [blame] | 1134 | const cc::OverscrollBehavior& overscroll_behavior, |
dtapuska | 1827dd2 | 2016-03-11 15:24:59 | [diff] [blame] | 1135 | bool event_processed) { |
| 1136 | if (!compositor_deps_->IsElasticOverscrollEnabled()) |
| 1137 | return; |
| 1138 | |
| 1139 | cc::InputHandlerScrollResult scroll_result; |
| 1140 | scroll_result.did_scroll = event_processed; |
| 1141 | scroll_result.did_overscroll_root = !unused_delta.IsZero(); |
| 1142 | scroll_result.unused_scroll_delta = unused_delta; |
Sandra Sun | ac5cdd83 | 2017-12-11 03:27:13 | [diff] [blame] | 1143 | scroll_result.overscroll_behavior = overscroll_behavior; |
dtapuska | 1827dd2 | 2016-03-11 15:24:59 | [diff] [blame] | 1144 | |
Dave Tapuska | 04bc5ee9 | 2018-04-17 19:03:31 | [diff] [blame] | 1145 | widget_input_handler_manager_->ObserveGestureEventOnMainThread(gesture_event, |
| 1146 | scroll_result); |
dtapuska | 1827dd2 | 2016-03-11 15:24:59 | [diff] [blame] | 1147 | } |
| 1148 | |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1149 | void RenderWidget::OnDidHandleKeyEvent() { |
alexmos | 5656749 | 2016-09-13 00:52:46 | [diff] [blame] | 1150 | ClearEditCommands(); |
| 1151 | } |
| 1152 | |
| 1153 | void RenderWidget::SetEditCommandForNextKeyEvent(const std::string& name, |
| 1154 | const std::string& value) { |
| 1155 | ClearEditCommands(); |
| 1156 | edit_commands_.emplace_back(name, value); |
| 1157 | } |
| 1158 | |
| 1159 | void RenderWidget::ClearEditCommands() { |
| 1160 | edit_commands_.clear(); |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1161 | } |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1162 | |
chongz | a8ba91fc | 2016-08-16 21:39:17 | [diff] [blame] | 1163 | void RenderWidget::OnDidOverscroll(const ui::DidOverscrollParams& params) { |
Dave Tapuska | 04bc5ee9 | 2018-04-17 19:03:31 | [diff] [blame] | 1164 | if (mojom::WidgetInputHandlerHost* host = |
| 1165 | widget_input_handler_manager_->GetWidgetInputHandlerHost()) { |
| 1166 | host->DidOverscroll(params); |
Dave Tapuska | 139a72f | 2017-09-06 21:57:03 | [diff] [blame] | 1167 | } |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1168 | } |
| 1169 | |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1170 | void RenderWidget::SetInputHandler(RenderWidgetInputHandler* input_handler) { |
| 1171 | // Nothing to do here. RenderWidget created the |input_handler| and will take |
| 1172 | // ownership of it. We just verify here that we don't already have an input |
| 1173 | // handler. |
| 1174 | DCHECK(!input_handler_); |
| 1175 | } |
| 1176 | |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 1177 | void RenderWidget::ShowVirtualKeyboard() { |
| 1178 | UpdateTextInputStateInternal(true, false); |
| 1179 | } |
| 1180 | |
changwan | 62f5729 | 2017-02-17 08:28:25 | [diff] [blame] | 1181 | void RenderWidget::ClearTextInputState() { |
| 1182 | text_input_info_ = blink::WebTextInputInfo(); |
| 1183 | text_input_type_ = ui::TextInputType::TEXT_INPUT_TYPE_NONE; |
| 1184 | text_input_mode_ = ui::TextInputMode::TEXT_INPUT_MODE_DEFAULT; |
| 1185 | can_compose_inline_ = false; |
| 1186 | text_input_flags_ = 0; |
AJITH KUMAR V | 041c0b0 | 2017-08-08 10:39:20 | [diff] [blame] | 1187 | next_previous_flags_ = kInvalidNextPreviousFlagsValue; |
changwan | 62f5729 | 2017-02-17 08:28:25 | [diff] [blame] | 1188 | } |
| 1189 | |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 1190 | void RenderWidget::UpdateTextInputState() { |
| 1191 | UpdateTextInputStateInternal(false, false); |
| 1192 | } |
| 1193 | |
| 1194 | void RenderWidget::UpdateTextInputStateInternal(bool show_virtual_keyboard, |
| 1195 | bool reply_to_request) { |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1196 | TRACE_EVENT0("renderer", "RenderWidget::UpdateTextInputState"); |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 1197 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1198 | if (ime_event_guard_) { |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 1199 | DCHECK(!reply_to_request); |
| 1200 | // show_virtual_keyboard should still be effective even if it was set inside |
| 1201 | // the IME |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1202 | // event guard. |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 1203 | if (show_virtual_keyboard) |
| 1204 | ime_event_guard_->set_show_virtual_keyboard(true); |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1205 | return; |
| 1206 | } |
| 1207 | |
dglazkov | 97b6c2b | 2016-10-25 17:35:55 | [diff] [blame] | 1208 | ui::TextInputType new_type = GetTextInputType(); |
| 1209 | if (IsDateTimeInput(new_type)) |
| 1210 | return; // Not considered as a text input field in WebKit/Chromium. |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1211 | |
dglazkov | 97b6c2b | 2016-10-25 17:35:55 | [diff] [blame] | 1212 | blink::WebTextInputInfo new_info; |
ekaramad | 5aff194 | 2017-01-06 01:26:35 | [diff] [blame] | 1213 | if (auto* controller = GetInputMethodController()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1214 | new_info = controller->TextInputInfo(); |
dtapuska | c4dd5be | 2016-10-25 15:11:10 | [diff] [blame] | 1215 | const ui::TextInputMode new_mode = |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1216 | ConvertWebTextInputMode(new_info.input_mode); |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1217 | |
| 1218 | bool new_can_compose_inline = CanComposeInline(); |
| 1219 | |
| 1220 | // Only sends text input params if they are changed or if the ime should be |
| 1221 | // shown. |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 1222 | if (show_virtual_keyboard || reply_to_request || |
changwan | 38c3eb61 | 2016-12-09 01:45:56 | [diff] [blame] | 1223 | text_input_type_ != new_type || text_input_mode_ != new_mode || |
| 1224 | text_input_info_ != new_info || |
| 1225 | can_compose_inline_ != new_can_compose_inline) { |
ekaramad | 9053e57b | 2016-04-26 20:00:38 | [diff] [blame] | 1226 | TextInputState params; |
dglazkov | 97b6c2b | 2016-10-25 17:35:55 | [diff] [blame] | 1227 | params.type = new_type; |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1228 | params.mode = new_mode; |
| 1229 | params.flags = new_info.flags; |
AJITH KUMAR V | 9e7b557 | 2017-11-14 00:54:21 | [diff] [blame] | 1230 | #if defined(OS_ANDROID) |
AJITH KUMAR V | 041c0b0 | 2017-08-08 10:39:20 | [diff] [blame] | 1231 | if (next_previous_flags_ == kInvalidNextPreviousFlagsValue) { |
| 1232 | // Due to a focus change, values will be reset by the frame. |
| 1233 | // That case we only need fresh NEXT/PREVIOUS information. |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1234 | // Also we won't send WidgetHostMsg_TextInputStateChanged if next/previous |
AJITH KUMAR V | 041c0b0 | 2017-08-08 10:39:20 | [diff] [blame] | 1235 | // focusable status is changed. |
| 1236 | if (auto* controller = GetInputMethodController()) { |
| 1237 | next_previous_flags_ = |
| 1238 | controller->ComputeWebTextInputNextPreviousFlags(); |
| 1239 | } else { |
| 1240 | // For safety in case GetInputMethodController() is null, because -1 is |
| 1241 | // invalid value to send to browser process. |
| 1242 | next_previous_flags_ = 0; |
| 1243 | } |
| 1244 | } |
AJITH KUMAR V | 9e7b557 | 2017-11-14 00:54:21 | [diff] [blame] | 1245 | #else |
| 1246 | next_previous_flags_ = 0; |
| 1247 | #endif |
AJITH KUMAR V | 041c0b0 | 2017-08-08 10:39:20 | [diff] [blame] | 1248 | params.flags |= next_previous_flags_; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1249 | params.value = new_info.value.Utf8(); |
| 1250 | params.selection_start = new_info.selection_start; |
| 1251 | params.selection_end = new_info.selection_end; |
| 1252 | params.composition_start = new_info.composition_start; |
| 1253 | params.composition_end = new_info.composition_end; |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1254 | params.can_compose_inline = new_can_compose_inline; |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 1255 | // TODO(changwan): change instances of show_ime_if_needed to |
| 1256 | // show_virtual_keyboard. |
| 1257 | params.show_ime_if_needed = show_virtual_keyboard; |
| 1258 | params.reply_to_request = reply_to_request; |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1259 | Send(new WidgetHostMsg_TextInputStateChanged(routing_id(), params)); |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1260 | |
| 1261 | text_input_info_ = new_info; |
dglazkov | 97b6c2b | 2016-10-25 17:35:55 | [diff] [blame] | 1262 | text_input_type_ = new_type; |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1263 | text_input_mode_ = new_mode; |
| 1264 | can_compose_inline_ = new_can_compose_inline; |
| 1265 | text_input_flags_ = new_info.flags; |
| 1266 | } |
| 1267 | } |
| 1268 | |
| 1269 | bool RenderWidget::WillHandleGestureEvent(const blink::WebGestureEvent& event) { |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 1270 | possible_drag_event_info_.event_source = |
| 1271 | ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; |
| 1272 | possible_drag_event_info_.event_location = |
Ella Ge | 1116059d | 2018-03-21 02:06:13 | [diff] [blame] | 1273 | gfx::ToFlooredPoint(event.PositionInScreen()); |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1274 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1275 | return false; |
| 1276 | } |
| 1277 | |
| 1278 | bool RenderWidget::WillHandleMouseEvent(const blink::WebMouseEvent& event) { |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 1279 | for (auto& observer : render_frames_) |
| 1280 | observer.RenderWidgetWillHandleMouseEvent(); |
lfg | e0c2792ec | 2016-05-11 18:52:08 | [diff] [blame] | 1281 | |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 1282 | possible_drag_event_info_.event_source = |
| 1283 | ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE; |
| 1284 | possible_drag_event_info_.event_location = |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1285 | gfx::Point(event.PositionInScreen().x, event.PositionInScreen().y); |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 1286 | |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1287 | if (owner_delegate_) |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1288 | return owner_delegate_->RenderWidgetWillHandleMouseEventForWidget(event); |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1289 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1290 | return false; |
[email protected] | fd84779 | 2013-10-24 17:12:35 | [diff] [blame] | 1291 | } |
| 1292 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1293 | /////////////////////////////////////////////////////////////////////////////// |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1294 | // RenderWidgetScreenMetricsDelegate |
| 1295 | |
| 1296 | void RenderWidget::Redraw() { |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 1297 | if (layer_tree_view_) |
| 1298 | layer_tree_view_->SetNeedsRedrawRect(gfx::Rect(size_)); |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1299 | } |
| 1300 | |
bokan | c63441c | 2016-04-27 15:49:12 | [diff] [blame] | 1301 | void RenderWidget::ResizeWebWidget() { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1302 | gfx::Size size = GetSizeForWebWidget(); |
| 1303 | if (owner_delegate_) { |
| 1304 | owner_delegate_->ResizeWebWidgetForWidget( |
| 1305 | size, top_controls_height_, bottom_controls_height_, |
| 1306 | browser_controls_shrink_blink_size_); |
| 1307 | return; |
| 1308 | } |
| 1309 | GetWebWidget()->Resize(size); |
bokan | c63441c | 2016-04-27 15:49:12 | [diff] [blame] | 1310 | } |
| 1311 | |
| 1312 | gfx::Size RenderWidget::GetSizeForWebWidget() const { |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 1313 | if (compositor_deps_->IsUseZoomForDSFEnabled()) { |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 1314 | return gfx::ScaleToCeiledSize(size_, |
| 1315 | GetOriginalScreenInfo().device_scale_factor); |
| 1316 | } |
bokan | c63441c | 2016-04-27 15:49:12 | [diff] [blame] | 1317 | |
| 1318 | return size_; |
| 1319 | } |
| 1320 | |
akaba | 3483d8f | 2018-07-10 21:43:09 | [diff] [blame] | 1321 | void RenderWidget::UpdateZoom(double zoom_level) { |
akaba | c6bd121 | 2018-06-25 20:10:48 | [diff] [blame] | 1322 | blink::WebFrameWidget* frame_widget = GetFrameWidget(); |
| 1323 | if (!frame_widget) |
| 1324 | return; |
| 1325 | RenderFrameImpl* render_frame = |
| 1326 | RenderFrameImpl::FromWebFrame(frame_widget->LocalRoot()); |
| 1327 | |
akaba | 3483d8f | 2018-07-10 21:43:09 | [diff] [blame] | 1328 | // Return early if zoom level is unchanged. |
| 1329 | if (render_frame->GetZoomLevel() == zoom_level) { |
akaba | c6bd121 | 2018-06-25 20:10:48 | [diff] [blame] | 1330 | return; |
| 1331 | } |
| 1332 | |
akaba | 3483d8f | 2018-07-10 21:43:09 | [diff] [blame] | 1333 | render_frame->SetZoomLevel(zoom_level); |
akaba | c6bd121 | 2018-06-25 20:10:48 | [diff] [blame] | 1334 | |
| 1335 | for (auto& observer : render_frame_proxies_) |
akaba | 3483d8f | 2018-07-10 21:43:09 | [diff] [blame] | 1336 | observer.OnZoomLevelChanged(zoom_level); |
akaba | c6bd121 | 2018-06-25 20:10:48 | [diff] [blame] | 1337 | |
| 1338 | for (auto& plugin : browser_plugins_) |
akaba | 3483d8f | 2018-07-10 21:43:09 | [diff] [blame] | 1339 | plugin.OnZoomLevelChanged(zoom_level); |
akaba | c6bd121 | 2018-06-25 20:10:48 | [diff] [blame] | 1340 | } |
| 1341 | |
Fady Samuel | 799e7219 | 2018-04-25 21:16:57 | [diff] [blame] | 1342 | void RenderWidget::SynchronizeVisualProperties(const VisualProperties& params) { |
Christopher Cameron | be7ecea | 2018-02-27 00:47:19 | [diff] [blame] | 1343 | // Inform the rendering thread of the color space indicate the presence of HDR |
| 1344 | // capabilities. |
Miguel Casas | 5e101805 | 2018-01-09 19:17:36 | [diff] [blame] | 1345 | RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 1346 | if (render_thread) |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 1347 | render_thread->SetRenderingColorSpace(params.screen_info.color_space); |
Miguel Casas | 5e101805 | 2018-01-09 19:17:36 | [diff] [blame] | 1348 | |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1349 | // Ignore this during shutdown. |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 1350 | if (!GetWebWidget()) |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1351 | return; |
| 1352 | |
W. James MacLean | 2a90bff | 2018-11-05 20:52:47 | [diff] [blame] | 1353 | // Only propagate the external PSF to non-main-frames. |
| 1354 | if (!owner_delegate_) |
| 1355 | layer_tree_view_->SetExternalPageScaleFactor(params.page_scale_factor); |
| 1356 | |
Fady Samuel | e62be40 | 2018-03-29 03:19:53 | [diff] [blame] | 1357 | gfx::Size new_compositor_viewport_pixel_size = |
| 1358 | params.auto_resize_enabled |
| 1359 | ? gfx::ScaleToCeiledSize(size_, |
| 1360 | params.screen_info.device_scale_factor) |
| 1361 | : params.compositor_viewport_pixel_size; |
Fady Samuel | 84d8a1f7 | 2018-11-08 00:26:17 | [diff] [blame] | 1362 | UpdateSurfaceAndScreenInfo(params.local_surface_id_allocation.value_or( |
| 1363 | viz::LocalSurfaceIdAllocation()), |
| 1364 | new_compositor_viewport_pixel_size, |
| 1365 | params.screen_info); |
Vladimir Levin | 98d76dad | 2018-04-21 00:21:29 | [diff] [blame] | 1366 | UpdateCaptureSequenceNumber(params.capture_sequence_number); |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 1367 | if (layer_tree_view_) { |
| 1368 | layer_tree_view_->SetBrowserControlsHeight( |
Sadrul Habib Chowdhury | 04d5dd4d | 2017-08-10 01:59:27 | [diff] [blame] | 1369 | params.top_controls_height, params.bottom_controls_height, |
| 1370 | params.browser_controls_shrink_blink_size); |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 1371 | layer_tree_view_->SetRasterColorSpace( |
Sadrul Habib Chowdhury | 04d5dd4d | 2017-08-10 01:59:27 | [diff] [blame] | 1372 | screen_info_.color_space.GetRasterColorSpace()); |
ianwen | e5fc578 | 2016-08-18 04:05:15 | [diff] [blame] | 1373 | } |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1374 | |
akaba | 3483d8f | 2018-07-10 21:43:09 | [diff] [blame] | 1375 | UpdateZoom(params.zoom_level); |
akaba | c6bd121 | 2018-06-25 20:10:48 | [diff] [blame] | 1376 | |
Fady Samuel | e62be40 | 2018-03-29 03:19:53 | [diff] [blame] | 1377 | if (params.auto_resize_enabled) |
| 1378 | return; |
| 1379 | |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1380 | visible_viewport_size_ = params.visible_viewport_size; |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1381 | |
| 1382 | // NOTE: We may have entered fullscreen mode without changing our size. |
| 1383 | bool fullscreen_change = |
| 1384 | is_fullscreen_granted_ != params.is_fullscreen_granted; |
| 1385 | is_fullscreen_granted_ = params.is_fullscreen_granted; |
| 1386 | display_mode_ = params.display_mode; |
| 1387 | |
bokan | c63441c | 2016-04-27 15:49:12 | [diff] [blame] | 1388 | size_ = params.new_size; |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1389 | |
bokan | c63441c | 2016-04-27 15:49:12 | [diff] [blame] | 1390 | ResizeWebWidget(); |
bokan | 71cb5b1 | 2016-04-27 03:45:22 | [diff] [blame] | 1391 | |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1392 | WebSize visual_viewport_size; |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 1393 | if (compositor_deps_->IsUseZoomForDSFEnabled()) { |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 1394 | visual_viewport_size = |
| 1395 | gfx::ScaleToCeiledSize(params.visible_viewport_size, |
| 1396 | GetOriginalScreenInfo().device_scale_factor); |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1397 | } else { |
| 1398 | visual_viewport_size = visible_viewport_size_; |
| 1399 | } |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1400 | GetWebWidget()->ResizeVisualViewport(visual_viewport_size); |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1401 | |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1402 | if (fullscreen_change) |
| 1403 | DidToggleFullscreen(); |
W. James MacLean | 2a90bff | 2018-11-05 20:52:47 | [diff] [blame] | 1404 | |
| 1405 | if (!owner_delegate_) { |
| 1406 | // Make sure that page scale factor changes propagating down from the main |
| 1407 | // frame are relayed to nested OOPIFs/non-main-frames. |
| 1408 | page_scale_factor_from_mainframe_ = params.page_scale_factor; |
| 1409 | for (auto& observer : render_frame_proxies_) |
| 1410 | observer.OnPageScaleFactorChanged(params.page_scale_factor); |
| 1411 | } |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1412 | } |
| 1413 | |
| 1414 | void RenderWidget::SetScreenMetricsEmulationParameters( |
| 1415 | bool enabled, |
| 1416 | const blink::WebDeviceEmulationParams& params) { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1417 | // This is only supported in RenderView, which has an |owner_delegate_|. |
| 1418 | DCHECK(owner_delegate_); |
| 1419 | owner_delegate_->SetScreenMetricsEmulationParametersForWidget(enabled, |
| 1420 | params); |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1421 | } |
| 1422 | |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1423 | void RenderWidget::SetScreenRects(const gfx::Rect& widget_screen_rect, |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1424 | const gfx::Rect& window_screen_rect) { |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1425 | widget_screen_rect_ = widget_screen_rect; |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 1426 | window_screen_rect_ = window_screen_rect; |
| 1427 | } |
| 1428 | |
| 1429 | /////////////////////////////////////////////////////////////////////////////// |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 1430 | // WebWidgetClient |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1431 | |
Chris Harrelson | d7ab99b | 2018-01-24 17:51:36 | [diff] [blame] | 1432 | void RenderWidget::IntrinsicSizingInfoChanged( |
| 1433 | const blink::WebIntrinsicSizingInfo& sizing_info) { |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1434 | Send(new WidgetHostMsg_IntrinsicSizingInfoChanged(routing_id_, sizing_info)); |
Chris Harrelson | d7ab99b | 2018-01-24 17:51:36 | [diff] [blame] | 1435 | } |
| 1436 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1437 | void RenderWidget::DidMeaningfulLayout(blink::WebMeaningfulLayout layout_type) { |
| 1438 | if (layout_type == blink::WebMeaningfulLayout::kVisuallyNonEmpty) { |
Albert J. Wong | fb64e14 | 2018-10-16 01:10:45 | [diff] [blame] | 1439 | QueueMessage(new WidgetHostMsg_DidFirstVisuallyNonEmptyPaint(routing_id_)); |
dglazkov | f0e1d6d | 2015-10-10 02:13:48 | [diff] [blame] | 1440 | } |
dglazkov | 79c42610 | 2015-08-31 21:22:43 | [diff] [blame] | 1441 | |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 1442 | for (auto& observer : render_frames_) |
| 1443 | observer.DidMeaningfulLayout(layout_type); |
dglazkov | 79c42610 | 2015-08-31 21:22:43 | [diff] [blame] | 1444 | } |
| 1445 | |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 1446 | // static |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 1447 | std::unique_ptr<cc::SwapPromise> RenderWidget::QueueMessageImpl( |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 1448 | IPC::Message* msg, |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 1449 | FrameSwapMessageQueue* frame_swap_message_queue, |
| 1450 | scoped_refptr<IPC::SyncMessageFilter> sync_message_filter, |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 1451 | int source_frame_number) { |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 1452 | bool first_message_for_frame = false; |
Sadrul Habib Chowdhury | 4e0335cf | 2018-07-31 20:08:49 | [diff] [blame] | 1453 | frame_swap_message_queue->QueueMessageForFrame( |
| 1454 | source_frame_number, base::WrapUnique(msg), &first_message_for_frame); |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 1455 | if (first_message_for_frame) { |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 1456 | std::unique_ptr<cc::SwapPromise> promise(new QueueMessageSwapPromise( |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 1457 | sync_message_filter, frame_swap_message_queue, source_frame_number)); |
dcheng | 4b6b5ff | 2014-10-16 00:42:06 | [diff] [blame] | 1458 | return promise; |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 1459 | } |
dcheng | 4b6b5ff | 2014-10-16 00:42:06 | [diff] [blame] | 1460 | return nullptr; |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 1461 | } |
| 1462 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 1463 | void RenderWidget::SetHandlingInputEvent(bool handling_input_event) { |
| 1464 | input_handler_->set_handling_input_event(handling_input_event); |
| 1465 | } |
| 1466 | |
Sadrul Habib Chowdhury | 4e0335cf | 2018-07-31 20:08:49 | [diff] [blame] | 1467 | void RenderWidget::QueueMessage(IPC::Message* msg) { |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 1468 | // RenderThreadImpl::current() is NULL in some tests. |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 1469 | if (!layer_tree_view_ || !RenderThreadImpl::current()) { |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 1470 | Send(msg); |
| 1471 | return; |
| 1472 | } |
| 1473 | |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 1474 | std::unique_ptr<cc::SwapPromise> swap_promise = |
Sadrul Habib Chowdhury | 4e0335cf | 2018-07-31 20:08:49 | [diff] [blame] | 1475 | QueueMessageImpl(msg, frame_swap_message_queue_.get(), |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 1476 | RenderThreadImpl::current()->sync_message_filter(), |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 1477 | layer_tree_view_->GetSourceFrameNumber()); |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 1478 | |
Ken Buchanan | ce710eb | 2017-08-30 23:46:52 | [diff] [blame] | 1479 | if (swap_promise) |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 1480 | layer_tree_view_->QueueSwapPromise(std::move(swap_promise)); |
[email protected] | 586871b | 2014-07-22 17:05:11 | [diff] [blame] | 1481 | } |
| 1482 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1483 | void RenderWidget::DidChangeCursor(const WebCursorInfo& cursor_info) { |
[email protected] | 7c51b0ee | 2009-07-08 21:49:30 | [diff] [blame] | 1484 | // TODO(darin): Eliminate this temporary. |
[email protected] | 9ec8771 | 2013-05-24 23:23:52 | [diff] [blame] | 1485 | WebCursor cursor; |
tfarina | 75a0abf | 2015-10-06 15:07:18 | [diff] [blame] | 1486 | InitializeCursorFromWebCursorInfo(&cursor, cursor_info); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1487 | // Only send a SetCursor message if we need to make a change. |
| 1488 | if (!current_cursor_.IsEqual(cursor)) { |
| 1489 | current_cursor_ = cursor; |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1490 | Send(new WidgetHostMsg_SetCursor(routing_id_, cursor)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1491 | } |
| 1492 | } |
| 1493 | |
aelias | 5971e47d | 2017-06-16 02:39:38 | [diff] [blame] | 1494 | void RenderWidget::AutoscrollStart(const blink::WebFloatPoint& point) { |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1495 | Send(new WidgetHostMsg_AutoscrollStart(routing_id_, point)); |
aelias | 5971e47d | 2017-06-16 02:39:38 | [diff] [blame] | 1496 | } |
| 1497 | |
| 1498 | void RenderWidget::AutoscrollFling(const blink::WebFloatSize& velocity) { |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1499 | Send(new WidgetHostMsg_AutoscrollFling(routing_id_, velocity)); |
aelias | 5971e47d | 2017-06-16 02:39:38 | [diff] [blame] | 1500 | } |
| 1501 | |
| 1502 | void RenderWidget::AutoscrollEnd() { |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1503 | Send(new WidgetHostMsg_AutoscrollEnd(routing_id_)); |
aelias | 5971e47d | 2017-06-16 02:39:38 | [diff] [blame] | 1504 | } |
| 1505 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1506 | // We are supposed to get a single call to Show for a newly created RenderWidget |
| 1507 | // that was created via RenderWidget::CreateWebView. So, we wait until this |
| 1508 | // point to dispatch the ShowWidget message. |
| 1509 | // |
| 1510 | // This method provides us with the information about how to display the newly |
[email protected] | 5f9de588 | 2011-09-30 23:36:28 | [diff] [blame] | 1511 | // created RenderWidget (i.e., as a blocked popup or as a new tab). |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1512 | // |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1513 | void RenderWidget::Show(WebNavigationPolicy policy) { |
danakj | 65f423b7 | 2018-10-10 17:21:20 | [diff] [blame] | 1514 | if (!show_callback_) { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1515 | if (owner_delegate_) { |
| 1516 | // When SupportsMultipleWindows is disabled, popups are reusing |
danakj | 65f423b7 | 2018-10-10 17:21:20 | [diff] [blame] | 1517 | // the view's RenderWidget. In some scenarios, this makes blink to call |
| 1518 | // Show() twice. But otherwise, if it is enabled, we should not visit |
| 1519 | // Show() more than once. |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1520 | DCHECK(!owner_delegate_->SupportsMultipleWindowsForWidget()); |
danakj | 65f423b7 | 2018-10-10 17:21:20 | [diff] [blame] | 1521 | return; |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1522 | } else { |
danakj | 65f423b7 | 2018-10-10 17:21:20 | [diff] [blame] | 1523 | NOTREACHED() << "received extraneous Show call"; |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1524 | } |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1525 | } |
| 1526 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1527 | DCHECK(routing_id_ != MSG_ROUTING_NONE); |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1528 | |
| 1529 | // The opener is responsible for actually showing this widget. |
danakj | df1ceb7 | 2018-07-18 20:02:25 | [diff] [blame] | 1530 | std::move(show_callback_).Run(this, policy, initial_rect_); |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1531 | |
bokan | c007c3a | 2015-02-03 07:15:56 | [diff] [blame] | 1532 | // NOTE: initial_rect_ may still have its default values at this point, but |
[email protected] | 8de12d94 | 2010-11-17 20:42:44 | [diff] [blame] | 1533 | // that's okay. It'll be ignored if as_popup is false, or the browser |
| 1534 | // process will impose a default position otherwise. |
bokan | c007c3a | 2015-02-03 07:15:56 | [diff] [blame] | 1535 | SetPendingWindowRect(initial_rect_); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1536 | } |
| 1537 | |
danakj | 17216f4d | 2018-10-16 22:57:32 | [diff] [blame] | 1538 | LayerTreeView* RenderWidget::InitializeLayerTreeView() { |
| 1539 | TRACE_EVENT0("blink", "RenderWidget::InitializeLayerTreeView"); |
danakj | 17216f4d | 2018-10-16 22:57:32 | [diff] [blame] | 1540 | |
| 1541 | layer_tree_view_ = std::make_unique<LayerTreeView>( |
| 1542 | this, compositor_deps_->GetCompositorMainThreadTaskRunner(), |
| 1543 | compositor_deps_->GetCompositorImplThreadTaskRunner(), |
| 1544 | compositor_deps_->GetTaskGraphRunner(), |
| 1545 | compositor_deps_->GetWebMainThreadScheduler()); |
| 1546 | layer_tree_view_->Initialize( |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 1547 | GenerateLayerTreeSettings(compositor_deps_, for_child_local_root_frame_, |
danakj | 17216f4d | 2018-10-16 22:57:32 | [diff] [blame] | 1548 | screen_info_.rect.size(), |
| 1549 | screen_info_.device_scale_factor), |
| 1550 | compositor_deps_->CreateUkmRecorderFactory()); |
| 1551 | |
Fady Samuel | 1c1ad369 | 2018-11-06 23:28:40 | [diff] [blame] | 1552 | UpdateSurfaceAndScreenInfo(local_surface_id_allocation_from_parent_, |
danakj | 17216f4d | 2018-10-16 22:57:32 | [diff] [blame] | 1553 | compositor_viewport_pixel_size_, screen_info_); |
| 1554 | layer_tree_view_->SetRasterColorSpace( |
| 1555 | screen_info_.color_space.GetRasterColorSpace()); |
| 1556 | layer_tree_view_->SetContentSourceId(current_content_source_id_); |
| 1557 | // For background pages and certain tests, we don't want to trigger |
| 1558 | // LayerTreeFrameSink creation. |
| 1559 | bool should_generate_frame_sink = |
| 1560 | !compositor_never_visible_ && RenderThreadImpl::current(); |
danakj | e9be316 | 2018-11-05 21:32:00 | [diff] [blame] | 1561 | if (!should_generate_frame_sink) { |
| 1562 | // Prevents SetVisible() from blink from doing anything. |
danakj | 17216f4d | 2018-10-16 22:57:32 | [diff] [blame] | 1563 | layer_tree_view_->SetNeverVisible(); |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 1564 | } else if (!is_frozen_) { |
danakj | e9be316 | 2018-11-05 21:32:00 | [diff] [blame] | 1565 | // Begins the compositor's scheduler to start producing frames. |
| 1566 | // Don't do this if the RenderWidget is attached to a RenderViewImpl for a |
| 1567 | // remote main frame, as this RenderWidget is a zombie then, which won't be |
| 1568 | // used for compositing until a WebFrameWidget is attached. |
| 1569 | StartCompositor(); |
| 1570 | } |
danakj | 17216f4d | 2018-10-16 22:57:32 | [diff] [blame] | 1571 | |
danakj | 17216f4d | 2018-10-16 22:57:32 | [diff] [blame] | 1572 | DCHECK_NE(MSG_ROUTING_NONE, routing_id_); |
| 1573 | layer_tree_view_->SetFrameSinkId( |
| 1574 | viz::FrameSinkId(RenderThread::Get()->GetClientId(), routing_id_)); |
| 1575 | |
| 1576 | RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 1577 | if (render_thread) { |
| 1578 | input_event_queue_ = base::MakeRefCounted<MainThreadEventQueue>( |
| 1579 | this, render_thread->GetWebMainThreadScheduler()->InputTaskRunner(), |
| 1580 | render_thread->GetWebMainThreadScheduler(), should_generate_frame_sink); |
| 1581 | } |
| 1582 | |
| 1583 | return layer_tree_view_.get(); |
| 1584 | } |
| 1585 | |
danakj | de8b748 | 2018-11-15 23:45:02 | [diff] [blame] | 1586 | void RenderWidget::StartCompositor() { |
| 1587 | if (!is_hidden_) |
| 1588 | layer_tree_view_->SetVisible(true); |
| 1589 | } |
| 1590 | |
| 1591 | void RenderWidget::StopCompositor() { |
| 1592 | layer_tree_view_->SetVisible(false); |
| 1593 | // Drop all gpu resources, this makes SetVisible(true) more expensive/slower |
| 1594 | // but we don't expect to use this RenderWidget again until some possible |
| 1595 | // future navigation. This brings us a bit closer to emulating deleting the |
| 1596 | // RenderWidget instead of just stopping the compositor. |
| 1597 | layer_tree_view_->ReleaseLayerTreeFrameSink(); |
| 1598 | } |
| 1599 | |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 1600 | void RenderWidget::SetIsFrozen(bool is_frozen) { |
| 1601 | DCHECK_NE(is_frozen, is_frozen_); |
| 1602 | is_frozen_ = is_frozen; |
| 1603 | if (is_frozen) |
danakj | de8b748 | 2018-11-15 23:45:02 | [diff] [blame] | 1604 | StopCompositor(); |
| 1605 | else |
| 1606 | StartCompositor(); |
| 1607 | } |
| 1608 | |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1609 | void RenderWidget::DoDeferredClose() { |
danakj | 5c5269b | 2018-11-06 00:39:11 | [diff] [blame] | 1610 | // Prevent compositor from setting up new IPC channels, since we know a |
| 1611 | // WidgetMsg_Close is coming. |
| 1612 | host_will_close_this_ = true; |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1613 | Send(new WidgetHostMsg_Close(routing_id_)); |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1614 | } |
| 1615 | |
dgozman | cf9039cd | 2015-04-06 12:01:31 | [diff] [blame] | 1616 | void RenderWidget::NotifyOnClose() { |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 1617 | for (auto& observer : render_frames_) |
| 1618 | observer.WidgetWillClose(); |
dgozman | cf9039cd | 2015-04-06 12:01:31 | [diff] [blame] | 1619 | } |
| 1620 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1621 | void RenderWidget::CloseWidgetSoon() { |
skyostil | ed8969c | 2015-07-20 16:57:08 | [diff] [blame] | 1622 | DCHECK(content::RenderThread::Get()); |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 1623 | if (is_frozen_) { |
| 1624 | // This widget is currently not active. The active main frame widget is in a |
[email protected] | e1c3a55 | 2012-05-04 20:51:32 | [diff] [blame] | 1625 | // different process. Have the browser route the close request to the |
| 1626 | // active widget instead, so that the correct unload handlers are run. |
Albert J. Wong | fb64e14 | 2018-10-16 01:10:45 | [diff] [blame] | 1627 | Send(new WidgetHostMsg_RouteCloseEvent(routing_id_)); |
[email protected] | e1c3a55 | 2012-05-04 20:51:32 | [diff] [blame] | 1628 | return; |
| 1629 | } |
| 1630 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1631 | // If a page calls window.close() twice, we'll end up here twice, but that's |
| 1632 | // OK. It is safe to send multiple Close messages. |
| 1633 | |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1634 | // Ask the RenderWidgetHost to initiate close. We could be called from deep |
| 1635 | // in Javascript. If we ask the RendwerWidgetHost to close now, the window |
| 1636 | // could be closed before the JS finishes executing. So instead, post a |
| 1637 | // message back to the message loop, which won't run until the JS is |
| 1638 | // complete, and then the Close message can be sent. |
Hajime Hoshi | 315a61f | 2018-08-14 17:27:28 | [diff] [blame] | 1639 | GetCleanupTaskRunner()->PostTask( |
| 1640 | FROM_HERE, base::BindOnce(&RenderWidget::DoDeferredClose, this)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1641 | } |
| 1642 | |
| 1643 | void RenderWidget::Close() { |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 1644 | // This was done immediately in the |for_child_local_root_frame_| case in the |
| 1645 | // OnClose() IPC handler. |
| 1646 | if (!for_child_local_root_frame_) |
danakj | 5c5269b | 2018-11-06 00:39:11 | [diff] [blame] | 1647 | CloseWebWidget(); |
| 1648 | |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 1649 | layer_tree_view_.reset(); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1650 | if (owner_delegate_) |
| 1651 | owner_delegate_->DidCloseWidget(); |
Albert J. Wong | d593de53 | 2018-09-06 05:42:15 | [diff] [blame] | 1652 | // Note the ACK is a control message going to the RenderProcessHost. |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1653 | RenderThread::Get()->Send(new WidgetHostMsg_Close_ACK(routing_id())); |
Ken Buchanan | ed449bb | 2018-02-01 21:02:05 | [diff] [blame] | 1654 | } |
| 1655 | |
| 1656 | void RenderWidget::CloseWebWidget() { |
danakj | 35314ab | 2018-10-19 16:37:34 | [diff] [blame] | 1657 | // If the browser has not sent OnDisableDeviceEmulation, we have an emulator |
| 1658 | // hanging out still. Destroying it must happen *after* the IPC route is |
| 1659 | // removed so that another IPC does not arrive and re-create the emulator |
| 1660 | // during closing. |
| 1661 | // |
| 1662 | // This destruction is normally part of an IPC and expects objects to be alive |
| 1663 | // that would be alive while the IPC route is active such as the |
| 1664 | // |layer_tree_view_|. So we ensure that it is the first thing to be |
| 1665 | // destroyed here before deleting things from the RenderWidget or the |
| 1666 | // |owner_delegate_|. |
| 1667 | // |
| 1668 | // TODO(danakj): The emulator could reset to non-emulated values in an |
| 1669 | // explicit method call (instead of in the destructor) that occurs when |
| 1670 | // emulation is disabled, but does not need to occur during RenderWidget |
| 1671 | // closing. Then we would not have to destroy this so carefully. |
| 1672 | screen_metrics_emulator_.reset(); |
| 1673 | |
danakj | 5c5269b | 2018-11-06 00:39:11 | [diff] [blame] | 1674 | // Informs the WebWidget that compositor is being destroyed, so it can remove |
| 1675 | // references to it first. |
| 1676 | // |
| 1677 | // When |owner_delegate_| is present, the RenderWidget is for a main frame, |
| 1678 | // and the GetWebWidget() is not the same as |webwidget_internal_|. However |
| 1679 | // that widget is responsible for doing WillCloseLayerTreeView() on the |
| 1680 | // |webwidget_internal_|, not us. Otherwise, they are the same and this is |
| 1681 | // notifying |webwidget_internal_|. |
| 1682 | GetWebWidget()->WillCloseLayerTreeView(); |
| 1683 | |
| 1684 | // While the wrapping WebWidget from an |owner_delegate_| is responsible for |
| 1685 | // doing WillCloseLayerTreeView() on the |webwidget_internal_|, this class is |
| 1686 | // responsible for calling Close() on it. Notably, then, the wrapping |
| 1687 | // WebWidget does not. |
| 1688 | webwidget_internal_->Close(); |
| 1689 | webwidget_internal_ = nullptr; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1690 | } |
| 1691 | |
Mitsuru Oshima | 3c07b33 | 2018-02-06 04:56:50 | [diff] [blame] | 1692 | void RenderWidget::UpdateWebViewWithDeviceScaleFactor() { |
| 1693 | blink::WebFrameWidget* frame_widget = GetFrameWidget(); |
| 1694 | blink::WebFrame* current_frame = |
| 1695 | frame_widget ? frame_widget->LocalRoot() : nullptr; |
| 1696 | blink::WebView* webview = current_frame ? current_frame->View() : nullptr; |
| 1697 | if (webview) { |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 1698 | if (compositor_deps_->IsUseZoomForDSFEnabled()) |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 1699 | webview->SetZoomFactorForDeviceScaleFactor( |
| 1700 | GetWebScreenInfo().device_scale_factor); |
Mitsuru Oshima | 3c07b33 | 2018-02-06 04:56:50 | [diff] [blame] | 1701 | else |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 1702 | webview->SetDeviceScaleFactor(GetWebScreenInfo().device_scale_factor); |
Mitsuru Oshima | 3c07b33 | 2018-02-06 04:56:50 | [diff] [blame] | 1703 | |
| 1704 | webview->GetSettings()->SetPreferCompositingToLCDTextEnabled( |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 1705 | PreferCompositingToLCDText(compositor_deps_, |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 1706 | GetWebScreenInfo().device_scale_factor)); |
Mitsuru Oshima | 3c07b33 | 2018-02-06 04:56:50 | [diff] [blame] | 1707 | } |
| 1708 | } |
| 1709 | |
Ehsan Karamad | 655d7b8a | 2018-01-12 18:38:38 | [diff] [blame] | 1710 | blink::WebFrameWidget* RenderWidget::GetFrameWidget() const { |
| 1711 | blink::WebWidget* web_widget = GetWebWidget(); |
| 1712 | if (!web_widget) |
| 1713 | return nullptr; |
| 1714 | |
| 1715 | if (!web_widget->IsWebFrameWidget()) { |
| 1716 | // TODO(ekaramad): This should not happen. If we have a WebWidget and we |
| 1717 | // need a WebFrameWidget then we should be getting a WebFrameWidget. But |
| 1718 | // unfortunately this does not seem to be the case in some scenarios -- |
| 1719 | // specifically when a RenderViewImpl swaps out during navigation the |
| 1720 | // WebViewImpl loses its WebViewFrameWidget but sometimes we receive IPCs |
| 1721 | // which are destined for WebFrameWidget (https://crbug.com/669219). |
| 1722 | return nullptr; |
| 1723 | } |
| 1724 | |
| 1725 | return static_cast<blink::WebFrameWidget*>(web_widget); |
| 1726 | } |
| 1727 | |
bokan | 841fdc7 | 2016-10-06 00:16:35 | [diff] [blame] | 1728 | void RenderWidget::ScreenRectToEmulatedIfNeeded(WebRect* window_rect) const { |
| 1729 | DCHECK(window_rect); |
| 1730 | float scale = popup_origin_scale_for_emulation_; |
| 1731 | if (!scale) |
| 1732 | return; |
| 1733 | window_rect->x = |
| 1734 | popup_view_origin_for_emulation_.x() + |
| 1735 | (window_rect->x - popup_screen_origin_for_emulation_.x()) / scale; |
| 1736 | window_rect->y = |
| 1737 | popup_view_origin_for_emulation_.y() + |
| 1738 | (window_rect->y - popup_screen_origin_for_emulation_.y()) / scale; |
| 1739 | } |
| 1740 | |
| 1741 | void RenderWidget::EmulatedToScreenRectIfNeeded(WebRect* window_rect) const { |
| 1742 | DCHECK(window_rect); |
| 1743 | float scale = popup_origin_scale_for_emulation_; |
| 1744 | if (!scale) |
| 1745 | return; |
| 1746 | window_rect->x = |
| 1747 | popup_screen_origin_for_emulation_.x() + |
| 1748 | (window_rect->x - popup_view_origin_for_emulation_.x()) * scale; |
| 1749 | window_rect->y = |
| 1750 | popup_screen_origin_for_emulation_.y() + |
| 1751 | (window_rect->y - popup_view_origin_for_emulation_.y()) * scale; |
| 1752 | } |
| 1753 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1754 | WebRect RenderWidget::WindowRect() { |
bokan | 841fdc7 | 2016-10-06 00:16:35 | [diff] [blame] | 1755 | WebRect rect; |
bokan | 6b08cd2 | 2016-10-05 00:55:21 | [diff] [blame] | 1756 | if (pending_window_rect_count_) { |
| 1757 | // NOTE(mbelshe): If there is a pending_window_rect_, then getting |
| 1758 | // the RootWindowRect is probably going to return wrong results since the |
| 1759 | // browser may not have processed the Move yet. There isn't really anything |
| 1760 | // good to do in this case, and it shouldn't happen - since this size is |
| 1761 | // only really needed for windowToScreen, which is only used for Popups. |
bokan | 841fdc7 | 2016-10-06 00:16:35 | [diff] [blame] | 1762 | rect = pending_window_rect_; |
| 1763 | } else { |
| 1764 | rect = window_screen_rect_; |
bokan | 6b08cd2 | 2016-10-05 00:55:21 | [diff] [blame] | 1765 | } |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1766 | |
bokan | 841fdc7 | 2016-10-06 00:16:35 | [diff] [blame] | 1767 | ScreenRectToEmulatedIfNeeded(&rect); |
| 1768 | return rect; |
bokan | 6b08cd2 | 2016-10-05 00:55:21 | [diff] [blame] | 1769 | } |
| 1770 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1771 | WebRect RenderWidget::ViewRect() { |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1772 | WebRect rect = widget_screen_rect_; |
bokan | 841fdc7 | 2016-10-06 00:16:35 | [diff] [blame] | 1773 | ScreenRectToEmulatedIfNeeded(&rect); |
| 1774 | return rect; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1775 | } |
| 1776 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1777 | void RenderWidget::SetToolTipText(const blink::WebString& text, |
[email protected] | 8a9d6ca3 | 2011-06-06 20:11:30 | [diff] [blame] | 1778 | WebTextDirection hint) { |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1779 | Send(new WidgetHostMsg_SetTooltipText(routing_id_, text.Utf16(), hint)); |
[email protected] | 8a9d6ca3 | 2011-06-06 20:11:30 | [diff] [blame] | 1780 | } |
| 1781 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1782 | void RenderWidget::SetWindowRect(const WebRect& rect_in_screen) { |
danakj | 81d601e6 | 2018-10-09 22:15:05 | [diff] [blame] | 1783 | // This path is for the renderer to change the on-screen position/size of |
| 1784 | // the widget by changing its window rect. This is not possible for |
| 1785 | // RenderWidgets whose position/size are controlled by layout from another |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 1786 | // frame tree (ie. child local root frames), as the window rect can only be |
| 1787 | // set by the browser. |
| 1788 | if (for_child_local_root_frame_) |
danakj | 81d601e6 | 2018-10-09 22:15:05 | [diff] [blame] | 1789 | return; |
| 1790 | |
oshima | 33ec97cd | 2015-12-14 19:40:24 | [diff] [blame] | 1791 | WebRect window_rect = rect_in_screen; |
bokan | 841fdc7 | 2016-10-06 00:16:35 | [diff] [blame] | 1792 | EmulatedToScreenRectIfNeeded(&window_rect); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 1793 | |
danakj | 65f423b7 | 2018-10-10 17:21:20 | [diff] [blame] | 1794 | if (resizing_mode_selector_->is_synchronous_mode()) { |
| 1795 | // This is a layout-test-only path. At one point, it was planned to be |
| 1796 | // removed. See https://crbug.com/309760. |
bokan | c007c3a | 2015-02-03 07:15:56 | [diff] [blame] | 1797 | SetWindowRectSynchronously(window_rect); |
danakj | 65f423b7 | 2018-10-10 17:21:20 | [diff] [blame] | 1798 | return; |
| 1799 | } |
| 1800 | |
| 1801 | if (show_callback_) { |
| 1802 | // The widget is not shown yet. Delay the |window_rect| being sent to the |
| 1803 | // browser until Show() is called so it can be sent with that IPC, once the |
| 1804 | // browser is ready for the info. |
| 1805 | initial_rect_ = window_rect; |
| 1806 | } else { |
| 1807 | Send(new WidgetHostMsg_RequestSetBounds(routing_id_, window_rect)); |
| 1808 | SetPendingWindowRect(window_rect); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1809 | } |
| 1810 | } |
| 1811 | |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1812 | void RenderWidget::SetPendingWindowRect(const WebRect& rect) { |
| 1813 | pending_window_rect_ = rect; |
| 1814 | pending_window_rect_count_++; |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1815 | |
bokan | 6b08cd2 | 2016-10-05 00:55:21 | [diff] [blame] | 1816 | // Popups don't get size updates back from the browser so just store the set |
| 1817 | // values. |
danakj | 6a81659 | 2018-09-25 18:30:56 | [diff] [blame] | 1818 | if (widget_type_ != WidgetType::kFrame) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1819 | window_screen_rect_ = rect; |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1820 | widget_screen_rect_ = rect; |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1821 | } |
[email protected] | d454745 | 2008-08-28 18:36:37 | [diff] [blame] | 1822 | } |
| 1823 | |
wjmaclean | ee244e0 | 2017-05-26 21:06:07 | [diff] [blame] | 1824 | void RenderWidget::OnShowContextMenu(ui::MenuSourceType source_type, |
| 1825 | const gfx::Point& location) { |
wjmaclean | ee244e0 | 2017-05-26 21:06:07 | [diff] [blame] | 1826 | has_host_context_menu_location_ = true; |
| 1827 | host_context_menu_location_ = location; |
| 1828 | if (GetWebWidget()) { |
| 1829 | GetWebWidget()->ShowContextMenu( |
| 1830 | static_cast<blink::WebMenuSourceType>(source_type)); |
| 1831 | } |
| 1832 | has_host_context_menu_location_ = false; |
| 1833 | } |
| 1834 | |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 1835 | void RenderWidget::OnImeSetComposition( |
[email protected] | fcf75d4 | 2013-12-03 20:11:26 | [diff] [blame] | 1836 | const base::string16& text, |
Ryan Landay | 9e42fd74 | 2017-08-12 01:59:11 | [diff] [blame] | 1837 | const std::vector<WebImeTextSpan>& ime_text_spans, |
chongz | 7eb75280 | 2016-01-27 21:28:07 | [diff] [blame] | 1838 | const gfx::Range& replacement_range, |
Ryan Landay | 9e42fd74 | 2017-08-12 01:59:11 | [diff] [blame] | 1839 | int selection_start, |
| 1840 | int selection_end) { |
ekaramad | 5aff194 | 2017-01-06 01:26:35 | [diff] [blame] | 1841 | if (!ShouldHandleImeEvents()) |
| 1842 | return; |
| 1843 | |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 1844 | #if BUILDFLAG(ENABLE_PLUGINS) |
EhsanK | 22d482e | 2017-08-10 17:29:49 | [diff] [blame] | 1845 | if (auto* plugin = GetFocusedPepperPluginInsideWidget()) { |
Ryan Landay | 9e42fd74 | 2017-08-12 01:59:11 | [diff] [blame] | 1846 | plugin->render_frame()->OnImeSetComposition(text, ime_text_spans, |
EhsanK | 22d482e | 2017-08-10 17:29:49 | [diff] [blame] | 1847 | selection_start, selection_end); |
ekaramad | 2a46d63 | 2016-07-19 13:33:09 | [diff] [blame] | 1848 | return; |
| 1849 | } |
| 1850 | #endif |
[email protected] | 66fca5bc | 2013-05-23 06:58:29 | [diff] [blame] | 1851 | ImeEventGuard guard(this); |
ekaramad | 2daaf67 | 2016-11-10 20:29:01 | [diff] [blame] | 1852 | blink::WebInputMethodController* controller = GetInputMethodController(); |
ekaramad | 2daaf67 | 2016-11-10 20:29:01 | [diff] [blame] | 1853 | if (!controller || |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1854 | !controller->SetComposition( |
Ryan Landay | 9e42fd74 | 2017-08-12 01:59:11 | [diff] [blame] | 1855 | WebString::FromUTF16(text), WebVector<WebImeTextSpan>(ime_text_spans), |
ekaramad | ce32ef9f | 2017-02-09 17:33:56 | [diff] [blame] | 1856 | replacement_range.IsValid() |
| 1857 | ? WebRange(replacement_range.start(), replacement_range.length()) |
| 1858 | : WebRange(), |
| 1859 | selection_start, selection_end)) { |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 1860 | // If we failed to set the composition text, then we need to let the browser |
| 1861 | // process to cancel the input method's ongoing composition session, to make |
| 1862 | // sure we are in a consistent state. |
Dave Tapuska | 04bc5ee9 | 2018-04-17 19:03:31 | [diff] [blame] | 1863 | if (mojom::WidgetInputHandlerHost* host = |
| 1864 | widget_input_handler_manager_->GetWidgetInputHandlerHost()) { |
| 1865 | host->ImeCancelComposition(); |
Dave Tapuska | 139a72f | 2017-09-06 21:57:03 | [diff] [blame] | 1866 | } |
[email protected] | 7f00efa | 2010-04-15 05:01:26 | [diff] [blame] | 1867 | } |
nona | fa29179 | 2016-08-10 02:36:18 | [diff] [blame] | 1868 | UpdateCompositionInfo(false /* not an immediate request */); |
[email protected] | fa7b1dc | 2010-06-23 17:53:04 | [diff] [blame] | 1869 | } |
| 1870 | |
rlanday | 7efe230 | 2017-01-11 00:14:28 | [diff] [blame] | 1871 | void RenderWidget::OnImeCommitText( |
| 1872 | const base::string16& text, |
Ryan Landay | 9e42fd74 | 2017-08-12 01:59:11 | [diff] [blame] | 1873 | const std::vector<WebImeTextSpan>& ime_text_spans, |
rlanday | 7efe230 | 2017-01-11 00:14:28 | [diff] [blame] | 1874 | const gfx::Range& replacement_range, |
| 1875 | int relative_cursor_pos) { |
ekaramad | 5aff194 | 2017-01-06 01:26:35 | [diff] [blame] | 1876 | if (!ShouldHandleImeEvents()) |
| 1877 | return; |
| 1878 | |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 1879 | #if BUILDFLAG(ENABLE_PLUGINS) |
EhsanK | 22d482e | 2017-08-10 17:29:49 | [diff] [blame] | 1880 | if (auto* plugin = GetFocusedPepperPluginInsideWidget()) { |
| 1881 | plugin->render_frame()->OnImeCommitText(text, replacement_range, |
| 1882 | relative_cursor_pos); |
ekaramad | 2a46d63 | 2016-07-19 13:33:09 | [diff] [blame] | 1883 | return; |
| 1884 | } |
| 1885 | #endif |
[email protected] | 66fca5bc | 2013-05-23 06:58:29 | [diff] [blame] | 1886 | ImeEventGuard guard(this); |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1887 | input_handler_->set_handling_input_event(true); |
ekaramad | b6483a05 | 2017-02-10 02:23:26 | [diff] [blame] | 1888 | if (auto* controller = GetInputMethodController()) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1889 | controller->CommitText( |
Ryan Landay | 9e42fd74 | 2017-08-12 01:59:11 | [diff] [blame] | 1890 | WebString::FromUTF16(text), WebVector<WebImeTextSpan>(ime_text_spans), |
ekaramad | ce32ef9f | 2017-02-09 17:33:56 | [diff] [blame] | 1891 | replacement_range.IsValid() |
| 1892 | ? WebRange(replacement_range.start(), replacement_range.length()) |
| 1893 | : WebRange(), |
| 1894 | relative_cursor_pos); |
ekaramad | b6483a05 | 2017-02-10 02:23:26 | [diff] [blame] | 1895 | } |
aelias | 87b8f7c | 2016-09-14 03:19:29 | [diff] [blame] | 1896 | input_handler_->set_handling_input_event(false); |
| 1897 | UpdateCompositionInfo(false /* not an immediate request */); |
| 1898 | } |
| 1899 | |
| 1900 | void RenderWidget::OnImeFinishComposingText(bool keep_selection) { |
ekaramad | 5aff194 | 2017-01-06 01:26:35 | [diff] [blame] | 1901 | if (!ShouldHandleImeEvents()) |
| 1902 | return; |
| 1903 | |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 1904 | #if BUILDFLAG(ENABLE_PLUGINS) |
EhsanK | 22d482e | 2017-08-10 17:29:49 | [diff] [blame] | 1905 | if (auto* plugin = GetFocusedPepperPluginInsideWidget()) { |
| 1906 | plugin->render_frame()->OnImeFinishComposingText(keep_selection); |
aelias | 87b8f7c | 2016-09-14 03:19:29 | [diff] [blame] | 1907 | return; |
| 1908 | } |
| 1909 | #endif |
| 1910 | |
changwan | 38c3eb61 | 2016-12-09 01:45:56 | [diff] [blame] | 1911 | if (!GetWebWidget()) |
aelias | 87b8f7c | 2016-09-14 03:19:29 | [diff] [blame] | 1912 | return; |
| 1913 | ImeEventGuard guard(this); |
| 1914 | input_handler_->set_handling_input_event(true); |
ekaramad | 2daaf67 | 2016-11-10 20:29:01 | [diff] [blame] | 1915 | if (auto* controller = GetInputMethodController()) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1916 | controller->FinishComposingText( |
| 1917 | keep_selection ? WebInputMethodController::kKeepSelection |
| 1918 | : WebInputMethodController::kDoNotKeepSelection); |
ekaramad | 2daaf67 | 2016-11-10 20:29:01 | [diff] [blame] | 1919 | } |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1920 | input_handler_->set_handling_input_event(false); |
nona | fa29179 | 2016-08-10 02:36:18 | [diff] [blame] | 1921 | UpdateCompositionInfo(false /* not an immediate request */); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1922 | } |
| 1923 | |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 1924 | void RenderWidget::UpdateSurfaceAndScreenInfo( |
Fady Samuel | 1c1ad369 | 2018-11-06 23:28:40 | [diff] [blame] | 1925 | const viz::LocalSurfaceIdAllocation& new_local_surface_id_allocation, |
Christopher Cameron | aad15a0d | 2018-03-09 03:47:33 | [diff] [blame] | 1926 | const gfx::Size& new_compositor_viewport_pixel_size, |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 1927 | const ScreenInfo& new_screen_info) { |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 1928 | bool orientation_changed = |
| 1929 | screen_info_.orientation_angle != new_screen_info.orientation_angle || |
| 1930 | screen_info_.orientation_type != new_screen_info.orientation_type; |
| 1931 | bool web_device_scale_factor_changed = |
| 1932 | screen_info_.device_scale_factor != new_screen_info.device_scale_factor; |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 1933 | ScreenInfo previous_original_screen_info = GetOriginalScreenInfo(); |
Christopher Cameron | be7ecea | 2018-02-27 00:47:19 | [diff] [blame] | 1934 | |
Fady Samuel | 1c1ad369 | 2018-11-06 23:28:40 | [diff] [blame] | 1935 | local_surface_id_allocation_from_parent_ = new_local_surface_id_allocation; |
Christopher Cameron | aad15a0d | 2018-03-09 03:47:33 | [diff] [blame] | 1936 | compositor_viewport_pixel_size_ = new_compositor_viewport_pixel_size; |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 1937 | screen_info_ = new_screen_info; |
Christopher Cameron | be7ecea | 2018-02-27 00:47:19 | [diff] [blame] | 1938 | |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 1939 | if (layer_tree_view_) { |
| 1940 | layer_tree_view_->SetViewportVisibleRect(ViewportVisibleRect()); |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 1941 | // Note carefully that the DSF specified in |new_screen_info| is not the |
| 1942 | // DSF used by the compositor during device emulation! |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 1943 | layer_tree_view_->SetViewportSizeAndScale( |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 1944 | compositor_viewport_pixel_size_, |
Fady Samuel | 4255c18 | 2018-05-24 20:42:36 | [diff] [blame] | 1945 | GetOriginalScreenInfo().device_scale_factor, |
Fady Samuel | 1c1ad369 | 2018-11-06 23:28:40 | [diff] [blame] | 1946 | local_surface_id_allocation_from_parent_); |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 1947 | } |
Christopher Cameron | be7ecea | 2018-02-27 00:47:19 | [diff] [blame] | 1948 | |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 1949 | if (orientation_changed) |
| 1950 | OnOrientationChange(); |
Christopher Cameron | be7ecea | 2018-02-27 00:47:19 | [diff] [blame] | 1951 | |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 1952 | if (previous_original_screen_info != GetOriginalScreenInfo()) { |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 1953 | for (auto& observer : render_frame_proxies_) |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 1954 | observer.OnScreenInfoChanged(GetOriginalScreenInfo()); |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 1955 | |
| 1956 | // Notify all embedded BrowserPlugins of the updated ScreenInfo. |
| 1957 | for (auto& observer : browser_plugins_) |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 1958 | observer.ScreenInfoChanged(GetOriginalScreenInfo()); |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 1959 | } |
| 1960 | |
| 1961 | if (web_device_scale_factor_changed) |
Christopher Cameron | be7ecea | 2018-02-27 00:47:19 | [diff] [blame] | 1962 | UpdateWebViewWithDeviceScaleFactor(); |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 1963 | } |
| 1964 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1965 | void RenderWidget::SetWindowRectSynchronously( |
| 1966 | const gfx::Rect& new_window_rect) { |
| 1967 | VisualProperties visual_properties; |
| 1968 | visual_properties.screen_info = screen_info_; |
| 1969 | visual_properties.new_size = new_window_rect.size(); |
| 1970 | visual_properties.compositor_viewport_pixel_size = gfx::ScaleToCeiledSize( |
| 1971 | new_window_rect.size(), GetWebScreenInfo().device_scale_factor); |
| 1972 | visual_properties.visible_viewport_size = new_window_rect.size(); |
| 1973 | visual_properties.is_fullscreen_granted = is_fullscreen_granted_; |
| 1974 | visual_properties.display_mode = display_mode_; |
Fady Samuel | 84d8a1f7 | 2018-11-08 00:26:17 | [diff] [blame] | 1975 | visual_properties.local_surface_id_allocation = |
| 1976 | local_surface_id_allocation_from_parent_; |
W. James MacLean | 2a90bff | 2018-11-05 20:52:47 | [diff] [blame] | 1977 | visual_properties.page_scale_factor = page_scale_factor_from_mainframe_; |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1978 | // We are resizing the window from the renderer, so allocate a new |
| 1979 | // viz::LocalSurfaceId to avoid surface invariants violations in tests. |
| 1980 | if (layer_tree_view_) |
| 1981 | layer_tree_view_->RequestNewLocalSurfaceId(); |
| 1982 | SynchronizeVisualProperties(visual_properties); |
| 1983 | |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 1984 | widget_screen_rect_ = new_window_rect; |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1985 | window_screen_rect_ = new_window_rect; |
danakj | 65f423b7 | 2018-10-10 17:21:20 | [diff] [blame] | 1986 | if (show_callback_) { |
| 1987 | // Tests may call here directly to control the window rect. If |
| 1988 | // Show() did not happen yet, the rect is stored to be passed to the |
| 1989 | // browser when the RenderWidget requests Show(). |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1990 | initial_rect_ = new_window_rect; |
danakj | 65f423b7 | 2018-10-10 17:21:20 | [diff] [blame] | 1991 | } |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1992 | } |
| 1993 | |
Vladimir Levin | 98d76dad | 2018-04-21 00:21:29 | [diff] [blame] | 1994 | void RenderWidget::UpdateCaptureSequenceNumber( |
| 1995 | uint32_t capture_sequence_number) { |
| 1996 | if (capture_sequence_number == last_capture_sequence_number_) |
| 1997 | return; |
| 1998 | last_capture_sequence_number_ = capture_sequence_number; |
| 1999 | |
| 2000 | // Notify observers of the new capture sequence number. |
| 2001 | for (auto& observer : render_frame_proxies_) |
| 2002 | observer.UpdateCaptureSequenceNumber(capture_sequence_number); |
| 2003 | for (auto& observer : browser_plugins_) |
| 2004 | observer.UpdateCaptureSequenceNumber(capture_sequence_number); |
| 2005 | } |
| 2006 | |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 2007 | void RenderWidget::OnSetTextDirection(WebTextDirection direction) { |
EhsanK | 955ba58 | 2017-11-30 21:14:40 | [diff] [blame] | 2008 | if (auto* frame = GetFocusedWebLocalFrameInWidget()) |
| 2009 | frame->SetTextDirection(direction); |
[email protected] | 07f95333 | 2009-03-25 04:31:11 | [diff] [blame] | 2010 | } |
| 2011 | |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 2012 | void RenderWidget::OnUpdateScreenRects(const gfx::Rect& widget_screen_rect, |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 2013 | const gfx::Rect& window_screen_rect) { |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 2014 | if (screen_metrics_emulator_) { |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 2015 | screen_metrics_emulator_->OnUpdateScreenRects(widget_screen_rect, |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 2016 | window_screen_rect); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 2017 | } else { |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 2018 | SetScreenRects(widget_screen_rect, window_screen_rect); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 2019 | } |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 2020 | Send(new WidgetHostMsg_UpdateScreenRects_ACK(routing_id())); |
[email protected] | 80ad862 | 2012-11-07 16:33:03 | [diff] [blame] | 2021 | } |
| 2022 | |
kenrb | ea73179 | 2017-01-13 15:10:48 | [diff] [blame] | 2023 | void RenderWidget::OnSetViewportIntersection( |
Ken Buchanan | b2c9e26 | 2018-03-10 16:53:31 | [diff] [blame] | 2024 | const gfx::Rect& viewport_intersection, |
Stefan Zager | 54e2583 | 2018-08-14 22:15:31 | [diff] [blame] | 2025 | const gfx::Rect& compositor_visible_rect, |
| 2026 | bool occluded_or_obscured) { |
Ehsan Karamad | f3ca2a8 | 2018-01-20 01:05:25 | [diff] [blame] | 2027 | if (auto* frame_widget = GetFrameWidget()) { |
danakj | 6a81659 | 2018-09-25 18:30:56 | [diff] [blame] | 2028 | DCHECK_EQ(widget_type_, WidgetType::kFrame); |
Ken Buchanan | b2c9e26 | 2018-03-10 16:53:31 | [diff] [blame] | 2029 | compositor_visible_rect_ = compositor_visible_rect; |
Stefan Zager | 54e2583 | 2018-08-14 22:15:31 | [diff] [blame] | 2030 | frame_widget->SetRemoteViewportIntersection(viewport_intersection, |
| 2031 | occluded_or_obscured); |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 2032 | layer_tree_view_->SetViewportVisibleRect(ViewportVisibleRect()); |
kenrb | ea73179 | 2017-01-13 15:10:48 | [diff] [blame] | 2033 | } |
| 2034 | } |
| 2035 | |
kenrb | 0432378 | 2017-06-23 01:23:32 | [diff] [blame] | 2036 | void RenderWidget::OnSetIsInert(bool inert) { |
Ehsan Karamad | f3ca2a8 | 2018-01-20 01:05:25 | [diff] [blame] | 2037 | if (auto* frame_widget = GetFrameWidget()) { |
danakj | 6a81659 | 2018-09-25 18:30:56 | [diff] [blame] | 2038 | DCHECK_EQ(widget_type_, WidgetType::kFrame); |
Ehsan Karamad | f3ca2a8 | 2018-01-20 01:05:25 | [diff] [blame] | 2039 | frame_widget->SetIsInert(inert); |
kenrb | 0432378 | 2017-06-23 01:23:32 | [diff] [blame] | 2040 | } |
| 2041 | } |
| 2042 | |
sunxd | 540a996 | 2018-05-24 22:51:06 | [diff] [blame] | 2043 | void RenderWidget::OnSetInheritedEffectiveTouchAction( |
| 2044 | cc::TouchAction touch_action) { |
| 2045 | if (auto* frame_widget = GetFrameWidget()) { |
danakj | 6a81659 | 2018-09-25 18:30:56 | [diff] [blame] | 2046 | DCHECK_EQ(widget_type_, WidgetType::kFrame); |
sunxd | 540a996 | 2018-05-24 22:51:06 | [diff] [blame] | 2047 | frame_widget->SetInheritedEffectiveTouchAction(touch_action); |
| 2048 | } |
| 2049 | } |
| 2050 | |
Ken Buchanan | 8a319fb | 2017-11-15 18:37:12 | [diff] [blame] | 2051 | void RenderWidget::OnUpdateRenderThrottlingStatus(bool is_throttled, |
| 2052 | bool subtree_throttled) { |
Ehsan Karamad | f3ca2a8 | 2018-01-20 01:05:25 | [diff] [blame] | 2053 | if (auto* frame_widget = GetFrameWidget()) { |
danakj | 6a81659 | 2018-09-25 18:30:56 | [diff] [blame] | 2054 | DCHECK_EQ(widget_type_, WidgetType::kFrame); |
Ehsan Karamad | f3ca2a8 | 2018-01-20 01:05:25 | [diff] [blame] | 2055 | frame_widget->UpdateRenderThrottlingStatus(is_throttled, subtree_throttled); |
Ken Buchanan | 8a319fb | 2017-11-15 18:37:12 | [diff] [blame] | 2056 | } |
| 2057 | } |
| 2058 | |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 2059 | void RenderWidget::OnDragTargetDragEnter( |
| 2060 | const std::vector<DropData::Metadata>& drop_meta_data, |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 2061 | const gfx::PointF& client_point, |
| 2062 | const gfx::PointF& screen_point, |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 2063 | WebDragOperationsMask ops, |
| 2064 | int key_modifiers) { |
Ehsan Karamad | f3ca2a8 | 2018-01-20 01:05:25 | [diff] [blame] | 2065 | blink::WebFrameWidget* frame_widget = GetFrameWidget(); |
| 2066 | if (!frame_widget) |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 2067 | return; |
| 2068 | |
Ehsan Karamad | f3ca2a8 | 2018-01-20 01:05:25 | [diff] [blame] | 2069 | WebDragOperation operation = frame_widget->DragTargetDragEnter( |
| 2070 | DropMetaDataToWebDragData(drop_meta_data), client_point, screen_point, |
| 2071 | ops, key_modifiers); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 2072 | |
| 2073 | Send(new DragHostMsg_UpdateDragCursor(routing_id(), operation)); |
| 2074 | } |
| 2075 | |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 2076 | void RenderWidget::OnDragTargetDragOver(const gfx::PointF& client_point, |
| 2077 | const gfx::PointF& screen_point, |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 2078 | WebDragOperationsMask ops, |
| 2079 | int key_modifiers) { |
Ehsan Karamad | f3ca2a8 | 2018-01-20 01:05:25 | [diff] [blame] | 2080 | blink::WebFrameWidget* frame_widget = GetFrameWidget(); |
| 2081 | if (!frame_widget) |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 2082 | return; |
| 2083 | |
Ehsan Karamad | f3ca2a8 | 2018-01-20 01:05:25 | [diff] [blame] | 2084 | WebDragOperation operation = frame_widget->DragTargetDragOver( |
| 2085 | ConvertWindowPointToViewport(client_point), screen_point, ops, |
| 2086 | key_modifiers); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 2087 | |
| 2088 | Send(new DragHostMsg_UpdateDragCursor(routing_id(), operation)); |
| 2089 | } |
| 2090 | |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 2091 | void RenderWidget::OnDragTargetDragLeave(const gfx::PointF& client_point, |
| 2092 | const gfx::PointF& screen_point) { |
Ehsan Karamad | f3ca2a8 | 2018-01-20 01:05:25 | [diff] [blame] | 2093 | blink::WebFrameWidget* frame_widget = GetFrameWidget(); |
| 2094 | if (!frame_widget) |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 2095 | return; |
Ehsan Karamad | f3ca2a8 | 2018-01-20 01:05:25 | [diff] [blame] | 2096 | |
| 2097 | frame_widget |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2098 | ->DragTargetDragLeave(ConvertWindowPointToViewport(client_point), |
kenrb | 07c27280 | 2017-02-07 23:48:17 | [diff] [blame] | 2099 | screen_point); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 2100 | } |
| 2101 | |
| 2102 | void RenderWidget::OnDragTargetDrop(const DropData& drop_data, |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 2103 | const gfx::PointF& client_point, |
| 2104 | const gfx::PointF& screen_point, |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 2105 | int key_modifiers) { |
Ehsan Karamad | f3ca2a8 | 2018-01-20 01:05:25 | [diff] [blame] | 2106 | blink::WebFrameWidget* frame_widget = GetFrameWidget(); |
| 2107 | if (!frame_widget) |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 2108 | return; |
| 2109 | |
Ehsan Karamad | f3ca2a8 | 2018-01-20 01:05:25 | [diff] [blame] | 2110 | frame_widget->DragTargetDrop(DropDataToWebDragData(drop_data), |
| 2111 | ConvertWindowPointToViewport(client_point), |
| 2112 | screen_point, key_modifiers); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 2113 | } |
| 2114 | |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 2115 | void RenderWidget::OnDragSourceEnded(const gfx::PointF& client_point, |
| 2116 | const gfx::PointF& screen_point, |
paulmeyer | 8fc8ea9 | 2016-11-15 05:12:21 | [diff] [blame] | 2117 | WebDragOperation op) { |
Ehsan Karamad | f3ca2a8 | 2018-01-20 01:05:25 | [diff] [blame] | 2118 | blink::WebFrameWidget* frame_widget = GetFrameWidget(); |
| 2119 | if (!frame_widget) |
paulmeyer | 8fc8ea9 | 2016-11-15 05:12:21 | [diff] [blame] | 2120 | return; |
| 2121 | |
Ehsan Karamad | f3ca2a8 | 2018-01-20 01:05:25 | [diff] [blame] | 2122 | frame_widget->DragSourceEndedAt(ConvertWindowPointToViewport(client_point), |
| 2123 | screen_point, op); |
paulmeyer | 8fc8ea9 | 2016-11-15 05:12:21 | [diff] [blame] | 2124 | } |
| 2125 | |
| 2126 | void RenderWidget::OnDragSourceSystemDragEnded() { |
| 2127 | if (!GetWebWidget()) |
| 2128 | return; |
| 2129 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2130 | static_cast<WebFrameWidget*>(GetWebWidget())->DragSourceSystemDragEnded(); |
paulmeyer | 8fc8ea9 | 2016-11-15 05:12:21 | [diff] [blame] | 2131 | } |
| 2132 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2133 | void RenderWidget::ShowVirtualKeyboardOnElementFocus() { |
oka | a398f50b | 2017-03-21 06:30:26 | [diff] [blame] | 2134 | #if defined(OS_CHROMEOS) |
| 2135 | // On ChromeOS, virtual keyboard is triggered only when users leave the |
| 2136 | // mouse button or the finger and a text input element is focused at that |
| 2137 | // time. Focus event itself shouldn't trigger virtual keyboard. |
| 2138 | UpdateTextInputState(); |
| 2139 | #else |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 2140 | ShowVirtualKeyboard(); |
oka | a398f50b | 2017-03-21 06:30:26 | [diff] [blame] | 2141 | #endif |
boliu | 7b2be2f | 2016-11-04 04:58:31 | [diff] [blame] | 2142 | |
| 2143 | // TODO(rouslan): Fix ChromeOS and Windows 8 behavior of autofill popup with |
| 2144 | // virtual keyboard. |
| 2145 | #if !defined(OS_ANDROID) |
| 2146 | FocusChangeComplete(); |
| 2147 | #endif |
[email protected] | 0d1ebed1 | 2013-08-05 22:01:13 | [diff] [blame] | 2148 | } |
| 2149 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 2150 | ui::TextInputType RenderWidget::GetTextInputType() { |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 2151 | #if BUILDFLAG(ENABLE_PLUGINS) |
EhsanK | 22d482e | 2017-08-10 17:29:49 | [diff] [blame] | 2152 | if (auto* plugin = GetFocusedPepperPluginInsideWidget()) |
| 2153 | return plugin->text_input_type(); |
ekaramad | 2a46d63 | 2016-07-19 13:33:09 | [diff] [blame] | 2154 | #endif |
ekaramad | 5aff194 | 2017-01-06 01:26:35 | [diff] [blame] | 2155 | if (auto* controller = GetInputMethodController()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2156 | return ConvertWebTextInputType(controller->TextInputType()); |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 2157 | return ui::TEXT_INPUT_TYPE_NONE; |
| 2158 | } |
| 2159 | |
nona | fa29179 | 2016-08-10 02:36:18 | [diff] [blame] | 2160 | void RenderWidget::UpdateCompositionInfo(bool immediate_request) { |
| 2161 | if (!monitor_composition_info_ && !immediate_request) |
| 2162 | return; // Do not calculate composition info if not requested. |
nona | dac0c7a | 2016-08-01 02:30:59 | [diff] [blame] | 2163 | |
nona | fa29179 | 2016-08-10 02:36:18 | [diff] [blame] | 2164 | TRACE_EVENT0("renderer", "RenderWidget::UpdateCompositionInfo"); |
| 2165 | gfx::Range range; |
| 2166 | std::vector<gfx::Rect> character_bounds; |
| 2167 | |
| 2168 | if (GetTextInputType() == ui::TEXT_INPUT_TYPE_NONE) { |
| 2169 | // Composition information is only available on editable node. |
| 2170 | range = gfx::Range::InvalidRange(); |
| 2171 | } else { |
| 2172 | GetCompositionRange(&range); |
| 2173 | GetCompositionCharacterBounds(&character_bounds); |
| 2174 | } |
| 2175 | |
| 2176 | if (!immediate_request && |
| 2177 | !ShouldUpdateCompositionInfo(range, character_bounds)) { |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 2178 | return; |
nona | fa29179 | 2016-08-10 02:36:18 | [diff] [blame] | 2179 | } |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 2180 | composition_character_bounds_ = character_bounds; |
| 2181 | composition_range_ = range; |
Dave Tapuska | 04bc5ee9 | 2018-04-17 19:03:31 | [diff] [blame] | 2182 | if (mojom::WidgetInputHandlerHost* host = |
| 2183 | widget_input_handler_manager_->GetWidgetInputHandlerHost()) { |
| 2184 | host->ImeCompositionRangeChanged(composition_range_, |
| 2185 | composition_character_bounds_); |
Dave Tapuska | 139a72f | 2017-09-06 21:57:03 | [diff] [blame] | 2186 | } |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 2187 | } |
| 2188 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2189 | void RenderWidget::ConvertViewportToWindow(blink::WebRect* rect) { |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 2190 | if (compositor_deps_->IsUseZoomForDSFEnabled()) { |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 2191 | float reverse = 1 / GetOriginalScreenInfo().device_scale_factor; |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 2192 | // TODO(oshima): We may need to allow pixel precision here as the the |
oshima | f866dab | 2015-12-05 00:41:54 | [diff] [blame] | 2193 | // anchor element can be placed at half pixel. |
lfg | 15b235a3 | 2016-08-25 17:45:46 | [diff] [blame] | 2194 | gfx::Rect window_rect = |
| 2195 | gfx::ScaleToEnclosedRect(gfx::Rect(*rect), reverse); |
| 2196 | rect->x = window_rect.x(); |
| 2197 | rect->y = window_rect.y(); |
| 2198 | rect->width = window_rect.width(); |
| 2199 | rect->height = window_rect.height(); |
oshima | f866dab | 2015-12-05 00:41:54 | [diff] [blame] | 2200 | } |
| 2201 | } |
| 2202 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2203 | void RenderWidget::ConvertWindowToViewport(blink::WebFloatRect* rect) { |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 2204 | if (compositor_deps_->IsUseZoomForDSFEnabled()) { |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 2205 | rect->x *= GetOriginalScreenInfo().device_scale_factor; |
| 2206 | rect->y *= GetOriginalScreenInfo().device_scale_factor; |
| 2207 | rect->width *= GetOriginalScreenInfo().device_scale_factor; |
| 2208 | rect->height *= GetOriginalScreenInfo().device_scale_factor; |
oshima | a6985b6 | 2016-01-27 08:58:30 | [diff] [blame] | 2209 | } |
| 2210 | } |
| 2211 | |
changwan | 8c34274 | 2016-02-26 00:53:39 | [diff] [blame] | 2212 | void RenderWidget::OnRequestTextInputStateUpdate() { |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 2213 | #if defined(OS_ANDROID) |
changwan | 8c34274 | 2016-02-26 00:53:39 | [diff] [blame] | 2214 | DCHECK(!ime_event_guard_); |
| 2215 | UpdateSelectionBounds(); |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 2216 | UpdateTextInputStateInternal(false, true /* reply_to_request */); |
[email protected] | 105dffb4 | 2013-02-20 03:46:21 | [diff] [blame] | 2217 | #endif |
Dave Tapuska | 9db8084 | 2017-07-24 17:24:26 | [diff] [blame] | 2218 | } |
[email protected] | 105dffb4 | 2013-02-20 03:46:21 | [diff] [blame] | 2219 | |
ekaramad | c9b70a7 | 2017-03-23 16:14:23 | [diff] [blame] | 2220 | void RenderWidget::OnRequestCompositionUpdates(bool immediate_request, |
| 2221 | bool monitor_updates) { |
| 2222 | monitor_composition_info_ = monitor_updates; |
nona | fa29179 | 2016-08-10 02:36:18 | [diff] [blame] | 2223 | if (!immediate_request) |
| 2224 | return; |
| 2225 | UpdateCompositionInfo(true /* immediate request */); |
| 2226 | } |
| 2227 | |
[email protected] | fcdc564 | 2014-05-09 14:32:24 | [diff] [blame] | 2228 | void RenderWidget::OnOrientationChange() { |
Ehsan Karamad | 655d7b8a | 2018-01-12 18:38:38 | [diff] [blame] | 2229 | if (auto* frame_widget = GetFrameWidget()) { |
Alex Moshchuk | 0b409c4 | 2017-09-13 02:09:00 | [diff] [blame] | 2230 | // LocalRoot() might return null for provisional main frames. In this case, |
| 2231 | // the frame hasn't committed a navigation and is not swapped into the tree |
| 2232 | // yet, so it doesn't make sense to send orientation change events to it. |
| 2233 | // |
| 2234 | // TODO(https://crbug.com/578349): This check should be cleaned up |
| 2235 | // once provisional frames are gone. |
Ehsan Karamad | 655d7b8a | 2018-01-12 18:38:38 | [diff] [blame] | 2236 | if (frame_widget->LocalRoot()) |
| 2237 | frame_widget->LocalRoot()->SendOrientationChangeEvent(); |
lfg | 8d649cc | 2017-04-28 18:04:30 | [diff] [blame] | 2238 | } |
[email protected] | fcdc564 | 2014-05-09 14:32:24 | [diff] [blame] | 2239 | } |
| 2240 | |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 2241 | void RenderWidget::SetHidden(bool hidden) { |
| 2242 | if (is_hidden_ == hidden) |
| 2243 | return; |
| 2244 | |
jdduke | 8fac9d10 | 2014-12-20 02:40:13 | [diff] [blame] | 2245 | // The status has changed. Tell the RenderThread about it and ensure |
| 2246 | // throttled acks are released in case frame production ceases. |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 2247 | is_hidden_ = hidden; |
jdduke | 8fac9d10 | 2014-12-20 02:40:13 | [diff] [blame] | 2248 | |
Scott Violet | 1098538e | 2017-10-05 19:23:33 | [diff] [blame] | 2249 | #if defined(USE_AURA) |
Scott Violet | e46b335 | 2018-09-22 00:37:07 | [diff] [blame] | 2250 | if (features::IsMultiProcessMash()) |
Scott Violet | 1098538e | 2017-10-05 19:23:33 | [diff] [blame] | 2251 | RendererWindowTreeClient::Get(routing_id_)->SetVisible(!hidden); |
| 2252 | #endif |
| 2253 | |
Saman Sami | 58ed439 | 2018-01-31 20:54:19 | [diff] [blame] | 2254 | // RenderThreadImpl::current() could be null in tests. |
| 2255 | if (RenderThreadImpl::current()) { |
| 2256 | if (is_hidden_) { |
| 2257 | RenderThreadImpl::current()->WidgetHidden(); |
| 2258 | first_update_visual_state_after_hidden_ = true; |
| 2259 | } else { |
| 2260 | RenderThreadImpl::current()->WidgetRestored(); |
| 2261 | } |
Lei Zhang | 9b359d3 | 2017-11-28 00:57:02 | [diff] [blame] | 2262 | } |
alexclarke | 7fa9394 | 2015-10-21 15:37:11 | [diff] [blame] | 2263 | |
| 2264 | if (render_widget_scheduling_state_) |
| 2265 | render_widget_scheduling_state_->SetHidden(hidden); |
danakj | 1b35e9d | 2018-11-07 19:09:28 | [diff] [blame] | 2266 | |
| 2267 | layer_tree_view_->SetVisible(!is_hidden_); |
[email protected] | bee16aab | 2009-08-26 15:55:03 | [diff] [blame] | 2268 | } |
| 2269 | |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 2270 | void RenderWidget::DidToggleFullscreen() { |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 2271 | if (!GetWebWidget()) |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 2272 | return; |
| 2273 | |
mikhail.pozdnyakov | f2c902a | 2015-04-14 08:09:12 | [diff] [blame] | 2274 | if (is_fullscreen_granted_) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2275 | GetWebWidget()->DidEnterFullscreen(); |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 2276 | } else { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2277 | GetWebWidget()->DidExitFullscreen(); |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 2278 | } |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 2279 | } |
| 2280 | |
changwan | f2a707b | 2015-10-30 08:22:16 | [diff] [blame] | 2281 | void RenderWidget::OnImeEventGuardStart(ImeEventGuard* guard) { |
| 2282 | if (!ime_event_guard_) |
| 2283 | ime_event_guard_ = guard; |
[email protected] | 66fca5bc | 2013-05-23 06:58:29 | [diff] [blame] | 2284 | } |
| 2285 | |
changwan | f2a707b | 2015-10-30 08:22:16 | [diff] [blame] | 2286 | void RenderWidget::OnImeEventGuardFinish(ImeEventGuard* guard) { |
Jeremy Roman | 0b261f4 | 2018-08-28 15:36:01 | [diff] [blame] | 2287 | if (ime_event_guard_ != guard) |
changwan | f2a707b | 2015-10-30 08:22:16 | [diff] [blame] | 2288 | return; |
changwan | f2a707b | 2015-10-30 08:22:16 | [diff] [blame] | 2289 | ime_event_guard_ = nullptr; |
| 2290 | |
[email protected] | 66fca5bc | 2013-05-23 06:58:29 | [diff] [blame] | 2291 | // While handling an ime event, text input state and selection bounds updates |
| 2292 | // are ignored. These must explicitly be updated once finished handling the |
| 2293 | // ime event. |
| 2294 | UpdateSelectionBounds(); |
[email protected] | cb9e263 | 2013-06-18 11:26:47 | [diff] [blame] | 2295 | #if defined(OS_ANDROID) |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 2296 | if (guard->show_virtual_keyboard()) |
| 2297 | ShowVirtualKeyboard(); |
| 2298 | else |
| 2299 | UpdateTextInputState(); |
[email protected] | cb9e263 | 2013-06-18 11:26:47 | [diff] [blame] | 2300 | #endif |
[email protected] | 66fca5bc | 2013-05-23 06:58:29 | [diff] [blame] | 2301 | } |
| 2302 | |
[email protected] | 7c8873e | 2013-02-05 08:03:01 | [diff] [blame] | 2303 | void RenderWidget::GetSelectionBounds(gfx::Rect* focus, gfx::Rect* anchor) { |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 2304 | #if BUILDFLAG(ENABLE_PLUGINS) |
EhsanK | 22d482e | 2017-08-10 17:29:49 | [diff] [blame] | 2305 | if (auto* plugin = GetFocusedPepperPluginInsideWidget()) { |
ekaramad | 2a46d63 | 2016-07-19 13:33:09 | [diff] [blame] | 2306 | // TODO(kinaba) http://crbug.com/101101 |
| 2307 | // Current Pepper IME API does not handle selection bounds. So we simply |
| 2308 | // use the caret position as an empty range for now. It will be updated |
| 2309 | // after Pepper API equips features related to surrounding text retrieval. |
EhsanK | 22d482e | 2017-08-10 17:29:49 | [diff] [blame] | 2310 | blink::WebRect caret(plugin->GetCaretBounds()); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2311 | ConvertViewportToWindow(&caret); |
ekaramad | 2a46d63 | 2016-07-19 13:33:09 | [diff] [blame] | 2312 | *focus = caret; |
| 2313 | *anchor = caret; |
| 2314 | return; |
| 2315 | } |
| 2316 | #endif |
[email protected] | 7c8873e | 2013-02-05 08:03:01 | [diff] [blame] | 2317 | WebRect focus_webrect; |
| 2318 | WebRect anchor_webrect; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2319 | GetWebWidget()->SelectionBounds(focus_webrect, anchor_webrect); |
| 2320 | ConvertViewportToWindow(&focus_webrect); |
| 2321 | ConvertViewportToWindow(&anchor_webrect); |
oshima | 33ec97cd | 2015-12-14 19:40:24 | [diff] [blame] | 2322 | *focus = focus_webrect; |
| 2323 | *anchor = anchor_webrect; |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 2324 | } |
| 2325 | |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 2326 | void RenderWidget::UpdateSelectionBounds() { |
jdduke | 1aebad8e | 2015-07-22 23:25:08 | [diff] [blame] | 2327 | TRACE_EVENT0("renderer", "RenderWidget::UpdateSelectionBounds"); |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 2328 | if (!GetWebWidget()) |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 2329 | return; |
changwan | f2a707b | 2015-10-30 08:22:16 | [diff] [blame] | 2330 | if (ime_event_guard_) |
[email protected] | 66fca5bc | 2013-05-23 06:58:29 | [diff] [blame] | 2331 | return; |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 2332 | |
mohsen | b0eeba7 | 2015-08-09 06:20:08 | [diff] [blame] | 2333 | #if defined(USE_AURA) |
| 2334 | // TODO(mohsen): For now, always send explicit selection IPC notifications for |
| 2335 | // Aura beucause composited selection updates are not working for webview tags |
| 2336 | // which regresses IME inside webview. Remove this when composited selection |
| 2337 | // updates are fixed for webviews. See, http://crbug.com/510568. |
| 2338 | bool send_ipc = true; |
| 2339 | #else |
jdduke | acf809e | 2014-09-23 20:38:38 | [diff] [blame] | 2340 | // With composited selection updates, the selection bounds will be reported |
| 2341 | // directly by the compositor, in which case explicit IPC selection |
| 2342 | // notifications should be suppressed. |
mohsen | b0eeba7 | 2015-08-09 06:20:08 | [diff] [blame] | 2343 | bool send_ipc = |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2344 | !blink::WebRuntimeFeatures::IsCompositedSelectionUpdateEnabled(); |
mohsen | b0eeba7 | 2015-08-09 06:20:08 | [diff] [blame] | 2345 | #endif |
| 2346 | if (send_ipc) { |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 2347 | WidgetHostMsg_SelectionBounds_Params params; |
EhsanK | 955ba58 | 2017-11-30 21:14:40 | [diff] [blame] | 2348 | params.is_anchor_first = false; |
jdduke | acf809e | 2014-09-23 20:38:38 | [diff] [blame] | 2349 | GetSelectionBounds(¶ms.anchor_rect, ¶ms.focus_rect); |
| 2350 | if (selection_anchor_rect_ != params.anchor_rect || |
| 2351 | selection_focus_rect_ != params.focus_rect) { |
| 2352 | selection_anchor_rect_ = params.anchor_rect; |
| 2353 | selection_focus_rect_ = params.focus_rect; |
EhsanK | 955ba58 | 2017-11-30 21:14:40 | [diff] [blame] | 2354 | if (auto* focused_frame = GetFocusedWebLocalFrameInWidget()) { |
| 2355 | focused_frame->SelectionTextDirection(params.focus_dir, |
| 2356 | params.anchor_dir); |
| 2357 | params.is_anchor_first = focused_frame->IsSelectionAnchorFirst(); |
| 2358 | } |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 2359 | Send(new WidgetHostMsg_SelectionBoundsChanged(routing_id_, params)); |
jdduke | acf809e | 2014-09-23 20:38:38 | [diff] [blame] | 2360 | } |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 2361 | } |
jdduke | acf809e | 2014-09-23 20:38:38 | [diff] [blame] | 2362 | |
nona | fa29179 | 2016-08-10 02:36:18 | [diff] [blame] | 2363 | UpdateCompositionInfo(false /* not an immediate request */); |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 2364 | } |
| 2365 | |
lfg | b00fcad | 2016-07-14 14:16:33 | [diff] [blame] | 2366 | void RenderWidget::DidAutoResize(const gfx::Size& new_size) { |
| 2367 | WebRect new_size_in_window(0, 0, new_size.width(), new_size.height()); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2368 | ConvertViewportToWindow(&new_size_in_window); |
lfg | b00fcad | 2016-07-14 14:16:33 | [diff] [blame] | 2369 | if (size_.width() != new_size_in_window.width || |
| 2370 | size_.height() != new_size_in_window.height) { |
| 2371 | size_ = gfx::Size(new_size_in_window.width, new_size_in_window.height); |
| 2372 | |
| 2373 | if (resizing_mode_selector_->is_synchronous_mode()) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2374 | gfx::Rect new_pos(WindowRect().x, WindowRect().y, size_.width(), |
| 2375 | size_.height()); |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 2376 | widget_screen_rect_ = new_pos; |
lfg | b00fcad | 2016-07-14 14:16:33 | [diff] [blame] | 2377 | window_screen_rect_ = new_pos; |
| 2378 | } |
| 2379 | |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 2380 | // TODO(ccameron): Note that this destroys any information differentiating |
Christopher Cameron | aad15a0d | 2018-03-09 03:47:33 | [diff] [blame] | 2381 | // |size_| from |compositor_viewport_pixel_size_|. Also note that the |
| 2382 | // calculation of |new_compositor_viewport_pixel_size| does not appear to |
| 2383 | // take into account device emulation. |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 2384 | if (layer_tree_view_) |
| 2385 | layer_tree_view_->RequestNewLocalSurfaceId(); |
Christopher Cameron | aad15a0d | 2018-03-09 03:47:33 | [diff] [blame] | 2386 | gfx::Size new_compositor_viewport_pixel_size = |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 2387 | gfx::ScaleToCeiledSize(size_, GetWebScreenInfo().device_scale_factor); |
Fady Samuel | 1c1ad369 | 2018-11-06 23:28:40 | [diff] [blame] | 2388 | UpdateSurfaceAndScreenInfo(local_surface_id_allocation_from_parent_, |
| 2389 | new_compositor_viewport_pixel_size, |
| 2390 | screen_info_); |
lfg | b00fcad | 2016-07-14 14:16:33 | [diff] [blame] | 2391 | } |
| 2392 | } |
| 2393 | |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 2394 | void RenderWidget::GetCompositionCharacterBounds( |
| 2395 | std::vector<gfx::Rect>* bounds) { |
| 2396 | DCHECK(bounds); |
| 2397 | bounds->clear(); |
ekaramad | 2a46d63 | 2016-07-19 13:33:09 | [diff] [blame] | 2398 | |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 2399 | #if BUILDFLAG(ENABLE_PLUGINS) |
EhsanK | 22d482e | 2017-08-10 17:29:49 | [diff] [blame] | 2400 | if (GetFocusedPepperPluginInsideWidget()) |
ekaramad | 2a46d63 | 2016-07-19 13:33:09 | [diff] [blame] | 2401 | return; |
| 2402 | #endif |
| 2403 | |
Ehsan Karamad | 4975af6d | 2018-02-09 16:58:16 | [diff] [blame] | 2404 | blink::WebInputMethodController* controller = GetInputMethodController(); |
| 2405 | if (!controller) |
ekaramad | 2a46d63 | 2016-07-19 13:33:09 | [diff] [blame] | 2406 | return; |
| 2407 | blink::WebVector<blink::WebRect> bounds_from_blink; |
Ehsan Karamad | 4975af6d | 2018-02-09 16:58:16 | [diff] [blame] | 2408 | if (!controller->GetCompositionCharacterBounds(bounds_from_blink)) |
ekaramad | 2a46d63 | 2016-07-19 13:33:09 | [diff] [blame] | 2409 | return; |
| 2410 | |
| 2411 | for (size_t i = 0; i < bounds_from_blink.size(); ++i) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2412 | ConvertViewportToWindow(&bounds_from_blink[i]); |
ekaramad | 2a46d63 | 2016-07-19 13:33:09 | [diff] [blame] | 2413 | bounds->push_back(bounds_from_blink[i]); |
| 2414 | } |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 2415 | } |
| 2416 | |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 2417 | void RenderWidget::GetCompositionRange(gfx::Range* range) { |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 2418 | #if BUILDFLAG(ENABLE_PLUGINS) |
EhsanK | 22d482e | 2017-08-10 17:29:49 | [diff] [blame] | 2419 | if (GetFocusedPepperPluginInsideWidget()) |
ekaramad | 2a46d63 | 2016-07-19 13:33:09 | [diff] [blame] | 2420 | return; |
| 2421 | #endif |
EhsanK | cdee7b7 | 2017-11-08 21:30:09 | [diff] [blame] | 2422 | blink::WebInputMethodController* controller = GetInputMethodController(); |
| 2423 | WebRange web_range = controller ? controller->CompositionRange() : WebRange(); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2424 | if (web_range.IsNull()) { |
nona | 2363a3d | 2016-11-09 03:26:21 | [diff] [blame] | 2425 | *range = gfx::Range::InvalidRange(); |
| 2426 | return; |
[email protected] | 88dbe32f | 2013-06-20 23:31:36 | [diff] [blame] | 2427 | } |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2428 | range->set_start(web_range.StartOffset()); |
| 2429 | range->set_end(web_range.EndOffset()); |
[email protected] | 88dbe32f | 2013-06-20 23:31:36 | [diff] [blame] | 2430 | } |
| 2431 | |
[email protected] | 501ea13d | 2013-07-09 17:03:29 | [diff] [blame] | 2432 | bool RenderWidget::ShouldUpdateCompositionInfo( |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 2433 | const gfx::Range& range, |
[email protected] | 501ea13d | 2013-07-09 17:03:29 | [diff] [blame] | 2434 | const std::vector<gfx::Rect>& bounds) { |
changwan | 2418e1b | 2016-12-12 12:43:08 | [diff] [blame] | 2435 | if (!range.IsValid()) |
| 2436 | return false; |
[email protected] | 501ea13d | 2013-07-09 17:03:29 | [diff] [blame] | 2437 | if (composition_range_ != range) |
| 2438 | return true; |
| 2439 | if (bounds.size() != composition_character_bounds_.size()) |
| 2440 | return true; |
| 2441 | for (size_t i = 0; i < bounds.size(); ++i) { |
| 2442 | if (bounds[i] != composition_character_bounds_[i]) |
| 2443 | return true; |
| 2444 | } |
| 2445 | return false; |
| 2446 | } |
[email protected] | 501ea13d | 2013-07-09 17:03:29 | [diff] [blame] | 2447 | |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 2448 | bool RenderWidget::CanComposeInline() { |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 2449 | #if BUILDFLAG(ENABLE_PLUGINS) |
EhsanK | 22d482e | 2017-08-10 17:29:49 | [diff] [blame] | 2450 | if (auto* plugin = GetFocusedPepperPluginInsideWidget()) |
| 2451 | return plugin->IsPluginAcceptingCompositionEvents(); |
ekaramad | 2a46d63 | 2016-07-19 13:33:09 | [diff] [blame] | 2452 | #endif |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 2453 | return true; |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 2454 | } |
| 2455 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2456 | void RenderWidget::DidHandleGestureEvent(const WebGestureEvent& event, |
| 2457 | bool event_cancelled) { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 2458 | if (event_cancelled) { |
| 2459 | // The |owner_delegate_| doesn't need to hear about cancelled events. |
[email protected] | c68c3e4e | 2013-01-24 00:36:56 | [diff] [blame] | 2460 | return; |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 2461 | } |
| 2462 | |
| 2463 | #if defined(OS_ANDROID) || defined(USE_AURA) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2464 | if (event.GetType() == WebInputEvent::kGestureTap) { |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 2465 | ShowVirtualKeyboard(); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2466 | } else if (event.GetType() == WebInputEvent::kGestureLongPress) { |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 2467 | DCHECK(GetWebWidget()); |
ekaramad | 5aff194 | 2017-01-06 01:26:35 | [diff] [blame] | 2468 | blink::WebInputMethodController* controller = GetInputMethodController(); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2469 | if (!controller || controller->TextInputInfo().value.IsEmpty()) |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 2470 | UpdateTextInputState(); |
[email protected] | 07c70d2 | 2014-08-21 08:33:46 | [diff] [blame] | 2471 | else |
changwan | 75e3b207 | 2017-01-16 02:55:00 | [diff] [blame] | 2472 | ShowVirtualKeyboard(); |
[email protected] | c68c3e4e | 2013-01-24 00:36:56 | [diff] [blame] | 2473 | } |
ekaramad | a110f64 | 2016-12-21 19:47:28 | [diff] [blame] | 2474 | // TODO(ananta): Piggyback off existing IPCs to communicate this information, |
| 2475 | // crbug/420130. |
| 2476 | #if defined(OS_WIN) |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 2477 | if (event.GetType() == blink::WebGestureEvent::kGestureTap) { |
| 2478 | // TODO(estade): hit test the event against focused node to make sure |
| 2479 | // the tap actually hit the focused node. |
| 2480 | blink::WebInputMethodController* controller = GetInputMethodController(); |
| 2481 | blink::WebTextInputType text_input_type = |
| 2482 | controller ? controller->TextInputType() : blink::kWebTextInputTypeNone; |
ekaramad | a110f64 | 2016-12-21 19:47:28 | [diff] [blame] | 2483 | |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 2484 | Send(new WidgetHostMsg_FocusedNodeTouched( |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 2485 | routing_id_, text_input_type != blink::kWebTextInputTypeNone)); |
| 2486 | } |
ekaramad | a110f64 | 2016-12-21 19:47:28 | [diff] [blame] | 2487 | #endif |
[email protected] | c68c3e4e | 2013-01-24 00:36:56 | [diff] [blame] | 2488 | #endif |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 2489 | |
| 2490 | // The |owner_delegate_| gets to respond to handling gestures last. |
| 2491 | if (owner_delegate_) |
| 2492 | owner_delegate_->DidHandleGestureEventForWidget(event); |
[email protected] | c68c3e4e | 2013-01-24 00:36:56 | [diff] [blame] | 2493 | } |
| 2494 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2495 | void RenderWidget::DidOverscroll( |
bokan | e53a10f | 2016-04-13 23:48:31 | [diff] [blame] | 2496 | const blink::WebFloatSize& overscrollDelta, |
| 2497 | const blink::WebFloatSize& accumulatedOverscroll, |
sataya.m | 582c9ce | 2015-06-09 08:03:42 | [diff] [blame] | 2498 | const blink::WebFloatPoint& position, |
sunyunjia | bbea8a9 | 2017-08-31 11:18:54 | [diff] [blame] | 2499 | const blink::WebFloatSize& velocity, |
danakj | e819b62 | 2018-05-01 20:27:14 | [diff] [blame] | 2500 | const cc::OverscrollBehavior& behavior) { |
bokan | 731ec38 | 2016-04-07 03:16:48 | [diff] [blame] | 2501 | #if defined(OS_MACOSX) |
| 2502 | // On OSX the user can disable the elastic overscroll effect. If that's the |
| 2503 | // case, don't forward the overscroll notification. |
| 2504 | DCHECK(compositor_deps()); |
| 2505 | if (!compositor_deps()->IsElasticOverscrollEnabled()) |
| 2506 | return; |
| 2507 | #endif |
bokan | e53a10f | 2016-04-13 23:48:31 | [diff] [blame] | 2508 | input_handler_->DidOverscrollFromBlink(overscrollDelta, accumulatedOverscroll, |
sunyunjia | bbea8a9 | 2017-08-31 11:18:54 | [diff] [blame] | 2509 | position, velocity, behavior); |
sataya.m | 582c9ce | 2015-06-09 08:03:42 | [diff] [blame] | 2510 | } |
| 2511 | |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 2512 | // static |
| 2513 | cc::LayerTreeSettings RenderWidget::GenerateLayerTreeSettings( |
| 2514 | CompositorDependencies* compositor_deps, |
| 2515 | bool is_for_subframe, |
| 2516 | const gfx::Size& initial_screen_size, |
| 2517 | float initial_device_scale_factor) { |
| 2518 | const bool is_threaded = |
| 2519 | !!compositor_deps->GetCompositorImplThreadTaskRunner(); |
| 2520 | |
| 2521 | const base::CommandLine& cmd = *base::CommandLine::ForCurrentProcess(); |
| 2522 | cc::LayerTreeSettings settings; |
| 2523 | |
| 2524 | settings.resource_settings.use_r16_texture = |
| 2525 | base::FeatureList::IsEnabled(media::kUseR16Texture); |
| 2526 | |
| 2527 | settings.commit_to_active_tree = !is_threaded; |
| 2528 | settings.is_layer_tree_for_subframe = is_for_subframe; |
| 2529 | |
| 2530 | // For web contents, layer transforms should scale up the contents of layers |
| 2531 | // to keep content always crisp when possible. |
| 2532 | settings.layer_transforms_should_scale_layer_contents = true; |
| 2533 | |
| 2534 | settings.main_frame_before_activation_enabled = |
| 2535 | cmd.HasSwitch(cc::switches::kEnableMainFrameBeforeActivation); |
| 2536 | |
| 2537 | // Checkerimaging is not supported for synchronous single-threaded mode, which |
| 2538 | // is what the renderer uses if its not threaded. |
| 2539 | settings.enable_checker_imaging = |
| 2540 | !cmd.HasSwitch(cc::switches::kDisableCheckerImaging) && is_threaded; |
| 2541 | |
| 2542 | #if defined(OS_ANDROID) |
| 2543 | // We can use a more aggressive limit on Android since decodes tend to take |
| 2544 | // longer on these devices. |
| 2545 | settings.min_image_bytes_to_checker = 512 * 1024; // 512kB |
| 2546 | |
| 2547 | // Re-rasterization of checker-imaged content with software raster can be too |
| 2548 | // costly on Android. |
| 2549 | settings.only_checker_images_with_gpu_raster = true; |
| 2550 | #endif |
| 2551 | |
| 2552 | auto switch_value_as_int = [](const base::CommandLine& command_line, |
| 2553 | const std::string& switch_string, int min_value, |
| 2554 | int max_value, int* result) { |
| 2555 | std::string string_value = command_line.GetSwitchValueASCII(switch_string); |
| 2556 | int int_value; |
| 2557 | if (base::StringToInt(string_value, &int_value) && int_value >= min_value && |
| 2558 | int_value <= max_value) { |
| 2559 | *result = int_value; |
| 2560 | return true; |
| 2561 | } else { |
| 2562 | LOG(WARNING) << "Failed to parse switch " << switch_string << ": " |
| 2563 | << string_value; |
| 2564 | return false; |
| 2565 | } |
| 2566 | }; |
| 2567 | |
| 2568 | int default_tile_size = 256; |
| 2569 | #if defined(OS_ANDROID) |
| 2570 | const gfx::Size screen_size = |
| 2571 | gfx::ScaleToFlooredSize(initial_screen_size, initial_device_scale_factor); |
| 2572 | int display_width = screen_size.width(); |
| 2573 | int display_height = screen_size.height(); |
| 2574 | int numTiles = (display_width * display_height) / (256 * 256); |
| 2575 | if (numTiles > 16) |
| 2576 | default_tile_size = 384; |
| 2577 | if (numTiles >= 40) |
| 2578 | default_tile_size = 512; |
| 2579 | |
| 2580 | // Adjust for some resolutions that barely straddle an extra |
| 2581 | // tile when in portrait mode. This helps worst case scroll/raster |
| 2582 | // by not needing a full extra tile for each row. |
| 2583 | constexpr int tolerance = 10; // To avoid rounding errors. |
| 2584 | int portrait_width = std::min(display_width, display_height); |
| 2585 | if (default_tile_size == 256 && std::abs(portrait_width - 768) < tolerance) |
| 2586 | default_tile_size += 32; |
| 2587 | if (default_tile_size == 384 && std::abs(portrait_width - 1200) < tolerance) |
| 2588 | default_tile_size += 32; |
| 2589 | #elif defined(OS_CHROMEOS) || defined(OS_MACOSX) |
| 2590 | // Use 512 for high DPI (dsf=2.0f) devices. |
| 2591 | if (initial_device_scale_factor >= 2.0f) |
| 2592 | default_tile_size = 512; |
| 2593 | #endif |
| 2594 | |
| 2595 | // TODO(danakj): This should not be a setting O_O; it should change when the |
| 2596 | // device scale factor on LayerTreeHost changes. |
| 2597 | settings.default_tile_size = gfx::Size(default_tile_size, default_tile_size); |
| 2598 | if (cmd.HasSwitch(switches::kDefaultTileWidth)) { |
| 2599 | int tile_width = 0; |
| 2600 | switch_value_as_int(cmd, switches::kDefaultTileWidth, 1, |
| 2601 | std::numeric_limits<int>::max(), &tile_width); |
| 2602 | settings.default_tile_size.set_width(tile_width); |
| 2603 | } |
| 2604 | if (cmd.HasSwitch(switches::kDefaultTileHeight)) { |
| 2605 | int tile_height = 0; |
| 2606 | switch_value_as_int(cmd, switches::kDefaultTileHeight, 1, |
| 2607 | std::numeric_limits<int>::max(), &tile_height); |
| 2608 | settings.default_tile_size.set_height(tile_height); |
| 2609 | } |
| 2610 | |
| 2611 | int max_untiled_layer_width = settings.max_untiled_layer_size.width(); |
| 2612 | if (cmd.HasSwitch(switches::kMaxUntiledLayerWidth)) { |
| 2613 | switch_value_as_int(cmd, switches::kMaxUntiledLayerWidth, 1, |
| 2614 | std::numeric_limits<int>::max(), |
| 2615 | &max_untiled_layer_width); |
| 2616 | } |
| 2617 | int max_untiled_layer_height = settings.max_untiled_layer_size.height(); |
| 2618 | if (cmd.HasSwitch(switches::kMaxUntiledLayerHeight)) { |
| 2619 | switch_value_as_int(cmd, switches::kMaxUntiledLayerHeight, 1, |
| 2620 | std::numeric_limits<int>::max(), |
| 2621 | &max_untiled_layer_height); |
| 2622 | } |
| 2623 | |
| 2624 | settings.max_untiled_layer_size = |
| 2625 | gfx::Size(max_untiled_layer_width, max_untiled_layer_height); |
| 2626 | |
| 2627 | settings.gpu_rasterization_msaa_sample_count = |
| 2628 | compositor_deps->GetGpuRasterizationMSAASampleCount(); |
| 2629 | settings.gpu_rasterization_forced = |
| 2630 | compositor_deps->IsGpuRasterizationForced(); |
| 2631 | |
| 2632 | settings.can_use_lcd_text = compositor_deps->IsLcdTextEnabled(); |
| 2633 | settings.use_zero_copy = compositor_deps->IsZeroCopyEnabled(); |
| 2634 | settings.use_partial_raster = compositor_deps->IsPartialRasterEnabled(); |
| 2635 | settings.enable_elastic_overscroll = |
| 2636 | compositor_deps->IsElasticOverscrollEnabled(); |
| 2637 | settings.resource_settings.use_gpu_memory_buffer_resources = |
| 2638 | compositor_deps->IsGpuMemoryBufferCompositorResourcesEnabled(); |
| 2639 | settings.use_painted_device_scale_factor = |
| 2640 | compositor_deps->IsUseZoomForDSFEnabled(); |
| 2641 | |
| 2642 | // Build LayerTreeSettings from command line args. |
| 2643 | if (cmd.HasSwitch(cc::switches::kBrowserControlsShowThreshold)) { |
| 2644 | std::string top_threshold_str = |
| 2645 | cmd.GetSwitchValueASCII(cc::switches::kBrowserControlsShowThreshold); |
| 2646 | double show_threshold; |
| 2647 | if (base::StringToDouble(top_threshold_str, &show_threshold) && |
| 2648 | show_threshold >= 0.f && show_threshold <= 1.f) |
| 2649 | settings.top_controls_show_threshold = show_threshold; |
| 2650 | } |
| 2651 | |
| 2652 | if (cmd.HasSwitch(cc::switches::kBrowserControlsHideThreshold)) { |
| 2653 | std::string top_threshold_str = |
| 2654 | cmd.GetSwitchValueASCII(cc::switches::kBrowserControlsHideThreshold); |
| 2655 | double hide_threshold; |
| 2656 | if (base::StringToDouble(top_threshold_str, &hide_threshold) && |
| 2657 | hide_threshold >= 0.f && hide_threshold <= 1.f) |
| 2658 | settings.top_controls_hide_threshold = hide_threshold; |
| 2659 | } |
| 2660 | |
Philip Rogers | fc2f116 | 2018-10-17 18:28:31 | [diff] [blame] | 2661 | // Blink sends cc a layer list and property trees when either Blink Gen |
| 2662 | // Property Trees or Slimming Paint V2 are enabled. |
| 2663 | settings.use_layer_lists = |
| 2664 | blink::WebRuntimeFeatures::IsBlinkGenPropertyTreesEnabled() || |
| 2665 | blink::WebRuntimeFeatures::IsSlimmingPaintV2Enabled(); |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 2666 | |
David Bokan | 163b6a7 | 2018-10-25 22:03:49 | [diff] [blame] | 2667 | // Blink currently doesn't support setting fractional scroll offsets so CC |
| 2668 | // must send integer values. We plan to eventually make Blink use fractional |
| 2669 | // offsets internally: https://crbug.com/414283. |
| 2670 | settings.commit_fractional_scroll_deltas = |
| 2671 | blink::WebRuntimeFeatures::IsFractionalScrollOffsetsEnabled(); |
| 2672 | |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 2673 | // The means the renderer compositor has 2 possible modes: |
| 2674 | // - Threaded compositing with a scheduler. |
| 2675 | // - Single threaded compositing without a scheduler (for layout tests only). |
| 2676 | // Using the scheduler in layout tests introduces additional composite steps |
| 2677 | // that create flakiness. |
| 2678 | settings.single_thread_proxy_scheduler = false; |
| 2679 | |
| 2680 | // These flags should be mirrored by UI versions in ui/compositor/. |
| 2681 | if (cmd.HasSwitch(cc::switches::kShowCompositedLayerBorders)) |
| 2682 | settings.initial_debug_state.show_debug_borders.set(); |
| 2683 | settings.initial_debug_state.show_layer_animation_bounds_rects = |
| 2684 | cmd.HasSwitch(cc::switches::kShowLayerAnimationBounds); |
| 2685 | settings.initial_debug_state.show_paint_rects = |
| 2686 | cmd.HasSwitch(switches::kShowPaintRects); |
| 2687 | settings.initial_debug_state.show_property_changed_rects = |
| 2688 | cmd.HasSwitch(cc::switches::kShowPropertyChangedRects); |
| 2689 | settings.initial_debug_state.show_surface_damage_rects = |
| 2690 | cmd.HasSwitch(cc::switches::kShowSurfaceDamageRects); |
| 2691 | settings.initial_debug_state.show_screen_space_rects = |
| 2692 | cmd.HasSwitch(cc::switches::kShowScreenSpaceRects); |
| 2693 | |
| 2694 | settings.initial_debug_state.SetRecordRenderingStats( |
| 2695 | cmd.HasSwitch(cc::switches::kEnableGpuBenchmarking)); |
| 2696 | settings.enable_surface_synchronization = |
| 2697 | features::IsSurfaceSynchronizationEnabled(); |
| 2698 | settings.build_hit_test_data = features::IsVizHitTestingSurfaceLayerEnabled(); |
| 2699 | |
| 2700 | if (cmd.HasSwitch(cc::switches::kSlowDownRasterScaleFactor)) { |
| 2701 | const int kMinSlowDownScaleFactor = 0; |
| 2702 | const int kMaxSlowDownScaleFactor = INT_MAX; |
| 2703 | switch_value_as_int( |
| 2704 | cmd, cc::switches::kSlowDownRasterScaleFactor, kMinSlowDownScaleFactor, |
| 2705 | kMaxSlowDownScaleFactor, |
| 2706 | &settings.initial_debug_state.slow_down_raster_scale_factor); |
| 2707 | } |
| 2708 | |
| 2709 | // This is default overlay scrollbar settings for Android and DevTools mobile |
| 2710 | // emulator. Aura Overlay Scrollbar will override below. |
| 2711 | settings.scrollbar_animator = cc::LayerTreeSettings::ANDROID_OVERLAY; |
| 2712 | settings.solid_color_scrollbar_color = SkColorSetARGB(128, 128, 128, 128); |
| 2713 | settings.scrollbar_fade_delay = base::TimeDelta::FromMilliseconds(300); |
| 2714 | settings.scrollbar_fade_duration = base::TimeDelta::FromMilliseconds(300); |
| 2715 | |
| 2716 | #if defined(OS_ANDROID) |
| 2717 | bool using_synchronous_compositor = |
| 2718 | compositor_deps->UsingSynchronousCompositing(); |
| 2719 | bool using_low_memory_policy = base::SysInfo::IsLowEndDevice(); |
| 2720 | |
| 2721 | settings.use_stream_video_draw_quad = true; |
| 2722 | settings.using_synchronous_renderer_compositor = using_synchronous_compositor; |
| 2723 | if (using_synchronous_compositor) { |
| 2724 | // Android WebView uses system scrollbars, so make ours invisible. |
| 2725 | // http://crbug.com/677348: This can't be done using hide_scrollbars |
| 2726 | // setting because supporting -webkit custom scrollbars is still desired |
| 2727 | // on sublayers. |
| 2728 | settings.scrollbar_animator = cc::LayerTreeSettings::NO_ANIMATOR; |
| 2729 | settings.solid_color_scrollbar_color = SK_ColorTRANSPARENT; |
| 2730 | |
| 2731 | settings.enable_early_damage_check = |
| 2732 | cmd.HasSwitch(cc::switches::kCheckDamageEarly); |
| 2733 | } |
| 2734 | // Android WebView handles root layer flings itself. |
| 2735 | settings.ignore_root_layer_flings = using_synchronous_compositor; |
| 2736 | // Memory policy on Android WebView does not depend on whether device is |
| 2737 | // low end, so always use default policy. |
| 2738 | if (using_low_memory_policy && !using_synchronous_compositor) { |
| 2739 | // On low-end we want to be very carefull about killing other |
| 2740 | // apps. So initially we use 50% more memory to avoid flickering |
| 2741 | // or raster-on-demand. |
| 2742 | settings.max_memory_for_prepaint_percentage = 67; |
| 2743 | } else { |
| 2744 | // On other devices we have increased memory excessively to avoid |
| 2745 | // raster-on-demand already, so now we reserve 50% _only_ to avoid |
| 2746 | // raster-on-demand, and use 50% of the memory otherwise. |
| 2747 | settings.max_memory_for_prepaint_percentage = 50; |
| 2748 | } |
| 2749 | |
| 2750 | // TODO(danakj): Only do this on low end devices. |
| 2751 | settings.create_low_res_tiling = true; |
| 2752 | |
| 2753 | #else // defined(OS_ANDROID) |
| 2754 | bool using_synchronous_compositor = false; // Only for Android WebView. |
| 2755 | // On desktop, we never use the low memory policy unless we are simulating |
| 2756 | // low-end mode via a switch. |
| 2757 | bool using_low_memory_policy = |
| 2758 | cmd.HasSwitch(switches::kEnableLowEndDeviceMode); |
| 2759 | |
| 2760 | if (ui::IsOverlayScrollbarEnabled()) { |
| 2761 | settings.scrollbar_animator = cc::LayerTreeSettings::AURA_OVERLAY; |
| 2762 | settings.scrollbar_fade_delay = ui::kOverlayScrollbarFadeDelay; |
| 2763 | settings.scrollbar_fade_duration = ui::kOverlayScrollbarFadeDuration; |
| 2764 | settings.scrollbar_thinning_duration = |
| 2765 | ui::kOverlayScrollbarThinningDuration; |
| 2766 | settings.scrollbar_flash_after_any_scroll_update = |
| 2767 | ui::OverlayScrollbarFlashAfterAnyScrollUpdate(); |
| 2768 | settings.scrollbar_flash_when_mouse_enter = |
| 2769 | ui::OverlayScrollbarFlashWhenMouseEnter(); |
| 2770 | } |
| 2771 | |
| 2772 | // On desktop, if there's over 4GB of memory on the machine, increase the |
| 2773 | // working set size to 256MB for both gpu and software. |
| 2774 | const int kImageDecodeMemoryThresholdMB = 4 * 1024; |
| 2775 | if (base::SysInfo::AmountOfPhysicalMemoryMB() >= |
| 2776 | kImageDecodeMemoryThresholdMB) { |
| 2777 | settings.decoded_image_working_set_budget_bytes = 256 * 1024 * 1024; |
| 2778 | } else { |
| 2779 | // This is the default, but recorded here as well. |
| 2780 | settings.decoded_image_working_set_budget_bytes = 128 * 1024 * 1024; |
| 2781 | } |
| 2782 | #endif // defined(OS_ANDROID) |
| 2783 | |
| 2784 | if (using_low_memory_policy) { |
| 2785 | // RGBA_4444 textures are only enabled: |
| 2786 | // - If the user hasn't explicitly disabled them |
| 2787 | // - If system ram is <= 512MB (1GB devices are sometimes low-end). |
| 2788 | // - If we are not running in a WebView, where 4444 isn't supported. |
| 2789 | if (!cmd.HasSwitch(switches::kDisableRGBA4444Textures) && |
| 2790 | base::SysInfo::AmountOfPhysicalMemoryMB() <= 512 && |
| 2791 | !using_synchronous_compositor) { |
| 2792 | settings.use_rgba_4444 = viz::RGBA_4444; |
| 2793 | |
| 2794 | // If we are going to unpremultiply and dither these tiles, we need to |
| 2795 | // allocate an additional RGBA_8888 intermediate for each tile |
| 2796 | // rasterization when rastering to RGBA_4444 to allow for dithering. |
| 2797 | // Setting a reasonable sized max tile size allows this intermediate to |
| 2798 | // be consistently reused. |
| 2799 | if (base::FeatureList::IsEnabled( |
| 2800 | kUnpremultiplyAndDitherLowBitDepthTiles)) { |
| 2801 | settings.max_gpu_raster_tile_size = gfx::Size(512, 256); |
| 2802 | settings.unpremultiply_and_dither_low_bit_depth_tiles = true; |
| 2803 | } |
| 2804 | } |
| 2805 | } |
| 2806 | |
| 2807 | if (cmd.HasSwitch(switches::kEnableLowResTiling)) |
| 2808 | settings.create_low_res_tiling = true; |
| 2809 | if (cmd.HasSwitch(switches::kDisableLowResTiling)) |
| 2810 | settings.create_low_res_tiling = false; |
| 2811 | |
| 2812 | if (cmd.HasSwitch(switches::kEnableRGBA4444Textures) && |
| 2813 | !cmd.HasSwitch(switches::kDisableRGBA4444Textures)) { |
| 2814 | settings.use_rgba_4444 = true; |
| 2815 | } |
| 2816 | |
| 2817 | settings.max_staging_buffer_usage_in_bytes = 32 * 1024 * 1024; // 32MB |
| 2818 | // Use 1/4th of staging buffers on low-end devices. |
| 2819 | if (base::SysInfo::IsLowEndDevice()) |
| 2820 | settings.max_staging_buffer_usage_in_bytes /= 4; |
| 2821 | |
| 2822 | cc::ManagedMemoryPolicy defaults = settings.memory_policy; |
| 2823 | settings.memory_policy = GetGpuMemoryPolicy(defaults, initial_screen_size, |
| 2824 | initial_device_scale_factor); |
| 2825 | |
| 2826 | settings.disallow_non_exact_resource_reuse = |
| 2827 | cmd.HasSwitch(switches::kDisallowNonExactResourceReuse); |
| 2828 | #if defined(OS_ANDROID) |
| 2829 | // TODO(crbug.com/746931): This feature appears to be causing visual |
| 2830 | // corruption on certain android devices. Will investigate and re-enable. |
| 2831 | settings.disallow_non_exact_resource_reuse = true; |
| 2832 | #endif |
| 2833 | |
| 2834 | if (cmd.HasSwitch(switches::kRunAllCompositorStagesBeforeDraw)) { |
| 2835 | settings.wait_for_all_pipeline_stages_before_draw = true; |
| 2836 | settings.enable_latency_recovery = false; |
| 2837 | } |
| 2838 | |
| 2839 | settings.enable_image_animation_resync = |
| 2840 | !cmd.HasSwitch(switches::kDisableImageAnimationResync); |
| 2841 | |
| 2842 | settings.always_request_presentation_time = |
| 2843 | cmd.HasSwitch(cc::switches::kAlwaysRequestPresentationTime); |
Karolina Soltys | 4d60b40 | 2018-10-01 19:28:20 | [diff] [blame] | 2844 | |
| 2845 | settings.send_compositor_frame_ack = false; |
| 2846 | |
danakj | 4b34721 | 2018-07-04 17:55:17 | [diff] [blame] | 2847 | return settings; |
| 2848 | } |
| 2849 | |
| 2850 | // static |
| 2851 | cc::ManagedMemoryPolicy RenderWidget::GetGpuMemoryPolicy( |
| 2852 | const cc::ManagedMemoryPolicy& default_policy, |
| 2853 | const gfx::Size& initial_screen_size, |
| 2854 | float initial_device_scale_factor) { |
| 2855 | cc::ManagedMemoryPolicy actual = default_policy; |
| 2856 | actual.bytes_limit_when_visible = 0; |
| 2857 | |
| 2858 | // If the value was overridden on the command line, use the specified value. |
| 2859 | static bool client_hard_limit_bytes_overridden = |
| 2860 | base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 2861 | switches::kForceGpuMemAvailableMb); |
| 2862 | if (client_hard_limit_bytes_overridden) { |
| 2863 | if (base::StringToSizeT( |
| 2864 | base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 2865 | switches::kForceGpuMemAvailableMb), |
| 2866 | &actual.bytes_limit_when_visible)) |
| 2867 | actual.bytes_limit_when_visible *= 1024 * 1024; |
| 2868 | return actual; |
| 2869 | } |
| 2870 | |
| 2871 | #if defined(OS_ANDROID) |
| 2872 | // We can't query available GPU memory from the system on Android. |
| 2873 | // Physical memory is also mis-reported sometimes (eg. Nexus 10 reports |
| 2874 | // 1262MB when it actually has 2GB, while Razr M has 1GB but only reports |
| 2875 | // 128MB java heap size). First we estimate physical memory using both. |
| 2876 | size_t dalvik_mb = base::SysInfo::DalvikHeapSizeMB(); |
| 2877 | size_t physical_mb = base::SysInfo::AmountOfPhysicalMemoryMB(); |
| 2878 | size_t physical_memory_mb = 0; |
| 2879 | if (base::SysInfo::IsLowEndDevice()) { |
| 2880 | // TODO(crbug.com/742534): The code below appears to no longer work. |
| 2881 | // |dalvik_mb| no longer follows the expected heuristic pattern, causing us |
| 2882 | // to over-estimate memory on low-end devices. This entire section probably |
| 2883 | // needs to be re-written, but for now we can address the low-end Android |
| 2884 | // issues by ignoring |dalvik_mb|. |
| 2885 | physical_memory_mb = physical_mb; |
| 2886 | } else if (dalvik_mb >= 256) { |
| 2887 | physical_memory_mb = dalvik_mb * 4; |
| 2888 | } else { |
| 2889 | physical_memory_mb = std::max(dalvik_mb * 4, (physical_mb * 4) / 3); |
| 2890 | } |
| 2891 | |
| 2892 | // Now we take a default of 1/8th of memory on high-memory devices, |
| 2893 | // and gradually scale that back for low-memory devices (to be nicer |
| 2894 | // to other apps so they don't get killed). Examples: |
| 2895 | // Nexus 4/10(2GB) 256MB (normally 128MB) |
| 2896 | // Droid Razr M(1GB) 114MB (normally 57MB) |
| 2897 | // Galaxy Nexus(1GB) 100MB (normally 50MB) |
| 2898 | // Xoom(1GB) 100MB (normally 50MB) |
| 2899 | // Nexus S(low-end) 8MB (normally 8MB) |
| 2900 | // Note that the compositor now uses only some of this memory for |
| 2901 | // pre-painting and uses the rest only for 'emergencies'. |
| 2902 | if (actual.bytes_limit_when_visible == 0) { |
| 2903 | // NOTE: Non-low-end devices use only 50% of these limits, |
| 2904 | // except during 'emergencies' where 100% can be used. |
| 2905 | if (physical_memory_mb >= 1536) |
| 2906 | actual.bytes_limit_when_visible = physical_memory_mb / 8; // >192MB |
| 2907 | else if (physical_memory_mb >= 1152) |
| 2908 | actual.bytes_limit_when_visible = physical_memory_mb / 8; // >144MB |
| 2909 | else if (physical_memory_mb >= 768) |
| 2910 | actual.bytes_limit_when_visible = physical_memory_mb / 10; // >76MB |
| 2911 | else if (physical_memory_mb >= 513) |
| 2912 | actual.bytes_limit_when_visible = physical_memory_mb / 12; // <64MB |
| 2913 | else |
| 2914 | // Devices with this little RAM have very little headroom so we hardcode |
| 2915 | // the limit rather than relying on the heuristics above. (They also use |
| 2916 | // 4444 textures so we can use a lower limit.) |
| 2917 | actual.bytes_limit_when_visible = 8; |
| 2918 | |
| 2919 | actual.bytes_limit_when_visible = |
| 2920 | actual.bytes_limit_when_visible * 1024 * 1024; |
| 2921 | // Clamp the observed value to a specific range on Android. |
| 2922 | actual.bytes_limit_when_visible = std::max( |
| 2923 | actual.bytes_limit_when_visible, static_cast<size_t>(8 * 1024 * 1024)); |
| 2924 | actual.bytes_limit_when_visible = |
| 2925 | std::min(actual.bytes_limit_when_visible, |
| 2926 | static_cast<size_t>(256 * 1024 * 1024)); |
| 2927 | } |
| 2928 | actual.priority_cutoff_when_visible = |
| 2929 | gpu::MemoryAllocation::CUTOFF_ALLOW_EVERYTHING; |
| 2930 | #else |
| 2931 | // Ignore what the system said and give all clients the same maximum |
| 2932 | // allocation on desktop platforms. |
| 2933 | actual.bytes_limit_when_visible = 512 * 1024 * 1024; |
| 2934 | actual.priority_cutoff_when_visible = |
| 2935 | gpu::MemoryAllocation::CUTOFF_ALLOW_NICE_TO_HAVE; |
| 2936 | |
| 2937 | // For large monitors (4k), double the tile memory to avoid frequent out of |
| 2938 | // memory problems. 4k could mean a screen width of anywhere from 3840 to 4096 |
| 2939 | // (see https://en.wikipedia.org/wiki/4K_resolution). We use 3500 as a proxy |
| 2940 | // for "large enough". |
| 2941 | static const int kLargeDisplayThreshold = 3500; |
| 2942 | int display_width = |
| 2943 | std::round(initial_screen_size.width() * initial_device_scale_factor); |
| 2944 | if (display_width >= kLargeDisplayThreshold) |
| 2945 | actual.bytes_limit_when_visible *= 2; |
| 2946 | #endif |
| 2947 | return actual; |
| 2948 | } |
| 2949 | |
Navid Zolghadr | 8fdb6114e | 2018-08-29 19:00:54 | [diff] [blame] | 2950 | void RenderWidget::HasPointerRawMoveEventHandlers(bool has_handlers) { |
| 2951 | if (input_event_queue_) |
| 2952 | input_event_queue_->HasPointerRawMoveEventHandlers(has_handlers); |
| 2953 | } |
| 2954 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2955 | void RenderWidget::HasTouchEventHandlers(bool has_handlers) { |
W. James MacLean | 662d538 | 2018-03-29 18:33:08 | [diff] [blame] | 2956 | if (has_touch_handlers_ && *has_touch_handlers_ == has_handlers) |
| 2957 | return; |
| 2958 | |
| 2959 | has_touch_handlers_ = has_handlers; |
alexclarke | 7fa9394 | 2015-10-21 15:37:11 | [diff] [blame] | 2960 | if (render_widget_scheduling_state_) |
| 2961 | render_widget_scheduling_state_->SetHasTouchHandler(has_handlers); |
Albert J. Wong | eb28e7e | 2018-10-12 00:57:43 | [diff] [blame] | 2962 | Send(new WidgetHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); |
[email protected] | ce6689f | 2013-03-29 12:52:55 | [diff] [blame] | 2963 | } |
| 2964 | |
Dave Tapuska | dfe486c1 | 2017-06-09 16:53:13 | [diff] [blame] | 2965 | void RenderWidget::SetNeedsLowLatencyInput(bool needs_low_latency) { |
| 2966 | if (input_event_queue_) |
| 2967 | input_event_queue_->SetNeedsLowLatency(needs_low_latency); |
| 2968 | } |
| 2969 | |
Dave Tapuska | bafc2ba3 | 2017-11-28 01:54:37 | [diff] [blame] | 2970 | void RenderWidget::RequestUnbufferedInputEvents() { |
| 2971 | if (input_event_queue_) |
| 2972 | input_event_queue_->RequestUnbufferedInputEvents(); |
| 2973 | } |
| 2974 | |
xidachen | fa0199e7 | 2017-05-11 11:34:26 | [diff] [blame] | 2975 | void RenderWidget::SetTouchAction(cc::TouchAction touch_action) { |
Dave Tapuska | b28a108 | 2017-08-30 15:37:26 | [diff] [blame] | 2976 | if (!input_handler_->ProcessTouchAction(touch_action)) |
[email protected] | 5d0bbdfa9 | 2013-12-10 00:35:51 | [diff] [blame] | 2977 | return; |
| 2978 | |
Dave Tapuska | 04bc5ee9 | 2018-04-17 19:03:31 | [diff] [blame] | 2979 | widget_input_handler_manager_->ProcessTouchAction(touch_action); |
[email protected] | 5d0bbdfa9 | 2013-12-10 00:35:51 | [diff] [blame] | 2980 | } |
| 2981 | |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 2982 | void RenderWidget::RegisterRenderFrameProxy(RenderFrameProxy* proxy) { |
| 2983 | render_frame_proxies_.AddObserver(proxy); |
W. James MacLean | 2a90bff | 2018-11-05 20:52:47 | [diff] [blame] | 2984 | // During initial page load, the main frame may have received page |
| 2985 | // scale factor information before the sub-frame proxies were registered, so |
| 2986 | // make sure we pass the page scale factor along here. |
| 2987 | proxy->OnPageScaleFactorChanged(page_scale_factor_from_mainframe_); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 2988 | } |
| 2989 | |
[email protected] | e3244ed | 2014-06-20 20:04:27 | [diff] [blame] | 2990 | void RenderWidget::UnregisterRenderFrameProxy(RenderFrameProxy* proxy) { |
| 2991 | render_frame_proxies_.RemoveObserver(proxy); |
[email protected] | bffc830 | 2014-01-23 20:52:16 | [diff] [blame] | 2992 | } |
| 2993 | |
[email protected] | de3c5d8 | 2014-05-28 22:12:59 | [diff] [blame] | 2994 | void RenderWidget::RegisterRenderFrame(RenderFrameImpl* frame) { |
| 2995 | render_frames_.AddObserver(frame); |
| 2996 | } |
| 2997 | |
| 2998 | void RenderWidget::UnregisterRenderFrame(RenderFrameImpl* frame) { |
| 2999 | render_frames_.RemoveObserver(frame); |
| 3000 | } |
| 3001 | |
Saman Sami | d189e5dfd | 2017-12-20 22:55:31 | [diff] [blame] | 3002 | void RenderWidget::RegisterBrowserPlugin(BrowserPlugin* browser_plugin) { |
| 3003 | browser_plugins_.AddObserver(browser_plugin); |
Saman Sami | 50d1e0c | 2018-03-13 20:03:49 | [diff] [blame] | 3004 | browser_plugin->ScreenInfoChanged(GetOriginalScreenInfo()); |
Saman Sami | d189e5dfd | 2017-12-20 22:55:31 | [diff] [blame] | 3005 | } |
| 3006 | |
| 3007 | void RenderWidget::UnregisterBrowserPlugin(BrowserPlugin* browser_plugin) { |
| 3008 | browser_plugins_.RemoveObserver(browser_plugin); |
| 3009 | } |
| 3010 | |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 3011 | void RenderWidget::OnWaitNextFrameForTests( |
| 3012 | int main_frame_thread_observer_routing_id) { |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 3013 | // Sends an ACK to the browser process during the next compositor frame. |
Albert J. Wong | 3c93c18 | 2018-09-27 17:29:43 | [diff] [blame] | 3014 | QueueMessage(new WidgetHostMsg_WaitForNextFrameForTests_ACK( |
| 3015 | main_frame_thread_observer_routing_id)); |
lfg | 43e08e6 | 2016-02-03 18:51:37 | [diff] [blame] | 3016 | } |
| 3017 | |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 3018 | const ScreenInfo& RenderWidget::GetWebScreenInfo() const { |
| 3019 | return screen_info_; |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 3020 | } |
| 3021 | |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 3022 | const ScreenInfo& RenderWidget::GetOriginalScreenInfo() const { |
Christopher Cameron | e9a30c1 | 2018-03-07 08:23:38 | [diff] [blame] | 3023 | return screen_metrics_emulator_ |
| 3024 | ? screen_metrics_emulator_->original_screen_info() |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 3025 | : screen_info_; |
oshima | 50872a7 | 2016-03-04 13:26:18 | [diff] [blame] | 3026 | } |
| 3027 | |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 3028 | gfx::PointF RenderWidget::ConvertWindowPointToViewport( |
| 3029 | const gfx::PointF& point) { |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 3030 | blink::WebFloatRect point_in_viewport(point.x(), point.y(), 0, 0); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 3031 | ConvertWindowToViewport(&point_in_viewport); |
Ella Ge | 80a52dce | 2017-11-15 18:01:52 | [diff] [blame] | 3032 | return gfx::PointF(point_in_viewport.x, point_in_viewport.y); |
| 3033 | } |
| 3034 | |
| 3035 | gfx::Point RenderWidget::ConvertWindowPointToViewport(const gfx::Point& point) { |
| 3036 | return gfx::ToRoundedPoint(ConvertWindowPointToViewport(gfx::PointF(point))); |
paulmeyer | 90f6c31d | 2016-11-12 00:17:59 | [diff] [blame] | 3037 | } |
| 3038 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 3039 | bool RenderWidget::RequestPointerLock() { |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 3040 | return mouse_lock_dispatcher_->LockMouse(webwidget_mouse_lock_target_.get()); |
| 3041 | } |
| 3042 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 3043 | void RenderWidget::RequestPointerUnlock() { |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 3044 | mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); |
| 3045 | } |
| 3046 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 3047 | bool RenderWidget::IsPointerLocked() { |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 3048 | return mouse_lock_dispatcher_->IsMouseLockedTo( |
| 3049 | webwidget_mouse_lock_target_.get()); |
| 3050 | } |
| 3051 | |
Richard Li | 49fe04d | 2018-10-21 09:07:19 | [diff] [blame] | 3052 | void RenderWidget::StartDragging(network::mojom::ReferrerPolicy policy, |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 3053 | const WebDragData& data, |
| 3054 | WebDragOperationsMask mask, |
danakj | 0c75ad8 | 2018-07-10 19:50:12 | [diff] [blame] | 3055 | const SkBitmap& drag_image, |
danakj | ef1735a | 2018-11-13 19:34:44 | [diff] [blame] | 3056 | const gfx::Point& web_image_offset) { |
| 3057 | blink::WebRect offset_in_window(web_image_offset.x(), web_image_offset.y(), 0, |
| 3058 | 0); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 3059 | ConvertViewportToWindow(&offset_in_window); |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 3060 | DropData drop_data(DropDataBuilder::Build(data)); |
| 3061 | drop_data.referrer_policy = policy; |
danakj | 0c75ad8 | 2018-07-10 19:50:12 | [diff] [blame] | 3062 | gfx::Vector2d image_offset(offset_in_window.x, offset_in_window.y); |
| 3063 | Send(new DragHostMsg_StartDragging(routing_id(), drop_data, mask, drag_image, |
| 3064 | image_offset, possible_drag_event_info_)); |
paulmeyer | 6ef5a79 | 2016-11-08 20:33:58 | [diff] [blame] | 3065 | } |
| 3066 | |
kenrb | 5d78b84 | 2017-03-06 21:06:01 | [diff] [blame] | 3067 | uint32_t RenderWidget::GetContentSourceId() { |
| 3068 | return current_content_source_id_; |
| 3069 | } |
| 3070 | |
Saman Sami | f773134 | 2018-01-24 22:18:44 | [diff] [blame] | 3071 | void RenderWidget::DidNavigate() { |
Saman Sami | 26a1fcd | 2018-04-10 17:12:21 | [diff] [blame] | 3072 | ++current_content_source_id_; |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 3073 | if (!layer_tree_view_) |
Saman Sami | f773134 | 2018-01-24 22:18:44 | [diff] [blame] | 3074 | return; |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 3075 | layer_tree_view_->SetContentSourceId(current_content_source_id_); |
| 3076 | layer_tree_view_->ClearCachesOnNextCommit(); |
kenrb | 5d78b84 | 2017-03-06 21:06:01 | [diff] [blame] | 3077 | } |
| 3078 | |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 3079 | blink::WebWidget* RenderWidget::GetWebWidget() const { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 3080 | if (owner_delegate_) { |
| 3081 | blink::WebWidget* delegate_widget = |
| 3082 | owner_delegate_->GetWebWidgetForWidget(); |
| 3083 | if (delegate_widget) |
| 3084 | return delegate_widget; |
| 3085 | } |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 3086 | return webwidget_internal_; |
| 3087 | } |
| 3088 | |
ekaramad | 2daaf67 | 2016-11-10 20:29:01 | [diff] [blame] | 3089 | blink::WebInputMethodController* RenderWidget::GetInputMethodController() |
| 3090 | const { |
Ehsan Karamad | 655d7b8a | 2018-01-12 18:38:38 | [diff] [blame] | 3091 | if (auto* frame_widget = GetFrameWidget()) |
| 3092 | return frame_widget->GetActiveWebInputMethodController(); |
| 3093 | |
| 3094 | return nullptr; |
ekaramad | 2daaf67 | 2016-11-10 20:29:01 | [diff] [blame] | 3095 | } |
| 3096 | |
Dave Tapuska | 139a72f | 2017-09-06 21:57:03 | [diff] [blame] | 3097 | void RenderWidget::SetupWidgetInputHandler( |
| 3098 | mojom::WidgetInputHandlerRequest request, |
| 3099 | mojom::WidgetInputHandlerHostPtr host) { |
Dave Tapuska | b66c28f | 2017-11-15 17:18:47 | [diff] [blame] | 3100 | widget_input_handler_manager_->AddInterface(std::move(request), |
| 3101 | std::move(host)); |
Dave Tapuska | 525eb15e | 2017-08-17 21:05:50 | [diff] [blame] | 3102 | } |
| 3103 | |
Dave Tapuska | 485aca9 | 2017-08-08 00:47:58 | [diff] [blame] | 3104 | void RenderWidget::SetWidgetBinding(mojom::WidgetRequest request) { |
| 3105 | // Close the old binding if there was one. |
| 3106 | // A RenderWidgetHost should not need more than one channel. |
| 3107 | widget_binding_.Close(); |
| 3108 | widget_binding_.Bind(std::move(request)); |
| 3109 | } |
| 3110 | |
Ken Buchanan | 94c0beb6 | 2018-06-22 19:56:24 | [diff] [blame] | 3111 | void RenderWidget::SetMouseCapture(bool capture) { |
| 3112 | if (mojom::WidgetInputHandlerHost* host = |
| 3113 | widget_input_handler_manager_->GetWidgetInputHandlerHost()) { |
| 3114 | host->SetMouseCapture(capture); |
| 3115 | } |
| 3116 | } |
| 3117 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 3118 | void RenderWidget::SetWindowScreenRect(const gfx::Rect& window_screen_rect) { |
| 3119 | if (screen_metrics_emulator_) |
| 3120 | screen_metrics_emulator_->OnUpdateWindowScreenRect(window_screen_rect); |
| 3121 | else |
| 3122 | window_screen_rect_ = window_screen_rect; |
| 3123 | } |
| 3124 | |
Fady Samuel | ca9ecb7 | 2018-05-05 05:59:27 | [diff] [blame] | 3125 | bool RenderWidget::IsSurfaceSynchronizationEnabled() const { |
danakj | a6c1001 | 2018-07-06 14:25:36 | [diff] [blame] | 3126 | return layer_tree_view_ && |
| 3127 | layer_tree_view_->IsSurfaceSynchronizationEnabled(); |
Fady Samuel | ca9ecb7 | 2018-05-05 05:59:27 | [diff] [blame] | 3128 | } |
| 3129 | |
W. James MacLean | 2a90bff | 2018-11-05 20:52:47 | [diff] [blame] | 3130 | void RenderWidget::PageScaleFactorChanged(float page_scale_factor) { |
| 3131 | // Only the main frame pulls page scale information from the layer tree host. |
| 3132 | // Pages scale is shared with non-mainframe widgets via the IPC for |
| 3133 | // OnSynchronizeVisualProperties. |
| 3134 | if (!owner_delegate_) |
| 3135 | return; |
| 3136 | |
| 3137 | page_scale_factor_from_mainframe_ = page_scale_factor; |
| 3138 | for (auto& observer : render_frame_proxies_) |
| 3139 | observer.OnPageScaleFactorChanged(page_scale_factor); |
| 3140 | } |
| 3141 | |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 3142 | void RenderWidget::UseSynchronousResizeModeForTesting(bool enable) { |
| 3143 | resizing_mode_selector_->set_is_synchronous_mode(enable); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 3144 | } |
| 3145 | |
| 3146 | void RenderWidget::SetDeviceScaleFactorForTesting(float factor) { |
| 3147 | device_scale_factor_for_testing_ = factor; |
| 3148 | |
| 3149 | VisualProperties visual_properties; |
| 3150 | visual_properties.screen_info = screen_info_; |
| 3151 | visual_properties.screen_info.device_scale_factor = factor; |
| 3152 | visual_properties.new_size = size(); |
| 3153 | visual_properties.visible_viewport_size = visible_viewport_size_; |
| 3154 | visual_properties.compositor_viewport_pixel_size = |
| 3155 | gfx::ScaleToCeiledSize(size(), factor); |
| 3156 | visual_properties.browser_controls_shrink_blink_size = false; |
| 3157 | visual_properties.top_controls_height = 0.f; |
| 3158 | visual_properties.is_fullscreen_granted = is_fullscreen_granted_; |
| 3159 | visual_properties.display_mode = display_mode_; |
Fady Samuel | 84d8a1f7 | 2018-11-08 00:26:17 | [diff] [blame] | 3160 | visual_properties.local_surface_id_allocation = |
| 3161 | local_surface_id_allocation_from_parent_; |
W. James MacLean | 2a90bff | 2018-11-05 20:52:47 | [diff] [blame] | 3162 | visual_properties.page_scale_factor = page_scale_factor_from_mainframe_; |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 3163 | // We are changing the device scale factor from the renderer, so allocate a |
| 3164 | // new viz::LocalSurfaceId to avoid surface invariants violations in tests. |
| 3165 | if (layer_tree_view_) |
| 3166 | layer_tree_view_->RequestNewLocalSurfaceId(); |
| 3167 | |
| 3168 | OnSynchronizeVisualProperties(visual_properties); |
| 3169 | } |
| 3170 | |
| 3171 | void RenderWidget::SetDeviceColorSpaceForTesting( |
| 3172 | const gfx::ColorSpace& color_space) { |
| 3173 | VisualProperties visual_properties; |
| 3174 | visual_properties.screen_info = screen_info_; |
| 3175 | visual_properties.screen_info.color_space = color_space; |
| 3176 | visual_properties.new_size = size(); |
| 3177 | visual_properties.visible_viewport_size = visible_viewport_size_; |
| 3178 | visual_properties.compositor_viewport_pixel_size = |
| 3179 | compositor_viewport_pixel_size_; |
| 3180 | visual_properties.browser_controls_shrink_blink_size = false; |
| 3181 | visual_properties.top_controls_height = 0.f; |
| 3182 | visual_properties.is_fullscreen_granted = is_fullscreen_granted_; |
| 3183 | visual_properties.display_mode = display_mode_; |
Fady Samuel | 84d8a1f7 | 2018-11-08 00:26:17 | [diff] [blame] | 3184 | visual_properties.local_surface_id_allocation = |
| 3185 | local_surface_id_allocation_from_parent_; |
W. James MacLean | 2a90bff | 2018-11-05 20:52:47 | [diff] [blame] | 3186 | visual_properties.page_scale_factor = page_scale_factor_from_mainframe_; |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 3187 | // We are changing the device color space from the renderer, so allocate a |
| 3188 | // new viz::LocalSurfaceId to avoid surface invariants violations in tests. |
| 3189 | if (layer_tree_view_) |
| 3190 | layer_tree_view_->RequestNewLocalSurfaceId(); |
| 3191 | OnSynchronizeVisualProperties(visual_properties); |
| 3192 | } |
| 3193 | |
| 3194 | void RenderWidget::SetWindowRectSynchronouslyForTesting( |
| 3195 | const gfx::Rect& new_window_rect) { |
| 3196 | SetWindowRectSynchronously(new_window_rect); |
| 3197 | } |
| 3198 | |
| 3199 | void RenderWidget::EnableAutoResizeForTesting(const gfx::Size& min_size, |
| 3200 | const gfx::Size& max_size) { |
| 3201 | VisualProperties visual_properties; |
| 3202 | visual_properties.auto_resize_enabled = true; |
| 3203 | visual_properties.min_size_for_auto_resize = min_size; |
| 3204 | visual_properties.max_size_for_auto_resize = max_size; |
Fady Samuel | 84d8a1f7 | 2018-11-08 00:26:17 | [diff] [blame] | 3205 | visual_properties.local_surface_id_allocation = |
| 3206 | base::Optional<viz::LocalSurfaceIdAllocation>( |
| 3207 | viz::LocalSurfaceIdAllocation( |
| 3208 | viz::LocalSurfaceId(1, 1, base::UnguessableToken::Create()), |
| 3209 | base::TimeTicks::Now())); |
W. James MacLean | 2a90bff | 2018-11-05 20:52:47 | [diff] [blame] | 3210 | visual_properties.page_scale_factor = page_scale_factor_from_mainframe_; |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 3211 | OnSynchronizeVisualProperties(visual_properties); |
| 3212 | } |
| 3213 | |
| 3214 | void RenderWidget::DisableAutoResizeForTesting(const gfx::Size& new_size) { |
| 3215 | if (!auto_resize_mode_) |
| 3216 | return; |
| 3217 | |
| 3218 | VisualProperties visual_properties; |
| 3219 | visual_properties.auto_resize_enabled = false; |
| 3220 | visual_properties.screen_info = screen_info_; |
| 3221 | visual_properties.new_size = new_size; |
| 3222 | visual_properties.compositor_viewport_pixel_size = |
| 3223 | compositor_viewport_pixel_size_; |
| 3224 | visual_properties.browser_controls_shrink_blink_size = |
| 3225 | browser_controls_shrink_blink_size_; |
| 3226 | visual_properties.top_controls_height = top_controls_height_; |
| 3227 | visual_properties.visible_viewport_size = visible_viewport_size_; |
| 3228 | visual_properties.is_fullscreen_granted = is_fullscreen_granted_; |
| 3229 | visual_properties.display_mode = display_mode_; |
W. James MacLean | 2a90bff | 2018-11-05 20:52:47 | [diff] [blame] | 3230 | visual_properties.page_scale_factor = page_scale_factor_from_mainframe_; |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 3231 | OnSynchronizeVisualProperties(visual_properties); |
| 3232 | } |
| 3233 | |
EhsanK | 955ba58 | 2017-11-30 21:14:40 | [diff] [blame] | 3234 | blink::WebLocalFrame* RenderWidget::GetFocusedWebLocalFrameInWidget() const { |
Ehsan Karamad | 655d7b8a | 2018-01-12 18:38:38 | [diff] [blame] | 3235 | if (auto* frame_widget = GetFrameWidget()) |
| 3236 | return frame_widget->FocusedWebLocalFrameInWidget(); |
| 3237 | return nullptr; |
EhsanK | 955ba58 | 2017-11-30 21:14:40 | [diff] [blame] | 3238 | } |
| 3239 | |
EhsanK | 22d482e | 2017-08-10 17:29:49 | [diff] [blame] | 3240 | #if BUILDFLAG(ENABLE_PLUGINS) |
| 3241 | PepperPluginInstanceImpl* RenderWidget::GetFocusedPepperPluginInsideWidget() { |
Ehsan Karamad | 655d7b8a | 2018-01-12 18:38:38 | [diff] [blame] | 3242 | blink::WebFrameWidget* frame_widget = GetFrameWidget(); |
| 3243 | if (!frame_widget) |
EhsanK | 22d482e | 2017-08-10 17:29:49 | [diff] [blame] | 3244 | return nullptr; |
| 3245 | |
| 3246 | // Focused pepper instance might not always be in the focused frame. For |
| 3247 | // instance if a pepper instance and its embedder frame are focused an then |
| 3248 | // another frame takes focus using javascript, the embedder frame will no |
| 3249 | // longer be focused while the pepper instance is (the embedder frame's |
| 3250 | // |focused_pepper_plugin_| is not nullptr). Especially, if the pepper plugin |
| 3251 | // is fullscreen, clicking into the pepper will not refocus the embedder |
| 3252 | // frame. This is why we have to traverse the whole frame tree to find the |
| 3253 | // focused plugin. |
Ehsan Karamad | 655d7b8a | 2018-01-12 18:38:38 | [diff] [blame] | 3254 | blink::WebFrame* current_frame = frame_widget->LocalRoot(); |
EhsanK | 22d482e | 2017-08-10 17:29:49 | [diff] [blame] | 3255 | while (current_frame) { |
| 3256 | RenderFrameImpl* render_frame = |
| 3257 | current_frame->IsWebLocalFrame() |
| 3258 | ? RenderFrameImpl::FromWebFrame(current_frame) |
| 3259 | : nullptr; |
| 3260 | if (render_frame && render_frame->focused_pepper_plugin()) |
| 3261 | return render_frame->focused_pepper_plugin(); |
| 3262 | current_frame = current_frame->TraverseNext(); |
| 3263 | } |
| 3264 | return nullptr; |
| 3265 | } |
| 3266 | #endif |
| 3267 | |
Ken Buchanan | b2c9e26 | 2018-03-10 16:53:31 | [diff] [blame] | 3268 | gfx::Rect RenderWidget::ViewportVisibleRect() { |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame^] | 3269 | return for_child_local_root_frame_ |
| 3270 | ? compositor_visible_rect_ |
| 3271 | : gfx::Rect(compositor_viewport_pixel_size_); |
Ken Buchanan | b2c9e26 | 2018-03-10 16:53:31 | [diff] [blame] | 3272 | } |
| 3273 | |
Hajime Hoshi | 315a61f | 2018-08-14 17:27:28 | [diff] [blame] | 3274 | // static |
| 3275 | scoped_refptr<base::SingleThreadTaskRunner> |
| 3276 | RenderWidget::GetCleanupTaskRunner() { |
| 3277 | return RenderThreadImpl::current_blink_platform_impl() |
| 3278 | ->main_thread_scheduler() |
| 3279 | ->CleanupTaskRunner(); |
| 3280 | } |
| 3281 | |
Saman Sami | 50d1e0c | 2018-03-13 20:03:49 | [diff] [blame] | 3282 | base::WeakPtr<RenderWidget> RenderWidget::AsWeakPtr() { |
| 3283 | return weak_ptr_factory_.GetWeakPtr(); |
| 3284 | } |
| 3285 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 3286 | } // namespace content |