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

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

Issue 2650913006: Send keyboard-derived commands only if the key events are sent (Closed)
Patch Set: Created 3 years, 10 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
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #import <Carbon/Carbon.h> 7 #import <Carbon/Carbon.h>
8 #import <objc/runtime.h> 8 #import <objc/runtime.h>
9 #include <OpenGL/gl.h> 9 #include <OpenGL/gl.h>
10 #include <QuartzCore/QuartzCore.h> 10 #include <QuartzCore/QuartzCore.h>
(...skipping 2144 matching lines...) Expand 10 before | Expand all | Expand 10 after
2155 // If this key event was handled by the input method, but 2155 // If this key event was handled by the input method, but
2156 // -doCommandBySelector: (invoked by the call to -interpretKeyEvents: above) 2156 // -doCommandBySelector: (invoked by the call to -interpretKeyEvents: above)
2157 // enqueued edit commands, then in order to let webkit handle them 2157 // enqueued edit commands, then in order to let webkit handle them
2158 // correctly, we need to send the real key event and corresponding edit 2158 // correctly, we need to send the real key event and corresponding edit
2159 // commands after processing the input method result. 2159 // commands after processing the input method result.
2160 // We shouldn't do this if a new marked text was set by the input method, 2160 // We shouldn't do this if a new marked text was set by the input method,
2161 // otherwise the new marked text might be cancelled by webkit. 2161 // otherwise the new marked text might be cancelled by webkit.
2162 if (hasEditCommands_ && !hasMarkedText_) 2162 if (hasEditCommands_ && !hasMarkedText_)
2163 delayEventUntilAfterImeCompostion = YES; 2163 delayEventUntilAfterImeCompostion = YES;
2164 } else { 2164 } else {
2165 if (!editCommands_.empty()) { 2165 widgetHost->ForwardKeyboardEventWithCommands(event, &editCommands_);
2166 widgetHost->Send(new InputMsg_SetEditCommandsForNextKeyEvent(
2167 widgetHost->GetRoutingID(), editCommands_));
2168 }
2169 widgetHost->ForwardKeyboardEvent(event);
2170 } 2166 }
2171 2167
2172 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the 2168 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the
2173 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will 2169 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will
2174 // be set to NULL. So we check it here and return immediately if it's NULL. 2170 // be set to NULL. So we check it here and return immediately if it's NULL.
2175 if (!renderWidgetHostView_->render_widget_host_) 2171 if (!renderWidgetHostView_->render_widget_host_)
2176 return; 2172 return;
2177 2173
2178 // Then send keypress and/or composition related events. 2174 // Then send keypress and/or composition related events.
2179 // If there was a marked text or the text to be inserted is longer than 1 2175 // If there was a marked text or the text to be inserted is longer than 1
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 // So before sending the real key down event, we need to send a fake key up 2224 // So before sending the real key down event, we need to send a fake key up
2229 // event to balance it. 2225 // event to balance it.
2230 NativeWebKeyboardEvent fakeEvent = event; 2226 NativeWebKeyboardEvent fakeEvent = event;
2231 fakeEvent.setType(blink::WebInputEvent::KeyUp); 2227 fakeEvent.setType(blink::WebInputEvent::KeyUp);
2232 fakeEvent.skip_in_browser = true; 2228 fakeEvent.skip_in_browser = true;
2233 widgetHost->ForwardKeyboardEvent(fakeEvent); 2229 widgetHost->ForwardKeyboardEvent(fakeEvent);
2234 // Not checking |renderWidgetHostView_->render_widget_host_| here because 2230 // Not checking |renderWidgetHostView_->render_widget_host_| here because
2235 // a key event with |skip_in_browser| == true won't be handled by browser, 2231 // a key event with |skip_in_browser| == true won't be handled by browser,
2236 // thus it won't destroy the widget. 2232 // thus it won't destroy the widget.
2237 2233
2238 if (!editCommands_.empty()) { 2234 widgetHost->ForwardKeyboardEventWithCommands(event, &editCommands_);
2239 widgetHost->Send(new InputMsg_SetEditCommandsForNextKeyEvent(
2240 widgetHost->GetRoutingID(), editCommands_));
2241 }
2242 widgetHost->ForwardKeyboardEvent(event);
2243 2235
2244 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the 2236 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the
2245 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will 2237 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will
2246 // be set to NULL. So we check it here and return immediately if it's NULL. 2238 // be set to NULL. So we check it here and return immediately if it's NULL.
2247 if (!renderWidgetHostView_->render_widget_host_) 2239 if (!renderWidgetHostView_->render_widget_host_)
2248 return; 2240 return;
2249 } 2241 }
2250 2242
2251 const NSUInteger kCtrlCmdKeyMask = NSControlKeyMask | NSCommandKeyMask; 2243 const NSUInteger kCtrlCmdKeyMask = NSControlKeyMask | NSCommandKeyMask;
2252 // Only send a corresponding key press event if there is no marked text. 2244 // Only send a corresponding key press event if there is no marked text.
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
3453 3445
3454 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3446 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3455 // regions that are not draggable. (See ControlRegionView in 3447 // regions that are not draggable. (See ControlRegionView in
3456 // native_app_window_cocoa.mm). This requires the render host view to be 3448 // native_app_window_cocoa.mm). This requires the render host view to be
3457 // draggable by default. 3449 // draggable by default.
3458 - (BOOL)mouseDownCanMoveWindow { 3450 - (BOOL)mouseDownCanMoveWindow {
3459 return YES; 3451 return YES;
3460 } 3452 }
3461 3453
3462 @end 3454 @end
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698