| 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_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/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 // static | 224 // static |
| 225 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( | 225 void content::RenderWidgetHostViewPort::GetDefaultScreenInfo( |
| 226 WebKit::WebScreenInfo* results) { | 226 WebKit::WebScreenInfo* results) { |
| 227 *results = WebKit::WebScreenInfoFactory::screenInfo(NULL); | 227 *results = WebKit::WebScreenInfoFactory::screenInfo(NULL); |
| 228 } | 228 } |
| 229 | 229 |
| 230 /////////////////////////////////////////////////////////////////////////////// | 230 /////////////////////////////////////////////////////////////////////////////// |
| 231 // RenderWidgetHostViewMac, public: | 231 // RenderWidgetHostViewMac, public: |
| 232 | 232 |
| 233 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) | 233 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) |
| 234 : about_to_validate_and_paint_(false), | 234 : render_widget_host_(RenderWidgetHostImpl::From(widget)), |
| 235 about_to_validate_and_paint_(false), |
| 235 call_set_needs_display_in_rect_pending_(false), | 236 call_set_needs_display_in_rect_pending_(false), |
| 236 last_frame_was_accelerated_(false), | 237 last_frame_was_accelerated_(false), |
| 237 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 238 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 238 can_compose_inline_(true), | 239 can_compose_inline_(true), |
| 239 is_loading_(false), | 240 is_loading_(false), |
| 240 is_hidden_(false), | 241 is_hidden_(false), |
| 241 weak_factory_(this), | 242 weak_factory_(this), |
| 242 accelerated_compositing_active_(false), | 243 accelerated_compositing_active_(false), |
| 243 needs_gpu_visibility_update_after_repaint_(false), | 244 needs_gpu_visibility_update_after_repaint_(false), |
| 244 compositing_surface_(gfx::kNullPluginWindow) { | 245 compositing_surface_(gfx::kNullPluginWindow) { |
| 245 render_widget_host_ = static_cast<RenderWidgetHostImpl*>(widget); | |
| 246 | |
| 247 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| | 246 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| |
| 248 // goes away. Since we autorelease it, our caller must put | 247 // goes away. Since we autorelease it, our caller must put |
| 249 // |GetNativeView()| into the view hierarchy right after calling us. | 248 // |GetNativeView()| into the view hierarchy right after calling us. |
| 250 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] | 249 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] |
| 251 initWithRenderWidgetHostViewMac:this] autorelease]; | 250 initWithRenderWidgetHostViewMac:this] autorelease]; |
| 252 render_widget_host_->SetView(this); | 251 render_widget_host_->SetView(this); |
| 253 } | 252 } |
| 254 | 253 |
| 255 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { | 254 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { |
| 256 UnlockMouse(); | 255 UnlockMouse(); |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 if (event.type == WebInputEvent::RawKeyDown && | 763 if (event.type == WebInputEvent::RawKeyDown && |
| 765 [event.os_event type] == NSKeyDown) | 764 [event.os_event type] == NSKeyDown) |
| 766 return [cocoa_view_ postProcessEventForPluginIme:event.os_event]; | 765 return [cocoa_view_ postProcessEventForPluginIme:event.os_event]; |
| 767 return false; | 766 return false; |
| 768 } | 767 } |
| 769 | 768 |
| 770 void RenderWidgetHostViewMac::PluginImeCompositionCompleted( | 769 void RenderWidgetHostViewMac::PluginImeCompositionCompleted( |
| 771 const string16& text, int plugin_id) { | 770 const string16& text, int plugin_id) { |
| 772 if (render_widget_host_) { | 771 if (render_widget_host_) { |
| 773 render_widget_host_->Send(new ViewMsg_PluginImeCompositionCompleted( | 772 render_widget_host_->Send(new ViewMsg_PluginImeCompositionCompleted( |
| 774 render_widget_host_->routing_id(), text, plugin_id)); | 773 render_widget_host_->GetRoutingID(), text, plugin_id)); |
| 775 } | 774 } |
| 776 } | 775 } |
| 777 | 776 |
| 778 gfx::PluginWindowHandle | 777 gfx::PluginWindowHandle |
| 779 RenderWidgetHostViewMac::AllocateFakePluginWindowHandle(bool opaque, | 778 RenderWidgetHostViewMac::AllocateFakePluginWindowHandle(bool opaque, |
| 780 bool root) { | 779 bool root) { |
| 781 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 780 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 782 | 781 |
| 783 // |render_widget_host_| is set to NULL when |RWHVMac::Destroy()| has | 782 // |render_widget_host_| is set to NULL when |RWHVMac::Destroy()| has |
| 784 // completed. If |AllocateFakePluginWindowHandle()| is called after that, | 783 // completed. If |AllocateFakePluginWindowHandle()| is called after that, |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 962 TRACE_EVENT0("renderer_host", | 961 TRACE_EVENT0("renderer_host", |
| 963 "RenderWidgetHostViewMac::HandleDelayedGpuViewHiding"); | 962 "RenderWidgetHostViewMac::HandleDelayedGpuViewHiding"); |
| 964 if (needs_gpu_visibility_update_after_repaint_) { | 963 if (needs_gpu_visibility_update_after_repaint_) { |
| 965 UpdateRootGpuViewVisibility(false); | 964 UpdateRootGpuViewVisibility(false); |
| 966 needs_gpu_visibility_update_after_repaint_ = false; | 965 needs_gpu_visibility_update_after_repaint_ = false; |
| 967 } | 966 } |
| 968 } | 967 } |
| 969 | 968 |
| 970 void RenderWidgetHostViewMac::OnAcceleratedCompositingStateChange() { | 969 void RenderWidgetHostViewMac::OnAcceleratedCompositingStateChange() { |
| 971 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 970 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 972 bool activated = | 971 bool activated = RenderWidgetHostImpl::From( |
| 973 GetRenderWidgetHostImpl()->is_accelerated_compositing_active(); | 972 GetRenderWidgetHost())->is_accelerated_compositing_active(); |
| 974 bool changed = accelerated_compositing_active_ != activated; | 973 bool changed = accelerated_compositing_active_ != activated; |
| 975 accelerated_compositing_active_ = activated; | 974 accelerated_compositing_active_ = activated; |
| 976 if (!changed) | 975 if (!changed) |
| 977 return; | 976 return; |
| 978 | 977 |
| 979 TRACE_EVENT1("renderer_host", | 978 TRACE_EVENT1("renderer_host", |
| 980 "RenderWidgetHostViewMac::OnAcceleratedCompositingStateChange", | 979 "RenderWidgetHostViewMac::OnAcceleratedCompositingStateChange", |
| 981 "active", accelerated_compositing_active_); | 980 "active", accelerated_compositing_active_); |
| 982 if (accelerated_compositing_active_) { | 981 if (accelerated_compositing_active_) { |
| 983 UpdateRootGpuViewVisibility(accelerated_compositing_active_); | 982 UpdateRootGpuViewVisibility(accelerated_compositing_active_); |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1099 SetTextInputActive(active); | 1098 SetTextInputActive(active); |
| 1100 if (!active) { | 1099 if (!active) { |
| 1101 [cocoa_view_ setPluginImeActive:NO]; | 1100 [cocoa_view_ setPluginImeActive:NO]; |
| 1102 UnlockMouse(); | 1101 UnlockMouse(); |
| 1103 } | 1102 } |
| 1104 } | 1103 } |
| 1105 | 1104 |
| 1106 void RenderWidgetHostViewMac::SetWindowVisibility(bool visible) { | 1105 void RenderWidgetHostViewMac::SetWindowVisibility(bool visible) { |
| 1107 if (render_widget_host_) { | 1106 if (render_widget_host_) { |
| 1108 render_widget_host_->Send(new ViewMsg_SetWindowVisibility( | 1107 render_widget_host_->Send(new ViewMsg_SetWindowVisibility( |
| 1109 render_widget_host_->routing_id(), visible)); | 1108 render_widget_host_->GetRoutingID(), visible)); |
| 1110 } | 1109 } |
| 1111 } | 1110 } |
| 1112 | 1111 |
| 1113 void RenderWidgetHostViewMac::WindowFrameChanged() { | 1112 void RenderWidgetHostViewMac::WindowFrameChanged() { |
| 1114 if (render_widget_host_) { | 1113 if (render_widget_host_) { |
| 1115 render_widget_host_->Send(new ViewMsg_WindowFrameChanged( | 1114 render_widget_host_->Send(new ViewMsg_WindowFrameChanged( |
| 1116 render_widget_host_->routing_id(), GetRootWindowBounds(), | 1115 render_widget_host_->GetRoutingID(), GetRootWindowBounds(), |
| 1117 GetViewBounds())); | 1116 GetViewBounds())); |
| 1118 } | 1117 } |
| 1119 } | 1118 } |
| 1120 | 1119 |
| 1121 void RenderWidgetHostViewMac::SetBackground(const SkBitmap& background) { | 1120 void RenderWidgetHostViewMac::SetBackground(const SkBitmap& background) { |
| 1122 content::RenderWidgetHostViewBase::SetBackground(background); | 1121 content::RenderWidgetHostViewBase::SetBackground(background); |
| 1123 if (render_widget_host_) | 1122 if (render_widget_host_) |
| 1124 render_widget_host_->Send(new ViewMsg_SetBackground( | 1123 render_widget_host_->Send(new ViewMsg_SetBackground( |
| 1125 render_widget_host_->routing_id(), background)); | 1124 render_widget_host_->GetRoutingID(), background)); |
| 1126 } | 1125 } |
| 1127 | 1126 |
| 1128 void RenderWidgetHostViewMac::OnAccessibilityNotifications( | 1127 void RenderWidgetHostViewMac::OnAccessibilityNotifications( |
| 1129 const std::vector<AccessibilityHostMsg_NotificationParams>& params) { | 1128 const std::vector<AccessibilityHostMsg_NotificationParams>& params) { |
| 1130 if (!GetBrowserAccessibilityManager()) { | 1129 if (!GetBrowserAccessibilityManager()) { |
| 1131 SetBrowserAccessibilityManager( | 1130 SetBrowserAccessibilityManager( |
| 1132 BrowserAccessibilityManager::CreateEmptyDocument( | 1131 BrowserAccessibilityManager::CreateEmptyDocument( |
| 1133 cocoa_view_, static_cast<WebAccessibility::State>(0), NULL)); | 1132 cocoa_view_, static_cast<WebAccessibility::State>(0), NULL)); |
| 1134 } | 1133 } |
| 1135 GetBrowserAccessibilityManager()->OnAccessibilityNotifications(params); | 1134 GetBrowserAccessibilityManager()->OnAccessibilityNotifications(params); |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1539 // enqueued edit commands, then in order to let webkit handle them | 1538 // enqueued edit commands, then in order to let webkit handle them |
| 1540 // correctly, we need to send the real key event and corresponding edit | 1539 // correctly, we need to send the real key event and corresponding edit |
| 1541 // commands after processing the input method result. | 1540 // commands after processing the input method result. |
| 1542 // We shouldn't do this if a new marked text was set by the input method, | 1541 // We shouldn't do this if a new marked text was set by the input method, |
| 1543 // otherwise the new marked text might be cancelled by webkit. | 1542 // otherwise the new marked text might be cancelled by webkit. |
| 1544 if (hasEditCommands_ && !hasMarkedText_) | 1543 if (hasEditCommands_ && !hasMarkedText_) |
| 1545 delayEventUntilAfterImeCompostion = YES; | 1544 delayEventUntilAfterImeCompostion = YES; |
| 1546 } else { | 1545 } else { |
| 1547 if (!editCommands_.empty()) { | 1546 if (!editCommands_.empty()) { |
| 1548 widgetHost->Send(new ViewMsg_SetEditCommandsForNextKeyEvent( | 1547 widgetHost->Send(new ViewMsg_SetEditCommandsForNextKeyEvent( |
| 1549 widgetHost->routing_id(), editCommands_)); | 1548 widgetHost->GetRoutingID(), editCommands_)); |
| 1550 } | 1549 } |
| 1551 widgetHost->ForwardKeyboardEvent(event); | 1550 widgetHost->ForwardKeyboardEvent(event); |
| 1552 } | 1551 } |
| 1553 | 1552 |
| 1554 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the | 1553 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the |
| 1555 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will | 1554 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will |
| 1556 // be set to NULL. So we check it here and return immediately if it's NULL. | 1555 // be set to NULL. So we check it here and return immediately if it's NULL. |
| 1557 if (!renderWidgetHostView_->render_widget_host_) | 1556 if (!renderWidgetHostView_->render_widget_host_) |
| 1558 return; | 1557 return; |
| 1559 | 1558 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1605 NativeWebKeyboardEvent fakeEvent = event; | 1604 NativeWebKeyboardEvent fakeEvent = event; |
| 1606 fakeEvent.type = WebKit::WebInputEvent::KeyUp; | 1605 fakeEvent.type = WebKit::WebInputEvent::KeyUp; |
| 1607 fakeEvent.skip_in_browser = true; | 1606 fakeEvent.skip_in_browser = true; |
| 1608 widgetHost->ForwardKeyboardEvent(fakeEvent); | 1607 widgetHost->ForwardKeyboardEvent(fakeEvent); |
| 1609 // Not checking |renderWidgetHostView_->render_widget_host_| here because | 1608 // Not checking |renderWidgetHostView_->render_widget_host_| here because |
| 1610 // a key event with |skip_in_browser| == true won't be handled by browser, | 1609 // a key event with |skip_in_browser| == true won't be handled by browser, |
| 1611 // thus it won't destroy the widget. | 1610 // thus it won't destroy the widget. |
| 1612 | 1611 |
| 1613 if (!editCommands_.empty()) { | 1612 if (!editCommands_.empty()) { |
| 1614 widgetHost->Send(new ViewMsg_SetEditCommandsForNextKeyEvent( | 1613 widgetHost->Send(new ViewMsg_SetEditCommandsForNextKeyEvent( |
| 1615 widgetHost->routing_id(), editCommands_)); | 1614 widgetHost->GetRoutingID(), editCommands_)); |
| 1616 } | 1615 } |
| 1617 widgetHost->ForwardKeyboardEvent(event); | 1616 widgetHost->ForwardKeyboardEvent(event); |
| 1618 | 1617 |
| 1619 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the | 1618 // Calling ForwardKeyboardEvent() could have destroyed the widget. When the |
| 1620 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will | 1619 // widget was destroyed, |renderWidgetHostView_->render_widget_host_| will |
| 1621 // be set to NULL. So we check it here and return immediately if it's NULL. | 1620 // be set to NULL. So we check it here and return immediately if it's NULL. |
| 1622 if (!renderWidgetHostView_->render_widget_host_) | 1621 if (!renderWidgetHostView_->render_widget_host_) |
| 1623 return; | 1622 return; |
| 1624 } | 1623 } |
| 1625 | 1624 |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2033 if (focused_item_cocoa) | 2032 if (focused_item_cocoa) |
| 2034 return focused_item_cocoa; | 2033 return focused_item_cocoa; |
| 2035 } | 2034 } |
| 2036 } | 2035 } |
| 2037 return [super accessibilityFocusedUIElement]; | 2036 return [super accessibilityFocusedUIElement]; |
| 2038 } | 2037 } |
| 2039 | 2038 |
| 2040 - (void)doDefaultAction:(int32)accessibilityObjectId { | 2039 - (void)doDefaultAction:(int32)accessibilityObjectId { |
| 2041 RenderWidgetHostImpl* rwh = renderWidgetHostView_->render_widget_host_; | 2040 RenderWidgetHostImpl* rwh = renderWidgetHostView_->render_widget_host_; |
| 2042 rwh->Send(new AccessibilityMsg_DoDefaultAction( | 2041 rwh->Send(new AccessibilityMsg_DoDefaultAction( |
| 2043 rwh->routing_id(), accessibilityObjectId)); | 2042 rwh->GetRoutingID(), accessibilityObjectId)); |
| 2044 } | 2043 } |
| 2045 | 2044 |
| 2046 // Convert a web accessibility's location in web coordinates into a cocoa | 2045 // Convert a web accessibility's location in web coordinates into a cocoa |
| 2047 // screen coordinate. | 2046 // screen coordinate. |
| 2048 - (NSPoint)accessibilityPointInScreen: | 2047 - (NSPoint)accessibilityPointInScreen: |
| 2049 (BrowserAccessibilityCocoa*)accessibility { | 2048 (BrowserAccessibilityCocoa*)accessibility { |
| 2050 NSPoint origin = [accessibility origin]; | 2049 NSPoint origin = [accessibility origin]; |
| 2051 NSSize size = [[accessibility size] sizeValue]; | 2050 NSSize size = [[accessibility size] sizeValue]; |
| 2052 origin.y = NSHeight([self bounds]) - origin.y; | 2051 origin.y = NSHeight([self bounds]) - origin.y; |
| 2053 NSPoint originInWindow = [self convertPoint:origin toView:nil]; | 2052 NSPoint originInWindow = [self convertPoint:origin toView:nil]; |
| 2054 NSPoint originInScreen = [[self window] convertBaseToScreen:originInWindow]; | 2053 NSPoint originInScreen = [[self window] convertBaseToScreen:originInWindow]; |
| 2055 originInScreen.y = originInScreen.y - size.height; | 2054 originInScreen.y = originInScreen.y - size.height; |
| 2056 return originInScreen; | 2055 return originInScreen; |
| 2057 } | 2056 } |
| 2058 | 2057 |
| 2059 - (void)setAccessibilityFocus:(BOOL)focus | 2058 - (void)setAccessibilityFocus:(BOOL)focus |
| 2060 accessibilityId:(int32)accessibilityObjectId { | 2059 accessibilityId:(int32)accessibilityObjectId { |
| 2061 if (focus) { | 2060 if (focus) { |
| 2062 RenderWidgetHostImpl* rwh = renderWidgetHostView_->render_widget_host_; | 2061 RenderWidgetHostImpl* rwh = renderWidgetHostView_->render_widget_host_; |
| 2063 rwh->Send(new AccessibilityMsg_SetFocus( | 2062 rwh->Send(new AccessibilityMsg_SetFocus( |
| 2064 rwh->routing_id(), accessibilityObjectId)); | 2063 rwh->GetRoutingID(), accessibilityObjectId)); |
| 2065 } | 2064 } |
| 2066 } | 2065 } |
| 2067 | 2066 |
| 2068 - (void)performShowMenuAction:(BrowserAccessibilityCocoa*)accessibility { | 2067 - (void)performShowMenuAction:(BrowserAccessibilityCocoa*)accessibility { |
| 2069 // Performs a right click copying WebKit's | 2068 // Performs a right click copying WebKit's |
| 2070 // accessibilityPerformShowMenuAction. | 2069 // accessibilityPerformShowMenuAction. |
| 2071 NSPoint location = [self accessibilityPointInScreen:accessibility]; | 2070 NSPoint location = [self accessibilityPointInScreen:accessibility]; |
| 2072 NSSize size = [[accessibility size] sizeValue]; | 2071 NSSize size = [[accessibility size] sizeValue]; |
| 2073 location = [[self window] convertScreenToBase:location]; | 2072 location = [[self window] convertScreenToBase:location]; |
| 2074 location.x += size.width/2; | 2073 location.x += size.width/2; |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2505 // it here. | 2504 // it here. |
| 2506 if (handlingKeyDown_) { | 2505 if (handlingKeyDown_) { |
| 2507 hasEditCommands_ = YES; | 2506 hasEditCommands_ = YES; |
| 2508 // We ignore commands that insert characters, because this was causing | 2507 // We ignore commands that insert characters, because this was causing |
| 2509 // strange behavior (e.g. tab always inserted a tab rather than moving to | 2508 // strange behavior (e.g. tab always inserted a tab rather than moving to |
| 2510 // the next field on the page). | 2509 // the next field on the page). |
| 2511 if (!StartsWithASCII(command, "insert", false)) | 2510 if (!StartsWithASCII(command, "insert", false)) |
| 2512 editCommands_.push_back(EditCommand(command, "")); | 2511 editCommands_.push_back(EditCommand(command, "")); |
| 2513 } else { | 2512 } else { |
| 2514 RenderWidgetHostImpl* rwh = renderWidgetHostView_->render_widget_host_; | 2513 RenderWidgetHostImpl* rwh = renderWidgetHostView_->render_widget_host_; |
| 2515 rwh->Send(new ViewMsg_ExecuteEditCommand(rwh->routing_id(), command, "")); | 2514 rwh->Send(new ViewMsg_ExecuteEditCommand(rwh->GetRoutingID(), command, "")); |
| 2516 } | 2515 } |
| 2517 } | 2516 } |
| 2518 | 2517 |
| 2519 - (void)insertText:(id)string replacementRange:(NSRange)replacementRange { | 2518 - (void)insertText:(id)string replacementRange:(NSRange)replacementRange { |
| 2520 // An input method has characters to be inserted. | 2519 // An input method has characters to be inserted. |
| 2521 // Same as Linux, Mac calls this method not only: | 2520 // Same as Linux, Mac calls this method not only: |
| 2522 // * when an input method finishs composing text, but also; | 2521 // * when an input method finishs composing text, but also; |
| 2523 // * when we type an ASCII character (without using input methods). | 2522 // * when we type an ASCII character (without using input methods). |
| 2524 // When we aren't using input methods, we should send the given character as | 2523 // When we aren't using input methods, we should send the given character as |
| 2525 // a Char event so it is dispatched to an onkeypress() event handler of | 2524 // a Char event so it is dispatched to an onkeypress() event handler of |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2578 event.button = WebMouseEvent::ButtonLeft; | 2577 event.button = WebMouseEvent::ButtonLeft; |
| 2579 if (renderWidgetHostView_->render_widget_host_) | 2578 if (renderWidgetHostView_->render_widget_host_) |
| 2580 renderWidgetHostView_->render_widget_host_->ForwardMouseEvent(event); | 2579 renderWidgetHostView_->render_widget_host_->ForwardMouseEvent(event); |
| 2581 | 2580 |
| 2582 hasOpenMouseDown_ = NO; | 2581 hasOpenMouseDown_ = NO; |
| 2583 } | 2582 } |
| 2584 } | 2583 } |
| 2585 | 2584 |
| 2586 - (void)undo:(id)sender { | 2585 - (void)undo:(id)sender { |
| 2587 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { | 2586 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { |
| 2588 static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)-> | 2587 static_cast<RenderViewHostImpl*>( |
| 2589 Undo(); | 2588 renderWidgetHostView_->render_widget_host_)->Undo(); |
| 2590 } | 2589 } |
| 2591 } | 2590 } |
| 2592 | 2591 |
| 2593 - (void)redo:(id)sender { | 2592 - (void)redo:(id)sender { |
| 2594 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { | 2593 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { |
| 2595 static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)-> | 2594 static_cast<RenderViewHostImpl*>( |
| 2596 Redo(); | 2595 renderWidgetHostView_->render_widget_host_)->Redo(); |
| 2597 } | 2596 } |
| 2598 } | 2597 } |
| 2599 | 2598 |
| 2600 - (void)cut:(id)sender { | 2599 - (void)cut:(id)sender { |
| 2601 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { | 2600 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { |
| 2602 static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)-> | 2601 static_cast<RenderViewHostImpl*>( |
| 2603 Cut(); | 2602 renderWidgetHostView_->render_widget_host_)->Cut(); |
| 2604 } | 2603 } |
| 2605 } | 2604 } |
| 2606 | 2605 |
| 2607 - (void)copy:(id)sender { | 2606 - (void)copy:(id)sender { |
| 2608 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { | 2607 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { |
| 2609 static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)-> | 2608 static_cast<RenderViewHostImpl*>( |
| 2610 Copy(); | 2609 renderWidgetHostView_->render_widget_host_)->Copy(); |
| 2611 } | 2610 } |
| 2612 } | 2611 } |
| 2613 | 2612 |
| 2614 - (void)copyToFindPboard:(id)sender { | 2613 - (void)copyToFindPboard:(id)sender { |
| 2615 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { | 2614 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { |
| 2616 static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)-> | 2615 static_cast<RenderViewHostImpl*>( |
| 2617 CopyToFindPboard(); | 2616 renderWidgetHostView_->render_widget_host_)->CopyToFindPboard(); |
| 2618 } | 2617 } |
| 2619 } | 2618 } |
| 2620 | 2619 |
| 2621 - (void)paste:(id)sender { | 2620 - (void)paste:(id)sender { |
| 2622 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { | 2621 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { |
| 2623 static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)-> | 2622 static_cast<RenderViewHostImpl*>( |
| 2624 Paste(); | 2623 renderWidgetHostView_->render_widget_host_)->Paste(); |
| 2625 } | 2624 } |
| 2626 } | 2625 } |
| 2627 | 2626 |
| 2628 - (void)pasteAndMatchStyle:(id)sender { | 2627 - (void)pasteAndMatchStyle:(id)sender { |
| 2629 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { | 2628 if (renderWidgetHostView_->render_widget_host_->IsRenderView()) { |
| 2630 static_cast<RenderViewHost*>(renderWidgetHostView_->render_widget_host_)-> | 2629 static_cast<RenderViewHostImpl*>( |
| 2631 PasteAndMatchStyle(); | 2630 renderWidgetHostView_->render_widget_host_)->PasteAndMatchStyle(); |
| 2632 } | 2631 } |
| 2633 } | 2632 } |
| 2634 | 2633 |
| 2635 - (void)cancelComposition { | 2634 - (void)cancelComposition { |
| 2636 if (!hasMarkedText_) | 2635 if (!hasMarkedText_) |
| 2637 return; | 2636 return; |
| 2638 | 2637 |
| 2639 // Cancel the ongoing composition. [NSInputManager markedTextAbandoned:] | 2638 // Cancel the ongoing composition. [NSInputManager markedTextAbandoned:] |
| 2640 // doesn't call any NSTextInput functions, such as setMarkedText or | 2639 // doesn't call any NSTextInput functions, such as setMarkedText or |
| 2641 // insertText. So, we need to send an IPC message to a renderer so it can | 2640 // insertText. So, we need to send an IPC message to a renderer so it can |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2727 requestor = [super validRequestorForSendType:sendType | 2726 requestor = [super validRequestorForSendType:sendType |
| 2728 returnType:returnType]; | 2727 returnType:returnType]; |
| 2729 } | 2728 } |
| 2730 return requestor; | 2729 return requestor; |
| 2731 } | 2730 } |
| 2732 | 2731 |
| 2733 - (void)viewWillStartLiveResize { | 2732 - (void)viewWillStartLiveResize { |
| 2734 [super viewWillStartLiveResize]; | 2733 [super viewWillStartLiveResize]; |
| 2735 RenderWidgetHostImpl* widget = renderWidgetHostView_->render_widget_host_; | 2734 RenderWidgetHostImpl* widget = renderWidgetHostView_->render_widget_host_; |
| 2736 if (widget) | 2735 if (widget) |
| 2737 widget->Send(new ViewMsg_SetInLiveResize(widget->routing_id(), true)); | 2736 widget->Send(new ViewMsg_SetInLiveResize(widget->GetRoutingID(), true)); |
| 2738 } | 2737 } |
| 2739 | 2738 |
| 2740 - (void)viewDidEndLiveResize { | 2739 - (void)viewDidEndLiveResize { |
| 2741 [super viewDidEndLiveResize]; | 2740 [super viewDidEndLiveResize]; |
| 2742 RenderWidgetHostImpl* widget = renderWidgetHostView_->render_widget_host_; | 2741 RenderWidgetHostImpl* widget = renderWidgetHostView_->render_widget_host_; |
| 2743 if (widget) | 2742 if (widget) |
| 2744 widget->Send(new ViewMsg_SetInLiveResize(widget->routing_id(), false)); | 2743 widget->Send(new ViewMsg_SetInLiveResize(widget->GetRoutingID(), false)); |
| 2745 } | 2744 } |
| 2746 | 2745 |
| 2747 @end | 2746 @end |
| 2748 | 2747 |
| 2749 // | 2748 // |
| 2750 // Supporting application services | 2749 // Supporting application services |
| 2751 // | 2750 // |
| 2752 @implementation RenderWidgetHostViewCocoa(NSServicesRequests) | 2751 @implementation RenderWidgetHostViewCocoa(NSServicesRequests) |
| 2753 | 2752 |
| 2754 - (BOOL)writeSelectionToPasteboard:(NSPasteboard*)pboard | 2753 - (BOOL)writeSelectionToPasteboard:(NSPasteboard*)pboard |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2768 if (!string) return NO; | 2767 if (!string) return NO; |
| 2769 | 2768 |
| 2770 // If the user is currently using an IME, confirm the IME input, | 2769 // If the user is currently using an IME, confirm the IME input, |
| 2771 // and then insert the text from the service, the same as TextEdit and Safari. | 2770 // and then insert the text from the service, the same as TextEdit and Safari. |
| 2772 [self confirmComposition]; | 2771 [self confirmComposition]; |
| 2773 [self insertText:string]; | 2772 [self insertText:string]; |
| 2774 return YES; | 2773 return YES; |
| 2775 } | 2774 } |
| 2776 | 2775 |
| 2777 @end | 2776 @end |
| OLD | NEW |