| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ui/views/controls/native/native_view_host_aura.h" | 5 #include "ui/views/controls/native/native_view_host_aura.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
| 10 #include "ui/aura/window.h" | 10 #include "ui/aura/window.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 struct EventDetails { | 32 struct EventDetails { |
| 33 EventType type; | 33 EventType type; |
| 34 aura::Window* window; | 34 aura::Window* window; |
| 35 gfx::Rect bounds; | 35 gfx::Rect bounds; |
| 36 bool operator!=(const EventDetails& rhs) { | 36 bool operator!=(const EventDetails& rhs) { |
| 37 return type != rhs.type || window != rhs.window || bounds != rhs.bounds; | 37 return type != rhs.type || window != rhs.window || bounds != rhs.bounds; |
| 38 } | 38 } |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 NativeViewHostWindowObserver() {} | 41 NativeViewHostWindowObserver() {} |
| 42 virtual ~NativeViewHostWindowObserver() {} | 42 ~NativeViewHostWindowObserver() override {} |
| 43 | 43 |
| 44 const std::vector<EventDetails>& events() const { return events_; } | 44 const std::vector<EventDetails>& events() const { return events_; } |
| 45 | 45 |
| 46 // aura::WindowObserver overrides | 46 // aura::WindowObserver overrides |
| 47 virtual void OnWindowVisibilityChanged(aura::Window* window, | 47 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override { |
| 48 bool visible) override { | |
| 49 EventDetails event; | 48 EventDetails event; |
| 50 event.type = visible ? EVENT_SHOWN : EVENT_HIDDEN; | 49 event.type = visible ? EVENT_SHOWN : EVENT_HIDDEN; |
| 51 event.window = window; | 50 event.window = window; |
| 52 event.bounds = window->GetBoundsInRootWindow(); | 51 event.bounds = window->GetBoundsInRootWindow(); |
| 53 | 52 |
| 54 // Dedupe events as a single Hide() call can result in several | 53 // Dedupe events as a single Hide() call can result in several |
| 55 // notifications. | 54 // notifications. |
| 56 if (events_.size() == 0u || events_.back() != event) | 55 if (events_.size() == 0u || events_.back() != event) |
| 57 events_.push_back(event); | 56 events_.push_back(event); |
| 58 } | 57 } |
| 59 | 58 |
| 60 virtual void OnWindowBoundsChanged(aura::Window* window, | 59 void OnWindowBoundsChanged(aura::Window* window, |
| 61 const gfx::Rect& old_bounds, | 60 const gfx::Rect& old_bounds, |
| 62 const gfx::Rect& new_bounds) override { | 61 const gfx::Rect& new_bounds) override { |
| 63 EventDetails event; | 62 EventDetails event; |
| 64 event.type = EVENT_BOUNDS_CHANGED; | 63 event.type = EVENT_BOUNDS_CHANGED; |
| 65 event.window = window; | 64 event.window = window; |
| 66 event.bounds = window->GetBoundsInRootWindow(); | 65 event.bounds = window->GetBoundsInRootWindow(); |
| 67 events_.push_back(event); | 66 events_.push_back(event); |
| 68 } | 67 } |
| 69 | 68 |
| 70 private: | 69 private: |
| 71 std::vector<EventDetails> events_; | 70 std::vector<EventDetails> events_; |
| 72 gfx::Rect bounds_at_visibility_changed_; | 71 gfx::Rect bounds_at_visibility_changed_; |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 339 |
| 341 host()->SetVisible(false); | 340 host()->SetVisible(false); |
| 342 EXPECT_FALSE(clipping_window()->IsVisible()); | 341 EXPECT_FALSE(clipping_window()->IsVisible()); |
| 343 EXPECT_FALSE(child()->IsVisible()); | 342 EXPECT_FALSE(child()->IsVisible()); |
| 344 | 343 |
| 345 DestroyHost(); | 344 DestroyHost(); |
| 346 DestroyTopLevel(); | 345 DestroyTopLevel(); |
| 347 } | 346 } |
| 348 | 347 |
| 349 } // namespace views | 348 } // namespace views |
| OLD | NEW |