 Chromium Code Reviews
 Chromium Code Reviews Issue 16583005:
  Some improvement of validation message bubble UI.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 16583005:
  Some improvement of validation message bubble UI.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| Index: chrome/browser/ui/cocoa/validation_message_bubble_cocoa.mm | 
| diff --git a/chrome/browser/ui/cocoa/validation_message_bubble_cocoa.mm b/chrome/browser/ui/cocoa/validation_message_bubble_cocoa.mm | 
| index db4818562f83b006bb3c1b6aa6c7cf9525053458..274f7a7e260ecf99c38d7ee461d076c10f20f986 100644 | 
| --- a/chrome/browser/ui/cocoa/validation_message_bubble_cocoa.mm | 
| +++ b/chrome/browser/ui/cocoa/validation_message_bubble_cocoa.mm | 
| @@ -134,20 +134,26 @@ anchoredAt:(NSPoint)anchorPoint | 
| namespace { | 
| +NSPoint GetAnchorPoint(content::RenderWidgetHost* widget_host, | 
| 
Nico
2013/06/07 16:35:31
Can you add a comment above this function, explain
 
tkent
2013/06/10 06:15:37
Done.
 | 
| + const gfx::Rect& anchor_in_root_view) { | 
| + content::RenderWidgetHostView* view = widget_host->GetView(); | 
| + gfx::Rect anchor_in_screen = anchor_in_root_view | 
| + + view->GetViewBounds().origin().OffsetFromOrigin(); | 
| + NSWindow* parent_window = [view->GetNativeView() window]; | 
| + return NSMakePoint(anchor_in_screen.x() + anchor_in_screen.width() / 2, | 
| + NSHeight([[parent_window screen] frame]) | 
| + - (anchor_in_screen.y() + anchor_in_screen.height())); | 
| 
Nico
2013/06/07 16:35:31
If this function does what I think it does, the mo
 
tkent
2013/06/10 06:15:37
Done.
 | 
| +} | 
| + | 
| class ValidationMessageBubbleCocoa : public chrome::ValidationMessageBubble { | 
| public: | 
| ValidationMessageBubbleCocoa(content::RenderWidgetHost* widget_host, | 
| - const gfx::Rect& anchor_in_screen, | 
| + const gfx::Rect& anchor_in_root_view, | 
| const string16& main_text, | 
| const string16& sub_text) { | 
| - NSWindow* parent_window = [widget_host->GetView()->GetNativeView() window]; | 
| - NSPoint anchor_point = NSMakePoint( | 
| - anchor_in_screen.x() + anchor_in_screen.width() / 2, | 
| - NSHeight([[parent_window screen] frame]) | 
| - - (anchor_in_screen.y() + anchor_in_screen.height())); | 
| controller_.reset([[[ValidationMessageBubbleController alloc] | 
| - init:parent_window | 
| - anchoredAt:anchor_point | 
| + init:[widget_host->GetView()->GetNativeView() window] | 
| + anchoredAt:GetAnchorPoint(widget_host, anchor_in_root_view) | 
| mainText:main_text | 
| subText:sub_text] retain]); | 
| } | 
| @@ -156,6 +162,12 @@ class ValidationMessageBubbleCocoa : public chrome::ValidationMessageBubble { | 
| [controller_.get() close]; | 
| } | 
| + virtual void MoveOnAnchor(content::RenderWidgetHost* widget_host, | 
| 
Nico
2013/06/07 16:35:31
(same nit as in the android file here too, and in
 
tkent
2013/06/10 06:15:37
Done.
 | 
| + const gfx::Rect& anchor_in_root_view) OVERRIDE { | 
| + [controller_.get() | 
| + setAnchorPoint:GetAnchorPoint(widget_host, anchor_in_root_view)]; | 
| + } | 
| + | 
| private: | 
| scoped_nsobject<ValidationMessageBubbleController> controller_; | 
| }; | 
| @@ -168,11 +180,11 @@ namespace chrome { | 
| scoped_ptr<ValidationMessageBubble> ValidationMessageBubble::CreateAndShow( | 
| content::RenderWidgetHost* widget_host, | 
| - const gfx::Rect& anchor_in_screen, | 
| + const gfx::Rect& anchor_in_root_view, | 
| const string16& main_text, | 
| const string16& sub_text) { | 
| return scoped_ptr<ValidationMessageBubble>(new ValidationMessageBubbleCocoa( | 
| - widget_host, anchor_in_screen, main_text, sub_text)).Pass(); | 
| + widget_host, anchor_in_root_view, main_text, sub_text)).Pass(); | 
| } | 
| } |