| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 #include "gpu/ipc/common/gpu_messages.h" | 80 #include "gpu/ipc/common/gpu_messages.h" |
| 81 #include "net/base/filename_util.h" | 81 #include "net/base/filename_util.h" |
| 82 #include "skia/ext/image_operations.h" | 82 #include "skia/ext/image_operations.h" |
| 83 #include "skia/ext/platform_canvas.h" | 83 #include "skia/ext/platform_canvas.h" |
| 84 #include "storage/browser/fileapi/isolated_context.h" | 84 #include "storage/browser/fileapi/isolated_context.h" |
| 85 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" | 85 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" |
| 86 #include "ui/base/clipboard/clipboard.h" | 86 #include "ui/base/clipboard/clipboard.h" |
| 87 #include "ui/display/display_switches.h" | 87 #include "ui/display/display_switches.h" |
| 88 #include "ui/events/blink/web_input_event_traits.h" | 88 #include "ui/events/blink/web_input_event_traits.h" |
| 89 #include "ui/events/event.h" | 89 #include "ui/events/event.h" |
| 90 #include "ui/events/keycodes/dom/keycode_converter.h" |
| 90 #include "ui/events/keycodes/keyboard_codes.h" | 91 #include "ui/events/keycodes/keyboard_codes.h" |
| 91 #include "ui/gfx/color_space.h" | 92 #include "ui/gfx/color_space.h" |
| 92 #include "ui/gfx/geometry/size_conversions.h" | 93 #include "ui/gfx/geometry/size_conversions.h" |
| 93 #include "ui/gfx/geometry/vector2d_conversions.h" | 94 #include "ui/gfx/geometry/vector2d_conversions.h" |
| 94 #include "ui/gfx/geometry/vector2d_f.h" | 95 #include "ui/gfx/geometry/vector2d_f.h" |
| 95 #include "ui/gfx/image/image.h" | 96 #include "ui/gfx/image/image.h" |
| 96 #include "ui/gfx/image/image_skia.h" | 97 #include "ui/gfx/image/image_skia.h" |
| 97 #include "ui/gfx/skbitmap_operations.h" | 98 #include "ui/gfx/skbitmap_operations.h" |
| 98 #include "ui/snapshot/snapshot.h" | 99 #include "ui/snapshot/snapshot.h" |
| 99 | 100 |
| (...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 const NativeWebKeyboardEvent& key_event, | 1213 const NativeWebKeyboardEvent& key_event, |
| 1213 const ui::LatencyInfo& latency) { | 1214 const ui::LatencyInfo& latency) { |
| 1214 ForwardKeyboardEventWithCommands(key_event, latency, nullptr, nullptr); | 1215 ForwardKeyboardEventWithCommands(key_event, latency, nullptr, nullptr); |
| 1215 } | 1216 } |
| 1216 | 1217 |
| 1217 void RenderWidgetHostImpl::ForwardKeyboardEventWithCommands( | 1218 void RenderWidgetHostImpl::ForwardKeyboardEventWithCommands( |
| 1218 const NativeWebKeyboardEvent& key_event, | 1219 const NativeWebKeyboardEvent& key_event, |
| 1219 const ui::LatencyInfo& latency, | 1220 const ui::LatencyInfo& latency, |
| 1220 const std::vector<EditCommand>* commands, | 1221 const std::vector<EditCommand>* commands, |
| 1221 bool* update_event) { | 1222 bool* update_event) { |
| 1223 LOG(ERROR) << "RenderWidgetHostImpl::ForwardKeyboardEventWithCommands"; |
| 1222 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent"); | 1224 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent"); |
| 1223 if (owner_delegate_ && | 1225 if (owner_delegate_ && |
| 1224 !owner_delegate_->MayRenderWidgetForwardKeyboardEvent(key_event)) { | 1226 !owner_delegate_->MayRenderWidgetForwardKeyboardEvent(key_event)) { |
| 1225 return; | 1227 return; |
| 1226 } | 1228 } |
| 1227 | 1229 |
| 1228 if (ShouldDropInputEvents()) | 1230 if (ShouldDropInputEvents()) |
| 1229 return; | 1231 return; |
| 1230 | 1232 |
| 1231 if (!process_->HasConnection()) | 1233 if (!process_->HasConnection()) |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1254 key_event.GetType() == WebKeyboardEvent::kChar) | 1256 key_event.GetType() == WebKeyboardEvent::kChar) |
| 1255 return; | 1257 return; |
| 1256 DCHECK(key_event.GetType() == WebKeyboardEvent::kRawKeyDown || | 1258 DCHECK(key_event.GetType() == WebKeyboardEvent::kRawKeyDown || |
| 1257 key_event.GetType() == WebKeyboardEvent::kKeyDown); | 1259 key_event.GetType() == WebKeyboardEvent::kKeyDown); |
| 1258 suppress_events_until_keydown_ = false; | 1260 suppress_events_until_keydown_ = false; |
| 1259 } | 1261 } |
| 1260 | 1262 |
| 1261 bool is_shortcut = false; | 1263 bool is_shortcut = false; |
| 1262 | 1264 |
| 1263 // Only pre-handle the key event if it's not handled by the input method. | 1265 // Only pre-handle the key event if it's not handled by the input method. |
| 1264 if (delegate_ && !key_event.skip_in_browser) { | 1266 LOG(ERROR) << " > delegate_ = " << delegate_; |
| 1267 LOG(ERROR) << " > key_event.skip_in_browser = " << key_event.skip_in_browser; |
| 1268 if (delegate_){// && !key_event.skip_in_browser) { |
| 1265 // We need to set |suppress_events_until_keydown_| to true if | 1269 // We need to set |suppress_events_until_keydown_| to true if |
| 1266 // PreHandleKeyboardEvent() handles the event, but |this| may already be | 1270 // PreHandleKeyboardEvent() handles the event, but |this| may already be |
| 1267 // destroyed at that time. So set |suppress_events_until_keydown_| true | 1271 // destroyed at that time. So set |suppress_events_until_keydown_| true |
| 1268 // here, then revert it afterwards when necessary. | 1272 // here, then revert it afterwards when necessary. |
| 1269 if (key_event.GetType() == WebKeyboardEvent::kRawKeyDown) | 1273 if (key_event.GetType() == WebKeyboardEvent::kRawKeyDown) |
| 1270 suppress_events_until_keydown_ = true; | 1274 suppress_events_until_keydown_ = true; |
| 1271 | 1275 |
| 1272 // Tab switching/closing accelerators aren't sent to the renderer to avoid | 1276 // Tab switching/closing accelerators aren't sent to the renderer to avoid |
| 1273 // a hung/malicious renderer from interfering. | 1277 // a hung/malicious renderer from interfering. |
| 1274 switch (delegate_->PreHandleKeyboardEvent(key_event)) { | 1278 switch (delegate_->PreHandleKeyboardEvent(key_event)) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1289 | 1293 |
| 1290 if (key_event.GetType() == WebKeyboardEvent::kRawKeyDown) | 1294 if (key_event.GetType() == WebKeyboardEvent::kRawKeyDown) |
| 1291 suppress_events_until_keydown_ = false; | 1295 suppress_events_until_keydown_ = false; |
| 1292 } | 1296 } |
| 1293 | 1297 |
| 1294 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) | 1298 if (touch_emulator_ && touch_emulator_->HandleKeyboardEvent(key_event)) |
| 1295 return; | 1299 return; |
| 1296 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event, | 1300 NativeWebKeyboardEventWithLatencyInfo key_event_with_latency(key_event, |
| 1297 latency); | 1301 latency); |
| 1298 key_event_with_latency.event.is_browser_shortcut = is_shortcut; | 1302 key_event_with_latency.event.is_browser_shortcut = is_shortcut; |
| 1299 DispatchInputEventWithLatencyInfo(key_event, &key_event_with_latency.latency); | 1303 LOG(ERROR) << " > key_event_with_latency.event.GetType() " |
| 1304 << key_event_with_latency.event.GetType(); |
| 1305 LOG(ERROR) << " > key_event_with_latency.event.is_browser_shortcut " |
| 1306 << key_event_with_latency.event.is_browser_shortcut; |
| 1307 LOG(ERROR) << " > key_event_with_latency.event.windows_key_code " |
| 1308 << key_event_with_latency.event.windows_key_code; |
| 1309 LOG(ERROR) << " > key_event_with_latency.event.dom_code " |
| 1310 << key_event_with_latency.event.dom_code; |
| 1311 LOG(ERROR) << " > key_event_with_latency.event.dom_key " |
| 1312 << key_event_with_latency.event.dom_key; |
| 1313 LOG(ERROR) << " > key_event_with_latency.event.text[0] " |
| 1314 << key_event_with_latency.event.text[0] << " " |
| 1315 << (key_event.text[0] ? ((char)key_event.text[0]) : ' '); |
| 1316 LOG(ERROR) << " > is_modifier " |
| 1317 << ui::KeycodeConverter::IsDomKeyForModifier(key_event.dom_key); |
| 1318 DispatchInputEventWithLatencyInfo(key_event_with_latency.event, |
| 1319 &key_event_with_latency.latency); |
| 1300 // TODO(foolip): |InputRouter::SendKeyboardEvent()| may filter events, in | 1320 // TODO(foolip): |InputRouter::SendKeyboardEvent()| may filter events, in |
| 1301 // which the commands will be treated as belonging to the next key event. | 1321 // which the commands will be treated as belonging to the next key event. |
| 1302 // InputMsg_SetEditCommandsForNextKeyEvent should only be sent if | 1322 // InputMsg_SetEditCommandsForNextKeyEvent should only be sent if |
| 1303 // InputMsg_HandleInputEvent is, but has to be sent first. | 1323 // InputMsg_HandleInputEvent is, but has to be sent first. |
| 1304 // https://crbug.com/684298 | 1324 // https://crbug.com/684298 |
| 1305 if (commands && !commands->empty()) { | 1325 if (commands && !commands->empty()) { |
| 1306 Send( | 1326 Send( |
| 1307 new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), *commands)); | 1327 new InputMsg_SetEditCommandsForNextKeyEvent(GetRoutingID(), *commands)); |
| 1308 } | 1328 } |
| 1309 input_router_->SendKeyboardEvent(key_event_with_latency); | 1329 input_router_->SendKeyboardEvent(key_event_with_latency); |
| (...skipping 1386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2696 device::mojom::WakeLockType::PreventDisplaySleep, | 2716 device::mojom::WakeLockType::PreventDisplaySleep, |
| 2697 device::mojom::WakeLockReason::ReasonOther, "GetSnapshot", | 2717 device::mojom::WakeLockReason::ReasonOther, "GetSnapshot", |
| 2698 std::move(request)); | 2718 std::move(request)); |
| 2699 } | 2719 } |
| 2700 } | 2720 } |
| 2701 return wake_lock_.get(); | 2721 return wake_lock_.get(); |
| 2702 } | 2722 } |
| 2703 #endif | 2723 #endif |
| 2704 | 2724 |
| 2705 } // namespace content | 2725 } // namespace content |
| OLD | NEW |