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

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

Issue 1992006: Do right-alignment of popups when WebKit indicates to do so. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 7 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/surface/io_surface_support_mac.h" 9 #include "app/surface/io_surface_support_mac.h"
10 #import "base/chrome_application_mac.h" 10 #import "base/chrome_application_mac.h"
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 NOTIMPLEMENTED(); 457 NOTIMPLEMENTED();
458 return NULL; 458 return NULL;
459 } 459 }
460 460
461 // Display a popup menu for WebKit using Cocoa widgets. 461 // Display a popup menu for WebKit using Cocoa widgets.
462 void RenderWidgetHostViewMac::ShowPopupWithItems( 462 void RenderWidgetHostViewMac::ShowPopupWithItems(
463 gfx::Rect bounds, 463 gfx::Rect bounds,
464 int item_height, 464 int item_height,
465 double item_font_size, 465 double item_font_size,
466 int selected_item, 466 int selected_item,
467 const std::vector<WebMenuItem>& items) { 467 const std::vector<WebMenuItem>& items,
468 bool right_aligned) {
468 is_popup_menu_ = true; 469 is_popup_menu_ = true;
469 470
470 // Retain the Cocoa view for the duration of the pop-up so that it can't 471 // Retain the Cocoa view for the duration of the pop-up so that it can't
471 // be dealloced if my Destroy() method is called while the pop-up's up 472 // be dealloced if my Destroy() method is called while the pop-up's up
472 // (which would in turn delete me, causing a crash once the -runMenuInView 473 // (which would in turn delete me, causing a crash once the -runMenuInView
473 // call returns. That's what was happening in <http://crbug.com/33250>). 474 // call returns. That's what was happening in <http://crbug.com/33250>).
474 scoped_nsobject<RenderWidgetHostViewCocoa> retainedCocoaView 475 scoped_nsobject<RenderWidgetHostViewCocoa> retainedCocoaView
475 ([cocoa_view_ retain]); 476 ([cocoa_view_ retain]);
476 477
477 NSRect view_rect = [cocoa_view_ bounds]; 478 NSRect view_rect = [cocoa_view_ bounds];
478 NSRect parent_rect = [parent_view_ bounds]; 479 NSRect parent_rect = [parent_view_ bounds];
479 int y_offset = bounds.y() + bounds.height(); 480 int y_offset = bounds.y() + bounds.height();
480 NSRect position = NSMakeRect(bounds.x(), parent_rect.size.height - y_offset, 481 NSRect position = NSMakeRect(bounds.x(), parent_rect.size.height - y_offset,
481 bounds.width(), bounds.height()); 482 bounds.width(), bounds.height());
482 483
483 // Display the menu. 484 // Display the menu.
484 scoped_nsobject<WebMenuRunner> menu_runner; 485 scoped_nsobject<WebMenuRunner> menu_runner;
485 menu_runner.reset([[WebMenuRunner alloc] initWithItems:items 486 menu_runner.reset([[WebMenuRunner alloc] initWithItems:items
486 fontSize:item_font_size]); 487 fontSize:item_font_size
488 rightAligned:right_aligned]);
487 489
488 { 490 {
489 // Make sure events can be pumped while the menu is up. 491 // Make sure events can be pumped while the menu is up.
490 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); 492 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
491 493
492 // One of the events that could be pumped is |window.close()|. 494 // One of the events that could be pumped is |window.close()|.
493 // User-initiated event-tracking loops protect against this by 495 // User-initiated event-tracking loops protect against this by
494 // setting flags in -[CrApplication sendEvent:], but since 496 // setting flags in -[CrApplication sendEvent:], but since
495 // web-content menus are initiated by IPC message the setup has to 497 // web-content menus are initiated by IPC message the setup has to
496 // be done manually. 498 // be done manually.
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 } 1036 }
1035 1037
1036 - (void)drawRect:(NSRect)dirtyRect { 1038 - (void)drawRect:(NSRect)dirtyRect {
1037 if (!renderWidgetHostView_->render_widget_host_) { 1039 if (!renderWidgetHostView_->render_widget_host_) {
1038 // TODO(shess): Consider using something more noticable? 1040 // TODO(shess): Consider using something more noticable?
1039 [[NSColor whiteColor] set]; 1041 [[NSColor whiteColor] set];
1040 NSRectFill(dirtyRect); 1042 NSRectFill(dirtyRect);
1041 return; 1043 return;
1042 } 1044 }
1043 1045
1044 DCHECK(renderWidgetHostView_->render_widget_host_->process()->HasConnection()) ; 1046 DCHECK(
1047 renderWidgetHostView_->render_widget_host_->process()->HasConnection());
1045 DCHECK(!renderWidgetHostView_->about_to_validate_and_paint_); 1048 DCHECK(!renderWidgetHostView_->about_to_validate_and_paint_);
1046 1049
1047 renderWidgetHostView_->about_to_validate_and_paint_ = true; 1050 renderWidgetHostView_->about_to_validate_and_paint_ = true;
1048 BackingStoreMac* backing_store = static_cast<BackingStoreMac*>( 1051 BackingStoreMac* backing_store = static_cast<BackingStoreMac*>(
1049 renderWidgetHostView_->render_widget_host_->GetBackingStore(true)); 1052 renderWidgetHostView_->render_widget_host_->GetBackingStore(true));
1050 renderWidgetHostView_->about_to_validate_and_paint_ = false; 1053 renderWidgetHostView_->about_to_validate_and_paint_ = false;
1051 1054
1052 if (backing_store) { 1055 if (backing_store) {
1053 NSRect view_bounds = [self bounds]; 1056 NSRect view_bounds = [self bounds];
1054 gfx::Rect damaged_rect([self NSRectToRect:dirtyRect]); 1057 gfx::Rect damaged_rect([self NSRectToRect:dirtyRect]);
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
1815 // doesn't call any NSTextInput functions, such as setMarkedText or 1818 // doesn't call any NSTextInput functions, such as setMarkedText or
1816 // insertText. So, we need to send an IPC message to a renderer so it can 1819 // insertText. So, we need to send an IPC message to a renderer so it can
1817 // delete the composition node. 1820 // delete the composition node.
1818 NSInputManager *currentInputManager = [NSInputManager currentInputManager]; 1821 NSInputManager *currentInputManager = [NSInputManager currentInputManager];
1819 [currentInputManager markedTextAbandoned:self]; 1822 [currentInputManager markedTextAbandoned:self];
1820 1823
1821 [self unmarkText]; 1824 [self unmarkText];
1822 } 1825 }
1823 1826
1824 @end 1827 @end
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host_view_mac.h ('k') | chrome/browser/renderer_host/test/test_render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698