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/web_contents/web_contents_view_aura.h" | 5 #include "content/browser/web_contents/web_contents_view_aura.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 UpdateConstrainedWindows(NULL); | 540 UpdateConstrainedWindows(NULL); |
541 } | 541 } |
542 } | 542 } |
543 #endif | 543 #endif |
544 | 544 |
545 virtual void OnWindowParentChanged(aura::Window* window, | 545 virtual void OnWindowParentChanged(aura::Window* window, |
546 aura::Window* parent) OVERRIDE { | 546 aura::Window* parent) OVERRIDE { |
547 if (window != view_->window_) | 547 if (window != view_->window_) |
548 return; | 548 return; |
549 | 549 |
| 550 // Use the new parent's root window for calculating HiDPI subpixel offset. |
| 551 RenderWidgetHostViewAura* rwhv = ToRenderWidgetHostViewAura( |
| 552 view_->web_contents_->GetRenderWidgetHostView()); |
| 553 if (rwhv) |
| 554 rwhv->SnapToPhysicalPixelBoundary(); |
| 555 |
550 aura::Window* host_window = | 556 aura::Window* host_window = |
551 window->GetProperty(aura::client::kHostWindowKey); | 557 window->GetProperty(aura::client::kHostWindowKey); |
552 if (!host_window) | 558 if (!host_window) |
553 host_window = parent; | 559 host_window = parent; |
554 | 560 |
555 if (host_window_) | 561 if (host_window_) |
556 host_window_->RemoveObserver(this); | 562 host_window_->RemoveObserver(this); |
557 | 563 |
558 #if defined(OS_WIN) | 564 #if defined(OS_WIN) |
559 if (host_window_) { | 565 if (host_window_) { |
560 const aura::Window::Windows& children = host_window_->children(); | 566 const aura::Window::Windows& children = host_window_->children(); |
561 for (size_t i = 0; i < children.size(); ++i) | 567 for (size_t i = 0; i < children.size(); ++i) |
562 children[i]->RemoveObserver(this); | 568 children[i]->RemoveObserver(this); |
563 | 569 |
564 RenderWidgetHostViewAura* view = ToRenderWidgetHostViewAura( | 570 if (rwhv) |
565 view_->web_contents_->GetRenderWidgetHostView()); | 571 rwhv->UpdateConstrainedWindowRects(std::vector<gfx::Rect>()); |
566 if (view) | |
567 view->UpdateConstrainedWindowRects(std::vector<gfx::Rect>()); | |
568 } | 572 } |
569 | 573 |
570 // When we get parented to the root window, the code below will watch the | 574 // When we get parented to the root window, the code below will watch the |
571 // host window, aka root window. Since we already watch the root window on | 575 // host window, aka root window. Since we already watch the root window on |
572 // Windows, unregister first so that the debug check doesn't fire. | 576 // Windows, unregister first so that the debug check doesn't fire. |
573 if (host_window && host_window == window->GetRootWindow()) | 577 if (host_window && host_window == window->GetRootWindow()) |
574 host_window->RemoveObserver(this); | 578 host_window->RemoveObserver(this); |
575 | 579 |
576 // We need to undo the above if we were parented to the root window and then | 580 // We need to undo the above if we were parented to the root window and then |
577 // got parented to another window. At that point, the code before the ifdef | 581 // got parented to another window. At that point, the code before the ifdef |
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1600 if (visible) { | 1604 if (visible) { |
1601 if (!web_contents_->should_normally_be_visible()) | 1605 if (!web_contents_->should_normally_be_visible()) |
1602 web_contents_->WasShown(); | 1606 web_contents_->WasShown(); |
1603 } else { | 1607 } else { |
1604 if (web_contents_->should_normally_be_visible()) | 1608 if (web_contents_->should_normally_be_visible()) |
1605 web_contents_->WasHidden(); | 1609 web_contents_->WasHidden(); |
1606 } | 1610 } |
1607 } | 1611 } |
1608 | 1612 |
1609 } // namespace content | 1613 } // namespace content |
OLD | NEW |