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 #include <stdint.h> |
| 11 |
| 12 #include <limits> |
10 #include <utility> | 13 #include <utility> |
11 | 14 |
12 #include "base/basictypes.h" | |
13 #include "base/bind.h" | 15 #include "base/bind.h" |
14 #include "base/callback_helpers.h" | 16 #include "base/callback_helpers.h" |
15 #include "base/command_line.h" | 17 #include "base/command_line.h" |
16 #include "base/debug/crash_logging.h" | 18 #include "base/debug/crash_logging.h" |
17 #include "base/logging.h" | 19 #include "base/logging.h" |
18 #include "base/mac/mac_util.h" | 20 #include "base/mac/mac_util.h" |
19 #include "base/mac/scoped_cftyperef.h" | 21 #include "base/mac/scoped_cftyperef.h" |
20 #import "base/mac/scoped_nsobject.h" | 22 #import "base/mac/scoped_nsobject.h" |
21 #include "base/mac/sdk_forward_declarations.h" | 23 #include "base/mac/sdk_forward_declarations.h" |
22 #include "base/message_loop/message_loop.h" | 24 #include "base/message_loop/message_loop.h" |
(...skipping 1301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1324 return false; | 1326 return false; |
1325 | 1327 |
1326 // We can't check line breaking completely from only rectangle array. Thus we | 1328 // We can't check line breaking completely from only rectangle array. Thus we |
1327 // assume the line breaking as the next character's y offset is larger than | 1329 // assume the line breaking as the next character's y offset is larger than |
1328 // a threshold. Currently the threshold is determined as minimum y offset plus | 1330 // a threshold. Currently the threshold is determined as minimum y offset plus |
1329 // 75% of maximum height. | 1331 // 75% of maximum height. |
1330 // TODO(nona): Check the threshold is reliable or not. | 1332 // TODO(nona): Check the threshold is reliable or not. |
1331 // TODO(nona): Bidi support. | 1333 // TODO(nona): Bidi support. |
1332 const size_t loop_end_idx = std::min(bounds.size(), range.end()); | 1334 const size_t loop_end_idx = std::min(bounds.size(), range.end()); |
1333 int max_height = 0; | 1335 int max_height = 0; |
1334 int min_y_offset = kint32max; | 1336 int min_y_offset = std::numeric_limits<int32_t>::max(); |
1335 for (size_t idx = range.start(); idx < loop_end_idx; ++idx) { | 1337 for (size_t idx = range.start(); idx < loop_end_idx; ++idx) { |
1336 max_height = std::max(max_height, bounds[idx].height()); | 1338 max_height = std::max(max_height, bounds[idx].height()); |
1337 min_y_offset = std::min(min_y_offset, bounds[idx].y()); | 1339 min_y_offset = std::min(min_y_offset, bounds[idx].y()); |
1338 } | 1340 } |
1339 int line_break_threshold = min_y_offset + (max_height * 3 / 4); | 1341 int line_break_threshold = min_y_offset + (max_height * 3 / 4); |
1340 for (size_t idx = range.start(); idx < loop_end_idx; ++idx) { | 1342 for (size_t idx = range.start(); idx < loop_end_idx; ++idx) { |
1341 if (bounds[idx].y() > line_break_threshold) { | 1343 if (bounds[idx].y() > line_break_threshold) { |
1342 *line_break_point = idx; | 1344 *line_break_point = idx; |
1343 return true; | 1345 return true; |
1344 } | 1346 } |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1458 bool RenderWidgetHostViewMac::HasAcceleratedSurface( | 1460 bool RenderWidgetHostViewMac::HasAcceleratedSurface( |
1459 const gfx::Size& desired_size) { | 1461 const gfx::Size& desired_size) { |
1460 if (browser_compositor_) { | 1462 if (browser_compositor_) { |
1461 return browser_compositor_->accelerated_widget_mac()->HasFrameOfSize( | 1463 return browser_compositor_->accelerated_widget_mac()->HasFrameOfSize( |
1462 desired_size); | 1464 desired_size); |
1463 } | 1465 } |
1464 return false; | 1466 return false; |
1465 } | 1467 } |
1466 | 1468 |
1467 void RenderWidgetHostViewMac::OnSwapCompositorFrame( | 1469 void RenderWidgetHostViewMac::OnSwapCompositorFrame( |
1468 uint32 output_surface_id, scoped_ptr<cc::CompositorFrame> frame) { | 1470 uint32_t output_surface_id, |
| 1471 scoped_ptr<cc::CompositorFrame> frame) { |
1469 TRACE_EVENT0("browser", "RenderWidgetHostViewMac::OnSwapCompositorFrame"); | 1472 TRACE_EVENT0("browser", "RenderWidgetHostViewMac::OnSwapCompositorFrame"); |
1470 | 1473 |
1471 last_scroll_offset_ = frame->metadata.root_scroll_offset; | 1474 last_scroll_offset_ = frame->metadata.root_scroll_offset; |
1472 | 1475 |
1473 page_at_minimum_scale_ = frame->metadata.page_scale_factor == | 1476 page_at_minimum_scale_ = frame->metadata.page_scale_factor == |
1474 frame->metadata.min_page_scale_factor; | 1477 frame->metadata.min_page_scale_factor; |
1475 | 1478 |
1476 if (frame->delegated_frame_data) { | 1479 if (frame->delegated_frame_data) { |
1477 float scale_factor = frame->metadata.device_scale_factor; | 1480 float scale_factor = frame->metadata.device_scale_factor; |
1478 | 1481 |
(...skipping 1963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3442 | 3445 |
3443 // "-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 |
3444 // regions that are not draggable. (See ControlRegionView in | 3447 // regions that are not draggable. (See ControlRegionView in |
3445 // 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 |
3446 // draggable by default. | 3449 // draggable by default. |
3447 - (BOOL)mouseDownCanMoveWindow { | 3450 - (BOOL)mouseDownCanMoveWindow { |
3448 return YES; | 3451 return YES; |
3449 } | 3452 } |
3450 | 3453 |
3451 @end | 3454 @end |
OLD | NEW |