From 4d0bd1045bc0df8daea2a5626e73906cb074631b Mon Sep 17 00:00:00 2001 From: "ben@chromium.org" Date: Thu, 16 Oct 2008 00:26:30 +0000 Subject: Rename ViewContainer to Container and HWNDViewContainer to ContainerWin. http://crbug.com/3430 Review URL: http://codereview.chromium.org/7376 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3441 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/automation/automation_provider.cc | 2 +- chrome/browser/automation/ui_controls.cc | 2 +- .../bookmark_bar_context_menu_controller.cc | 16 +- chrome/browser/browser_commands.cc | 4 +- chrome/browser/browser_uitest.cc | 2 +- chrome/browser/debugger/debugger_view.cc | 2 +- chrome/browser/external_tab_container.cc | 3 +- chrome/browser/external_tab_container.h | 8 +- chrome/browser/find_in_page_controller.cc | 20 +- chrome/browser/find_in_page_controller.h | 6 +- chrome/browser/find_in_page_view.cc | 1 - chrome/browser/history_view.cc | 7 +- chrome/browser/native_ui_contents.cc | 4 +- chrome/browser/native_ui_contents.h | 4 +- chrome/browser/network_status_view.cc | 1 - chrome/browser/network_status_view.h | 3 - chrome/browser/render_widget_host_view_win.cc | 4 +- chrome/browser/tab_contents.cc | 8 +- chrome/browser/task_manager.cc | 2 +- chrome/browser/views/bookmark_bar_view.cc | 10 +- chrome/browser/views/bookmark_bubble_view.cc | 22 +- chrome/browser/views/bookmark_editor_view.cc | 2 +- chrome/browser/views/constrained_window_impl.cc | 13 +- chrome/browser/views/dom_view.cc | 4 +- chrome/browser/views/download_item_view.cc | 4 +- chrome/browser/views/download_started_animation.cc | 4 +- chrome/browser/views/download_started_animation.h | 4 +- chrome/browser/views/download_tab_view.cc | 4 +- chrome/browser/views/frame/aero_glass_frame.cc | 4 +- chrome/browser/views/frame/aero_glass_frame.h | 4 +- .../views/frame/aero_glass_non_client_view.cc | 4 +- chrome/browser/views/frame/browser_view.cc | 6 +- chrome/browser/views/frame/browser_view2.cc | 12 +- chrome/browser/views/frame/opaque_frame.cc | 2 +- chrome/browser/views/frame/opaque_frame.h | 2 +- .../browser/views/frame/opaque_non_client_view.cc | 2 +- chrome/browser/views/hung_renderer_view.cc | 2 +- chrome/browser/views/hwnd_html_view.cc | 6 +- chrome/browser/views/info_bar_item_view.cc | 4 +- chrome/browser/views/info_bubble.cc | 4 +- chrome/browser/views/info_bubble.h | 4 +- chrome/browser/views/keyword_editor_view.cc | 4 +- chrome/browser/views/location_bar_view.cc | 14 +- chrome/browser/views/old_frames/vista_frame.cc | 9 +- chrome/browser/views/old_frames/vista_frame.h | 6 +- chrome/browser/views/old_frames/xp_frame.cc | 9 +- chrome/browser/views/old_frames/xp_frame.h | 6 +- .../views/options/advanced_contents_view.cc | 2 +- chrome/browser/views/options/content_page_view.cc | 4 +- .../views/options/fonts_languages_window_view.cc | 2 +- chrome/browser/views/options/fonts_page_view.cc | 4 +- .../browser/views/options/languages_page_view.cc | 6 +- chrome/browser/views/options/options_page_view.cc | 8 +- .../browser/views/options/options_window_view.cc | 4 +- chrome/browser/views/sad_tab_view.h | 6 +- chrome/browser/views/shelf_item_dialog.cc | 2 +- chrome/browser/views/status_bubble.cc | 12 +- chrome/browser/views/status_bubble.h | 10 +- .../browser/views/tab_contents_container_view.cc | 5 +- .../browser/views/tabs/dragged_tab_controller.cc | 11 +- chrome/browser/views/tabs/dragged_tab_view.cc | 6 +- chrome/browser/views/tabs/dragged_tab_view.h | 4 +- chrome/browser/views/tabs/hwnd_photobooth.cc | 4 +- chrome/browser/views/tabs/hwnd_photobooth.h | 4 +- chrome/browser/views/tabs/tab.cc | 7 +- chrome/browser/views/tabs/tab_strip.cc | 13 +- chrome/browser/views/tabs/tab_strip.h | 4 +- chrome/browser/views/toolbar_view.cc | 24 +- chrome/browser/views/user_data_dir_dialog.cc | 2 +- chrome/browser/web_contents_view_win.cc | 4 +- chrome/browser/web_contents_view_win.h | 6 +- chrome/common/gfx/url_elider.cc | 1 - chrome/common/gfx/url_elider_unittest.cc | 1 - chrome/test/accessibility/accessibility_util.cc | 2 +- chrome/test/accessibility/constants.h | 2 +- chrome/views/SConscript | 2 +- chrome/views/accessibility/view_accessibility.cc | 8 +- chrome/views/aero_tooltip_manager.cc | 2 +- chrome/views/aero_tooltip_manager.h | 2 +- chrome/views/bitmap_scroll_bar.cc | 8 +- chrome/views/button.cc | 2 +- chrome/views/button_dropdown.cc | 8 +- chrome/views/chrome_menu.cc | 14 +- chrome/views/chrome_menu.h | 8 +- chrome/views/client_view.cc | 6 +- chrome/views/container.h | 85 ++ chrome/views/container_win.cc | 916 ++++++++++++++++++++ chrome/views/container_win.h | 586 +++++++++++++ chrome/views/custom_frame_window.cc | 8 +- chrome/views/custom_frame_window.h | 2 +- chrome/views/dialog_client_view.cc | 2 +- chrome/views/focus_manager.cc | 8 +- chrome/views/focus_manager.h | 6 +- chrome/views/focus_manager_unittest.cc | 10 +- chrome/views/hwnd_view.cc | 14 +- chrome/views/hwnd_view_container.cc | 928 --------------------- chrome/views/hwnd_view_container.h | 586 ------------- chrome/views/label.cc | 2 +- chrome/views/menu_button.cc | 6 +- chrome/views/native_control.cc | 8 +- chrome/views/native_scroll_bar.cc | 10 +- chrome/views/root_view.cc | 26 +- chrome/views/root_view.h | 40 +- chrome/views/root_view_drop_target.cc | 4 +- chrome/views/tabbed_pane.cc | 4 +- chrome/views/tabbed_pane.h | 4 +- chrome/views/table_view.cc | 2 +- chrome/views/text_button.cc | 2 +- chrome/views/text_field.cc | 8 +- chrome/views/tooltip_manager.cc | 22 +- chrome/views/tooltip_manager.h | 10 +- chrome/views/tree_view.cc | 4 +- chrome/views/view.cc | 32 +- chrome/views/view.h | 22 +- chrome/views/view_container.h | 86 -- chrome/views/view_unittest.cc | 8 +- chrome/views/views.vcproj | 24 +- chrome/views/window.cc | 30 +- chrome/views/window.h | 14 +- 119 files changed, 1991 insertions(+), 2018 deletions(-) create mode 100644 chrome/views/container.h create mode 100644 chrome/views/container_win.cc create mode 100644 chrome/views/container_win.h delete mode 100644 chrome/views/hwnd_view_container.cc delete mode 100644 chrome/views/hwnd_view_container.h delete mode 100644 chrome/views/view_container.h diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index c7bb3d5..e4b4bf6 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -1143,7 +1143,7 @@ void AutomationProvider::WindowGetViewBounds(const IPC::Message& message, if (window_tracker_->ContainsHandle(handle)) { HWND hwnd = window_tracker_->GetResource(handle); ChromeViews::RootView* root_view = - ChromeViews::HWNDViewContainer::FindRootView(hwnd); + ChromeViews::ContainerWin::FindRootView(hwnd); if (root_view) { ChromeViews::View* view = root_view->GetViewByID(view_id); if (view) { diff --git a/chrome/browser/automation/ui_controls.cc b/chrome/browser/automation/ui_controls.cc index ab5f572..f87490e 100644 --- a/chrome/browser/automation/ui_controls.cc +++ b/chrome/browser/automation/ui_controls.cc @@ -335,7 +335,7 @@ bool SendMouseClick(MouseButton type) { void MoveMouseToCenterAndPress( ChromeViews::View* view, MouseButton button, int state, Task* task) { DCHECK(view); - DCHECK(view->GetViewContainer()); + DCHECK(view->GetContainer()); gfx::Point view_center(view->width() / 2, view->height() / 2); ChromeViews::View::ConvertPointToScreen(view, &view_center); SendMouseMove(view_center.x(), view_center.y()); diff --git a/chrome/browser/bookmark_bar_context_menu_controller.cc b/chrome/browser/bookmark_bar_context_menu_controller.cc index d7c1010d..75d33b8 100644 --- a/chrome/browser/bookmark_bar_context_menu_controller.cc +++ b/chrome/browser/bookmark_bar_context_menu_controller.cc @@ -16,7 +16,7 @@ #include "chrome/common/l10n_util.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" -#include "chrome/views/view_container.h" +#include "chrome/views/container.h" #include "chrome/views/window.h" #include "chromium_strings.h" @@ -121,7 +121,7 @@ class EditFolderController : public InputWindowDelegate, visual_order_(visual_order), is_new_(is_new) { DCHECK(is_new_ || node); - window_ = CreateInputWindow(view->GetViewContainer()->GetHWND(), this); + window_ = CreateInputWindow(view->GetContainer()->GetHWND(), this); view_->SetModelChangedListener(this); } @@ -274,7 +274,7 @@ void BookmarkBarContextMenuController::RunMenuAt(int x, int y) { view_->SetModelChangedListener(this); // width/height don't matter here. - menu_.RunMenuAt(view_->GetViewContainer()->GetHWND(), gfx::Rect(x, y, 0, 0), + menu_.RunMenuAt(view_->GetContainer()->GetHWND(), gfx::Rect(x, y, 0, 0), ChromeViews::MenuItemView::TOPLEFT, true); if (view_->GetModelChangedListener() == this) @@ -328,9 +328,9 @@ void BookmarkBarContextMenuController::ExecuteCommand(int id) { else initial_disposition = CURRENT_TAB; - // GetViewContainer is NULL during testing. - HWND parent_hwnd = view_->GetViewContainer() ? - view_->GetViewContainer()->GetHWND() : 0; + // GetContainer is NULL during testing. + HWND parent_hwnd = view_->GetContainer() ? + view_->GetContainer()->GetHWND() : 0; OpenAll(parent_hwnd, view_->GetPageNavigator(), node_, initial_disposition); @@ -341,7 +341,7 @@ void BookmarkBarContextMenuController::ExecuteCommand(int id) { UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_Edit", profile); if (node_->GetType() == history::StarredEntry::URL) { - BookmarkEditorView::Show(view_->GetViewContainer()->GetHWND(), + BookmarkEditorView::Show(view_->GetContainer()->GetHWND(), view_->GetProfile(), NULL, node_); } else { // Controller deletes itself when done. @@ -362,7 +362,7 @@ void BookmarkBarContextMenuController::ExecuteCommand(int id) { case add_bookmark_id: { UserMetrics::RecordAction(L"BookmarkBar_ContextMenu_Add", profile); - BookmarkEditorView::Show(view_->GetViewContainer()->GetHWND(), + BookmarkEditorView::Show(view_->GetContainer()->GetHWND(), view_->GetProfile(), node_, NULL); break; } diff --git a/chrome/browser/browser_commands.cc b/chrome/browser/browser_commands.cc index cca8754..eb1d405 100644 --- a/chrome/browser/browser_commands.cc +++ b/chrome/browser/browser_commands.cc @@ -1027,8 +1027,8 @@ void Browser::DuplicateContentsAt(int index) { Browser* new_browser = new Browser(gfx::Rect(), SW_SHOWNORMAL, profile(), BrowserType::APPLICATION, app_name_); - // We need to show the browser now. Otherwise HWNDViewContainer assumes - // the tab contents is invisible and won't size it. + // We need to show the browser now. Otherwise ContainerWin assumes the + // TabContents is invisible and won't size it. new_browser->Show(); // The page transition below is only for the purpose of inserting the tab. diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc index 842b7d8..f564d4f 100644 --- a/chrome/browser/browser_uitest.cc +++ b/chrome/browser/browser_uitest.cc @@ -12,7 +12,7 @@ #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/automation/window_proxy.h" #include "chrome/test/ui/ui_test.h" -#include "chrome/views/view_container.h" +#include "chrome/views/container.h" #include "net/base/net_util.h" #include "net/url_request/url_request_unittest.h" diff --git a/chrome/browser/debugger/debugger_view.cc b/chrome/browser/debugger/debugger_view.cc index 34b4de5..f6cac90 100644 --- a/chrome/browser/debugger/debugger_view.cc +++ b/chrome/browser/debugger/debugger_view.cc @@ -55,7 +55,7 @@ void DebuggerView::ViewHierarchyChanged(bool is_add, ChromeViews::View* parent, ChromeViews::View* child) { if (is_add && child == this) { - DCHECK(GetViewContainer()); + DCHECK(GetContainer()); OnInit(); } } diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index c6188c3..abf033f 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -13,7 +13,8 @@ #include "chrome/browser/web_contents.h" #include "chrome/common/chrome_constants.h" #include "chrome/common/win_util.h" -#include "chrome/views/hwnd_view_container.h" +// Included for SetRootViewForHWND. +#include "chrome/views/container_win.h" #include "chrome/test/automation/automation_messages.h" static const wchar_t kWindowObjectKey[] = L"ChromeWindowObject"; diff --git a/chrome/browser/external_tab_container.h b/chrome/browser/external_tab_container.h index b0f4909..2e3d589 100644 --- a/chrome/browser/external_tab_container.h +++ b/chrome/browser/external_tab_container.h @@ -15,9 +15,9 @@ #include "chrome/common/chrome_constants.h" #include "chrome/common/notification_registrar.h" #include "chrome/common/notification_service.h" +#include "chrome/views/container.h" #include "chrome/views/focus_manager.h" #include "chrome/views/root_view.h" -#include "chrome/views/view_container.h" class AutomationProvider; class TabContents; @@ -27,10 +27,10 @@ class TabContentsContainerView; // An external tab is a Chrome tab that is meant to displayed in an // external process. This class provides the FocusManger needed by the // TabContents as well as an implementation of TabContentsDelagate. -// It also implements ViewContainer +// It also implements Container class ExternalTabContainer : public TabContentsDelegate, public NotificationObserver, - public ChromeViews::ViewContainer, + public ChromeViews::Container, public ChromeViews::KeystrokeListener, public CWindowImplGetLocalBounds(&local_bounds, false); toolbar_bounds = gfx::Rect(local_bounds); } - // Need to convert toolbar bounds into ViewContainer coords because the - // toolbar is the child of another view that isn't the top level view. - // This is required to ensure correct positioning relative to the top,left - // of the window. + // Need to convert toolbar bounds into Container coords because the toolbar + // is the child of another view that isn't the top level view. This is + // required to ensure correct positioning relative to the top,left of the + // window. gfx::Point topleft; - ChromeViews::View::ConvertPointToViewContainer(toolbar, &topleft); + ChromeViews::View::ConvertPointToContainer(toolbar, &topleft); toolbar_bounds.Offset(topleft.x(), topleft.y()); } diff --git a/chrome/browser/find_in_page_controller.h b/chrome/browser/find_in_page_controller.h index 5ddef23..733d068 100644 --- a/chrome/browser/find_in_page_controller.h +++ b/chrome/browser/find_in_page_controller.h @@ -8,7 +8,7 @@ #include "base/gfx/rect.h" #include "chrome/browser/render_view_host_delegate.h" #include "chrome/common/animation.h" -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/container_win.h" class FindInPageView; class SlideAnimation; @@ -34,7 +34,7 @@ namespace ChromeViews { //////////////////////////////////////////////////////////////////////////////// class FindInPageController : public RenderViewHostDelegate::FindInPage, public ChromeViews::FocusChangeListener, - public ChromeViews::HWNDViewContainer, + public ChromeViews::ContainerWin, public AnimationDelegate { public: FindInPageController(TabContents* parent_tab, @@ -107,7 +107,7 @@ class FindInPageController : public RenderViewHostDelegate::FindInPage, find_string_ = find_string; } - // Overridden from ChromeViews::HWNDViewContainer: + // Overridden from ChromeViews::ContainerWin: virtual void OnFinalMessage(HWND window); // Overridden from ChromeViews::FocusChangeListener: diff --git a/chrome/browser/find_in_page_view.cc b/chrome/browser/find_in_page_view.cc index 813dc10..da14afe 100644 --- a/chrome/browser/find_in_page_view.cc +++ b/chrome/browser/find_in_page_view.cc @@ -13,7 +13,6 @@ #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/resource_bundle.h" #include "chrome/views/background.h" -#include "chrome/views/hwnd_view_container.h" #include "chrome/views/label.h" #include "skia/include/SkGradientShader.h" diff --git a/chrome/browser/history_view.cc b/chrome/browser/history_view.cc index 6cac8f1..ef439eb 100644 --- a/chrome/browser/history_view.cc +++ b/chrome/browser/history_view.cc @@ -22,6 +22,7 @@ #include "chrome/common/resource_bundle.h" #include "chrome/common/time_format.h" #include "chrome/common/win_util.h" +#include "chrome/views/container.h" #include "chrome/views/link.h" #include "generated_resources.h" @@ -562,7 +563,7 @@ void HistoryItemRenderer::StarStateChanged(bool state) { gfx::Rect star_bounds(star_location.x(), star_location.y() + 4, star_toggle_->width(), star_toggle_->height()); - HWND parent = GetViewContainer()->GetHWND(); + HWND parent = GetContainer()->GetHWND(); Profile* profile = model_->profile(); GURL url = model_->GetURL(model_index_); @@ -835,7 +836,7 @@ ChromeViews::VariableRowHeightScrollHelper::RowInfo } bool HistoryView::IsVisible() { - ChromeViews::ViewContainer* vc = GetViewContainer(); + ChromeViews::Container* vc = GetContainer(); return vc && vc->IsVisible(); } @@ -1242,7 +1243,7 @@ void HistoryView::DeleteDayAtModelIndex(int index) { IDS_HISTORY_DELETE_PRIOR_VISITS_WARNING_TITLE); UINT flags = MB_OKCANCEL | MB_ICONWARNING | MB_TOPMOST | MB_SETFOREGROUND; - if (win_util::MessageBox(GetViewContainer()->GetHWND(), + if (win_util::MessageBox(GetContainer()->GetHWND(), text, caption, flags) != IDOK) { return; } diff --git a/chrome/browser/native_ui_contents.cc b/chrome/browser/native_ui_contents.cc index ef81dbd..785ca8a 100644 --- a/chrome/browser/native_ui_contents.cc +++ b/chrome/browser/native_ui_contents.cc @@ -16,8 +16,8 @@ #include "chrome/common/resource_bundle.h" #include "chrome/views/background.h" #include "chrome/views/checkbox.h" +#include "chrome/views/container_win.h" #include "chrome/views/grid_layout.h" -#include "chrome/views/hwnd_view_container.h" #include "chrome/views/image_view.h" #include "chrome/views/root_view.h" #include "chrome/views/scroll_view.h" @@ -151,7 +151,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, false); + ContainerWin::Init(parent_hwnd, initial_bounds, false); } LRESULT NativeUIContents::OnCreate(LPCREATESTRUCT create_struct) { diff --git a/chrome/browser/native_ui_contents.h b/chrome/browser/native_ui_contents.h index 443e3be..d333fcf 100644 --- a/chrome/browser/native_ui_contents.h +++ b/chrome/browser/native_ui_contents.h @@ -8,7 +8,7 @@ #include "chrome/browser/page_state.h" #include "chrome/browser/tab_contents.h" #include "chrome/views/background.h" -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/container_win.h" #include "chrome/views/link.h" #include "chrome/views/native_button.h" #include "chrome/views/text_field.h" @@ -33,7 +33,7 @@ class NativeUI; // //////////////////////////////////////////////////////////////////////////////// class NativeUIContents : public TabContents, - public ChromeViews::HWNDViewContainer { + public ChromeViews::ContainerWin { public: explicit NativeUIContents(Profile* profile); diff --git a/chrome/browser/network_status_view.cc b/chrome/browser/network_status_view.cc index 4a0e57c..74fff7f 100644 --- a/chrome/browser/network_status_view.cc +++ b/chrome/browser/network_status_view.cc @@ -11,7 +11,6 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/tab_contents_delegate.h" -#include "chrome/views/hwnd_view_container.h" #include "chrome/views/root_view.h" #include "net/url_request/url_request.h" #include "net/url_request/url_request_job.h" diff --git a/chrome/browser/network_status_view.h b/chrome/browser/network_status_view.h index bae43fa..2170f73 100644 --- a/chrome/browser/network_status_view.h +++ b/chrome/browser/network_status_view.h @@ -16,9 +16,6 @@ class MessageLoop; class RenderProcessHost; class NavigationPerformanceViewer; class PageLoadView; -namespace ChromeViews { -class HWNDViewContainer; -} class NetworkStatusView : public StatusView { public: diff --git a/chrome/browser/render_widget_host_view_win.cc b/chrome/browser/render_widget_host_view_win.cc index bc9c283..d32e658 100644 --- a/chrome/browser/render_widget_host_view_win.cc +++ b/chrome/browser/render_widget_host_view_win.cc @@ -21,7 +21,9 @@ #include "chrome/common/l10n_util.h" #include "chrome/common/plugin_messages.h" #include "chrome/common/win_util.h" -#include "chrome/views/hwnd_view_container.h" +// Included for ChromeViews::kReflectedMessage - TODO(beng): move this to +// win_util.h! +#include "chrome/views/container_win.h" #include "webkit/glue/webcursor.h" namespace { diff --git a/chrome/browser/tab_contents.cc b/chrome/browser/tab_contents.cc index 2deb196..77a55f7 100644 --- a/chrome/browser/tab_contents.cc +++ b/chrome/browser/tab_contents.cc @@ -13,7 +13,7 @@ #include "chrome/common/l10n_util.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/container.h" #include "chrome/views/native_scroll_bar.h" #include "chrome/views/root_view.h" #include "chrome/views/view.h" @@ -26,8 +26,8 @@ static size_t kMaxNumberOfConstrainedPopups = 20; namespace { BOOL CALLBACK InvalidateWindow(HWND hwnd, LPARAM lparam) { - // Note: erase is required to properly paint some widgets borders. This can be - // seen with textfields. + // Note: erase is required to properly paint some widgets borders. This can + // be seen with textfields. InvalidateRect(hwnd, NULL, TRUE); return TRUE; } @@ -365,7 +365,7 @@ void TabContents::StoreFocus() { if (container_hwnd) { ChromeViews::View* focused_view = focus_manager->GetFocusedView(); if (focused_view) { - HWND hwnd = focused_view->GetRootView()->GetViewContainer()->GetHWND(); + HWND hwnd = focused_view->GetRootView()->GetContainer()->GetHWND(); if (container_hwnd == hwnd || ::IsChild(container_hwnd, hwnd)) focus_manager->ClearFocus(); } diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc index 82afafc..0f593b1 100644 --- a/chrome/browser/task_manager.cc +++ b/chrome/browser/task_manager.cc @@ -937,7 +937,7 @@ void TaskManagerContents::ShowContextMenu(ChromeViews::View* source, int y, bool is_mouse_gesture) { UpdateStatsCounters(); - Menu menu(this, Menu::TOPLEFT, source->GetViewContainer()->GetHWND()); + Menu menu(this, Menu::TOPLEFT, source->GetContainer()->GetHWND()); for (std::vector::iterator i = columns_.begin(); i != columns_.end(); ++i) { menu.AppendMenuItem(i->id, i->title, Menu::CHECKBOX); diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc index dce6d08..ca3267b 100644 --- a/chrome/browser/views/bookmark_bar_view.cc +++ b/chrome/browser/views/bookmark_bar_view.cc @@ -40,9 +40,9 @@ #include "chrome/common/resource_bundle.h" #include "chrome/common/win_util.h" #include "chrome/views/chrome_menu.h" +#include "chrome/views/container.h" #include "chrome/views/menu_button.h" #include "chrome/views/tooltip_manager.h" -#include "chrome/views/view_container.h" #include "chrome/views/window.h" #include "generated_resources.h" @@ -1408,7 +1408,7 @@ void BookmarkBarView::RunMenu(ChromeViews::View* view, gfx::Point screen_loc(x, 0); View::ConvertPointToScreen(this, &screen_loc); menu_runner_.reset(new MenuRunner(this, node, start_index)); - HWND parent_hwnd = GetViewContainer()->GetHWND(); + HWND parent_hwnd = GetContainer()->GetHWND(); menu_runner_->RunMenuAt(parent_hwnd, gfx::Rect(screen_loc.x(), screen_loc.y(), view->width(), bar_height), @@ -1433,7 +1433,7 @@ void BookmarkBarView::ButtonPressed(ChromeViews::BaseButton* sender) { PageTransition::AUTO_BOOKMARK); } else { BookmarkBarContextMenuController::OpenAll( - GetViewContainer()->GetHWND(), GetPageNavigator(), node, + GetContainer()->GetHWND(), GetPageNavigator(), node, event_utils::DispositionFromEventFlags(sender->mouse_event_flags())); } UserMetrics::RecordAction(L"ClickedBookmarkBarURLButton", profile_); @@ -1591,7 +1591,7 @@ void BookmarkBarView::ShowDropFolderForNode(BookmarkNode* node) { gfx::Point screen_loc; View::ConvertPointToScreen(view_to_position_menu_from, &screen_loc); drop_menu_runner_->RunMenuAt( - GetViewContainer()->GetHWND(), + GetContainer()->GetHWND(), gfx::Rect(screen_loc.x(), screen_loc.y(), view_to_position_menu_from->width(), view_to_position_menu_from->height()), @@ -1828,7 +1828,7 @@ void BookmarkBarView::StartThrobbing() { if (bubble_url_.is_empty()) return; // Bubble isn't showing; nothing to throb. - if (!GetViewContainer()) + if (!GetContainer()) return; // We're not showing, don't do anything. BookmarkNode* node = model_->GetMostRecentlyAddedNodeForURL(bubble_url_); diff --git a/chrome/browser/views/bookmark_bubble_view.cc b/chrome/browser/views/bookmark_bubble_view.cc index ffb9817..f6021ef 100644 --- a/chrome/browser/views/bookmark_bubble_view.cc +++ b/chrome/browser/views/bookmark_bubble_view.cc @@ -136,9 +136,9 @@ void BookmarkBubbleView::DidChangeBounds(const CRect& previous, } void BookmarkBubbleView::BubbleShown() { - DCHECK(GetViewContainer()); + DCHECK(GetContainer()); ChromeViews::FocusManager* focus_manager = - ChromeViews::FocusManager::GetFocusManager(GetViewContainer()->GetHWND()); + ChromeViews::FocusManager::GetFocusManager(GetContainer()->GetHWND()); focus_manager->RegisterAccelerator( ChromeViews::Accelerator(VK_RETURN, false, false, false), this); @@ -316,7 +316,7 @@ bool BookmarkBubbleView::CloseOnEscape() { } void BookmarkBubbleView::Close() { - static_cast(GetViewContainer())->Close(); + static_cast(GetContainer())->Close(); } void BookmarkBubbleView::RemoveBookmark() { @@ -342,16 +342,16 @@ void BookmarkBubbleView::ShowEditor() { // Parent the editor to our root ancestor (not the root we're in, as that // is the info bubble and will close shortly). - HWND parent = GetAncestor(GetViewContainer()->GetHWND(), GA_ROOTOWNER); + HWND parent = GetAncestor(GetContainer()->GetHWND(), GA_ROOTOWNER); // We're about to show the bookmark editor. When the bookmark editor closes - // we want the browser to become active. HWNDViewContainer::Hide() does a - // hide in a such way that activation isn't changed, which means when we - // close Windows gets confused as to who it should give active status to. - // We explicitly hide the bookmark bubble window in such a way that - // activation status changes. That way, when the editor closes, activation - // is properly restored to the browser. - ShowWindow(GetViewContainer()->GetHWND(), SW_HIDE); + // we want the browser to become active. ContainerWin::Hide() does a hide in + // a such way that activation isn't changed, which means when we close + // Windows gets confused as to who it should give active status to. We + // explicitly hide the bookmark bubble window in such a way that activation + // status changes. That way, when the editor closes, activation is properly + // restored to the browser. + ShowWindow(GetContainer()->GetHWND(), SW_HIDE); // Even though we just hid the window, we need to invoke Close to schedule // the delete and all that. diff --git a/chrome/browser/views/bookmark_editor_view.cc b/chrome/browser/views/bookmark_editor_view.cc index f73b4dd..b93e8a6 100644 --- a/chrome/browser/views/bookmark_editor_view.cc +++ b/chrome/browser/views/bookmark_editor_view.cc @@ -210,7 +210,7 @@ void BookmarkEditorView::ShowContextMenu(View* source, (tree_model_->GetParent(tree_view_.GetSelectedNode()) == tree_model_->GetRoot()); context_menu_.reset(new Menu(this, Menu::TOPLEFT, - GetViewContainer()->GetHWND())); + GetContainer()->GetHWND())); context_menu_->AppendMenuItemWithLabel(IDS_EDIT, l10n_util::GetString(IDS_EDIT)); context_menu_->AppendMenuItemWithLabel( diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc index 4666e1f..11f635a 100644 --- a/chrome/browser/views/constrained_window_impl.cc +++ b/chrome/browser/views/constrained_window_impl.cc @@ -627,11 +627,10 @@ gfx::Size ConstrainedWindowNonClientView::GetPreferredSize() { void ConstrainedWindowNonClientView::ViewHierarchyChanged(bool is_add, View *parent, View *child) { - if (is_add && GetViewContainer()) { - // Add our Client View as we are added to the ViewContainer so that if we - // are subsequently resized all the parent-child relationships are - // established. - if (is_add && GetViewContainer() && child == this) + if (is_add && GetContainer()) { + // Add our Client View as we are added to the Container so that if we are + // subsequently resized all the parent-child relationships are established. + if (is_add && GetContainer() && child == this) AddChildView(container_->client_view()); if (location_bar_ && !location_bar_->IsInitialized()) location_bar_->Init(); @@ -1241,7 +1240,7 @@ void ConstrainedWindowImpl::UpdateUI(unsigned int changed_flags) { } //////////////////////////////////////////////////////////////////////////////// -// ConstrainedWindowImpl, ChromeViews::HWNDViewContainer overrides: +// ConstrainedWindowImpl, ChromeViews::ContainerWin overrides: void ConstrainedWindowImpl::OnDestroy() { // We do this here, rather than |Close|, since the window may be destroyed in @@ -1291,7 +1290,7 @@ void ConstrainedWindowImpl::OnFinalMessage(HWND window) { constrained_contents_ = NULL; } - HWNDViewContainer::OnFinalMessage(window); + ContainerWin::OnFinalMessage(window); } void ConstrainedWindowImpl::OnGetMinMaxInfo(LPMINMAXINFO mm_info) { diff --git a/chrome/browser/views/dom_view.cc b/chrome/browser/views/dom_view.cc index c97b605..24f6f5b 100644 --- a/chrome/browser/views/dom_view.cc +++ b/chrome/browser/views/dom_view.cc @@ -5,7 +5,7 @@ #include "chrome/browser/views/dom_view.h" #include "chrome/browser/dom_ui/dom_ui_host.h" -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/container.h" DOMView::DOMView(const GURL& contents) : contents_(contents), initialized_(false), host_(NULL) { @@ -29,7 +29,7 @@ bool DOMView::Init(Profile* profile, SiteInstance* instance) { // should only be associated with instances of DOMUIHost. TabContentsType type = TabContents::TypeForURL(&contents_); TabContents* tab_contents = TabContents::CreateWithType(type, - GetViewContainer()->GetHWND(), profile, instance); + GetContainer()->GetHWND(), profile, instance); host_ = tab_contents->AsDOMUIHost(); DCHECK(host_); diff --git a/chrome/browser/views/download_item_view.cc b/chrome/browser/views/download_item_view.cc index 1738463..66f4c55 100644 --- a/chrome/browser/views/download_item_view.cc +++ b/chrome/browser/views/download_item_view.cc @@ -16,9 +16,9 @@ #include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" #include "chrome/common/win_util.h" +#include "chrome/views/container.h" #include "chrome/views/native_button.h" #include "chrome/views/root_view.h" -#include "chrome/views/view_container.h" #include "generated_resources.h" @@ -630,7 +630,7 @@ bool DownloadItemView::OnMousePressed(const ChromeViews::MouseEvent& event) { ChromeViews::View::ConvertPointToScreen(this, &point); download_util::DownloadShelfContextMenu menu(download_, - GetViewContainer()->GetHWND(), + GetContainer()->GetHWND(), model_.get(), point.ToPOINT()); drop_down_pressed_ = false; diff --git a/chrome/browser/views/download_started_animation.cc b/chrome/browser/views/download_started_animation.cc index f95b13c..d3e04c6 100644 --- a/chrome/browser/views/download_started_animation.cc +++ b/chrome/browser/views/download_started_animation.cc @@ -7,7 +7,7 @@ #include "chrome/app/theme/theme_resources.h" #include "chrome/browser/tab_contents.h" #include "chrome/common/resource_bundle.h" -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/container_win.h" // How long to spend moving downwards and fading out after waiting. static const int kMoveTimeMs = 600; @@ -44,7 +44,7 @@ DownloadStartedAnimation::DownloadStartedAnimation(TabContents* tab_contents) SetImage(kDownloadImage); gfx::Rect rc(0, 0, 0, 0); - popup_ = new ChromeViews::HWNDViewContainer; + popup_ = new ChromeViews::ContainerWin; popup_->set_window_style(WS_POPUP); popup_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT); diff --git a/chrome/browser/views/download_started_animation.h b/chrome/browser/views/download_started_animation.h index 5cff47fe..6934fc5 100644 --- a/chrome/browser/views/download_started_animation.h +++ b/chrome/browser/views/download_started_animation.h @@ -11,7 +11,7 @@ #include "chrome/views/image_view.h" namespace ChromeViews { - class HWNDViewContainer; +class ContainerWin; }; class TabContents; @@ -42,7 +42,7 @@ class DownloadStartedAnimation : public Animation, const NotificationDetails& details); // We use a HWND for the popup so that it may float above any HWNDs in our UI. - ChromeViews::HWNDViewContainer* popup_; + ChromeViews::ContainerWin* popup_; // The content area holding us. TabContents* tab_contents_; diff --git a/chrome/browser/views/download_tab_view.cc b/chrome/browser/views/download_tab_view.cc index 1deaf60..61f5164 100644 --- a/chrome/browser/views/download_tab_view.cc +++ b/chrome/browser/views/download_tab_view.cc @@ -702,7 +702,7 @@ bool DownloadItemTabView::OnMousePressed(const ChromeViews::MouseEvent& event) { ChromeViews::View::ConvertPointToScreen(this, &point); download_util::DownloadDestinationContextMenu menu( - model_, GetViewContainer()->GetHWND(), point.ToPOINT()); + model_, GetContainer()->GetHWND(), point.ToPOINT()); } } else { parent_->ItemBecameSelected(NULL); @@ -743,7 +743,7 @@ void DownloadItemTabView::LinkActivated(ChromeViews::Link* source, int event_flags) { // There are several links in our view that could have been clicked: if (source == file_name_) { - ChromeViews::ViewContainer* container = this->GetViewContainer(); + ChromeViews::Container* container = this->GetContainer(); HWND parent_window = container ? container->GetHWND() : NULL; model_->manager()->OpenDownloadInShell(model_, parent_window); } else if (source == pause_) { diff --git a/chrome/browser/views/frame/aero_glass_frame.cc b/chrome/browser/views/frame/aero_glass_frame.cc index cb86728..7810cac 100644 --- a/chrome/browser/views/frame/aero_glass_frame.cc +++ b/chrome/browser/views/frame/aero_glass_frame.cc @@ -91,7 +91,7 @@ ChromeViews::Window* AeroGlassFrame::GetWindow() { } /////////////////////////////////////////////////////////////////////////////// -// AeroGlassFrame, ChromeViews::HWNDViewContainer implementation: +// AeroGlassFrame, ChromeViews::ContainerWin implementation: void AeroGlassFrame::OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu) { @@ -183,7 +183,7 @@ LRESULT AeroGlassFrame::OnNCHitTest(const CPoint& pt) { } /////////////////////////////////////////////////////////////////////////////// -// AeroGlassFrame, ChromeViews::HWNDViewContainer overrides: +// AeroGlassFrame, ChromeViews::ContainerWin overrides: bool AeroGlassFrame::AcceleratorPressed( ChromeViews::Accelerator* accelerator) { diff --git a/chrome/browser/views/frame/aero_glass_frame.h b/chrome/browser/views/frame/aero_glass_frame.h index a649eef..ccdec53 100644 --- a/chrome/browser/views/frame/aero_glass_frame.h +++ b/chrome/browser/views/frame/aero_glass_frame.h @@ -38,13 +38,13 @@ class AeroGlassFrame : public BrowserFrame, virtual void UpdateThrobber(bool running); virtual ChromeViews::Window* GetWindow(); - // Overridden from ChromeViews::HWNDViewContainer: + // Overridden from ChromeViews::ContainerWin: virtual bool AcceleratorPressed(ChromeViews::Accelerator* accelerator); virtual bool GetAccelerator(int cmd_id, ChromeViews::Accelerator* accelerator); protected: - // Overridden from ChromeViews::HWNDViewContainer: + // Overridden from ChromeViews::ContainerWin: virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu); virtual void OnEndSession(BOOL ending, UINT logoff); virtual void OnExitMenuLoop(bool is_track_popup_menu); diff --git a/chrome/browser/views/frame/aero_glass_non_client_view.cc b/chrome/browser/views/frame/aero_glass_non_client_view.cc index 74de8bb..5155634 100644 --- a/chrome/browser/views/frame/aero_glass_non_client_view.cc +++ b/chrome/browser/views/frame/aero_glass_non_client_view.cc @@ -181,7 +181,7 @@ gfx::Size AeroGlassNonClientView::CalculateWindowSizeForClientSize( CPoint AeroGlassNonClientView::GetSystemMenuPoint() const { CPoint offset(0, 0); - MapWindowPoints(GetViewContainer()->GetHWND(), HWND_DESKTOP, &offset, 1); + MapWindowPoints(GetContainer()->GetHWND(), HWND_DESKTOP, &offset, 1); return offset; } @@ -259,7 +259,7 @@ void AeroGlassNonClientView::ViewHierarchyChanged(bool is_add, ChromeViews::View* parent, ChromeViews::View* child) { if (is_add && child == this) { - DCHECK(GetViewContainer()); + DCHECK(GetContainer()); DCHECK(frame_->client_view()->GetParent() != this); AddChildView(frame_->client_view()); } diff --git a/chrome/browser/views/frame/browser_view.cc b/chrome/browser/views/frame/browser_view.cc index 71b82c4..5a8b495 100644 --- a/chrome/browser/views/frame/browser_view.cc +++ b/chrome/browser/views/frame/browser_view.cc @@ -61,7 +61,7 @@ void BrowserView::Init() { toolbar_->Init(browser_->profile()); toolbar_->SetAccessibleName(l10n_util::GetString(IDS_ACCNAME_TOOLBAR)); - status_bubble_.reset(new StatusBubble(GetViewContainer())); + status_bubble_.reset(new StatusBubble(GetContainer())); } void BrowserView::Show(int command, bool adjust_to_fit) { @@ -228,10 +228,10 @@ void BrowserView::DidChangeBounds(const CRect& previous, void BrowserView::ViewHierarchyChanged(bool is_add, ChromeViews::View* parent, ChromeViews::View* child) { - if (is_add && child == this && GetViewContainer() && !initialized_) { + if (is_add && child == this && GetContainer() && !initialized_) { Init(); // Make sure not to call Init() twice if we get inserted into a different - // ViewContainer. + // Container. initialized_ = true; } } diff --git a/chrome/browser/views/frame/browser_view2.cc b/chrome/browser/views/frame/browser_view2.cc index b5c4ee7..7ee9567 100644 --- a/chrome/browser/views/frame/browser_view2.cc +++ b/chrome/browser/views/frame/browser_view2.cc @@ -272,7 +272,7 @@ unsigned int BrowserView2::FeaturesForBrowserType(BrowserType::Type type) { void BrowserView2::Init() { // Stow a pointer to this object onto the window handle so that we can get // at it later when all we have is a HWND. - SetProp(GetViewContainer()->GetHWND(), kBrowserWindowKey, this); + SetProp(GetContainer()->GetHWND(), kBrowserWindowKey, this); LoadAccelerators(); SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); @@ -291,7 +291,7 @@ void BrowserView2::Init() { set_contents_view(contents_container_); AddChildView(contents_container_); - status_bubble_.reset(new StatusBubble(GetViewContainer())); + status_bubble_.reset(new StatusBubble(GetContainer())); #ifdef CHROME_PERSONALIZATION EnablePersonalization(CommandLine().HasSwitch(switches::kEnableP13n)); @@ -311,7 +311,7 @@ void BrowserView2::Close() { } void* BrowserView2::GetPlatformID() { - return GetViewContainer()->GetHWND(); + return GetContainer()->GetHWND(); } TabStrip* BrowserView2::GetTabStrip() const { @@ -356,7 +356,7 @@ void BrowserView2::FlashFrame() { void BrowserView2::ContinueDetachConstrainedWindowDrag( const gfx::Point& mouse_point, int frame_component) { - HWND vc_hwnd = GetViewContainer()->GetHWND(); + HWND vc_hwnd = GetContainer()->GetHWND(); if (frame_component == HTCLIENT) { // If the user's mouse was over the content area of the popup when they // clicked down, we need to re-play the mouse down event so as to actually @@ -789,7 +789,7 @@ void BrowserView2::DidChangeBounds(const CRect& previous, void BrowserView2::ViewHierarchyChanged(bool is_add, ChromeViews::View* parent, ChromeViews::View* child) { - if (is_add && child == this && GetViewContainer() && !initialized_) { + if (is_add && child == this && GetContainer() && !initialized_) { Init(); initialized_ = true; } @@ -1072,7 +1072,7 @@ void BrowserView2::LoadAccelerators() { CopyAcceleratorTable(accelerator_table, accelerators, count); ChromeViews::FocusManager* focus_manager = - ChromeViews::FocusManager::GetFocusManager(GetViewContainer()->GetHWND()); + ChromeViews::FocusManager::GetFocusManager(GetContainer()->GetHWND()); DCHECK(focus_manager); // Let's build our own accelerator table. diff --git a/chrome/browser/views/frame/opaque_frame.cc b/chrome/browser/views/frame/opaque_frame.cc index 97b9566..9bf52a3 100644 --- a/chrome/browser/views/frame/opaque_frame.cc +++ b/chrome/browser/views/frame/opaque_frame.cc @@ -63,7 +63,7 @@ void OpaqueFrame::UpdateWindowIcon() { } /////////////////////////////////////////////////////////////////////////////// -// OpaqueFrame, ChromeViews::HWNDViewContainer overrides: +// OpaqueFrame, ChromeViews::ContainerWin overrides: bool OpaqueFrame::AcceleratorPressed(ChromeViews::Accelerator* accelerator) { return browser_view_->AcceleratorPressed(*accelerator); diff --git a/chrome/browser/views/frame/opaque_frame.h b/chrome/browser/views/frame/opaque_frame.h index a30b855..f40f1a8 100644 --- a/chrome/browser/views/frame/opaque_frame.h +++ b/chrome/browser/views/frame/opaque_frame.h @@ -41,7 +41,7 @@ class OpaqueFrame : public BrowserFrame, // Overridden from ChromeViews::CustomFrameWindow: virtual void UpdateWindowIcon(); - // Overridden from ChromeViews::HWNDViewContainer: + // Overridden from ChromeViews::ContainerWin: virtual bool AcceleratorPressed(ChromeViews::Accelerator* accelerator); virtual bool GetAccelerator(int cmd_id, ChromeViews::Accelerator* accelerator); diff --git a/chrome/browser/views/frame/opaque_non_client_view.cc b/chrome/browser/views/frame/opaque_non_client_view.cc index 1bbbbfd..72b2215 100644 --- a/chrome/browser/views/frame/opaque_non_client_view.cc +++ b/chrome/browser/views/frame/opaque_non_client_view.cc @@ -660,7 +660,7 @@ void OpaqueNonClientView::ViewHierarchyChanged(bool is_add, ChromeViews::View* parent, ChromeViews::View* child) { if (is_add && child == this) { - DCHECK(GetViewContainer()); + DCHECK(GetContainer()); DCHECK(frame_->client_view()->GetParent() != this); AddChildView(frame_->client_view()); diff --git a/chrome/browser/views/hung_renderer_view.cc b/chrome/browser/views/hung_renderer_view.cc index edba957..bd0c289 100644 --- a/chrome/browser/views/hung_renderer_view.cc +++ b/chrome/browser/views/hung_renderer_view.cc @@ -321,7 +321,7 @@ void HungRendererWarningView::ButtonPressed( void HungRendererWarningView::ViewHierarchyChanged(bool is_add, ChromeViews::View* parent, ChromeViews::View* child) { - if (!initialized_ && is_add && child == this && GetViewContainer()) + if (!initialized_ && is_add && child == this && GetContainer()) Init(); } diff --git a/chrome/browser/views/hwnd_html_view.cc b/chrome/browser/views/hwnd_html_view.cc index 026ebe0..11a7225 100644 --- a/chrome/browser/views/hwnd_html_view.cc +++ b/chrome/browser/views/hwnd_html_view.cc @@ -8,7 +8,7 @@ #include "chrome/browser/render_widget_host_view_win.h" #include "chrome/browser/render_view_host_delegate.h" #include "chrome/browser/site_instance.h" -#include "chrome/views/view_container.h" +#include "chrome/views/container.h" HWNDHtmlView::~HWNDHtmlView() { if (render_view_host_) { @@ -47,6 +47,6 @@ void HWNDHtmlView::Init(HWND parent_hwnd) { void HWNDHtmlView::ViewHierarchyChanged(bool is_add, View* parent, View* child) { - if (is_add && GetViewContainer() && !initialized_) - Init(GetViewContainer()->GetHWND()); + if (is_add && GetContainer() && !initialized_) + Init(GetContainer()->GetHWND()); } diff --git a/chrome/browser/views/info_bar_item_view.cc b/chrome/browser/views/info_bar_item_view.cc index 1f1d2ab..b7c0d3b 100644 --- a/chrome/browser/views/info_bar_item_view.cc +++ b/chrome/browser/views/info_bar_item_view.cc @@ -7,10 +7,10 @@ #include "chrome/browser/views/standard_layout.h" #include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" +#include "chrome/views/container.h" #include "chrome/views/external_focus_tracker.h" #include "chrome/views/image_view.h" #include "chrome/views/root_view.h" -#include "chrome/views/view_container.h" #include "generated_resources.h" @@ -203,7 +203,7 @@ void InfoBarItemView::ViewHierarchyChanged(bool is_add, View* root_view = GetRootView(); HWND root_hwnd = NULL; if (root_view) - root_hwnd = root_view->GetViewContainer()->GetHWND(); + root_hwnd = root_view->GetContainer()->GetHWND(); if (root_hwnd) { focus_tracker_.reset(new ChromeViews::ExternalFocusTracker( diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc index 938ac49..d059af4 100644 --- a/chrome/browser/views/info_bubble.cc +++ b/chrome/browser/views/info_bubble.cc @@ -107,7 +107,7 @@ void InfoBubble::Init(HWND parent_hwnd, (win_util::GetWinVersion() < win_util::WINVERSION_XP) ? 0 : CS_DROPSHADOW); - HWNDViewContainer::Init(parent_hwnd, bounds, true); + ContainerWin::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. @@ -146,7 +146,7 @@ void InfoBubble::Close() { delegate_->InfoBubbleClosing(this); if (frame) frame->InfoBubbleClosing(); - HWNDViewContainer::Close(); + ContainerWin::Close(); } void InfoBubble::AnimationProgressed(const Animation* animation) { diff --git a/chrome/browser/views/info_bubble.h b/chrome/browser/views/info_bubble.h index e237660..bb8933b 100644 --- a/chrome/browser/views/info_bubble.h +++ b/chrome/browser/views/info_bubble.h @@ -6,7 +6,7 @@ #define CHROME_BROWSER_VIEWS_INFO_BUBBLE_H_ #include "chrome/common/slide_animation.h" -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/container_win.h" #include "chrome/views/view.h" // InfoBubble is used to display an arbitrary view above all other windows. @@ -30,7 +30,7 @@ class InfoBubbleDelegate { virtual bool CloseOnEscape() = 0; }; -class InfoBubble : public ChromeViews::HWNDViewContainer, +class InfoBubble : public ChromeViews::ContainerWin, public AnimationDelegate { public: // Shows the InfoBubble. The InfoBubble is parented to parent_hwnd, contains diff --git a/chrome/browser/views/keyword_editor_view.cc b/chrome/browser/views/keyword_editor_view.cc index fb1fd8e..a49801a 100644 --- a/chrome/browser/views/keyword_editor_view.cc +++ b/chrome/browser/views/keyword_editor_view.cc @@ -585,7 +585,7 @@ void KeywordEditorView::OnDoubleClick() { void KeywordEditorView::ButtonPressed(ChromeViews::NativeButton* sender) { if (sender == add_button_) { EditKeywordController* controller = - new EditKeywordController(GetViewContainer()->GetHWND(), NULL, this, + new EditKeywordController(GetContainer()->GetHWND(), NULL, this, profile_); controller->Show(); } else if (sender == remove_button_) { @@ -625,7 +625,7 @@ void KeywordEditorView::ButtonPressed(ChromeViews::NativeButton* sender) { const TemplateURL* template_url = &table_model_->GetTemplateURL(selected_row); EditKeywordController* controller = - new EditKeywordController(GetViewContainer()->GetHWND(), template_url, + new EditKeywordController(GetContainer()->GetHWND(), template_url, this, profile_); controller->Show(); } else if (sender == enable_suggest_checkbox_) { diff --git a/chrome/browser/views/location_bar_view.cc b/chrome/browser/views/location_bar_view.cc index 8e3a2c5..51081bd 100644 --- a/chrome/browser/views/location_bar_view.cc +++ b/chrome/browser/views/location_bar_view.cc @@ -26,8 +26,8 @@ #include "chrome/common/win_util.h" #include "chrome/views/background.h" #include "chrome/views/border.h" +#include "chrome/views/container.h" #include "chrome/views/root_view.h" -#include "chrome/views/view_container.h" #include "generated_resources.h" using ChromeViews::View; @@ -123,7 +123,7 @@ void LocationBarView::Init() { } // URL edit field. - ChromeViews::ViewContainer* vc = GetViewContainer(); + ChromeViews::Container* vc = GetContainer(); DCHECK(vc) << "LocationBarView::Init - vc is NULL!"; location_entry_.reset(new AutocompleteEditView(font_, this, model_, this, vc->GetHWND(), @@ -843,7 +843,7 @@ void LocationBarView::ShowInfoBubbleTask::Run() { if (cancelled_) return; - if (!image_view_->GetViewContainer()->IsActive()) { + if (!image_view_->GetContainer()->IsActive()) { // The browser is no longer active. Let's not show the info bubble, this // would make the browser the active window again. Also makes sure we NULL // show_info_bubble_task_ to prevent the SecurityImageView from keeping a @@ -864,7 +864,7 @@ void LocationBarView::ShowInfoBubbleTask::Cancel() { void LocationBarView::ShowFirstRunBubbleInternal() { if (!location_entry_view_) return; - if (!location_entry_view_->GetViewContainer()->IsActive()) { + if (!location_entry_view_->GetContainer()->IsActive()) { // The browser is no longer active. Let's not show the info bubble, this // would make the browser the active window again. return; @@ -889,7 +889,7 @@ void LocationBarView::ShowFirstRunBubbleInternal() { bounds.set_x(location.x() - 20); FirstRunBubble::Show( - location_entry_view_->GetRootView()->GetViewContainer()->GetHWND(), + location_entry_view_->GetRootView()->GetContainer()->GetHWND(), bounds); } @@ -962,7 +962,7 @@ void LocationBarView::SecurityImageView::ShowInfoBubble() { label->SetHorizontalAlignment(ChromeViews::Label::ALIGN_LEFT); label->SizeToFit(0); DCHECK(info_bubble_ == NULL); - info_bubble_ = InfoBubble::Show(GetRootView()->GetViewContainer()->GetHWND(), + info_bubble_ = InfoBubble::Show(GetRootView()->GetContainer()->GetHWND(), bounds, label, this); show_info_bubble_task_ = NULL; } @@ -1006,7 +1006,7 @@ bool LocationBarView::SecurityImageView::OnMousePressed( } PageInfoWindow::CreatePageInfo(profile_, nav_entry, - GetRootView()->GetViewContainer()->GetHWND(), + GetRootView()->GetContainer()->GetHWND(), PageInfoWindow::SECURITY); return true; } diff --git a/chrome/browser/views/old_frames/vista_frame.cc b/chrome/browser/views/old_frames/vista_frame.cc index fb934ad..fe1f0b4 100644 --- a/chrome/browser/views/old_frames/vista_frame.cc +++ b/chrome/browser/views/old_frames/vista_frame.cc @@ -38,7 +38,6 @@ #include "chrome/views/aero_tooltip_manager.h" #include "chrome/views/background.h" #include "chrome/views/event.h" -#include "chrome/views/hwnd_view_container.h" #include "chrome/views/hwnd_notification_source.h" #include "chromium_strings.h" @@ -468,7 +467,7 @@ void VistaFrame::Init() { FrameUtil::LoadAccelerators(this, accelerators_table, this); ShelfVisibilityChanged(); - root_view_.OnViewContainerCreated(); + root_view_.OnContainerCreated(); Layout(); } @@ -522,7 +521,7 @@ void VistaFrame::Close() { browser_->OnWindowClosing(); } else { // Empty tab strip, it's now safe to clean-up. - root_view_.OnViewContainerDestroyed(); + root_view_.OnContainerDestroyed(); NotificationService::current()->Notify( NOTIFY_WINDOW_CLOSED, Source(m_hWnd), @@ -588,7 +587,7 @@ gfx::Rect VistaFrame::GetBoundsForContentBounds(const gfx::Rect content_rect) { } gfx::Point p; - ChromeViews::View::ConvertPointToViewContainer(tab_contents_container_, &p); + ChromeViews::View::ConvertPointToContainer(tab_contents_container_, &p); CRect bounds; GetBounds(&bounds, true); @@ -1173,7 +1172,7 @@ void VistaFrame::ProcessMouseExited() { //////////////////////////////////////////////////////////////////////////////// // -// ChromeViews::ViewContainer +// ChromeViews::Container // //////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/views/old_frames/vista_frame.h b/chrome/browser/views/old_frames/vista_frame.h index b812db1..5858436 100644 --- a/chrome/browser/views/old_frames/vista_frame.h +++ b/chrome/browser/views/old_frames/vista_frame.h @@ -16,7 +16,7 @@ #include "chrome/browser/browser_window.h" #include "chrome/browser/views/old_frames/frame_view.h" #include "chrome/browser/views/status_bubble.h" -#include "chrome/views/view_container.h" +#include "chrome/views/container.h" #include "chrome/views/root_view.h" #include "chrome/views/hwnd_view.h" #include "chrome/views/image_view.h" @@ -44,7 +44,7 @@ class VistaFrame : public BrowserWindow, CWindow, CWinTraits>, - public ChromeViews::ViewContainer, + public ChromeViews::Container, public ChromeViews::AcceleratorTarget { public: // Create a new VistaFrame given the bounds and provided browser. @@ -187,7 +187,7 @@ class VistaFrame : public BrowserWindow, virtual bool IsBookmarkBarVisible() const; //////////////////////////////////////////////////////////////////////////////// - // ChromeViews::ViewContainer + // ChromeViews::Container //////////////////////////////////////////////////////////////////////////////// virtual void GetBounds(CRect *out, bool including_frame) const; diff --git a/chrome/browser/views/old_frames/xp_frame.cc b/chrome/browser/views/old_frames/xp_frame.cc index 2512f63..24f614d 100644 --- a/chrome/browser/views/old_frames/xp_frame.cc +++ b/chrome/browser/views/old_frames/xp_frame.cc @@ -37,7 +37,6 @@ #include "chrome/views/background.h" #include "chrome/views/event.h" #include "chrome/views/focus_manager.h" -#include "chrome/views/hwnd_view_container.h" #include "chrome/views/hwnd_notification_source.h" #include "chrome/views/tooltip_manager.h" #include "chrome/views/view.h" @@ -540,7 +539,7 @@ void XPFrame::Init() { FrameUtil::LoadAccelerators(this, accelerators_table, this); ShelfVisibilityChanged(); - root_view_.OnViewContainerCreated(); + root_view_.OnContainerCreated(); } TabStrip* XPFrame::CreateTabStrip(Browser* browser) { @@ -879,7 +878,7 @@ void XPFrame::Close() { } else { // Empty tab strip, it's now safe to do the final clean-up. - root_view_.OnViewContainerDestroyed(); + root_view_.OnContainerDestroyed(); NotificationService::current()->Notify( NOTIFY_WINDOW_CLOSED, Source(m_hWnd), @@ -1794,7 +1793,7 @@ void XPFrame::SetResizeCursor(ResizeMode r_mode) { //////////////////////////////////////////////////////////////////////////////// // -// ViewContainer +// Container // //////////////////////////////////////////////////////////////////////////////// @@ -1814,7 +1813,7 @@ gfx::Rect XPFrame::GetBoundsForContentBounds(const gfx::Rect content_rect) { } gfx::Point p; - ChromeViews::View::ConvertPointToViewContainer(tab_contents_container_, &p); + ChromeViews::View::ConvertPointToContainer(tab_contents_container_, &p); CRect bounds; GetBounds(&bounds, true); diff --git a/chrome/browser/views/old_frames/xp_frame.h b/chrome/browser/views/old_frames/xp_frame.h index 89df94c..b0bb8c9 100644 --- a/chrome/browser/views/old_frames/xp_frame.h +++ b/chrome/browser/views/old_frames/xp_frame.h @@ -16,8 +16,8 @@ #include "chrome/browser/browser_window.h" #include "chrome/browser/views/old_frames/frame_view.h" #include "chrome/browser/views/status_bubble.h" -#include "chrome/views/view_container.h" #include "chrome/views/button.h" +#include "chrome/views/container.h" #include "chrome/views/hwnd_view.h" #include "chrome/views/root_view.h" #include "chrome/views/image_view.h" @@ -52,7 +52,7 @@ class XPFrame : public BrowserWindow, WS_MAXIMIZEBOX | WS_CLIPCHILDREN>>, public ChromeViews::BaseButton::ButtonListener, - public ChromeViews::ViewContainer, + public ChromeViews::Container, public ChromeViews::AcceleratorTarget { public: @@ -156,7 +156,7 @@ class XPFrame : public BrowserWindow, void ButtonPressed(ChromeViews::BaseButton *sender); // - // ViewContainer + // Container virtual void GetBounds(CRect *out, bool including_frame) const; virtual void MoveToFront(bool should_activate); virtual HWND GetHWND() const; diff --git a/chrome/browser/views/options/advanced_contents_view.cc b/chrome/browser/views/options/advanced_contents_view.cc index 0c04dd8..7df768c 100644 --- a/chrome/browser/views/options/advanced_contents_view.cc +++ b/chrome/browser/views/options/advanced_contents_view.cc @@ -505,7 +505,7 @@ void ContentSection::ButtonPressed(ChromeViews::NativeButton* sender) { disable_popup_blocked_notification_pref_.SetValue(!notification_disabled); } else if (sender == gears_settings_button_) { UserMetricsRecordAction(L"Options_GearsSettings", NULL); - GearsSettingsPressed(GetAncestor(GetViewContainer()->GetHWND(), GA_ROOT)); + GearsSettingsPressed(GetAncestor(GetContainer()->GetHWND(), GA_ROOT)); } } diff --git a/chrome/browser/views/options/content_page_view.cc b/chrome/browser/views/options/content_page_view.cc index 510976a..52911a4 100644 --- a/chrome/browser/views/options/content_page_view.cc +++ b/chrome/browser/views/options/content_page_view.cc @@ -25,11 +25,11 @@ #include "chrome/common/pref_service.h" #include "chrome/common/resource_bundle.h" #include "chrome/views/checkbox.h" +#include "chrome/views/container.h" #include "chrome/views/grid_layout.h" #include "chrome/views/native_button.h" #include "chrome/views/radio_button.h" #include "chrome/views/text_field.h" -#include "chrome/views/view_container.h" #include "generated_resources.h" #include "skia/include/SkBitmap.h" @@ -127,7 +127,7 @@ gfx::Size FileDisplayArea::GetPreferredSize() { void FileDisplayArea::ViewHierarchyChanged(bool is_add, ChromeViews::View* parent, ChromeViews::View* child) { - if (!initialized_ && is_add && GetViewContainer()) + if (!initialized_ && is_add && GetContainer()) Init(); } diff --git a/chrome/browser/views/options/fonts_languages_window_view.cc b/chrome/browser/views/options/fonts_languages_window_view.cc index a93fe2c..b147d4e 100644 --- a/chrome/browser/views/options/fonts_languages_window_view.cc +++ b/chrome/browser/views/options/fonts_languages_window_view.cc @@ -75,7 +75,7 @@ gfx::Size FontsLanguagesWindowView::GetPreferredSize() { void FontsLanguagesWindowView::ViewHierarchyChanged( bool is_add, ChromeViews::View* parent, ChromeViews::View* child) { - // Can't init before we're inserted into a ViewContainer, because we require + // Can't init before we're inserted into a Container, because we require // a HWND to parent native child controls to. if (is_add && child == this) Init(); diff --git a/chrome/browser/views/options/fonts_page_view.cc b/chrome/browser/views/options/fonts_page_view.cc index 0dd8bab..7bd8836 100644 --- a/chrome/browser/views/options/fonts_page_view.cc +++ b/chrome/browser/views/options/fonts_page_view.cc @@ -26,11 +26,11 @@ #include "chrome/common/pref_service.h" #include "chrome/common/resource_bundle.h" #include "chrome/views/checkbox.h" +#include "chrome/views/container.h" #include "chrome/views/grid_layout.h" #include "chrome/views/native_button.h" #include "chrome/views/radio_button.h" #include "chrome/views/text_field.h" -#include "chrome/views/view_container.h" #include "generated_resources.h" #include "skia/include/SkBitmap.h" @@ -228,7 +228,7 @@ FontsPageView::~FontsPageView() { } void FontsPageView::ButtonPressed(ChromeViews::NativeButton* sender) { - HWND owning_hwnd = GetAncestor(GetViewContainer()->GetHWND(), GA_ROOT); + HWND owning_hwnd = GetAncestor(GetContainer()->GetHWND(), GA_ROOT); std::wstring font_name; int font_size = 0; if (sender == serif_font_change_page_button_) { diff --git a/chrome/browser/views/options/languages_page_view.cc b/chrome/browser/views/options/languages_page_view.cc index 9a22c74..240bbe3 100644 --- a/chrome/browser/views/options/languages_page_view.cc +++ b/chrome/browser/views/options/languages_page_view.cc @@ -28,12 +28,12 @@ #include "chrome/common/resource_bundle.h" #include "chrome/views/checkbox.h" #include "chrome/views/combo_box.h" +#include "chrome/views/container.h" #include "chrome/views/grid_layout.h" #include "chrome/views/native_button.h" #include "chrome/views/radio_button.h" #include "chrome/views/tabbed_pane.h" #include "chrome/views/text_field.h" -#include "chrome/views/view_container.h" #include "skia/include/SkBitmap.h" #include "unicode/uloc.h" @@ -305,7 +305,7 @@ gfx::Size AddLanguageWindowView::GetPreferredSize() { void AddLanguageWindowView::ViewHierarchyChanged( bool is_add, ChromeViews::View* parent, ChromeViews::View* child) { - // Can't init before we're inserted into a ViewContainer, because we require + // Can't init before we're inserted into a Container, because we require // a HWND to parent native child controls to. if (is_add && child == this) Init(); @@ -503,7 +503,7 @@ void LanguagesPageView::ButtonPressed(ChromeViews::NativeButton* sender) { language_table_edited_ = true; } else if (sender == add_button_) { ChromeViews::Window::CreateChromeWindow( - GetViewContainer()->GetHWND(), + GetContainer()->GetHWND(), gfx::Rect(), new AddLanguageWindowView(this, profile()))->Show(); language_table_edited_ = true; diff --git a/chrome/browser/views/options/options_page_view.cc b/chrome/browser/views/options/options_page_view.cc index d6ea955..5672397 100644 --- a/chrome/browser/views/options/options_page_view.cc +++ b/chrome/browser/views/options/options_page_view.cc @@ -7,7 +7,7 @@ #include "chrome/browser/browser_process.h" #include "chrome/browser/user_metrics.h" #include "chrome/common/pref_service.h" -#include "chrome/views/view_container.h" +#include "chrome/views/container.h" /////////////////////////////////////////////////////////////////////////////// // OptionsPageView @@ -43,7 +43,7 @@ void OptionsPageView::Observe(NotificationType type, void OptionsPageView::ViewHierarchyChanged(bool is_add, ChromeViews::View* parent, ChromeViews::View* child) { - if (!initialized_ && is_add && GetViewContainer()) { + if (!initialized_ && is_add && GetContainer()) { // It is important that this only get done _once_ otherwise we end up // duplicating the view hierarchy when tabs are switched. initialized_ = true; @@ -53,7 +53,7 @@ void OptionsPageView::ViewHierarchyChanged(bool is_add, } HWND OptionsPageView::GetRootWindow() const { - // Our ViewContainer is the TabbedPane content HWND, which is a child HWND. + // Our Container is the TabbedPane content HWND, which is a child HWND. // We need the root HWND for parenting. - return GetAncestor(GetViewContainer()->GetHWND(), GA_ROOT); + return GetAncestor(GetContainer()->GetHWND(), GA_ROOT); } diff --git a/chrome/browser/views/options/options_window_view.cc b/chrome/browser/views/options/options_window_view.cc index 57138f0..4393a7e 100644 --- a/chrome/browser/views/options/options_window_view.cc +++ b/chrome/browser/views/options/options_window_view.cc @@ -172,8 +172,8 @@ gfx::Size OptionsWindowView::GetPreferredSize() { void OptionsWindowView::ViewHierarchyChanged(bool is_add, ChromeViews::View* parent, ChromeViews::View* child) { - // Can't init before we're inserted into a ViewContainer, because we require - // a HWND to parent native child controls to. + // Can't init before we're inserted into a Container, because we require a + // HWND to parent native child controls to. if (is_add && child == this) Init(); } diff --git a/chrome/browser/views/sad_tab_view.h b/chrome/browser/views/sad_tab_view.h index f4ca7f0..2486224 100644 --- a/chrome/browser/views/sad_tab_view.h +++ b/chrome/browser/views/sad_tab_view.h @@ -15,11 +15,11 @@ // A ChromeViews::View subclass used to render the presentation of the crashed // "sad tab" in the browser window when a renderer is destroyed unnaturally. // -// Note that since this view is not (currently) part of a ViewContainer or +// Note that since this view is not (currently) part of a Container or // RootView hierarchy, it cannot respond to events or contain controls that -// do, right now it is used simply to render. Adding an extra ViewContainer to +// do, right now it is used simply to render. Adding an extra Container to // WebContents seemed like a lot of complexity. Ideally, perhaps WebContents' -// view portion would itself become a ViewContainer in the future, then event +// view portion would itself become a Container in the future, then event // processing will work. // /////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/views/shelf_item_dialog.cc b/chrome/browser/views/shelf_item_dialog.cc index f1bbeaa..306922f 100644 --- a/chrome/browser/views/shelf_item_dialog.cc +++ b/chrome/browser/views/shelf_item_dialog.cc @@ -458,7 +458,7 @@ bool ShelfItemDialog::AcceleratorPressed( window()->Close(); } else if (accelerator.GetKeyCode() == VK_RETURN) { ChromeViews::FocusManager* fm = ChromeViews::FocusManager::GetFocusManager( - GetViewContainer()->GetHWND()); + GetContainer()->GetHWND()); if (fm->GetFocusedView() == url_table_) { // Return on table behaves like a double click. OnDoubleClick(); diff --git a/chrome/browser/views/status_bubble.cc b/chrome/browser/views/status_bubble.cc index 9021634..fab001c 100644 --- a/chrome/browser/views/status_bubble.cc +++ b/chrome/browser/views/status_bubble.cc @@ -14,10 +14,9 @@ #include "chrome/common/gfx/url_elider.h" #include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" -#include "chrome/views/hwnd_view_container.h" #include "chrome/views/label.h" #include "chrome/views/root_view.h" -#include "chrome/views/view_container.h" +#include "chrome/views/container_win.h" #include "googleurl/src/gurl.h" #include "net/base/net_util.h" #include "SkPaint.h" @@ -69,8 +68,7 @@ class StatusBubble::StatusView : public ChromeViews::Label, public Animation, public AnimationDelegate { public: - StatusView(StatusBubble* status_bubble, - ChromeViews::HWNDViewContainer* popup) + StatusView(StatusBubble* status_bubble, ChromeViews::ContainerWin* popup) : Animation(kFramerate, this), status_bubble_(status_bubble), popup_(popup), @@ -154,7 +152,7 @@ class StatusBubble::StatusView : public ChromeViews::Label, StatusBubble* status_bubble_; // Handle to the HWND that contains us. - ChromeViews::HWNDViewContainer* popup_; + ChromeViews::ContainerWin* popup_; // The currently-displayed text. std::wstring text_; @@ -445,7 +443,7 @@ void StatusBubble::StatusView::Paint(ChromeCanvas* canvas) { // StatusBubble --------------------------------------------------------------- -StatusBubble::StatusBubble(ChromeViews::ViewContainer* frame) +StatusBubble::StatusBubble(ChromeViews::Container* frame) : popup_(NULL), frame_(frame), view_(NULL), @@ -467,7 +465,7 @@ StatusBubble::~StatusBubble() { void StatusBubble::Init() { if (!popup_) { - popup_ = new ChromeViews::HWNDViewContainer(); + popup_ = new ChromeViews::ContainerWin(); popup_->set_delete_on_destroy(false); if (!view_) { diff --git a/chrome/browser/views/status_bubble.h b/chrome/browser/views/status_bubble.h index c6083f1..28d189c 100644 --- a/chrome/browser/views/status_bubble.h +++ b/chrome/browser/views/status_bubble.h @@ -6,8 +6,8 @@ #define CHROME_BROWSER_VIEWS_STATUS_BUBBLE_H__ #include "base/gfx/rect.h" -#include "chrome/views/hwnd_view_container.h" -#include "chrome/views/view_container.h" +#include "chrome/views/container.h" +#include "chrome/views/container_win.h" class GURL; @@ -16,7 +16,7 @@ class GURL; // to allow users to see where hovered links point to. class StatusBubble { public: - explicit StatusBubble(ChromeViews::ViewContainer* frame); + explicit StatusBubble(ChromeViews::Container* frame); ~StatusBubble(); // Sets the bubble contents to a specific string and causes the bubble @@ -74,10 +74,10 @@ class StatusBubble { // We use a HWND for the popup so that it may float above any HWNDs in our // UI (the location bar, for example). - ChromeViews::HWNDViewContainer* popup_; + ChromeViews::ContainerWin* popup_; double opacity_; - ChromeViews::ViewContainer* frame_; + ChromeViews::Container* frame_; StatusView* view_; DISALLOW_EVIL_CONSTRUCTORS(StatusBubble); diff --git a/chrome/browser/views/tab_contents_container_view.cc b/chrome/browser/views/tab_contents_container_view.cc index 0918ccf..a8ed55a 100644 --- a/chrome/browser/views/tab_contents_container_view.cc +++ b/chrome/browser/views/tab_contents_container_view.cc @@ -13,7 +13,7 @@ #include "chrome/browser/tab_contents.h" #include "chrome/browser/view_ids.h" #include "chrome/browser/web_contents.h" -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/container.h" #include "chrome/views/root_view.h" using ChromeViews::FocusTraversable; @@ -229,8 +229,7 @@ void TabContentsContainerView::RenderViewHostChanged(RenderViewHost* old_host, // If we are focused, we need to pass the focus to the new RenderViewHost. FocusManager* focus_manager = - FocusManager::GetFocusManager(GetRootView()->GetViewContainer()-> - GetHWND()); + FocusManager::GetFocusManager(GetRootView()->GetContainer()->GetHWND()); if (focus_manager->GetFocusedView() == this) Focus(); } diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc index bb93238..b174dc8 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -273,8 +273,7 @@ void DraggedTabController::DidProcessMessage(const MSG& msg) { void DraggedTabController::InitWindowCreatePoint() { window_create_point_.SetPoint(mouse_offset_.x(), mouse_offset_.y()); Tab* first_tab = attached_tabstrip_->GetTabAt(0); - ChromeViews::View::ConvertPointToViewContainer(first_tab, - &window_create_point_); + ChromeViews::View::ConvertPointToContainer(first_tab, &window_create_point_); } gfx::Point DraggedTabController::GetWindowCreatePoint() const { @@ -386,7 +385,7 @@ void DraggedTabController::MoveTab(const gfx::Point& screen_point) { TabStrip* DraggedTabController::GetTabStripForPoint( const gfx::Point& screen_point) const { - HWND dragged_hwnd = view_->GetViewContainer()->GetHWND(); + HWND dragged_hwnd = view_->GetContainer()->GetHWND(); HWND other_hwnd = WindowFinder::WindowForPoint(screen_point, dragged_hwnd); if (!other_hwnd) return NULL; @@ -487,7 +486,7 @@ void DraggedTabController::Attach(TabStrip* attached_tabstrip, tab->SetVisible(false); // Move the corresponding window to the front. - attached_tabstrip_->GetViewContainer()->MoveToFront(true); + attached_tabstrip_->GetContainer()->MoveToFront(true); } void DraggedTabController::Detach() { @@ -679,7 +678,7 @@ void DraggedTabController::RevertDrag() { // it has been hidden. if (restore_frame) { if (!restore_bounds_.IsEmpty()) { - HWND frame_hwnd = source_tabstrip_->GetViewContainer()->GetHWND(); + HWND frame_hwnd = source_tabstrip_->GetContainer()->GetHWND(); MoveWindow(frame_hwnd, restore_bounds_.x(), restore_bounds_.y(), restore_bounds_.width(), restore_bounds_.height(), TRUE); } @@ -747,7 +746,7 @@ int DraggedTabController::NormalizeIndexToAttachedTabStrip(int index) const { void DraggedTabController::HideFrame() { // We don't actually hide the window, rather we just move it way off-screen. // If we actually hide it, we stop receiving drag events. - HWND frame_hwnd = source_tabstrip_->GetViewContainer()->GetHWND(); + HWND frame_hwnd = source_tabstrip_->GetContainer()->GetHWND(); RECT wr; GetWindowRect(frame_hwnd, &wr); MoveWindow(frame_hwnd, 0xFFFF, 0xFFFF, wr.right - wr.left, diff --git a/chrome/browser/views/tabs/dragged_tab_view.cc b/chrome/browser/views/tabs/dragged_tab_view.cc index 5b43500..2c326ba 100644 --- a/chrome/browser/views/tabs/dragged_tab_view.cc +++ b/chrome/browser/views/tabs/dragged_tab_view.cc @@ -9,7 +9,7 @@ #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/views/tabs/hwnd_photobooth.h" #include "chrome/browser/views/tabs/tab_renderer.h" -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/container_win.h" #include "skia/include/SkShader.h" const int kTransparentAlpha = 200; @@ -38,7 +38,7 @@ DraggedTabView::DraggedTabView(TabContents* datasource, renderer_->UpdateData(datasource); - container_ = new ChromeViews::HWNDViewContainer; + container_ = new ChromeViews::ContainerWin; container_->set_window_style(WS_POPUP); container_->set_window_ex_style( WS_EX_LAYERED | WS_EX_TOPMOST | WS_EX_TOOLWINDOW); @@ -106,7 +106,7 @@ void DraggedTabView::AnimateToBounds(const gfx::Rect& bounds, animation_callback_.reset(callback); RECT wr; - GetWindowRect(GetViewContainer()->GetHWND(), &wr); + GetWindowRect(GetContainer()->GetHWND(), &wr); animation_start_bounds_ = wr; animation_end_bounds_ = bounds; diff --git a/chrome/browser/views/tabs/dragged_tab_view.h b/chrome/browser/views/tabs/dragged_tab_view.h index 14ba7ec..0f4d626 100644 --- a/chrome/browser/views/tabs/dragged_tab_view.h +++ b/chrome/browser/views/tabs/dragged_tab_view.h @@ -13,7 +13,7 @@ #include "skia/include/SkBitmap.h" namespace ChromeViews { -class HWNDViewContainer; +class ContainerWin; } namespace gfx { class Point; @@ -76,7 +76,7 @@ class DraggedTabView : public ChromeViews::View, int ScaleValue(int value); // The window that contains the DraggedTabView. - ChromeViews::HWNDViewContainer* container_; + ChromeViews::ContainerWin* container_; // The renderer that paints the Tab shape. scoped_ptr renderer_; diff --git a/chrome/browser/views/tabs/hwnd_photobooth.cc b/chrome/browser/views/tabs/hwnd_photobooth.cc index a230c6b..5096565 100644 --- a/chrome/browser/views/tabs/hwnd_photobooth.cc +++ b/chrome/browser/views/tabs/hwnd_photobooth.cc @@ -6,7 +6,7 @@ #include "chrome/browser/tab_contents.h" #include "chrome/browser/views/tabs/hwnd_photobooth.h" #include "chrome/common/gfx/chrome_canvas.h" -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/container_win.h" #include "skia/include/SkBitmap.h" namespace { @@ -143,7 +143,7 @@ void HWNDPhotobooth::CreateCaptureWindow(HWND initial_hwnd) { gfx::Point window_position = GetCaptureWindowPosition(); gfx::Rect capture_bounds(window_position.x(), window_position.y(), contents_rect.Width(), contents_rect.Height()); - capture_window_ = new ChromeViews::HWNDViewContainer; + capture_window_ = new ChromeViews::ContainerWin; capture_window_->set_window_style(WS_POPUP); // WS_EX_TOOLWINDOW ensures the capture window doesn't produce a Taskbar // button. diff --git a/chrome/browser/views/tabs/hwnd_photobooth.h b/chrome/browser/views/tabs/hwnd_photobooth.h index 4de1d14..d3f79bb 100644 --- a/chrome/browser/views/tabs/hwnd_photobooth.h +++ b/chrome/browser/views/tabs/hwnd_photobooth.h @@ -10,7 +10,7 @@ class ChromeCanvas; namespace ChromeViews { -class HWNDViewContainer; +class ContainerWin; } /////////////////////////////////////////////////////////////////////////////// @@ -50,7 +50,7 @@ class HWNDPhotobooth { void CreateCaptureWindow(HWND initial_hwnd); // The nearly off-screen photo-booth layered window used to hold the HWND. - ChromeViews::HWNDViewContainer* capture_window_; + ChromeViews::ContainerWin* capture_window_; // The current HWND being captured. HWND current_hwnd_; diff --git a/chrome/browser/views/tabs/tab.cc b/chrome/browser/views/tabs/tab.cc index 8a6f205..a64a073 100644 --- a/chrome/browser/views/tabs/tab.cc +++ b/chrome/browser/views/tabs/tab.cc @@ -5,12 +5,12 @@ #include "chrome/browser/views/tabs/tab.h" #include "base/gfx/size.h" -#include "chrome/views/view_container.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/gfx/path.h" #include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" #include "chrome/views/chrome_menu.h" +#include "chrome/views/container.h" #include "chrome/views/tooltip_manager.h" #include "generated_resources.h" @@ -53,9 +53,8 @@ class TabContextMenuController : public ChromeViews::MenuDelegate { } void RunMenuAt(int x, int y) { - menu_->RunMenuAt(tab_->GetViewContainer()->GetHWND(), - gfx::Rect(x, y, 0, 0), ChromeViews::MenuItemView::TOPLEFT, - true); + menu_->RunMenuAt(tab_->GetContainer()->GetHWND(), gfx::Rect(x, y, 0, 0), + ChromeViews::MenuItemView::TOPLEFT, true); } private: diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index 7158bf0..c4e1371 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -342,10 +342,9 @@ class RemoveTabAnimation : public TabStrip::TabAnimation { } } - // When the animation completes, we send the ViewContainer a message to - // simulate a mouse moved event at the current mouse position. This tickles - // the Tab the mouse is currently over to show the "hot" state of the close - // button. + // When the animation completes, we send the Container a message to simulate + // a mouse moved event at the current mouse position. This tickles the Tab + // the mouse is currently over to show the "hot" state of the close button. void HighlightCloseButton() { if (tabstrip_->available_width_for_tabs_ == -1 || tabstrip_->IsDragSessionActive()) { @@ -356,7 +355,7 @@ class RemoveTabAnimation : public TabStrip::TabAnimation { POINT pt; GetCursorPos(&pt); - ChromeViews::ViewContainer* vc = tabstrip_->GetViewContainer(); + ChromeViews::Container* vc = tabstrip_->GetContainer(); RECT wr; GetWindowRect(vc->GetHWND(), &wr); pt.x -= wr.left; @@ -837,7 +836,7 @@ void TabStrip::TabInsertedAt(TabContents* contents, // Don't animate the first tab, it looks weird, and don't animate anything // if the containing window isn't visible yet. - if (GetTabCount() > 1 && IsWindowVisible(GetViewContainer()->GetHWND())) { + if (GetTabCount() > 1 && IsWindowVisible(GetContainer()->GetHWND())) { StartInsertTabAnimation(index); } else { Layout(); @@ -1402,7 +1401,7 @@ TabStrip::DropInfo::DropInfo(int drop_index, bool drop_before, bool point_down) : drop_index(drop_index), drop_before(drop_before), point_down(point_down) { - arrow_window = new ChromeViews::HWNDViewContainer(); + arrow_window = new ChromeViews::ContainerWin(); arrow_window->set_window_style(WS_POPUP); arrow_window->set_window_ex_style(WS_EX_TOPMOST | WS_EX_NOACTIVATE | WS_EX_LAYERED | WS_EX_TRANSPARENT); diff --git a/chrome/browser/views/tabs/tab_strip.h b/chrome/browser/views/tabs/tab_strip.h index f30f59b..b00268db 100644 --- a/chrome/browser/views/tabs/tab_strip.h +++ b/chrome/browser/views/tabs/tab_strip.h @@ -9,7 +9,7 @@ #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/views/tabs/tab.h" #include "chrome/views/button.h" -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/container_win.h" #include "chrome/views/menu.h" #include "chrome/views/view.h" @@ -342,7 +342,7 @@ class TabStrip : public ChromeViews::View, bool point_down; // Renders the drop indicator. - ChromeViews::HWNDViewContainer* arrow_window; + ChromeViews::ContainerWin* arrow_window; ChromeViews::ImageView* arrow_view; private: diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc index 63dd222..45d4354 100644 --- a/chrome/browser/views/toolbar_view.cc +++ b/chrome/browser/views/toolbar_view.cc @@ -34,9 +34,9 @@ #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" #include "chrome/common/resource_bundle.h" +#include "chrome/views/container.h" #include "chrome/views/button_dropdown.h" #include "chrome/views/hwnd_view.h" -#include "chrome/views/view_container.h" #include "chrome/views/background.h" #include "chrome/views/label.h" #include "chrome/views/tooltip_manager.h" @@ -365,8 +365,8 @@ void BrowserToolbarView::DidGainFocus() { acc_focused_view_->SetHotTracked(true); // Show the tooltip for the view that got the focus. - if (GetViewContainer()->GetTooltipManager()) { - GetViewContainer()->GetTooltipManager()-> + if (GetContainer()->GetTooltipManager()) { + GetContainer()->GetTooltipManager()-> ShowKeyboardTooltip(acc_focused_view_); } @@ -374,7 +374,7 @@ void BrowserToolbarView::DidGainFocus() { view_index = acc_focused_view_->GetID(); } - HWND hwnd = GetViewContainer()->GetHWND(); + HWND hwnd = GetContainer()->GetHWND(); // Notify Access Technology that there was a change in keyboard focus. ::NotifyWinEvent(EVENT_OBJECT_FOCUS, hwnd, OBJID_CLIENT, @@ -385,8 +385,8 @@ void BrowserToolbarView::WillLoseFocus() { // Resetting focus state. acc_focused_view_->SetHotTracked(false); // Any tooltips that are active should be hidden when toolbar loses focus. - if (GetViewContainer() && GetViewContainer()->GetTooltipManager()) - GetViewContainer()->GetTooltipManager()->HideKeyboardTooltip(); + if (GetContainer() && GetContainer()->GetTooltipManager()) + GetContainer()->GetTooltipManager()->HideKeyboardTooltip(); acc_focused_view_ = NULL; } @@ -412,8 +412,8 @@ bool BrowserToolbarView::OnKeyPressed(const ChromeViews::KeyEvent& e) { acc_focused_view_->GetID() == VIEW_ID_APP_MENU) { // If a menu button in toolbar is activated and its menu is displayed, // then active tooltip should be hidden. - if (GetViewContainer()->GetTooltipManager()) - GetViewContainer()->GetTooltipManager()->HideKeyboardTooltip(); + if (GetContainer()->GetTooltipManager()) + GetContainer()->GetTooltipManager()->HideKeyboardTooltip(); // Safe to cast, given to above view id check. static_cast(acc_focused_view_)->Activate(); if (!acc_focused_view_) { @@ -446,11 +446,11 @@ bool BrowserToolbarView::OnKeyPressed(const ChromeViews::KeyEvent& e) { // Retrieve information to generate an MSAA focus event. int view_id = acc_focused_view_->GetID(); - HWND hwnd = GetViewContainer()->GetHWND(); + HWND hwnd = GetContainer()->GetHWND(); // Show the tooltip for the view that got the focus. - if (GetViewContainer()->GetTooltipManager()) { - GetViewContainer()->GetTooltipManager()-> + if (GetContainer()->GetTooltipManager()) { + GetContainer()->GetTooltipManager()-> ShowKeyboardTooltip(GetChildViewAt(next_view)); } // Notify Access Technology that there was a change in keyboard focus. @@ -737,6 +737,6 @@ bool BrowserToolbarView::GetAcceleratorInfo(int id, return true; } // Else, we retrieve the accelerator information from the frame. - return GetViewContainer()->GetAccelerator(id, accel); + return GetContainer()->GetAccelerator(id, accel); } diff --git a/chrome/browser/views/user_data_dir_dialog.cc b/chrome/browser/views/user_data_dir_dialog.cc index 90460fb..01d181a 100644 --- a/chrome/browser/views/user_data_dir_dialog.cc +++ b/chrome/browser/views/user_data_dir_dialog.cc @@ -70,7 +70,7 @@ bool UserDataDirDialog::Accept() { std::wstring dialog_title = l10n_util::GetString( IDS_CANT_WRITE_USER_DIRECTORY_CHOOSE_DIRECTORY_BUTTON); HWND owning_hwnd = - GetAncestor(message_box_view_->GetViewContainer()->GetHWND(), GA_ROOT); + GetAncestor(message_box_view_->GetContainer()->GetHWND(), GA_ROOT); select_file_dialog_->SelectFile(SelectFileDialog::SELECT_FOLDER, dialog_title, std::wstring(), owning_hwnd, NULL); diff --git a/chrome/browser/web_contents_view_win.cc b/chrome/browser/web_contents_view_win.cc index 82380cd..4891b6f 100644 --- a/chrome/browser/web_contents_view_win.cc +++ b/chrome/browser/web_contents_view_win.cc @@ -47,7 +47,7 @@ WebContentsViewWin::~WebContentsViewWin() { void WebContentsViewWin::CreateView(HWND parent_hwnd, const gfx::Rect& initial_bounds) { set_delete_on_destroy(false); - HWNDViewContainer::Init(parent_hwnd, initial_bounds, false); + ContainerWin::Init(parent_hwnd, initial_bounds, false); // Remove the root view drop target so we can register our own. RevokeDragDrop(GetHWND()); @@ -344,7 +344,7 @@ void WebContentsViewWin::OnWindowPosChanged(WINDOWPOS* window_pos) { } void WebContentsViewWin::OnSize(UINT param, const CSize& size) { - HWNDViewContainer::OnSize(param, size); + ContainerWin::OnSize(param, size); // Hack for thinkpad touchpad driver. // Set fake scrollbars so that we can get scroll messages, diff --git a/chrome/browser/web_contents_view_win.h b/chrome/browser/web_contents_view_win.h index 459dd6e..36bcbe7 100644 --- a/chrome/browser/web_contents_view_win.h +++ b/chrome/browser/web_contents_view_win.h @@ -6,7 +6,7 @@ #define CHROME_BROWSER_WEB_CONTENTS_VIEW_WIN_H_ #include "chrome/browser/web_contents_view.h" -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/container_win.h" class InfoBarView; class InfoBarMessageView; @@ -16,7 +16,7 @@ class WebDropTarget; // Windows-specific implementation of the WebContentsView. It is a HWND that // contains all of the contents of the tab and associated child views. class WebContentsViewWin : public WebContentsView, - public ChromeViews::HWNDViewContainer { + public ChromeViews::ContainerWin { public: // The corresponding WebContents is passed in the constructor, and manages our // lifetime. This doesn't need to be the case, but is this way currently @@ -49,7 +49,7 @@ class WebContentsViewWin : public WebContentsView, private: // Windows events ------------------------------------------------------------ - // Overrides from HWNDViewContainer. + // Overrides from ContainerWin. virtual void OnDestroy(); virtual void OnHScroll(int scroll_type, short position, HWND scrollbar); virtual void OnMouseLeave(); diff --git a/chrome/common/gfx/url_elider.cc b/chrome/common/gfx/url_elider.cc index 1cc92ca..b930557 100644 --- a/chrome/common/gfx/url_elider.cc +++ b/chrome/common/gfx/url_elider.cc @@ -7,7 +7,6 @@ #include "chrome/common/gfx/url_elider.h" #include "chrome/common/pref_names.h" #include "chrome/common/pref_service.h" -#include "chrome/views/hwnd_view_container.h" #include "chrome/views/label.h" #include "googleurl/src/gurl.h" #include "net/base/escape.h" diff --git a/chrome/common/gfx/url_elider_unittest.cc b/chrome/common/gfx/url_elider_unittest.cc index 741f351..82feb80 100644 --- a/chrome/common/gfx/url_elider_unittest.cc +++ b/chrome/common/gfx/url_elider_unittest.cc @@ -5,7 +5,6 @@ #include "base/string_util.h" #include "chrome/common/gfx/chrome_font.h" #include "chrome/common/gfx/url_elider.h" -#include "chrome/views/hwnd_view_container.h" #include "chrome/views/label.h" #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/test/accessibility/accessibility_util.cc b/chrome/test/accessibility/accessibility_util.cc index 82a4121..782ee0a 100644 --- a/chrome/test/accessibility/accessibility_util.cc +++ b/chrome/test/accessibility/accessibility_util.cc @@ -21,7 +21,7 @@ static const wchar_t* kBrowserWindowKey = L"__BROWSER_WINDOW__"; static BOOL CALLBACK WindowEnumProc(HWND hwnd, LPARAM data) { std::wstring class_name = win_util::GetClassName(hwnd); - if (class_name == L"Chrome_HWNDViewContainer_0") { + if (class_name == L"Chrome_ContainerWin_0") { HANDLE window_interface = GetProp(hwnd, kBrowserWindowKey); if (window_interface) { HWND* out = reinterpret_cast(data); diff --git a/chrome/test/accessibility/constants.h b/chrome/test/accessibility/constants.h index c331a24..967de0c 100644 --- a/chrome/test/accessibility/constants.h +++ b/chrome/test/accessibility/constants.h @@ -24,7 +24,7 @@ #define CHROME_VIEWS_TEXT_FIELD_EDIT _T("ChromeViewsTextFieldEdit") #define CHROME_AUTOCOMPLETE_EDIT _T("Chrome_AutocompleteEdit") #define CHROME_VIEWS_NATIVE_CTRL_CONTNR _T("ChromeViewsNativeControlContainer") -#define CHROME_HWND_VIEW_CONTAINER _T("Chrome_HWNDViewContainer_0") +#define CHROME_HWND_VIEW_CONTAINER _T("Chrome_ContainerWin_0") #define STD_BUTTON _T("Button") #define AUTH_TITLE _T("Authentication Required - Chrome") #define CHROME_TAB_CONTENTS _T("Chrome_TabContents") diff --git a/chrome/views/SConscript b/chrome/views/SConscript index 3963a77..832db30 100644 --- a/chrome/views/SConscript +++ b/chrome/views/SConscript @@ -45,6 +45,7 @@ input_files = [ 'chrome_menu.cc', 'client_view.cc', 'combo_box.cc', + 'container_win.cc', 'custom_frame_window.cc', 'dialog_delegate.cc', 'dialog_client_view.cc', @@ -55,7 +56,6 @@ input_files = [ 'grid_layout.cc', 'group_table_view.cc', 'hwnd_view.cc', - 'hwnd_view_container.cc', 'image_view.cc', 'label.cc', 'layout_manager.cc', diff --git a/chrome/views/accessibility/view_accessibility.cc b/chrome/views/accessibility/view_accessibility.cc index af502fc..838995a 100644 --- a/chrome/views/accessibility/view_accessibility.cc +++ b/chrome/views/accessibility/view_accessibility.cc @@ -109,9 +109,9 @@ STDMETHODIMP ViewAccessibility::get_accParent(IDispatch** disp_parent) { ChromeViews::View* parent = view_->GetParent(); if (!parent) { - // This function can get called during teardown of HWNDViewContainer so - // we should bail out if we fail to get the HWND. - if (!view_->GetViewContainer() || !view_->GetViewContainer()->GetHWND()) { + // This function can get called during teardown of ContainerWin so we + // should bail out if we fail to get the HWND. + if (!view_->GetContainer() || !view_->GetContainer()->GetHWND()) { *disp_parent = NULL; return S_FALSE; } @@ -120,7 +120,7 @@ STDMETHODIMP ViewAccessibility::get_accParent(IDispatch** disp_parent) { // the default implementation, to interface with Windows' hierarchy and to // support calls from e.g. WindowFromAccessibleObject. HRESULT hr = - ::AccessibleObjectFromWindow(view_->GetViewContainer()->GetHWND(), + ::AccessibleObjectFromWindow(view_->GetContainer()->GetHWND(), OBJID_WINDOW, IID_IAccessible, reinterpret_cast(disp_parent)); diff --git a/chrome/views/aero_tooltip_manager.cc b/chrome/views/aero_tooltip_manager.cc index cf446d8..7929786 100644 --- a/chrome/views/aero_tooltip_manager.cc +++ b/chrome/views/aero_tooltip_manager.cc @@ -18,7 +18,7 @@ namespace ChromeViews { /////////////////////////////////////////////////////////////////////////////// // AeroTooltipManager, public: -AeroTooltipManager::AeroTooltipManager(ViewContainer* container, HWND parent) +AeroTooltipManager::AeroTooltipManager(Container* container, HWND parent) : TooltipManager(container, parent), initial_delay_(0) { } diff --git a/chrome/views/aero_tooltip_manager.h b/chrome/views/aero_tooltip_manager.h index 136db2e..2f2f29a 100644 --- a/chrome/views/aero_tooltip_manager.h +++ b/chrome/views/aero_tooltip_manager.h @@ -28,7 +28,7 @@ namespace ChromeViews { // TODO(glen): Resolve this with Microsoft. class AeroTooltipManager : public ChromeViews::TooltipManager { public: - AeroTooltipManager(ViewContainer* container, HWND parent); + AeroTooltipManager(Container* container, HWND parent); virtual ~AeroTooltipManager(); void OnMouse(UINT u_msg, WPARAM w_param, LPARAM l_param); diff --git a/chrome/views/bitmap_scroll_bar.cc b/chrome/views/bitmap_scroll_bar.cc index 699d986..87b1c5a 100644 --- a/chrome/views/bitmap_scroll_bar.cc +++ b/chrome/views/bitmap_scroll_bar.cc @@ -7,9 +7,9 @@ #include "base/message_loop.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/l10n_util.h" +#include "chrome/views/container.h" #include "chrome/views/menu.h" #include "chrome/views/scroll_view.h" -#include "chrome/views/view_container.h" #include "skia/include/SkBitmap.h" #include "generated_resources.h" @@ -534,14 +534,14 @@ enum ScrollBarContextMenuCommands { void BitmapScrollBar::ShowContextMenu(View* source, int x, int y, bool is_mouse_gesture) { - ViewContainer* vc = GetViewContainer(); + Container* vc = GetContainer(); CRect vc_bounds; vc->GetBounds(&vc_bounds, true); gfx::Point temp_pt(x - vc_bounds.left, y - vc_bounds.top); - View::ConvertPointFromViewContainer(this, &temp_pt); + View::ConvertPointFromContainer(this, &temp_pt); context_menu_mouse_position_ = IsHorizontal() ? temp_pt.x() : temp_pt.y(); - Menu menu(this, Menu::TOPLEFT, GetViewContainer()->GetHWND()); + Menu menu(this, Menu::TOPLEFT, GetContainer()->GetHWND()); menu.AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollHere); menu.AppendSeparator(); menu.AppendDelegateMenuItem(ScrollBarContextMenuCommand_ScrollStart); diff --git a/chrome/views/button.cc b/chrome/views/button.cc index 0cc98ae..4cc1bde 100644 --- a/chrome/views/button.cc +++ b/chrome/views/button.cc @@ -11,8 +11,8 @@ #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/l10n_util.h" #include "chrome/common/throb_animation.h" +#include "chrome/views/container.h" #include "chrome/views/event.h" -#include "chrome/views/view_container.h" #include "chrome/app/chrome_dll_resource.h" #include "generated_resources.h" diff --git a/chrome/views/button_dropdown.cc b/chrome/views/button_dropdown.cc index a2d473b..bea4001 100644 --- a/chrome/views/button_dropdown.cc +++ b/chrome/views/button_dropdown.cc @@ -7,8 +7,8 @@ #include "base/message_loop.h" #include "chrome/browser/back_forward_menu_model.h" #include "chrome/common/l10n_util.h" +#include "chrome/views/container.h" #include "chrome/views/view_menu_delegate.h" -#include "chrome/views/view_container.h" #include "generated_resources.h" @@ -49,7 +49,7 @@ bool ButtonDropDown::OnMousePressed(const ChromeViews::MouseEvent& e) { // Schedule a task that will show the menu. MessageLoop::current()->PostDelayedTask(FROM_HERE, show_menu_factory_.NewRunnableMethod(&ButtonDropDown::ShowDropDownMenu, - GetViewContainer()->GetHWND()), + GetContainer()->GetHWND()), kMenuTimerDelay); } @@ -74,7 +74,7 @@ void ButtonDropDown::OnMouseReleased(const ChromeViews::MouseEvent& e, // update the appearance synchronously. SetState(BS_PUSHED); PaintNow(); - ShowDropDownMenu(GetViewContainer()->GetHWND()); + ShowDropDownMenu(GetContainer()->GetHWND()); } } @@ -92,7 +92,7 @@ bool ButtonDropDown::OnMouseDragged(const ChromeViews::MouseEvent& e) { // it immediately. if (e.y() > y_position_on_lbuttondown_ + dragging_threshold) { show_menu_factory_.RevokeAll(); - ShowDropDownMenu(GetViewContainer()->GetHWND()); + ShowDropDownMenu(GetContainer()->GetHWND()); } } diff --git a/chrome/views/chrome_menu.cc b/chrome/views/chrome_menu.cc index 0b0d4ff..72519d5 100644 --- a/chrome/views/chrome_menu.cc +++ b/chrome/views/chrome_menu.cc @@ -21,7 +21,7 @@ #include "chrome/common/l10n_util.h" #include "chrome/common/os_exchange_data.h" #include "chrome/views/border.h" -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/container_win.h" #include "chrome/views/root_view.h" #include "generated_resources.h" @@ -517,7 +517,7 @@ class MenuSeparator : public View { class MenuHostRootView : public RootView { public: - explicit MenuHostRootView(ViewContainer* container, + explicit MenuHostRootView(Container* container, SubmenuView* submenu) : RootView(container), submenu_(submenu), @@ -623,7 +623,7 @@ class MenuHostRootView : public RootView { // DelayedClosed, which avoids timing issues with deleting the window while // capture or events are directed at it. -class MenuHost : public HWNDViewContainer { +class MenuHost : public ContainerWin { public: MenuHost(SubmenuView* submenu) : closed_(false), @@ -647,7 +647,7 @@ class MenuHost : public HWNDViewContainer { const gfx::Rect& bounds, View* contents_view, bool do_capture) { - HWNDViewContainer::Init(parent, bounds, true); + ContainerWin::Init(parent, bounds, true); SetContentsView(contents_view); // We don't want to take focus away from the hosting window. ShowWindow(SW_SHOWNA); @@ -674,11 +674,11 @@ class MenuHost : public HWNDViewContainer { GetRootView()->RemoveAllChildViews(false); closed_ = true; ReleaseCapture(); - HWNDViewContainer::Hide(); + ContainerWin::Hide(); } virtual void OnCaptureChanged(HWND hwnd) { - HWNDViewContainer::OnCaptureChanged(hwnd); + ContainerWin::OnCaptureChanged(hwnd); owns_capture_ = false; #ifdef DEBUG_MENU DLOG(INFO) << "Capture changed"; @@ -2559,7 +2559,7 @@ bool MenuController::IsMenuWindow(MenuItemView* item, HWND window) { if (!item) return false; return ((item->HasSubmenu() && item->GetSubmenu()->IsShowing() && - item->GetSubmenu()->GetViewContainer()->GetHWND() == window) || + item->GetSubmenu()->GetContainer()->GetHWND() == window) || IsMenuWindow(item->GetParentMenuItem(), window)); } diff --git a/chrome/views/chrome_menu.h b/chrome/views/chrome_menu.h index 1c49188..75bec86 100644 --- a/chrome/views/chrome_menu.h +++ b/chrome/views/chrome_menu.h @@ -19,7 +19,7 @@ namespace ChromeViews { -class HWNDViewContainer; +class ContainerWin; class MenuController; class MenuItemView; class SubmenuView; @@ -477,8 +477,8 @@ class MenuItemView : public View { // . Forwards the appropriate events to the MenuController. This allows the // MenuController to update the selection as the user moves the mouse around. // . Renders the drop indicator during a drop operation. -// . Shows and hides the window (an HWNDViewContainer) when the menu is -// shown on screen. +// . Shows and hides the window (a ContainerWin) when the menu is shown on +// screen. // // SubmenuView is itself contained in a MenuScrollViewContainer. // MenuScrollViewContainer handles showing as much of the SubmenuView as the @@ -571,7 +571,7 @@ class SubmenuView : public View { // Parent menu item. MenuItemView* parent_menu_item_; - // HWNDViewContainer subclass used to show the children. + // ContainerWin subclass used to show the children. MenuHost* host_; // If non-null, indicates a drop is in progress and drop_item is the item diff --git a/chrome/views/client_view.cc b/chrome/views/client_view.cc index 5072acd..29953cc 100644 --- a/chrome/views/client_view.cc +++ b/chrome/views/client_view.cc @@ -24,7 +24,7 @@ int ClientView::NonClientHitTest(const gfx::Point& point) { gfx::Size ClientView::GetPreferredSize() { // |contents_view_| is allowed to be NULL up until the point where this view - // is attached to a ViewContainer. + // is attached to a Container. if (contents_view_) return contents_view_->GetPreferredSize(); return gfx::Size(); @@ -32,7 +32,7 @@ gfx::Size ClientView::GetPreferredSize() { void ClientView::ViewHierarchyChanged(bool is_add, View* parent, View* child) { if (is_add && child == this) { - DCHECK(GetViewContainer()); + DCHECK(GetContainer()); DCHECK(contents_view_); // |contents_view_| must be valid now! AddChildView(contents_view_); } @@ -44,7 +44,7 @@ void ClientView::DidChangeBounds(const CRect& previous, const CRect& current) { void ClientView::Layout() { // |contents_view_| is allowed to be NULL up until the point where this view - // is attached to a ViewContainer. + // is attached to a Container. if (contents_view_) contents_view_->SetBounds(0, 0, width(), height()); } diff --git a/chrome/views/container.h b/chrome/views/container.h new file mode 100644 index 0000000..b4d6e29 --- /dev/null +++ b/chrome/views/container.h @@ -0,0 +1,85 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_VIEWS_CONTAINER_H_ +#define CHROME_VIEWS_CONTAINER_H_ + +// TODO(maruel): Remove once HWND is abstracted. +#include + +// TODO(maruel): Remove once gfx::Rect is used instead. +namespace WTL { +class CRect; +} +using WTL::CRect; + +namespace ChromeViews { + +class RootView; +class TooltipManager; +class Accelerator; + +///////////////////////////////////////////////////////////////////////////// +// +// Container interface +// +// Container is an abstract class that defines the API that should be +// implemented by a CWindow / HWND implementation in order to host a view +// hierarchy. +// +// Container wraps a hierarchy of View objects (see view.h) that implement +// painting and flexible layout within the bounds of the Container's window. +// +// The Container is responsible for handling various system events and +// forwarding them to the appropriate view. +// +///////////////////////////////////////////////////////////////////////////// + +class Container { + public: + virtual ~Container() { } + + // Returns the bounds of this container in the screen coordinate system. + // If the receiving view container is a frame which is larger than its + // client area, this method returns the client area if including_frame is + // false and the frame bounds otherwise. If the receiving view container + // is not a frame, including_frame is ignored. + virtual void GetBounds(CRect *out, bool including_frame) const = 0; + + // Moves this view container to the front of the Z-Order + // If should_activate is TRUE, the window should also become the active + // window + virtual void MoveToFront(bool should_activate) = 0; + + // Returns the Window HWND associated with this container + virtual HWND GetHWND() const = 0; + + // Forces a paint of a specified rectangle immediately. + virtual void PaintNow(const CRect& update_rect) = 0; + + // Returns the RootView contained by this container + virtual RootView* GetRootView() = 0; + + // Returns whether the view container is visible to the user + virtual bool IsVisible() = 0; + + // Returns whether the view container is the currently active window. + virtual bool IsActive() = 0; + + // Returns the TooltipManager for this Container. If this Container does not + // support tooltips, NULL is returned. + virtual TooltipManager* GetTooltipManager() { + return NULL; + } + + // Returns the accelerator given a command id. Returns false if there is + // no accelerator associated with a given id, which is a common condition. + virtual bool GetAccelerator(int cmd_id, + Accelerator* accelerator) = 0; +}; + +} // namespace ChromeViews + +#endif // CHROME_VIEWS_VIEW_CONTAINER_H_ + diff --git a/chrome/views/container_win.cc b/chrome/views/container_win.cc new file mode 100644 index 0000000..4506b80 --- /dev/null +++ b/chrome/views/container_win.cc @@ -0,0 +1,916 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/views/container_win.h" + +#include "base/gfx/native_theme.h" +#include "base/string_util.h" +#include "base/win_util.h" +#include "chrome/app/chrome_dll_resource.h" +#include "chrome/common/gfx/chrome_canvas.h" +#include "chrome/common/win_util.h" +#include "chrome/views/aero_tooltip_manager.h" +#include "chrome/views/accessibility/view_accessibility.h" +#include "chrome/views/hwnd_notification_source.h" +#include "chrome/views/root_view.h" + +namespace ChromeViews { + +static const DWORD kWindowDefaultChildStyle = + WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; +static const DWORD kWindowDefaultStyle = WS_OVERLAPPEDWINDOW; +static const DWORD kWindowDefaultExStyle = 0; + +// Property used to link the HWND to its RootView. +static const wchar_t* const kRootViewWindowProperty = L"__ROOT_VIEW__"; + +bool SetRootViewForHWND(HWND hwnd, RootView* root_view) { + return ::SetProp(hwnd, kRootViewWindowProperty, root_view) ? true : false; +} + +RootView* GetRootViewForHWND(HWND hwnd) { + return reinterpret_cast(::GetProp(hwnd, kRootViewWindowProperty)); +} + +// Used to locate the ContainerWin issuing the current Create. Only valid for +// the life of Create. +// +// This obviously assumes we only create ContainerWins from the same thread, +// which is currently the case. +static ContainerWin* instance_issuing_create = NULL; + +/////////////////////////////////////////////////////////////////////////////// +// FillLayout + +FillLayout::FillLayout() { +} + +FillLayout::~FillLayout() { +} + +void FillLayout::Layout(View* host) { + CRect bounds; + host->GetContainer()->GetBounds(&bounds, false); + if (host->GetChildViewCount() == 0) + return; + + View* frame_view = host->GetChildViewAt(0); + frame_view->SetBounds(CRect(CPoint(0, 0), bounds.Size())); +} + +gfx::Size FillLayout::GetPreferredSize(View* host) { + DCHECK(host->GetChildViewCount() == 1); + return host->GetChildViewAt(0)->GetPreferredSize(); +} + +/////////////////////////////////////////////////////////////////////////////// +// Window class tracking. + +// static +const wchar_t* const ContainerWin::kBaseClassName = + L"Chrome_ContainerWin_"; + +// Window class information used for registering unique windows. +struct ClassInfo { + UINT style; + HBRUSH background; + + explicit ClassInfo(int style) + : style(style), + background(NULL) {} + + // Compares two ClassInfos. Returns true if all members match. + bool Equals(const ClassInfo& other) { + return (other.style == style && other.background == background); + } +}; + +// Represents a registered window class. +struct RegisteredClass { + RegisteredClass(const ClassInfo& info, + const std::wstring& name, + ATOM atom) + : info(info), + name(name), + atom(atom) { + } + + // Info used to create the class. + ClassInfo info; + + // The name given to the window. + std::wstring name; + + // The ATOM returned from creating the window. + ATOM atom; +}; + +typedef std::list RegisteredClasses; + +// The list of registered classes. +static RegisteredClasses* registered_classes = NULL; + + +/////////////////////////////////////////////////////////////////////////////// +// ContainerWin, public + +ContainerWin::ContainerWin() + : active_mouse_tracking_flags_(0), + has_capture_(false), + current_action_(FA_NONE), + toplevel_(false), + window_style_(0), + window_ex_style_(kWindowDefaultExStyle), + layered_(false), + layered_alpha_(255), + delete_on_destroy_(true), + can_update_layered_window_(true), + last_mouse_event_was_move_(false), + is_mouse_down_(false), + class_style_(CS_DBLCLKS), + hwnd_(NULL), + close_container_factory_(this) { +} + +ContainerWin::~ContainerWin() { + MessageLoopForUI::current()->RemoveObserver(this); +} + +void ContainerWin::Init(HWND parent, const gfx::Rect& bounds, + bool has_own_focus_manager) { + toplevel_ = parent == NULL; + + if (window_style_ == 0) + window_style_ = toplevel_ ? kWindowDefaultStyle : kWindowDefaultChildStyle; + + // See if the style has been overridden. + opaque_ = !(window_ex_style_ & WS_EX_TRANSPARENT); + layered_ = !!(window_ex_style_ & WS_EX_LAYERED); + + // Force creation of the RootView if it hasn't been created yet. + GetRootView(); + + // Ensures the parent we have been passed is valid, otherwise CreateWindowEx + // will fail. + if (parent && !::IsWindow(parent)) { + NOTREACHED() << "invalid parent window specified."; + parent = NULL; + } + + hwnd_ = CreateWindowEx(window_ex_style_, GetWindowClassName().c_str(), L"", + window_style_, bounds.x(), bounds.y(), bounds.width(), + bounds.height(), parent, NULL, NULL, this); + DCHECK(hwnd_); + // The window procedure should have set the data for us. + DCHECK(win_util::GetWindowUserData(hwnd_) == this); + + root_view_->OnContainerCreated(); + + if (has_own_focus_manager) { + ChromeViews::FocusManager::CreateFocusManager(hwnd_, GetRootView()); + } else { + // Subclass the window so we get the tab key messages when a view with no + // associated native window is focused. + FocusManager::InstallFocusSubclass(hwnd_, NULL); + } + + // Sets the RootView as a property, so the automation can introspect windows. + SetRootViewForHWND(hwnd_, root_view_.get()); + + MessageLoopForUI::current()->AddObserver(this); + + // Windows special DWM window frame requires a special tooltip manager so + // that window controls in Chrome windows don't flicker when you move your + // mouse over them. See comment in aero_tooltip_manager.h. + if (win_util::ShouldUseVistaFrame()) { + tooltip_manager_.reset(new AeroTooltipManager(this, GetHWND())); + } else { + tooltip_manager_.reset(new TooltipManager(this, GetHWND())); + } + + // This message initializes the window so that focus border are shown for + // windows. + ::SendMessage(GetHWND(), + WM_CHANGEUISTATE, + MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), + 0); + + // Bug 964884: detach the IME attached to this window. + // We should attach IMEs only when we need to input CJK strings. + ::ImmAssociateContextEx(GetHWND(), NULL, 0); +} + +void ContainerWin::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 + // Container 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::Container implementation: + +void ContainerWin::GetBounds(CRect *out, bool including_frame) const { + if (including_frame) { + GetWindowRect(out); + } else { + GetClientRect(out); + + POINT p = {0, 0}; + ::ClientToScreen(hwnd_, &p); + + out->left += p.x; + out->top += p.y; + out->right += p.x; + out->bottom += p.y; + } +} + +void ContainerWin::MoveToFront(bool should_activate) { + int flags = SWP_NOMOVE | SWP_NOSIZE; + if (!should_activate) { + flags |= SWP_NOACTIVATE; + } + SetWindowPos(HWND_NOTOPMOST, 0, 0, 0, 0, flags); +} + +HWND ContainerWin::GetHWND() const { + return hwnd_; +} + +void ContainerWin::PaintNow(const CRect& update_rect) { + if (layered_) { + PaintLayeredWindow(); + } else if (root_view_->NeedsPainting(false) && IsWindow()) { + if (!opaque_ && GetParent()) { + // We're transparent. Need to force painting to occur from our parent. + CRect parent_update_rect = update_rect; + POINT location_in_parent = { 0, 0 }; + ClientToScreen(hwnd_, &location_in_parent); + ::ScreenToClient(GetParent(), &location_in_parent); + parent_update_rect.OffsetRect(location_in_parent); + ::RedrawWindow(GetParent(), parent_update_rect, NULL, + RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN); + } else { + RedrawWindow(hwnd_, update_rect, NULL, + RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN); + } + // As we were created with a style of WS_CLIPCHILDREN redraw requests may + // result in an empty paint rect in WM_PAINT (this'll happen if a + // child HWND completely contains the update _rect). In such a scenario + // RootView would never get a ProcessPaint and always think it needs to + // be painted (leading to a steady stream of RedrawWindow requests on every + // event). For this reason we tell RootView it doesn't need to paint + // here. + root_view_->ClearPaintRect(); + } +} + +RootView* ContainerWin::GetRootView() { + if (!root_view_.get()) { + // First time the root view is being asked for, create it now. + root_view_.reset(CreateRootView()); + } + return root_view_.get(); +} + +bool ContainerWin::IsVisible() { + return !!::IsWindowVisible(GetHWND()); +} + +bool ContainerWin::IsActive() { + return win_util::IsWindowActive(GetHWND()); +} + +TooltipManager* ContainerWin::GetTooltipManager() { + return tooltip_manager_.get(); +} + + +void ContainerWin::SetLayeredAlpha(BYTE layered_alpha) { + layered_alpha_ = layered_alpha; + +// if (hwnd_) +// UpdateWindowFromContents(contents_->getTopPlatformDevice().getBitmapDC()); +} + +static BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM l_param) { + RootView* root_view = + reinterpret_cast(GetProp(hwnd, kRootViewWindowProperty)); + if (root_view) { + *reinterpret_cast(l_param) = root_view; + return FALSE; // Stop enumerating. + } + return TRUE; // Keep enumerating. +} + +// static +RootView* ContainerWin::FindRootView(HWND hwnd) { + RootView* root_view = + reinterpret_cast(GetProp(hwnd, kRootViewWindowProperty)); + if (root_view) + return root_view; + + // Enumerate all children and check if they have a RootView. + EnumChildWindows(hwnd, EnumChildProc, reinterpret_cast(&root_view)); + + return root_view; +} + +void ContainerWin::Close() { + // Let's hide ourselves right away. + Hide(); + if (close_container_factory_.empty()) { + // And we delay the close so that if we are called from an ATL callback, + // we don't destroy the window before the callback returned (as the caller + // may delete ourselves on destroy and the ATL callback would still + // dereference us when the callback returns). + MessageLoop::current()->PostTask(FROM_HERE, + close_container_factory_.NewRunnableMethod( + &ContainerWin::CloseNow)); + } +} + +void ContainerWin::Hide() { + // NOTE: Be careful not to activate any windows here (for example, calling + // ShowWindow(SW_HIDE) will automatically activate another window). This + // code can be called while a window is being deactivated, and activating + // another window will screw up the activation that is already in progress. + SetWindowPos(NULL, 0, 0, 0, 0, + SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | + SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER); +} + +void ContainerWin::CloseNow() { + // We may already have been destroyed if the selection resulted in a tab + // switch which will have reactivated the browser window and closed us, so + // we need to check to see if we're still a window before trying to destroy + // ourself. + if (IsWindow()) + DestroyWindow(); +} + +/////////////////////////////////////////////////////////////////////////////// +// MessageLoop::Observer + +void ContainerWin::WillProcessMessage(const MSG& msg) { +} + +void ContainerWin::DidProcessMessage(const MSG& msg) { + if (root_view_->NeedsPainting(true)) { + PaintNow(root_view_->GetScheduledPaintRect()); + } +} + +/////////////////////////////////////////////////////////////////////////////// +// FocusTraversable + +View* ContainerWin::FindNextFocusableView( + View* starting_view, bool reverse, Direction direction, bool dont_loop, + FocusTraversable** focus_traversable, View** focus_traversable_view) { + return root_view_->FindNextFocusableView(starting_view, + reverse, + direction, + dont_loop, + focus_traversable, + focus_traversable_view); +} + +FocusTraversable* ContainerWin::GetFocusTraversableParent() { + // We are a proxy to the root view, so we should be bypassed when traversing + // up and as a result this should not be called. + NOTREACHED(); + return NULL; +} + +void ContainerWin::SetFocusTraversableParent(FocusTraversable* parent) { + root_view_->SetFocusTraversableParent(parent); +} + +View* ContainerWin::GetFocusTraversableParentView() { + // We are a proxy to the root view, so we should be bypassed when traversing + // up and as a result this should not be called. + NOTREACHED(); + return NULL; +} + +void ContainerWin::SetFocusTraversableParentView(View* parent_view) { + root_view_->SetFocusTraversableParentView(parent_view); +} + +/////////////////////////////////////////////////////////////////////////////// +// Message handlers + +void ContainerWin::OnCaptureChanged(HWND hwnd) { + if (has_capture_) { + if (is_mouse_down_) + root_view_->ProcessMouseDragCanceled(); + is_mouse_down_ = false; + has_capture_ = false; + } +} + +void ContainerWin::OnClose() { + // WARNING: this method is NOT called for all ContainerWins. If you need to + // do cleanup code before ContainerWin is destroyed, put it in + // OnDestroy. + + NotificationService::current()->Notify( + NOTIFY_WINDOW_CLOSED, Source(hwnd_), + NotificationService::NoDetails()); + + Close(); +} + +void ContainerWin::OnDestroy() { + root_view_->OnContainerDestroyed(); + + RemoveProp(hwnd_, kRootViewWindowProperty); +} + +LRESULT ContainerWin::OnEraseBkgnd(HDC dc) { + // This is needed for magical win32 flicker ju-ju + return 1; +} + +LRESULT ContainerWin::OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param) { + LRESULT reference_result = static_cast(0L); + + // Accessibility readers will send an OBJID_CLIENT message + if (OBJID_CLIENT == l_param) { + // If our MSAA root is already created, reuse that pointer. Otherwise, + // create a new one. + if (!accessibility_root_) { + CComObject* instance = NULL; + + HRESULT hr = CComObject::CreateInstance(&instance); + DCHECK(SUCCEEDED(hr)); + + if (!instance) { + // Return with failure. + return static_cast(0L); + } + + CComPtr accessibility_instance(instance); + + if (!SUCCEEDED(instance->Initialize(root_view_.get()))) { + // Return with failure. + return static_cast(0L); + } + + // All is well, assign the temp instance to the class smart pointer + accessibility_root_.Attach(accessibility_instance.Detach()); + + if (!accessibility_root_) { + // Return with failure. + return static_cast(0L); + } + + // Notify that an instance of IAccessible was allocated for m_hWnd + ::NotifyWinEvent(EVENT_OBJECT_CREATE, GetHWND(), OBJID_CLIENT, + CHILDID_SELF); + } + + // Create a reference to ViewAccessibility that MSAA will marshall + // to the client. + reference_result = LresultFromObject(IID_IAccessible, w_param, + static_cast(accessibility_root_)); + } + return reference_result; +} + +void ContainerWin::OnKeyDown(TCHAR c, UINT rep_cnt, UINT flags) { + KeyEvent event(Event::ET_KEY_PRESSED, c, rep_cnt, flags); + root_view_->ProcessKeyEvent(event); +} + +void ContainerWin::OnKeyUp(TCHAR c, UINT rep_cnt, UINT flags) { + KeyEvent event(Event::ET_KEY_RELEASED, c, rep_cnt, flags); + root_view_->ProcessKeyEvent(event); +} + +void ContainerWin::OnLButtonDown(UINT flags, const CPoint& point) { + ProcessMousePressed(point, flags | MK_LBUTTON, false); +} + +void ContainerWin::OnLButtonUp(UINT flags, const CPoint& point) { + ProcessMouseReleased(point, flags | MK_LBUTTON); +} + +void ContainerWin::OnLButtonDblClk(UINT flags, const CPoint& point) { + ProcessMousePressed(point, flags | MK_LBUTTON, true); +} + +void ContainerWin::OnMButtonDown(UINT flags, const CPoint& point) { + ProcessMousePressed(point, flags | MK_MBUTTON, false); +} + +void ContainerWin::OnMButtonUp(UINT flags, const CPoint& point) { + ProcessMouseReleased(point, flags | MK_MBUTTON); +} + +void ContainerWin::OnMButtonDblClk(UINT flags, const CPoint& point) { + ProcessMousePressed(point, flags | MK_MBUTTON, true); +} + +LRESULT ContainerWin::OnMouseActivate(HWND window, UINT hittest_code, + UINT message) { + SetMsgHandled(FALSE); + return MA_ACTIVATE; +} + +void ContainerWin::OnMouseMove(UINT flags, const CPoint& point) { + ProcessMouseMoved(point, flags, false); +} + +LRESULT ContainerWin::OnMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param) { + ProcessMouseExited(); + return 0; +} + +LRESULT ContainerWin::OnMouseWheel(UINT flags, short distance, + const CPoint& point) { + MouseWheelEvent e(distance, + point.x, + point.y, + Event::ConvertWindowsFlags(flags)); + return root_view_->ProcessMouseWheelEvent(e) ? 0 : 1; +} + +LRESULT ContainerWin::OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param) { + tooltip_manager_->OnMouse(msg, w_param, l_param); + SetMsgHandled(FALSE); + return 0; +} + +void ContainerWin::OnNCLButtonDblClk(UINT flags, const CPoint& point) { + SetMsgHandled(FALSE); +} + +void ContainerWin::OnNCLButtonDown(UINT flags, const CPoint& point) { + SetMsgHandled(FALSE); +} + +void ContainerWin::OnNCLButtonUp(UINT flags, const CPoint& point) { + SetMsgHandled(FALSE); +} + +LRESULT ContainerWin::OnNCMouseLeave(UINT uMsg, WPARAM w_param, + LPARAM l_param) { + ProcessMouseExited(); + return 0; +} + +LRESULT ContainerWin::OnNCMouseMove(UINT flags, const CPoint& point) { + // NC points are in screen coordinates. + CPoint temp = point; + MapWindowPoints(HWND_DESKTOP, GetHWND(), &temp, 1); + ProcessMouseMoved(temp, 0, true); + + // We need to process this message to stop Windows from drawing the window + // controls as the mouse moves over the title bar area when the window is + // maximized. + return 0; +} + +void ContainerWin::OnNCRButtonDblClk(UINT flags, const CPoint& point) { + SetMsgHandled(FALSE); +} + +void ContainerWin::OnNCRButtonDown(UINT flags, const CPoint& point) { + SetMsgHandled(FALSE); +} + +void ContainerWin::OnNCRButtonUp(UINT flags, const CPoint& point) { + SetMsgHandled(FALSE); +} + +LRESULT ContainerWin::OnNotify(int w_param, NMHDR* l_param) { + // We can be sent this message before the tooltip manager is created, if a + // subclass overrides OnCreate and creates some kind of Windows control there + // that sends WM_NOTIFY messages. + if (tooltip_manager_.get()) { + bool handled; + LRESULT result = tooltip_manager_->OnNotify(w_param, l_param, &handled); + SetMsgHandled(handled); + return result; + } + SetMsgHandled(FALSE); + return 0; +} + +void ContainerWin::OnPaint(HDC dc) { + root_view_->OnPaint(GetHWND()); +} + +void ContainerWin::OnRButtonDown(UINT flags, const CPoint& point) { + ProcessMousePressed(point, flags | MK_RBUTTON, false); +} + +void ContainerWin::OnRButtonUp(UINT flags, const CPoint& point) { + ProcessMouseReleased(point, flags | MK_RBUTTON); +} + +void ContainerWin::OnRButtonDblClk(UINT flags, const CPoint& point) { + ProcessMousePressed(point, flags | MK_RBUTTON, true); +} + +LRESULT ContainerWin::OnSettingChange(UINT msg, WPARAM w_param, + LPARAM l_param) { + if (toplevel_) { + SetMsgHandled(FALSE); + if (w_param != SPI_SETWORKAREA) + return 0; // Return value is effectively ignored in atlwin.h. + + AdjustWindowToFitScreenSize(); + SetMsgHandled(TRUE); + } + // Don't care, overridden by interested subclasses + return 0; +} + +void ContainerWin::OnSize(UINT param, const CSize& size) { + ChangeSize(param, size); +} + +void ContainerWin::OnThemeChanged() { + // Notify NativeTheme. + gfx::NativeTheme::instance()->CloseHandles(); +} + +void ContainerWin::OnFinalMessage(HWND window) { + if (delete_on_destroy_) + delete this; +} + +/////////////////////////////////////////////////////////////////////////////// +// ContainerWin, protected: + +void ContainerWin::TrackMouseEvents(DWORD mouse_tracking_flags) { + // Begin tracking mouse events for this HWND so that we get WM_MOUSELEAVE + // when the user moves the mouse outside this HWND's bounds. + if (active_mouse_tracking_flags_ == 0 || mouse_tracking_flags & TME_CANCEL) { + if (mouse_tracking_flags & TME_CANCEL) { + // We're about to cancel active mouse tracking, so empty out the stored + // state. + active_mouse_tracking_flags_ = 0; + } else { + active_mouse_tracking_flags_ = mouse_tracking_flags; + } + + TRACKMOUSEEVENT tme; + tme.cbSize = sizeof(tme); + tme.dwFlags = mouse_tracking_flags; + tme.hwndTrack = GetHWND(); + tme.dwHoverTime = 0; + TrackMouseEvent(&tme); + } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { + TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); + TrackMouseEvents(mouse_tracking_flags); + } +} + +bool ContainerWin::ProcessMousePressed(const CPoint& point, UINT flags, + bool dbl_click) { + last_mouse_event_was_move_ = false; + MouseEvent mouse_pressed(Event::ET_MOUSE_PRESSED, + point.x, + point.y, + (dbl_click ? MouseEvent::EF_IS_DOUBLE_CLICK : 0) | + Event::ConvertWindowsFlags(flags)); + if (root_view_->OnMousePressed(mouse_pressed)) { + is_mouse_down_ = true; + if (!has_capture_) { + SetCapture(); + has_capture_ = true; + current_action_ = FA_FORWARDING; + } + return true; + } + return false; +} + +void ContainerWin::ProcessMouseDragged(const CPoint& point, UINT flags) { + last_mouse_event_was_move_ = false; + MouseEvent mouse_drag(Event::ET_MOUSE_DRAGGED, + point.x, + point.y, + Event::ConvertWindowsFlags(flags)); + root_view_->OnMouseDragged(mouse_drag); +} + +void ContainerWin::ProcessMouseReleased(const CPoint& point, UINT flags) { + last_mouse_event_was_move_ = false; + MouseEvent mouse_up(Event::ET_MOUSE_RELEASED, + point.x, + point.y, + Event::ConvertWindowsFlags(flags)); + // Release the capture first, that way we don't get confused if + // OnMouseReleased blocks. + if (has_capture_ && ReleaseCaptureOnMouseReleased()) { + has_capture_ = false; + current_action_ = FA_NONE; + ReleaseCapture(); + } + is_mouse_down_ = false; + root_view_->OnMouseReleased(mouse_up, false); +} + +void ContainerWin::ProcessMouseMoved(const CPoint &point, UINT flags, + bool is_nonclient) { + // Windows only fires WM_MOUSELEAVE events if the application begins + // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events. + // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE. + if (!has_capture_) + TrackMouseEvents(is_nonclient ? TME_NONCLIENT | TME_LEAVE : TME_LEAVE); + if (has_capture_ && is_mouse_down_) { + ProcessMouseDragged(point, flags); + } else { + gfx::Point screen_loc(point); + View::ConvertPointToScreen(root_view_.get(), &screen_loc); + if (last_mouse_event_was_move_ && last_mouse_move_x_ == screen_loc.x() && + last_mouse_move_y_ == screen_loc.y()) { + // Don't generate a mouse event for the same location as the last. + return; + } + last_mouse_move_x_ = screen_loc.x(); + last_mouse_move_y_ = screen_loc.y(); + last_mouse_event_was_move_ = true; + MouseEvent mouse_move(Event::ET_MOUSE_MOVED, + point.x, + point.y, + Event::ConvertWindowsFlags(flags)); + root_view_->OnMouseMoved(mouse_move); + } +} + +void ContainerWin::ProcessMouseExited() { + last_mouse_event_was_move_ = false; + root_view_->ProcessOnMouseExited(); + // Reset our tracking flag so that future mouse movement over this + // ContainerWin results in a new tracking session. + active_mouse_tracking_flags_ = 0; +} + +void ContainerWin::AdjustWindowToFitScreenSize() { + // Desktop size has changed. Make sure we're still on screen. + CRect wr; + GetWindowRect(&wr); + HMONITOR hmon = MonitorFromRect(&wr, MONITOR_DEFAULTTONEAREST); + if (!hmon) { + // No monitor available. + return; + } + + MONITORINFO mi; + mi.cbSize = sizeof(mi); + GetMonitorInfo(hmon, &mi); + gfx::Rect window_rect(wr); + gfx::Rect monitor_rect(mi.rcWork); + gfx::Rect new_window_rect = window_rect.AdjustToFit(monitor_rect); + if (!new_window_rect.Equals(window_rect)) { + // New position differs from last, resize window. + ::SetWindowPos(GetHWND(), + 0, + new_window_rect.x(), + new_window_rect.y(), + new_window_rect.width(), + new_window_rect.height(), + SWP_NOACTIVATE | SWP_NOZORDER); + } +} + +void ContainerWin::ChangeSize(UINT size_param, const CSize& size) { + CRect rect; + if (layered_) { + GetWindowRect(&rect); + SizeContents(rect); + } else { + GetClientRect(&rect); + } + + // Resizing changes the size of the view hierarchy and thus forces a + // complete relayout. + root_view_->SetBounds(CRect(CPoint(0,0), rect.Size())); + root_view_->Layout(); + root_view_->SchedulePaint(); + + if (layered_) + PaintNow(rect); +} + +RootView* ContainerWin::CreateRootView() { + return new RootView(this); +} + +/////////////////////////////////////////////////////////////////////////////// +// ContainerWin, private: + +void ContainerWin::SizeContents(const CRect& window_rect) { + contents_.reset(new ChromeCanvas(window_rect.Width(), + window_rect.Height(), + false)); +} + +void ContainerWin::PaintLayeredWindow() { + // Painting monkeys with our cliprect, so we need to save it so that the + // call to UpdateLayeredWindow updates the entire window, not just the + // cliprect. + contents_->save(SkCanvas::kClip_SaveFlag); + CRect dirty_rect = root_view_->GetScheduledPaintRect(); + contents_->ClipRectInt( + dirty_rect.left, dirty_rect.top, dirty_rect.Width(), dirty_rect.Height()); + root_view_->ProcessPaint(contents_.get()); + contents_->restore(); + + UpdateWindowFromContents(contents_->getTopPlatformDevice().getBitmapDC()); +} + +void ContainerWin::UpdateWindowFromContents(HDC dib_dc) { + DCHECK(layered_); + if (can_update_layered_window_) { + CRect wr; + GetWindowRect(&wr); + CSize size(wr.right - wr.left, wr.bottom - wr.top); + CPoint zero_origin(0, 0); + CPoint window_position = wr.TopLeft(); + + BLENDFUNCTION blend = {AC_SRC_OVER, 0, layered_alpha_, AC_SRC_ALPHA}; + ::UpdateLayeredWindow( + hwnd_, NULL, &window_position, &size, dib_dc, &zero_origin, + RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA); + } +} + +std::wstring ContainerWin::GetWindowClassName() { + if (!registered_classes) + registered_classes = new RegisteredClasses(); + ClassInfo class_info(initial_class_style()); + for (RegisteredClasses::iterator i = registered_classes->begin(); + i != registered_classes->end(); ++i) { + if (class_info.Equals(i->info)) + return i->name; + } + + // No class found, need to register one. + static int registered_count = 0; + std::wstring name = + std::wstring(kBaseClassName) + IntToWString(registered_count++); + WNDCLASSEX class_ex; + class_ex.cbSize = sizeof(WNDCLASSEX); + class_ex.style = class_info.style; + class_ex.lpfnWndProc = &ContainerWin::WndProc; + class_ex.cbClsExtra = 0; + class_ex.cbWndExtra = 0; + class_ex.hInstance = NULL; + class_ex.hIcon = LoadIcon(GetModuleHandle(L"chrome.dll"), + MAKEINTRESOURCE(IDR_MAINFRAME)); + class_ex.hCursor = LoadCursor(NULL, IDC_ARROW); + class_ex.hbrBackground = reinterpret_cast(class_info.background + 1); + class_ex.lpszMenuName = NULL; + class_ex.lpszClassName = name.c_str(); + class_ex.hIconSm = class_ex.hIcon; + ATOM atom = RegisterClassEx(&class_ex); + DCHECK(atom); + RegisteredClass registered_class(class_info, name, atom); + registered_classes->push_back(registered_class); + return name; +} + +// static +LRESULT CALLBACK ContainerWin::WndProc(HWND window, UINT message, + WPARAM w_param, LPARAM l_param) { + if (message == WM_NCCREATE) { + CREATESTRUCT* cs = reinterpret_cast(l_param); + ContainerWin* vc = + reinterpret_cast(cs->lpCreateParams); + DCHECK(vc); + win_util::SetWindowUserData(window, vc); + vc->hwnd_ = window; + return TRUE; + } + ContainerWin* vc = reinterpret_cast( + win_util::GetWindowUserData(window)); + if (!vc) + return 0; + LRESULT result = 0; + if (!vc->ProcessWindowMessage(window, message, w_param, l_param, result)) + result = DefWindowProc(window, message, w_param, l_param); + if (message == WM_NCDESTROY) { + vc->hwnd_ = NULL; + vc->OnFinalMessage(window); + } + return result; +} + +} // namespace ChromeViews + diff --git a/chrome/views/container_win.h b/chrome/views/container_win.h new file mode 100644 index 0000000..0a8861a --- /dev/null +++ b/chrome/views/container_win.h @@ -0,0 +1,586 @@ +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_VIEWS_CONTAINER_WIN_H_ +#define CHROME_VIEWS_CONTAINER_WIN_H_ + +#include +#include + +#include "base/message_loop.h" +#include "chrome/views/focus_manager.h" +#include "chrome/views/layout_manager.h" +#include "chrome/views/container.h" + +class ChromeCanvas; + +namespace gfx { +class Rect; +} + +namespace ChromeViews { + +class RootView; +class TooltipManager; + +bool SetRootViewForHWND(HWND hwnd, RootView* root_view); +RootView* GetRootViewForHWND(HWND hwnd); + +// A Windows message reflected from other windows. This message is sent +// with the following arguments: +// hWnd - Target window +// uMsg - kReflectedMessage +// wParam - Should be 0 +// lParam - Pointer to MSG struct containing the original message. +static const int kReflectedMessage = WM_APP + 3; + +// These two messages aren't defined in winuser.h, but they are sent to windows +// with captions. They appear to paint the window caption and frame. +// Unfortunately if you override the standard non-client rendering as we do +// with CustomFrameWindow, sometimes Windows (not deterministically +// reproducibly but definitely frequently) will send these messages to the +// window and paint the standard caption/title over the top of the custom one. +// So we need to handle these messages in CustomFrameWindow to prevent this +// from happening. +static const int WM_NCUAHDRAWCAPTION = 0xAE; +static const int WM_NCUAHDRAWFRAME = 0xAF; + +/////////////////////////////////////////////////////////////////////////////// +// +// FillLayout +// A simple LayoutManager that causes the associated view's one child to be +// sized to match the bounds of its parent. +// +/////////////////////////////////////////////////////////////////////////////// +class FillLayout : public LayoutManager { + public: + FillLayout(); + virtual ~FillLayout(); + + // Overridden from LayoutManager: + virtual void Layout(View* host); + virtual gfx::Size GetPreferredSize(View* host); + + private: + DISALLOW_EVIL_CONSTRUCTORS(FillLayout); +}; + +/////////////////////////////////////////////////////////////////////////////// +// +// ContainerWin +// A container for a ChromeViews hierarchy used to represent anything that can +// be contained within an HWND, e.g. a control, a window, etc. Specializations +// suitable for specific tasks, e.g. top level window, are derived from this. +// +// This Container contains a RootView which owns the hierarchy of ChromeViews +// within it. As long as ChromeViews are part of this tree, they will be +// deleted automatically when the RootView is destroyed. If you remove a view +// from the tree, you are then responsible for cleaning up after it. +// +// Note: We try and keep this API platform-neutral, since to some extent we +// consider this the boundary between the platform and potentially cross +// platform ChromeViews code. In some cases this isn't true, primarily +// because of other code that has not yet been refactored to maintain +// this -- separation. +// +/////////////////////////////////////////////////////////////////////////////// +class ContainerWin : public Container, + public MessageLoopForUI::Observer, + public FocusTraversable, + public AcceleratorTarget { + public: + ContainerWin(); + virtual ~ContainerWin(); + + // Initialize the container with a parent and an initial desired size. + // |contents_view| is the view that will be the single child of RootView + // within this Container. As contents_view is inserted into RootView's tree, + // RootView assumes ownership of this view and cleaning it up. If you remove + // this view, you are responsible for its destruction. If this value is NULL, + // the caller is responsible for populating the RootView, and sizing its + // contents as the window is sized. + // If |has_own_focus_manager| is true, the focus traversal stay confined to + // the window. + void Init(HWND parent, + const gfx::Rect& bounds, + bool has_own_focus_manager); + + // Sets the specified view as the contents of this Container. There can only + // be one contnets view child of this Container'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; } + DWORD window_style() const { return window_style_; } + + // Sets the extended window styles. See comment about |set_window_style|. + void set_window_ex_style(DWORD style) { window_ex_style_ = style; } + DWORD window_ex_style() const { return window_ex_style_; }; + + // Sets the class style to use. The default is CS_DBLCLKS. + void set_initial_class_style(UINT class_style) { + // We dynamically generate the class name, so don't register it globally! + DCHECK((class_style & CS_GLOBALCLASS) == 0); + class_style_ = class_style; + } + UINT initial_class_style() { return class_style_; } + + void set_delete_on_destroy(bool delete_on_destroy) { + delete_on_destroy_ = delete_on_destroy; + } + + // Sets the initial opacity of a layered window, or updates the window's + // opacity if it is on the screen. + void SetLayeredAlpha(BYTE layered_alpha); + + // Disable Layered Window updates by setting to false. + void set_can_update_layered_window(bool can_update_layered_window) { + can_update_layered_window_ = can_update_layered_window; + } + + // Returns the RootView associated with the specified HWND (if any). + static RootView* FindRootView(HWND hwnd); + + // Closes the window asynchronously by scheduling a task for it. The window + // is destroyed as a result. + // This invokes Hide to hide the window, and schedules a task that + // invokes CloseNow. + virtual void Close(); + + // Hides the window. This does NOT delete the window, it just hides it. + virtual void Hide(); + + // Closes the window synchronously. Note that this should not be called from + // an ATL message callback as it deletes the ContainerWin and ATL will + // dereference it after the callback is processed. + void CloseNow(); + + // All classes registered by ContainerWin start with this name. + static const wchar_t* const kBaseClassName; + + BEGIN_MSG_MAP_EX(0) + // Range handlers must go first! + MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) + MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE, WM_NCMOUSEMOVE, OnMouseRange) + MESSAGE_RANGE_HANDLER_EX(WM_SETTINGCHANGE, WM_SETTINGCHANGE, OnSettingChange) + + // Reflected message handler + MESSAGE_HANDLER_EX(kReflectedMessage, OnReflectedMessage) + + // CustomFrameWindow hacks + MESSAGE_HANDLER_EX(WM_NCUAHDRAWCAPTION, OnNCUAHDrawCaption) + MESSAGE_HANDLER_EX(WM_NCUAHDRAWFRAME, OnNCUAHDrawFrame) + + // Non-atlcrack.h handlers + MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject) + MESSAGE_HANDLER_EX(WM_NCMOUSELEAVE, OnNCMouseLeave) + MESSAGE_HANDLER_EX(WM_MOUSELEAVE, OnMouseLeave) + + // This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU. + MSG_WM_ACTIVATE(OnActivate) + MSG_WM_APPCOMMAND(OnAppCommand) + MSG_WM_CANCELMODE(OnCancelMode) + MSG_WM_CAPTURECHANGED(OnCaptureChanged) + MSG_WM_CLOSE(OnClose) + MSG_WM_COMMAND(OnCommand) + MSG_WM_CREATE(OnCreate) + MSG_WM_DESTROY(OnDestroy) + MSG_WM_ERASEBKGND(OnEraseBkgnd) + MSG_WM_ENDSESSION(OnEndSession) + MSG_WM_EXITMENULOOP(OnExitMenuLoop) + MSG_WM_GETMINMAXINFO(OnGetMinMaxInfo) + MSG_WM_HSCROLL(OnHScroll) + MSG_WM_INITMENU(OnInitMenu) + MSG_WM_INITMENUPOPUP(OnInitMenuPopup) + MSG_WM_KEYDOWN(OnKeyDown) + MSG_WM_KEYUP(OnKeyUp) + MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk) + MSG_WM_LBUTTONDOWN(OnLButtonDown) + MSG_WM_LBUTTONUP(OnLButtonUp) + MSG_WM_MBUTTONDOWN(OnMButtonDown) + MSG_WM_MBUTTONUP(OnMButtonUp) + MSG_WM_MBUTTONDBLCLK(OnMButtonDblClk) + MSG_WM_MOUSEACTIVATE(OnMouseActivate) + MSG_WM_MOUSEMOVE(OnMouseMove) + MSG_WM_MOUSEWHEEL(OnMouseWheel) + MSG_WM_MOVE(OnMove) + MSG_WM_MOVING(OnMoving) + MSG_WM_NCACTIVATE(OnNCActivate) + MSG_WM_NCCALCSIZE(OnNCCalcSize) + MSG_WM_NCHITTEST(OnNCHitTest) + MSG_WM_NCMOUSEMOVE(OnNCMouseMove) + MSG_WM_NCLBUTTONDBLCLK(OnNCLButtonDblClk) + MSG_WM_NCLBUTTONDOWN(OnNCLButtonDown) + MSG_WM_NCLBUTTONUP(OnNCLButtonUp) + MSG_WM_NCPAINT(OnNCPaint) + MSG_WM_NCRBUTTONDBLCLK(OnNCRButtonDblClk) + MSG_WM_NCRBUTTONDOWN(OnNCRButtonDown) + MSG_WM_NCRBUTTONUP(OnNCRButtonUp) + MSG_WM_NOTIFY(OnNotify) + MSG_WM_PAINT(OnPaint) + MSG_WM_POWERBROADCAST(OnPowerBroadcast) + MSG_WM_RBUTTONDBLCLK(OnRButtonDblClk) + MSG_WM_RBUTTONDOWN(OnRButtonDown) + MSG_WM_RBUTTONUP(OnRButtonUp) + MSG_WM_SETCURSOR(OnSetCursor) + MSG_WM_SETFOCUS(OnSetFocus) + MSG_WM_SETICON(OnSetIcon) + MSG_WM_SETTEXT(OnSetText) + MSG_WM_SIZE(OnSize) + MSG_WM_SYSCOMMAND(OnSysCommand) + MSG_WM_THEMECHANGED(OnThemeChanged) + MSG_WM_VSCROLL(OnVScroll) + MSG_WM_WINDOWPOSCHANGED(OnWindowPosChanged) + END_MSG_MAP() + + // Overridden from Container: + virtual void GetBounds(CRect *out, bool including_frame) const; + virtual void MoveToFront(bool should_activate); + virtual HWND GetHWND() const; + virtual void PaintNow(const CRect& update_rect); + virtual RootView* GetRootView(); + virtual bool IsVisible(); + virtual bool IsActive(); + virtual TooltipManager* GetTooltipManager(); + + // Overridden from MessageLoop::Observer: + void WillProcessMessage(const MSG& msg); + virtual void DidProcessMessage(const MSG& msg); + + // Overridden from FocusTraversable: + virtual View* FindNextFocusableView(View* starting_view, + bool reverse, + Direction direction, + bool dont_loop, + FocusTraversable** focus_traversable, + View** focus_traversable_view); + virtual FocusTraversable* GetFocusTraversableParent(); + virtual View* GetFocusTraversableParentView(); + + // Overridden from AcceleratorTarget: + virtual bool AcceleratorPressed(const Accelerator& accelerator) { + return false; + } + + void SetFocusTraversableParent(FocusTraversable* parent); + void SetFocusTraversableParentView(View* parent_view); + + virtual bool GetAccelerator(int cmd_id, + ChromeViews::Accelerator* accelerator) { + return false; + } + + BOOL IsWindow() const { + return ::IsWindow(GetHWND()); + } + + BOOL ShowWindow(int command) { + DCHECK(::IsWindow(GetHWND())); + return ::ShowWindow(GetHWND(), command); + } + + HWND SetCapture() { + DCHECK(::IsWindow(GetHWND())); + return ::SetCapture(GetHWND()); + } + + HWND GetParent() const { + return ::GetParent(GetHWND()); + } + + BOOL GetWindowRect(RECT* rect) const { + return ::GetWindowRect(GetHWND(), rect); + } + + BOOL SetWindowPos(HWND hwnd_after, int x, int y, int cx, int cy, UINT flags) { + DCHECK(::IsWindow(GetHWND())); + return ::SetWindowPos(GetHWND(), hwnd_after, x, y, cx, cy, flags); + } + + BOOL IsZoomed() const { + DCHECK(::IsWindow(GetHWND())); + return ::IsZoomed(GetHWND()); + } + + BOOL MoveWindow(int x, int y, int width, int height) { + return MoveWindow(x, y, width, height, TRUE); + } + + BOOL MoveWindow(int x, int y, int width, int height, BOOL repaint) { + DCHECK(::IsWindow(GetHWND())); + return ::MoveWindow(GetHWND(), x, y, width, height, repaint); + } + + int SetWindowRgn(HRGN region, BOOL redraw) { + DCHECK(::IsWindow(GetHWND())); + return ::SetWindowRgn(GetHWND(), region, redraw); + } + + BOOL GetClientRect(RECT* rect) const { + DCHECK(::IsWindow(GetHWND())); + return ::GetClientRect(GetHWND(), rect); + } + + protected: + + // Call close instead of this to Destroy the window. + BOOL DestroyWindow() { + DCHECK(::IsWindow(GetHWND())); + return ::DestroyWindow(GetHWND()); + } + + // Message Handlers + // These are all virtual so that specialized view containers can modify or + // augment processing. + // This list is in _ALPHABETICAL_ order! + // Note: in the base class these functions must do nothing but convert point + // coordinates to client coordinates (if necessary) and forward the + // handling to the appropriate Process* function. This is so that + // subclasses can easily override these methods to do different things + // and have a convenient function to call to get the default behavior. + virtual void OnActivate(UINT action, BOOL minimized, HWND window) { } + virtual LRESULT OnAppCommand(HWND window, short app_command, WORD device, + int keystate) { + SetMsgHandled(FALSE); + return 0; + } + virtual void OnCancelMode() {} + virtual void OnCaptureChanged(HWND hwnd); + virtual void OnClose(); + virtual void OnCommand( + UINT notification_code, int command_id, HWND window) { SetMsgHandled(FALSE); } + virtual LRESULT OnCreate(LPCREATESTRUCT create_struct) { return 0; } + // WARNING: If you override this be sure and invoke super, otherwise we'll + // leak a few things. + virtual void OnDestroy(); + virtual void OnEndSession(BOOL ending, UINT logoff) { SetMsgHandled(FALSE); } + virtual void OnExitMenuLoop(BOOL is_track_popup_menu) { SetMsgHandled(FALSE); } + virtual LRESULT OnEraseBkgnd(HDC dc); + virtual void OnGetMinMaxInfo(LPMINMAXINFO mm_info) { } + virtual LRESULT OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param); + virtual void OnHScroll(int scroll_type, short position, HWND scrollbar) { + SetMsgHandled(FALSE); + } + virtual void OnInitMenu(HMENU menu) { SetMsgHandled(FALSE); } + virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu) { + SetMsgHandled(FALSE); + } + virtual void OnKeyDown(TCHAR c, UINT rep_cnt, UINT flags); + virtual void OnKeyUp(TCHAR c, UINT rep_cnt, UINT flags); + virtual void OnLButtonDblClk(UINT flags, const CPoint& point); + virtual void OnLButtonDown(UINT flags, const CPoint& point); + virtual void OnLButtonUp(UINT flags, const CPoint& point); + virtual void OnMButtonDblClk(UINT flags, const CPoint& point); + virtual void OnMButtonDown(UINT flags, const CPoint& point); + virtual void OnMButtonUp(UINT flags, const CPoint& point); + virtual LRESULT OnMouseActivate(HWND window, UINT hittest_code, UINT message); + virtual void OnMouseMove(UINT flags, const CPoint& point); + virtual LRESULT OnMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param); + virtual void OnMove(const CPoint& point) { SetMsgHandled(FALSE); } + virtual void OnMoving(UINT param, const LPRECT new_bounds) { } + virtual LRESULT OnMouseWheel(UINT flags, short distance, const CPoint& point); + virtual LRESULT OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param); + virtual LRESULT OnNCActivate(BOOL active) { SetMsgHandled(FALSE); return 0; } + virtual LRESULT OnNCCalcSize(BOOL w_param, LPARAM l_param) { SetMsgHandled(FALSE); return 0; } + virtual LRESULT OnNCHitTest(const CPoint& pt) { SetMsgHandled(FALSE); return 0; } + virtual void OnNCLButtonDblClk(UINT flags, const CPoint& point); + virtual void OnNCLButtonDown(UINT flags, const CPoint& point); + virtual void OnNCLButtonUp(UINT flags, const CPoint& point); + virtual LRESULT OnNCMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param); + virtual LRESULT OnNCMouseMove(UINT flags, const CPoint& point); + virtual void OnNCPaint(HRGN rgn) { SetMsgHandled(FALSE); } + virtual void OnNCRButtonDblClk(UINT flags, const CPoint& point); + virtual void OnNCRButtonDown(UINT flags, const CPoint& point); + virtual void OnNCRButtonUp(UINT flags, const CPoint& point); + virtual LRESULT OnNCUAHDrawCaption(UINT msg, + WPARAM w_param, + LPARAM l_param) { + SetMsgHandled(FALSE); + return 0; + } + virtual LRESULT OnNCUAHDrawFrame(UINT msg, WPARAM w_param, LPARAM l_param) { + SetMsgHandled(FALSE); + return 0; + } + virtual LRESULT OnNotify(int w_param, NMHDR* l_param); + virtual void OnPaint(HDC dc); + virtual LRESULT OnPowerBroadcast(DWORD power_event, DWORD data) { + SetMsgHandled(FALSE); + return 0; + } + virtual void OnRButtonDblClk(UINT flags, const CPoint& point); + virtual void OnRButtonDown(UINT flags, const CPoint& point); + virtual void OnRButtonUp(UINT flags, const CPoint& point); + virtual LRESULT OnReflectedMessage(UINT msg, WPARAM w_param, LPARAM l_param) { + SetMsgHandled(FALSE); + return 0; + } + virtual LRESULT OnSetCursor(HWND window, UINT hittest_code, UINT message) { + SetMsgHandled(FALSE); + return 0; + } + virtual void OnSetFocus(HWND focused_window) { + SetMsgHandled(FALSE); + } + virtual LRESULT OnSetIcon(UINT size_type, HICON new_icon) { + SetMsgHandled(FALSE); + return 0; + } + virtual LRESULT OnSetText(const wchar_t* text) { + SetMsgHandled(FALSE); + return 0; + } + virtual LRESULT OnSettingChange(UINT msg, WPARAM w_param, LPARAM l_param); + virtual void OnSize(UINT param, const CSize& size); + virtual void OnSysCommand(UINT notification_code, CPoint click) { } + virtual void OnThemeChanged(); + virtual void OnVScroll(int scroll_type, short position, HWND scrollbar) { + SetMsgHandled(FALSE); + } + virtual void OnWindowPosChanged(WINDOWPOS* window_pos) { + SetMsgHandled(FALSE); + } + + // deletes this window as it is destroyed, override to provide different + // behavior. + virtual void OnFinalMessage(HWND window); + + // Start tracking all mouse events so that this window gets sent mouse leave + // messages too. |is_nonclient| is true when we should track WM_NCMOUSELEAVE + // messages instead of WM_MOUSELEAVE ones. + void TrackMouseEvents(DWORD mouse_tracking_flags); + + // Actually handle mouse events. These functions are called by subclasses who + // override the message handlers above to do the actual real work of handling + // the event in the View system. + bool ProcessMousePressed(const CPoint& point, UINT flags, bool dbl_click); + void ProcessMouseDragged(const CPoint& point, UINT flags); + void ProcessMouseReleased(const CPoint& point, UINT flags); + void ProcessMouseMoved(const CPoint& point, UINT flags, bool is_nonclient); + void ProcessMouseExited(); + + // Makes sure the window still fits on screen after a settings change message + // from the OS, e.g. a screen resolution change. + virtual void AdjustWindowToFitScreenSize(); + + // Handles re-laying out content in response to a window size change. + virtual void ChangeSize(UINT size_param, const CSize& size); + + // Returns whether capture should be released on mouse release. The default + // is true. + virtual bool ReleaseCaptureOnMouseReleased() { return true; } + + enum FrameAction {FA_NONE = 0, FA_RESIZING, FA_MOVING, FA_FORWARDING}; + + virtual RootView* CreateRootView(); + + // Returns true if this ContainerWin is opaque. + bool opaque() const { return opaque_; } + + // The root of the View hierarchy attached to this window. + scoped_ptr root_view_; + + // Current frame ui action + FrameAction current_action_; + + // Whether or not we have capture the mouse. + bool has_capture_; + + // If true, the mouse is currently down. + bool is_mouse_down_; + + scoped_ptr tooltip_manager_; + + private: + // Resize the bitmap used to contain the contents of the layered window. This + // recreates the entire bitmap. + void SizeContents(const CRect& window_rect); + + // Paint into a DIB and then update the layered window with its contents. + void PaintLayeredWindow(); + + // In layered mode, update the layered window. |dib_dc| represents a handle + // to a device context that contains the contents of the window. + void UpdateWindowFromContents(HDC dib_dc); + + // Invoked from WM_DESTROY. Does appropriate cleanup and invokes OnDestroy + // so that subclasses can do any cleanup they need to. + void OnDestroyImpl(); + + // The windows procedure used by all ContainerWins. + static LRESULT CALLBACK WndProc(HWND window, + UINT message, + WPARAM w_param, + LPARAM l_param); + + // Gets the window class name to use when creating the corresponding HWND. + // If necessary, this registers the window class. + std::wstring GetWindowClassName(); + + // The following factory is used for calls to close the ContainerWin + // instance. + ScopedRunnableMethodFactory close_container_factory_; + + // The flags currently being used with TrackMouseEvent to track mouse + // messages. 0 if there is no active tracking. The value of this member is + // used when tracking is canceled. + DWORD active_mouse_tracking_flags_; + + // Whether or not this is a top level window. + bool toplevel_; + + bool opaque_; + + // Window Styles used when creating the window. + DWORD window_style_; + + // Window Extended Styles used when creating the window. + DWORD window_ex_style_; + + // Style of the class to use. + UINT class_style_; + + // Whether or not this is a layered window. + bool layered_; + + // The default alpha to be applied to the layered window. + BYTE layered_alpha_; + + // A canvas that contains the window contents in the case of a layered + // window. + scoped_ptr contents_; + + // Whether or not the window should delete itself when it is destroyed. + // Set this to false via its setter for stack allocated instances. + bool delete_on_destroy_; + + // True if we are allowed to update the layered window from the DIB backing + // store if necessary. + bool can_update_layered_window_; + + // The following are used to detect duplicate mouse move events and not + // deliver them. Displaying a window may result in the system generating + // duplicate move events even though the mouse hasn't moved. + + // If true, the last event was a mouse move event. + bool last_mouse_event_was_move_; + + // Coordinates of the last mouse move event, in screen coordinates. + int last_mouse_move_x_; + int last_mouse_move_y_; + + // Instance of accessibility information and handling for MSAA root + CComPtr accessibility_root_; + + // Our hwnd. + HWND hwnd_; +}; + +} // namespace ChromeViews + +#endif // #ifndef CHROME_VIEWS_CONTAINER_WIN_H_ + diff --git a/chrome/views/custom_frame_window.cc b/chrome/views/custom_frame_window.cc index 046210a..9bd9758 100644 --- a/chrome/views/custom_frame_window.cc +++ b/chrome/views/custom_frame_window.cc @@ -525,9 +525,9 @@ gfx::Size DefaultNonClientView::GetPreferredSize() { void DefaultNonClientView::ViewHierarchyChanged(bool is_add, View* parent, View* child) { - // Add our Client View as we are added to the ViewContainer so that if we are + // Add our Client View as we are added to the Container so that if we are // subsequently resized all the parent-child relationships are established. - if (is_add && GetViewContainer() && child == this) + if (is_add && GetContainer() && child == this) AddChildView(container_->client_view()); } @@ -920,7 +920,7 @@ void CustomFrameWindow::SetClientView(ClientView* cv) { DCHECK(cv && !client_view() && GetHWND()); set_client_view(cv); // For a CustomFrameWindow, the non-client view is the root. - HWNDViewContainer::SetContentsView(non_client_view_); + ContainerWin::SetContentsView(non_client_view_); // When the non client view is added to the view hierarchy, it will cause the // client view to be added as well. } @@ -970,7 +970,7 @@ void CustomFrameWindow::SizeWindowToDefault() { } /////////////////////////////////////////////////////////////////////////////// -// CustomFrameWindow, HWNDViewContainer overrides: +// CustomFrameWindow, ContainerWin overrides: void CustomFrameWindow::OnGetMinMaxInfo(MINMAXINFO* minmax_info) { // We handle this message so that we can make sure we interact nicely with diff --git a/chrome/views/custom_frame_window.h b/chrome/views/custom_frame_window.h index b1812a0..fbaff21 100644 --- a/chrome/views/custom_frame_window.h +++ b/chrome/views/custom_frame_window.h @@ -47,7 +47,7 @@ class CustomFrameWindow : public Window { virtual void EnableClose(bool enable); virtual void DisableInactiveRendering(bool disable); - // Overridden from HWNDViewContainer: + // Overridden from ContainerWin: virtual void OnGetMinMaxInfo(MINMAXINFO* minmax_info); virtual void OnInitMenu(HMENU menu); virtual void OnMouseLeave(); diff --git a/chrome/views/dialog_client_view.cc b/chrome/views/dialog_client_view.cc index 2435644..559bc2e 100644 --- a/chrome/views/dialog_client_view.cc +++ b/chrome/views/dialog_client_view.cc @@ -226,7 +226,7 @@ void DialogClientView::ViewHierarchyChanged(bool is_add, View* parent, View* chi if (is_add && child == this) { // Can only add and update the dialog buttons _after_ they are added to the // view hierarchy since they are native controls and require the - // ViewContainer's HWND. + // Container's HWND. ShowDialogButtons(); ClientView::ViewHierarchyChanged(is_add, parent, child); UpdateDialogButtons(); diff --git a/chrome/views/focus_manager.cc b/chrome/views/focus_manager.cc index 8af3542..397a4a8 100644 --- a/chrome/views/focus_manager.cc +++ b/chrome/views/focus_manager.cc @@ -9,10 +9,10 @@ #include "chrome/browser/render_widget_host_view_win.h" #include "chrome/common/notification_types.h" #include "chrome/views/accelerator.h" +#include "chrome/views/container.h" #include "chrome/views/focus_manager.h" #include "chrome/views/root_view.h" #include "chrome/views/view.h" -#include "chrome/views/view_container.h" #include "chrome/views/view_storage.h" // The following keys are used in SetProp/GetProp to associate additional @@ -304,7 +304,7 @@ bool FocusManager::OnKeyDown(HWND window, UINT message, WPARAM wparam, DCHECK((message == WM_KEYDOWN) || (message == WM_SYSKEYDOWN)); if (!IsWindowVisible(root_)) { - // We got a message for a hidden window. Because HWNDViewContainer::Close + // We got a message for a hidden window. Because ContainerWin::Close // hides the window, then destroys it, it it possible to get a message after // we've hidden the window. If we allow the message to be dispatched // chances are we'll crash in some weird place. By returning false we make @@ -425,7 +425,7 @@ bool FocusManager::ContainsView(View* view) { if (!root_view) return false; - ViewContainer* view_container = root_view->GetViewContainer(); + Container* view_container = root_view->GetContainer(); if (!view_container) return false; @@ -457,7 +457,7 @@ View* FocusManager::GetNextFocusableView(View* original_starting_view, View* starting_view = NULL; if (original_starting_view) { // If the starting view has a focus traversable, use it. - // This is the case with HWNDViewContainers for example. + // This is the case with ContainerWins for example. focus_traversable = original_starting_view->GetFocusTraversable(); // Otherwise default to the root view. diff --git a/chrome/views/focus_manager.h b/chrome/views/focus_manager.h index dc80253..e12457f 100644 --- a/chrome/views/focus_manager.h +++ b/chrome/views/focus_manager.h @@ -29,10 +29,10 @@ // This is already done for you if you subclass the NativeControl class or if // you use the HWNDView class. // -// When creating a top window, if it derives from HWNDViewContainer, the +// When creating a top window, if it derives from ContainerWin, the // |has_own_focus_manager| of the Init method lets you specify whether that // window should have its own focus manager (so focus traversal stays confined -// in that window). If you are not deriving from HWNDViewContainer or one of its +// in that window). If you are not deriving from ContainerWin or one of its // derived classes (Window, FramelessWindow, ConstrainedWindow), you must // create a FocusManager when the window is created (it is automatically deleted // when the window is destroyed). @@ -49,7 +49,7 @@ // method SetNextFocusableView(). // // If you are embedding a native view containing a nested RootView (for example -// by adding a NativeControl that contains a HWNDViewContainer as its native +// by adding a NativeControl that contains a ContainerWin as its native // component), then you need to: // - override the View::GetFocusTraversable() method in your outter component. // It should return the RootView of the inner component. This is used when diff --git a/chrome/views/focus_manager_unittest.cc b/chrome/views/focus_manager_unittest.cc index 78d02b4..3eba191 100644 --- a/chrome/views/focus_manager_unittest.cc +++ b/chrome/views/focus_manager_unittest.cc @@ -14,7 +14,7 @@ #include "chrome/views/background.h" #include "chrome/views/border.h" #include "chrome/views/checkbox.h" -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/container_win.h" #include "chrome/views/label.h" #include "chrome/views/link.h" #include "chrome/views/native_button.h" @@ -114,7 +114,7 @@ class BorderView : public ChromeViews::NativeControl { 0, 0, width(), height(), parent_container, NULL, NULL, NULL); // Create the view container which is a child of the TabControl. - view_container_ = new ChromeViews::HWNDViewContainer(); + view_container_ = new ChromeViews::ContainerWin(); view_container_->Init(tab_control, gfx::Rect(), false); view_container_->SetContentsView(child_); view_container_->SetFocusTraversableParentView(this); @@ -162,12 +162,12 @@ private: } View* child_; - ChromeViews::HWNDViewContainer* view_container_; + ChromeViews::ContainerWin* view_container_; DISALLOW_EVIL_CONSTRUCTORS(BorderView); }; -class TestViewWindow : public ChromeViews::HWNDViewContainer { +class TestViewWindow : public ChromeViews::ContainerWin { public: explicit TestViewWindow(FocusManagerTest* test); ~TestViewWindow() { } @@ -239,7 +239,7 @@ void TestViewWindow::Init() { contents_->SetBackground( ChromeViews::Background::CreateSolidBackground(255, 255, 255)); - HWNDViewContainer::Init(NULL, bounds, true); + ContainerWin::Init(NULL, bounds, true); SetContentsView(contents_); ChromeViews::CheckBox* cb = diff --git a/chrome/views/hwnd_view.cc b/chrome/views/hwnd_view.cc index 3550278..6c66851 100644 --- a/chrome/views/hwnd_view.cc +++ b/chrome/views/hwnd_view.cc @@ -6,9 +6,9 @@ #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/common/win_util.h" +#include "chrome/views/container.h" #include "chrome/views/focus_manager.h" #include "chrome/views/scroll_view.h" -#include "chrome/views/view_container.h" #include "base/logging.h" namespace ChromeViews { @@ -38,7 +38,7 @@ void HWNDView::Attach(HWND hwnd) { ShowWindow(hwnd_, SW_HIDE); // Need to set the HWND's parent before changing its size to avoid flashing. - ::SetParent(hwnd_, GetViewContainer()->GetHWND()); + ::SetParent(hwnd_, GetContainer()->GetHWND()); UpdateHWNDBounds(); // Register with the focus manager so the associated view is focused when the @@ -66,12 +66,12 @@ void HWNDView::UpdateHWNDBounds() { if (!hwnd_) return; - // Since HWNDs know nothing about the View hierarchy (they are direct children - // of the ViewContainer that hosts our View hierarchy) they need to be - // positioned in the coordinate system of the ViewContainer, not the current + // Since HWNDs know nothing about the View hierarchy (they are direct + // children of the Container that hosts our View hierarchy) they need to be + // positioned in the coordinate system of the Container, not the current // view. gfx::Point top_left; - ConvertPointToViewContainer(this, &top_left); + ConvertPointToContainer(this, &top_left); gfx::Rect vis_bounds = GetVisibleBounds(); bool visible = !vis_bounds.IsEmpty(); @@ -150,7 +150,7 @@ gfx::Size HWNDView::GetPreferredSize() { void HWNDView::ViewHierarchyChanged(bool is_add, View *parent, View *child) { if (hwnd_) { - ViewContainer* vc = GetViewContainer(); + Container* vc = GetContainer(); if (is_add && vc) { HWND parent = ::GetParent(hwnd_); HWND vc_hwnd = vc->GetHWND(); diff --git a/chrome/views/hwnd_view_container.cc b/chrome/views/hwnd_view_container.cc deleted file mode 100644 index 1529085..0000000 --- a/chrome/views/hwnd_view_container.cc +++ /dev/null @@ -1,928 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "chrome/views/hwnd_view_container.h" - -#include "base/gfx/native_theme.h" -#include "base/string_util.h" -#include "base/win_util.h" -#include "chrome/app/chrome_dll_resource.h" -#include "chrome/common/gfx/chrome_canvas.h" -#include "chrome/common/win_util.h" -#include "chrome/views/aero_tooltip_manager.h" -#include "chrome/views/accessibility/view_accessibility.h" -#include "chrome/views/hwnd_notification_source.h" -#include "chrome/views/root_view.h" - -namespace ChromeViews { - -static const DWORD kWindowDefaultChildStyle = - WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS; -static const DWORD kWindowDefaultStyle = WS_OVERLAPPEDWINDOW; -static const DWORD kWindowDefaultExStyle = 0; - -// Property used to link the HWND to its RootView. -static const wchar_t* const kRootViewWindowProperty = L"__ROOT_VIEW__"; - -bool SetRootViewForHWND(HWND hwnd, RootView* root_view) { - return ::SetProp(hwnd, kRootViewWindowProperty, root_view) ? true : false; -} - -RootView* GetRootViewForHWND(HWND hwnd) { - return reinterpret_cast(::GetProp(hwnd, kRootViewWindowProperty)); -} - -// Used to locate the HWNDViewContainer issuing the current Create. Only valid -// for the life of Create. -// -// This obviously assumes we only create HWNDViewContainers from the same -// thread, which is currently the case. -static HWNDViewContainer* instance_issuing_create = NULL; - -/////////////////////////////////////////////////////////////////////////////// -// FillLayout - -FillLayout::FillLayout() { -} - -FillLayout::~FillLayout() { -} - -void FillLayout::Layout(View* host) { - CRect bounds; - host->GetViewContainer()->GetBounds(&bounds, false); - if (host->GetChildViewCount() == 0) - return; - - View* frame_view = host->GetChildViewAt(0); - frame_view->SetBounds(CRect(CPoint(0, 0), bounds.Size())); -} - -gfx::Size FillLayout::GetPreferredSize(View* host) { - DCHECK(host->GetChildViewCount() == 1); - return host->GetChildViewAt(0)->GetPreferredSize(); -} - -/////////////////////////////////////////////////////////////////////////////// -// Window class tracking. - -// static -const wchar_t* const HWNDViewContainer::kBaseClassName = - L"Chrome_HWNDViewContainer_"; - -// Window class information used for registering unique windows. -struct ClassInfo { - UINT style; - HBRUSH background; - - explicit ClassInfo(int style) - : style(style), - background(NULL) {} - - // Compares two ClassInfos. Returns true if all members match. - bool Equals(const ClassInfo& other) { - return (other.style == style && other.background == background); - } -}; - -// Represents a registered window class. -struct RegisteredClass { - RegisteredClass(const ClassInfo& info, - const std::wstring& name, - ATOM atom) - : info(info), - name(name), - atom(atom) { - } - - // Info used to create the class. - ClassInfo info; - - // The name given to the window. - std::wstring name; - - // The ATOM returned from creating the window. - ATOM atom; -}; - -typedef std::list RegisteredClasses; - -// The list of registered classes. -static RegisteredClasses* registered_classes = NULL; - - -/////////////////////////////////////////////////////////////////////////////// -// HWNDViewContainer, public - -HWNDViewContainer::HWNDViewContainer() - : active_mouse_tracking_flags_(0), - has_capture_(false), - current_action_(FA_NONE), - toplevel_(false), - window_style_(0), - window_ex_style_(kWindowDefaultExStyle), - layered_(false), - layered_alpha_(255), - delete_on_destroy_(true), - can_update_layered_window_(true), - last_mouse_event_was_move_(false), - is_mouse_down_(false), - class_style_(CS_DBLCLKS), - hwnd_(NULL), - close_container_factory_(this) { -} - -HWNDViewContainer::~HWNDViewContainer() { - MessageLoopForUI::current()->RemoveObserver(this); -} - -void HWNDViewContainer::Init(HWND parent, - const gfx::Rect& bounds, - bool has_own_focus_manager) { - toplevel_ = parent == NULL; - - if (window_style_ == 0) - window_style_ = toplevel_ ? kWindowDefaultStyle : kWindowDefaultChildStyle; - - // See if the style has been overridden. - opaque_ = !(window_ex_style_ & WS_EX_TRANSPARENT); - layered_ = !!(window_ex_style_ & WS_EX_LAYERED); - - // Force creation of the RootView if it hasn't been created yet. - GetRootView(); - - // Ensures the parent we have been passed is valid, otherwise CreateWindowEx - // will fail. - if (parent && !::IsWindow(parent)) { - NOTREACHED() << "invalid parent window specified."; - parent = NULL; - } - - hwnd_ = CreateWindowEx(window_ex_style_, GetWindowClassName().c_str(), L"", - window_style_, bounds.x(), bounds.y(), bounds.width(), - bounds.height(), parent, NULL, NULL, this); - DCHECK(hwnd_); - // The window procedure should have set the data for us. - DCHECK(win_util::GetWindowUserData(hwnd_) == this); - - root_view_->OnViewContainerCreated(); - - if (has_own_focus_manager) { - ChromeViews::FocusManager::CreateFocusManager(hwnd_, GetRootView()); - } else { - // Subclass the window so we get the tab key messages when a view with no - // associated native window is focused. - FocusManager::InstallFocusSubclass(hwnd_, NULL); - } - - // Sets the RootView as a property, so the automation can introspect windows. - SetRootViewForHWND(hwnd_, root_view_.get()); - - MessageLoopForUI::current()->AddObserver(this); - - // Windows special DWM window frame requires a special tooltip manager so - // that window controls in Chrome windows don't flicker when you move your - // mouse over them. See comment in aero_tooltip_manager.h. - if (win_util::ShouldUseVistaFrame()) { - tooltip_manager_.reset(new AeroTooltipManager(this, GetHWND())); - } else { - tooltip_manager_.reset(new TooltipManager(this, GetHWND())); - } - - // This message initializes the window so that focus border are shown for - // windows. - ::SendMessage(GetHWND(), - WM_CHANGEUISTATE, - MAKELPARAM(UIS_CLEAR, UISF_HIDEFOCUS), - 0); - - // Bug 964884: detach the IME attached to this window. - // We should attach IMEs only when we need to input CJK strings. - ::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 - -void HWNDViewContainer::GetBounds(CRect *out, bool including_frame) const { - if (including_frame) { - GetWindowRect(out); - } else { - GetClientRect(out); - - POINT p = {0, 0}; - ::ClientToScreen(hwnd_, &p); - - out->left += p.x; - out->top += p.y; - out->right += p.x; - out->bottom += p.y; - } -} - -void HWNDViewContainer::MoveToFront(bool should_activate) { - int flags = SWP_NOMOVE | SWP_NOSIZE; - if (!should_activate) { - flags |= SWP_NOACTIVATE; - } - SetWindowPos(HWND_NOTOPMOST, 0, 0, 0, 0, flags); -} - -HWND HWNDViewContainer::GetHWND() const { - return hwnd_; -} - -void HWNDViewContainer::PaintNow(const CRect& update_rect) { - if (layered_) { - PaintLayeredWindow(); - } else if (root_view_->NeedsPainting(false) && IsWindow()) { - if (!opaque_ && GetParent()) { - // We're transparent. Need to force painting to occur from our parent. - CRect parent_update_rect = update_rect; - POINT location_in_parent = { 0, 0 }; - ClientToScreen(hwnd_, &location_in_parent); - ::ScreenToClient(GetParent(), &location_in_parent); - parent_update_rect.OffsetRect(location_in_parent); - ::RedrawWindow(GetParent(), parent_update_rect, NULL, - RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN); - } else { - RedrawWindow(hwnd_, update_rect, NULL, - RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN); - } - // As we were created with a style of WS_CLIPCHILDREN redraw requests may - // result in an empty paint rect in WM_PAINT (this'll happen if a - // child HWND completely contains the update _rect). In such a scenario - // RootView would never get a ProcessPaint and always think it needs to - // be painted (leading to a steady stream of RedrawWindow requests on every - // event). For this reason we tell RootView it doesn't need to paint - // here. - root_view_->ClearPaintRect(); - } -} - -RootView* HWNDViewContainer::GetRootView() { - if (!root_view_.get()) { - // First time the root view is being asked for, create it now. - root_view_.reset(CreateRootView()); - } - return root_view_.get(); -} - -bool HWNDViewContainer::IsVisible() { - return !!::IsWindowVisible(GetHWND()); -} - -bool HWNDViewContainer::IsActive() { - return win_util::IsWindowActive(GetHWND()); -} - -TooltipManager* HWNDViewContainer::GetTooltipManager() { - return tooltip_manager_.get(); -} - - -void HWNDViewContainer::SetLayeredAlpha(BYTE layered_alpha) { - layered_alpha_ = layered_alpha; - -// if (hwnd_) -// UpdateWindowFromContents(contents_->getTopPlatformDevice().getBitmapDC()); -} - -static BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM l_param) { - RootView* root_view = - reinterpret_cast(GetProp(hwnd, kRootViewWindowProperty)); - if (root_view) { - *reinterpret_cast(l_param) = root_view; - return FALSE; // Stop enumerating. - } - return TRUE; // Keep enumerating. -} - -// static -RootView* HWNDViewContainer::FindRootView(HWND hwnd) { - RootView* root_view = - reinterpret_cast(GetProp(hwnd, kRootViewWindowProperty)); - if (root_view) - return root_view; - - // Enumerate all children and check if they have a RootView. - EnumChildWindows(hwnd, EnumChildProc, reinterpret_cast(&root_view)); - - return root_view; -} - -void HWNDViewContainer::Close() { - // Let's hide ourselves right away. - Hide(); - if (close_container_factory_.empty()) { - // And we delay the close so that if we are called from an ATL callback, - // we don't destroy the window before the callback returned (as the caller - // may delete ourselves on destroy and the ATL callback would still - // dereference us when the callback returns). - MessageLoop::current()->PostTask(FROM_HERE, - close_container_factory_.NewRunnableMethod( - &HWNDViewContainer::CloseNow)); - } -} - -void HWNDViewContainer::Hide() { - // NOTE: Be careful not to activate any windows here (for example, calling - // ShowWindow(SW_HIDE) will automatically activate another window). This - // code can be called while a window is being deactivated, and activating - // another window will screw up the activation that is already in progress. - SetWindowPos(NULL, 0, 0, 0, 0, - SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | - SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER); -} - -void HWNDViewContainer::CloseNow() { - // We may already have been destroyed if the selection resulted in a tab - // switch which will have reactivated the browser window and closed us, so - // we need to check to see if we're still a window before trying to destroy - // ourself. - if (IsWindow()) - DestroyWindow(); -} - -/////////////////////////////////////////////////////////////////////////////// -// MessageLoop::Observer - -void HWNDViewContainer::WillProcessMessage(const MSG& msg) { -} - -void HWNDViewContainer::DidProcessMessage(const MSG& msg) { - if (root_view_->NeedsPainting(true)) { - PaintNow(root_view_->GetScheduledPaintRect()); - } -} - -/////////////////////////////////////////////////////////////////////////////// -// FocusTraversable - -View* HWNDViewContainer::FindNextFocusableView( - View* starting_view, bool reverse, Direction direction, bool dont_loop, - FocusTraversable** focus_traversable, View** focus_traversable_view) { - return root_view_->FindNextFocusableView(starting_view, - reverse, - direction, - dont_loop, - focus_traversable, - focus_traversable_view); -} - -FocusTraversable* HWNDViewContainer::GetFocusTraversableParent() { - // We are a proxy to the root view, so we should be bypassed when traversing - // up and as a result this should not be called. - NOTREACHED(); - return NULL; -} - -void HWNDViewContainer::SetFocusTraversableParent(FocusTraversable* parent) { - root_view_->SetFocusTraversableParent(parent); -} - -View* HWNDViewContainer::GetFocusTraversableParentView() { - // We are a proxy to the root view, so we should be bypassed when traversing - // up and as a result this should not be called. - NOTREACHED(); - return NULL; -} - -void HWNDViewContainer::SetFocusTraversableParentView(View* parent_view) { - root_view_->SetFocusTraversableParentView(parent_view); -} - -/////////////////////////////////////////////////////////////////////////////// -// Message handlers - -void HWNDViewContainer::OnCaptureChanged(HWND hwnd) { - if (has_capture_) { - if (is_mouse_down_) - root_view_->ProcessMouseDragCanceled(); - is_mouse_down_ = false; - has_capture_ = false; - } -} - -void HWNDViewContainer::OnClose() { - // WARNING: this method is NOT called for all HWNDViewContainers. If you - // need to do cleanup code before HWNDViewContainer is destroyed, put it - // in OnDestroy. - - NotificationService::current()->Notify( - NOTIFY_WINDOW_CLOSED, Source(hwnd_), - NotificationService::NoDetails()); - - Close(); -} - -void HWNDViewContainer::OnDestroy() { - root_view_->OnViewContainerDestroyed(); - - RemoveProp(hwnd_, kRootViewWindowProperty); -} - -LRESULT HWNDViewContainer::OnEraseBkgnd(HDC dc) { - // This is needed for magical win32 flicker ju-ju - return 1; -} - -LRESULT HWNDViewContainer::OnGetObject(UINT uMsg, WPARAM w_param, - LPARAM l_param) { - LRESULT reference_result = static_cast(0L); - - // Accessibility readers will send an OBJID_CLIENT message - if (OBJID_CLIENT == l_param) { - // If our MSAA root is already created, reuse that pointer. Otherwise, - // create a new one. - if (!accessibility_root_) { - CComObject* instance = NULL; - - HRESULT hr = CComObject::CreateInstance(&instance); - DCHECK(SUCCEEDED(hr)); - - if (!instance) { - // Return with failure. - return static_cast(0L); - } - - CComPtr accessibility_instance(instance); - - if (!SUCCEEDED(instance->Initialize(root_view_.get()))) { - // Return with failure. - return static_cast(0L); - } - - // All is well, assign the temp instance to the class smart pointer - accessibility_root_.Attach(accessibility_instance.Detach()); - - if (!accessibility_root_) { - // Return with failure. - return static_cast(0L); - } - - // Notify that an instance of IAccessible was allocated for m_hWnd - ::NotifyWinEvent(EVENT_OBJECT_CREATE, GetHWND(), OBJID_CLIENT, - CHILDID_SELF); - } - - // Create a reference to ViewAccessibility that MSAA will marshall - // to the client. - reference_result = LresultFromObject(IID_IAccessible, w_param, - static_cast(accessibility_root_)); - } - return reference_result; -} - -void HWNDViewContainer::OnKeyDown(TCHAR c, UINT rep_cnt, UINT flags) { - KeyEvent event(Event::ET_KEY_PRESSED, c, rep_cnt, flags); - root_view_->ProcessKeyEvent(event); -} - -void HWNDViewContainer::OnKeyUp(TCHAR c, UINT rep_cnt, UINT flags) { - KeyEvent event(Event::ET_KEY_RELEASED, c, rep_cnt, flags); - root_view_->ProcessKeyEvent(event); -} - -void HWNDViewContainer::OnLButtonDown(UINT flags, const CPoint& point) { - ProcessMousePressed(point, flags | MK_LBUTTON, false); -} - -void HWNDViewContainer::OnLButtonUp(UINT flags, const CPoint& point) { - ProcessMouseReleased(point, flags | MK_LBUTTON); -} - -void HWNDViewContainer::OnLButtonDblClk(UINT flags, const CPoint& point) { - ProcessMousePressed(point, flags | MK_LBUTTON, true); -} - -void HWNDViewContainer::OnMButtonDown(UINT flags, const CPoint& point) { - ProcessMousePressed(point, flags | MK_MBUTTON, false); -} - -void HWNDViewContainer::OnMButtonUp(UINT flags, const CPoint& point) { - ProcessMouseReleased(point, flags | MK_MBUTTON); -} - -void HWNDViewContainer::OnMButtonDblClk(UINT flags, const CPoint& point) { - ProcessMousePressed(point, flags | MK_MBUTTON, true); -} - -LRESULT HWNDViewContainer::OnMouseActivate(HWND window, - UINT hittest_code, - UINT message) { - SetMsgHandled(FALSE); - return MA_ACTIVATE; -} - -void HWNDViewContainer::OnMouseMove(UINT flags, const CPoint& point) { - ProcessMouseMoved(point, flags, false); -} - -LRESULT HWNDViewContainer::OnMouseLeave(UINT uMsg, WPARAM w_param, - LPARAM l_param) { - ProcessMouseExited(); - return 0; -} - -LRESULT HWNDViewContainer::OnMouseWheel(UINT flags, - short distance, - const CPoint& point) { - MouseWheelEvent e(distance, - point.x, - point.y, - Event::ConvertWindowsFlags(flags)); - return root_view_->ProcessMouseWheelEvent(e) ? 0 : 1; -} - -LRESULT HWNDViewContainer::OnMouseRange(UINT msg, - WPARAM w_param, - LPARAM l_param) { - tooltip_manager_->OnMouse(msg, w_param, l_param); - SetMsgHandled(FALSE); - return 0; -} - -void HWNDViewContainer::OnNCLButtonDblClk(UINT flags, const CPoint& point) { - SetMsgHandled(FALSE); -} - -void HWNDViewContainer::OnNCLButtonDown(UINT flags, const CPoint& point) { - SetMsgHandled(FALSE); -} - -void HWNDViewContainer::OnNCLButtonUp(UINT flags, const CPoint& point) { - SetMsgHandled(FALSE); -} - -LRESULT HWNDViewContainer::OnNCMouseLeave(UINT uMsg, - WPARAM w_param, - LPARAM l_param) { - ProcessMouseExited(); - return 0; -} - -LRESULT HWNDViewContainer::OnNCMouseMove(UINT flags, const CPoint& point) { - // NC points are in screen coordinates. - CPoint temp = point; - MapWindowPoints(HWND_DESKTOP, GetHWND(), &temp, 1); - ProcessMouseMoved(temp, 0, true); - - // We need to process this message to stop Windows from drawing the window - // controls as the mouse moves over the title bar area when the window is - // maximized. - return 0; -} - -void HWNDViewContainer::OnNCRButtonDblClk(UINT flags, const CPoint& point) { - SetMsgHandled(FALSE); -} - -void HWNDViewContainer::OnNCRButtonDown(UINT flags, const CPoint& point) { - SetMsgHandled(FALSE); -} - -void HWNDViewContainer::OnNCRButtonUp(UINT flags, const CPoint& point) { - SetMsgHandled(FALSE); -} - -LRESULT HWNDViewContainer::OnNotify(int w_param, NMHDR* l_param) { - // We can be sent this message before the tooltip manager is created, if a - // subclass overrides OnCreate and creates some kind of Windows control there - // that sends WM_NOTIFY messages. - if (tooltip_manager_.get()) { - bool handled; - LRESULT result = tooltip_manager_->OnNotify(w_param, l_param, &handled); - SetMsgHandled(handled); - return result; - } - SetMsgHandled(FALSE); - return 0; -} - -void HWNDViewContainer::OnPaint(HDC dc) { - root_view_->OnPaint(GetHWND()); -} - -void HWNDViewContainer::OnRButtonDown(UINT flags, const CPoint& point) { - ProcessMousePressed(point, flags | MK_RBUTTON, false); -} - -void HWNDViewContainer::OnRButtonUp(UINT flags, const CPoint& point) { - ProcessMouseReleased(point, flags | MK_RBUTTON); -} - -void HWNDViewContainer::OnRButtonDblClk(UINT flags, const CPoint& point) { - ProcessMousePressed(point, flags | MK_RBUTTON, true); -} - -LRESULT HWNDViewContainer::OnSettingChange(UINT msg, - WPARAM w_param, - LPARAM l_param) { - if (toplevel_) { - SetMsgHandled(FALSE); - if (w_param != SPI_SETWORKAREA) - return 0; // Return value is effectively ignored in atlwin.h. - - AdjustWindowToFitScreenSize(); - SetMsgHandled(TRUE); - } - // Don't care, overridden by interested subclasses - return 0; -} - -void HWNDViewContainer::OnSize(UINT param, const CSize& size) { - ChangeSize(param, size); -} - -void HWNDViewContainer::OnThemeChanged() { - // Notify NativeTheme. - gfx::NativeTheme::instance()->CloseHandles(); -} - -void HWNDViewContainer::OnFinalMessage(HWND window) { - if (delete_on_destroy_) - delete this; -} - -/////////////////////////////////////////////////////////////////////////////// -// HWNDViewContainer, protected - -void HWNDViewContainer::TrackMouseEvents(DWORD mouse_tracking_flags) { - // Begin tracking mouse events for this HWND so that we get WM_MOUSELEAVE - // when the user moves the mouse outside this HWND's bounds. - if (active_mouse_tracking_flags_ == 0 || mouse_tracking_flags & TME_CANCEL) { - if (mouse_tracking_flags & TME_CANCEL) { - // We're about to cancel active mouse tracking, so empty out the stored - // state. - active_mouse_tracking_flags_ = 0; - } else { - active_mouse_tracking_flags_ = mouse_tracking_flags; - } - - TRACKMOUSEEVENT tme; - tme.cbSize = sizeof(tme); - tme.dwFlags = mouse_tracking_flags; - tme.hwndTrack = GetHWND(); - tme.dwHoverTime = 0; - TrackMouseEvent(&tme); - } else if (mouse_tracking_flags != active_mouse_tracking_flags_) { - TrackMouseEvents(active_mouse_tracking_flags_ | TME_CANCEL); - TrackMouseEvents(mouse_tracking_flags); - } -} - -bool HWNDViewContainer::ProcessMousePressed(const CPoint& point, - UINT flags, - bool dbl_click) { - last_mouse_event_was_move_ = false; - MouseEvent mouse_pressed(Event::ET_MOUSE_PRESSED, - point.x, - point.y, - (dbl_click ? MouseEvent::EF_IS_DOUBLE_CLICK : 0) | - Event::ConvertWindowsFlags(flags)); - if (root_view_->OnMousePressed(mouse_pressed)) { - is_mouse_down_ = true; - if (!has_capture_) { - SetCapture(); - has_capture_ = true; - current_action_ = FA_FORWARDING; - } - return true; - } - return false; -} - -void HWNDViewContainer::ProcessMouseDragged(const CPoint& point, UINT flags) { - last_mouse_event_was_move_ = false; - MouseEvent mouse_drag(Event::ET_MOUSE_DRAGGED, - point.x, - point.y, - Event::ConvertWindowsFlags(flags)); - root_view_->OnMouseDragged(mouse_drag); -} - -void HWNDViewContainer::ProcessMouseReleased(const CPoint& point, UINT flags) { - last_mouse_event_was_move_ = false; - MouseEvent mouse_up(Event::ET_MOUSE_RELEASED, - point.x, - point.y, - Event::ConvertWindowsFlags(flags)); - // Release the capture first, that way we don't get confused if - // OnMouseReleased blocks. - if (has_capture_ && ReleaseCaptureOnMouseReleased()) { - has_capture_ = false; - current_action_ = FA_NONE; - ReleaseCapture(); - } - is_mouse_down_ = false; - root_view_->OnMouseReleased(mouse_up, false); -} - -void HWNDViewContainer::ProcessMouseMoved(const CPoint &point, UINT flags, - bool is_nonclient) { - // Windows only fires WM_MOUSELEAVE events if the application begins - // "tracking" mouse events for a given HWND during WM_MOUSEMOVE events. - // We need to call |TrackMouseEvents| to listen for WM_MOUSELEAVE. - if (!has_capture_) - TrackMouseEvents(is_nonclient ? TME_NONCLIENT | TME_LEAVE : TME_LEAVE); - if (has_capture_ && is_mouse_down_) { - ProcessMouseDragged(point, flags); - } else { - gfx::Point screen_loc(point); - View::ConvertPointToScreen(root_view_.get(), &screen_loc); - if (last_mouse_event_was_move_ && last_mouse_move_x_ == screen_loc.x() && - last_mouse_move_y_ == screen_loc.y()) { - // Don't generate a mouse event for the same location as the last. - return; - } - last_mouse_move_x_ = screen_loc.x(); - last_mouse_move_y_ = screen_loc.y(); - last_mouse_event_was_move_ = true; - MouseEvent mouse_move(Event::ET_MOUSE_MOVED, - point.x, - point.y, - Event::ConvertWindowsFlags(flags)); - root_view_->OnMouseMoved(mouse_move); - } -} - -void HWNDViewContainer::ProcessMouseExited() { - last_mouse_event_was_move_ = false; - root_view_->ProcessOnMouseExited(); - // Reset our tracking flag so that future mouse movement over this - // HWNDViewContainer results in a new tracking session. - active_mouse_tracking_flags_ = 0; -} - -void HWNDViewContainer::AdjustWindowToFitScreenSize() { - // Desktop size has changed. Make sure we're still on screen. - CRect wr; - GetWindowRect(&wr); - HMONITOR hmon = MonitorFromRect(&wr, MONITOR_DEFAULTTONEAREST); - if (!hmon) { - // No monitor available. - return; - } - - MONITORINFO mi; - mi.cbSize = sizeof(mi); - GetMonitorInfo(hmon, &mi); - gfx::Rect window_rect(wr); - gfx::Rect monitor_rect(mi.rcWork); - gfx::Rect new_window_rect = window_rect.AdjustToFit(monitor_rect); - if (!new_window_rect.Equals(window_rect)) { - // New position differs from last, resize window. - ::SetWindowPos(GetHWND(), - 0, - new_window_rect.x(), - new_window_rect.y(), - new_window_rect.width(), - new_window_rect.height(), - SWP_NOACTIVATE | SWP_NOZORDER); - } -} - -void HWNDViewContainer::ChangeSize(UINT size_param, const CSize& size) { - CRect rect; - if (layered_) { - GetWindowRect(&rect); - SizeContents(rect); - } else { - GetClientRect(&rect); - } - - // Resizing changes the size of the view hierarchy and thus forces a - // complete relayout. - root_view_->SetBounds(CRect(CPoint(0,0), rect.Size())); - root_view_->Layout(); - root_view_->SchedulePaint(); - - if (layered_) - PaintNow(rect); -} - -RootView* HWNDViewContainer::CreateRootView() { - return new RootView(this); -} - -/////////////////////////////////////////////////////////////////////////////// -// HWNDViewContainer, private: - -void HWNDViewContainer::SizeContents(const CRect& window_rect) { - contents_.reset(new ChromeCanvas(window_rect.Width(), - window_rect.Height(), - false)); -} - -void HWNDViewContainer::PaintLayeredWindow() { - // Painting monkeys with our cliprect, so we need to save it so that the - // call to UpdateLayeredWindow updates the entire window, not just the - // cliprect. - contents_->save(SkCanvas::kClip_SaveFlag); - CRect dirty_rect = root_view_->GetScheduledPaintRect(); - contents_->ClipRectInt( - dirty_rect.left, dirty_rect.top, dirty_rect.Width(), dirty_rect.Height()); - root_view_->ProcessPaint(contents_.get()); - contents_->restore(); - - UpdateWindowFromContents(contents_->getTopPlatformDevice().getBitmapDC()); -} - -void HWNDViewContainer::UpdateWindowFromContents(HDC dib_dc) { - DCHECK(layered_); - if (can_update_layered_window_) { - CRect wr; - GetWindowRect(&wr); - CSize size(wr.right - wr.left, wr.bottom - wr.top); - CPoint zero_origin(0, 0); - CPoint window_position = wr.TopLeft(); - - BLENDFUNCTION blend = {AC_SRC_OVER, 0, layered_alpha_, AC_SRC_ALPHA}; - ::UpdateLayeredWindow( - hwnd_, NULL, &window_position, &size, dib_dc, &zero_origin, - RGB(0xFF, 0xFF, 0xFF), &blend, ULW_ALPHA); - } -} - -std::wstring HWNDViewContainer::GetWindowClassName() { - if (!registered_classes) - registered_classes = new RegisteredClasses(); - ClassInfo class_info(initial_class_style()); - for (RegisteredClasses::iterator i = registered_classes->begin(); - i != registered_classes->end(); ++i) { - if (class_info.Equals(i->info)) - return i->name; - } - - // No class found, need to register one. - static int registered_count = 0; - std::wstring name = - std::wstring(kBaseClassName) + IntToWString(registered_count++); - WNDCLASSEX class_ex; - class_ex.cbSize = sizeof(WNDCLASSEX); - class_ex.style = class_info.style; - class_ex.lpfnWndProc = &HWNDViewContainer::WndProc; - class_ex.cbClsExtra = 0; - class_ex.cbWndExtra = 0; - class_ex.hInstance = NULL; - class_ex.hIcon = LoadIcon(GetModuleHandle(L"chrome.dll"), - MAKEINTRESOURCE(IDR_MAINFRAME)); - class_ex.hCursor = LoadCursor(NULL, IDC_ARROW); - class_ex.hbrBackground = reinterpret_cast(class_info.background + 1); - class_ex.lpszMenuName = NULL; - class_ex.lpszClassName = name.c_str(); - class_ex.hIconSm = class_ex.hIcon; - ATOM atom = RegisterClassEx(&class_ex); - DCHECK(atom); - RegisteredClass registered_class(class_info, name, atom); - registered_classes->push_back(registered_class); - return name; -} - -// static -LRESULT CALLBACK HWNDViewContainer::WndProc(HWND window, - UINT message, - WPARAM w_param, - LPARAM l_param) { - if (message == WM_NCCREATE) { - CREATESTRUCT* cs = reinterpret_cast(l_param); - HWNDViewContainer* vc = - reinterpret_cast(cs->lpCreateParams); - DCHECK(vc); - win_util::SetWindowUserData(window, vc); - vc->hwnd_ = window; - return TRUE; - } - HWNDViewContainer* vc = reinterpret_cast( - win_util::GetWindowUserData(window)); - if (!vc) - return 0; - LRESULT result = 0; - if (!vc->ProcessWindowMessage(window, message, w_param, l_param, result)) - result = DefWindowProc(window, message, w_param, l_param); - if (message == WM_NCDESTROY) { - vc->hwnd_ = NULL; - vc->OnFinalMessage(window); - } - return result; -} - -} // namespace ChromeViews - diff --git a/chrome/views/hwnd_view_container.h b/chrome/views/hwnd_view_container.h deleted file mode 100644 index 2df9622..0000000 --- a/chrome/views/hwnd_view_container.h +++ /dev/null @@ -1,586 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_VIEWS_HWND_VIEW_CONTAINER_H_ -#define CHROME_VIEWS_HWND_VIEW_CONTAINER_H_ - -#include -#include - -#include "base/message_loop.h" -#include "chrome/views/focus_manager.h" -#include "chrome/views/layout_manager.h" -#include "chrome/views/view_container.h" - -class ChromeCanvas; - -namespace gfx { -class Rect; -} - -namespace ChromeViews { - -class RootView; -class TooltipManager; - -bool SetRootViewForHWND(HWND hwnd, RootView* root_view); -RootView* GetRootViewForHWND(HWND hwnd); - -// A Windows message reflected from other windows. This message is sent -// with the following arguments: -// hWnd - Target window -// uMsg - kReflectedMessage -// wParam - Should be 0 -// lParam - Pointer to MSG struct containing the original message. -static const int kReflectedMessage = WM_APP + 3; - -// These two messages aren't defined in winuser.h, but they are sent to windows -// with captions. They appear to paint the window caption and frame. -// Unfortunately if you override the standard non-client rendering as we do -// with CustomFrameWindow, sometimes Windows (not deterministically -// reproducibly but definitely frequently) will send these messages to the -// window and paint the standard caption/title over the top of the custom one. -// So we need to handle these messages in CustomFrameWindow to prevent this -// from happening. -static const int WM_NCUAHDRAWCAPTION = 0xAE; -static const int WM_NCUAHDRAWFRAME = 0xAF; - -/////////////////////////////////////////////////////////////////////////////// -// -// FillLayout -// A simple LayoutManager that causes the associated view's one child to be -// sized to match the bounds of its parent. -// -/////////////////////////////////////////////////////////////////////////////// -class FillLayout : public LayoutManager { - public: - FillLayout(); - virtual ~FillLayout(); - - // Overridden from LayoutManager: - virtual void Layout(View* host); - virtual gfx::Size GetPreferredSize(View* host); - - private: - DISALLOW_EVIL_CONSTRUCTORS(FillLayout); -}; - -/////////////////////////////////////////////////////////////////////////////// -// -// HWNDViewContainer -// A container for a ChromeViews hierarchy used to represent anything that can -// be contained within an HWND, e.g. a control, a window, etc. Specializations -// suitable for specific tasks, e.g. top level window, are derived from this. -// -// This ViewContainer contains a RootView which owns the hierarchy of -// ChromeViews within it. As long as ChromeViews are part of this tree, they -// will be deleted automatically when the RootView is destroyed. If you remove -// a view from the tree, you are then responsible for cleaning up after it. -// -// Note: We try and keep this API platform-neutral, since to some extent we -// consider this the boundary between the platform and potentially cross -// platform ChromeViews code. In some cases this isn't true, primarily -// because of other code that has not yet been refactored to maintain -// this -- separation. -// -/////////////////////////////////////////////////////////////////////////////// -class HWNDViewContainer : public ViewContainer, - public MessageLoopForUI::Observer, - public FocusTraversable, - public AcceleratorTarget { - public: - HWNDViewContainer(); - virtual ~HWNDViewContainer(); - - // Initialize the container with a parent and an initial desired size. - // |contents_view| is the view that will be the single child of RootView - // within this ViewContainer. As contents_view is inserted into RootView's - // tree, RootView assumes ownership of this view and cleaning it up. If you - // remove this view, you are responsible for its destruction. If this value - // is NULL, the caller is responsible for populating the RootView, and sizing - // its contents as the window is sized. - // If |has_own_focus_manager| is true, the focus traversal stay confined to - // the window. - void Init(HWND parent, - const gfx::Rect& bounds, - 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; } - DWORD window_style() const { return window_style_; } - - // Sets the extended window styles. See comment about |set_window_style|. - void set_window_ex_style(DWORD style) { window_ex_style_ = style; } - DWORD window_ex_style() const { return window_ex_style_; }; - - // Sets the class style to use. The default is CS_DBLCLKS. - void set_initial_class_style(UINT class_style) { - // We dynamically generate the class name, so don't register it globally! - DCHECK((class_style & CS_GLOBALCLASS) == 0); - class_style_ = class_style; - } - UINT initial_class_style() { return class_style_; } - - void set_delete_on_destroy(bool delete_on_destroy) { - delete_on_destroy_ = delete_on_destroy; - } - - // Sets the initial opacity of a layered window, or updates the window's - // opacity if it is on the screen. - void SetLayeredAlpha(BYTE layered_alpha); - - // Disable Layered Window updates by setting to false. - void set_can_update_layered_window(bool can_update_layered_window) { - can_update_layered_window_ = can_update_layered_window; - } - - // Returns the RootView associated with the specified HWND (if any). - static RootView* FindRootView(HWND hwnd); - - // Closes the window asynchronously by scheduling a task for it. The window - // is destroyed as a result. - // This invokes Hide to hide the window, and schedules a task that - // invokes CloseNow. - virtual void Close(); - - // Hides the window. This does NOT delete the window, it just hides it. - virtual void Hide(); - - // Closes the window synchronously. Note that this should not be called from - // an ATL message callback as it deletes the HWNDDViewContainer and ATL will - // dereference it after the callback is processed. - void CloseNow(); - - // All classes registered by HWNDViewContainer start with this name. - static const wchar_t* const kBaseClassName; - - BEGIN_MSG_MAP_EX(0) - // Range handlers must go first! - MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) - MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE, WM_NCMOUSEMOVE, OnMouseRange) - MESSAGE_RANGE_HANDLER_EX(WM_SETTINGCHANGE, WM_SETTINGCHANGE, OnSettingChange) - - // Reflected message handler - MESSAGE_HANDLER_EX(kReflectedMessage, OnReflectedMessage) - - // CustomFrameWindow hacks - MESSAGE_HANDLER_EX(WM_NCUAHDRAWCAPTION, OnNCUAHDrawCaption) - MESSAGE_HANDLER_EX(WM_NCUAHDRAWFRAME, OnNCUAHDrawFrame) - - // Non-atlcrack.h handlers - MESSAGE_HANDLER_EX(WM_GETOBJECT, OnGetObject) - MESSAGE_HANDLER_EX(WM_NCMOUSELEAVE, OnNCMouseLeave) - MESSAGE_HANDLER_EX(WM_MOUSELEAVE, OnMouseLeave) - - // This list is in _ALPHABETICAL_ order! OR I WILL HURT YOU. - MSG_WM_ACTIVATE(OnActivate) - MSG_WM_APPCOMMAND(OnAppCommand) - MSG_WM_CANCELMODE(OnCancelMode) - MSG_WM_CAPTURECHANGED(OnCaptureChanged) - MSG_WM_CLOSE(OnClose) - MSG_WM_COMMAND(OnCommand) - MSG_WM_CREATE(OnCreate) - MSG_WM_DESTROY(OnDestroy) - MSG_WM_ERASEBKGND(OnEraseBkgnd) - MSG_WM_ENDSESSION(OnEndSession) - MSG_WM_EXITMENULOOP(OnExitMenuLoop) - MSG_WM_GETMINMAXINFO(OnGetMinMaxInfo) - MSG_WM_HSCROLL(OnHScroll) - MSG_WM_INITMENU(OnInitMenu) - MSG_WM_INITMENUPOPUP(OnInitMenuPopup) - MSG_WM_KEYDOWN(OnKeyDown) - MSG_WM_KEYUP(OnKeyUp) - MSG_WM_LBUTTONDBLCLK(OnLButtonDblClk) - MSG_WM_LBUTTONDOWN(OnLButtonDown) - MSG_WM_LBUTTONUP(OnLButtonUp) - MSG_WM_MBUTTONDOWN(OnMButtonDown) - MSG_WM_MBUTTONUP(OnMButtonUp) - MSG_WM_MBUTTONDBLCLK(OnMButtonDblClk) - MSG_WM_MOUSEACTIVATE(OnMouseActivate) - MSG_WM_MOUSEMOVE(OnMouseMove) - MSG_WM_MOUSEWHEEL(OnMouseWheel) - MSG_WM_MOVE(OnMove) - MSG_WM_MOVING(OnMoving) - MSG_WM_NCACTIVATE(OnNCActivate) - MSG_WM_NCCALCSIZE(OnNCCalcSize) - MSG_WM_NCHITTEST(OnNCHitTest) - MSG_WM_NCMOUSEMOVE(OnNCMouseMove) - MSG_WM_NCLBUTTONDBLCLK(OnNCLButtonDblClk) - MSG_WM_NCLBUTTONDOWN(OnNCLButtonDown) - MSG_WM_NCLBUTTONUP(OnNCLButtonUp) - MSG_WM_NCPAINT(OnNCPaint) - MSG_WM_NCRBUTTONDBLCLK(OnNCRButtonDblClk) - MSG_WM_NCRBUTTONDOWN(OnNCRButtonDown) - MSG_WM_NCRBUTTONUP(OnNCRButtonUp) - MSG_WM_NOTIFY(OnNotify) - MSG_WM_PAINT(OnPaint) - MSG_WM_POWERBROADCAST(OnPowerBroadcast) - MSG_WM_RBUTTONDBLCLK(OnRButtonDblClk) - MSG_WM_RBUTTONDOWN(OnRButtonDown) - MSG_WM_RBUTTONUP(OnRButtonUp) - MSG_WM_SETCURSOR(OnSetCursor) - MSG_WM_SETFOCUS(OnSetFocus) - MSG_WM_SETICON(OnSetIcon) - MSG_WM_SETTEXT(OnSetText) - MSG_WM_SIZE(OnSize) - MSG_WM_SYSCOMMAND(OnSysCommand) - MSG_WM_THEMECHANGED(OnThemeChanged) - MSG_WM_VSCROLL(OnVScroll) - MSG_WM_WINDOWPOSCHANGED(OnWindowPosChanged) - END_MSG_MAP() - - // Overridden from ViewContainer: - virtual void GetBounds(CRect *out, bool including_frame) const; - virtual void MoveToFront(bool should_activate); - virtual HWND GetHWND() const; - virtual void PaintNow(const CRect& update_rect); - virtual RootView* GetRootView(); - virtual bool IsVisible(); - virtual bool IsActive(); - virtual TooltipManager* GetTooltipManager(); - - // Overridden from MessageLoop::Observer: - void WillProcessMessage(const MSG& msg); - virtual void DidProcessMessage(const MSG& msg); - - // Overridden from FocusTraversable: - virtual View* FindNextFocusableView(View* starting_view, - bool reverse, - Direction direction, - bool dont_loop, - FocusTraversable** focus_traversable, - View** focus_traversable_view); - virtual FocusTraversable* GetFocusTraversableParent(); - virtual View* GetFocusTraversableParentView(); - - // Overridden from AcceleratorTarget: - virtual bool AcceleratorPressed(const Accelerator& accelerator) { - return false; - } - - void SetFocusTraversableParent(FocusTraversable* parent); - void SetFocusTraversableParentView(View* parent_view); - - virtual bool GetAccelerator(int cmd_id, - ChromeViews::Accelerator* accelerator) { - return false; - } - - BOOL IsWindow() const { - return ::IsWindow(GetHWND()); - } - - BOOL ShowWindow(int command) { - DCHECK(::IsWindow(GetHWND())); - return ::ShowWindow(GetHWND(), command); - } - - HWND SetCapture() { - DCHECK(::IsWindow(GetHWND())); - return ::SetCapture(GetHWND()); - } - - HWND GetParent() const { - return ::GetParent(GetHWND()); - } - - BOOL GetWindowRect(RECT* rect) const { - return ::GetWindowRect(GetHWND(), rect); - } - - BOOL SetWindowPos(HWND hwnd_after, int x, int y, int cx, int cy, UINT flags) { - DCHECK(::IsWindow(GetHWND())); - return ::SetWindowPos(GetHWND(), hwnd_after, x, y, cx, cy, flags); - } - - BOOL IsZoomed() const { - DCHECK(::IsWindow(GetHWND())); - return ::IsZoomed(GetHWND()); - } - - BOOL MoveWindow(int x, int y, int width, int height) { - return MoveWindow(x, y, width, height, TRUE); - } - - BOOL MoveWindow(int x, int y, int width, int height, BOOL repaint) { - DCHECK(::IsWindow(GetHWND())); - return ::MoveWindow(GetHWND(), x, y, width, height, repaint); - } - - int SetWindowRgn(HRGN region, BOOL redraw) { - DCHECK(::IsWindow(GetHWND())); - return ::SetWindowRgn(GetHWND(), region, redraw); - } - - BOOL GetClientRect(RECT* rect) const { - DCHECK(::IsWindow(GetHWND())); - return ::GetClientRect(GetHWND(), rect); - } - - protected: - - // Call close instead of this to Destroy the window. - BOOL DestroyWindow() { - DCHECK(::IsWindow(GetHWND())); - return ::DestroyWindow(GetHWND()); - } - - // Message Handlers - // These are all virtual so that specialized view containers can modify or - // augment processing. - // This list is in _ALPHABETICAL_ order! - // Note: in the base class these functions must do nothing but convert point - // coordinates to client coordinates (if necessary) and forward the - // handling to the appropriate Process* function. This is so that - // subclasses can easily override these methods to do different things - // and have a convenient function to call to get the default behavior. - virtual void OnActivate(UINT action, BOOL minimized, HWND window) { } - virtual LRESULT OnAppCommand(HWND window, short app_command, WORD device, - int keystate) { - SetMsgHandled(FALSE); - return 0; - } - virtual void OnCancelMode() {} - virtual void OnCaptureChanged(HWND hwnd); - virtual void OnClose(); - virtual void OnCommand( - UINT notification_code, int command_id, HWND window) { SetMsgHandled(FALSE); } - virtual LRESULT OnCreate(LPCREATESTRUCT create_struct) { return 0; } - // WARNING: If you override this be sure and invoke super, otherwise we'll - // leak a few things. - virtual void OnDestroy(); - virtual void OnEndSession(BOOL ending, UINT logoff) { SetMsgHandled(FALSE); } - virtual void OnExitMenuLoop(BOOL is_track_popup_menu) { SetMsgHandled(FALSE); } - virtual LRESULT OnEraseBkgnd(HDC dc); - virtual void OnGetMinMaxInfo(LPMINMAXINFO mm_info) { } - virtual LRESULT OnGetObject(UINT uMsg, WPARAM w_param, LPARAM l_param); - virtual void OnHScroll(int scroll_type, short position, HWND scrollbar) { - SetMsgHandled(FALSE); - } - virtual void OnInitMenu(HMENU menu) { SetMsgHandled(FALSE); } - virtual void OnInitMenuPopup(HMENU menu, UINT position, BOOL is_system_menu) { - SetMsgHandled(FALSE); - } - virtual void OnKeyDown(TCHAR c, UINT rep_cnt, UINT flags); - virtual void OnKeyUp(TCHAR c, UINT rep_cnt, UINT flags); - virtual void OnLButtonDblClk(UINT flags, const CPoint& point); - virtual void OnLButtonDown(UINT flags, const CPoint& point); - virtual void OnLButtonUp(UINT flags, const CPoint& point); - virtual void OnMButtonDblClk(UINT flags, const CPoint& point); - virtual void OnMButtonDown(UINT flags, const CPoint& point); - virtual void OnMButtonUp(UINT flags, const CPoint& point); - virtual LRESULT OnMouseActivate(HWND window, UINT hittest_code, UINT message); - virtual void OnMouseMove(UINT flags, const CPoint& point); - virtual LRESULT OnMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param); - virtual void OnMove(const CPoint& point) { SetMsgHandled(FALSE); } - virtual void OnMoving(UINT param, const LPRECT new_bounds) { } - virtual LRESULT OnMouseWheel(UINT flags, short distance, const CPoint& point); - virtual LRESULT OnMouseRange(UINT msg, WPARAM w_param, LPARAM l_param); - virtual LRESULT OnNCActivate(BOOL active) { SetMsgHandled(FALSE); return 0; } - virtual LRESULT OnNCCalcSize(BOOL w_param, LPARAM l_param) { SetMsgHandled(FALSE); return 0; } - virtual LRESULT OnNCHitTest(const CPoint& pt) { SetMsgHandled(FALSE); return 0; } - virtual void OnNCLButtonDblClk(UINT flags, const CPoint& point); - virtual void OnNCLButtonDown(UINT flags, const CPoint& point); - virtual void OnNCLButtonUp(UINT flags, const CPoint& point); - virtual LRESULT OnNCMouseLeave(UINT uMsg, WPARAM w_param, LPARAM l_param); - virtual LRESULT OnNCMouseMove(UINT flags, const CPoint& point); - virtual void OnNCPaint(HRGN rgn) { SetMsgHandled(FALSE); } - virtual void OnNCRButtonDblClk(UINT flags, const CPoint& point); - virtual void OnNCRButtonDown(UINT flags, const CPoint& point); - virtual void OnNCRButtonUp(UINT flags, const CPoint& point); - virtual LRESULT OnNCUAHDrawCaption(UINT msg, - WPARAM w_param, - LPARAM l_param) { - SetMsgHandled(FALSE); - return 0; - } - virtual LRESULT OnNCUAHDrawFrame(UINT msg, WPARAM w_param, LPARAM l_param) { - SetMsgHandled(FALSE); - return 0; - } - virtual LRESULT OnNotify(int w_param, NMHDR* l_param); - virtual void OnPaint(HDC dc); - virtual LRESULT OnPowerBroadcast(DWORD power_event, DWORD data) { - SetMsgHandled(FALSE); - return 0; - } - virtual void OnRButtonDblClk(UINT flags, const CPoint& point); - virtual void OnRButtonDown(UINT flags, const CPoint& point); - virtual void OnRButtonUp(UINT flags, const CPoint& point); - virtual LRESULT OnReflectedMessage(UINT msg, WPARAM w_param, LPARAM l_param) { - SetMsgHandled(FALSE); - return 0; - } - virtual LRESULT OnSetCursor(HWND window, UINT hittest_code, UINT message) { - SetMsgHandled(FALSE); - return 0; - } - virtual void OnSetFocus(HWND focused_window) { - SetMsgHandled(FALSE); - } - virtual LRESULT OnSetIcon(UINT size_type, HICON new_icon) { - SetMsgHandled(FALSE); - return 0; - } - virtual LRESULT OnSetText(const wchar_t* text) { - SetMsgHandled(FALSE); - return 0; - } - virtual LRESULT OnSettingChange(UINT msg, WPARAM w_param, LPARAM l_param); - virtual void OnSize(UINT param, const CSize& size); - virtual void OnSysCommand(UINT notification_code, CPoint click) { } - virtual void OnThemeChanged(); - virtual void OnVScroll(int scroll_type, short position, HWND scrollbar) { - SetMsgHandled(FALSE); - } - virtual void OnWindowPosChanged(WINDOWPOS* window_pos) { - SetMsgHandled(FALSE); - } - - // deletes this window as it is destroyed, override to provide different - // behavior. - virtual void OnFinalMessage(HWND window); - - // Start tracking all mouse events so that this window gets sent mouse leave - // messages too. |is_nonclient| is true when we should track WM_NCMOUSELEAVE - // messages instead of WM_MOUSELEAVE ones. - void TrackMouseEvents(DWORD mouse_tracking_flags); - - // Actually handle mouse events. These functions are called by subclasses who - // override the message handlers above to do the actual real work of handling - // the event in the View system. - bool ProcessMousePressed(const CPoint& point, UINT flags, bool dbl_click); - void ProcessMouseDragged(const CPoint& point, UINT flags); - void ProcessMouseReleased(const CPoint& point, UINT flags); - void ProcessMouseMoved(const CPoint& point, UINT flags, bool is_nonclient); - void ProcessMouseExited(); - - // Makes sure the window still fits on screen after a settings change message - // from the OS, e.g. a screen resolution change. - virtual void AdjustWindowToFitScreenSize(); - - // Handles re-laying out content in response to a window size change. - virtual void ChangeSize(UINT size_param, const CSize& size); - - // Returns whether capture should be released on mouse release. The default - // is true. - virtual bool ReleaseCaptureOnMouseReleased() { return true; } - - enum FrameAction {FA_NONE = 0, FA_RESIZING, FA_MOVING, FA_FORWARDING}; - - virtual RootView* CreateRootView(); - - // Returns true if this HWNDViewContainer is opaque. - bool opaque() const { return opaque_; } - - // The root of the View hierarchy attached to this window. - scoped_ptr root_view_; - - // Current frame ui action - FrameAction current_action_; - - // Whether or not we have capture the mouse. - bool has_capture_; - - // If true, the mouse is currently down. - bool is_mouse_down_; - - scoped_ptr tooltip_manager_; - - private: - // Resize the bitmap used to contain the contents of the layered window. This - // recreates the entire bitmap. - void SizeContents(const CRect& window_rect); - - // Paint into a DIB and then update the layered window with its contents. - void PaintLayeredWindow(); - - // In layered mode, update the layered window. |dib_dc| represents a handle - // to a device context that contains the contents of the window. - void UpdateWindowFromContents(HDC dib_dc); - - // Invoked from WM_DESTROY. Does appropriate cleanup and invokes OnDestroy - // so that subclasses can do any cleanup they need to. - void OnDestroyImpl(); - - // The windows procedure used by all HWNDViewContainers. - static LRESULT CALLBACK WndProc(HWND window, - UINT message, - WPARAM w_param, - LPARAM l_param); - - // Gets the window class name to use when creating the corresponding HWND. - // If necessary, this registers the window class. - std::wstring GetWindowClassName(); - - // The following factory is used for calls to close the HWNDViewContainer - // instance. - ScopedRunnableMethodFactory close_container_factory_; - - // The flags currently being used with TrackMouseEvent to track mouse - // messages. 0 if there is no active tracking. The value of this member is - // used when tracking is canceled. - DWORD active_mouse_tracking_flags_; - - // Whether or not this is a top level window. - bool toplevel_; - - bool opaque_; - - // Window Styles used when creating the window. - DWORD window_style_; - - // Window Extended Styles used when creating the window. - DWORD window_ex_style_; - - // Style of the class to use. - UINT class_style_; - - // Whether or not this is a layered window. - bool layered_; - - // The default alpha to be applied to the layered window. - BYTE layered_alpha_; - - // A canvas that contains the window contents in the case of a layered - // window. - scoped_ptr contents_; - - // Whether or not the window should delete itself when it is destroyed. - // Set this to false via its setter for stack allocated instances. - bool delete_on_destroy_; - - // True if we are allowed to update the layered window from the DIB backing - // store if necessary. - bool can_update_layered_window_; - - // The following are used to detect duplicate mouse move events and not - // deliver them. Displaying a window may result in the system generating - // duplicate move events even though the mouse hasn't moved. - - // If true, the last event was a mouse move event. - bool last_mouse_event_was_move_; - - // Coordinates of the last mouse move event, in screen coordinates. - int last_mouse_move_x_; - int last_mouse_move_y_; - - // Instance of accessibility information and handling for MSAA root - CComPtr accessibility_root_; - - // Our hwnd. - HWND hwnd_; -}; - -} // namespace ChromeViews - -#endif // #ifndef CHROME_VIEWS_HWND_VIEW_CONTAINER_H_ - diff --git a/chrome/views/label.cc b/chrome/views/label.cc index f6ce601..d918cd5 100644 --- a/chrome/views/label.cc +++ b/chrome/views/label.cc @@ -15,7 +15,7 @@ #include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" #include "chrome/views/background.h" -#include "chrome/views/view_container.h" +#include "chrome/views/container.h" namespace ChromeViews { diff --git a/chrome/views/menu_button.cc b/chrome/views/menu_button.cc index a7eeb46..847239a 100644 --- a/chrome/views/menu_button.cc +++ b/chrome/views/menu_button.cc @@ -14,10 +14,10 @@ #include "chrome/common/resource_bundle.h" #include "chrome/common/win_util.h" #include "chrome/views/button.h" +#include "chrome/views/container.h" #include "chrome/views/event.h" #include "chrome/views/root_view.h" #include "chrome/views/view_menu_delegate.h" -#include "chrome/views/view_container.h" #include "generated_resources.h" @@ -102,7 +102,7 @@ void MenuButton::Paint(ChromeCanvas* canvas, bool for_drag) { //////////////////////////////////////////////////////////////////////////////// int MenuButton::GetMaximumScreenXCoordinate() { - ViewContainer* vc = GetViewContainer(); + Container* vc = GetContainer(); if (!vc) { NOTREACHED(); @@ -156,7 +156,7 @@ bool MenuButton::Activate() { menu_visible_ = true; menu_delegate_->RunMenu(this, menu_position.ToPOINT(), - GetViewContainer()->GetHWND()); + GetContainer()->GetHWND()); menu_visible_ = false; menu_closed_time_ = Time::Now(); diff --git a/chrome/views/native_control.cc b/chrome/views/native_control.cc index db0403d..5c14c57 100644 --- a/chrome/views/native_control.cc +++ b/chrome/views/native_control.cc @@ -12,8 +12,8 @@ #include "base/win_util.h" #include "chrome/common/l10n_util.h" #include "chrome/views/border.h" +#include "chrome/views/container.h" #include "chrome/views/focus_manager.h" -#include "chrome/views/view_container.h" #include "chrome/views/hwnd_view.h" #include "chrome/views/background.h" #include "base/gfx/native_theme.h" @@ -36,7 +36,7 @@ class NativeControlContainer : public CWindowImplGetViewContainer()->GetHWND()); + Create(parent->GetContainer()->GetHWND()); ::ShowWindow(m_hWnd, SW_SHOW); } @@ -199,14 +199,14 @@ void NativeControl::ValidateNativeControl() { void NativeControl::ViewHierarchyChanged(bool is_add, View *parent, View *child) { - if (is_add && GetViewContainer()) { + if (is_add && GetContainer()) { ValidateNativeControl(); Layout(); } } void NativeControl::Layout() { - if (!container_ && GetViewContainer()) + if (!container_ && GetContainer()) ValidateNativeControl(); if (hwnd_view_) { diff --git a/chrome/views/native_scroll_bar.cc b/chrome/views/native_scroll_bar.cc index 6058646..53c5189 100644 --- a/chrome/views/native_scroll_bar.cc +++ b/chrome/views/native_scroll_bar.cc @@ -11,8 +11,8 @@ #include #include "base/message_loop.h" +#include "chrome/views/container.h" #include "chrome/views/hwnd_view.h" -#include "chrome/views/view_container.h" namespace ChromeViews { @@ -30,7 +30,7 @@ class ScrollBarContainer : public CWindowImplGetViewContainer()->GetHWND()); + Create(parent->GetContainer()->GetHWND()); ::ShowWindow(m_hWnd, SW_SHOW); } @@ -126,7 +126,7 @@ class ScrollBarContainer : public CWindowImplGetViewContainer(); + Container* vc = parent_->GetContainer(); if (vc && vc->GetHWND() != GetFocus()) { parent_->RequestFocus(); } @@ -227,8 +227,8 @@ NativeScrollBar::~NativeScrollBar() { void NativeScrollBar::ViewHierarchyChanged(bool is_add, View *parent, View *child) { - ViewContainer* vc; - if (is_add && (vc = GetViewContainer()) && !sb_view_) { + Container* vc; + if (is_add && (vc = GetContainer()) && !sb_view_) { sb_view_ = new HWNDView(); AddChildView(sb_view_); sb_container_ = new ScrollBarContainer(this); diff --git a/chrome/views/root_view.cc b/chrome/views/root_view.cc index c5b1979..5e7beff 100644 --- a/chrome/views/root_view.cc +++ b/chrome/views/root_view.cc @@ -12,7 +12,7 @@ #include "chrome/common/drag_drop_types.h" #include "chrome/common/gfx/chrome_canvas.h" #include "chrome/views/root_view_drop_target.h" -#include "chrome/views/view_container.h" +#include "chrome/views/container.h" namespace ChromeViews { @@ -51,8 +51,8 @@ const char RootView::kViewClassName[] = "chrome/views/RootView"; // ///////////////////////////////////////////////////////////////////////////// -RootView::RootView(ViewContainer* view_container) - : view_container_(view_container), +RootView::RootView(Container* container) + : container_(container), invalid_rect_(0,0,0,0), mouse_pressed_handler_(NULL), mouse_move_handler_(NULL), @@ -178,7 +178,7 @@ void RootView::PaintNow() { } if (!paint_task_needed_) return; - ViewContainer* vc = GetViewContainer(); + Container* vc = GetContainer(); if (vc) vc->PaintNow(invalid_rect_); } @@ -216,8 +216,8 @@ CRect RootView::GetScheduledPaintRectConstrainedToSize() { // ///////////////////////////////////////////////////////////////////////////// -ViewContainer* RootView::GetViewContainer() const { - return view_container_; +Container* RootView::GetContainer() const { + return container_; } ///////////////////////////////////////////////////////////////////////////// @@ -315,7 +315,7 @@ bool RootView::OnMousePressed(const MouseEvent& e) { mouse_pressed_handler_ = NULL; if (focus_on_mouse_pressed_) { - HWND hwnd = view_container_->GetHWND(); + HWND hwnd = container_->GetHWND(); if (::GetFocus() != hwnd) { ::SetFocus(hwnd); } @@ -331,7 +331,7 @@ bool RootView::ConvertPointToMouseHandler(const gfx::Point& l, // window. (a non explicit mouse handler is automatically // cleared when the control is removed from the hierarchy) if (explicit_mouse_handler_) { - if (mouse_pressed_handler_->GetViewContainer()) { + if (mouse_pressed_handler_->GetContainer()) { *p = l; ConvertPointToScreen(this, p); ConvertPointToView(NULL, mouse_pressed_handler_, p); @@ -463,17 +463,17 @@ void RootView::SetMouseHandler(View *new_mh) { mouse_pressed_handler_ = new_mh; } -void RootView::OnViewContainerCreated() { +void RootView::OnContainerCreated() { DCHECK(!drop_target_.get()); drop_target_ = new RootViewDropTarget(this); } -void RootView::OnViewContainerDestroyed() { +void RootView::OnContainerDestroyed() { if (drop_target_.get()) { - RevokeDragDrop(GetViewContainer()->GetHWND()); + RevokeDragDrop(GetContainer()->GetHWND()); drop_target_ = NULL; } - view_container_ = NULL; + container_ = NULL; } void RootView::ProcessMouseDragCanceled() { @@ -493,7 +493,7 @@ void RootView::FocusView(View* view) { if (view != GetFocusedView()) { FocusManager* focus_manager = GetFocusManager(); DCHECK(focus_manager) << "No Focus Manager for Window " << - (GetViewContainer() ? GetViewContainer()->GetHWND() : 0); + (GetContainer() ? GetContainer()->GetHWND() : 0); if (!focus_manager) return; diff --git a/chrome/views/root_view.h b/chrome/views/root_view.h index 99d744b..14a3977 100644 --- a/chrome/views/root_view.h +++ b/chrome/views/root_view.h @@ -11,7 +11,7 @@ namespace ChromeViews { -class ViewContainer; +class Container; class PaintTask; class RootViewDropTarget; @@ -31,11 +31,11 @@ class FocusListener { // RootView class // // The RootView is the root of a View hierarchy. Its parent is not -// necessarily a ViewContainer, but the ViewContainer's View child is -// always a RootView. +// necessarily a Container, but the Container's View child is always a +// RootView. // // The RootView manages the View hierarchy's interface with the -// ViewContainer, and also maintains the current invalid rect - the region +// Container, and also maintains the current invalid rect - the region // that needs repainting. // ///////////////////////////////////////////////////////////////////////////// @@ -44,7 +44,7 @@ class RootView : public View, public: static const char kViewClassName[]; - explicit RootView(ViewContainer* view_container); + explicit RootView(Container* container); virtual ~RootView(); @@ -71,7 +71,7 @@ class RootView : public View, // returns whether this root view needs to paint as soon as possible. virtual bool NeedsPainting(bool urgent); - // Invoked by the ViewContainer to discover what rectangle should be + // Invoked by the Container to discover what rectangle should be // painted const CRect& GetScheduledPaintRect(); @@ -80,8 +80,8 @@ class RootView : public View, // Tree functions - // Get the ViewContainer that hosts this View. - virtual ViewContainer* GetViewContainer() const; + // Get the Container that hosts this View. + virtual Container* GetContainer() const; // The following event methods are overridden to propagate event to the // control tree @@ -91,19 +91,19 @@ class RootView : public View, virtual void OnMouseMoved(const MouseEvent& e); virtual void SetMouseHandler(View* new_mouse_handler); - // Invoked when the ViewContainers has been fully initialized. - // At the time the constructor is invoked the ViewContainer may not be + // Invoked when the Containers has been fully initialized. + // At the time the constructor is invoked the Container may not be // completely initialized, when this method is invoked, it is. - void OnViewContainerCreated(); + void OnContainerCreated(); - // Invoked prior to the ViewContainer being destroyed. - void OnViewContainerDestroyed(); + // Invoked prior to the Container being destroyed. + void OnContainerDestroyed(); - // Invoked By the ViewContainer if the mouse drag is interrupted by + // Invoked By the Container if the mouse drag is interrupted by // the system. Invokes OnMouseReleased with a value of true for canceled. void ProcessMouseDragCanceled(); - // Invoked by the ViewContainer instance when the mouse moves outside of + // Invoked by the Container instance when the mouse moves outside of // the container bounds virtual void ProcessOnMouseExited(); @@ -167,10 +167,10 @@ class RootView : public View, virtual std::string GetClassName() const; // Clears the region that is schedule to be painted. You nearly never need - // to invoke this. This is primarily intended for ViewContainers. + // to invoke this. This is primarily intended for Containers. void ClearPaintRect(); - // Invoked from the ViewContainer to service a WM_PAINT call. + // Invoked from the Container to service a WM_PAINT call. void OnPaint(HWND hwnd); // Returns the MSAA role of the current view. The role is what assistive @@ -202,7 +202,7 @@ class RootView : public View, DISALLOW_EVIL_CONSTRUCTORS(RootView); // Convert a point to our current mouse handler. Returns false if the - // mouse handler is not connected to a ViewContainer. In that case, the + // mouse handler is not connected to a Container. In that case, the // conversion cannot take place and *p is unchanged bool ConvertPointToMouseHandler(const gfx::Point& l, gfx::Point *p); @@ -267,8 +267,8 @@ class RootView : public View, // The view currently handling enter / exit View* mouse_move_handler_; - // The host ViewContainer - ViewContainer* view_container_; + // The host Container + Container* container_; // The rectangle that should be painted CRect invalid_rect_; diff --git a/chrome/views/root_view_drop_target.cc b/chrome/views/root_view_drop_target.cc index fae3265..a58320c 100644 --- a/chrome/views/root_view_drop_target.cc +++ b/chrome/views/root_view_drop_target.cc @@ -7,13 +7,13 @@ #include "base/gfx/point.h" #include "base/logging.h" #include "chrome/common/drag_drop_types.h" +#include "chrome/views/container.h" #include "chrome/views/root_view.h" -#include "chrome/views/view_container.h" namespace ChromeViews { RootViewDropTarget::RootViewDropTarget(RootView* root_view) - : BaseDropTarget(root_view->GetViewContainer()->GetHWND()), + : BaseDropTarget(root_view->GetContainer()->GetHWND()), root_view_(root_view), target_view_(NULL), deepest_view_(NULL) { diff --git a/chrome/views/tabbed_pane.cc b/chrome/views/tabbed_pane.cc index 473f1db..3d87ca8 100644 --- a/chrome/views/tabbed_pane.cc +++ b/chrome/views/tabbed_pane.cc @@ -16,7 +16,7 @@ #include "chrome/common/stl_util-inl.h" #include "chrome/common/throb_animation.h" #include "chrome/views/background.h" -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/container_win.h" #include "chrome/views/root_view.h" #include "skia/include/SkColor.h" @@ -166,7 +166,7 @@ HWND TabbedPane::CreateNativeControl(HWND parent_container) { SendMessage(tab_control_, WM_SETFONT, reinterpret_cast(font), FALSE); // Create the view container which is a child of the TabControl. - content_window_ = new HWNDViewContainer(); + content_window_ = new ContainerWin(); content_window_->Init(tab_control_, gfx::Rect(), false); // Explicitly setting the WS_EX_LAYOUTRTL property for the HWND (see above diff --git a/chrome/views/tabbed_pane.h b/chrome/views/tabbed_pane.h index 16cc575..d518a4e 100644 --- a/chrome/views/tabbed_pane.h +++ b/chrome/views/tabbed_pane.h @@ -12,7 +12,7 @@ namespace ChromeViews { // The TabbedPane class is a view that shows tabs. When the user clicks on a // tab, the associated view is displayed. // TODO (jcampan): implement GetPreferredSize(). -class HWNDViewContainer; +class ContainerWin; class TabbedPane : public NativeControl { public: @@ -75,7 +75,7 @@ class TabbedPane : public NativeControl { std::vector tab_views_; // The window displayed in the tab. - HWNDViewContainer* content_window_; + ContainerWin* content_window_; // The listener we notify about tab selection changes. Listener* listener_; diff --git a/chrome/views/table_view.cc b/chrome/views/table_view.cc index 21ada1f..ab33ebf 100644 --- a/chrome/views/table_view.cc +++ b/chrome/views/table_view.cc @@ -15,8 +15,8 @@ #include "chrome/common/gfx/icon_util.h" #include "chrome/common/resource_bundle.h" #include "chrome/common/win_util.h" +#include "chrome/views/container.h" #include "chrome/views/hwnd_view.h" -#include "chrome/views/view_container.h" #include "SkBitmap.h" #include "SkColorFilter.h" diff --git a/chrome/views/text_button.cc b/chrome/views/text_button.cc index c1631ff..91e2e9808 100644 --- a/chrome/views/text_button.cc +++ b/chrome/views/text_button.cc @@ -10,9 +10,9 @@ #include "chrome/common/throb_animation.h" #include "chrome/common/win_util.h" #include "chrome/views/button.h" +#include "chrome/views/container.h" #include "chrome/views/event.h" #include "chrome/views/view_menu_delegate.h" -#include "chrome/views/view_container.h" #include "generated_resources.h" diff --git a/chrome/views/text_field.cc b/chrome/views/text_field.cc index 6968b2b..2991040 100644 --- a/chrome/views/text_field.cc +++ b/chrome/views/text_field.cc @@ -20,9 +20,9 @@ #include "chrome/common/l10n_util.h" #include "chrome/common/logging_chrome.h" #include "chrome/common/win_util.h" +#include "chrome/views/container.h" #include "chrome/views/hwnd_view.h" #include "chrome/views/menu.h" -#include "chrome/views/view_container.h" #include "generated_resources.h" @@ -248,7 +248,7 @@ TextField::Edit::Edit(TextField* parent, bool draw_border) DWORD ex_style = l10n_util::GetExtendedStyles(); RECT r = {0, 0, parent_->width(), parent_->height()}; - Create(parent_->GetViewContainer()->GetHWND(), r, NULL, style, ex_style); + Create(parent_->GetContainer()->GetHWND(), r, NULL, style, ex_style); // Set up the text_object_model_. CComPtr ole_interface; @@ -800,9 +800,9 @@ TextField::~TextField() { } void TextField::ViewHierarchyChanged(bool is_add, View* parent, View* child) { - ViewContainer* vc; + Container* vc; - if (is_add && (vc = GetViewContainer())) { + if (is_add && (vc = GetContainer())) { // This notification is called from the AddChildView call below. Ignore it. if (native_view_ && !edit_) return; diff --git a/chrome/views/tooltip_manager.cc b/chrome/views/tooltip_manager.cc index e4ea574..aa37cf3 100644 --- a/chrome/views/tooltip_manager.cc +++ b/chrome/views/tooltip_manager.cc @@ -13,7 +13,7 @@ #include "chrome/views/root_view.h" #include "chrome/views/tooltip_manager.h" #include "chrome/views/view.h" -#include "chrome/views/view_container.h" +#include "chrome/views/container.h" namespace ChromeViews { @@ -76,8 +76,8 @@ const std::wstring& TooltipManager::GetLineSeparator() { return *separator; } -TooltipManager::TooltipManager(ViewContainer* container, HWND parent) - : view_container_(container), +TooltipManager::TooltipManager(Container* container, HWND parent) + : container_(container), parent_(parent), last_mouse_x_(-1), last_mouse_y_(-1), @@ -147,7 +147,7 @@ LRESULT TooltipManager::OnNotify(int w_param, NMHDR* l_param, bool* handled) { case TTN_GETDISPINFO: { if (last_view_out_of_sync_) { // View under the mouse is out of sync, determine it now. - RootView* root_view = view_container_->GetRootView(); + RootView* root_view = container_->GetRootView(); last_tooltip_view_ = root_view->GetViewForPoint( gfx::Point(last_mouse_x_, last_mouse_y_)); last_view_out_of_sync_ = false; @@ -165,7 +165,7 @@ LRESULT TooltipManager::OnNotify(int w_param, NMHDR* l_param, bool* handled) { tooltip_text_.clear(); // Mouse is over a View, ask the View for it's tooltip. gfx::Point view_loc(last_mouse_x_, last_mouse_y_); - View::ConvertPointToView(view_container_->GetRootView(), + View::ConvertPointToView(container_->GetRootView(), last_tooltip_view_, &view_loc); if (last_tooltip_view_->GetTooltipText(view_loc.x(), view_loc.y(), &tooltip_text_) && @@ -194,7 +194,7 @@ LRESULT TooltipManager::OnNotify(int w_param, NMHDR* l_param, bool* handled) { if (tooltip_height_ == 0) tooltip_height_ = CalcTooltipHeight(); gfx::Point view_loc(last_mouse_x_, last_mouse_y_); - View::ConvertPointToView(view_container_->GetRootView(), + View::ConvertPointToView(container_->GetRootView(), last_tooltip_view_, &view_loc); if (last_tooltip_view_->GetTooltipTextOrigin( view_loc.x(), view_loc.y(), &text_origin) && @@ -284,7 +284,7 @@ void TooltipManager::TrimTooltipToFit(std::wstring* text, // Determine the available width for the tooltip. gfx::Point screen_loc(position_x, position_y); - View::ConvertPointToScreen(view_container_->GetRootView(), &screen_loc); + View::ConvertPointToScreen(container_->GetRootView(), &screen_loc); gfx::Rect monitor_bounds = win_util::GetMonitorBoundsForRect(gfx::Rect(screen_loc.x(), screen_loc.y(), 0, 0)); @@ -319,7 +319,7 @@ void TooltipManager::TrimTooltipToFit(std::wstring* text, } void TooltipManager::UpdateTooltip(int x, int y) { - RootView* root_view = view_container_->GetRootView(); + RootView* root_view = container_->GetRootView(); View* view = root_view->GetViewForPoint(gfx::Point(x, y)); if (view != last_tooltip_view_) { // NOTE: This *must* be sent regardless of the visibility of the tooltip. @@ -352,7 +352,7 @@ void TooltipManager::OnMouse(UINT u_msg, WPARAM w_param, LPARAM l_param) { if (u_msg >= WM_NCMOUSEMOVE && u_msg <= WM_NCXBUTTONDBLCLK) { // NC message coordinates are in screen coordinates. CRect frame_bounds; - view_container_->GetBounds(&frame_bounds, true); + container_->GetBounds(&frame_bounds, true); x -= frame_bounds.left; y -= frame_bounds.top; } @@ -385,8 +385,8 @@ void TooltipManager::ShowKeyboardTooltip(View* focused_view) { gfx::Point screen_point; focused_view->ConvertPointToScreen(focused_view, &screen_point); gfx::Point relative_point_coordinates; - focused_view->ConvertPointToViewContainer(focused_view, - &relative_point_coordinates); + focused_view->ConvertPointToContainer(focused_view, + &relative_point_coordinates); keyboard_tooltip_hwnd_ = CreateWindowEx( WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(), TOOLTIPS_CLASS, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL); diff --git a/chrome/views/tooltip_manager.h b/chrome/views/tooltip_manager.h index cb793fa..b48ddeb 100644 --- a/chrome/views/tooltip_manager.h +++ b/chrome/views/tooltip_manager.h @@ -13,11 +13,11 @@ class ChromeFont; namespace ChromeViews { +class Container; class View; -class ViewContainer; // TooltipManager takes care of the wiring to support tooltips for Views. -// This class is intended to be used by ViewContainers. To use this, you must +// This class is intended to be used by Containers. To use this, you must // do the following: // Add the following to your MSG_MAP: // @@ -57,8 +57,8 @@ class TooltipManager { // Returns the separator for lines of text in a tooltip. static const std::wstring& GetLineSeparator(); - // Creates a TooltipManager for the specified ViewContainer and parent window. - TooltipManager(ViewContainer* container, HWND parent); + // Creates a TooltipManager for the specified Container and parent window. + TooltipManager(Container* container, HWND parent); virtual ~TooltipManager(); // Notification that the view hierarchy has changed in some way. @@ -122,7 +122,7 @@ class TooltipManager { void DestroyKeyboardTooltipWindow(HWND window_to_destroy); // Hosting view container. - ViewContainer* view_container_; + Container* container_; // The View the mouse is under. This is null if the mouse isn't under a // View. diff --git a/chrome/views/tree_view.cc b/chrome/views/tree_view.cc index 662f7194..2dca467 100644 --- a/chrome/views/tree_view.cc +++ b/chrome/views/tree_view.cc @@ -13,8 +13,8 @@ #include "chrome/common/l10n_util.h" #include "chrome/common/resource_bundle.h" #include "chrome/common/stl_util-inl.h" +#include "chrome/views/container.h" #include "chrome/views/focus_manager.h" -#include "chrome/views/view_container.h" namespace ChromeViews { @@ -411,7 +411,7 @@ bool TreeView::OnKeyDown(int virtual_key_code) { } return true; } else if (virtual_key_code == VK_RETURN && !process_enter_) { - ViewContainer* vc = GetViewContainer(); + Container* vc = GetContainer(); DCHECK(vc); FocusManager* fm = FocusManager::GetFocusManager(vc->GetHWND()); DCHECK(fm); diff --git a/chrome/views/view.cc b/chrome/views/view.cc index cbb1b25..6b8f53e 100644 --- a/chrome/views/view.cc +++ b/chrome/views/view.cc @@ -22,10 +22,10 @@ #include "chrome/views/accessibility/accessible_wrapper.h" #include "chrome/views/background.h" #include "chrome/views/border.h" +#include "chrome/views/container.h" #include "chrome/views/layout_manager.h" #include "chrome/views/root_view.h" #include "chrome/views/tooltip_manager.h" -#include "chrome/views/view_container.h" #include "SkShader.h" namespace ChromeViews { @@ -323,7 +323,7 @@ void View::SetFocusable(bool focusable) { } FocusManager* View::GetFocusManager() { - ViewContainer* container = GetViewContainer(); + Container* container = GetContainer(); if (!container) return NULL; @@ -803,14 +803,14 @@ View* View::GetViewForPoint(const gfx::Point& point, return this; } -ViewContainer* View::GetViewContainer() const { +Container* View::GetContainer() const { // The root view holds a reference to this view hierarchy's container. - return parent_ ? parent_->GetViewContainer() : NULL; + return parent_ ? parent_->GetContainer() : NULL; } // Get the containing RootView RootView* View::GetRootView() { - ViewContainer* vc = GetViewContainer(); + Container* vc = GetContainer(); if (vc) { return vc->GetRootView(); } else { @@ -1319,7 +1319,7 @@ void View::ConvertPointToView(View* src, View* dst, gfx::Point* point, // If src is NULL, sp is in the screen coordinate system if (src == NULL) { - ViewContainer* vc = dst->GetViewContainer(); + Container* vc = dst->GetContainer(); if (vc) { CRect b; vc->GetBounds(&b, false); @@ -1330,7 +1330,7 @@ void View::ConvertPointToView(View* src, View* dst, gfx::Point* point, } // static -void View::ConvertPointToViewContainer(View* src, gfx::Point* p) { +void View::ConvertPointToContainer(View* src, gfx::Point* p) { DCHECK(src); DCHECK(p); @@ -1344,9 +1344,9 @@ void View::ConvertPointToViewContainer(View* src, gfx::Point* p) { } // static -void View::ConvertPointFromViewContainer(View *source, gfx::Point* p) { +void View::ConvertPointFromContainer(View *source, gfx::Point* p) { gfx::Point t; - ConvertPointToViewContainer(source, &t); + ConvertPointToContainer(source, &t); p->SetPoint(p->x() - t.x(), p->y() - t.y()); } @@ -1356,9 +1356,9 @@ void View::ConvertPointToScreen(View* src, gfx::Point* p) { DCHECK(p); // If the view is not connected to a tree, there's nothing we can do. - ViewContainer* vc = src->GetViewContainer(); + Container* vc = src->GetContainer(); if (vc) { - ConvertPointToViewContainer(src, p); + ConvertPointToContainer(src, p); CRect r; vc->GetBounds(&r, false); p->SetPoint(p->x() + r.left, p->y() + r.top); @@ -1531,7 +1531,7 @@ void View::Focus() { // messages. FocusManager* focus_manager = GetFocusManager(); if (focus_manager) - focus_manager->FocusHWND(GetRootView()->GetViewContainer()->GetHWND()); + focus_manager->FocusHWND(GetRootView()->GetContainer()->GetHWND()); } bool View::CanProcessTabKeyEvents() { @@ -1548,13 +1548,13 @@ bool View::GetTooltipTextOrigin(int x, int y, CPoint* loc) { } void View::TooltipTextChanged() { - ViewContainer* view_container = GetViewContainer(); + Container* view_container = GetContainer(); if (view_container != NULL && view_container->GetTooltipManager()) view_container->GetTooltipManager()->TooltipTextChanged(this); } void View::UpdateTooltip() { - ViewContainer* view_container = GetViewContainer(); + Container* view_container = GetContainer(); if (view_container != NULL && view_container->GetTooltipManager()) view_container->GetTooltipManager()->UpdateTooltip(); } @@ -1587,8 +1587,8 @@ gfx::Rect View::GetVisibleBounds() { ancestor_bounds.SetRect(0, 0, ancestor->width(), ancestor->height()); vis_bounds = vis_bounds.Intersect(ancestor_bounds); - } else if (!view->GetViewContainer()) { - // If the view has no ViewContainer, we're not visible. Return an empty + } else if (!view->GetContainer()) { + // If the view has no Container, we're not visible. Return an empty // rect. return gfx::Rect(); } diff --git a/chrome/views/view.h b/chrome/views/view.h index 18314b0..2d0f21e 100644 --- a/chrome/views/view.h +++ b/chrome/views/view.h @@ -31,13 +31,13 @@ namespace ChromeViews { class Background; class Border; +class Container; class FocusManager; class FocusTraversable; class LayoutManager; class RestoreFocusTask; class RootView; class ScrollView; -class ViewContainer; // ContextMenuController is responsible for showing the context menu for a // View. To use a ContextMenuController invoke SetContextMenuController on a @@ -430,8 +430,8 @@ class View : public AcceleratorTarget { // Get the child View at the specified point. virtual View* GetViewForPoint(const gfx::Point& point); - // Get the containing ViewContainer - virtual ViewContainer* GetViewContainer() const; + // Get the Container that hosts this View, if any. + virtual Container* GetContainer() const; // Get the containing RootView virtual RootView* GetRootView(); @@ -503,7 +503,7 @@ class View : public AcceleratorTarget { // Convenience method to retrieve the FocusManager associated with the // container window that contains this view. This can return NULL if this - // view is not part of a view hierarchy with a ViewContainer. + // view is not part of a view hierarchy with a Container. virtual FocusManager* GetFocusManager(); // Sets a keyboard accelerator for that view. When the user presses the @@ -675,13 +675,13 @@ class View : public AcceleratorTarget { gfx::Point* point); // Convert a point from the coordinate system of a View to that of the - // ViewContainer. This is useful for example when sizing HWND children - // of the ViewContainer that don't know about the View hierarchy and need - // to be placed relative to the ViewContainer that is their parent. - static void ConvertPointToViewContainer(View* src, gfx::Point* point); + // Container. This is useful for example when sizing HWND children of the + // Container that don't know about the View hierarchy and need to be placed + // relative to the Container that is their parent. + static void ConvertPointToContainer(View* src, gfx::Point* point); - // Convert a point from a view ViewContainer to a View dest - static void ConvertPointFromViewContainer(View *dest, gfx::Point* p); + // Convert a point from a view Container to a View dest + static void ConvertPointFromContainer(View *dest, gfx::Point* p); // Convert a point from the coordinate system of a View to that of the // screen. This is useful for example when placing popup windows. @@ -1168,7 +1168,7 @@ class View : public AcceleratorTarget { gfx::Point* point, bool try_other_direction); - // Propagates UpdateTooltip() to the TooltipManager for the ViewContainer. + // Propagates UpdateTooltip() to the TooltipManager for the Container. // This must be invoked any time the View hierarchy changes in such a way // the view under the mouse differs. For example, if the bounds of a View is // changed, this is invoked. Similarly, as Views are added/removed, this diff --git a/chrome/views/view_container.h b/chrome/views/view_container.h deleted file mode 100644 index 52ef668..0000000 --- a/chrome/views/view_container.h +++ /dev/null @@ -1,86 +0,0 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef CHROME_VIEWS_VIEW_CONTAINER_H_ -#define CHROME_VIEWS_VIEW_CONTAINER_H_ - -// TODO(maruel): Remove once HWND is abstracted. -#include - -// TODO(maruel): Remove once gfx::Rect is used instead. -namespace WTL { -class CRect; -} -using WTL::CRect; - -namespace ChromeViews { - -class RootView; -class TooltipManager; -class Accelerator; - -///////////////////////////////////////////////////////////////////////////// -// -// ViewContainer class -// -// ViewContainer is an abstract class that defines the API that should -// be implemented by a CWindow / HWND implementation in order to host a view -// hierarchy. -// -// ViewContainer wraps a hierarchy of View objects (see view.h) that -// implement painting and flexible layout within the bounds of the -// ViewContainer's window. -// -// The ViewContainer is responsible for handling various system events and -// forwarding them to the appropriate view. -// -///////////////////////////////////////////////////////////////////////////// - -class ViewContainer { - public: - virtual ~ViewContainer() { } - - // Returns the bounds of this container in the screen coordinate system. - // If the receiving view container is a frame which is larger than its - // client area, this method returns the client area if including_frame is - // false and the frame bounds otherwise. If the receiving view container - // is not a frame, including_frame is ignored. - virtual void GetBounds(CRect *out, bool including_frame) const = 0; - - // Moves this view container to the front of the Z-Order - // If should_activate is TRUE, the window should also become the active - // window - virtual void MoveToFront(bool should_activate) = 0; - - // Returns the Window HWND associated with this container - virtual HWND GetHWND() const = 0; - - // Forces a paint of a specified rectangle immediately. - virtual void PaintNow(const CRect& update_rect) = 0; - - // Returns the RootView contained by this container - virtual RootView* GetRootView() = 0; - - // Returns whether the view container is visible to the user - virtual bool IsVisible() = 0; - - // Returns whether the view container is the currently active window. - virtual bool IsActive() = 0; - - // Returns the TooltipManager for this ViewContainer. If this ViewContainer - // does not support tooltips, NULL is returned. - virtual TooltipManager* GetTooltipManager() { - return NULL; - } - - // Returns the accelerator given a command id. Returns false if there is - // no accelerator associated with a given id, which is a common condition. - virtual bool GetAccelerator(int cmd_id, - Accelerator* accelerator) = 0; -}; - -} // namespace ChromeViews - -#endif // CHROME_VIEWS_VIEW_CONTAINER_H_ - diff --git a/chrome/views/view_unittest.cc b/chrome/views/view_unittest.cc index 91c556c..38df3bd 100644 --- a/chrome/views/view_unittest.cc +++ b/chrome/views/view_unittest.cc @@ -281,7 +281,7 @@ TEST_F(ViewTest, MouseEvent) { TestView* v2 = new TestView(); v2->SetBounds (100, 100, 100, 100); - ChromeViews::HWNDViewContainer window; + ChromeViews::ContainerWin window; window.set_delete_on_destroy(false); window.set_window_style(WS_OVERLAPPEDWINDOW); window.Init(NULL, gfx::Rect(50, 50, 650, 650), false); @@ -355,7 +355,7 @@ TEST_F(ViewTest, Painting) { RDW_UPDATENOW | RDW_INVALIDATE | RDW_ALLCHILDREN); bool empty_paint = paint_window.empty_paint(); - ChromeViews::HWNDViewContainer window; + ChromeViews::ContainerWin window; window.set_delete_on_destroy(false); window.set_window_style(WS_OVERLAPPEDWINDOW); window.Init(NULL, gfx::Rect(50, 50, 650, 650), NULL); @@ -442,7 +442,7 @@ TEST_F(ViewTest, RemoveNotification) { NotificationService::current()->AddObserver( observer.get(), NOTIFY_VIEW_REMOVED, NotificationService::AllSources()); - ChromeViews::HWNDViewContainer* window = new ChromeViews::HWNDViewContainer; + ChromeViews::ContainerWin* window = new ChromeViews::ContainerWin; ChromeViews::RootView* root_view = window->GetRootView(); View* v1 = new View; @@ -546,7 +546,7 @@ gfx::Point ConvertPointToView(ChromeViews::View* view, const gfx::Point& p) { } TEST_F(ViewTest, HitTestMasks) { - ChromeViews::HWNDViewContainer window; + ChromeViews::ContainerWin window; ChromeViews::RootView* root_view = window.GetRootView(); root_view->SetBounds(0, 0, 500, 500); diff --git a/chrome/views/views.vcproj b/chrome/views/views.vcproj index ecb5048..0a6ef96 100644 --- a/chrome/views/views.vcproj +++ b/chrome/views/views.vcproj @@ -258,6 +258,18 @@ > + + + + + + @@ -346,14 +358,6 @@ > - - - - @@ -598,10 +602,6 @@ > - - diff --git a/chrome/views/window.cc b/chrome/views/window.cc index 78df878..4c9de42 100644 --- a/chrome/views/window.cc +++ b/chrome/views/window.cc @@ -117,7 +117,7 @@ void Window::Close() { if (client_view_->CanClose()) { SaveWindowPosition(); RestoreEnabledIfNecessary(); - HWNDViewContainer::Close(); + ContainerWin::Close(); // If the user activates another app after opening us, then comes back and // closes us, we want our owner to gain activation. But only if the owner // is visible. If we don't manually force that here, the other app will @@ -259,7 +259,7 @@ gfx::Size Window::GetLocalizedContentsSize(int col_resource_id, // Window, protected: Window::Window(WindowDelegate* window_delegate) - : HWNDViewContainer(), + : ContainerWin(), focus_on_creation_(true), window_delegate_(window_delegate), non_client_view_(NULL), @@ -286,7 +286,7 @@ void Window::Init(HWND parent, const gfx::Rect& bounds) { // return NULL. owning_hwnd_ = parent; // We call this after initializing our members since our implementations of - // assorted HWNDViewContainer functions may be called during initialization. + // assorted ContainerWin functions may be called during initialization. is_modal_ = window_delegate_->IsModal(); if (is_modal_) BecomeModal(); @@ -297,7 +297,7 @@ void Window::Init(HWND parent, const gfx::Rect& bounds) { if (window_ex_style() == 0) set_window_ex_style(CalculateWindowExStyle()); - HWNDViewContainer::Init(parent, bounds, true); + ContainerWin::Init(parent, bounds, true); win_util::SetWindowUserData(GetHWND(), this); std::wstring window_title = window_delegate_->GetWindowTitle(); @@ -318,9 +318,9 @@ void Window::SetClientView(ClientView* client_view) { client_view_ = client_view; if (non_client_view_) { // This will trigger the ClientView to be added by the non-client view. - HWNDViewContainer::SetContentsView(non_client_view_); + ContainerWin::SetContentsView(non_client_view_); } else { - HWNDViewContainer::SetContentsView(client_view_); + ContainerWin::SetContentsView(client_view_); } } @@ -352,7 +352,7 @@ void Window::RunSystemMenu(const CPoint& point) { } /////////////////////////////////////////////////////////////////////////////// -// Window, HWNDViewContainer overrides: +// Window, ContainerWin overrides: void Window::OnActivate(UINT action, BOOL minimized, HWND window) { if (action == WA_INACTIVE) @@ -363,17 +363,15 @@ LRESULT Window::OnAppCommand(HWND window, short app_command, WORD device, int keystate) { // We treat APPCOMMAND ids as an extension of our command namespace, and just // let the delegate figure out what to do... - if (!window_delegate_->ExecuteWindowsCommand(app_command)) { - return HWNDViewContainer::OnAppCommand(window, app_command, device, - keystate); - } + if (!window_delegate_->ExecuteWindowsCommand(app_command)) + return ContainerWin::OnAppCommand(window, app_command, device, keystate); return 0; } void Window::OnCommand(UINT notification_code, int command_id, HWND window) { if (!window_delegate_->ExecuteWindowsCommand(command_id)) - HWNDViewContainer::OnCommand(notification_code, command_id, window); + ContainerWin::OnCommand(notification_code, command_id, window); } void Window::OnDestroy() { @@ -382,7 +380,7 @@ void Window::OnDestroy() { window_delegate_ = NULL; } RestoreEnabledIfNecessary(); - HWNDViewContainer::OnDestroy(); + ContainerWin::OnDestroy(); } LRESULT Window::OnEraseBkgnd(HDC dc) { @@ -396,7 +394,7 @@ LRESULT Window::OnNCActivate(BOOL active) { return DefWindowProc(GetHWND(), WM_NCACTIVATE, TRUE, 0); } // Otherwise just do the default thing. - return HWNDViewContainer::OnNCActivate(active); + return ContainerWin::OnNCActivate(active); } LRESULT Window::OnNCHitTest(const CPoint& point) { @@ -422,14 +420,14 @@ LRESULT Window::OnNCHitTest(const CPoint& point) { void Window::OnNCLButtonDown(UINT ht_component, const CPoint& point) { if (non_client_view_ && ht_component == HTSYSMENU) RunSystemMenu(non_client_view_->GetSystemMenuPoint()); - HWNDViewContainer::OnNCLButtonDown(ht_component, point); + ContainerWin::OnNCLButtonDown(ht_component, point); } void Window::OnNCRButtonDown(UINT ht_component, const CPoint& point) { if (ht_component == HTCAPTION || ht_component == HTSYSMENU) { RunSystemMenu(point); } else { - HWNDViewContainer::OnNCRButtonDown(ht_component, point); + ContainerWin::OnNCRButtonDown(ht_component, point); } } diff --git a/chrome/views/window.h b/chrome/views/window.h index fcf3e49..cfb0b88 100644 --- a/chrome/views/window.h +++ b/chrome/views/window.h @@ -5,7 +5,7 @@ #ifndef CHROME_VIEWS_WINDOW_H__ #define CHROME_VIEWS_WINDOW_H__ -#include "chrome/views/hwnd_view_container.h" +#include "chrome/views/container_win.h" namespace gfx { class Size; @@ -22,15 +22,15 @@ class Client; class NonClientView; class WindowDelegate; -//////////////////////////////////////////////////////////////////////////////// +/////////////////////////////////////////////////////////////////////////////// // // Window // -// A Window is a HWNDViewContainer that has a caption and a border. The frame -// is rendered by the operating system. +// A Window is a ContainerWin that has a caption and a border. The frame is +// rendered by the operating system. // -//////////////////////////////////////////////////////////////////////////////// -class Window : public HWNDViewContainer { +/////////////////////////////////////////////////////////////////////////////// +class Window : public ContainerWin { public: virtual ~Window(); @@ -156,7 +156,7 @@ class Window : public HWNDViewContainer { // Shows the system menu at the specified screen point. void RunSystemMenu(const CPoint& point); - // Overridden from HWNDViewContainer: + // Overridden from ContainerWin: virtual void OnActivate(UINT action, BOOL minimized, HWND window); virtual LRESULT OnAppCommand(HWND window, short app_command, WORD device, int keystate); -- cgit v1.1