Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(203)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac.mm

Issue 864333004: Clean up DelegatedFrameHost's interface to its client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Incorprate review feedback Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 return results; 387 return results;
388 } 388 }
389 389
390 } // namespace 390 } // namespace
391 391
392 namespace content { 392 namespace content {
393 393
394 //////////////////////////////////////////////////////////////////////////////// 394 ////////////////////////////////////////////////////////////////////////////////
395 // DelegatedFrameHost, public: 395 // DelegatedFrameHost, public:
396 396
397 ui::Layer* RenderWidgetHostViewMac::GetLayer() { 397 bool RenderWidgetHostViewMac::DelegatedFrameHostIsVisible() const {
398 return root_layer_.get();
399 }
400
401 RenderWidgetHostImpl* RenderWidgetHostViewMac::GetHost() {
402 return render_widget_host_;
403 }
404
405 bool RenderWidgetHostViewMac::IsVisible() {
406 return !render_widget_host_->is_hidden(); 398 return !render_widget_host_->is_hidden();
407 } 399 }
408 400
409 gfx::Size RenderWidgetHostViewMac::DesiredFrameSize() { 401 gfx::Size RenderWidgetHostViewMac::DelegatedFrameHostDesiredSizeInDIP() const {
410 return GetViewBounds().size(); 402 return GetViewBounds().size();
411 } 403 }
412 404
413 float RenderWidgetHostViewMac::CurrentDeviceScaleFactor() { 405 bool RenderWidgetHostViewMac::DelegatedFrameCanCreateResizeLock() const {
414 return ViewScaleFactor(); 406 // Mac uses the RenderWidgetResizeHelper instead of a resize lock.
407 return false;
415 } 408 }
416 409
417 gfx::Size RenderWidgetHostViewMac::ConvertViewSizeToPixel( 410 scoped_ptr<ResizeLock>
418 const gfx::Size& size) { 411 RenderWidgetHostViewMac::DelegatedFrameHostCreateResizeLock(
419 return gfx::ToEnclosingRect(gfx::ScaleRect(gfx::Rect(size), 412 bool defer_compositor_lock) {
420 ViewScaleFactor())).size(); 413 NOTREACHED();
414 return scoped_ptr<ResizeLock>();
421 } 415 }
422 416
423 scoped_ptr<ResizeLock> RenderWidgetHostViewMac::CreateResizeLock( 417 void RenderWidgetHostViewMac::DelegatedFrameHostResizeLockWasReleased() {
424 bool defer_compositor_lock) {
425 NOTREACHED(); 418 NOTREACHED();
426 ResizeLock* lock = NULL;
427 return scoped_ptr<ResizeLock>(lock);
428 } 419 }
429 420
430 DelegatedFrameHost* RenderWidgetHostViewMac::GetDelegatedFrameHost() const { 421 void RenderWidgetHostViewMac::DelegatedFrameHostSendCompositorSwapAck(
431 return delegated_frame_host_.get(); 422 int output_surface_id,
423 const cc::CompositorFrameAck& ack) {
424 render_widget_host_->Send(new ViewMsg_SwapCompositorFrameAck(
425 render_widget_host_->GetRoutingID(), output_surface_id, ack));
426 }
427
428 void RenderWidgetHostViewMac::DelegatedFrameHostSendReclaimCompositorResources(
429 int output_surface_id,
430 const cc::CompositorFrameAck& ack) {
431 render_widget_host_->Send(new ViewMsg_ReclaimCompositorResources(
432 render_widget_host_->GetRoutingID(), output_surface_id, ack));
433 }
434
435 void RenderWidgetHostViewMac::DelegatedFrameHostOnLostCompositorResources() {
436 render_widget_host_->ScheduleComposite();
437 }
438
439 void RenderWidgetHostViewMac::DelegatedFrameHostUpdateVSyncParameters(
440 const base::TimeTicks& timebase,
441 const base::TimeDelta& interval) {
442 render_widget_host_->UpdateVSyncParameters(timebase, interval);
432 } 443 }
433 444
434 //////////////////////////////////////////////////////////////////////////////// 445 ////////////////////////////////////////////////////////////////////////////////
435 // AcceleratedWidgetMacNSView, public: 446 // AcceleratedWidgetMacNSView, public:
436 447
437 NSView* RenderWidgetHostViewMac::AcceleratedWidgetGetNSView() const { 448 NSView* RenderWidgetHostViewMac::AcceleratedWidgetGetNSView() const {
438 return cocoa_view_; 449 return cocoa_view_;
439 } 450 }
440 451
441 bool RenderWidgetHostViewMac::AcceleratedWidgetShouldIgnoreBackpressure() 452 bool RenderWidgetHostViewMac::AcceleratedWidgetShouldIgnoreBackpressure()
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
530 // ready to draw. 541 // ready to draw.
531 background_layer_.reset([[CALayer alloc] init]); 542 background_layer_.reset([[CALayer alloc] init]);
532 base::ScopedCFTypeRef<CGColorRef> background( 543 base::ScopedCFTypeRef<CGColorRef> background(
533 gfx::CGColorCreateFromSkColor(background_color_)); 544 gfx::CGColorCreateFromSkColor(background_color_));
534 [background_layer_ setBackgroundColor:background]; 545 [background_layer_ setBackgroundColor:background];
535 [cocoa_view_ setLayer:background_layer_]; 546 [cocoa_view_ setLayer:background_layer_];
536 [cocoa_view_ setWantsLayer:YES]; 547 [cocoa_view_ setWantsLayer:YES];
537 548
538 if (IsDelegatedRendererEnabled()) { 549 if (IsDelegatedRendererEnabled()) {
539 root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR)); 550 root_layer_.reset(new ui::Layer(ui::LAYER_SOLID_COLOR));
540 delegated_frame_host_.reset(new DelegatedFrameHost(this)); 551 delegated_frame_host_.reset(
552 new DelegatedFrameHost(this, root_layer_.get()));
541 } 553 }
542 554
543 gfx::Screen::GetScreenFor(cocoa_view_)->AddObserver(this); 555 gfx::Screen::GetScreenFor(cocoa_view_)->AddObserver(this);
544 556
545 if (!is_guest_view_hack_) 557 if (!is_guest_view_hack_)
546 render_widget_host_->SetView(this); 558 render_widget_host_->SetView(this);
547 } 559 }
548 560
549 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() { 561 RenderWidgetHostViewMac::~RenderWidgetHostViewMac() {
550 gfx::Screen::GetScreenFor(cocoa_view_)->RemoveObserver(this); 562 gfx::Screen::GetScreenFor(cocoa_view_)->RemoveObserver(this);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 void RenderWidgetHostViewMac::UpdateBackingStoreScaleFactor() { 819 void RenderWidgetHostViewMac::UpdateBackingStoreScaleFactor() {
808 if (!render_widget_host_) 820 if (!render_widget_host_)
809 return; 821 return;
810 render_widget_host_->NotifyScreenInfoChanged(); 822 render_widget_host_->NotifyScreenInfoChanged();
811 } 823 }
812 824
813 RenderWidgetHost* RenderWidgetHostViewMac::GetRenderWidgetHost() const { 825 RenderWidgetHost* RenderWidgetHostViewMac::GetRenderWidgetHost() const {
814 return render_widget_host_; 826 return render_widget_host_;
815 } 827 }
816 828
817
818 void RenderWidgetHostViewMac::Show() { 829 void RenderWidgetHostViewMac::Show() {
819 [cocoa_view_ setHidden:NO]; 830 [cocoa_view_ setHidden:NO];
820 if (!render_widget_host_->is_hidden()) 831 if (!render_widget_host_->is_hidden())
821 return; 832 return;
822 833
823 WasUnOccluded(); 834 WasUnOccluded();
824 835
825 // If there is not a frame being currently drawn, kick one, so that the below 836 // If there is not a frame being currently drawn, kick one, so that the below
826 // pause will have a frame to wait on. 837 // pause will have a frame to wait on.
827 render_widget_host_->ScheduleComposite(); 838 render_widget_host_->ScheduleComposite();
(...skipping 1716 matching lines...) Expand 10 before | Expand all | Expand 10 after
2544 return [fullArray subarrayWithRange:NSMakeRange(index, length)]; 2555 return [fullArray subarrayWithRange:NSMakeRange(index, length)];
2545 } 2556 }
2546 2557
2547 - (NSUInteger)accessibilityArrayAttributeCount:(NSString *)attribute { 2558 - (NSUInteger)accessibilityArrayAttributeCount:(NSString *)attribute {
2548 NSArray* fullArray = [self accessibilityAttributeValue:attribute]; 2559 NSArray* fullArray = [self accessibilityAttributeValue:attribute];
2549 return [fullArray count]; 2560 return [fullArray count];
2550 } 2561 }
2551 2562
2552 - (id)accessibilityAttributeValue:(NSString *)attribute { 2563 - (id)accessibilityAttributeValue:(NSString *)attribute {
2553 BrowserAccessibilityManager* manager = 2564 BrowserAccessibilityManager* manager =
2554 renderWidgetHostView_->GetHost()->GetRootBrowserAccessibilityManager(); 2565 renderWidgetHostView_->render_widget_host_
2566 ->GetRootBrowserAccessibilityManager();
2555 2567
2556 // Contents specifies document view of RenderWidgetHostViewCocoa provided by 2568 // Contents specifies document view of RenderWidgetHostViewCocoa provided by
2557 // BrowserAccessibilityManager. Children includes all subviews in addition to 2569 // BrowserAccessibilityManager. Children includes all subviews in addition to
2558 // contents. Currently we do not have subviews besides the document view. 2570 // contents. Currently we do not have subviews besides the document view.
2559 if (([attribute isEqualToString:NSAccessibilityChildrenAttribute] || 2571 if (([attribute isEqualToString:NSAccessibilityChildrenAttribute] ||
2560 [attribute isEqualToString:NSAccessibilityContentsAttribute]) && 2572 [attribute isEqualToString:NSAccessibilityContentsAttribute]) &&
2561 manager) { 2573 manager) {
2562 return [NSArray arrayWithObjects:manager-> 2574 return [NSArray arrayWithObjects:manager->
2563 GetRoot()->ToBrowserAccessibilityCocoa(), nil]; 2575 GetRoot()->ToBrowserAccessibilityCocoa(), nil];
2564 } else if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) { 2576 } else if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) {
2565 return NSAccessibilityScrollAreaRole; 2577 return NSAccessibilityScrollAreaRole;
2566 } 2578 }
2567 id ret = [super accessibilityAttributeValue:attribute]; 2579 id ret = [super accessibilityAttributeValue:attribute];
2568 return ret; 2580 return ret;
2569 } 2581 }
2570 2582
2571 - (NSArray*)accessibilityAttributeNames { 2583 - (NSArray*)accessibilityAttributeNames {
2572 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; 2584 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease];
2573 [ret addObject:NSAccessibilityContentsAttribute]; 2585 [ret addObject:NSAccessibilityContentsAttribute];
2574 [ret addObjectsFromArray:[super accessibilityAttributeNames]]; 2586 [ret addObjectsFromArray:[super accessibilityAttributeNames]];
2575 return ret; 2587 return ret;
2576 } 2588 }
2577 2589
2578 - (id)accessibilityHitTest:(NSPoint)point { 2590 - (id)accessibilityHitTest:(NSPoint)point {
2579 BrowserAccessibilityManager* manager = 2591 BrowserAccessibilityManager* manager =
2580 renderWidgetHostView_->GetHost()->GetRootBrowserAccessibilityManager(); 2592 renderWidgetHostView_->render_widget_host_
2593 ->GetRootBrowserAccessibilityManager();
2581 if (!manager) 2594 if (!manager)
2582 return self; 2595 return self;
2583 NSPoint pointInWindow = [[self window] convertScreenToBase:point]; 2596 NSPoint pointInWindow = [[self window] convertScreenToBase:point];
2584 NSPoint localPoint = [self convertPoint:pointInWindow fromView:nil]; 2597 NSPoint localPoint = [self convertPoint:pointInWindow fromView:nil];
2585 localPoint.y = NSHeight([self bounds]) - localPoint.y; 2598 localPoint.y = NSHeight([self bounds]) - localPoint.y;
2586 BrowserAccessibilityCocoa* root = 2599 BrowserAccessibilityCocoa* root =
2587 manager->GetRoot()->ToBrowserAccessibilityCocoa(); 2600 manager->GetRoot()->ToBrowserAccessibilityCocoa();
2588 id obj = [root accessibilityHitTest:localPoint]; 2601 id obj = [root accessibilityHitTest:localPoint];
2589 return obj; 2602 return obj;
2590 } 2603 }
2591 2604
2592 - (BOOL)accessibilityIsIgnored { 2605 - (BOOL)accessibilityIsIgnored {
2593 BrowserAccessibilityManager* manager = 2606 BrowserAccessibilityManager* manager =
2594 renderWidgetHostView_->GetHost()->GetRootBrowserAccessibilityManager(); 2607 renderWidgetHostView_->render_widget_host_
2608 ->GetRootBrowserAccessibilityManager();
2595 return !manager; 2609 return !manager;
2596 } 2610 }
2597 2611
2598 - (NSUInteger)accessibilityGetIndexOf:(id)child { 2612 - (NSUInteger)accessibilityGetIndexOf:(id)child {
2599 BrowserAccessibilityManager* manager = 2613 BrowserAccessibilityManager* manager =
2600 renderWidgetHostView_->GetHost()->GetRootBrowserAccessibilityManager(); 2614 renderWidgetHostView_->render_widget_host_
2615 ->GetRootBrowserAccessibilityManager();
2601 // Only child is root. 2616 // Only child is root.
2602 if (manager && 2617 if (manager &&
2603 manager->GetRoot()->ToBrowserAccessibilityCocoa() == child) { 2618 manager->GetRoot()->ToBrowserAccessibilityCocoa() == child) {
2604 return 0; 2619 return 0;
2605 } else { 2620 } else {
2606 return NSNotFound; 2621 return NSNotFound;
2607 } 2622 }
2608 } 2623 }
2609 2624
2610 - (id)accessibilityFocusedUIElement { 2625 - (id)accessibilityFocusedUIElement {
2611 BrowserAccessibilityManager* manager = 2626 BrowserAccessibilityManager* manager =
2612 renderWidgetHostView_->GetHost()->GetRootBrowserAccessibilityManager(); 2627 renderWidgetHostView_->render_widget_host_
2628 ->GetRootBrowserAccessibilityManager();
2613 if (manager) { 2629 if (manager) {
2614 BrowserAccessibility* focused_item = manager->GetFocus(NULL); 2630 BrowserAccessibility* focused_item = manager->GetFocus(NULL);
2615 DCHECK(focused_item); 2631 DCHECK(focused_item);
2616 if (focused_item) { 2632 if (focused_item) {
2617 BrowserAccessibilityCocoa* focused_item_cocoa = 2633 BrowserAccessibilityCocoa* focused_item_cocoa =
2618 focused_item->ToBrowserAccessibilityCocoa(); 2634 focused_item->ToBrowserAccessibilityCocoa();
2619 DCHECK(focused_item_cocoa); 2635 DCHECK(focused_item_cocoa);
2620 if (focused_item_cocoa) 2636 if (focused_item_cocoa)
2621 return focused_item_cocoa; 2637 return focused_item_cocoa;
2622 } 2638 }
(...skipping 741 matching lines...) Expand 10 before | Expand all | Expand 10 after
3364 3380
3365 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding 3381 // "-webkit-app-region: drag | no-drag" is implemented on Mac by excluding
3366 // regions that are not draggable. (See ControlRegionView in 3382 // regions that are not draggable. (See ControlRegionView in
3367 // native_app_window_cocoa.mm). This requires the render host view to be 3383 // native_app_window_cocoa.mm). This requires the render host view to be
3368 // draggable by default. 3384 // draggable by default.
3369 - (BOOL)mouseDownCanMoveWindow { 3385 - (BOOL)mouseDownCanMoveWindow {
3370 return YES; 3386 return YES;
3371 } 3387 }
3372 3388
3373 @end 3389 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698