Commit 0532c4e2 authored by Peter Kasting's avatar Peter Kasting Committed by Commit Bot

Extend window drag handle into background tabs for non-custom frame.

This required:

* Deleting the old pre-custom-titlebar rect intersection code, which bypassed
  the drag extension code.  AFIACT this code had no advantages over the common
  code in BrowserNonClientFrameView.
* Fixing a color computation bug in GetTabBackgroundColor() that I introduced in
  https://chromium-review.googlesource.com/1173715 , where it ignored the
  requested active state of the frame.  This probably had other bad effects too.
* Fixing code in the tab strip that failed to mirror bounds correctly, so this
  would work in RTL.  Again, that probably resulted in other bugs too.

While testing that this worked right with the new tab button, I also fixed (via
simplification) an unrelated issue where the new tab button hit test region in
refresh was a rectangle instead of the correct path.

Bug: 862276
Test: Run chrome on Windows 10 with --disable-features=Windows10CustomTitlebar, then hover the top couple pixels of a background tab in a restored window in the default theme.  The tab should not light up with a hover effect until you get 6 px or so down into the tab.
Change-Id: Iabc80cdde7f67251214c5308687105f13ea22f19
Reviewed-on: https://chromium-review.googlesource.com/1180594Reviewed-by: default avatarBret Sepulveda <bsep@chromium.org>
Commit-Queue: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#584447}
parent 121f7b29
......@@ -211,16 +211,15 @@ SkColor BrowserNonClientFrameView::GetTabBackgroundColor(
// When the background tab color has not been customized, use the actual frame
// color instead of COLOR_BACKGROUND_TAB; these will differ for single-tab
// mode and custom window frame colors.
const SkColor frame = GetFrameColor(active_state);
const SkColor background =
(MD::IsRefreshUi() && !tp->HasCustomColor(color_id))
? color_utils::HSLShift(
GetFrameColor(),
tp->GetTint(ThemeProperties::TINT_BACKGROUND_TAB))
frame, tp->GetTint(ThemeProperties::TINT_BACKGROUND_TAB))
: GetThemeOrDefaultColor(color_id);
return opaque
? color_utils::GetResultingPaintColor(background, GetFrameColor())
: background;
return opaque ? color_utils::GetResultingPaintColor(background, frame)
: background;
}
SkColor BrowserNonClientFrameView::GetTabForegroundColor(TabState state) const {
......
......@@ -516,35 +516,11 @@ AvatarButtonStyle GlassBrowserFrameView::GetAvatarButtonStyle() const {
///////////////////////////////////////////////////////////////////////////////
// GlassBrowserFrameView, private:
// views::NonClientFrameView:
bool GlassBrowserFrameView::DoesIntersectRect(const views::View* target,
const gfx::Rect& rect) const {
if (ShouldCustomDrawSystemTitlebar())
return BrowserNonClientFrameView::DoesIntersectRect(target, rect);
// TODO(bsep): This override has "dead zones" where you can't click on the
// custom titlebar buttons. It's not clear why it's necessary at all.
// Investigate tearing this out.
// TODO(pkasting): https://crbug.com/862276 This interferes with drag handle
// extension because we never run BrowserNonClientFrameView's code.
CHECK_EQ(target, this);
bool hit_incognito_icon =
profile_indicator_icon() &&
profile_indicator_icon()->GetMirroredBounds().Intersects(rect);
views::View* profile_switcher_view = GetProfileSwitcherButton();
bool hit_profile_switcher_button =
profile_switcher_view &&
profile_switcher_view->GetMirroredBounds().Intersects(rect);
return hit_incognito_icon || hit_profile_switcher_button ||
!frame()->client_view()->bounds().Intersects(rect);
}
void GlassBrowserFrameView::ActivationChanged(bool active) {
BrowserNonClientFrameView::ActivationChanged(active);
if (hosted_app_button_container_) {
if (hosted_app_button_container_)
hosted_app_button_container_->SetPaintAsActive(active);
}
}
int GlassBrowserFrameView::ClientBorderThickness(bool restored) const {
......
......@@ -88,8 +88,6 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView,
private:
// views::NonClientFrameView:
bool DoesIntersectRect(const views::View* target,
const gfx::Rect& rect) const override;
void ActivationChanged(bool active) override;
// Returns the thickness of the border around the client area (web content,
......
......@@ -414,23 +414,11 @@ void NewTabButton::GetBorderPath(float button_y,
float scale,
bool extend_to_top,
SkPath* path) const {
const gfx::Rect contents_bounds = GetContentsBounds();
if (MD::IsRefreshUi()) {
// TODO(pkasting): This should really be a circle with (potentially) its top
// half extended rectangularly upward... try to reuse
// GetTouchOptimizedButtonPath().
path->addRect(0, extend_to_top ? 0 : button_y,
contents_bounds.width() * scale,
button_y + contents_bounds.height() * scale);
return;
}
*path =
MD::IsTouchOptimizedUiEnabled()
MD::IsNewerMaterialUi()
? GetNewerMaterialUiButtonPath(button_y, scale, extend_to_top, false)
: GetMaterialUiButtonPath(button_y, contents_bounds.height(), scale,
extend_to_top, false);
: GetMaterialUiButtonPath(button_y, GetContentsBounds().height(),
scale, extend_to_top, false);
}
void NewTabButton::PaintFill(bool pressed,
......
......@@ -355,7 +355,7 @@ bool TabStrip::IsRectInWindowCaption(const gfx::Rect& rect) {
const int tab_index = tabs_.GetIndexOfView(v);
if (IsValidModelIndex(tab_index)) {
Tab* tab = tab_at(tab_index);
gfx::Rect tab_drag_handle = tab->bounds();
gfx::Rect tab_drag_handle = tab->GetMirroredBounds();
tab_drag_handle.set_height(drag_handle_extension);
return extend_drag_handle && !tab->IsActive() &&
tab_drag_handle.Intersects(rect);
......@@ -363,7 +363,7 @@ bool TabStrip::IsRectInWindowCaption(const gfx::Rect& rect) {
// Similarly, a hit in the new tab button is considered to be in the caption
// if it's in this thin strip.
gfx::Rect new_tab_button_drag_handle = new_tab_button_->bounds();
gfx::Rect new_tab_button_drag_handle = new_tab_button_->GetMirroredBounds();
new_tab_button_drag_handle.set_height(drag_handle_extension);
if (extend_drag_handle && new_tab_button_drag_handle.Intersects(rect))
return true;
......
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