Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/platform_window/win/win_window.h" | 5 #include "ui/platform_window/win/win_window.h" |
| 6 | 6 |
| 7 #include "base/profiler/scoped_tracker.h" | 7 #include "base/profiler/scoped_tracker.h" |
| 8 #include "ui/events/event.h" | 8 #include "ui/events/event.h" |
| 9 #include "ui/events/event_utils.h" | 9 #include "ui/events/event_utils.h" |
| 10 #include "ui/gfx/win/msg_util.h" | 10 #include "ui/gfx/win/msg_util.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 wr.right - wr.left, wr.bottom - wr.top); | 31 wr.right - wr.left, wr.bottom - wr.top); |
| 32 window_bounds.set_x(std::max(0, window_bounds.x())); | 32 window_bounds.set_x(std::max(0, window_bounds.x())); |
| 33 window_bounds.set_y(std::max(0, window_bounds.y())); | 33 window_bounds.set_y(std::max(0, window_bounds.y())); |
| 34 return window_bounds; | 34 return window_bounds; |
| 35 } | 35 } |
| 36 | 36 |
| 37 } // namespace | 37 } // namespace |
| 38 | 38 |
| 39 WinWindow::WinWindow(PlatformWindowDelegate* delegate, | 39 WinWindow::WinWindow(PlatformWindowDelegate* delegate, |
| 40 const gfx::Rect& bounds) | 40 const gfx::Rect& bounds) |
| 41 : delegate_(delegate) { | 41 : delegate_(delegate), destroyed_(false) { |
| 42 CHECK(delegate_); | 42 CHECK(delegate_); |
| 43 if (use_popup_as_root_window_for_test) | 43 if (use_popup_as_root_window_for_test) |
| 44 set_window_style(WS_POPUP); | 44 set_window_style(WS_POPUP); |
| 45 gfx::Rect window_bounds = GetWindowBoundsForClientBounds( | 45 gfx::Rect window_bounds = GetWindowBoundsForClientBounds( |
| 46 WS_OVERLAPPEDWINDOW, window_ex_style(), bounds); | 46 WS_OVERLAPPEDWINDOW, window_ex_style(), bounds); |
| 47 gfx::WindowImpl::Init(NULL, window_bounds); | 47 gfx::WindowImpl::Init(NULL, window_bounds); |
| 48 SetWindowText(hwnd(), L"WinWindow"); | 48 SetWindowText(hwnd(), L"WinWindow"); |
| 49 } | 49 } |
| 50 | 50 |
| 51 WinWindow::~WinWindow() { | 51 WinWindow::~WinWindow() { |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 LRESULT WinWindow::OnCreate(CREATESTRUCT* create_struct) { | 170 LRESULT WinWindow::OnCreate(CREATESTRUCT* create_struct) { |
| 171 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. | 171 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. |
| 172 tracked_objects::ScopedTracker tracking_profile( | 172 tracked_objects::ScopedTracker tracking_profile( |
| 173 FROM_HERE_WITH_EXPLICIT_FUNCTION("440919 WinWindow::OnCreate")); | 173 FROM_HERE_WITH_EXPLICIT_FUNCTION("440919 WinWindow::OnCreate")); |
| 174 | 174 |
| 175 delegate_->OnAcceleratedWidgetAvailable(hwnd()); | 175 delegate_->OnAcceleratedWidgetAvailable(hwnd()); |
| 176 return 0; | 176 return 0; |
| 177 } | 177 } |
| 178 | 178 |
| 179 void WinWindow::OnDestroy() { | 179 void WinWindow::OnDestroy() { |
| 180 if (destroyed_) | |
|
Ben Goodger (Google)
2015/05/13 20:21:07
Instead we should make ~WinWindow not call Destroy
jam
2015/05/14 14:42:48
Done.
| |
| 181 return; | |
| 182 | |
| 183 destroyed_ = true; | |
| 184 | |
| 180 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. | 185 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. |
| 181 tracked_objects::ScopedTracker tracking_profile( | 186 tracked_objects::ScopedTracker tracking_profile( |
| 182 FROM_HERE_WITH_EXPLICIT_FUNCTION("440919 WinWindow::OnDestroy")); | 187 FROM_HERE_WITH_EXPLICIT_FUNCTION("440919 WinWindow::OnDestroy")); |
| 183 | 188 |
| 184 delegate_->OnClosed(); | 189 delegate_->OnClosed(); |
| 185 } | 190 } |
| 186 | 191 |
| 187 void WinWindow::OnPaint(HDC) { | 192 void WinWindow::OnPaint(HDC) { |
| 188 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. | 193 // TODO(vadimt): Remove ScopedTracker below once crbug.com/440919 is fixed. |
| 189 tracked_objects::ScopedTracker tracking_profile( | 194 tracked_objects::ScopedTracker tracking_profile( |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 214 | 219 |
| 215 namespace test { | 220 namespace test { |
| 216 | 221 |
| 217 // static | 222 // static |
| 218 void SetUsePopupAsRootWindowForTest(bool use) { | 223 void SetUsePopupAsRootWindowForTest(bool use) { |
| 219 use_popup_as_root_window_for_test = use; | 224 use_popup_as_root_window_for_test = use; |
| 220 } | 225 } |
| 221 | 226 |
| 222 } // namespace test | 227 } // namespace test |
| 223 } // namespace ui | 228 } // namespace ui |
| OLD | NEW |