Commit 65b2f463 authored by Dana Fried's avatar Dana Fried Committed by Commit Bot

Account for bookmark bar height when calculating preview image size.

Previously, the target tab preview size for the tablet (Mohnstrudel)
tabstrip was determined by the size of the web viewport. However, the
size of the viewport can be affected by the visibility of the bookmark
bar, which is dependent on a number of factors including whether the
user has opted to enable the bar, whether the current page is the NTP,
whether the current page is crashed, etc.

That resulted in a situation where the size of the thumbnails in the
tabstrip could change as the user switched between tabs.

This CL standardizes the thumbnail size to be based on the size of the
viewport if the bookmark bar were completely visible, regardless of the
current bookmark bar state. The result is that in the event the user has
disabled the bookmark bar, the resulting thumbnail may be slightly
shorter than it would otherwise be, which can result in a couple of
pixels being trimmed off the right and left when the thumbnail is
displayed. However, it's extremely hard to notice this slight reduction
in fidelity compared to the benefit of having the thumbnail size
constantly changing.

Bug: 1066652
Change-Id: I05fc47ac6f99e1323ebe682a636151fb81360229
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462492
Auto-Submit: Dana Fried <dfried@chromium.org>
Commit-Queue: Collin Baker <collinbaker@chromium.org>
Reviewed-by: default avatarCollin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815895}
parent 7d10b1be
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h" #include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h" #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "chrome/browser/ui/ui_features.h" #include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h"
#include "chrome/browser/ui/views/chrome_view_class_properties.h" #include "chrome/browser/ui/views/chrome_view_class_properties.h"
#include "chrome/browser/ui/views/frame/browser_view.h" #include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h" #include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
...@@ -804,8 +805,27 @@ void WebUITabStripContainerView::ShowEditDialogForGroupAtPoint( ...@@ -804,8 +805,27 @@ void WebUITabStripContainerView::ShowEditDialogForGroupAtPoint(
TabStripUILayout WebUITabStripContainerView::GetLayout() { TabStripUILayout WebUITabStripContainerView::GetLayout() {
DCHECK(tab_contents_container_); DCHECK(tab_contents_container_);
return TabStripUILayout::CalculateForWebViewportSize(
tab_contents_container_->size()); gfx::Size tab_contents_size = tab_contents_container_->size();
// Because some pages can display the bookmark bar even when the bookmark bar
// is disabled (e.g. NTP) and some pages never display the bookmark bar (e.g.
// crashed tab pages, pages in guest browser windows), we will always reserve
// room for the bookmarks bar so that the size and shape of the effective
// viewport doesn't change.
//
// This may cause the thumbnail to crop off the extreme right and left edge of
// the image in some cases, but a very slight crop is preferable to constantly
// changing thumbnail sizes.
//
// See: crbug.com/1066652 for more info
const int max_bookmark_height = GetLayoutConstant(BOOKMARK_BAR_HEIGHT);
const views::View* bookmarks = browser_view_->bookmark_bar();
const int bookmark_bar_height =
(bookmarks && bookmarks->GetVisible()) ? bookmarks->height() : 0;
tab_contents_size.Enlarge(0, -(max_bookmark_height - bookmark_bar_height));
return TabStripUILayout::CalculateForWebViewportSize(tab_contents_size);
} }
SkColor WebUITabStripContainerView::GetColor(int id) const { SkColor WebUITabStripContainerView::GetColor(int id) const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment