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/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 if (!output->Allocate( | 845 if (!output->Allocate( |
846 dst_pixel_size.width(), dst_pixel_size.height(), true)) | 846 dst_pixel_size.width(), dst_pixel_size.height(), true)) |
847 return; | 847 return; |
848 scoped_callback_runner.Release(); | 848 scoped_callback_runner.Release(); |
849 | 849 |
850 // Convert |src_subrect| from the views coordinate (upper-left origin) into | 850 // Convert |src_subrect| from the views coordinate (upper-left origin) into |
851 // the OpenGL coordinate (lower-left origin). | 851 // the OpenGL coordinate (lower-left origin). |
852 gfx::Rect src_gl_subrect = src_subrect; | 852 gfx::Rect src_gl_subrect = src_subrect; |
853 src_gl_subrect.set_y(GetViewBounds().height() - src_subrect.bottom()); | 853 src_gl_subrect.set_y(GetViewBounds().height() - src_subrect.bottom()); |
854 | 854 |
855 gfx::Rect src_pixel_gl_subrect = | 855 gfx::RectF scaled_src_gl_subrect = src_gl_subrect; |
856 gfx::ToEnclosingRect(src_gl_subrect.Scale(scale)); | 856 scaled_src_gl_subrect.Scale(scale); |
| 857 gfx::Rect src_pixel_gl_subrect = gfx::ToEnclosingRect(scaled_src_gl_subrect); |
857 compositing_iosurface_->CopyTo( | 858 compositing_iosurface_->CopyTo( |
858 src_pixel_gl_subrect, | 859 src_pixel_gl_subrect, |
859 dst_pixel_size, | 860 dst_pixel_size, |
860 output->GetBitmap().getPixels(), | 861 output->GetBitmap().getPixels(), |
861 callback); | 862 callback); |
862 } | 863 } |
863 | 864 |
864 // Sets whether or not to accept first responder status. | 865 // Sets whether or not to accept first responder status. |
865 void RenderWidgetHostViewMac::SetTakesFocusOnlyOnMouseDown(bool flag) { | 866 void RenderWidgetHostViewMac::SetTakesFocusOnlyOnMouseDown(bool flag) { |
866 [cocoa_view_ setTakesFocusOnlyOnMouseDown:flag]; | 867 [cocoa_view_ setTakesFocusOnlyOnMouseDown:flag]; |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 } | 1112 } |
1112 } | 1113 } |
1113 | 1114 |
1114 size_t end_idx; | 1115 size_t end_idx; |
1115 if (!GetLineBreakIndex(composition_bounds_, range, &end_idx)) { | 1116 if (!GetLineBreakIndex(composition_bounds_, range, &end_idx)) { |
1116 end_idx = range.end(); | 1117 end_idx = range.end(); |
1117 } | 1118 } |
1118 *actual_range = ui::Range(range.start(), end_idx); | 1119 *actual_range = ui::Range(range.start(), end_idx); |
1119 gfx::Rect rect = composition_bounds_[range.start()]; | 1120 gfx::Rect rect = composition_bounds_[range.start()]; |
1120 for (size_t i = range.start() + 1; i < end_idx; ++i) { | 1121 for (size_t i = range.start() + 1; i < end_idx; ++i) { |
1121 rect = rect.Union(composition_bounds_[i]); | 1122 rect.Union(composition_bounds_[i]); |
1122 } | 1123 } |
1123 return rect; | 1124 return rect; |
1124 } | 1125 } |
1125 | 1126 |
1126 ui::Range RenderWidgetHostViewMac::ConvertCharacterRangeToCompositionRange( | 1127 ui::Range RenderWidgetHostViewMac::ConvertCharacterRangeToCompositionRange( |
1127 const ui::Range& request_range) { | 1128 const ui::Range& request_range) { |
1128 if (composition_range_.is_empty()) | 1129 if (composition_range_.is_empty()) |
1129 return ui::Range::InvalidRange(); | 1130 return ui::Range::InvalidRange(); |
1130 | 1131 |
1131 if (request_range.is_reversed()) | 1132 if (request_range.is_reversed()) |
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2262 // Note: All coordinates are in view units, not pixels. | 2263 // Note: All coordinates are in view units, not pixels. |
2263 gfx::Rect bitmapRect(0, 0, | 2264 gfx::Rect bitmapRect(0, 0, |
2264 backingStore->size().width(), | 2265 backingStore->size().width(), |
2265 backingStore->size().height()); | 2266 backingStore->size().height()); |
2266 | 2267 |
2267 // Specify the proper y offset to ensure that the view is rooted to the | 2268 // Specify the proper y offset to ensure that the view is rooted to the |
2268 // upper left corner. This can be negative, if the window was resized | 2269 // upper left corner. This can be negative, if the window was resized |
2269 // smaller and the renderer hasn't yet repainted. | 2270 // smaller and the renderer hasn't yet repainted. |
2270 int yOffset = NSHeight([self bounds]) - backingStore->size().height(); | 2271 int yOffset = NSHeight([self bounds]) - backingStore->size().height(); |
2271 | 2272 |
2272 gfx::Rect paintRect = bitmapRect.Intersect(damagedRect); | 2273 gfx::Rect paintRect = bitmapRect; |
| 2274 paintRect.Intersect(damagedRect); |
2273 if (!paintRect.IsEmpty()) { | 2275 if (!paintRect.IsEmpty()) { |
2274 // if we have a CGLayer, draw that into the window | 2276 // if we have a CGLayer, draw that into the window |
2275 if (backingStore->cg_layer()) { | 2277 if (backingStore->cg_layer()) { |
2276 CGContextRef context = static_cast<CGContextRef>( | 2278 CGContextRef context = static_cast<CGContextRef>( |
2277 [[NSGraphicsContext currentContext] graphicsPort]); | 2279 [[NSGraphicsContext currentContext] graphicsPort]); |
2278 | 2280 |
2279 // TODO: add clipping to dirtyRect if it improves drawing performance. | 2281 // TODO: add clipping to dirtyRect if it improves drawing performance. |
2280 CGContextDrawLayerAtPoint(context, CGPointMake(0.0, yOffset), | 2282 CGContextDrawLayerAtPoint(context, CGPointMake(0.0, yOffset), |
2281 backingStore->cg_layer()); | 2283 backingStore->cg_layer()); |
2282 } else { | 2284 } else { |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3297 if (!string) return NO; | 3299 if (!string) return NO; |
3298 | 3300 |
3299 // If the user is currently using an IME, confirm the IME input, | 3301 // If the user is currently using an IME, confirm the IME input, |
3300 // and then insert the text from the service, the same as TextEdit and Safari. | 3302 // and then insert the text from the service, the same as TextEdit and Safari. |
3301 [self confirmComposition]; | 3303 [self confirmComposition]; |
3302 [self insertText:string]; | 3304 [self insertText:string]; |
3303 return YES; | 3305 return YES; |
3304 } | 3306 } |
3305 | 3307 |
3306 @end | 3308 @end |
OLD | NEW |