Skip to content

Commit

Permalink
[M102 Merge][side search] Eliminate grey flash when opening Side Search
Browse files Browse the repository at this point in the history
This CL eliminates the grey flash that can be seen when side search
is first opened.

This is done by setting the default background color of the
WebContents to be transparent and setting the hosting WebView's
background color to the toolbar background color.

Before:
https://screencast.googleplex.com/cast/NTQxMzQ3MzE1NzY0NDI4OHw1ZTRhOTEwMS1kOQ

After:
https://screencast.googleplex.com/cast/NjQ4MjY1MDQ3OTk4NDY0MHwwNDZhMmY5MS0wYg

(cherry picked from commit bdd6df8)

Bug: 1315412
Change-Id: I86a8879ddae422a3c1355924af012bd41d2adf3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3598181
Reviewed-by: Yuheng Huang <yuhengh@chromium.org>
Commit-Queue: Thomas Lukaszewicz <tluk@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#994790}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3606089
Cr-Commit-Position: refs/branch-heads/5005@{#141}
Cr-Branched-From: 5b4d945-refs/heads/main@{#992738}
  • Loading branch information
Thomas Lukaszewicz authored and Chromium LUCI CQ committed Apr 25, 2022
1 parent a86661a commit cd7dfc2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
Expand Up @@ -23,6 +23,7 @@
#include "services/network/public/cpp/simple_url_loader.h"
#include "third_party/blink/public/mojom/frame/user_activation_notification_type.mojom.h"
#include "ui/base/page_transition_types.h"
#include "ui/views/controls/webview/web_contents_set_background_color.h"

#if BUILDFLAG(ENABLE_EXTENSIONS)
#include "chrome/browser/extensions/tab_helper.h"
Expand Down Expand Up @@ -175,6 +176,12 @@ void SideSearchTabContentsHelper::CreateSidePanelContents() {
side_panel_contents_ =
content::WebContents::Create(content::WebContents::CreateParams(
web_contents()->GetBrowserContext(), nullptr));

// Apply a transparent background color so that we fallback to the hosting
// side panel view's background color.
views::WebContentsSetBackgroundColor::CreateForWebContentsWithColor(
side_panel_contents_.get(), SK_ColorTRANSPARENT);

task_manager::WebContentsTags::CreateForTabContents(
side_panel_contents_.get());

Expand Down
Expand Up @@ -11,6 +11,7 @@
#include "chrome/browser/feature_engagement/tracker_factory.h"
#include "chrome/browser/ui/browser_element_identifiers.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/color/chrome_color_id.h"
#include "chrome/browser/ui/layout_constants.h"
#include "chrome/browser/ui/page_action/page_action_icon_type.h"
#include "chrome/browser/ui/side_search/side_search_utils.h"
Expand Down Expand Up @@ -284,6 +285,7 @@ views::WebView* ConfigureSidePanel(views::View* side_panel,
views::kFlexBehaviorKey,
views::FlexSpecification(views::MinimumFlexSizeRule::kScaleToZero,
views::MaximumFlexSizeRule::kUnbounded));
web_view->SetBackground(views::CreateThemedSolidBackground(kColorToolbar));

side_panel->AddChildView(std::move(container));

Expand Down

0 comments on commit cd7dfc2

Please sign in to comment.