-
Notifications
You must be signed in to change notification settings - Fork 887
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds tab painting function for shadows. In order to paint the tab's (top) shadow above the tab's (previous) bounds rectangle, we must extend the tab (and tabstrip) higher, to the top of the window (usually 8px of space). This is because the Views framework does not allow painting outside a View's bounds. A hacky alternative would be to pass the PaintInfo from the BrowserView through the TabStrip child to the Tab descendants, so that a canvas can be created that can span the larger window rectangle. Aside from that strategy not done anywhere else in Chromium, it could cause issues if the tabs end up on a different paint layer, as well as paint invalidation and caching issues that would need to be solved. Close brave/brave-browser#788
- Loading branch information
Showing
13 changed files
with
311 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "brave/browser/ui/views/frame/brave_browser_view_layout.h" | ||
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" | ||
|
||
void BraveBrowserViewLayout::Layout(views::View* host) { | ||
BrowserViewLayout::Layout(host); | ||
// Extend the tab strip to start at the very top | ||
// so that it can draw shadows in the area which is pretending to | ||
// be non-client (i.e. draggable) | ||
if (tab_strip_->visible()) { | ||
gfx::Rect tabstrip_bounds(tab_strip_->bounds()); | ||
// set initial position to top | ||
tabstrip_bounds.set_y(tabstrip_bounds.y() - | ||
BrowserNonClientFrameView::kMinimumDragHeight); | ||
// increase height so that bottom is in same position | ||
tabstrip_bounds.set_height(tabstrip_bounds.height() + | ||
BrowserNonClientFrameView::kMinimumDragHeight); | ||
tab_strip_->SetBoundsRect(tabstrip_bounds); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_UI_VIEWS_FRAME_BRAVE_BROWSER_VIEW_LAYOUT_H_ | ||
#define BRAVE_BROWSER_UI_VIEWS_FRAME_BRAVE_BROWSER_VIEW_LAYOUT_H_ | ||
|
||
#include "chrome/browser/ui/views/frame/browser_view_layout.h" | ||
#include "chrome/browser/ui/views/tabs/tab_strip.h" | ||
|
||
class BraveBrowserViewLayout : public BrowserViewLayout { | ||
public: | ||
using BrowserViewLayout::BrowserViewLayout; | ||
// views::LayoutManager overrides: | ||
void Layout(views::View* host) override; | ||
private: | ||
DISALLOW_COPY_AND_ASSIGN(BraveBrowserViewLayout); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "brave/browser/ui/views/tabs/brave_tab_strip.h" | ||
|
||
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" | ||
#include "ui/gfx/canvas.h" | ||
|
||
void BraveTabStrip::OnPaint(gfx::Canvas* canvas) { | ||
// BraveTabStrip extends to top: 0 of window, TabStrip does not, | ||
// so bump all TabStrip painting down a bit whilst still reserving | ||
// the space for tab shadows. | ||
canvas->Translate(gfx::Vector2d(0, BrowserNonClientFrameView::kMinimumDragHeight)); | ||
TabStrip::OnPaint(canvas); | ||
} | ||
|
||
void BraveTabStrip::GenerateIdealBounds() { | ||
TabStrip::GenerateIdealBounds(); | ||
new_tab_button_bounds_.set_y(BrowserNonClientFrameView::kMinimumDragHeight); | ||
} | ||
|
||
bool BraveTabStrip::IsPositionInWindowCaption(const gfx::Point& point) { | ||
// ignore shadow area | ||
return point.y() < BrowserNonClientFrameView::kMinimumDragHeight | ||
? true | ||
: TabStrip::IsPositionInWindowCaption(point); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_UI_VIEWS_TABS_BRAVE_TAB_STRIP_H_ | ||
#define BRAVE_BROWSER_UI_VIEWS_TABS_BRAVE_TAB_STRIP_H_ | ||
|
||
#include "chrome/browser/ui/views/tabs/tab_strip.h" | ||
|
||
class BraveTabStrip : public TabStrip { | ||
public: | ||
using TabStrip::TabStrip; | ||
bool IsPositionInWindowCaption(const gfx::Point& point) override; | ||
// views::View | ||
void OnPaint(gfx::Canvas* canvas) override; | ||
private: | ||
void GenerateIdealBounds() override; | ||
DISALLOW_COPY_AND_ASSIGN(BraveTabStrip); | ||
}; | ||
|
||
#endif |
40 changes: 40 additions & 0 deletions
40
patches/chrome-browser-ui-views-frame-browser_view.cc.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc | ||
index 64fc254f05e6496de9d724a030d42aa2f4e0a804..8553bcded9b9f73da3dec1e51622d0340391e663 100644 | ||
--- a/chrome/browser/ui/views/frame/browser_view.cc | ||
+++ b/chrome/browser/ui/views/frame/browser_view.cc | ||
@@ -77,7 +77,7 @@ | ||
#include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views.h" | ||
#include "chrome/browser/ui/views/find_bar_host.h" | ||
#include "chrome/browser/ui/views/frame/app_menu_button.h" | ||
-#include "chrome/browser/ui/views/frame/browser_view_layout.h" | ||
+#include "brave/browser/ui/views/frame/brave_browser_view_layout.h" | ||
#include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h" | ||
#include "chrome/browser/ui/views/frame/contents_layout_manager.h" | ||
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h" | ||
@@ -96,7 +96,7 @@ | ||
#include "chrome/browser/ui/views/tab_contents/chrome_web_contents_view_focus_helper.h" | ||
#include "chrome/browser/ui/views/tabs/browser_tab_strip_controller.h" | ||
#include "chrome/browser/ui/views/tabs/tab.h" | ||
-#include "chrome/browser/ui/views/tabs/tab_strip.h" | ||
+#include "brave/browser/ui/views/tabs/brave_tab_strip.h" | ||
#include "chrome/browser/ui/views/toolbar/browser_actions_container.h" | ||
#include "chrome/browser/ui/views/toolbar/reload_button.h" | ||
#include "chrome/browser/ui/views/toolbar/toolbar_view.h" | ||
@@ -2345,7 +2345,7 @@ void BrowserView::InitViews() { | ||
BrowserTabStripController* tabstrip_controller = | ||
new BrowserTabStripController(browser_->tab_strip_model(), this); | ||
tabstrip_ = | ||
- new TabStrip(std::unique_ptr<TabStripController>(tabstrip_controller)); | ||
+ new BraveTabStrip(std::unique_ptr<TabStripController>(tabstrip_controller)); | ||
top_container_->AddChildView(tabstrip_); // Takes ownership. | ||
tabstrip_controller->InitFromModel(tabstrip_); | ||
|
||
@@ -2371,7 +2371,7 @@ void BrowserView::InitViews() { | ||
immersive_mode_controller_->Init(this); | ||
immersive_mode_controller_->AddObserver(this); | ||
|
||
- auto browser_view_layout = std::make_unique<BrowserViewLayout>(); | ||
+ auto browser_view_layout = std::make_unique<BraveBrowserViewLayout>(); | ||
browser_view_layout->Init(new BrowserViewLayoutDelegateImpl(this), | ||
browser(), | ||
this, |
12 changes: 12 additions & 0 deletions
12
patches/chrome-browser-ui-views-frame-browser_view_layout.h.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff --git a/chrome/browser/ui/views/frame/browser_view_layout.h b/chrome/browser/ui/views/frame/browser_view_layout.h | ||
index 4de4cfe8d18f3d00bb5267b2fac52050d4779d20..5b2989f52c825f36b5feed15f254f6653615dd40 100644 | ||
--- a/chrome/browser/ui/views/frame/browser_view_layout.h | ||
+++ b/chrome/browser/ui/views/frame/browser_view_layout.h | ||
@@ -37,6 +37,7 @@ class WebContentsModalDialogHost; | ||
// The layout manager used in chrome browser. | ||
class BrowserViewLayout : public views::LayoutManager { | ||
public: | ||
+ friend class BraveBrowserViewLayout; | ||
BrowserViewLayout(); | ||
~BrowserViewLayout() override; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.