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 #import <objc/runtime.h> | 7 #import <objc/runtime.h> |
8 #include <OpenGL/gl.h> | 8 #include <OpenGL/gl.h> |
9 #include <QuartzCore/QuartzCore.h> | 9 #include <QuartzCore/QuartzCore.h> |
10 | 10 |
(...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1455 request_range.end() > composition_range_.end()) { | 1455 request_range.end() > composition_range_.end()) { |
1456 return gfx::Range::InvalidRange(); | 1456 return gfx::Range::InvalidRange(); |
1457 } | 1457 } |
1458 | 1458 |
1459 return gfx::Range( | 1459 return gfx::Range( |
1460 request_range.start() - composition_range_.start(), | 1460 request_range.start() - composition_range_.start(), |
1461 request_range.end() - composition_range_.start()); | 1461 request_range.end() - composition_range_.start()); |
1462 } | 1462 } |
1463 | 1463 |
1464 WebContents* RenderWidgetHostViewMac::GetWebContents() { | 1464 WebContents* RenderWidgetHostViewMac::GetWebContents() { |
1465 if (!render_widget_host_->IsRenderView()) | |
1466 return NULL; | |
1467 | |
1468 return WebContents::FromRenderViewHost( | 1465 return WebContents::FromRenderViewHost( |
1469 RenderViewHost::From(render_widget_host_)); | 1466 RenderViewHost::From(render_widget_host_)); |
1470 } | 1467 } |
1471 | 1468 |
1472 bool RenderWidgetHostViewMac::GetCachedFirstRectForCharacterRange( | 1469 bool RenderWidgetHostViewMac::GetCachedFirstRectForCharacterRange( |
1473 NSRange range, | 1470 NSRange range, |
1474 NSRect* rect, | 1471 NSRect* rect, |
1475 NSRange* actual_range) { | 1472 NSRange* actual_range) { |
1476 DCHECK(rect); | 1473 DCHECK(rect); |
1477 // This exists to make IMEs more responsive, see http://crbug.com/115920 | 1474 // This exists to make IMEs more responsive, see http://crbug.com/115920 |
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2743 respondsToSelector:@selector(validateUserInterfaceItem: | 2740 respondsToSelector:@selector(validateUserInterfaceItem: |
2744 isValidItem:)]) { | 2741 isValidItem:)]) { |
2745 BOOL valid; | 2742 BOOL valid; |
2746 BOOL known = | 2743 BOOL known = |
2747 [responderDelegate_ validateUserInterfaceItem:item isValidItem:&valid]; | 2744 [responderDelegate_ validateUserInterfaceItem:item isValidItem:&valid]; |
2748 if (known) | 2745 if (known) |
2749 return valid; | 2746 return valid; |
2750 } | 2747 } |
2751 | 2748 |
2752 SEL action = [item action]; | 2749 SEL action = [item action]; |
| 2750 BOOL is_render_view = |
| 2751 RenderViewHost::From(renderWidgetHostView_->render_widget_host_) != |
| 2752 nullptr; |
2753 | 2753 |
2754 if (action == @selector(stopSpeaking:)) { | 2754 if (action == @selector(stopSpeaking:)) |
2755 return renderWidgetHostView_->render_widget_host_->IsRenderView() && | 2755 return is_render_view && renderWidgetHostView_->IsSpeaking(); |
2756 renderWidgetHostView_->IsSpeaking(); | 2756 |
2757 } | 2757 if (action == @selector(startSpeaking:)) |
2758 if (action == @selector(startSpeaking:)) { | 2758 return is_render_view && renderWidgetHostView_->SupportsSpeech(); |
2759 return renderWidgetHostView_->render_widget_host_->IsRenderView() && | |
2760 renderWidgetHostView_->SupportsSpeech(); | |
2761 } | |
2762 | 2759 |
2763 // For now, these actions are always enabled for render view, | 2760 // For now, these actions are always enabled for render view, |
2764 // this is sub-optimal. | 2761 // this is sub-optimal. |
2765 // TODO(suzhe): Plumb the "can*" methods up from WebCore. | 2762 // TODO(suzhe): Plumb the "can*" methods up from WebCore. |
2766 if (action == @selector(undo:) || | 2763 if (action == @selector(undo:) || |
2767 action == @selector(redo:) || | 2764 action == @selector(redo:) || |
2768 action == @selector(cut:) || | 2765 action == @selector(cut:) || |
2769 action == @selector(copy:) || | 2766 action == @selector(copy:) || |
2770 action == @selector(copyToFindPboard:) || | 2767 action == @selector(copyToFindPboard:) || |
2771 action == @selector(paste:) || | 2768 action == @selector(paste:) || |
2772 action == @selector(pasteAndMatchStyle:)) { | 2769 action == @selector(pasteAndMatchStyle:)) { |
2773 return renderWidgetHostView_->render_widget_host_->IsRenderView(); | 2770 return is_render_view; |
2774 } | 2771 } |
2775 | 2772 |
2776 return editCommand_helper_->IsMenuItemEnabled(action, self); | 2773 return editCommand_helper_->IsMenuItemEnabled(action, self); |
2777 } | 2774 } |
2778 | 2775 |
2779 - (RenderWidgetHostViewMac*)renderWidgetHostViewMac { | 2776 - (RenderWidgetHostViewMac*)renderWidgetHostViewMac { |
2780 return renderWidgetHostView_.get(); | 2777 return renderWidgetHostView_.get(); |
2781 } | 2778 } |
2782 | 2779 |
2783 // Determine whether we should autohide the cursor (i.e., hide it until mouse | 2780 // Determine whether we should autohide the cursor (i.e., hide it until mouse |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3485 | 3482 |
3486 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3483 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
3487 // regions that are not draggable. (See ControlRegionView in | 3484 // regions that are not draggable. (See ControlRegionView in |
3488 // native_app_window_cocoa.mm). This requires the render host view to be | 3485 // native_app_window_cocoa.mm). This requires the render host view to be |
3489 // draggable by default. | 3486 // draggable by default. |
3490 - (BOOL)mouseDownCanMoveWindow { | 3487 - (BOOL)mouseDownCanMoveWindow { |
3491 return YES; | 3488 return YES; |
3492 } | 3489 } |
3493 | 3490 |
3494 @end | 3491 @end |
OLD | NEW |