OLD | NEW |
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 SkRect rect; | 193 SkRect rect; |
194 double roundness = 0; | 194 double roundness = 0; |
195 DetachableToolbarView::CalculateContentArea(current_state, h_padding, | 195 DetachableToolbarView::CalculateContentArea(current_state, h_padding, |
196 v_padding, &rect, &roundness, host_view_); | 196 v_padding, &rect, &roundness, host_view_); |
197 DetachableToolbarView::PaintContentAreaBackground(canvas, tp, rect, | 197 DetachableToolbarView::PaintContentAreaBackground(canvas, tp, rect, |
198 roundness); | 198 roundness); |
199 DetachableToolbarView::PaintContentAreaBorder(canvas, tp, rect, roundness); | 199 DetachableToolbarView::PaintContentAreaBorder(canvas, tp, rect, roundness); |
200 if (!toolbar_overlap) | 200 if (!toolbar_overlap) |
201 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_); | 201 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_); |
202 } else { | 202 } else { |
203 DetachableToolbarView::PaintBackgroundAttachedMode(canvas, host_view_); | 203 DetachableToolbarView::PaintBackgroundAttachedMode(canvas, host_view_, |
| 204 browser_view_->OffsetPointForToolbarBackgroundImage( |
| 205 gfx::Point(host_view_->MirroredX(), host_view_->y()))); |
204 if (host_view_->height() >= toolbar_overlap) | 206 if (host_view_->height() >= toolbar_overlap) |
205 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_); | 207 DetachableToolbarView::PaintHorizontalBorder(canvas, host_view_); |
206 } | 208 } |
207 } | 209 } |
208 | 210 |
209 /////////////////////////////////////////////////////////////////////////////// | 211 /////////////////////////////////////////////////////////////////////////////// |
210 // ResizeCorner, private: | 212 // ResizeCorner, private: |
211 | 213 |
212 class ResizeCorner : public views::View { | 214 class ResizeCorner : public views::View { |
213 public: | 215 public: |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 toolbar_->location_bar()->location_entry()->ClosePopup(); | 511 toolbar_->location_bar()->location_entry()->ClosePopup(); |
510 } | 512 } |
511 | 513 |
512 void BrowserView::WindowMoveOrResizeStarted() { | 514 void BrowserView::WindowMoveOrResizeStarted() { |
513 TabContents* tab_contents = GetSelectedTabContents(); | 515 TabContents* tab_contents = GetSelectedTabContents(); |
514 if (tab_contents) | 516 if (tab_contents) |
515 tab_contents->WindowMoveOrResizeStarted(); | 517 tab_contents->WindowMoveOrResizeStarted(); |
516 } | 518 } |
517 | 519 |
518 gfx::Rect BrowserView::GetToolbarBounds() const { | 520 gfx::Rect BrowserView::GetToolbarBounds() const { |
519 return toolbar_->bounds(); | 521 gfx::Rect toolbar_bounds(toolbar_->bounds()); |
| 522 if (toolbar_bounds.IsEmpty()) |
| 523 return toolbar_bounds; |
| 524 // When using vertical tabs, the toolbar appears to extend behind the tab |
| 525 // column. |
| 526 if (UseVerticalTabs()) |
| 527 toolbar_bounds.Inset(tabstrip_->x() - toolbar_bounds.x(), 0, 0, 0); |
| 528 // The apparent toolbar edges are outside the "real" toolbar edges. |
| 529 toolbar_bounds.Inset(-views::NonClientFrameView::kClientEdgeThickness, 0); |
| 530 return toolbar_bounds; |
520 } | 531 } |
521 | 532 |
522 gfx::Rect BrowserView::GetClientAreaBounds() const { | 533 gfx::Rect BrowserView::GetClientAreaBounds() const { |
523 gfx::Rect container_bounds = contents_container_->bounds(); | 534 gfx::Rect container_bounds = contents_container_->bounds(); |
524 gfx::Point container_origin = container_bounds.origin(); | 535 gfx::Point container_origin = container_bounds.origin(); |
525 ConvertPointToView(this, GetParent(), &container_origin); | 536 ConvertPointToView(this, GetParent(), &container_origin); |
526 container_bounds.set_origin(container_origin); | 537 container_bounds.set_origin(container_origin); |
527 return container_bounds; | 538 return container_bounds; |
528 } | 539 } |
529 | 540 |
530 bool BrowserView::ShouldFindBarBlendWithBookmarksBar() const { | 541 bool BrowserView::ShouldFindBarBlendWithBookmarksBar() const { |
531 if (bookmark_bar_view_.get()) | 542 if (bookmark_bar_view_.get()) |
532 return bookmark_bar_view_->IsAlwaysShown(); | 543 return bookmark_bar_view_->IsAlwaysShown(); |
533 return false; | 544 return false; |
534 } | 545 } |
535 | 546 |
536 gfx::Rect BrowserView::GetFindBarBoundingBox() const { | 547 gfx::Rect BrowserView::GetFindBarBoundingBox() const { |
537 return GetBrowserViewLayout()->GetFindBarBoundingBox(); | 548 return GetBrowserViewLayout()->GetFindBarBoundingBox(); |
538 } | 549 } |
539 | 550 |
540 int BrowserView::GetTabStripHeight() const { | 551 int BrowserView::GetTabStripHeight() const { |
541 // We want to return tabstrip_->height(), but we might be called in the midst | 552 // We want to return tabstrip_->height(), but we might be called in the midst |
542 // of layout, when that hasn't yet been updated to reflect the current state. | 553 // of layout, when that hasn't yet been updated to reflect the current state. |
543 // So return what the tabstrip height _ought_ to be right now. | 554 // So return what the tabstrip height _ought_ to be right now. |
544 return IsTabStripVisible() ? tabstrip_->GetPreferredSize().height() : 0; | 555 return IsTabStripVisible() ? tabstrip_->GetPreferredSize().height() : 0; |
545 } | 556 } |
546 | 557 |
547 gfx::Rect BrowserView::GetTabStripBounds() const { | 558 gfx::Point BrowserView::OffsetPointForToolbarBackgroundImage( |
548 return frame_->GetBoundsForTabStrip(tabstrip_); | 559 const gfx::Point& point) const { |
| 560 // The background image starts tiling horizontally at the window left edge and |
| 561 // vertically at the top edge of the horizontal tab strip (or where it would |
| 562 // be). We expect our parent's origin to be the window origin. |
| 563 gfx::Point window_point(point.Add(gfx::Point(MirroredX(), y()))); |
| 564 window_point.Offset(0, -frame_->GetHorizontalTabStripVerticalOffset(false)); |
| 565 return window_point; |
549 } | 566 } |
550 | 567 |
551 bool BrowserView::IsTabStripVisible() const { | 568 bool BrowserView::IsTabStripVisible() const { |
552 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); | 569 return browser_->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); |
553 } | 570 } |
554 | 571 |
555 bool BrowserView::UseVerticalTabs() const { | 572 bool BrowserView::UseVerticalTabs() const { |
556 return browser_->tabstrip_model()->delegate()->UseVerticalTabs(); | 573 return browser_->tabstrip_model()->delegate()->UseVerticalTabs(); |
557 } | 574 } |
558 | 575 |
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1655 void BrowserView::Layout() { | 1672 void BrowserView::Layout() { |
1656 if (ignore_layout_) | 1673 if (ignore_layout_) |
1657 return; | 1674 return; |
1658 if (GetLayoutManager()) { | 1675 if (GetLayoutManager()) { |
1659 GetLayoutManager()->Layout(this); | 1676 GetLayoutManager()->Layout(this); |
1660 SchedulePaint(); | 1677 SchedulePaint(); |
1661 #if defined(OS_WIN) | 1678 #if defined(OS_WIN) |
1662 // Send the margins of the "user-perceived content area" of this | 1679 // Send the margins of the "user-perceived content area" of this |
1663 // browser window so AeroPeekManager can render a background-tab image in | 1680 // browser window so AeroPeekManager can render a background-tab image in |
1664 // the area. | 1681 // the area. |
| 1682 // TODO(pkasting) correct content inset?? |
1665 if (aeropeek_manager_.get()) { | 1683 if (aeropeek_manager_.get()) { |
1666 gfx::Insets insets(GetFindBarBoundingBox().y() + 1, | 1684 gfx::Insets insets(GetFindBarBoundingBox().y() + 1, |
1667 GetTabStripBounds().x(), | 1685 0, |
1668 GetTabStripBounds().x(), | 1686 0, |
1669 GetTabStripBounds().x()); | 1687 0); |
1670 aeropeek_manager_->SetContentInsets(insets); | 1688 aeropeek_manager_->SetContentInsets(insets); |
1671 } | 1689 } |
1672 #endif | 1690 #endif |
1673 } | 1691 } |
1674 } | 1692 } |
1675 | 1693 |
1676 void BrowserView::ViewHierarchyChanged(bool is_add, | 1694 void BrowserView::ViewHierarchyChanged(bool is_add, |
1677 views::View* parent, | 1695 views::View* parent, |
1678 views::View* child) { | 1696 views::View* child) { |
1679 if (is_add && child == this && GetWidget() && !initialized_) { | 1697 if (is_add && child == this && GetWidget() && !initialized_) { |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2278 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); | 2296 SetAccessibleName(l10n_util::GetString(IDS_PRODUCT_NAME)); |
2279 | 2297 |
2280 return view; | 2298 return view; |
2281 } | 2299 } |
2282 #endif | 2300 #endif |
2283 | 2301 |
2284 // static | 2302 // static |
2285 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2303 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
2286 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2304 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
2287 } | 2305 } |
OLD | NEW |