Skip to content

Commit

Permalink
Snap non toplevel dialog windows to pixel boundary.
Browse files Browse the repository at this point in the history
BUG=731309
TEST=manual. Start chrome with --force-device-scale-factor=1.6 and make sure javascript dialog is crisp.

Review-Url: https://codereview.chromium.org/2934883003
Cr-Commit-Position: refs/heads/master@{#485032}
  • Loading branch information
mitoshima authored and Commit Bot committed Jul 7, 2017
1 parent 0b54ae5 commit 4d31231
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions components/constrained_window/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ static_library("constrained_window") {
if (use_aura) {
deps += [
"//ui/aura",
"//ui/compositor",
"//ui/wm",
]
}
Expand Down
1 change: 1 addition & 0 deletions components/constrained_window/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ include_rules = [
"+content/public/browser",
"+ui/aura",
"+ui/base",
"+ui/compositor",
"+ui/display",
"+ui/gfx",
"+ui/views",
Expand Down
18 changes: 18 additions & 0 deletions components/constrained_window/constrained_window_views.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
#import "components/constrained_window/native_web_contents_modal_dialog_manager_views_mac.h"
#endif

#if defined(USE_AURA)
#include "ui/aura/window.h"
#include "ui/compositor/dip_util.h"
#endif

using web_modal::ModalDialogHost;
using web_modal::ModalDialogHostObserver;

Expand Down Expand Up @@ -126,6 +131,19 @@ void UpdateModalDialogPosition(views::Widget* widget,
}

widget->SetBounds(gfx::Rect(position, size));

#if defined(USE_AURA)
if (!widget->is_top_level()) {
// Toplevel windows are automatiacally snapped, but CHILD windows
// may not. If it's not toplevel, snap the widget's layer to pixel
// based on the parent toplevel window, which should be snapped.
gfx::NativeView window = widget->GetNativeView();
views::Widget* toplevel =
views::Widget::GetTopLevelWidgetForNativeView(window->parent());
ui::SnapLayerToPhysicalPixelBoundary(toplevel->GetLayer(),
widget->GetLayer());
}
#endif
}

} // namespace
Expand Down

0 comments on commit 4d31231

Please sign in to comment.