Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 14487003: Add a new pair of IPC categories for messages that need handling as input events (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addresses feedback Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_view_mac.h" 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h"
6 6
7 #include <QuartzCore/QuartzCore.h> 7 #include <QuartzCore/QuartzCore.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 14 matching lines...) Expand all
25 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" 25 #include "content/browser/accessibility/browser_accessibility_manager_mac.h"
26 #include "content/browser/renderer_host/backing_store_mac.h" 26 #include "content/browser/renderer_host/backing_store_mac.h"
27 #include "content/browser/renderer_host/backing_store_manager.h" 27 #include "content/browser/renderer_host/backing_store_manager.h"
28 #include "content/browser/renderer_host/compositing_iosurface_mac.h" 28 #include "content/browser/renderer_host/compositing_iosurface_mac.h"
29 #include "content/browser/renderer_host/render_view_host_impl.h" 29 #include "content/browser/renderer_host/render_view_host_impl.h"
30 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h" 30 #import "content/browser/renderer_host/render_widget_host_view_mac_editcommand_h elper.h"
31 #import "content/browser/renderer_host/text_input_client_mac.h" 31 #import "content/browser/renderer_host/text_input_client_mac.h"
32 #include "content/common/accessibility_messages.h" 32 #include "content/common/accessibility_messages.h"
33 #include "content/common/edit_command.h" 33 #include "content/common/edit_command.h"
34 #include "content/common/gpu/gpu_messages.h" 34 #include "content/common/gpu/gpu_messages.h"
35 #include "content/common/input_messages.h"
35 #include "content/common/plugin_messages.h" 36 #include "content/common/plugin_messages.h"
36 #include "content/common/view_messages.h" 37 #include "content/common/view_messages.h"
37 #include "content/port/browser/render_widget_host_view_frame_subscriber.h" 38 #include "content/port/browser/render_widget_host_view_frame_subscriber.h"
38 #include "content/public/browser/browser_thread.h" 39 #include "content/public/browser/browser_thread.h"
39 #include "content/public/browser/native_web_keyboard_event.h" 40 #include "content/public/browser/native_web_keyboard_event.h"
40 #import "content/public/browser/render_widget_host_view_mac_delegate.h" 41 #import "content/public/browser/render_widget_host_view_mac_delegate.h"
41 #include "skia/ext/platform_canvas.h" 42 #include "skia/ext/platform_canvas.h"
42 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" 43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h"
43 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" 44 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
44 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFact ory.h" 45 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebInputEventFact ory.h"
45 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebScreenInfoFact ory.h" 46 #include "third_party/WebKit/Source/WebKit/chromium/public/mac/WebScreenInfoFact ory.h"
46 #import "third_party/mozilla/ComplexTextInputPanel.h" 47 #import "third_party/mozilla/ComplexTextInputPanel.h"
47 #import "ui/base/cocoa/fullscreen_window_manager.h" 48 #import "ui/base/cocoa/fullscreen_window_manager.h"
48 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" 49 #import "ui/base/cocoa/underlay_opengl_hosting_window.h"
49 #include "ui/base/keycodes/keyboard_codes.h" 50 #include "ui/base/keycodes/keyboard_codes.h"
50 #include "ui/base/layout.h" 51 #include "ui/base/layout.h"
51 #include "ui/gfx/point.h" 52 #include "ui/gfx/point.h"
52 #include "ui/gfx/rect_conversions.h" 53 #include "ui/gfx/rect_conversions.h"
54 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
53 #include "ui/gfx/size_conversions.h" 55 #include "ui/gfx/size_conversions.h"
54 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
55 #include "ui/surface/io_surface_support_mac.h" 56 #include "ui/surface/io_surface_support_mac.h"
56 #include "webkit/plugins/npapi/webplugin.h" 57 #include "webkit/plugins/npapi/webplugin.h"
57 58
58 using content::BackingStoreMac; 59 using content::BackingStoreMac;
59 using content::BrowserAccessibility; 60 using content::BrowserAccessibility;
60 using content::BrowserAccessibilityManager; 61 using content::BrowserAccessibilityManager;
61 using content::EditCommand; 62 using content::EditCommand;
62 using content::NativeWebKeyboardEvent; 63 using content::NativeWebKeyboardEvent;
63 using content::RenderViewHostImpl; 64 using content::RenderViewHostImpl;
64 using content::RenderWidgetHostImpl; 65 using content::RenderWidgetHostImpl;
(...skipping 1879 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 // -doCommandBySelector: (invoked by the call to -interpretKeyEvents: above) 1945 // -doCommandBySelector: (invoked by the call to -interpretKeyEvents: above)
1945 // enqueued edit commands, then in order to let webkit handle them 1946 // enqueued edit commands, then in order to let webkit handle them
1946 // correctly, we need to send the real key event and corresponding edit 1947 // correctly, we need to send the real key event and corresponding edit
1947 // commands after processing the input method result. 1948 // commands after processing the input method result.
1948 // We shouldn't do this if a new marked text was set by the input method, 1949 // We shouldn't do this if a new marked text was set by the input method,
1949 // otherwise the new marked text might be cancelled by webkit. 1950 // otherwise the new marked text might be cancelled by webkit.
1950 if (hasEditCommands_ && !hasMarkedText_) 1951 if (hasEditCommands_ && !hasMarkedText_)
1951 delayEventUntilAfterImeCompostion = YES; 1952 delayEventUntilAfterImeCompostion = YES;
1952 } else { 1953 } else {
1953 if (!editCommands_.empty()) { 1954 if (!editCommands_.empty()) {
1954 widgetHost->Send(new ViewMsg_SetEditCommandsForNextKeyEvent( 1955 widgetHost->Send(new InputMsg_SetEditCommandsForNextKeyEvent(
1955 widgetHost->GetRoutingID(), editCommands_)); 1956 widgetHost->GetRoutingID(), editCommands_));
1956 } 1957 }
1957 widgetHost->ForwardKeyboardEvent(event); 1958 widgetHost->ForwardKeyboardEvent(event);
1958 } 1959 }
1959 1960
1960 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the 1961 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the
1961 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will 1962 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will
1962 // be set to NULL. So we check it here and return immediately if it's NULL. 1963 // be set to NULL. So we check it here and return immediately if it's NULL.
1963 if (!renderWidgetHostView_->render_widget_host_) 1964 if (!renderWidgetHostView_->render_widget_host_)
1964 return; 1965 return;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 // event to balance it. 2011 // event to balance it.
2011 NativeWebKeyboardEvent fakeEvent = event; 2012 NativeWebKeyboardEvent fakeEvent = event;
2012 fakeEvent.type = WebKit::WebInputEvent::KeyUp; 2013 fakeEvent.type = WebKit::WebInputEvent::KeyUp;
2013 fakeEvent.skip_in_browser = true; 2014 fakeEvent.skip_in_browser = true;
2014 widgetHost->ForwardKeyboardEvent(fakeEvent); 2015 widgetHost->ForwardKeyboardEvent(fakeEvent);
2015 // Not checking |renderWidgetHostView_->render_widget_host_| here because 2016 // Not checking |renderWidgetHostView_->render_widget_host_| here because
2016 // a key event with |skip_in_browser| == true won't be handled by browser, 2017 // a key event with |skip_in_browser| == true won't be handled by browser,
2017 // thus it won't destroy the widget. 2018 // thus it won't destroy the widget.
2018 2019
2019 if (!editCommands_.empty()) { 2020 if (!editCommands_.empty()) {
2020 widgetHost->Send(new ViewMsg_SetEditCommandsForNextKeyEvent( 2021 widgetHost->Send(new InputMsg_SetEditCommandsForNextKeyEvent(
2021 widgetHost->GetRoutingID(), editCommands_)); 2022 widgetHost->GetRoutingID(), editCommands_));
2022 } 2023 }
2023 widgetHost->ForwardKeyboardEvent(event); 2024 widgetHost->ForwardKeyboardEvent(event);
2024 2025
2025 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the 2026 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the
2026 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will 2027 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will
2027 // be set to NULL. So we check it here and return immediately if it's NULL. 2028 // be set to NULL. So we check it here and return immediately if it's NULL.
2028 if (!renderWidgetHostView_->render_widget_host_) 2029 if (!renderWidgetHostView_->render_widget_host_)
2029 return; 2030 return;
2030 } 2031 }
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
3072 // it here. 3073 // it here.
3073 if (handlingKeyDown_) { 3074 if (handlingKeyDown_) {
3074 hasEditCommands_ = YES; 3075 hasEditCommands_ = YES;
3075 // We ignore commands that insert characters, because this was causing 3076 // We ignore commands that insert characters, because this was causing
3076 // strange behavior (e.g. tab always inserted a tab rather than moving to 3077 // strange behavior (e.g. tab always inserted a tab rather than moving to
3077 // the next field on the page). 3078 // the next field on the page).
3078 if (!StartsWithASCII(command, "insert", false)) 3079 if (!StartsWithASCII(command, "insert", false))
3079 editCommands_.push_back(EditCommand(command, "")); 3080 editCommands_.push_back(EditCommand(command, ""));
3080 } else { 3081 } else {
3081 RenderWidgetHostImpl* rwh = renderWidgetHostView_->render_widget_host_; 3082 RenderWidgetHostImpl* rwh = renderWidgetHostView_->render_widget_host_;
3082 rwh->Send(new ViewMsg_ExecuteEditCommand(rwh->GetRoutingID(), command, "")); 3083 rwh->Send(new InputMsg_ExecuteEditCommand(rwh->GetRoutingID(),
3084 command, ""));
3083 } 3085 }
3084 } 3086 }
3085 3087
3086 - (void)insertText:(id)string replacementRange:(NSRange)replacementRange { 3088 - (void)insertText:(id)string replacementRange:(NSRange)replacementRange {
3087 // An input method has characters to be inserted. 3089 // An input method has characters to be inserted.
3088 // Same as Linux, Mac calls this method not only: 3090 // Same as Linux, Mac calls this method not only:
3089 // * when an input method finishs composing text, but also; 3091 // * when an input method finishs composing text, but also;
3090 // * when we type an ASCII character (without using input methods). 3092 // * when we type an ASCII character (without using input methods).
3091 // When we aren't using input methods, we should send the given character as 3093 // When we aren't using input methods, we should send the given character as
3092 // a Char event so it is dispatched to an onkeypress() event handler of 3094 // a Char event so it is dispatched to an onkeypress() event handler of
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
3368 if (!string) return NO; 3370 if (!string) return NO;
3369 3371
3370 // If the user is currently using an IME, confirm the IME input, 3372 // If the user is currently using an IME, confirm the IME input,
3371 // and then insert the text from the service, the same as TextEdit and Safari. 3373 // and then insert the text from the service, the same as TextEdit and Safari.
3372 [self confirmComposition]; 3374 [self confirmComposition];
3373 [self insertText:string]; 3375 [self insertText:string];
3374 return YES; 3376 return YES;
3375 } 3377 }
3376 3378
3377 @end 3379 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698