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

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

Issue 6024008: Consider the popup window position when the window shows upward. This patch depends on WebKit patch. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Use SetBounds(). Created 9 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <QuartzCore/QuartzCore.h> 5 #include <QuartzCore/QuartzCore.h>
6 6
7 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" 7 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
8 8
9 #include "app/app_switches.h" 9 #include "app/app_switches.h"
10 #include "app/surface/io_surface_support_mac.h" 10 #include "app/surface/io_surface_support_mac.h"
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 // ignore them so we don't re-allocate the backing store. We will paint 659 // ignore them so we don't re-allocate the backing store. We will paint
660 // everything again when we become selected again. 660 // everything again when we become selected again.
661 is_hidden_ = true; 661 is_hidden_ = true;
662 662
663 // If we have a renderer, then inform it that we are being hidden so it can 663 // If we have a renderer, then inform it that we are being hidden so it can
664 // reduce its resource utilization. 664 // reduce its resource utilization.
665 render_widget_host_->WasHidden(); 665 render_widget_host_->WasHidden();
666 } 666 }
667 667
668 void RenderWidgetHostViewMac::SetSize(const gfx::Size& size) { 668 void RenderWidgetHostViewMac::SetSize(const gfx::Size& size) {
669 gfx::Rect rect = GetViewBounds();
670 rect.set_size(size);
671 SetBounds(rect);
672 }
673
674 void RenderWidgetHostViewMac::SetBounds(const gfx::Rect& rect) {
669 if (is_hidden_) 675 if (is_hidden_)
670 return; 676 return;
671 677
672 // During the initial creation of the RenderWidgetHostView in 678 // During the initial creation of the RenderWidgetHostView in
673 // TabContents::CreateRenderViewForRenderManager, SetSize is called with an 679 // TabContents::CreateRenderViewForRenderManager, SetSize is called with an
674 // empty size. In the Windows code flow, it is not ignored because subsequent 680 // empty size. In the Windows code flow, it is not ignored because subsequent
675 // sizing calls from the OS flow through TCVW::WasSized which calls SetSize() 681 // sizing calls from the OS flow through TCVW::WasSized which calls SetSize()
676 // again. On Cocoa, we rely on the Cocoa view struture and resizer flags to 682 // again. On Cocoa, we rely on the Cocoa view struture and resizer flags to
677 // keep things sized properly. On the other hand, if the size is not empty 683 // keep things sized properly. On the other hand, if the size is not empty
678 // then this is a valid request for a pop-up. 684 // then this is a valid request for a pop-up.
679 if (size.IsEmpty()) 685 if (rect.size().IsEmpty())
680 return; 686 return;
681 687
682 // Do conversions to upper-left origin, as "set size" means keep the 688 // The position of |rect| is screen coordnate system and we have to consider
683 // upper-left corner pinned. If the new size is valid, this is a popup whose 689 // Cocoa coordinate system is upside-down and also muti screen.
684 // superview is another RenderWidgetHostViewCocoa, but even if it's directly 690 NSPoint global_origin = NSPointFromCGPoint(rect.origin().ToCGPoint());
685 // in a TabContentsViewCocoa, they're both BaseViews. 691 if ([[NSScreen screens] count] > 0) {
686 DCHECK([[cocoa_view_ superview] isKindOfClass:[BaseView class]]); 692 NSRect bounds = NSMakeRect(0, 0, rect.width(), rect.height());
687 gfx::Rect rect = 693 bounds = [cocoa_view_ convertRect:bounds toView:nil];
Nico 2011/02/16 18:18:45 is convertSize:toView: enough?
688 [(BaseView*)[cocoa_view_ superview] flipNSRectToRect:[cocoa_view_ frame]]; 694 global_origin.y = [[[NSScreen screens] objectAtIndex:0] frame].size.height -
689 rect.set_width(size.width()); 695 bounds.size.height - global_origin.y;
Nico 2011/02/16 18:20:03 global_origin and the screen's frame are in screen
honten.org 2011/02/16 18:45:37 Here, my intention is |rect| is actually in view c
Nico 2011/02/16 21:16:01 Chances are I misunderstand something. …ah! So Ge
honten.org 2011/02/16 21:18:57 Sure, I'll file it and fix the nits. On 2011/02/1
honten.org 2011/02/18 09:11:26 Done.
690 rect.set_height(size.height()); 696 }
691 [cocoa_view_ setFrame: 697
692 [(BaseView*)[cocoa_view_ superview] flipRectToNSRect:rect]]; 698 // Then |global_origin| is converted to client coordinate system.
699 NSPoint window_origin =
700 [[cocoa_view_ window] convertScreenToBase:global_origin];
701 NSRect frame = NSMakeRect(window_origin.x, window_origin.y,
702 rect.width(), rect.height());
703 [cocoa_view_ setFrame:frame];
693 } 704 }
694 705
695 gfx::NativeView RenderWidgetHostViewMac::GetNativeView() { 706 gfx::NativeView RenderWidgetHostViewMac::GetNativeView() {
696 return native_view(); 707 return native_view();
697 } 708 }
698 709
699 void RenderWidgetHostViewMac::MovePluginWindows( 710 void RenderWidgetHostViewMac::MovePluginWindows(
700 const std::vector<webkit::npapi::WebPluginGeometry>& moves) { 711 const std::vector<webkit::npapi::WebPluginGeometry>& moves) {
701 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 712 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
702 // Handle movement of accelerated plugins, which are the only "windowed" 713 // Handle movement of accelerated plugins, which are the only "windowed"
(...skipping 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2827 if (!string) return NO; 2838 if (!string) return NO;
2828 2839
2829 // If the user is currently using an IME, confirm the IME input, 2840 // If the user is currently using an IME, confirm the IME input,
2830 // and then insert the text from the service, the same as TextEdit and Safari. 2841 // and then insert the text from the service, the same as TextEdit and Safari.
2831 [self confirmComposition]; 2842 [self confirmComposition];
2832 [self insertText:string]; 2843 [self insertText:string];
2833 return YES; 2844 return YES;
2834 } 2845 }
2835 2846
2836 @end 2847 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698