Skip to content

Commit

Permalink
Fixed blank tab is shown after attaching split view
Browse files Browse the repository at this point in the history
fix brave/brave-browser#41852

When split view transfers to another browser, its web contents should
be cleared before attached to target browser.
It's done by SplitView::UpdateContentsWebViewVisual().

So far, we posted it to next turn when we break tile.
If we break a tile by unsplit, it doesn't cause any issue because
any other secondary web view doesn't host that secondary web contents.

However, if it's attached to another browser window, it's another story.
When we detach a split view from browser A and attach to browser B,
browser A breaks a tile after detached. And then, they are attached to
browser B and we make them as a split view. If we don't clear secondary
web contents after break the tile synchronously, browser A and browser
B's secondary web view has same web contents till posed
`UpdateContentsWebViewVisual(). This could cause unexpected behavior
like above issue. So, secondary web view should be cleared synchronously
after breaking a tile.
  • Loading branch information
simonhong committed Jan 8, 2025
1 parent bb79ef3 commit 1932bad
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
6 changes: 2 additions & 4 deletions browser/ui/views/frame/brave_browser_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -856,14 +856,12 @@ void BraveBrowserView::OnTileTabs(const TabTile& tile) {
UpdateContentsWebViewVisual();
}

void BraveBrowserView::OnWillBreakTile(const TabTile& tile) {
void BraveBrowserView::OnDidBreakTile(const TabTile& tile) {
if (!IsActiveWebContentsTiled(tile)) {
return;
}

base::SequencedTaskRunner::GetCurrentDefault()->PostTask(
FROM_HERE, base::BindOnce(&BraveBrowserView::UpdateContentsWebViewVisual,
weak_ptr_.GetWeakPtr()));
UpdateContentsWebViewVisual();
}

void BraveBrowserView::OnSwapTabsInTile(const TabTile& tile) {
Expand Down
2 changes: 1 addition & 1 deletion browser/ui/views/frame/brave_browser_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class BraveBrowserView : public BrowserView,

// SplitViewBrowserDataObserver:
void OnTileTabs(const TabTile& tile) override;
void OnWillBreakTile(const TabTile& tile) override;
void OnDidBreakTile(const TabTile& tile) override;
void OnSwapTabsInTile(const TabTile& tile) override;

views::WebView* secondary_contents_web_view() {
Expand Down
1 change: 0 additions & 1 deletion browser/ui/views/frame/split_view_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ IN_PROC_BROWSER_TEST_F(SplitViewBrowserTest,
split_view_data->IsTabTiled(tab_strip_model().GetTabHandleAt(0)));

// Then, the secondary web view should become hidden
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(secondary_contents_view().GetVisible());
}

Expand Down

0 comments on commit 1932bad

Please sign in to comment.