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

Give main content area padding and a shadow #20526

Merged
merged 1 commit into from
Oct 23, 2023
Merged

Conversation

zenparsing
Copy link
Collaborator

@zenparsing zenparsing commented Oct 13, 2023

Resolves brave/brave-browser#31645

A new feature flag has been created for this change:

Screenshot 2023-10-19 at 2 07 38 PM

With feature flag enabled:

Screenshot 2023-10-19 at 2 06 58 PM

Implementation Notes

In order to round the corners of the combined webview and devtools area, all other views have been moved out of the contents container view, matching upstream. The following views have been re-parented to the browser view:

  • Sidebar container
  • Speedreader toolbar

Significant refactoring has been done in brave_browser_view_layout.cc in order to accomplish this.

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 potential-layer-violation-fixes This PR touches a BUILD.gn file with check_includes=false CI/run-upstream-tests Run upstream unit and browser tests on Linux and Windows (otherwise only on Linux) labels Oct 13, 2023
@zenparsing zenparsing force-pushed the ksmith-padded-content branch 11 times, most recently from a4ab92a to e203b05 Compare October 19, 2023 17:59
@zenparsing zenparsing marked this pull request as ready for review October 19, 2023 21:30
@zenparsing zenparsing requested review from a team as code owners October 19, 2023 21:30
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.

Vertical tab related stuff LGTM but deferring the final call to @simonhong as he would know better about contents layout and sidebar layout.

@simonhong
Copy link
Member

