Commit 939e2f7e authored by Dana Fried's avatar Dana Fried Committed by Commit Bot

Remove detachable caption button container logic

Follow-up CL to remove logic added to make it possible to host the
caption buttons on browser elements. See upstream CL:
https://chromium-review.googlesource.com/c/chromium/src/+/2358249

Do not check in until upstream CL has been *verified* as what we want
for tablet mode on Windows.

Bug: 1116651
Change-Id: Ia5670d40e0565711041835d0641231396612730a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2359019
Commit-Queue: Dana Fried <dfried@chromium.org>
Reviewed-by: default avatarCollin Baker <collinbaker@chromium.org>
Cr-Commit-Position: refs/heads/master@{#798955}
parent c5a10f5b
......@@ -3425,8 +3425,6 @@ static_library("ui") {
"views/frame/browser_view_layout.h",
"views/frame/browser_view_layout_delegate.h",
"views/frame/browser_window_factory.cc",
"views/frame/caption_button_container.cc",
"views/frame/caption_button_container.h",
"views/frame/contents_layout_manager.cc",
"views/frame/contents_layout_manager.h",
"views/frame/contents_web_view.cc",
......
......@@ -76,11 +76,6 @@ bool BrowserNonClientFrameView::CaptionButtonsOnLeadingEdge() const {
return false;
}
CaptionButtonContainer* BrowserNonClientFrameView::GetCaptionButtonContainer()
const {
return nullptr;
}
void BrowserNonClientFrameView::UpdateFullscreenTopUI() {
if (frame_->IsFullscreen())
browser_view_->HideDownloadShelf();
......
......@@ -16,7 +16,6 @@
class BrowserFrame;
class BrowserView;
class CaptionButtonContainer;
class WebAppFrameToolbarView;
// Type used for functions whose return values depend on the active state of
......@@ -53,10 +52,6 @@ class BrowserNonClientFrameView : public views::NonClientFrameView,
// left in LTR mode, or the right in RTL mode).
virtual bool CaptionButtonsOnLeadingEdge() const;
// Returns the caption button container associated with the frame, if any.
// The caption buttons may be "borrowed" from the frame and returned to it.
virtual CaptionButtonContainer* GetCaptionButtonContainer() const;
// Retrieves the bounds in non-client view coordinates within which the
// TabStrip should be laid out.
virtual gfx::Rect GetBoundsForTabStripRegion(
......
......@@ -92,7 +92,6 @@
#include "chrome/browser/ui/views/frame/app_menu_button.h"
#include "chrome/browser/ui/views/frame/browser_view_layout.h"
#include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h"
#include "chrome/browser/ui/views/frame/caption_button_container.h"
#include "chrome/browser/ui/views/frame/contents_layout_manager.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
#include "chrome/browser/ui/views/frame/tab_strip_region_view.h"
......
......@@ -22,7 +22,6 @@
#include "chrome/browser/ui/views/exclusive_access_bubble_views.h"
#include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h"
#include "chrome/browser/ui/views/frame/browser_view_layout_delegate.h"
#include "chrome/browser/ui/views/frame/caption_button_container.h"
#include "chrome/browser/ui/views/frame/contents_layout_manager.h"
#include "chrome/browser/ui/views/frame/immersive_mode_controller.h"
#include "chrome/browser/ui/views/frame/tab_strip_region_view.h"
......@@ -231,20 +230,6 @@ int BrowserViewLayout::NonClientHitTest(const gfx::Point& point) {
views::View::ConvertPointToTarget(
parent, browser_view_, &point_in_browser_view_coords);
// In some configurations, the caption button container may be part of the
// browser top area instead of the frame, but we still have to treat it as
// part of the frame for hit testing purposes.
auto* const caption_buttons =
browser_view_->frame()->GetFrameView()->GetCaptionButtonContainer();
if (caption_buttons && top_container_->Contains(caption_buttons)) {
gfx::Point test_point = point;
if (ConvertedHitTest(parent, caption_buttons, &test_point)) {
const int result = caption_buttons->NonClientHitTest(test_point);
if (result != HTNOWHERE)
return result;
}
}
// Determine if the TabStrip exists and is capable of being clicked on. We
// might be a popup window without a TabStrip.
if (delegate_->IsTabStripVisible()) {
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/frame/caption_button_container.h"
#include "chrome/browser/themes/theme_properties.h"
#include "ui/base/theme_provider.h"
#include "ui/gfx/canvas.h"
#include "ui/views/widget/widget.h"
void CaptionButtonContainer::OnPaintBackground(gfx::Canvas* canvas) {
if (paint_frame_background_) {
const SkColor caption_color = GetThemeProvider()->GetColor(
GetWidget()->ShouldPaintAsActive()
? ThemeProperties::COLOR_FRAME_ACTIVE
: ThemeProperties::COLOR_FRAME_INACTIVE);
canvas->DrawColor(caption_color);
}
View::OnPaintBackground(canvas);
}
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_VIEWS_FRAME_CAPTION_BUTTON_CONTAINER_H_
#define CHROME_BROWSER_UI_VIEWS_FRAME_CAPTION_BUTTON_CONTAINER_H_
#include "ui/gfx/geometry/point.h"
#include "ui/views/view.h"
// Abstract base class for caption button containers. This allows ownership of
// caption buttons for certain frame types and situations (specifically handling
// the case of touch-tablet mode on Windows).
class CaptionButtonContainer : public views::View {
public:
void set_paint_frame_background(bool paint_frame_background) {
paint_frame_background_ = paint_frame_background;
}
bool paint_frame_background() const { return paint_frame_background_; }
// Tests to see if the specified |point| (which is expressed in this view's
// coordinates and which must be within this view's bounds) is within one of
// the caption buttons. Returns one of HitTestCompat enum defined in
// ui/base/hit_test.h, HTCAPTION if the area hit would be part of the window's
// drag handle, and HTNOWHERE otherwise.
// See also ClientView::NonClientHitTest.
virtual int NonClientHitTest(const gfx::Point& point) const = 0;
protected:
// views::View:
void OnPaintBackground(gfx::Canvas* canvas) override;
private:
// Determines whether or not this container should paint its own background in
// the appropriate browser frame color (true) or should paint on its existing
// parent view's background (false). The default is false.
//
// This method is provided because the background color of the caption buttons
// should match the background color of the tabstrip in normal browser mode,
// or the frame in PWA and WebUI tablet tabstrip mode. See crbug.com/1099195
// for an example of what happens if background painting is not disabled in
// normal browser mode.
bool paint_frame_background_ = false;
};
#endif // CHROME_BROWSER_UI_VIEWS_FRAME_CAPTION_BUTTON_CONTAINER_H_
......@@ -6,7 +6,6 @@
#define CHROME_BROWSER_UI_VIEWS_FRAME_GLASS_BROWSER_CAPTION_BUTTON_CONTAINER_H_
#include "base/scoped_observer.h"
#include "chrome/browser/ui/views/frame/caption_button_container.h"
#include "ui/base/pointer/touch_ui_controller.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/view.h"
......@@ -19,15 +18,20 @@ class Windows10CaptionButton;
// Provides a container for Windows 10 caption buttons that can be moved between
// frame and browser window as needed. When extended horizontally, becomes a
// grab bar for moving the window.
class GlassBrowserCaptionButtonContainer : public CaptionButtonContainer,
class GlassBrowserCaptionButtonContainer : public views::View,
public views::WidgetObserver {
public:
explicit GlassBrowserCaptionButtonContainer(
GlassBrowserFrameView* frame_view);
~GlassBrowserCaptionButtonContainer() override;
// CaptionButtonContainer:
int NonClientHitTest(const gfx::Point& point) const override;
// Tests to see if the specified |point| (which is expressed in this view's
// coordinates and which must be within this view's bounds) is within one of
// the caption buttons. Returns one of HitTestCompat enum defined in
// ui/base/hit_test.h, HTCAPTION if the area hit would be part of the window's
// drag handle, and HTNOWHERE otherwise.
// See also ClientView::NonClientHitTest.
int NonClientHitTest(const gfx::Point& point) const;
private:
friend class GlassBrowserFrameView;
......
......@@ -231,11 +231,6 @@ gfx::Size GlassBrowserFrameView::GetMinimumSize() const {
return min_size;
}
CaptionButtonContainer* GlassBrowserFrameView::GetCaptionButtonContainer()
const {
return caption_button_container_;
}
///////////////////////////////////////////////////////////////////////////////
// GlassBrowserFrameView, views::NonClientFrameView implementation:
......
......@@ -47,7 +47,6 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView,
SkColor GetCaptionColor(BrowserFrameActiveState active_state) const override;
void UpdateThrobber(bool running) override;
gfx::Size GetMinimumSize() const override;
CaptionButtonContainer* GetCaptionButtonContainer() const override;
// views::NonClientFrameView:
gfx::Rect GetBoundsForClientView() const override;
......@@ -162,11 +161,6 @@ class GlassBrowserFrameView : public BrowserNonClientFrameView,
views::Label* window_title_ = nullptr;
// The container holding the caption buttons (minimize, maximize, close, etc.)
//
// This is normally parented to the frame view, but in some modes (e.g. tablet
// mode on Windows) it is handed off to the browser view to be displayed in
// the client area.
//
// May be null if the caption button container is destroyed before the frame
// view. Always check for validity before using!
GlassBrowserCaptionButtonContainer* caption_button_container_;
......
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