| 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 <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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 #include "content/public/browser/web_contents.h" | 66 #include "content/public/browser/web_contents.h" |
| 67 #include "gpu/ipc/common/gpu_messages.h" | 67 #include "gpu/ipc/common/gpu_messages.h" |
| 68 #include "skia/ext/platform_canvas.h" | 68 #include "skia/ext/platform_canvas.h" |
| 69 #include "skia/ext/skia_utils_mac.h" | 69 #include "skia/ext/skia_utils_mac.h" |
| 70 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 70 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
| 71 #import "ui/base/clipboard/clipboard_util_mac.h" | 71 #import "ui/base/clipboard/clipboard_util_mac.h" |
| 72 #include "ui/base/cocoa/animation_utils.h" | 72 #include "ui/base/cocoa/animation_utils.h" |
| 73 #import "ui/base/cocoa/appkit_utils.h" | 73 #import "ui/base/cocoa/appkit_utils.h" |
| 74 #include "ui/base/cocoa/cocoa_base_utils.h" | 74 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 75 #import "ui/base/cocoa/fullscreen_window_manager.h" | 75 #import "ui/base/cocoa/fullscreen_window_manager.h" |
| 76 #include "ui/base/cocoa/text_services_context_menu.h" | |
| 77 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" | 76 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" |
| 78 #include "ui/base/layout.h" | 77 #include "ui/base/layout.h" |
| 79 #include "ui/compositor/compositor.h" | 78 #include "ui/compositor/compositor.h" |
| 80 #include "ui/compositor/layer.h" | 79 #include "ui/compositor/layer.h" |
| 81 #include "ui/display/display.h" | 80 #include "ui/display/display.h" |
| 82 #include "ui/display/screen.h" | 81 #include "ui/display/screen.h" |
| 83 #include "ui/events/base_event_utils.h" | 82 #include "ui/events/base_event_utils.h" |
| 84 #include "ui/events/event_utils.h" | 83 #include "ui/events/event_utils.h" |
| 85 #include "ui/events/keycodes/keyboard_codes.h" | 84 #include "ui/events/keycodes/keyboard_codes.h" |
| 86 #include "ui/gfx/geometry/dip_util.h" | 85 #include "ui/gfx/geometry/dip_util.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 return render_widget_host_view; | 131 return render_widget_host_view; |
| 133 content::WebContents* guest = | 132 content::WebContents* guest = |
| 134 guest_manager->GetFullPageGuest(web_contents); | 133 guest_manager->GetFullPageGuest(web_contents); |
| 135 if (!guest) | 134 if (!guest) |
| 136 return render_widget_host_view; | 135 return render_widget_host_view; |
| 137 return guest->GetRenderWidgetHostView(); | 136 return guest->GetRenderWidgetHostView(); |
| 138 } | 137 } |
| 139 | 138 |
| 140 } // namespace | 139 } // namespace |
| 141 | 140 |
| 141 // These are not documented, so use only after checking -respondsToSelector:. |
| 142 @interface NSApplication (UndocumentedSpeechMethods) |
| 143 - (void)speakString:(NSString*)string; |
| 144 - (void)stopSpeaking:(id)sender; |
| 145 - (BOOL)isSpeaking; |
| 146 @end |
| 147 |
| 142 // Private methods: | 148 // Private methods: |
| 143 @interface RenderWidgetHostViewCocoa () | 149 @interface RenderWidgetHostViewCocoa () |
| 144 @property(nonatomic, assign) NSRange selectedRange; | 150 @property(nonatomic, assign) NSRange selectedRange; |
| 145 @property(nonatomic, assign) NSRange markedRange; | 151 @property(nonatomic, assign) NSRange markedRange; |
| 146 | 152 |
| 147 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event; | 153 + (BOOL)shouldAutohideCursorForEvent:(NSEvent*)event; |
| 148 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r; | 154 - (id)initWithRenderWidgetHostViewMac:(RenderWidgetHostViewMac*)r; |
| 149 - (void)processedWheelEvent:(const blink::WebMouseWheelEvent&)event | 155 - (void)processedWheelEvent:(const blink::WebMouseWheelEvent&)event |
| 150 consumed:(BOOL)consumed; | 156 consumed:(BOOL)consumed; |
| 151 - (void)processedGestureScrollEvent:(const blink::WebGestureEvent&)event | 157 - (void)processedGestureScrollEvent:(const blink::WebGestureEvent&)event |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 | 721 |
| 716 if (!display_link_->GetVSyncParameters(&vsync_timebase_, &vsync_interval_)) { | 722 if (!display_link_->GetVSyncParameters(&vsync_timebase_, &vsync_interval_)) { |
| 717 vsync_timebase_ = base::TimeTicks(); | 723 vsync_timebase_ = base::TimeTicks(); |
| 718 vsync_interval_ = base::TimeDelta(); | 724 vsync_interval_ = base::TimeDelta(); |
| 719 return; | 725 return; |
| 720 } | 726 } |
| 721 | 727 |
| 722 browser_compositor_->UpdateVSyncParameters(vsync_timebase_, vsync_interval_); | 728 browser_compositor_->UpdateVSyncParameters(vsync_timebase_, vsync_interval_); |
| 723 } | 729 } |
| 724 | 730 |
| 731 void RenderWidgetHostViewMac::SpeakText(const std::string& text) { |
| 732 [NSApp speakString:base::SysUTF8ToNSString(text)]; |
| 733 } |
| 734 |
| 725 RenderWidgetHostViewBase* | 735 RenderWidgetHostViewBase* |
| 726 RenderWidgetHostViewMac::GetFocusedViewForTextSelection() { | 736 RenderWidgetHostViewMac::GetFocusedViewForTextSelection() { |
| 727 // We obtain the TextSelection from focused RWH which is obtained from the | 737 // We obtain the TextSelection from focused RWH which is obtained from the |
| 728 // frame tree. BrowserPlugin-based guests' RWH is not part of the frame tree | 738 // frame tree. BrowserPlugin-based guests' RWH is not part of the frame tree |
| 729 // and the focused RWH will be that of the embedder which is incorrect. In | 739 // and the focused RWH will be that of the embedder which is incorrect. In |
| 730 // this case we should use TextSelection for |this| since RWHV for guest | 740 // this case we should use TextSelection for |this| since RWHV for guest |
| 731 // forwards text selection information to its platform view. | 741 // forwards text selection information to its platform view. |
| 732 return is_guest_view_hack_ ? this : GetFocusedWidget() | 742 return is_guest_view_hack_ ? this : GetFocusedWidget() |
| 733 ? GetFocusedWidget()->GetView() | 743 ? GetFocusedWidget()->GetView() |
| 734 : nullptr; | 744 : nullptr; |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1014 RenderWidgetHostViewBase* focused_view = GetFocusedViewForTextSelection(); | 1024 RenderWidgetHostViewBase* focused_view = GetFocusedViewForTextSelection(); |
| 1015 if (!focused_view) | 1025 if (!focused_view) |
| 1016 return; | 1026 return; |
| 1017 | 1027 |
| 1018 const TextInputManager::TextSelection* selection = | 1028 const TextInputManager::TextSelection* selection = |
| 1019 GetTextInputManager()->GetTextSelection(focused_view); | 1029 GetTextInputManager()->GetTextSelection(focused_view); |
| 1020 | 1030 |
| 1021 base::string16 text; | 1031 base::string16 text; |
| 1022 if (!selection->GetSelectedText(&text)) | 1032 if (!selection->GetSelectedText(&text)) |
| 1023 return; | 1033 return; |
| 1024 selected_text_ = text; | 1034 selected_text_ = base::UTF16ToUTF8(text); |
| 1025 | 1035 |
| 1026 [cocoa_view_ setSelectedRange:selection->range.ToNSRange()]; | 1036 [cocoa_view_ setSelectedRange:selection->range.ToNSRange()]; |
| 1027 // Updates markedRange when there is no marked text so that retrieving | 1037 // Updates markedRange when there is no marked text so that retrieving |
| 1028 // markedRange immediately after calling setMarkdText: returns the current | 1038 // markedRange immediately after calling setMarkdText: returns the current |
| 1029 // caret position. | 1039 // caret position. |
| 1030 if (![cocoa_view_ hasMarkedText]) { | 1040 if (![cocoa_view_ hasMarkedText]) { |
| 1031 [cocoa_view_ setMarkedRange:selection->range.ToNSRange()]; | 1041 [cocoa_view_ setMarkedRange:selection->range.ToNSRange()]; |
| 1032 } | 1042 } |
| 1033 | 1043 |
| 1034 // TODO(ekaramad): The following values are tracked by TextInputManager and | 1044 // TODO(ekaramad): The following values are tracked by TextInputManager and |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 // set it again every single time the mouse moves. | 1112 // set it again every single time the mouse moves. |
| 1103 base::string16 display_text = tooltip_text_; | 1113 base::string16 display_text = tooltip_text_; |
| 1104 if (tooltip_text_.length() > kMaxTooltipLength) | 1114 if (tooltip_text_.length() > kMaxTooltipLength) |
| 1105 display_text = tooltip_text_.substr(0, kMaxTooltipLength); | 1115 display_text = tooltip_text_.substr(0, kMaxTooltipLength); |
| 1106 | 1116 |
| 1107 NSString* tooltip_nsstring = base::SysUTF16ToNSString(display_text); | 1117 NSString* tooltip_nsstring = base::SysUTF16ToNSString(display_text); |
| 1108 [cocoa_view_ setToolTipAtMousePoint:tooltip_nsstring]; | 1118 [cocoa_view_ setToolTipAtMousePoint:tooltip_nsstring]; |
| 1109 } | 1119 } |
| 1110 } | 1120 } |
| 1111 | 1121 |
| 1122 bool RenderWidgetHostViewMac::SupportsSpeech() const { |
| 1123 return [NSApp respondsToSelector:@selector(speakString:)] && |
| 1124 [NSApp respondsToSelector:@selector(stopSpeaking:)]; |
| 1125 } |
| 1126 |
| 1112 void RenderWidgetHostViewMac::SpeakSelection() { | 1127 void RenderWidgetHostViewMac::SpeakSelection() { |
| 1128 if (![NSApp respondsToSelector:@selector(speakString:)]) |
| 1129 return; |
| 1130 |
| 1113 if (selected_text_.empty() && render_widget_host_) { | 1131 if (selected_text_.empty() && render_widget_host_) { |
| 1114 // If there's no selection, speak all text. Send an asynchronous IPC | 1132 // If there's no selection, speak all text. Send an asynchronous IPC |
| 1115 // request for fetching all the text for a webcontent. | 1133 // request for fetching all the text for a webcontent. |
| 1116 // ViewMsg_GetRenderedTextCompleted is sent back to IPC Message receiver. | 1134 // ViewMsg_GetRenderedTextCompleted is sent back to IPC Message receiver. |
| 1117 render_widget_host_->Send(new ViewMsg_GetRenderedText( | 1135 render_widget_host_->Send(new ViewMsg_GetRenderedText( |
| 1118 render_widget_host_->GetRoutingID())); | 1136 render_widget_host_->GetRoutingID())); |
| 1119 return; | 1137 return; |
| 1120 } | 1138 } |
| 1121 | 1139 |
| 1122 ui::TextServicesContextMenu::SpeakText(selected_text_); | 1140 SpeakText(selected_text_); |
| 1141 } |
| 1142 |
| 1143 bool RenderWidgetHostViewMac::IsSpeaking() const { |
| 1144 return [NSApp respondsToSelector:@selector(isSpeaking)] && [NSApp isSpeaking]; |
| 1145 } |
| 1146 |
| 1147 void RenderWidgetHostViewMac::StopSpeaking() { |
| 1148 if ([NSApp respondsToSelector:@selector(stopSpeaking:)]) |
| 1149 [NSApp stopSpeaking:cocoa_view_]; |
| 1123 } | 1150 } |
| 1124 | 1151 |
| 1125 // | 1152 // |
| 1126 // RenderWidgetHostViewCocoa uses the stored selection text, | 1153 // RenderWidgetHostViewCocoa uses the stored selection text, |
| 1127 // which implements NSServicesRequests protocol. | 1154 // which implements NSServicesRequests protocol. |
| 1128 // | 1155 // |
| 1129 | 1156 |
| 1130 void RenderWidgetHostViewMac::SetShowingContextMenu(bool showing) { | 1157 void RenderWidgetHostViewMac::SetShowingContextMenu(bool showing) { |
| 1131 RenderWidgetHostViewBase::SetShowingContextMenu(showing); | 1158 RenderWidgetHostViewBase::SetShowingContextMenu(showing); |
| 1132 | 1159 |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1663 else | 1690 else |
| 1664 DisablePasswordInput(); | 1691 DisablePasswordInput(); |
| 1665 } else { | 1692 } else { |
| 1666 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_PASSWORD) | 1693 if (GetTextInputType() == ui::TEXT_INPUT_TYPE_PASSWORD) |
| 1667 DisablePasswordInput(); | 1694 DisablePasswordInput(); |
| 1668 } | 1695 } |
| 1669 } | 1696 } |
| 1670 | 1697 |
| 1671 void RenderWidgetHostViewMac::OnGetRenderedTextCompleted( | 1698 void RenderWidgetHostViewMac::OnGetRenderedTextCompleted( |
| 1672 const std::string& text) { | 1699 const std::string& text) { |
| 1673 ui::TextServicesContextMenu::SpeakText(base::UTF8ToUTF16(text)); | 1700 SpeakText(text); |
| 1674 } | 1701 } |
| 1675 | 1702 |
| 1676 void RenderWidgetHostViewMac::PauseForPendingResizeOrRepaintsAndDraw() { | 1703 void RenderWidgetHostViewMac::PauseForPendingResizeOrRepaintsAndDraw() { |
| 1677 if (!render_widget_host_ || render_widget_host_->is_hidden()) | 1704 if (!render_widget_host_ || render_widget_host_->is_hidden()) |
| 1678 return; | 1705 return; |
| 1679 | 1706 |
| 1680 // Pausing for one view prevents others from receiving frames. | 1707 // Pausing for one view prevents others from receiving frames. |
| 1681 // This may lead to large delays, causing overlaps. See crbug.com/352020. | 1708 // This may lead to large delays, causing overlaps. See crbug.com/352020. |
| 1682 if (!allow_pause_for_resize_or_repaint_) | 1709 if (!allow_pause_for_resize_or_repaint_) |
| 1683 return; | 1710 return; |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2349 | 2376 |
| 2350 - (void)showLookUpDictionaryOverlayInternal:(NSAttributedString*) string | 2377 - (void)showLookUpDictionaryOverlayInternal:(NSAttributedString*) string |
| 2351 baselinePoint:(NSPoint) baselinePoint | 2378 baselinePoint:(NSPoint) baselinePoint |
| 2352 targetView:(NSView*) view { | 2379 targetView:(NSView*) view { |
| 2353 if ([string length] == 0) { | 2380 if ([string length] == 0) { |
| 2354 // The PDF plugin does not support getting the attributed string at point. | 2381 // The PDF plugin does not support getting the attributed string at point. |
| 2355 // Until it does, use NSPerformService(), which opens Dictionary.app. | 2382 // Until it does, use NSPerformService(), which opens Dictionary.app. |
| 2356 // TODO(shuchen): Support GetStringAtPoint() & GetStringFromRange() for PDF. | 2383 // TODO(shuchen): Support GetStringAtPoint() & GetStringFromRange() for PDF. |
| 2357 // See crbug.com/152438. | 2384 // See crbug.com/152438. |
| 2358 NSString* text = | 2385 NSString* text = |
| 2359 base::SysUTF16ToNSString(renderWidgetHostView_->selected_text()); | 2386 base::SysUTF8ToNSString(renderWidgetHostView_->selected_text()); |
| 2360 if ([text length] == 0) | 2387 if ([text length] == 0) |
| 2361 return; | 2388 return; |
| 2362 scoped_refptr<ui::UniquePasteboard> pasteboard = new ui::UniquePasteboard; | 2389 scoped_refptr<ui::UniquePasteboard> pasteboard = new ui::UniquePasteboard; |
| 2363 NSArray* types = [NSArray arrayWithObject:NSStringPboardType]; | 2390 NSArray* types = [NSArray arrayWithObject:NSStringPboardType]; |
| 2364 [pasteboard->get() declareTypes:types owner:nil]; | 2391 [pasteboard->get() declareTypes:types owner:nil]; |
| 2365 if ([pasteboard->get() setString:text forType:NSStringPboardType]) | 2392 if ([pasteboard->get() setString:text forType:NSStringPboardType]) |
| 2366 NSPerformService(@"Look Up in Dictionary", pasteboard->get()); | 2393 NSPerformService(@"Look Up in Dictionary", pasteboard->get()); |
| 2367 return; | 2394 return; |
| 2368 } | 2395 } |
| 2369 dispatch_async(dispatch_get_main_queue(), ^{ | 2396 dispatch_async(dispatch_get_main_queue(), ^{ |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2743 if (known) | 2770 if (known) |
| 2744 return valid; | 2771 return valid; |
| 2745 } | 2772 } |
| 2746 | 2773 |
| 2747 SEL action = [item action]; | 2774 SEL action = [item action]; |
| 2748 BOOL is_render_view = | 2775 BOOL is_render_view = |
| 2749 RenderViewHost::From(renderWidgetHostView_->render_widget_host_) != | 2776 RenderViewHost::From(renderWidgetHostView_->render_widget_host_) != |
| 2750 nullptr; | 2777 nullptr; |
| 2751 | 2778 |
| 2752 if (action == @selector(stopSpeaking:)) | 2779 if (action == @selector(stopSpeaking:)) |
| 2753 return is_render_view && ui::TextServicesContextMenu::IsSpeaking(); | 2780 return is_render_view && renderWidgetHostView_->IsSpeaking(); |
| 2754 | 2781 |
| 2755 if (action == @selector(startSpeaking:)) | 2782 if (action == @selector(startSpeaking:)) |
| 2756 return is_render_view; | 2783 return is_render_view && renderWidgetHostView_->SupportsSpeech(); |
| 2757 | 2784 |
| 2758 // For now, these actions are always enabled for render view, | 2785 // For now, these actions are always enabled for render view, |
| 2759 // this is sub-optimal. | 2786 // this is sub-optimal. |
| 2760 // TODO(suzhe): Plumb the "can*" methods up from WebCore. | 2787 // TODO(suzhe): Plumb the "can*" methods up from WebCore. |
| 2761 if (action == @selector(undo:) || | 2788 if (action == @selector(undo:) || |
| 2762 action == @selector(redo:) || | 2789 action == @selector(redo:) || |
| 2763 action == @selector(cut:) || | 2790 action == @selector(cut:) || |
| 2764 action == @selector(copy:) || | 2791 action == @selector(copy:) || |
| 2765 action == @selector(copyToFindPboard:) || | 2792 action == @selector(copyToFindPboard:) || |
| 2766 action == @selector(paste:) || | 2793 action == @selector(paste:) || |
| (...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3340 renderWidgetHostView_->render_widget_host_->delegate(); | 3367 renderWidgetHostView_->render_widget_host_->delegate(); |
| 3341 if (render_widget_host_delegate) | 3368 if (render_widget_host_delegate) |
| 3342 render_widget_host_delegate->SelectAll(); | 3369 render_widget_host_delegate->SelectAll(); |
| 3343 } | 3370 } |
| 3344 | 3371 |
| 3345 - (void)startSpeaking:(id)sender { | 3372 - (void)startSpeaking:(id)sender { |
| 3346 GetRenderWidgetHostViewToUse(renderWidgetHostView_.get())->SpeakSelection(); | 3373 GetRenderWidgetHostViewToUse(renderWidgetHostView_.get())->SpeakSelection(); |
| 3347 } | 3374 } |
| 3348 | 3375 |
| 3349 - (void)stopSpeaking:(id)sender { | 3376 - (void)stopSpeaking:(id)sender { |
| 3350 ui::TextServicesContextMenu::StopSpeaking(); | 3377 GetRenderWidgetHostViewToUse(renderWidgetHostView_.get())->StopSpeaking(); |
| 3351 } | 3378 } |
| 3352 | 3379 |
| 3353 - (void)cancelComposition { | 3380 - (void)cancelComposition { |
| 3354 if (!hasMarkedText_) | 3381 if (!hasMarkedText_) |
| 3355 return; | 3382 return; |
| 3356 | 3383 |
| 3357 NSTextInputContext* inputContext = [self inputContext]; | 3384 NSTextInputContext* inputContext = [self inputContext]; |
| 3358 [inputContext discardMarkedText]; | 3385 [inputContext discardMarkedText]; |
| 3359 | 3386 |
| 3360 hasMarkedText_ = NO; | 3387 hasMarkedText_ = NO; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3411 | 3438 |
| 3412 @end | 3439 @end |
| 3413 | 3440 |
| 3414 // | 3441 // |
| 3415 // Supporting application services | 3442 // Supporting application services |
| 3416 // | 3443 // |
| 3417 @implementation RenderWidgetHostViewCocoa(NSServicesRequests) | 3444 @implementation RenderWidgetHostViewCocoa(NSServicesRequests) |
| 3418 | 3445 |
| 3419 - (BOOL)writeSelectionToPasteboard:(NSPasteboard*)pboard | 3446 - (BOOL)writeSelectionToPasteboard:(NSPasteboard*)pboard |
| 3420 types:(NSArray*)types { | 3447 types:(NSArray*)types { |
| 3421 const base::string16& str = renderWidgetHostView_->selected_text(); | 3448 const std::string& str = renderWidgetHostView_->selected_text(); |
| 3422 if (![types containsObject:NSStringPboardType] || str.empty()) return NO; | 3449 if (![types containsObject:NSStringPboardType] || str.empty()) return NO; |
| 3423 | 3450 |
| 3451 base::scoped_nsobject<NSString> text( |
| 3452 [[NSString alloc] initWithUTF8String:str.c_str()]); |
| 3424 NSArray* toDeclare = [NSArray arrayWithObject:NSStringPboardType]; | 3453 NSArray* toDeclare = [NSArray arrayWithObject:NSStringPboardType]; |
| 3425 [pboard declareTypes:toDeclare owner:nil]; | 3454 [pboard declareTypes:toDeclare owner:nil]; |
| 3426 return [pboard setString:SysUTF16ToNSString(str) forType:NSStringPboardType]; | 3455 return [pboard setString:text forType:NSStringPboardType]; |
| 3427 } | 3456 } |
| 3428 | 3457 |
| 3429 - (BOOL)readSelectionFromPasteboard:(NSPasteboard*)pboard { | 3458 - (BOOL)readSelectionFromPasteboard:(NSPasteboard*)pboard { |
| 3430 NSString *string = [pboard stringForType:NSStringPboardType]; | 3459 NSString *string = [pboard stringForType:NSStringPboardType]; |
| 3431 if (!string) return NO; | 3460 if (!string) return NO; |
| 3432 | 3461 |
| 3433 // If the user is currently using an IME, confirm the IME input, | 3462 // If the user is currently using an IME, confirm the IME input, |
| 3434 // and then insert the text from the service, the same as TextEdit and Safari. | 3463 // and then insert the text from the service, the same as TextEdit and Safari. |
| 3435 [self finishComposingText]; | 3464 [self finishComposingText]; |
| 3436 [self insertText:string]; | 3465 [self insertText:string]; |
| 3437 return YES; | 3466 return YES; |
| 3438 } | 3467 } |
| 3439 | 3468 |
| 3440 - (BOOL)isOpaque { | 3469 - (BOOL)isOpaque { |
| 3441 return opaque_; | 3470 return opaque_; |
| 3442 } | 3471 } |
| 3443 | 3472 |
| 3444 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3473 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3445 // regions that are not draggable. (See ControlRegionView in | 3474 // regions that are not draggable. (See ControlRegionView in |
| 3446 // native_app_window_cocoa.mm). This requires the render host view to be | 3475 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3447 // draggable by default. | 3476 // draggable by default. |
| 3448 - (BOOL)mouseDownCanMoveWindow { | 3477 - (BOOL)mouseDownCanMoveWindow { |
| 3449 return YES; | 3478 return YES; |
| 3450 } | 3479 } |
| 3451 | 3480 |
| 3452 @end | 3481 @end |
| OLD | NEW |