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

Unified Diff: chrome/browser/ui/views/validation_message_bubble_view.cc

Issue 2491113002: Fix form validation bubble positioning at hidpi. (Closed)
Patch Set: override and comment in rwhv_base Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
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..2fd52ba48f6d7dcee36b580732a6ee14d2b8d50c 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"
@@ -32,9 +31,7 @@ ValidationMessageBubbleView::ValidationMessageBubbleView(
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, rwhv));
ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance();
views::ImageView* icon = new views::ImageView();
@@ -82,6 +79,14 @@ ValidationMessageBubbleView::ValidationMessageBubbleView(
ValidationMessageBubbleView::~ValidationMessageBubbleView() {
}
+gfx::Rect ValidationMessageBubbleView::RootViewToScreenRect(
+ const gfx::Rect& rect_in_root_view,
+ const content::RenderWidgetHostView* rwhv) const {
+ const float scale = rwhv->GetDeviceScaleFactor();
+ return gfx::ScaleToEnclosingRect(rect_in_root_view, 1 / scale) +
msw 2016/11/10 18:59:14 Is there any chance this is zero? Consider adding
Bret 2016/11/11 23:51:27 I don't think we could reach this method if scale
+ rwhv->GetViewBounds().origin().OffsetFromOrigin();
sadrul 2016/11/10 20:44:41 Can you use aura::client::ScreenPositionClient ins
Bret 2016/11/11 23:51:27 I can't get access to aura-specific methods on Ren
sadrul 2016/11/12 02:30:44 You have the RenderWidgetHostView here. You can ge
Bret 2016/11/12 22:04:36 Okay that plumbing does work. But as far as I can
+}
+
gfx::Size ValidationMessageBubbleView::GetPreferredSize() const {
return size_;
}
@@ -93,8 +98,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() {

Powered by Google App Engine
This is Rietveld 408576698