| 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 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 // RenderWidgetHostViewMac, public: | 481 // RenderWidgetHostViewMac, public: |
| 482 | 482 |
| 483 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) | 483 RenderWidgetHostViewMac::RenderWidgetHostViewMac(RenderWidgetHost* widget) |
| 484 : render_widget_host_(RenderWidgetHostImpl::From(widget)), | 484 : render_widget_host_(RenderWidgetHostImpl::From(widget)), |
| 485 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 485 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 486 can_compose_inline_(true), | 486 can_compose_inline_(true), |
| 487 browser_compositor_view_placeholder_( | 487 browser_compositor_view_placeholder_( |
| 488 new BrowserCompositorViewPlaceholderMac), | 488 new BrowserCompositorViewPlaceholderMac), |
| 489 backing_store_scale_factor_(1), | 489 backing_store_scale_factor_(1), |
| 490 is_loading_(false), | 490 is_loading_(false), |
| 491 allow_pause_for_resize_or_repaint_(true), |
| 491 weak_factory_(this), | 492 weak_factory_(this), |
| 492 fullscreen_parent_host_view_(NULL), | 493 fullscreen_parent_host_view_(NULL), |
| 493 overlay_view_weak_factory_(this), | |
| 494 software_frame_weak_ptr_factory_(this) { | 494 software_frame_weak_ptr_factory_(this) { |
| 495 software_frame_manager_.reset(new SoftwareFrameManager( | 495 software_frame_manager_.reset(new SoftwareFrameManager( |
| 496 software_frame_weak_ptr_factory_.GetWeakPtr())); | 496 software_frame_weak_ptr_factory_.GetWeakPtr())); |
| 497 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| | 497 // |cocoa_view_| owns us and we will be deleted when |cocoa_view_| |
| 498 // goes away. Since we autorelease it, our caller must put | 498 // goes away. Since we autorelease it, our caller must put |
| 499 // |GetNativeView()| into the view hierarchy right after calling us. | 499 // |GetNativeView()| into the view hierarchy right after calling us. |
| 500 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] | 500 cocoa_view_ = [[[RenderWidgetHostViewCocoa alloc] |
| 501 initWithRenderWidgetHostViewMac:this] autorelease]; | 501 initWithRenderWidgetHostViewMac:this] autorelease]; |
| 502 | 502 |
| 503 background_layer_.reset([[CALayer alloc] init]); | 503 background_layer_.reset([[CALayer alloc] init]); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 | 536 |
| 537 void RenderWidgetHostViewMac::SetDelegate( | 537 void RenderWidgetHostViewMac::SetDelegate( |
| 538 NSObject<RenderWidgetHostViewMacDelegate>* delegate) { | 538 NSObject<RenderWidgetHostViewMacDelegate>* delegate) { |
| 539 [cocoa_view_ setResponderDelegate:delegate]; | 539 [cocoa_view_ setResponderDelegate:delegate]; |
| 540 } | 540 } |
| 541 | 541 |
| 542 void RenderWidgetHostViewMac::SetAllowOverlappingViews(bool overlapping) { | 542 void RenderWidgetHostViewMac::SetAllowOverlappingViews(bool overlapping) { |
| 543 // TODO(ccameron): Remove callers of this function. | 543 // TODO(ccameron): Remove callers of this function. |
| 544 } | 544 } |
| 545 | 545 |
| 546 void RenderWidgetHostViewMac::SetAllowPauseForResizeOrRepaint(bool allow) { |
| 547 allow_pause_for_resize_or_repaint_ = allow; |
| 548 } |
| 549 |
| 546 /////////////////////////////////////////////////////////////////////////////// | 550 /////////////////////////////////////////////////////////////////////////////// |
| 547 // RenderWidgetHostViewMac, RenderWidgetHostView implementation: | 551 // RenderWidgetHostViewMac, RenderWidgetHostView implementation: |
| 548 | 552 |
| 549 bool RenderWidgetHostViewMac::EnsureCompositedIOSurface() { | 553 bool RenderWidgetHostViewMac::EnsureCompositedIOSurface() { |
| 550 // If the context or the IOSurface's context has had an error, re-build | 554 // If the context or the IOSurface's context has had an error, re-build |
| 551 // everything from scratch. | 555 // everything from scratch. |
| 552 if (compositing_iosurface_context_ && | 556 if (compositing_iosurface_context_ && |
| 553 compositing_iosurface_context_->HasBeenPoisoned()) { | 557 compositing_iosurface_context_->HasBeenPoisoned()) { |
| 554 LOG(ERROR) << "Failing EnsureCompositedIOSurface because " | 558 LOG(ERROR) << "Failing EnsureCompositedIOSurface because " |
| 555 << "context was poisoned"; | 559 << "context was poisoned"; |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1559 // Request that a new frame be generated and dirty the view. | 1563 // Request that a new frame be generated and dirty the view. |
| 1560 if (render_widget_host_) | 1564 if (render_widget_host_) |
| 1561 render_widget_host_->ScheduleComposite(); | 1565 render_widget_host_->ScheduleComposite(); |
| 1562 [cocoa_view_ setNeedsDisplay:YES]; | 1566 [cocoa_view_ setNeedsDisplay:YES]; |
| 1563 | 1567 |
| 1564 // TODO(ccameron): It may be a good idea to request that the renderer recreate | 1568 // TODO(ccameron): It may be a good idea to request that the renderer recreate |
| 1565 // its GL context as well, and fall back to software if this happens | 1569 // its GL context as well, and fall back to software if this happens |
| 1566 // repeatedly. | 1570 // repeatedly. |
| 1567 } | 1571 } |
| 1568 | 1572 |
| 1569 void RenderWidgetHostViewMac::SetOverlayView( | |
| 1570 RenderWidgetHostViewMac* overlay, const gfx::Point& offset) { | |
| 1571 if (overlay_view_) | |
| 1572 overlay_view_->underlay_view_.reset(); | |
| 1573 | |
| 1574 overlay_view_ = overlay->overlay_view_weak_factory_.GetWeakPtr(); | |
| 1575 overlay_view_->underlay_view_ = overlay_view_weak_factory_.GetWeakPtr(); | |
| 1576 } | |
| 1577 | |
| 1578 void RenderWidgetHostViewMac::RemoveOverlayView() { | |
| 1579 if (overlay_view_) { | |
| 1580 overlay_view_->underlay_view_.reset(); | |
| 1581 overlay_view_.reset(); | |
| 1582 } | |
| 1583 } | |
| 1584 | |
| 1585 bool RenderWidgetHostViewMac::GetLineBreakIndex( | 1573 bool RenderWidgetHostViewMac::GetLineBreakIndex( |
| 1586 const std::vector<gfx::Rect>& bounds, | 1574 const std::vector<gfx::Rect>& bounds, |
| 1587 const gfx::Range& range, | 1575 const gfx::Range& range, |
| 1588 size_t* line_break_point) { | 1576 size_t* line_break_point) { |
| 1589 DCHECK(line_break_point); | 1577 DCHECK(line_break_point); |
| 1590 if (range.start() >= bounds.size() || range.is_reversed() || range.is_empty()) | 1578 if (range.start() >= bounds.size() || range.is_reversed() || range.is_empty()) |
| 1591 return false; | 1579 return false; |
| 1592 | 1580 |
| 1593 // We can't check line breaking completely from only rectangle array. Thus we | 1581 // We can't check line breaking completely from only rectangle array. Thus we |
| 1594 // assume the line breaking as the next character's y offset is larger than | 1582 // assume the line breaking as the next character's y offset is larger than |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2187 | 2175 |
| 2188 void RenderWidgetHostViewMac::PauseForPendingResizeOrRepaintsAndDraw() { | 2176 void RenderWidgetHostViewMac::PauseForPendingResizeOrRepaintsAndDraw() { |
| 2189 if (!render_widget_host_ || render_widget_host_->is_hidden()) | 2177 if (!render_widget_host_ || render_widget_host_->is_hidden()) |
| 2190 return; | 2178 return; |
| 2191 | 2179 |
| 2192 // Synchronized resizing does not yet work with browser compositor. | 2180 // Synchronized resizing does not yet work with browser compositor. |
| 2193 // http://crbug.com/388005 | 2181 // http://crbug.com/388005 |
| 2194 if (delegated_frame_host_) | 2182 if (delegated_frame_host_) |
| 2195 return; | 2183 return; |
| 2196 | 2184 |
| 2197 // Pausing for the overlay/underlay view prevents the other one from receiving | 2185 // Pausing for one view prevents others from receiving frames. |
| 2198 // frames. This may lead to large delays, causing overlaps. | 2186 // This may lead to large delays, causing overlaps. See crbug.com/352020. |
| 2199 // See crbug.com/352020. | 2187 if (!allow_pause_for_resize_or_repaint_) |
| 2200 if (underlay_view_ || overlay_view_) | |
| 2201 return; | 2188 return; |
| 2202 | 2189 |
| 2203 // Ensure that all frames are acked before waiting for a frame to come in. | 2190 // Ensure that all frames are acked before waiting for a frame to come in. |
| 2204 // Note that we will draw a frame at the end of this function, so it is safe | 2191 // Note that we will draw a frame at the end of this function, so it is safe |
| 2205 // to ack a never-drawn frame here. | 2192 // to ack a never-drawn frame here. |
| 2206 SendPendingSwapAck(); | 2193 SendPendingSwapAck(); |
| 2207 | 2194 |
| 2208 // Wait for a frame of the right size to come in. | 2195 // Wait for a frame of the right size to come in. |
| 2209 render_widget_host_->PauseForPendingResizeOrRepaints(); | 2196 render_widget_host_->PauseForPendingResizeOrRepaints(); |
| 2210 | 2197 |
| (...skipping 1743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3954 | 3941 |
| 3955 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding | 3942 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding |
| 3956 // regions that are not draggable. (See ControlRegionView in | 3943 // regions that are not draggable. (See ControlRegionView in |
| 3957 // native_app_window_cocoa.mm). This requires the render host view to be | 3944 // native_app_window_cocoa.mm). This requires the render host view to be |
| 3958 // draggable by default. | 3945 // draggable by default. |
| 3959 - (BOOL)mouseDownCanMoveWindow { | 3946 - (BOOL)mouseDownCanMoveWindow { |
| 3960 return YES; | 3947 return YES; |
| 3961 } | 3948 } |
| 3962 | 3949 |
| 3963 @end | 3950 @end |
| OLD | NEW |