Chromium Code Reviews| Index: chrome/browser/ui/views/validation_message_bubble_view.cc |
| diff --git a/chrome/browser/ui/views/validation_message_bubble_view.cc b/chrome/browser/ui/views/validation_message_bubble_view.cc |
| index 3f4f361551433131d20b067eea6405dc1191d16d..b64f59495f097a928bc78467fc6ba9cd44ce175e 100644 |
| --- a/chrome/browser/ui/views/validation_message_bubble_view.cc |
| +++ b/chrome/browser/ui/views/validation_message_bubble_view.cc |
| @@ -6,7 +6,6 @@ |
| #include "chrome/grit/theme_resources.h" |
| #include "content/public/browser/render_widget_host.h" |
| -#include "content/public/browser/render_widget_host_view.h" |
| #include "content/public/browser/web_contents.h" |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/views/controls/image_view.h" |
| @@ -27,14 +26,14 @@ ValidationMessageBubbleView::ValidationMessageBubbleView( |
| const gfx::Rect& anchor_in_root_view, |
| const base::string16& main_text, |
| const base::string16& sub_text) { |
| - content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView(); |
| - set_parent_window(rwhv->GetNativeView()); |
| + content::RenderWidgetHostView* render_widget_host_view = |
| + web_contents->GetRenderWidgetHostView(); |
| + set_parent_window(render_widget_host_view->GetNativeView()); |
| set_can_activate(false); |
| set_arrow(views::BubbleBorder::TOP_LEFT); |
| - const gfx::Rect anchor_in_screen = |
| - anchor_in_root_view + rwhv->GetViewBounds().origin().OffsetFromOrigin(); |
| - SetAnchorRect(anchor_in_screen); |
| + SetAnchorRect( |
| + RootViewToScreenRect(anchor_in_root_view, render_widget_host_view)); |
| ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| views::ImageView* icon = new views::ImageView(); |
| @@ -82,6 +81,14 @@ ValidationMessageBubbleView::ValidationMessageBubbleView( |
| ValidationMessageBubbleView::~ValidationMessageBubbleView() { |
| } |
| +gfx::Rect ValidationMessageBubbleView::RootViewToScreenRect( |
| + const gfx::Rect& rect_in_root_view, |
| + const content::RenderWidgetHostView* render_widget_host_view) const { |
| + const float scale = render_widget_host_view->GetDeviceScaleFactor(); |
|
sadrul
2016/11/14 16:58:03
Note that if you really need this, you can also ge
|
| + return gfx::ScaleToEnclosingRect(rect_in_root_view, 1 / scale) + |
| + render_widget_host_view->GetViewBounds().origin().OffsetFromOrigin(); |
| +} |
| + |
| gfx::Size ValidationMessageBubbleView::GetPreferredSize() const { |
| return size_; |
| } |
| @@ -93,8 +100,8 @@ int ValidationMessageBubbleView::GetDialogButtons() const { |
| void ValidationMessageBubbleView::SetPositionRelativeToAnchor( |
| content::RenderWidgetHost* widget_host, |
| const gfx::Rect& anchor_in_root_view) { |
| - SetAnchorRect(anchor_in_root_view + |
| - widget_host->GetView()->GetViewBounds().origin().OffsetFromOrigin()); |
| + SetAnchorRect( |
| + RootViewToScreenRect(anchor_in_root_view, widget_host->GetView())); |
| } |
| void ValidationMessageBubbleView::CloseValidationMessage() { |