Skip to content

Commit

Permalink
Move frame_utils.cc to //chromeos/ui/frame
Browse files Browse the repository at this point in the history
Dependency/include graph:

- frame_utils.h is included by frame_header.cc;
- frame_header.h is included by default_frame_header.h
- browser_non_client_frame_view_ash.cc includes default_frame_header.h.

So, in order to free browser_non_client_frame_view_ash.cc|h from
including //ash/ headers the items above will migrate step by step
to //chromeos/ui.

BUG=1113900
R=jamescook@chromium.org, sky@chromium.org

Change-Id: I573a053321b82825d80554c1a3c44079bf6d2a4b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2521364
Commit-Queue: Antonio Gomes <tonikitoo@igalia.com>
Reviewed-by: Scott Violet <sky@chromium.org>
Reviewed-by: James Cook <jamescook@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824893}
  • Loading branch information
tonikitoo authored and Commit Bot committed Nov 6, 2020
1 parent 290211d commit c4433df
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 26 deletions.
1 change: 1 addition & 0 deletions ash/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2675,6 +2675,7 @@ static_library("test_support") {
"//base/test:test_support",
"//cc:test_support",
"//chromeos/services/assistant/public/cpp",
"//chromeos/ui/frame",
"//ui/accessibility/mojom",
"//ui/platform_window/common",

Expand Down
4 changes: 2 additions & 2 deletions ash/frame/non_client_frame_view_ash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "ash/frame/header_view.h"
#include "ash/public/cpp/ash_constants.h"
#include "ash/public/cpp/default_frame_header.h"
#include "ash/public/cpp/frame_utils.h"
#include "ash/public/cpp/tablet_mode_observer.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/shell.h"
Expand All @@ -24,6 +23,7 @@
#include "base/bind.h"
#include "chromeos/ui/base/window_properties.h"
#include "chromeos/ui/frame/caption_buttons/frame_caption_button_container_view.h"
#include "chromeos/ui/frame/frame_utils.h"
#include "chromeos/ui/frame/immersive/immersive_fullscreen_controller.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
Expand Down Expand Up @@ -290,7 +290,7 @@ gfx::Rect NonClientFrameViewAsh::GetWindowBoundsForClientBounds(
}

int NonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) {
return FrameBorderNonClientHitTest(this, point);
return chromeos::FrameBorderNonClientHitTest(this, point);
}

