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

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: compile fixes pt 2 Created 7 years, 8 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 15 matching lines...) Expand all
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/plugin_messages.h" 35 #include "content/common/plugin_messages.h"
36 #include "content/common/view_input_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"
(...skipping 1896 matching lines...) Expand 10 before | Expand all | Expand 10 after
1942 // -doCommandBySelector: (invoked by the call to -interpretKeyEvents: above) 1943 // -doCommandBySelector: (invoked by the call to -interpretKeyEvents: above)
1943 // enqueued edit commands, then in order to let webkit handle them 1944 // enqueued edit commands, then in order to let webkit handle them
1944 // correctly, we need to send the real key event and corresponding edit 1945 // correctly, we need to send the real key event and corresponding edit
1945 // commands after processing the input method result. 1946 // commands after processing the input method result.
1946 // We shouldn't do this if a new marked text was set by the input method, 1947 // We shouldn't do this if a new marked text was set by the input method,
1947 // otherwise the new marked text might be cancelled by webkit. 1948 // otherwise the new marked text might be cancelled by webkit.
1948 if (hasEditCommands_ && !hasMarkedText_) 1949 if (hasEditCommands_ && !hasMarkedText_)
1949 delayEventUntilAfterImeCompostion = YES; 1950 delayEventUntilAfterImeCompostion = YES;
1950 } else { 1951 } else {
1951 if (!editCommands_.empty()) { 1952 if (!editCommands_.empty()) {
1952 widgetHost->Send(new ViewMsg_SetEditCommandsForNextKeyEvent( 1953 widgetHost->Send(new ViewInputMsg_SetEditCommandsForNextKeyEvent(
1953 widgetHost->GetRoutingID(), editCommands_)); 1954 widgetHost->GetRoutingID(), editCommands_));
1954 } 1955 }
1955 widgetHost->ForwardKeyboardEvent(event); 1956 widgetHost->ForwardKeyboardEvent(event);
1956 } 1957 }
1957 1958
1958 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the 1959 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the
1959 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will 1960 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will
1960 // be set to NULL. So we check it here and return immediately if it's NULL. 1961 // be set to NULL. So we check it here and return immediately if it's NULL.
1961 if (!renderWidgetHostView_->render_widget_host_) 1962 if (!renderWidgetHostView_->render_widget_host_)
1962 return; 1963 return;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2008 // event to balance it. 2009 // event to balance it.
2009 NativeWebKeyboardEvent fakeEvent = event; 2010 NativeWebKeyboardEvent fakeEvent = event;
2010 fakeEvent.type = WebKit::WebInputEvent::KeyUp; 2011 fakeEvent.type = WebKit::WebInputEvent::KeyUp;
2011 fakeEvent.skip_in_browser = true; 2012 fakeEvent.skip_in_browser = true;
2012 widgetHost->ForwardKeyboardEvent(fakeEvent); 2013 widgetHost->ForwardKeyboardEvent(fakeEvent);
2013 // Not checking |renderWidgetHostView_->render_widget_host_| here because 2014 // Not checking |renderWidgetHostView_->render_widget_host_| here because
2014 // a key event with |skip_in_browser| == true won't be handled by browser, 2015 // a key event with |skip_in_browser| == true won't be handled by browser,
2015 // thus it won't destroy the widget. 2016 // thus it won't destroy the widget.
2016 2017
2017 if (!editCommands_.empty()) { 2018 if (!editCommands_.empty()) {
2018 widgetHost->Send(new ViewMsg_SetEditCommandsForNextKeyEvent( 2019 widgetHost->Send(new ViewInputMsg_SetEditCommandsForNextKeyEvent(
2019 widgetHost->GetRoutingID(), editCommands_)); 2020 widgetHost->GetRoutingID(), editCommands_));
2020 } 2021 }
2021 widgetHost->ForwardKeyboardEvent(event); 2022 widgetHost->ForwardKeyboardEvent(event);
2022 2023
2023 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the 2024 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the
2024 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will 2025 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will
2025 // be set to NULL. So we check it here and return immediately if it's NULL. 2026 // be set to NULL. So we check it here and return immediately if it's NULL.
2026 if (!renderWidgetHostView_->render_widget_host_) 2027 if (!renderWidgetHostView_->render_widget_host_)
2027 return; 2028 return;
2028 } 2029 }
(...skipping 1041 matching lines...) Expand 10 before | Expand all | Expand 10 after
3070 // it here. 3071 // it here.
3071 if (handlingKeyDown_) { 3072 if (handlingKeyDown_) {
3072 hasEditCommands_ = YES; 3073 hasEditCommands_ = YES;
3073 // We ignore commands that insert characters, because this was causing 3074 // We ignore commands that insert characters, because this was causing
3074 // strange behavior (e.g. tab always inserted a tab rather than moving to 3075 // strange behavior (e.g. tab always inserted a tab rather than moving to
3075 // the next field on the page). 3076 // the next field on the page).
3076 if (!StartsWithASCII(command, "insert", false)) 3077 if (!StartsWithASCII(command, "insert", false))
3077 editCommands_.push_back(EditCommand(command, "")); 3078 editCommands_.push_back(EditCommand(command, ""));
3078 } else { 3079 } else {
3079 RenderWidgetHostImpl* rwh = renderWidgetHostView_->render_widget_host_; 3080 RenderWidgetHostImpl* rwh = renderWidgetHostView_->render_widget_host_;
3080 rwh->Send(new ViewMsg_ExecuteEditCommand(rwh->GetRoutingID(), command, "")); 3081 rwh->Send(new ViewInputMsg_ExecuteEditCommand(rwh->GetRoutingID(),
3082 command,
3083 ""));
3081 } 3084 }
3082 } 3085 }
3083 3086
3084 - (void)insertText:(id)string replacementRange:(NSRange)replacementRange { 3087 - (void)insertText:(id)string replacementRange:(NSRange)replacementRange {
3085 // An input method has characters to be inserted. 3088 // An input method has characters to be inserted.
3086 // Same as Linux, Mac calls this method not only: 3089 // Same as Linux, Mac calls this method not only:
3087 // * when an input method finishs composing text, but also; 3090 // * when an input method finishs composing text, but also;
3088 // * when we type an ASCII character (without using input methods). 3091 // * when we type an ASCII character (without using input methods).
3089 // When we aren't using input methods, we should send the given character as 3092 // When we aren't using input methods, we should send the given character as
3090 // a Char event so it is dispatched to an onkeypress() event handler of 3093 // 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
3366 if (!string) return NO; 3369 if (!string) return NO;
3367 3370
3368 // If the user is currently using an IME, confirm the IME input, 3371 // If the user is currently using an IME, confirm the IME input,
3369 // and then insert the text from the service, the same as TextEdit and Safari. 3372 // and then insert the text from the service, the same as TextEdit and Safari.
3370 [self confirmComposition]; 3373 [self confirmComposition];
3371 [self insertText:string]; 3374 [self insertText:string];
3372 return YES; 3375 return YES;
3373 } 3376 }
3374 3377
3375 @end 3378 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698