Got below crash while resizing window. WDP Infobar(#15822) was launched at that time. Only happened once and can't repro it again.

[56857:56857:1020/115322.314755:FATAL:brave_browser_view_layout.cc(237)] Check failed: vertical_tabs_top_.has_value(). 
#0 0x7f42f6e05382 base::debug::CollectStackTrace()
#1 0x7f42f6de1143 base::debug::StackTrace::StackTrace()
#2 0x7f42f6ca7541 logging::LogMessage::~LogMessage()
#3 0x7f42f6ca803e logging::LogMessage::~LogMessage()
#4 0x7f42f6c814b7 logging::CheckError::~CheckError()
#5 0x556b4a7d6911 BraveBrowserViewLayout::LayoutVerticalTabs()
#6 0x7f42ec9c5a77 views::View::Layout()
#7 0x556b4d3a4222 BrowserView::Layout()
#8 0x556b4d39b676 BrowserView::ToolbarSizeChanged()
#9 0x556b4bc43484 infobars::InfoBarContainer::OnInfoBarStateChanged()
#10 0x556b4bc41c60 infobars::InfoBar::RecalculateHeight()
#11 0x556b4aa74eeb WebDiscoveryInfoBarView::ChildPreferredSizeChanged()
#12 0x7f42ec9ccae2 views::View::PreferredSizeChanged()
#13 0x556b4aa6fc2b WebDiscoveryInfoBarContentView::SwitchChildLayout()
#14 0x7f42ec9c2336 views::View::SetBoundsRect()
#15 0x7f42ec9c1be9 views::View::SetBounds()
#16 0x556b4aa74e2b WebDiscoveryInfoBarView::Layout()
#17 0x7f42ec9c2403 views::View::SetBoundsRect()
#18 0x7f42ec9c1be9 views::View::SetBounds()
#19 0x556b4d4425ac InfoBarContainerView::Layout()
#20 0x7f42ec9c2403 views::View::SetBoundsRect()
#21 0x7f42ec9c1be9 views::View::SetBounds()
#22 0x556b4d4173dd BrowserViewLayout::LayoutInfoBar()
#23 0x556b4a7d7c11 BraveBrowserViewLayout::LayoutInfoBar()
#24 0x556b4d416a3c BrowserViewLayout::LayoutBookmarkAndInfoBars()
#25 0x556b4a7d76d2 BraveBrowserViewLayout::LayoutBookmarkAndInfoBars()
#26 0x556b4d413fe9 BrowserViewLayout::Layout()
#27 0x556b4a7d62a5 BraveBrowserViewLayout::Layout()
#28 0x7f42ec9c5a77 views::View::Layout()
#29 0x556b4d3a4222 BrowserView::Layout()
#30 0x556b4d39b676 BrowserView::ToolbarSizeChanged()
#31 0x556b4bc43484 infobars::InfoBarContainer::OnInfoBarStateChanged()
#32 0x556b4bc41c60 infobars::InfoBar::RecalculateHeight()
#33 0x556b4aa74eeb WebDiscoveryInfoBarView::ChildPreferredSizeChanged()
#34 0x7f42ec9ccae2 views::View::PreferredSizeChanged()
#35 0x556b4aa6fc2b WebDiscoveryInfoBarContentView::SwitchChildLayout()
#36 0x7f42ec9c2336 views::View::SetBoundsRect()
#37 0x7f42ec9c1be9 views::View::SetBounds()
#38 0x556b4aa74e2b WebDiscoveryInfoBarView::Layout()
#39 0x7f42ec9c2403 views::View::SetBoundsRect()
#40 0x7f42ec9c1be9 views::View::SetBounds()
#41 0x556b4d4425ac InfoBarContainerView::Layout()
#42 0x7f42ec9c2403 views::View::SetBoundsRect()
#43 0x7f42ec9c1be9 views::View::SetBounds()
#44 0x556b4d4173dd BrowserViewLayout::LayoutInfoBar()
#45 0x556b4a7d7c11 BraveBrowserViewLayout::LayoutInfoBar()
#46 0x556b4d416a3c BrowserViewLayout::LayoutBookmarkAndInfoBars()
#47 0x556b4a7d76d2 BraveBrowserViewLayout::LayoutBookmarkAndInfoBars()
#48 0x556b4d413fe9 BrowserViewLayout::Layout()
#49 0x556b4a7d62a5 BraveBrowserViewLayout::Layout()
#50 0x7f42ec9c5a77 views::View::Layout()
#51 0x556b4d3a4222 BrowserView::Layout()
#52 0x7f42ec9c2403 views::View::SetBoundsRect()
#53 0x7f42eca08cb2 views::NonClientFrameView::Layout()
#54 0x7f42ec9c2403 views::View::SetBoundsRect()
#55 0x7f42eca09d69 views::NonClientView::Layout()
#56 0x7f42ec9c2403 views::View::SetBoundsRect()
#57 0x7f42ec9d254b views::View::DefaultFillLayout::Layout()
#58 0x7f42ec9c5a77 views::View::Layout()
#59 0x7f42ec9c2403 views::View::SetBoundsRect()
#60 0x7f42ec9c2fd7 views::View::SetSize()
#61 0x7f42ec9ee920 views::Widget::OnNativeWidgetSizeChanged()
#62 0x7f42eca518d4 views::DesktopNativeWidgetAura::OnHostResized()
#63 0x7f42edf39203 aura::WindowTreeHost::OnHostResizedInPixels()
#64 0x7f42edf3b927 aura::WindowTreeHostPlatform::OnBoundsChanged()
#65 0x556b4d41eed9 BrowserDesktopWindowTreeHostLinux::OnBoundsChanged()
#66 0x7f42ed92ec28 ui::X11Window::NotifyBoundsChanged()
#67 0x7f42ed92fe80 ui::X11Window::DelayedResize()
#68 0x7f42ed931a2f base::internal::CancelableCallbackImpl<>::ForwardOnce<>()
#69 0x7f42ed89c75b base::internal::Invoker<>::RunOnce()
#70 0x7f42f6d30a6e base::TaskAnnotator::RunTaskImpl()
#71 0x7f42f6d6f150 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWorkImpl()
#72 0x7f42f6d6e3c4 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork()
#73 0x7f42f6d6fd45 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::DoWork()
#74 0x7f42f6e245ab base::MessagePumpGlib::Run()
#75 0x7f42f6d70488 base::sequence_manager::internal::ThreadControllerWithMessagePumpImpl::Run()
#76 0x7f42f6d0002c base::RunLoop::Run()
#77 0x7f42f3c9086f content::BrowserMainLoop::RunMainMessageLoop()
#78 0x7f42f3c93555 content::BrowserMainRunnerImpl::Run()
#79 0x7f42f3c8c9d6 content::BrowserMain()
#80 0x7f42f4d66317 content::RunBrowserProcessMain()
#81 0x7f42f4d68bca content::ContentMainRunnerImpl::RunBrowser()
#82 0x7f42f4d68478 content::ContentMainRunnerImpl::Run()
#83 0x7f42f4d649cf content::RunContentProcess()
#84 0x7f42f4d64c32 content::ContentMain()
#85 0x556b499dfa6a ChromeMain
#86 0x7f42e085d083 __libc_start_main
#87 0x556b499df77a _start
Task trace:
#0 0x7f42ed92f797 ui::X11Window::DispatchResize()
Crash keys:
  "tabdrag-event-source" = "mouse"
  "extension-1" = "ndmldohefgmnciihihioeeoiobchcmgi"
  "num-extensions" = "1"
  "switch-9" = "--component-updater=url-source=https://go-updater.brave.com/exte"
  "commandline-enabled-feature-6" = "brave-web-view-rounded-corners"
  "commandline-enabled-feature-5" = "Playlist"
  "commandline-enabled-feature-4" = "BraveRequestOTRTab"
  "commandline-enabled-feature-3" = "BraveHorizontalTabsUpdate"
  "commandline-enabled-feature-2" = "BraveExtensionNetworkBlocking"
  "commandline-enabled-feature-1" = "AIChat"
  "reentry_guard_tls_slot" = "unused"
  "switch-8" = "--variations-insecure-server-url=https://variations.brave.com/se"
  "switch-7" = "--variations-server-url=https://variations.brave.com/seed"
  "switch-6" = "--lso-url=https://no-thanks.invalid"
  "switch-5" = "--sync-url=https://sync-v2.brave.software/v2"
  "switch-4" = "--origin-trial-public-key=bYUKPJoPnCxeNvu72j4EmPuK7tr1PAC7SHh8ld"
  "switch-3" = "--enable-dom-distiller"
  "switch-2" = "--disable-domain-reliability"
  "switch-1" = "--disable-brave-update"
  "num-switches" = "14"
  "osarch" = "x86_64"
  "pid" = "56857"
  "ptype" = "browser"

[1020/115322.529035:ERROR:elf_dynamic_array_reader.h(64)] tag not found
null
null

@zenparsing
Copy link
Collaborator Author

zenparsing commented Oct 20, 2023

@simonhong Ah, thanks! I see that layout is getting called recursively.

STR:

  • Enter horizontal tabs mode
  • Visit search.brave.com - WDP infobar should be displayed
  • Resize window so that WDP infobar is just barely in wide mode
  • Switch to vertical tabs mode

@zenparsing zenparsing force-pushed the ksmith-padded-content branch from e203b05 to 9571224 Compare October 20, 2023 18:50
Copy link
Member

@simonhong simonhong left a comment

Choose a reason for hiding this comment

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

++ with nits 👍🏼

browser/ui/views/frame/brave_browser_view.cc Show resolved Hide resolved
@@ -262,10 +303,9 @@ void BraveBrowserView::UpdateSideBarHorizontalAlignment() {
prefs::kSidePanelHorizontalAlignment);

sidebar_container_view_->SetSidebarOnLeft(on_left);
static_cast<BraveContentsLayoutManager*>(GetContentsLayoutManager())
->set_sidebar_on_left(on_left);
GetBrowserViewLayout()->set_sidebar_on_left(on_left);
Copy link
Member

Choose a reason for hiding this comment

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

nit: How about call sidebar_container_view_->SetSidebarOnLeft(on_left); from BraveBrowserViewLayout::SetSidebarOnLeft() as layout manager manages sidebar 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.

Good idea.

Another option would be to have BraveBrowserViewLayout just get the "on left" state from sidebar_container_view_, like sidebar_container_view_->is_sidebar_on_left(). That way, we wouldn't have to worry about the "on left" state ever getting out of sync. Would that work?

Copy link
Member

Choose a reason for hiding this comment

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

I think it's good idea. It seems BraveBrowserView itself doesn't need left/right info

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Seems like BraveBrowserView still needs to listen to the pref change so that it can re-layout, though?

Copy link
Member

@simonhong simonhong Oct 23, 2023

Choose a reason for hiding this comment

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

Ah, I thought you'll use container view for listening prefs instead :)
IMO, current one seems fine but container view or layout manager also could listen prefs change if you want.

Comment on lines 9 to 15
#define BRAVE_SIDE_PANEL_WEB_UI_VIEW_H \
protected: \
void AddedToWidget() override;

#include "src/chrome/browser/ui/views/side_panel/side_panel_web_ui_view.h" // IWYU pragma: export

#undef BRAVE_SIDE_PANEL_WEB_UI_VIEW_H
Copy link
Member

Choose a reason for hiding this comment

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

With this, we could avoid side_panel_web_ui_view.h patch file.

#include "ui/views/controls/webview/webview.h"

#define ViewHierarchyChanged \
  AddedToWidget() override;  \
  void ViewHierarchyChanged

#include "src/chrome/browser/ui/views/side_panel/side_panel_web_ui_view.h"  // IWYU pragma: export

#undef ViewHierarchyChanged

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ah, I missed that we could include a dependency first to avoid interfering with parent class identifiers. Nice!

@zenparsing zenparsing force-pushed the ksmith-padded-content branch from 9571224 to cae6fe3 Compare October 23, 2023 04:08
@@ -19,13 +19,11 @@
#define BrowserWindow BraveBrowserWindow
#define BrowserViewLayout BraveBrowserViewLayout
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like this is a duplicate entry with L28 (similar to how #undef was duplicated).

@@ -69,6 +69,8 @@ class SidebarContainerView
SidebarContainerView& operator=(const SidebarContainerView&) = delete;

void Init();

bool sidebar_on_left() { return sidebar_on_left_; }
Copy link
Member

Choose a reason for hiding this comment

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

const

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.

chromiun_src LGTM (with one cleanup comment).

@zenparsing zenparsing force-pushed the ksmith-padded-content branch from cae6fe3 to 63f645a Compare October 23, 2023 15:57
@zenparsing zenparsing merged commit 865ccd9 into master Oct 23, 2023
6 checks passed
@zenparsing zenparsing deleted the ksmith-padded-content branch October 23, 2023 19:07
@github-actions github-actions bot added this to the 1.61.x - Nightly milestone Oct 23, 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.

Add padding and shadow to main content window
5 participants