void NonClientFrameViewAsh::GetWindowMask(const gfx::Size& size,
Expand Down
2 changes: 0 additions & 2 deletions ash/public/cpp/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,6 @@ component("cpp") {
"fps_counter.h",
"frame_header.cc",
"frame_header.h",
"frame_utils.cc",
"frame_utils.h",
"gesture_action_type.h",
"holding_space/holding_space_client.h",
"holding_space/holding_space_color_provider.cc",
Expand Down
5 changes: 3 additions & 2 deletions ash/public/cpp/frame_header.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

#include "ash/public/cpp/frame_header.h"

#include "ash/public/cpp/frame_utils.h"
#include "ash/public/cpp/window_properties.h"
#include "base/logging.h" // DCHECK
#include "chromeos/ui/frame/caption_buttons/caption_button_model.h"
#include "chromeos/ui/frame/caption_buttons/frame_caption_button_container_view.h"
#include "chromeos/ui/frame/frame_utils.h"
#include "chromeos/ui/vector_icons/vector_icons.h"
#include "ui/base/class_property.h"
#include "ui/compositor/layer_animation_observer.h"
Expand Down Expand Up @@ -367,7 +367,8 @@ void FrameHeader::LayoutHeaderInternal() {
// TODO(crbug.com/1092005): Investigate if we can move this to
// CaptionButtonModel and just check the model in
// chromeos::FrameCaptionButtonContainerView.
const bool use_restore_frame = ash::ShouldUseRestoreFrame(target_widget_);
const bool use_restore_frame =
chromeos::ShouldUseRestoreFrame(target_widget_);
caption_button_container()->SetButtonImage(
views::CAPTION_BUTTON_ICON_MAXIMIZE_RESTORE,
use_restore_frame ? maximize_icon : restore_icon);
Expand Down
4 changes: 2 additions & 2 deletions ash/test/ash_test_views_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

#include "ash/test/ash_test_views_delegate.h"

#include "ash/public/cpp/frame_utils.h"
#include "ash/shell.h"
#include "chromeos/ui/frame/frame_utils.h"

namespace ash {

Expand All @@ -20,7 +20,7 @@ void AshTestViewsDelegate::OnBeforeWidgetInit(
params->context = Shell::GetRootWindowForNewWindows();

if (params->opacity == views::Widget::InitParams::WindowOpacity::kInferred)
ResolveInferredOpacity(params);
chromeos::ResolveInferredOpacity(params);

TestViewsDelegate::OnBeforeWidgetInit(params, delegate);
}
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/views/chrome_views_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

#if defined(OS_CHROMEOS)
#include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/frame_utils.h"
#include "chrome/browser/ui/views/touch_selection_menu_runner_chromeos.h"
#include "chromeos/ui/frame/frame_utils.h"
#include "ui/aura/client/aura_constants.h"
#endif

Expand Down Expand Up @@ -172,7 +172,7 @@ void ChromeViewsDelegate::OnBeforeWidgetInit(
// We need to determine opacity if it's not already specified.
if (params->opacity == views::Widget::InitParams::WindowOpacity::kInferred) {
#if defined(OS_CHROMEOS)
ash::ResolveInferredOpacity(params);
chromeos::ResolveInferredOpacity(params);
#else
params->opacity = views::Widget::InitParams::WindowOpacity::kOpaque;
#endif
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/views/frame/browser_frame_header_ash.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#include "chrome/browser/ui/views/frame/browser_frame_header_ash.h"

#include "ash/public/cpp/ash_constants.h"
#include "ash/public/cpp/frame_utils.h"
#include "ash/public/cpp/tablet_mode.h"
#include "base/check.h"
#include "chrome/app/vector_icons/vector_icons.h"
#include "chromeos/ui/base/window_properties.h"
#include "chromeos/ui/base/window_state_type.h"
#include "chromeos/ui/frame/caption_buttons/frame_caption_button_container_view.h"
#include "chromeos/ui/frame/frame_utils.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkPaint.h"
Expand Down Expand Up @@ -147,7 +147,7 @@ views::CaptionButtonLayoutSize BrowserFrameHeaderAsh::GetButtonLayoutSize()
if (ash::TabletMode::Get() && ash::TabletMode::Get()->InTabletMode())
return views::CaptionButtonLayoutSize::kBrowserCaptionMaximized;

return ash::ShouldUseRestoreFrame(target_widget())
return chromeos::ShouldUseRestoreFrame(target_widget())
? views::CaptionButtonLayoutSize::kBrowserCaptionRestored
: views::CaptionButtonLayoutSize::kBrowserCaptionMaximized;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/default_frame_header.h"
#include "ash/public/cpp/frame_utils.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/wm/window_util.h"
#include "base/metrics/user_metrics.h"
Expand Down Expand Up @@ -40,6 +39,7 @@
#include "chromeos/ui/base/window_properties.h"
#include "chromeos/ui/base/window_state_type.h"
#include "chromeos/ui/frame/caption_buttons/frame_caption_button_container_view.h"
#include "chromeos/ui/frame/frame_utils.h"
#include "content/public/browser/web_contents.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/accessibility/ax_enums.mojom.h"
Expand Down Expand Up @@ -256,7 +256,7 @@ gfx::Rect BrowserNonClientFrameViewAsh::GetWindowBoundsForClientBounds(
}

int BrowserNonClientFrameViewAsh::NonClientHitTest(const gfx::Point& point) {
int hit_test = ash::FrameBorderNonClientHitTest(this, point);
int hit_test = chromeos::FrameBorderNonClientHitTest(this, point);

// When the window is restored we want a large click target above the tabs
// to drag the window, so redirect clicks in the tab's shadow to caption.
Expand Down
2 changes: 2 additions & 0 deletions chromeos/ui/frame/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ source_set("frame") {
"caption_buttons/frame_size_button_delegate.h",
"caption_buttons/snap_controller.cc",
"caption_buttons/snap_controller.h",
"frame_utils.cc",
"frame_utils.h",
"immersive/immersive_context.cc",
"immersive/immersive_context.h",
"immersive/immersive_focus_watcher.cc",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/public/cpp/frame_utils.h"
#include "chromeos/ui/frame/frame_utils.h"

#include "chromeos/ui/base/chromeos_ui_constants.h"
#include "chromeos/ui/base/window_properties.h"
Expand All @@ -15,7 +15,7 @@
#include "ui/views/window/hit_test_utils.h"
#include "ui/views/window/non_client_view.h"

namespace ash {
namespace chromeos {

using WindowOpacity = views::Widget::InitParams::WindowOpacity;

Expand Down Expand Up @@ -94,4 +94,4 @@ bool ShouldUseRestoreFrame(const views::Widget* widget) {
return true;
}

} // namespace ash
} // namespace chromeos
19 changes: 10 additions & 9 deletions ash/public/cpp/frame_utils.h → chromeos/ui/frame/frame_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef ASH_PUBLIC_CPP_FRAME_UTILS_H_
#define ASH_PUBLIC_CPP_FRAME_UTILS_H_

#include "ash/public/cpp/ash_public_export.h"
#include "base/component_export.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/views/widget/widget.h"

Expand All @@ -17,20 +17,21 @@ namespace views {
class NonClientFrameView;
}

namespace ash {
namespace chromeos {

// Returns the HitTestCompat for the specified point.
ASH_PUBLIC_EXPORT int FrameBorderNonClientHitTest(
views::NonClientFrameView* view,
const gfx::Point& point_in_widget);
COMPONENT_EXPORT(CHROMEOS_UI_FRAME)
int FrameBorderNonClientHitTest(views::NonClientFrameView* view,
const gfx::Point& point_in_widget);

// Resolve the inferred opacity and updates the params.
ASH_PUBLIC_EXPORT void ResolveInferredOpacity(
views::Widget::InitParams* params);
COMPONENT_EXPORT(CHROMEOS_UI_FRAME)
void ResolveInferredOpacity(views::Widget::InitParams* params);

// Checks whether we should draw the restored window frame on |widget|.
ASH_PUBLIC_EXPORT bool ShouldUseRestoreFrame(const views::Widget* widget);
COMPONENT_EXPORT(CHROMEOS_UI_FRAME)
bool ShouldUseRestoreFrame(const views::Widget* widget);

} // namespace ash
} // namespace chromeos

#endif // ASH_PUBLIC_CPP_FRAME_UTILS_H_

0 comments on commit c4433df

Please sign in to comment.