OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 #include "ui/aura/window.h" | 55 #include "ui/aura/window.h" |
56 #include "ui/aura/window_event_dispatcher.h" | 56 #include "ui/aura/window_event_dispatcher.h" |
57 #include "ui/aura/window_observer.h" | 57 #include "ui/aura/window_observer.h" |
58 #include "ui/aura/window_tracker.h" | 58 #include "ui/aura/window_tracker.h" |
59 #include "ui/aura/window_tree_host.h" | 59 #include "ui/aura/window_tree_host.h" |
60 #include "ui/base/clipboard/scoped_clipboard_writer.h" | 60 #include "ui/base/clipboard/scoped_clipboard_writer.h" |
61 #include "ui/base/hit_test.h" | 61 #include "ui/base/hit_test.h" |
62 #include "ui/base/ime/input_method.h" | 62 #include "ui/base/ime/input_method.h" |
63 #include "ui/base/ui_base_types.h" | 63 #include "ui/base/ui_base_types.h" |
64 #include "ui/compositor/compositor_vsync_manager.h" | 64 #include "ui/compositor/compositor_vsync_manager.h" |
| 65 #include "ui/compositor/dip_util.h" |
65 #include "ui/events/event.h" | 66 #include "ui/events/event.h" |
66 #include "ui/events/event_utils.h" | 67 #include "ui/events/event_utils.h" |
67 #include "ui/events/gestures/gesture_recognizer.h" | 68 #include "ui/events/gestures/gesture_recognizer.h" |
68 #include "ui/gfx/canvas.h" | 69 #include "ui/gfx/canvas.h" |
69 #include "ui/gfx/display.h" | 70 #include "ui/gfx/display.h" |
70 #include "ui/gfx/rect_conversions.h" | 71 #include "ui/gfx/rect_conversions.h" |
71 #include "ui/gfx/screen.h" | 72 #include "ui/gfx/screen.h" |
72 #include "ui/gfx/size_conversions.h" | 73 #include "ui/gfx/size_conversions.h" |
73 #include "ui/gfx/skia_util.h" | 74 #include "ui/gfx/skia_util.h" |
74 #include "ui/wm/public/activation_client.h" | 75 #include "ui/wm/public/activation_client.h" |
(...skipping 1536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 float device_scale_factor) { | 1612 float device_scale_factor) { |
1612 if (!host_) | 1613 if (!host_) |
1613 return; | 1614 return; |
1614 | 1615 |
1615 UpdateScreenInfo(window_); | 1616 UpdateScreenInfo(window_); |
1616 | 1617 |
1617 const gfx::Display display = gfx::Screen::GetScreenFor(window_)-> | 1618 const gfx::Display display = gfx::Screen::GetScreenFor(window_)-> |
1618 GetDisplayNearestWindow(window_); | 1619 GetDisplayNearestWindow(window_); |
1619 DCHECK_EQ(device_scale_factor, display.device_scale_factor()); | 1620 DCHECK_EQ(device_scale_factor, display.device_scale_factor()); |
1620 current_cursor_.SetDisplayInfo(display); | 1621 current_cursor_.SetDisplayInfo(display); |
| 1622 SnapToPhysicalPixelBoundary(); |
1621 } | 1623 } |
1622 | 1624 |
1623 void RenderWidgetHostViewAura::OnWindowDestroying(aura::Window* window) { | 1625 void RenderWidgetHostViewAura::OnWindowDestroying(aura::Window* window) { |
1624 #if defined(OS_WIN) | 1626 #if defined(OS_WIN) |
1625 HWND parent = NULL; | 1627 HWND parent = NULL; |
1626 // If the tab was hidden and it's closed, host_->is_hidden would have been | 1628 // If the tab was hidden and it's closed, host_->is_hidden would have been |
1627 // reset to false in RenderWidgetHostImpl::RendererExited. | 1629 // reset to false in RenderWidgetHostImpl::RendererExited. |
1628 if (!window_->GetRootWindow() || host_->is_hidden()) { | 1630 if (!window_->GetRootWindow() || host_->is_hidden()) { |
1629 parent = ui::GetHiddenWindow(); | 1631 parent = ui::GetHiddenWindow(); |
1630 } else { | 1632 } else { |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2244 else if (!overscroll_controller_) | 2246 else if (!overscroll_controller_) |
2245 overscroll_controller_.reset(new OverscrollController()); | 2247 overscroll_controller_.reset(new OverscrollController()); |
2246 } | 2248 } |
2247 | 2249 |
2248 void RenderWidgetHostViewAura::SnapToPhysicalPixelBoundary() { | 2250 void RenderWidgetHostViewAura::SnapToPhysicalPixelBoundary() { |
2249 // The top left corner of our view in window coordinates might not land on a | 2251 // The top left corner of our view in window coordinates might not land on a |
2250 // device pixel boundary if we have a non-integer device scale. In that case, | 2252 // device pixel boundary if we have a non-integer device scale. In that case, |
2251 // to avoid the web contents area looking blurry we translate the web contents | 2253 // to avoid the web contents area looking blurry we translate the web contents |
2252 // in the +x, +y direction to land on the nearest pixel boundary. This may | 2254 // in the +x, +y direction to land on the nearest pixel boundary. This may |
2253 // cause the bottom and right edges to be clipped slightly, but that's ok. | 2255 // cause the bottom and right edges to be clipped slightly, but that's ok. |
2254 gfx::Point view_offset_dips = window_->GetBoundsInRootWindow().origin(); | 2256 aura::Window* snapped = NULL; |
2255 gfx::PointF view_offset = view_offset_dips; | 2257 // On desktop, use the root window. On alternative environment (ash), |
2256 view_offset.Scale(current_device_scale_factor_); | 2258 // use the toplevel window which must be already snapped. |
2257 gfx::PointF view_offset_snapped(std::ceil(view_offset.x()), | 2259 if (gfx::Screen::GetScreenFor(window_) != |
2258 std::ceil(view_offset.y())); | 2260 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE)) { |
2259 | 2261 snapped = window_->GetRootWindow(); |
2260 gfx::Vector2dF fudge = view_offset_snapped - view_offset; | 2262 } else { |
2261 fudge.Scale(1.0 / current_device_scale_factor_); | 2263 snapped = window_->GetToplevelWindow(); |
2262 GetLayer()->SetSubpixelPositionOffset(fudge); | 2264 } |
| 2265 if (snapped && snapped != window_) |
| 2266 ui::SnapLayerToPhysicalPixelBoundary(snapped->layer(), window_->layer()); |
2263 } | 2267 } |
2264 | 2268 |
2265 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { | 2269 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { |
2266 if (HasDisplayPropertyChanged(window_)) | 2270 if (HasDisplayPropertyChanged(window_)) |
2267 host_->InvalidateScreenInfo(); | 2271 host_->InvalidateScreenInfo(); |
2268 | 2272 |
2269 SnapToPhysicalPixelBoundary(); | 2273 SnapToPhysicalPixelBoundary(); |
2270 // Don't recursively call SetBounds if this bounds update is the result of | 2274 // Don't recursively call SetBounds if this bounds update is the result of |
2271 // a Window::SetBoundsInternal call. | 2275 // a Window::SetBoundsInternal call. |
2272 if (!in_bounds_changed_) | 2276 if (!in_bounds_changed_) |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2480 | 2484 |
2481 //////////////////////////////////////////////////////////////////////////////// | 2485 //////////////////////////////////////////////////////////////////////////////// |
2482 // RenderWidgetHostViewBase, public: | 2486 // RenderWidgetHostViewBase, public: |
2483 | 2487 |
2484 // static | 2488 // static |
2485 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2489 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2486 GetScreenInfoForWindow(results, NULL); | 2490 GetScreenInfoForWindow(results, NULL); |
2487 } | 2491 } |
2488 | 2492 |
2489 } // namespace content | 2493 } // namespace content |
OLD | NEW |