Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2231)

Unified Diff: ash/wm/custom_frame_view_ash.cc

Issue 189463013: [Refactor] Move code for painting the window header for browser windows out of ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ash/wm/custom_frame_view_ash.cc
diff --git a/ash/wm/custom_frame_view_ash.cc b/ash/wm/custom_frame_view_ash.cc
index 85082d3a9c4b75b2718a04666d5b68e342e4c772..9c76956e95d12c9dd1393ac4ecb268ec8aecbac3 100644
--- a/ash/wm/custom_frame_view_ash.cc
+++ b/ash/wm/custom_frame_view_ash.cc
@@ -8,38 +8,27 @@
#include "ash/wm/caption_buttons/frame_caption_button_container_view.h"
#include "ash/wm/caption_buttons/frame_maximize_button.h"
#include "ash/wm/caption_buttons/frame_maximize_button_observer.h"
+#include "ash/wm/default_header_painter.h"
#include "ash/wm/frame_border_hit_test_controller.h"
-#include "ash/wm/header_painter.h"
#include "ash/wm/immersive_fullscreen_controller.h"
#include "ash/wm/window_state.h"
#include "ash/wm/window_state_delegate.h"
#include "ash/wm/window_state_observer.h"
#include "base/command_line.h"
-#include "base/debug/leak_annotations.h"
-#include "grit/ash_resources.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/window.h"
#include "ui/aura/window_observer.h"
#include "ui/gfx/canvas.h"
-#include "ui/gfx/font_list.h"
#include "ui/gfx/rect.h"
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/size.h"
#include "ui/views/view.h"
-#include "ui/views/widget/native_widget_aura.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
#include "ui/views/widget/widget_deletion_observer.h"
namespace {
-const gfx::FontList& GetTitleFontList() {
- static const gfx::FontList* title_font_list =
- new gfx::FontList(views::NativeWidgetAura::GetWindowTitleFontList());
- ANNOTATE_LEAKING_OBJECT_PTR(title_font_list);
- return *title_font_list;
-}
-
///////////////////////////////////////////////////////////////////////////////
// CustomFrameViewAshWindowStateDelegate
@@ -162,8 +151,8 @@ class CustomFrameViewAsh::HeaderView
virtual void Layout() OVERRIDE;
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE;
- HeaderPainter* header_painter() {
- return header_painter_.get();
+ FrameCaptionButtonContainerView* caption_button_container() {
+ return caption_button_container_;
}
private:
@@ -181,7 +170,7 @@ class CustomFrameViewAsh::HeaderView
views::Widget* frame_;
// Helper for painting the header.
- scoped_ptr<HeaderPainter> header_painter_;
+ scoped_ptr<DefaultHeaderPainter> header_painter_;
// View which contains the window caption buttons.
FrameCaptionButtonContainerView* caption_button_container_;
@@ -202,7 +191,7 @@ class CustomFrameViewAsh::HeaderView
CustomFrameViewAsh::HeaderView::HeaderView(views::Widget* frame)
: frame_(frame),
- header_painter_(new ash::HeaderPainter),
+ header_painter_(new ash::DefaultHeaderPainter),
caption_button_container_(NULL),
maximize_bubble_(NULL),
fullscreen_visible_fraction_(0) {
@@ -220,8 +209,7 @@ CustomFrameViewAsh::HeaderView::HeaderView(views::Widget* frame)
if (frame_maximize_button)
frame_maximize_button->AddObserver(this);
- header_painter_->Init(HeaderPainter::STYLE_OTHER, frame_, this, NULL,
- caption_button_container_);
+ header_painter_->Init(frame_, this, NULL, caption_button_container_);
}
CustomFrameViewAsh::HeaderView::~HeaderView() {
@@ -232,7 +220,7 @@ CustomFrameViewAsh::HeaderView::~HeaderView() {
}
void CustomFrameViewAsh::HeaderView::SchedulePaintForTitle() {
- header_painter_->SchedulePaintForTitle(GetTitleFontList());
+ header_painter_->SchedulePaintForTitle();
}
void CustomFrameViewAsh::HeaderView::ResetWindowControls() {
@@ -248,9 +236,7 @@ int CustomFrameViewAsh::HeaderView::GetPreferredOnScreenHeight() const {
}
int CustomFrameViewAsh::HeaderView::GetPreferredHeight() const {
- // Reserve enough space to see the buttons and the separator line.
- return caption_button_container_->bounds().bottom() +
- header_painter_->HeaderContentSeparatorSize();
+ return header_painter_->GetHeaderHeightForPainting();
}
int CustomFrameViewAsh::HeaderView::GetMinimumWidth() const {
@@ -259,7 +245,6 @@ int CustomFrameViewAsh::HeaderView::GetMinimumWidth() const {
void CustomFrameViewAsh::HeaderView::Layout() {
header_painter_->LayoutHeader();
- header_painter_->set_header_height(GetPreferredHeight());
}
void CustomFrameViewAsh::HeaderView::OnPaint(gfx::Canvas* canvas) {
@@ -267,21 +252,9 @@ void CustomFrameViewAsh::HeaderView::OnPaint(gfx::Canvas* canvas) {
frame_->non_client_view()->frame_view()->ShouldPaintAsActive();
caption_button_container_->SetPaintAsActive(paint_as_active);
- int theme_image_id = 0;
- if (paint_as_active)
- theme_image_id = IDR_AURA_WINDOW_HEADER_BASE_ACTIVE;
- else
- theme_image_id = IDR_AURA_WINDOW_HEADER_BASE_INACTIVE;
-
HeaderPainter::Mode header_mode = paint_as_active ?
HeaderPainter::MODE_ACTIVE : HeaderPainter::MODE_INACTIVE;
- header_painter_->PaintHeader(
- canvas,
- header_mode,
- theme_image_id,
- 0);
- header_painter_->PaintTitleBar(canvas, GetTitleFontList());
- header_painter_->PaintHeaderContentSeparator(canvas, header_mode);
+ header_painter_->PaintHeader(canvas, header_mode);
}
void CustomFrameViewAsh::HeaderView::OnImmersiveRevealStarted() {
@@ -421,20 +394,21 @@ void CustomFrameViewAsh::InitImmersiveFullscreenControllerForView(
// CustomFrameViewAsh, views::NonClientFrameView overrides:
gfx::Rect CustomFrameViewAsh::GetBoundsForClientView() const {
- int top_height = NonClientTopBorderHeight();
- return HeaderPainter::GetBoundsForClientView(top_height, bounds());
+ gfx::Rect client_bounds = bounds();
+ client_bounds.Inset(0, NonClientTopBorderHeight(), 0, 0);
+ return client_bounds;
}
gfx::Rect CustomFrameViewAsh::GetWindowBoundsForClientBounds(
const gfx::Rect& client_bounds) const {
- int top_height = NonClientTopBorderHeight();
- return HeaderPainter::GetWindowBoundsForClientBounds(top_height,
- client_bounds);
+ gfx::Rect window_bounds = client_bounds;
+ window_bounds.Inset(0, -NonClientTopBorderHeight(), 0, 0);
+ return window_bounds;
}
int CustomFrameViewAsh::NonClientHitTest(const gfx::Point& point) {
return FrameBorderHitTestController::NonClientHitTest(this,
- header_view_->header_painter(), point);
+ header_view_->caption_button_container(), point);
}
void CustomFrameViewAsh::GetWindowMask(const gfx::Size& size,

Powered by Google App Engine
This is Rietveld 408576698