Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(451)

Side by Side Diff: chrome/browser/ui/views/frame/browser_view.cc

Issue 5606012: Streamline the layout of the BrowserView's children TabContents views.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/views/frame/browser_view.h" 5 #include "chrome/browser/views/frame/browser_view.h"
6 6
7 #if defined(OS_LINUX) 7 #if defined(OS_LINUX)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 void BrowserView::ToggleTabStripMode() { 1344 void BrowserView::ToggleTabStripMode() {
1345 InitTabStrip(browser_->tabstrip_model()); 1345 InitTabStrip(browser_->tabstrip_model());
1346 frame_->TabStripDisplayModeChanged(); 1346 frame_->TabStripDisplayModeChanged();
1347 } 1347 }
1348 1348
1349 void BrowserView::PrepareForInstant() { 1349 void BrowserView::PrepareForInstant() {
1350 contents_->FadeActiveContents(); 1350 contents_->FadeActiveContents();
1351 } 1351 }
1352 1352
1353 void BrowserView::ShowInstant(TabContents* preview_contents) { 1353 void BrowserView::ShowInstant(TabContents* preview_contents) {
1354 if (!preview_container_) { 1354 if (!preview_container_)
1355 preview_container_ = new TabContentsContainer(); 1355 preview_container_ = new TabContentsContainer();
1356 preview_container_->set_reserved_area_delegate(this);
1357 }
1358 contents_->SetPreview(preview_container_, preview_contents); 1356 contents_->SetPreview(preview_container_, preview_contents);
1359 preview_container_->ChangeTabContents(preview_contents); 1357 preview_container_->ChangeTabContents(preview_contents);
1360 1358
1361 #if defined(OS_WIN) 1359 #if defined(OS_WIN)
1362 // Removing the fade is instant (on windows). We need to force the preview to 1360 // Removing the fade is instant (on windows). We need to force the preview to
1363 // draw, otherwise the current page flickers before the new page appears. 1361 // draw, otherwise the current page flickers before the new page appears.
1364 RedrawWindow(preview_contents->view()->GetContentNativeView(), NULL, NULL, 1362 RedrawWindow(preview_contents->view()->GetContentNativeView(), NULL, NULL,
1365 RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN); 1363 RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN);
1366 #endif 1364 #endif
1367 1365
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
1807 } 1805 }
1808 1806
1809 AccessibilityTypes::Role BrowserView::GetAccessibleRole() { 1807 AccessibilityTypes::Role BrowserView::GetAccessibleRole() {
1810 return AccessibilityTypes::ROLE_CLIENT; 1808 return AccessibilityTypes::ROLE_CLIENT;
1811 } 1809 }
1812 1810
1813 void BrowserView::InfoBarSizeChanged(bool is_animating) { 1811 void BrowserView::InfoBarSizeChanged(bool is_animating) {
1814 SelectedTabToolbarSizeChanged(is_animating); 1812 SelectedTabToolbarSizeChanged(is_animating);
1815 } 1813 }
1816 1814
1817 void BrowserView::UpdateReservedContentsRect( 1815 void BrowserView::SplitHandleMoved(views::SingleSplitView* view) {
1818 const TabContentsContainer* source) { 1816 for (int i = 0; i < view->GetChildViewCount(); ++i)
1819 RenderWidgetHostView* render_widget_host_view = 1817 view->GetChildViewAt(i)->InvalidateLayout();
1820 source->tab_contents() ? source->tab_contents()->GetRenderWidgetHostView() 1818 SchedulePaint();
1821 : NULL; 1819 Layout();
1822 if (!render_widget_host_view)
1823 return;
1824
1825 gfx::Rect reserved_rect;
1826
1827 if (!frame_->GetWindow()->IsMaximized() &&
1828 !frame_->GetWindow()->IsFullscreen()) {
1829 gfx::Size resize_corner_size = ResizeCorner::GetSize();
1830 if (!resize_corner_size.IsEmpty()) {
1831 gfx::Point resize_corner_origin;
1832 gfx::Rect bounds = GetLocalBounds(false);
1833 resize_corner_origin.set_x(bounds.right() - resize_corner_size.width());
1834 resize_corner_origin.set_y(bounds.bottom() - resize_corner_size.height());
1835
1836 View::ConvertPointToView(this, source, &resize_corner_origin);
1837
1838 gfx::Size container_size = source->size();
1839
1840 if (resize_corner_origin.x() < container_size.width() &&
1841 resize_corner_origin.y() < container_size.height()) {
1842 reserved_rect = gfx::Rect(resize_corner_origin, resize_corner_size);
1843 }
1844 }
1845 }
1846
1847 // TODO(alekseys): for source == contents_container_, consult SidebarTabView
1848 // for the current size to reserve. Something like this:
1849 // reserved_rect = reserved_rect.Union(SidebarTabView::GetCurrentBounds());
1850
1851 render_widget_host_view->set_reserved_contents_rect(reserved_rect);
1852 } 1820 }
1853 1821
1854 views::LayoutManager* BrowserView::CreateLayoutManager() const { 1822 views::LayoutManager* BrowserView::CreateLayoutManager() const {
1855 return new BrowserViewLayout; 1823 return new BrowserViewLayout;
1856 } 1824 }
1857 1825
1858 void BrowserView::InitTabStrip(TabStripModel* model) { 1826 void BrowserView::InitTabStrip(TabStripModel* model) {
1859 // Throw away the existing tabstrip if we're switching display modes. 1827 // Throw away the existing tabstrip if we're switching display modes.
1860 scoped_ptr<BaseTabStrip> old_strip(tabstrip_); 1828 scoped_ptr<BaseTabStrip> old_strip(tabstrip_);
1861 if (tabstrip_) { 1829 if (tabstrip_) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1904 toolbar_ = new ToolbarView(browser_.get()); 1872 toolbar_ = new ToolbarView(browser_.get());
1905 AddChildView(toolbar_); 1873 AddChildView(toolbar_);
1906 toolbar_->Init(browser_->profile()); 1874 toolbar_->Init(browser_->profile());
1907 toolbar_->SetAccessibleName( 1875 toolbar_->SetAccessibleName(
1908 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLBAR))); 1876 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_TOOLBAR)));
1909 1877
1910 infobar_container_ = new InfoBarContainer(this); 1878 infobar_container_ = new InfoBarContainer(this);
1911 AddChildView(infobar_container_); 1879 AddChildView(infobar_container_);
1912 1880
1913 contents_container_ = new TabContentsContainer; 1881 contents_container_ = new TabContentsContainer;
1914 contents_container_->set_reserved_area_delegate(this);
1915 contents_ = new ContentsContainer(contents_container_); 1882 contents_ = new ContentsContainer(contents_container_);
1916 1883
1917 SkColor bg_color = GetWidget()->GetThemeProvider()-> 1884 SkColor bg_color = GetWidget()->GetThemeProvider()->
1918 GetColor(BrowserThemeProvider::COLOR_TOOLBAR); 1885 GetColor(BrowserThemeProvider::COLOR_TOOLBAR);
1919 1886
1920 bool sidebar_allowed = SidebarManager::IsSidebarAllowed(); 1887 bool sidebar_allowed = SidebarManager::IsSidebarAllowed();
1921 if (sidebar_allowed) { 1888 if (sidebar_allowed) {
1922 sidebar_container_ = new TabContentsContainer; 1889 sidebar_container_ = new TabContentsContainer;
1923 sidebar_container_->set_reserved_area_delegate(this);
1924 sidebar_container_->SetID(VIEW_ID_SIDE_BAR_CONTAINER); 1890 sidebar_container_->SetID(VIEW_ID_SIDE_BAR_CONTAINER);
1925 sidebar_container_->SetVisible(false); 1891 sidebar_container_->SetVisible(false);
1926 1892
1927 sidebar_split_ = new views::SingleSplitView( 1893 sidebar_split_ = new views::SingleSplitView(
1928 contents_, 1894 contents_,
1929 sidebar_container_, 1895 sidebar_container_,
1930 views::SingleSplitView::HORIZONTAL_SPLIT); 1896 views::SingleSplitView::HORIZONTAL_SPLIT,
1897 this);
1931 sidebar_split_->SetID(VIEW_ID_SIDE_BAR_SPLIT); 1898 sidebar_split_->SetID(VIEW_ID_SIDE_BAR_SPLIT);
1932 sidebar_split_->SetAccessibleName( 1899 sidebar_split_->SetAccessibleName(
1933 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_SIDE_BAR))); 1900 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_SIDE_BAR)));
1934 sidebar_split_->set_background( 1901 sidebar_split_->set_background(
1935 views::Background::CreateSolidBackground(bg_color)); 1902 views::Background::CreateSolidBackground(bg_color));
1936 } 1903 }
1937 1904
1938 devtools_container_ = new TabContentsContainer; 1905 devtools_container_ = new TabContentsContainer;
1939 devtools_container_->set_reserved_area_delegate(this);
1940 devtools_container_->SetID(VIEW_ID_DEV_TOOLS_DOCKED); 1906 devtools_container_->SetID(VIEW_ID_DEV_TOOLS_DOCKED);
1941 devtools_container_->SetVisible(false); 1907 devtools_container_->SetVisible(false);
1942 1908
1943 views::View* contents_view = contents_; 1909 views::View* contents_view = contents_;
1944 if (sidebar_allowed) 1910 if (sidebar_allowed)
1945 contents_view = sidebar_split_; 1911 contents_view = sidebar_split_;
1946 1912
1947 contents_split_ = new views::SingleSplitView( 1913 contents_split_ = new views::SingleSplitView(
1948 contents_view, 1914 contents_view,
1949 devtools_container_, 1915 devtools_container_,
1950 views::SingleSplitView::VERTICAL_SPLIT); 1916 views::SingleSplitView::VERTICAL_SPLIT,
1917 this);
1951 contents_split_->SetID(VIEW_ID_CONTENTS_SPLIT); 1918 contents_split_->SetID(VIEW_ID_CONTENTS_SPLIT);
1952 contents_split_->SetAccessibleName( 1919 contents_split_->SetAccessibleName(
1953 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_WEB_CONTENTS))); 1920 UTF16ToWide(l10n_util::GetStringUTF16(IDS_ACCNAME_WEB_CONTENTS)));
1954 contents_split_->set_background( 1921 contents_split_->set_background(
1955 views::Background::CreateSolidBackground(bg_color)); 1922 views::Background::CreateSolidBackground(bg_color));
1956 AddChildView(contents_split_); 1923 AddChildView(contents_split_);
1957 set_contents_view(contents_split_); 1924 set_contents_view(contents_split_);
1958 1925
1959 status_bubble_.reset(new StatusBubbleViews(contents_)); 1926 status_bubble_.reset(new StatusBubbleViews(contents_));
1960 1927
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
2488 // handlers when we are eventually shown. 2455 // handlers when we are eventually shown.
2489 new_contents->view()->RestoreFocus(); 2456 new_contents->view()->RestoreFocus();
2490 } 2457 }
2491 2458
2492 // Update all the UI bits. 2459 // Update all the UI bits.
2493 UpdateTitleBar(); 2460 UpdateTitleBar();
2494 UpdateToolbar(new_contents, true); 2461 UpdateToolbar(new_contents, true);
2495 UpdateUIForContents(new_contents); 2462 UpdateUIForContents(new_contents);
2496 } 2463 }
2497 2464
2465 gfx::Size BrowserView::GetResizeCornerSize() const {
2466 return ResizeCorner::GetSize();
2467 }
2468
2498 #if !defined(OS_CHROMEOS) 2469 #if !defined(OS_CHROMEOS)
2499 // static 2470 // static
2500 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { 2471 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) {
2501 // Create the view and the frame. The frame will attach itself via the view 2472 // Create the view and the frame. The frame will attach itself via the view
2502 // so we don't need to do anything with the pointer. 2473 // so we don't need to do anything with the pointer.
2503 BrowserView* view = new BrowserView(browser); 2474 BrowserView* view = new BrowserView(browser);
2504 BrowserFrame::Create(view, browser->profile()); 2475 BrowserFrame::Create(view, browser->profile());
2505 2476
2506 view->GetWindow()->GetNonClientView()->SetAccessibleName( 2477 view->GetWindow()->GetNonClientView()->SetAccessibleName(
2507 UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); 2478 UTF16ToWide(l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
2508 2479
2509 return view; 2480 return view;
2510 } 2481 }
2511 #endif 2482 #endif
2512 2483
2513 // static 2484 // static
2514 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { 2485 FindBar* BrowserWindow::CreateFindBar(Browser* browser) {
2515 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); 2486 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window()));
2516 } 2487 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698