Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update horizontal tabs styling #20044

Merged
merged 1 commit into from
Sep 25, 2023
Merged

Update horizontal tabs styling #20044

merged 1 commit into from
Sep 25, 2023

Conversation

zenparsing
Copy link
Collaborator

@zenparsing zenparsing commented Sep 7, 2023

Resolves brave/brave-browser#31646

This changes updates the horizontal tabs styling, under the feature flag #brave-horizontal-tabs-update.

Screenshot 2023-09-21 at 6 09 37 PM

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run lint, npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@github-actions github-actions bot added the potential-layer-violation-fixes This PR touches a BUILD.gn file with check_includes=false label Sep 7, 2023
@zenparsing zenparsing force-pushed the ksmith-h-tabs branch 6 times, most recently from 9b402ee to f9d141a Compare September 13, 2023 12:49
@zenparsing zenparsing force-pushed the ksmith-h-tabs branch 2 times, most recently from f84738d to 133f468 Compare September 19, 2023 13:24
@zenparsing zenparsing changed the title Update horizontal tabs rendering Update horizontal tabs styling Sep 19, 2023
@zenparsing zenparsing force-pushed the ksmith-h-tabs branch 2 times, most recently from 1b5e3ff to 81b3631 Compare September 21, 2023 21:40
@zenparsing zenparsing marked this pull request as ready for review September 21, 2023 22:11
@zenparsing zenparsing requested review from a team as code owners September 21, 2023 22:11
Copy link
Contributor

@sangwoo108 sangwoo108 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! LGTM👍


// The tab strip will maintain the necessary padding between the top of the
// frame and the top of tabs.
return 2;
Copy link
Contributor

@sangwoo108 sangwoo108 Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just double checking, do you happen to check if "immersive tab strip on fullscreen" works? (Tabstrip slides down in fullscreen when mouse hovers on the topside, this is enabled only when view > Always show toolbar in fullscreen from OS app menu is unchecked)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's been checked in fullscreen. (Although I'm seeing an unrelated macOS fullscreen tabs issue in master at the moment. I'll attempt to put together a repro.)

@@ -138,6 +138,7 @@ void BraveCompoundTabContainer::SetScrollEnabled(bool enabled) {

if (enabled) {
scroll_view_ = AddChildView(std::make_unique<CustomScrollView>());
scroll_view_->SetBackgroundThemeColorId(kColorToolbar);
Copy link
Contributor

@sangwoo108 sangwoo108 Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Q. I'm curious why this was added. Isn't this code only reachable when it's vertical tab strip?


Update: maybe related to change in tab container.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right - the scroll view is also painted to an (opaque?) layer, so needs all pixels painted. Previously, the tab container would paint the background for it, but since we're moving background painting into BraveTabStrip (which is above this scroll view), we need to have the scroll view also take care of background painting.

Maybe it would be easier to have the tab container paint to a layer instead of BraveTabStrip. I'm not sure if I tried that, but I'll try it again.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BraveTabStrip needs to be the layer-based ancestor for tabs because tabs are moved out of TabContainer and into TabDragContext when dragging. BraveTabStrip is the parent for both.

browser/ui/views/tabs/brave_new_tab_button.cc Outdated Show resolved Hide resolved
browser/ui/views/tabs/brave_new_tab_button.cc Outdated Show resolved Hide resolved
@@ -32,6 +33,21 @@
#include "ui/gfx/skbitmap_operations.h"
#include "ui/views/view_utils.h"

namespace {

gfx::Size AddHorizontalTabStripSpacing(gfx::Size size) {
Copy link
Contributor

@sangwoo108 sangwoo108 Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

optional:

Suggested change
gfx::Size AddHorizontalTabStripSpacing(gfx::Size size) {
gfx::Size AddHorizontalTabStripSpacing(const gfx::Size& size) {

Copy link
Contributor

@sangwoo108 sangwoo108 Sep 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or you might want to use mutable reference. But it might not possible when it comes to the xvalue returned from PreferredSize().

gfx::Size& AddHorizontalTabStripSpacing(gfx::Size& size) {

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to leave it as pass-by-value, since we need to construct a new Size anyway, and since Size is a very small object.

Comment on lines -280 to -289
void BraveTabContainer::OnPaintBackground(gfx::Canvas* canvas) {
if (!tabs::utils::ShouldShowVerticalTabs(
tab_slot_controller_->GetBrowser())) {
TabContainerImpl::OnPaintBackground(canvas);
return;
}

canvas->DrawColor(GetColorProvider()->GetColor(kColorToolbar));
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha! this seems to be why scroll view in the compound container has the background. For vertical tabs, we have two different tab container instance for pinned tabs and unpinned tabs. And pinned tab container doesn't belong to the scroll view. so I'm wondering if pinned tabs container has background properly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, is it painted from BraveTabStrip?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right - it now paints the background in BraveTabStrip, because BraveTabStrip paints to an opaque layer. Since BraveTabStrip is a parent of BraveTabContainer, the background painting in BraveTabContainer is no longer required.

browser/ui/views/tabs/brave_tab_strip.cc Show resolved Hide resolved
browser/ui/tabs/brave_tab_style.h Show resolved Hide resolved
Comment on lines 7 to 12
#include "brave/browser/ui/color/brave_color_id.h"
#include "brave/browser/ui/tabs/brave_tab_layout_constants.h"
#include "brave/browser/ui/tabs/features.h"
#include "brave/browser/ui/views/tabs/brave_tab_group_header.h"
#include "brave/browser/ui/views/tabs/vertical_tab_utils.h"
#include "chrome/browser/ui/views/tabs/tab_slot_controller.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are all these needed here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are needed by brave_tab_style_views.inc.cc, which does not include its own dependencies (it relies on the includes defined in tab_style_views.cc).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes 😢

Copy link
Collaborator

@mkarolin mkarolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

chromium_src, patches ++

@zenparsing zenparsing merged commit cd701f7 into master Sep 25, 2023
@zenparsing zenparsing deleted the ksmith-h-tabs branch September 25, 2023 16:33
@github-actions github-actions bot added the CI/run-upstream-tests Run upstream unit and browser tests on Linux and Windows (otherwise only on Linux) label Sep 25, 2023
@github-actions github-actions bot added this to the 1.60.x - Nightly milestone Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/run-upstream-tests Run upstream unit and browser tests on Linux and Windows (otherwise only on Linux) potential-layer-violation-fixes This PR touches a BUILD.gn file with check_includes=false
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update horizontal tab shape for pins, normal tabs, and groups
3 participants