diff options
-rw-r--r-- | chrome/browser/find_in_page_controller.cc | 3 | ||||
-rw-r--r-- | chrome/browser/native_ui_contents.cc | 2 | ||||
-rw-r--r-- | chrome/browser/network_status_view.cc | 3 | ||||
-rw-r--r-- | chrome/browser/tabs/dragged_tab_view.cc | 3 | ||||
-rw-r--r-- | chrome/browser/tabs/hwnd_photobooth.cc | 2 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip.cc | 2 | ||||
-rw-r--r-- | chrome/browser/views/download_started_animation.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/info_bubble.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/status_bubble.cc | 4 | ||||
-rw-r--r-- | chrome/browser/web_contents.cc | 2 | ||||
-rw-r--r-- | chrome/views/chrome_menu.cc | 3 | ||||
-rw-r--r-- | chrome/views/focus_manager_unittest.cc | 3 | ||||
-rw-r--r-- | chrome/views/hwnd_view_container.cc | 30 | ||||
-rw-r--r-- | chrome/views/hwnd_view_container.h | 7 | ||||
-rw-r--r-- | chrome/views/tabbed_pane.cc | 2 | ||||
-rw-r--r-- | chrome/views/view_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/views/window.cc | 10 |
17 files changed, 49 insertions, 37 deletions
diff --git a/chrome/browser/find_in_page_controller.cc b/chrome/browser/find_in_page_controller.cc index 1129dc1..aa73a18 100644 --- a/chrome/browser/find_in_page_controller.cc +++ b/chrome/browser/find_in_page_controller.cc @@ -85,7 +85,8 @@ FindInPageController::FindInPageController(TabContents* parent_tab, gfx::Rect find_dlg_rect = GetDialogPosition(gfx::Rect()); set_window_style(WS_CHILD | WS_CLIPCHILDREN); set_window_ex_style(WS_EX_TOPMOST); - HWNDViewContainer::Init(parent_hwnd, find_dlg_rect, view_, false); + HWNDViewContainer::Init(parent_hwnd, find_dlg_rect, false); + SetContentsView(view_); // Start the process of animating the opening of the window. animation_.reset(new SlideAnimation(this)); diff --git a/chrome/browser/native_ui_contents.cc b/chrome/browser/native_ui_contents.cc index e36361f..ff7b24d 100644 --- a/chrome/browser/native_ui_contents.cc +++ b/chrome/browser/native_ui_contents.cc @@ -173,7 +173,7 @@ NativeUIContents::~NativeUIContents() { void NativeUIContents::CreateView(HWND parent_hwnd, const gfx::Rect& initial_bounds) { set_delete_on_destroy(false); - HWNDViewContainer::Init(parent_hwnd, initial_bounds, NULL, false); + HWNDViewContainer::Init(parent_hwnd, initial_bounds, false); } LRESULT NativeUIContents::OnCreate(LPCREATESTRUCT create_struct) { diff --git a/chrome/browser/network_status_view.cc b/chrome/browser/network_status_view.cc index a05a01b..d901324 100644 --- a/chrome/browser/network_status_view.cc +++ b/chrome/browser/network_status_view.cc @@ -147,7 +147,8 @@ void NetworkStatusView::OnCreate(const CRect& rect) { // Graphical report of page loading page_load_view_ = new PageLoadView(); page_view_container_ = new ChromeViews::HWNDViewContainer; - page_view_container_->Init(m_hWnd, gfx::Rect(rect), page_load_view_, false); + page_view_container_->Init(m_hWnd, gfx::Rect(rect), false); + page_view_container_->SetContentsView(page_load_view_); HideProfilingResults(); } diff --git a/chrome/browser/tabs/dragged_tab_view.cc b/chrome/browser/tabs/dragged_tab_view.cc index d452290..bf1a0ba 100644 --- a/chrome/browser/tabs/dragged_tab_view.cc +++ b/chrome/browser/tabs/dragged_tab_view.cc @@ -68,7 +68,8 @@ DraggedTabView::DraggedTabView(TabContents* datasource, container_->set_window_ex_style( WS_EX_LAYERED | WS_EX_TOPMOST | WS_EX_TOOLWINDOW); container_->set_can_update_layered_window(false); - container_->Init(NULL, gfx::Rect(0, 0, 0, 0), this, false); + container_->Init(NULL, gfx::Rect(0, 0, 0, 0), false); + container_->SetContentsView(this); } DraggedTabView::~DraggedTabView() { diff --git a/chrome/browser/tabs/hwnd_photobooth.cc b/chrome/browser/tabs/hwnd_photobooth.cc index d8a9348..f44c724 100644 --- a/chrome/browser/tabs/hwnd_photobooth.cc +++ b/chrome/browser/tabs/hwnd_photobooth.cc @@ -173,7 +173,7 @@ void HWNDPhotobooth::CreateCaptureWindow(HWND initial_hwnd) { // WS_EX_TOOLWINDOW ensures the capture window doesn't produce a Taskbar // button. capture_window_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW); - capture_window_->Init(NULL, capture_bounds, NULL, false); + capture_window_->Init(NULL, capture_bounds, false); // If the capture window isn't visible, blitting from the TabContents' // HWND's DC to the capture bitmap produces blankness. capture_window_->ShowWindow(SW_SHOWNOACTIVATE); diff --git a/chrome/browser/tabs/tab_strip.cc b/chrome/browser/tabs/tab_strip.cc index e3755a4..e6539a9 100644 --- a/chrome/browser/tabs/tab_strip.cc +++ b/chrome/browser/tabs/tab_strip.cc @@ -1264,8 +1264,8 @@ TabStrip::DropInfo::DropInfo(int drop_index, bool drop_before, bool point_down) arrow_window->Init( NULL, gfx::Rect(0, 0, drop_indicator_width, drop_indicator_height), - arrow_view, true); + arrow_window->SetContentsView(arrow_view); } TabStrip::DropInfo::~DropInfo() { diff --git a/chrome/browser/views/download_started_animation.cc b/chrome/browser/views/download_started_animation.cc index 3131a31..d66b789 100644 --- a/chrome/browser/views/download_started_animation.cc +++ b/chrome/browser/views/download_started_animation.cc @@ -74,7 +74,8 @@ DownloadStartedAnimation::DownloadStartedAnimation(TabContents* tab_contents) popup_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT); popup_->SetLayeredAlpha(0x00); - popup_->Init(tab_contents_->GetContainerHWND(), rc, this, false); + popup_->Init(tab_contents_->GetContainerHWND(), rc, false); + popup_->SetContentsView(this); Reposition(); popup_->ShowWindow(SW_SHOWNOACTIVATE); diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc index b307a98..a9671f6 100644 --- a/chrome/browser/views/info_bubble.cc +++ b/chrome/browser/views/info_bubble.cc @@ -132,7 +132,8 @@ void InfoBubble::Init(HWND parent_hwnd, (win_util::GetWinVersion() < win_util::WINVERSION_XP) ? 0 : CS_DROPSHADOW); - HWNDViewContainer::Init(parent_hwnd, bounds, content_view_, true); + HWNDViewContainer::Init(parent_hwnd, bounds, true); + SetContentsView(content_view_); // The preferred size may differ when parented. Ask for the bounds again // and if they differ reset the bounds. gfx::Rect parented_bounds = content_view_-> diff --git a/chrome/browser/views/status_bubble.cc b/chrome/browser/views/status_bubble.cc index 69985cd..04b44f3 100644 --- a/chrome/browser/views/status_bubble.cc +++ b/chrome/browser/views/status_bubble.cc @@ -505,8 +505,8 @@ void StatusBubble::Init() { WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles()); popup_->SetLayeredAlpha(0x00); - popup_->Init(frame_->GetHWND(), rc, view_, - false); + popup_->Init(frame_->GetHWND(), rc, false); + popup_->SetContentsView(view_); Reposition(); popup_->ShowWindow(SW_SHOWNOACTIVATE); } diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc index 6d55ed8..8ee43e3 100644 --- a/chrome/browser/web_contents.cc +++ b/chrome/browser/web_contents.cc @@ -275,7 +275,7 @@ WebContents::~WebContents() { void WebContents::CreateView(HWND parent_hwnd, const gfx::Rect& initial_bounds) { set_delete_on_destroy(false); - HWNDViewContainer::Init(parent_hwnd, initial_bounds, NULL, false); + HWNDViewContainer::Init(parent_hwnd, initial_bounds, false); // Remove the root view drop target so we can register our own. RevokeDragDrop(GetHWND()); diff --git a/chrome/views/chrome_menu.cc b/chrome/views/chrome_menu.cc index 9bb8c76..72fdf1b 100644 --- a/chrome/views/chrome_menu.cc +++ b/chrome/views/chrome_menu.cc @@ -678,7 +678,8 @@ class MenuHost : public HWNDViewContainer { const gfx::Rect& bounds, View* contents_view, bool do_capture) { - HWNDViewContainer::Init(parent, bounds, contents_view, true); + HWNDViewContainer::Init(parent, bounds, true); + SetContentsView(contents_view); // We don't want to take focus away from the hosting window. ShowWindow(SW_SHOWNA); owns_capture_ = do_capture; diff --git a/chrome/views/focus_manager_unittest.cc b/chrome/views/focus_manager_unittest.cc index ed5127e..4a7240a 100644 --- a/chrome/views/focus_manager_unittest.cc +++ b/chrome/views/focus_manager_unittest.cc @@ -141,7 +141,8 @@ class BorderView : public ChromeViews::NativeControl { parent_container, NULL, NULL, NULL); // Create the view container which is a child of the TabControl. view_container_ = new ChromeViews::HWNDViewContainer(); - view_container_->Init(tab_control, gfx::Rect(), child_, false); + view_container_->Init(tab_control, gfx::Rect(), false); + view_container_->SetContentsView(child_); view_container_->SetFocusTraversableParentView(this); ResizeContents(tab_control); return tab_control; diff --git a/chrome/views/hwnd_view_container.cc b/chrome/views/hwnd_view_container.cc index 6aa2332..69545c9 100644 --- a/chrome/views/hwnd_view_container.cc +++ b/chrome/views/hwnd_view_container.cc @@ -169,7 +169,6 @@ HWNDViewContainer::~HWNDViewContainer() { void HWNDViewContainer::Init(HWND parent, const gfx::Rect& bounds, - View* contents_view, bool has_own_focus_manager) { toplevel_ = parent == NULL; @@ -207,20 +206,6 @@ void HWNDViewContainer::Init(HWND parent, FocusManager::InstallFocusSubclass(hwnd_, NULL); } - // The RootView is set up _after_ the window is created so that its - // ViewContainer pointer is valid. - if (contents_view) { - // The FillLayout only applies when we have been provided with a single - // contents view. If the user intends to manage the RootView themselves, - // they are responsible for providing their own LayoutManager, since - // FillLayout is only capable of laying out a single child view. - root_view_->SetLayoutManager(new FillLayout()); - root_view_->AddChildView(contents_view); - } - - // Manually size the window here to ensure the root view is laid out. - ChangeSize(0, CSize(bounds.width(), bounds.height())); - // Sets the RootView as a property, so the automation can introspect windows. SetRootViewForHWND(hwnd_, root_view_.get()); @@ -247,6 +232,21 @@ void HWNDViewContainer::Init(HWND parent, ::ImmAssociateContextEx(GetHWND(), NULL, 0); } +void HWNDViewContainer::SetContentsView(View* view) { + DCHECK(view && hwnd_) << "Can't be called until after the HWND is created!"; + // The ContentsView must be set up _after_ the window is created so that its + // ViewContainer pointer is valid. + root_view_->SetLayoutManager(new FillLayout); + if (root_view_->GetChildViewCount() != 0) + root_view_->RemoveAllChildViews(true); + root_view_->AddChildView(view); + + // Manually size the window here to ensure the root view is laid out. + RECT wr; + GetWindowRect(&wr); + ChangeSize(0, CSize(wr.right - wr.left, wr.bottom - wr.top)); +} + /////////////////////////////////////////////////////////////////////////////// // ChromeViews::ViewContainer diff --git a/chrome/views/hwnd_view_container.h b/chrome/views/hwnd_view_container.h index a8fd689..c9ceb12 100644 --- a/chrome/views/hwnd_view_container.h +++ b/chrome/views/hwnd_view_container.h @@ -112,9 +112,14 @@ class HWNDViewContainer : public ViewContainer, // the window. void Init(HWND parent, const gfx::Rect& bounds, - View* contents_view, bool has_own_focus_manager); + // Sets the specified view as the contents of this HWNDViewContainer. There + // can only be one contnets view child of this ViewContainer's RootView. This + // view is sized to fit the entire size of the RootView. The RootView takes + // ownership of this View, unless it is set as not being parent-owned. + virtual void SetContentsView(View* view); + // Sets the window styles. This is ONLY used when the window is created. // In other words, if you invoke this after invoking Init, nothing happens. void set_window_style(DWORD style) { window_style_ = style; } diff --git a/chrome/views/tabbed_pane.cc b/chrome/views/tabbed_pane.cc index 8ca6155..5d9677a 100644 --- a/chrome/views/tabbed_pane.cc +++ b/chrome/views/tabbed_pane.cc @@ -189,7 +189,7 @@ HWND TabbedPane::CreateNativeControl(HWND parent_container) { // Create the view container which is a child of the TabControl. content_window_ = new HWNDViewContainer(); - content_window_->Init(tab_control_, gfx::Rect(), NULL, false); + content_window_->Init(tab_control_, gfx::Rect(), false); // Explicitly setting the WS_EX_LAYOUTRTL property for the HWND (see above // for a thorough explanation regarding why we waited until |content_window_| diff --git a/chrome/views/view_unittest.cc b/chrome/views/view_unittest.cc index 44de0c0..3dfd986 100644 --- a/chrome/views/view_unittest.cc +++ b/chrome/views/view_unittest.cc @@ -383,10 +383,10 @@ TEST_F(ViewTest, Painting) { RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN); bool empty_paint = paint_window.empty_paint(); - ChromeViews::Window window; + ChromeViews::HWNDViewContainer window; window.set_delete_on_destroy(false); window.set_window_style(WS_OVERLAPPEDWINDOW); - window.Init(NULL, gfx::Rect(50, 50, 650, 650), NULL, NULL); + window.Init(NULL, gfx::Rect(50, 50, 650, 650), NULL); RootView* root = window.GetRootView(); TestView* v1 = new TestView(); diff --git a/chrome/views/window.cc b/chrome/views/window.cc index b02afcb..042968b 100644 --- a/chrome/views/window.cc +++ b/chrome/views/window.cc @@ -116,18 +116,18 @@ void Window::Init(HWND parent, const gfx::Rect& bounds) { // associated with the root of the window tree... if (use_client_view_) { View* contents_view = window_delegate_->GetContentsView(); - if (!contents_view) - contents_view = new View; + DCHECK(contents_view); client_view_ = new ClientView(this, contents_view); // A Window almost always owns its own focus manager, even if it's a child // window. File a bug if you find a circumstance where this isn't the case // and we can adjust this API. Note that if this is not the case, you'll // also have to change SetInitialFocus() as it relies on the window's focus // manager. - HWNDViewContainer::Init(parent, bounds, client_view_, true); + HWNDViewContainer::Init(parent, bounds, true); + SetContentsView(client_view_); } else { - HWNDViewContainer::Init(parent, bounds, - window_delegate_->GetContentsView(), true); + HWNDViewContainer::Init(parent, bounds, true); + SetContentsView(window_delegate_->GetContentsView()); } win_util::SetWindowUserData(GetHWND(), this); |