OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/views/constrained_window_impl.h" | 5 #include "chrome/browser/views/constrained_window_impl.h" |
6 | 6 |
7 #include "base/gfx/rect.h" | 7 #include "base/gfx/rect.h" |
8 #include "chrome/app/chrome_dll_resource.h" | 8 #include "chrome/app/chrome_dll_resource.h" |
9 #include "chrome/app/theme/theme_resources.h" | 9 #include "chrome/app/theme/theme_resources.h" |
10 #include "chrome/browser/tab_contents.h" | 10 #include "chrome/browser/tab_contents.h" |
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1176 | 1176 |
1177 // We want to detach the constrained window at the same position on screen | 1177 // We want to detach the constrained window at the same position on screen |
1178 // as the constrained window, so we need to get its screen bounds. | 1178 // as the constrained window, so we need to get its screen bounds. |
1179 CRect constrained_window_bounds; | 1179 CRect constrained_window_bounds; |
1180 GetBounds(&constrained_window_bounds, true); | 1180 GetBounds(&constrained_window_bounds, true); |
1181 | 1181 |
1182 // Obtain the constrained TabContents' size from its HWND... | 1182 // Obtain the constrained TabContents' size from its HWND... |
1183 CRect bounds; | 1183 CRect bounds; |
1184 ::GetWindowRect(constrained_contents_->GetContainerHWND(), &bounds); | 1184 ::GetWindowRect(constrained_contents_->GetContainerHWND(), &bounds); |
1185 | 1185 |
1186 // ... but overwrite its screen position with the screen position of its | 1186 // This block of code was added by Ben, and is simply false in any world with |
1187 // containing ConstrainedWindowImpl. We do this because the code called by | 1187 // magic_browzr turned off. Eventually, the if block here should go away once |
1188 // |DetachContents| assumes the bounds contains position and size information | 1188 // we get rid of the old pre-magic_browzr window implementation, but for now |
1189 // similar to what is sent when a popup is not suppressed and must be opened, | 1189 // (and at least the next beta release), it's here to stay and magic_browzr |
1190 // i.e. the position is the screen position of the top left of the detached | 1190 // is off by default. |
1191 // popup window, and the size is the size of the content area. | 1191 if (g_browser_process->IsUsingNewFrames()) { |
1192 bounds.SetRect(constrained_window_bounds.left, constrained_window_bounds.top, | 1192 // ... but overwrite its screen position with the screen position of its |
1193 constrained_window_bounds.left + bounds.Width(), | 1193 // containing ConstrainedWindowImpl. We do this because the code called by |
1194 constrained_window_bounds.top + bounds.Height()); | 1194 // |DetachContents| assumes the bounds contains position and size |
| 1195 // information similar to what is sent when a popup is not suppressed and |
| 1196 // must be opened, i.e. the position is the screen position of the top left |
| 1197 // of the detached popup window, and the size is the size of the content |
| 1198 // area. |
| 1199 bounds.SetRect(constrained_window_bounds.left, |
| 1200 constrained_window_bounds.top, |
| 1201 constrained_window_bounds.left + bounds.Width(), |
| 1202 constrained_window_bounds.top + bounds.Height()); |
| 1203 } |
1195 | 1204 |
1196 // Save the cursor position so that we know where to send a mouse message | 1205 // Save the cursor position so that we know where to send a mouse message |
1197 // when the new detached window is created. | 1206 // when the new detached window is created. |
1198 CPoint cursor_pos; | 1207 CPoint cursor_pos; |
1199 ::GetCursorPos(&cursor_pos); | 1208 ::GetCursorPos(&cursor_pos); |
1200 gfx::Point screen_point(cursor_pos.x, cursor_pos.y); | 1209 gfx::Point screen_point(cursor_pos.x, cursor_pos.y); |
1201 | 1210 |
1202 // Determine what aspect of the constrained frame was clicked on, so that we | 1211 // Determine what aspect of the constrained frame was clicked on, so that we |
1203 // can continue the mouse move on this aspect of the detached frame. | 1212 // can continue the mouse move on this aspect of the detached frame. |
1204 int frame_component = static_cast<int>(OnNCHitTest(screen_point.ToPOINT())); | 1213 int frame_component = static_cast<int>(OnNCHitTest(screen_point.ToPOINT())); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 initial_bounds, | 1371 initial_bounds, |
1363 parent->delegate()->ShouldDisplayURLField()); | 1372 parent->delegate()->ShouldDisplayURLField()); |
1364 | 1373 |
1365 window->InitSizeForContents(window_bounds); | 1374 window->InitSizeForContents(window_bounds); |
1366 | 1375 |
1367 // This is a constrained popup window and thus we need to animate it in. | 1376 // This is a constrained popup window and thus we need to animate it in. |
1368 window->StartSuppressedAnimation(); | 1377 window->StartSuppressedAnimation(); |
1369 | 1378 |
1370 return window; | 1379 return window; |
1371 } | 1380 } |
OLD | NEW |