From 42c35a5997f5b11522ee308c19d334146ac6895a Mon Sep 17 00:00:00 2001 From: "jcampan@chromium.org" Date: Fri, 19 Jun 2009 23:08:41 +0000 Subject: Reverting 18872. Broke the Windows build. BUG=None TEST=None TBR=ben Review URL: http://codereview.chromium.org/140023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18873 0039d316-1c4b-4281-b951-d872f2087c98 --- .../views/autocomplete/autocomplete_popup_win.cc | 4 +- .../views/blocked_popup_container_view_win.cc | 2 +- chrome/browser/views/bookmark_bubble_view.cc | 4 +- chrome/browser/views/browser_bubble_win.cc | 4 +- chrome/browser/views/constrained_window_impl.cc | 691 --------------------- .../views/download_started_animation_win.cc | 2 +- chrome/browser/views/find_bar_win.cc | 5 +- chrome/browser/views/find_bar_win_browsertest.cc | 5 +- chrome/browser/views/first_run_bubble.cc | 8 +- chrome/browser/views/fullscreen_exit_bubble.cc | 2 +- chrome/browser/views/info_bubble.cc | 10 +- chrome/browser/views/infobars/infobars.cc | 5 +- chrome/browser/views/shelf_item_dialog.cc | 3 +- chrome/browser/views/status_bubble_views.cc | 2 +- .../views/tab_contents/tab_contents_view_win.cc | 12 +- .../browser/views/tabs/dragged_tab_controller.cc | 2 +- chrome/browser/views/tabs/dragged_tab_view.cc | 2 +- .../views/tabs/native_view_photobooth_win.cc | 2 +- chrome/browser/views/tabs/tab_strip.cc | 3 +- 19 files changed, 43 insertions(+), 725 deletions(-) delete mode 100644 chrome/browser/views/constrained_window_impl.cc (limited to 'chrome/browser/views') diff --git a/chrome/browser/views/autocomplete/autocomplete_popup_win.cc b/chrome/browser/views/autocomplete/autocomplete_popup_win.cc index accdbd5..02d3118 100644 --- a/chrome/browser/views/autocomplete/autocomplete_popup_win.cc +++ b/chrome/browser/views/autocomplete/autocomplete_popup_win.cc @@ -28,9 +28,7 @@ void AutocompletePopupWin::Init(AutocompleteEditViewWin* edit_view, views::View* contents) { // Create the popup WidgetWin::Init(edit_view->parent_view()->GetWidget()->GetNativeView(), - contents_->GetPopupBounds()); - // The contents is owned by the AutocompleteEditViewWin. - contents_->SetParentOwned(false); + contents_->GetPopupBounds(), false); // The contents is owned by the LocationBarView. contents_->SetParentOwned(false); SetContentsView(contents_); diff --git a/chrome/browser/views/blocked_popup_container_view_win.cc b/chrome/browser/views/blocked_popup_container_view_win.cc index 29240de..8e2837e 100644 --- a/chrome/browser/views/blocked_popup_container_view_win.cc +++ b/chrome/browser/views/blocked_popup_container_view_win.cc @@ -398,7 +398,7 @@ BlockedPopupContainerViewWin::BlockedPopupContainerViewWin( set_window_style(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN); WidgetWin::Init(GetModel()->GetConstrainingContents(NULL)->GetNativeView(), - gfx::Rect()); + gfx::Rect(), false); SetContentsView(container_view_); SetPosition(); } diff --git a/chrome/browser/views/bookmark_bubble_view.cc b/chrome/browser/views/bookmark_bubble_view.cc index b81d0ab..9a2a8f6 100644 --- a/chrome/browser/views/bookmark_bubble_view.cc +++ b/chrome/browser/views/bookmark_bubble_view.cc @@ -182,7 +182,9 @@ void BookmarkBubbleView::DidChangeBounds(const gfx::Rect& previous, void BookmarkBubbleView::BubbleShown() { DCHECK(GetWidget()); - GetFocusManager()->RegisterAccelerator( + views::FocusManager* focus_manager = + views::FocusManager::GetFocusManager(GetWidget()->GetNativeView()); + focus_manager->RegisterAccelerator( views::Accelerator(VK_RETURN, false, false, false), this); title_tf_->RequestFocus(); diff --git a/chrome/browser/views/browser_bubble_win.cc b/chrome/browser/views/browser_bubble_win.cc index e72545b..7b47fe9 100644 --- a/chrome/browser/views/browser_bubble_win.cc +++ b/chrome/browser/views/browser_bubble_win.cc @@ -24,7 +24,9 @@ void BrowserBubble::InitPopup() { #endif // A focus manager is necessary if you want to be able to handle various // mouse events properly. - pop->Init(frame_native_view_, bounds_); + pop->Init(frame_native_view_, + bounds_, + true); // Give the widget a focus manager. pop->SetContentsView(view_); popup_.reset(pop); Reposition(); diff --git a/chrome/browser/views/constrained_window_impl.cc b/chrome/browser/views/constrained_window_impl.cc deleted file mode 100644 index 39d3bcb..0000000 --- a/chrome/browser/views/constrained_window_impl.cc +++ /dev/null @@ -1,691 +0,0 @@ -// Copyright (c) 2006-2008 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/views/constrained_window_impl.h" - -#include "app/gfx/canvas.h" -#include "app/gfx/font.h" -#include "app/gfx/path.h" -#include "app/gfx/text_elider.h" -#include "app/l10n_util.h" -#include "app/resource_bundle.h" -#include "app/win_util.h" -#include "base/gfx/rect.h" -#include "chrome/app/chrome_dll_resource.h" -#include "chrome/browser/browser_process.h" -#include "chrome/browser/profile.h" -#include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/browser/tab_contents/tab_contents.h" -#include "chrome/browser/tab_contents/tab_contents_view.h" -#include "chrome/browser/toolbar_model.h" -#include "chrome/browser/views/frame/browser_view.h" -#include "chrome/browser/window_sizer.h" -#include "chrome/common/chrome_constants.h" -#include "chrome/common/notification_service.h" -#include "chrome/common/pref_names.h" -#include "chrome/common/pref_service.h" -#include "grit/app_resources.h" -#include "grit/chromium_strings.h" -#include "grit/generated_resources.h" -#include "grit/theme_resources.h" -#include "net/base/net_util.h" -#include "views/controls/button/image_button.h" -#include "views/focus/focus_manager.h" -#include "views/window/client_view.h" -#include "views/window/non_client_view.h" -#include "views/window/window_resources.h" - -using base::TimeDelta; - -namespace views { -class ClientView; -} - -// An enumeration of bitmap resources used by this window. -enum { - FRAME_PART_BITMAP_FIRST = 0, // Must be first. - - // Window Controls. - FRAME_CLOSE_BUTTON_ICON, - FRAME_CLOSE_BUTTON_ICON_H, - FRAME_CLOSE_BUTTON_ICON_P, - - // Window Frame Border. - FRAME_BOTTOM_EDGE, - FRAME_BOTTOM_LEFT_CORNER, - FRAME_BOTTOM_RIGHT_CORNER, - FRAME_LEFT_EDGE, - FRAME_RIGHT_EDGE, - FRAME_TOP_EDGE, - FRAME_TOP_LEFT_CORNER, - FRAME_TOP_RIGHT_CORNER, - - FRAME_WINDOW, - FRAME_WINDOW_INACTIVE, - FRAME_WINDOW_INCOGNITO, - FRAME_WINDOW_INCOGNITO_INACTIVE, - - FRAME_PART_BITMAP_COUNT // Must be last. -}; - -static const int kXPFramePartIDs[] = { - 0, - IDR_CLOSE_SA, IDR_CLOSE_SA_H, IDR_CLOSE_SA_P, - IDR_WINDOW_BOTTOM_CENTER, IDR_WINDOW_BOTTOM_LEFT_CORNER, - IDR_WINDOW_BOTTOM_RIGHT_CORNER, IDR_WINDOW_LEFT_SIDE, - IDR_WINDOW_RIGHT_SIDE, IDR_WINDOW_TOP_CENTER, - IDR_WINDOW_TOP_LEFT_CORNER, IDR_WINDOW_TOP_RIGHT_CORNER, - IDR_THEME_FRAME, IDR_THEME_FRAME_INACTIVE, IDR_THEME_FRAME_INCOGNITO, - IDR_THEME_FRAME_INCOGNITO_INACTIVE, - 0 }; -static const int kVistaFramePartIDs[] = { - 0, - IDR_CLOSE_SA, IDR_CLOSE_SA_H, IDR_CLOSE_SA_P, - IDR_CONSTRAINED_BOTTOM_CENTER_V, IDR_CONSTRAINED_BOTTOM_LEFT_CORNER_V, - IDR_CONSTRAINED_BOTTOM_RIGHT_CORNER_V, IDR_CONSTRAINED_LEFT_SIDE_V, - IDR_CONSTRAINED_RIGHT_SIDE_V, IDR_CONSTRAINED_TOP_CENTER_V, - IDR_CONSTRAINED_TOP_LEFT_CORNER_V, IDR_CONSTRAINED_TOP_RIGHT_CORNER_V, - IDR_THEME_FRAME, IDR_THEME_FRAME_INACTIVE, IDR_THEME_FRAME_INCOGNITO, - IDR_THEME_FRAME_INCOGNITO_INACTIVE, - 0 }; - -class XPWindowResources : public views::WindowResources { - public: - XPWindowResources() { - InitClass(); - } - virtual ~XPWindowResources() {} - - virtual SkBitmap* GetPartBitmap(views::FramePartBitmap part_id) const { - return bitmaps_[part_id]; - } - - private: - static void InitClass() { - static bool initialized = false; - if (!initialized) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) { - int id = kXPFramePartIDs[i]; - if (id != 0) - bitmaps_[i] = rb.GetBitmapNamed(id); - } - initialized = true; - } - } - - static SkBitmap* bitmaps_[FRAME_PART_BITMAP_COUNT]; - - DISALLOW_EVIL_CONSTRUCTORS(XPWindowResources); -}; - -class VistaWindowResources : public views::WindowResources { - public: - VistaWindowResources() { - InitClass(); - } - virtual ~VistaWindowResources() {} - - virtual SkBitmap* GetPartBitmap(views::FramePartBitmap part_id) const { - return bitmaps_[part_id]; - } - - private: - static void InitClass() { - static bool initialized = false; - if (!initialized) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - for (int i = 0; i < FRAME_PART_BITMAP_COUNT; ++i) { - int id = kVistaFramePartIDs[i]; - if (id != 0) - bitmaps_[i] = rb.GetBitmapNamed(id); - } - initialized = true; - } - } - - static SkBitmap* bitmaps_[FRAME_PART_BITMAP_COUNT]; - - DISALLOW_EVIL_CONSTRUCTORS(VistaWindowResources); -}; - -SkBitmap* XPWindowResources::bitmaps_[]; -SkBitmap* VistaWindowResources::bitmaps_[]; - -//////////////////////////////////////////////////////////////////////////////// -// ConstrainedWindowFrameView - -class ConstrainedWindowFrameView - : public views::NonClientFrameView, - public views::ButtonListener { - public: - explicit ConstrainedWindowFrameView(ConstrainedWindowImpl* container); - virtual ~ConstrainedWindowFrameView(); - - void UpdateWindowTitle(); - - // Overridden from views::NonClientFrameView: - virtual gfx::Rect GetBoundsForClientView() const; - virtual bool AlwaysUseCustomFrame() const; - virtual gfx::Rect GetWindowBoundsForClientBounds( - const gfx::Rect& client_bounds) const; - virtual gfx::Point GetSystemMenuPoint() const; - virtual int NonClientHitTest(const gfx::Point& point); - virtual void GetWindowMask(const gfx::Size& size, gfx::Path* window_mask); - virtual void EnableClose(bool enable); - virtual void ResetWindowControls() { } - - // Overridden from views::View: - virtual void Paint(gfx::Canvas* canvas); - virtual void Layout(); - virtual void ThemeChanged(); - - // Overridden from views::ButtonListener: - virtual void ButtonPressed(views::Button* sender); - - private: - // Returns the thickness of the border that makes up the window frame edges. - // This does not include any client edge. - int FrameBorderThickness() const; - - // Returns the thickness of the entire nonclient left, right, and bottom - // borders, including both the window frame and any client edge. - int NonClientBorderThickness() const; - - // Returns the height of the entire nonclient top border, including the window - // frame, any title area, and any connected client edge. - int NonClientTopBorderHeight() const; - - // Calculates multiple values related to title layout. Returns the height of - // the entire titlebar including any connected client edge. - int TitleCoordinates(int* title_top_spacing, - int* title_thickness) const; - - // Paints different parts of the window to the incoming canvas. - void PaintFrameBorder(gfx::Canvas* canvas); - void PaintTitleBar(gfx::Canvas* canvas); - void PaintClientEdge(gfx::Canvas* canvas); - - // Layout various sub-components of this view. - void LayoutWindowControls(); - void LayoutTitleBar(); - void LayoutClientView(); - - // Returns the bounds of the client area for the specified view size. - gfx::Rect CalculateClientAreaBounds(int width, int height) const; - - SkColor GetTitleColor() const { - return (container_->owner()->profile()->IsOffTheRecord() || - !win_util::ShouldUseVistaFrame()) ? SK_ColorWHITE : SK_ColorBLACK; - } - - // Loads the appropriate set of WindowResources for the frame view. - void InitWindowResources(); - - ConstrainedWindowImpl* container_; - - scoped_ptr resources_; - - gfx::Rect title_bounds_; - - views::ImageButton* close_button_; - - // The bounds of the ClientView. - gfx::Rect client_view_bounds_; - - static void InitClass(); - - // The font to be used to render the titlebar text. - static gfx::Font* title_font_; - - DISALLOW_EVIL_CONSTRUCTORS(ConstrainedWindowFrameView); -}; - -gfx::Font* ConstrainedWindowFrameView::title_font_ = NULL; - -namespace { -// The frame border is only visible in restored mode and is hardcoded to 4 px on -// each side regardless of the system window border size. -const int kFrameBorderThickness = 4; -// Various edges of the frame border have a 1 px shadow along their edges; in a -// few cases we shift elements based on this amount for visual appeal. -const int kFrameShadowThickness = 1; -// In the window corners, the resize areas don't actually expand bigger, but the -// 16 px at the end of each edge triggers diagonal resizing. -const int kResizeAreaCornerSize = 16; -// The titlebar never shrinks to less than 20 px tall, including the height of -// the frame border and client edge. -const int kTitlebarMinimumHeight = 20; -// The icon is inset 2 px from the left frame border. -const int kIconLeftSpacing = 2; -// The title text starts 2 px below the bottom of the top frame border. -const int kTitleTopSpacing = 2; -// There is a 5 px gap between the title text and the caption buttons. -const int kTitleCaptionSpacing = 5; -// The caption buttons are always drawn 1 px down from the visible top of the -// window (the true top in restored mode, or the top of the screen in maximized -// mode). -const int kCaptionTopSpacing = 1; - -const SkColor kContentsBorderShadow = SkColorSetARGB(51, 0, 0, 0); -} - -//////////////////////////////////////////////////////////////////////////////// -// ConstrainedWindowFrameView, public: - -ConstrainedWindowFrameView::ConstrainedWindowFrameView( - ConstrainedWindowImpl* container) - : NonClientFrameView(), - container_(container), - close_button_(new views::ImageButton(this)) { - InitClass(); - InitWindowResources(); - - close_button_->SetImage(views::CustomButton::BS_NORMAL, - resources_->GetPartBitmap(FRAME_CLOSE_BUTTON_ICON)); - close_button_->SetImage(views::CustomButton::BS_HOT, - resources_->GetPartBitmap(FRAME_CLOSE_BUTTON_ICON_H)); - close_button_->SetImage(views::CustomButton::BS_PUSHED, - resources_->GetPartBitmap(FRAME_CLOSE_BUTTON_ICON_P)); - close_button_->SetImageAlignment(views::ImageButton::ALIGN_CENTER, - views::ImageButton::ALIGN_MIDDLE); - AddChildView(close_button_); -} - -ConstrainedWindowFrameView::~ConstrainedWindowFrameView() { -} - -void ConstrainedWindowFrameView::UpdateWindowTitle() { - SchedulePaint(title_bounds_, false); -} - -//////////////////////////////////////////////////////////////////////////////// -// ConstrainedWindowFrameView, views::NonClientFrameView implementation: - -gfx::Rect ConstrainedWindowFrameView::GetBoundsForClientView() const { - return client_view_bounds_; -} - -bool ConstrainedWindowFrameView::AlwaysUseCustomFrame() const { - // Constrained windows always use the custom frame - they just have a - // different set of bitmaps. - return true; -} - -gfx::Rect ConstrainedWindowFrameView::GetWindowBoundsForClientBounds( - const gfx::Rect& client_bounds) const { - int top_height = NonClientTopBorderHeight(); - int border_thickness = NonClientBorderThickness(); - return gfx::Rect(std::max(0, client_bounds.x() - border_thickness), - std::max(0, client_bounds.y() - top_height), - client_bounds.width() + (2 * border_thickness), - client_bounds.height() + top_height + border_thickness); -} - -gfx::Point ConstrainedWindowFrameView::GetSystemMenuPoint() const { - // Doesn't really matter, since we never show system menus on constrained - // windows... - gfx::Point system_menu_point(FrameBorderThickness(), - NonClientTopBorderHeight()); - ConvertPointToScreen(this, &system_menu_point); - return system_menu_point; -} - -int ConstrainedWindowFrameView::NonClientHitTest(const gfx::Point& point) { - if (!bounds().Contains(point)) - return HTNOWHERE; - - int frame_component = container_->GetClientView()->NonClientHitTest(point); - if (frame_component != HTNOWHERE) - return frame_component; - - // Then see if the point is within any of the window controls. - if (close_button_->GetBounds(APPLY_MIRRORING_TRANSFORMATION).Contains(point)) - return HTCLOSE; - - int window_component = GetHTComponentForFrame(point, FrameBorderThickness(), - NonClientBorderThickness(), kResizeAreaCornerSize, kResizeAreaCornerSize, - container_->GetDelegate()->CanResize()); - // Fall back to the caption if no other component matches. - return (window_component == HTNOWHERE) ? HTCAPTION : window_component; -} - -void ConstrainedWindowFrameView::GetWindowMask(const gfx::Size& size, - gfx::Path* window_mask) { - DCHECK(window_mask); - - // Redefine the window visible region for the new size. - window_mask->moveTo(0, 3); - window_mask->lineTo(1, 2); - window_mask->lineTo(1, 1); - window_mask->lineTo(2, 1); - window_mask->lineTo(3, 0); - - window_mask->lineTo(SkIntToScalar(size.width() - 3), 0); - window_mask->lineTo(SkIntToScalar(size.width() - 2), 1); - window_mask->lineTo(SkIntToScalar(size.width() - 1), 1); - window_mask->lineTo(SkIntToScalar(size.width() - 1), 2); - window_mask->lineTo(SkIntToScalar(size.width()), 3); - - window_mask->lineTo(SkIntToScalar(size.width()), - SkIntToScalar(size.height())); - window_mask->lineTo(0, SkIntToScalar(size.height())); - window_mask->close(); -} - -void ConstrainedWindowFrameView::EnableClose(bool enable) { - close_button_->SetEnabled(enable); -} - -//////////////////////////////////////////////////////////////////////////////// -// ConstrainedWindowFrameView, views::View implementation: - -void ConstrainedWindowFrameView::Paint(gfx::Canvas* canvas) { - PaintFrameBorder(canvas); - PaintTitleBar(canvas); - PaintClientEdge(canvas); -} - -void ConstrainedWindowFrameView::Layout() { - LayoutWindowControls(); - LayoutTitleBar(); - LayoutClientView(); -} - -void ConstrainedWindowFrameView::ThemeChanged() { - InitWindowResources(); -} - -//////////////////////////////////////////////////////////////////////////////// -// ConstrainedWindowFrameView, views::ButtonListener implementation: - -void ConstrainedWindowFrameView::ButtonPressed(views::Button* sender) { - if (sender == close_button_) - container_->ExecuteSystemMenuCommand(SC_CLOSE); -} - -//////////////////////////////////////////////////////////////////////////////// -// ConstrainedWindowFrameView, private: - -int ConstrainedWindowFrameView::FrameBorderThickness() const { - return kFrameBorderThickness; -} - -int ConstrainedWindowFrameView::NonClientBorderThickness() const { - return FrameBorderThickness() + kClientEdgeThickness; -} - -int ConstrainedWindowFrameView::NonClientTopBorderHeight() const { - int title_top_spacing, title_thickness; - return TitleCoordinates(&title_top_spacing, &title_thickness); -} - -int ConstrainedWindowFrameView::TitleCoordinates( - int* title_top_spacing, - int* title_thickness) const { - int frame_thickness = FrameBorderThickness(); - int min_titlebar_height = kTitlebarMinimumHeight + frame_thickness; - *title_top_spacing = frame_thickness + kTitleTopSpacing; - // The bottom spacing should be the same apparent height as the top spacing, - // plus have the client edge tacked on. - int title_bottom_spacing = *title_top_spacing + kClientEdgeThickness; - *title_thickness = std::max(title_font_->height(), - min_titlebar_height - *title_top_spacing - title_bottom_spacing); - return *title_top_spacing + *title_thickness + title_bottom_spacing; -} - -void ConstrainedWindowFrameView::PaintFrameBorder(gfx::Canvas* canvas) { - SkBitmap* top_left_corner = resources_->GetPartBitmap(FRAME_TOP_LEFT_CORNER); - SkBitmap* top_right_corner = - resources_->GetPartBitmap(FRAME_TOP_RIGHT_CORNER); - SkBitmap* top_edge = resources_->GetPartBitmap(FRAME_TOP_EDGE); - SkBitmap* right_edge = resources_->GetPartBitmap(FRAME_RIGHT_EDGE); - SkBitmap* left_edge = resources_->GetPartBitmap(FRAME_LEFT_EDGE); - SkBitmap* bottom_left_corner = - resources_->GetPartBitmap(FRAME_BOTTOM_LEFT_CORNER); - SkBitmap* bottom_right_corner = - resources_->GetPartBitmap(FRAME_BOTTOM_RIGHT_CORNER); - SkBitmap* bottom_edge = resources_->GetPartBitmap(FRAME_BOTTOM_EDGE); - - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - SkBitmap* theme_frame = rb.GetBitmapNamed(IDR_THEME_FRAME); - SkColor frame_color = ResourceBundle::frame_color; - - // Fill with the frame color first so we have a constant background for - // areas not covered by the theme image. - canvas->FillRectInt(frame_color, 0, 0, width(), theme_frame->height()); - // Now fill down the sides - canvas->FillRectInt(frame_color, - 0, theme_frame->height(), - left_edge->width(), height() - theme_frame->height()); - canvas->FillRectInt(frame_color, - width() - right_edge->width(), theme_frame->height(), - right_edge->width(), height() - theme_frame->height()); - // Now fill the bottom area. - canvas->FillRectInt(frame_color, - left_edge->width(), height() - bottom_edge->height(), - width() - left_edge->width() - right_edge->width(), - bottom_edge->height()); - - // Draw the theme frame. - canvas->TileImageInt(*theme_frame, 0, 0, width(), theme_frame->height()); - - // Top. - canvas->DrawBitmapInt(*top_left_corner, 0, 0); - canvas->TileImageInt(*top_edge, top_left_corner->width(), 0, - width() - top_right_corner->width(), top_edge->height()); - canvas->DrawBitmapInt(*top_right_corner, - width() - top_right_corner->width(), 0); - - // Right. - canvas->TileImageInt(*right_edge, width() - right_edge->width(), - top_right_corner->height(), right_edge->width(), - height() - top_right_corner->height() - - bottom_right_corner->height()); - - // Bottom. - canvas->DrawBitmapInt(*bottom_right_corner, - width() - bottom_right_corner->width(), - height() - bottom_right_corner->height()); - canvas->TileImageInt(*bottom_edge, bottom_left_corner->width(), - height() - bottom_edge->height(), - width() - bottom_left_corner->width() - - bottom_right_corner->width(), - bottom_edge->height()); - canvas->DrawBitmapInt(*bottom_left_corner, 0, - height() - bottom_left_corner->height()); - - // Left. - canvas->TileImageInt(*left_edge, 0, top_left_corner->height(), - left_edge->width(), - height() - top_left_corner->height() - bottom_left_corner->height()); -} - -void ConstrainedWindowFrameView::PaintTitleBar(gfx::Canvas* canvas) { - canvas->DrawStringInt(container_->GetWindowTitle(), *title_font_, - GetTitleColor(), MirroredLeftPointForRect(title_bounds_), - title_bounds_.y(), title_bounds_.width(), title_bounds_.height()); -} - -void ConstrainedWindowFrameView::PaintClientEdge(gfx::Canvas* canvas) { - gfx::Rect client_edge_bounds(CalculateClientAreaBounds(width(), height())); - client_edge_bounds.Inset(-kClientEdgeThickness, -kClientEdgeThickness); - gfx::Rect frame_shadow_bounds(client_edge_bounds); - frame_shadow_bounds.Inset(-kFrameShadowThickness, -kFrameShadowThickness); - - canvas->FillRectInt(kContentsBorderShadow, frame_shadow_bounds.x(), - frame_shadow_bounds.y(), frame_shadow_bounds.width(), - frame_shadow_bounds.height()); - - canvas->FillRectInt(ResourceBundle::toolbar_color, client_edge_bounds.x(), - client_edge_bounds.y(), client_edge_bounds.width(), - client_edge_bounds.height()); -} - -void ConstrainedWindowFrameView::LayoutWindowControls() { - gfx::Size close_button_size = close_button_->GetPreferredSize(); - close_button_->SetBounds( - width() - close_button_size.width() - FrameBorderThickness(), - kCaptionTopSpacing, close_button_size.width(), - close_button_size.height()); -} - -void ConstrainedWindowFrameView::LayoutTitleBar() { - // Size the title. - int title_x = FrameBorderThickness() + kIconLeftSpacing; - int title_top_spacing, title_thickness; - TitleCoordinates(&title_top_spacing, &title_thickness); - title_bounds_.SetRect(title_x, - title_top_spacing + ((title_thickness - title_font_->height()) / 2), - std::max(0, close_button_->x() - kTitleCaptionSpacing - title_x), - title_font_->height()); -} - -void ConstrainedWindowFrameView::LayoutClientView() { - client_view_bounds_ = CalculateClientAreaBounds(width(), height()); -} - -gfx::Rect ConstrainedWindowFrameView::CalculateClientAreaBounds( - int width, - int height) const { - int top_height = NonClientTopBorderHeight(); - int border_thickness = NonClientBorderThickness(); - return gfx::Rect(border_thickness, top_height, - std::max(0, width - (2 * border_thickness)), - std::max(0, height - top_height - border_thickness)); -} - -void ConstrainedWindowFrameView::InitWindowResources() { - if (win_util::ShouldUseVistaFrame()) { - resources_.reset(new VistaWindowResources); - } else { - resources_.reset(new XPWindowResources); - } -} - -// static -void ConstrainedWindowFrameView::InitClass() { - static bool initialized = false; - if (!initialized) { - title_font_ = new gfx::Font(win_util::GetWindowTitleFont()); - - initialized = true; - } -} - -//////////////////////////////////////////////////////////////////////////////// -// ConstrainedWindowImpl, public: - -// The space (in pixels) between minimized pop-ups stacked horizontally and -// vertically. -static const int kPopupRepositionOffset = 5; -static const int kConstrainedWindowEdgePadding = 10; - -ConstrainedWindowImpl::~ConstrainedWindowImpl() { -} - -//////////////////////////////////////////////////////////////////////////////// -// ConstrainedWindowImpl, ConstrainedWindow implementation: - -views::NonClientFrameView* ConstrainedWindowImpl::CreateFrameViewForWindow() { - return new ConstrainedWindowFrameView(this); -} - -void ConstrainedWindowImpl::CloseConstrainedWindow() { - // Broadcast to all observers of NOTIFY_CWINDOW_CLOSED. - // One example of such an observer is AutomationCWindowTracker in the - // automation component. - NotificationService::current()->Notify(NotificationType::CWINDOW_CLOSED, - Source(this), - NotificationService::NoDetails()); - - Close(); -} - -std::wstring ConstrainedWindowImpl::GetWindowTitle() const { - std::wstring display_title; - if (GetDelegate()) - display_title = GetDelegate()->GetWindowTitle(); - else - display_title = L"Untitled"; - - return display_title; -} - -const gfx::Rect& ConstrainedWindowImpl::GetCurrentBounds() const { - return current_bounds_; -} - -//////////////////////////////////////////////////////////////////////////////// -// ConstrainedWindowImpl, private: - -ConstrainedWindowImpl::ConstrainedWindowImpl( - TabContents* owner, - views::WindowDelegate* window_delegate) - : WindowWin(window_delegate), - owner_(owner) { - GetNonClientView()->SetFrameView(CreateFrameViewForWindow()); - - focus_restoration_disabled_ = false; - set_window_style(WS_CHILD | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_CAPTION | - WS_THICKFRAME | WS_SYSMENU); - set_focus_on_creation(false); - - WindowWin::Init(owner_->GetNativeView(), gfx::Rect()); - ActivateConstrainedWindow(); -} - -void ConstrainedWindowImpl::ActivateConstrainedWindow() { - // Other pop-ups are simply moved to the front of the z-order. - SetWindowPos(HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); -} - -//////////////////////////////////////////////////////////////////////////////// -// ConstrainedWindowImpl, views::WidgetWin overrides: - -void ConstrainedWindowImpl::OnDestroy() { - // TODO(jcampan): figure out focus restoration - - // Make sure we call super so that it can do its cleanup. - WindowWin::OnDestroy(); -} - -void ConstrainedWindowImpl::OnFinalMessage(HWND window) { - // Tell our constraining TabContents that we've gone so it can update its - // list. - owner_->WillClose(this); - - WindowWin::OnFinalMessage(window); -} - -LRESULT ConstrainedWindowImpl::OnMouseActivate(HWND window, - UINT hittest_code, - UINT message) { - // We only detach the window if the user clicked on the title bar. That - // way, users can click inside the contents of legitimate popups obtained - // with a mouse gesture. - if (hittest_code != HTCLIENT && hittest_code != HTNOWHERE && - hittest_code != HTCLOSE) { - ActivateConstrainedWindow(); - } - - return MA_ACTIVATE; -} - -void ConstrainedWindowImpl::OnWindowPosChanged(WINDOWPOS* window_pos) { - // If the window was moved or sized, tell the owner. - if (!(window_pos->flags & SWP_NOMOVE) || !(window_pos->flags & SWP_NOSIZE)) - owner_->DidMoveOrResize(this); - SetMsgHandled(FALSE); -} - - -// static -ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog( - TabContents* parent, - views::WindowDelegate* window_delegate) { - ConstrainedWindowImpl* window = new ConstrainedWindowImpl(parent, - window_delegate); - return window; -} diff --git a/chrome/browser/views/download_started_animation_win.cc b/chrome/browser/views/download_started_animation_win.cc index ec71683..4de387e 100644 --- a/chrome/browser/views/download_started_animation_win.cc +++ b/chrome/browser/views/download_started_animation_win.cc @@ -106,7 +106,7 @@ DownloadStartedAnimationWin::DownloadStartedAnimationWin( popup_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW | WS_EX_TRANSPARENT); popup_->SetOpacity(0x00); - popup_->Init(tab_contents_->GetNativeView(), rc); + popup_->Init(tab_contents_->GetNativeView(), rc, false); popup_->SetContentsView(this); Reposition(); popup_->Show(); diff --git a/chrome/browser/views/find_bar_win.cc b/chrome/browser/views/find_bar_win.cc index 4272ef7..51e1b20 100644 --- a/chrome/browser/views/find_bar_win.cc +++ b/chrome/browser/views/find_bar_win.cc @@ -95,13 +95,12 @@ FindBarWin::FindBarWin(BrowserView* browser_view) // Initialize the host. host_.reset(new Host(this)); - host_->Init(browser_view->GetWidget()->GetNativeView(), gfx::Rect()); + host_->Init(browser_view->GetWidget()->GetNativeView(), gfx::Rect(), false); host_->SetContentsView(view_); // Start listening to focus changes, so we can register and unregister our // own handler for Escape. - focus_manager_ = - views::FocusManager::GetFocusManagerForNativeView(host_->GetNativeView()); + focus_manager_ = views::FocusManager::GetFocusManager(host_->GetNativeView()); focus_manager_->AddFocusChangeListener(this); // Stores the currently focused view, and tracks focus changes so that we can diff --git a/chrome/browser/views/find_bar_win_browsertest.cc b/chrome/browser/views/find_bar_win_browsertest.cc index cf55acf..67b05ad 100644 --- a/chrome/browser/views/find_bar_win_browsertest.cc +++ b/chrome/browser/views/find_bar_win_browsertest.cc @@ -557,9 +557,8 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, AcceleratorRestoring) { GURL url = server->TestServerPageW(kSimplePage); ui_test_utils::NavigateToURL(browser(), url); - gfx::NativeView browser_view = browser()->window()->GetNativeHandle(); - views::FocusManager* focus_manager = - views::FocusManager::GetFocusManagerForNativeView(browser_view); + views::FocusManager* focus_manager = views::FocusManager::GetFocusManager( + browser()->window()->GetNativeHandle()); // See where Escape is registered. views::Accelerator escape(VK_ESCAPE, false, false, false); diff --git a/chrome/browser/views/first_run_bubble.cc b/chrome/browser/views/first_run_bubble.cc index b79c665..ba8edb2 100644 --- a/chrome/browser/views/first_run_bubble.cc +++ b/chrome/browser/views/first_run_bubble.cc @@ -343,7 +343,9 @@ void FirstRunBubble::InfoBubbleClosing(InfoBubble* info_bubble, if (!IsWindowEnabled(GetParent())) ::EnableWindow(GetParent(), true); enable_window_method_factory_.RevokeAll(); - GetFocusManager()->RemoveFocusChangeListener(view_); + views::FocusManager* focus_manager = + views::FocusManager::GetFocusManager(GetNativeView()); + focus_manager->RemoveFocusChangeListener(view_); } // static @@ -360,7 +362,9 @@ FirstRunBubble* FirstRunBubble::Show(Profile* profile, views::Window* parent, window->set_view(view); window->Init(parent, position_relative_to, view); window->ShowWindow(SW_SHOW); - window->GetFocusManager()->AddFocusChangeListener(view); + views::FocusManager* focus_manager = + views::FocusManager::GetFocusManager(window->GetNativeView()); + focus_manager->AddFocusChangeListener(view); view->BubbleShown(); return window; } diff --git a/chrome/browser/views/fullscreen_exit_bubble.cc b/chrome/browser/views/fullscreen_exit_bubble.cc index 907a791..854c3dd 100644 --- a/chrome/browser/views/fullscreen_exit_bubble.cc +++ b/chrome/browser/views/fullscreen_exit_bubble.cc @@ -144,7 +144,7 @@ FullscreenExitBubble::FullscreenExitBubble( popup_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW | l10n_util::GetExtendedTooltipStyles()); popup_->SetOpacity(static_cast(0xff * kOpacity)); - popup_->Init(frame->GetNativeView(), GetPopupRect(false)); + popup_->Init(frame->GetNativeView(), GetPopupRect(false), false); popup_->SetContentsView(view_); popup_->Show(); // This does not activate the popup. diff --git a/chrome/browser/views/info_bubble.cc b/chrome/browser/views/info_bubble.cc index 031caaf..908aa54 100644 --- a/chrome/browser/views/info_bubble.cc +++ b/chrome/browser/views/info_bubble.cc @@ -133,7 +133,7 @@ void InfoBubble::Init(views::Window* parent, content_view_->CalculateWindowBoundsAndAjust(position_relative_to); #if defined(OS_WIN) - WidgetWin::Init(parent->GetNativeWindow(), bounds); + WidgetWin::Init(parent->GetNativeWindow(), bounds, true); #else WidgetGtk::Init(GTK_WIDGET(parent->GetNativeWindow()), bounds, true); #endif @@ -155,9 +155,11 @@ void InfoBubble::Init(views::Window* parent, #if defined(OS_WIN) // Register the Escape accelerator for closing. - GetFocusManager()->RegisterAccelerator(views::Accelerator(VK_ESCAPE, false, - false, false), - this); + views::FocusManager* focus_manager = + views::FocusManager::GetFocusManager(GetNativeView()); + focus_manager->RegisterAccelerator(views::Accelerator(VK_ESCAPE, false, + false, false), + this); // Set initial alpha value of the layered window. SetLayeredWindowAttributes(GetNativeView(), RGB(0xFF, 0xFF, 0xFF), diff --git a/chrome/browser/views/infobars/infobars.cc b/chrome/browser/views/infobars/infobars.cc index 3e19bf7..12fe42e 100644 --- a/chrome/browser/views/infobars/infobars.cc +++ b/chrome/browser/views/infobars/infobars.cc @@ -207,8 +207,9 @@ void InfoBar::InfoBarAdded() { // focus so that we can restore focus when we're removed. views::Widget* widget = GetWidget(); if (widget) { - focus_tracker_.reset(new views::ExternalFocusTracker(this, - GetFocusManager())); + focus_tracker_.reset( + new views::ExternalFocusTracker(this, + views::FocusManager::GetFocusManager(widget->GetNativeView()))); } #endif } diff --git a/chrome/browser/views/shelf_item_dialog.cc b/chrome/browser/views/shelf_item_dialog.cc index 12868f6..ade3be7 100644 --- a/chrome/browser/views/shelf_item_dialog.cc +++ b/chrome/browser/views/shelf_item_dialog.cc @@ -476,7 +476,8 @@ bool ShelfItemDialog::AcceleratorPressed( if (accelerator.GetKeyCode() == VK_ESCAPE) { window()->Close(); } else if (accelerator.GetKeyCode() == VK_RETURN) { - views::FocusManager* fm = GetFocusManager(); + views::FocusManager* fm = views::FocusManager::GetFocusManager( + GetWidget()->GetNativeView()); if (fm->GetFocusedView() == url_table_) { // Return on table behaves like a double click. OnDoubleClick(); diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc index 76c3ab9..49462bf 100644 --- a/chrome/browser/views/status_bubble_views.cc +++ b/chrome/browser/views/status_bubble_views.cc @@ -481,7 +481,7 @@ void StatusBubbleViews::Init() { WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles()); popup->SetOpacity(0x00); - popup->Init(frame_->GetNativeView(), gfx::Rect()); + popup->Init(frame_->GetNativeView(), gfx::Rect(), false); popup->SetContentsView(view_); Reposition(); popup->Show(); diff --git a/chrome/browser/views/tab_contents/tab_contents_view_win.cc b/chrome/browser/views/tab_contents/tab_contents_view_win.cc index 2080cff..1b7fa80 100755 --- a/chrome/browser/views/tab_contents/tab_contents_view_win.cc +++ b/chrome/browser/views/tab_contents/tab_contents_view_win.cc @@ -73,7 +73,7 @@ void TabContentsViewWin::CreateView() { // Since we create these windows parented to the desktop window initially, we // don't want to create them initially visible. set_window_style(WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS); - WidgetWin::Init(GetDesktopWindow(), gfx::Rect()); + WidgetWin::Init(GetDesktopWindow(), gfx::Rect(), false); // Remove the root view drop target so we can register our own. RevokeDragDrop(GetNativeView()); @@ -233,7 +233,7 @@ void TabContentsViewWin::SizeContents(const gfx::Size& size) { void TabContentsViewWin::Focus() { views::FocusManager* focus_manager = - views::FocusManager::GetFocusManagerForNativeView(GetNativeView()); + views::FocusManager::GetFocusManager(GetNativeView()); if (tab_contents()->interstitial_page()) { tab_contents()->interstitial_page()->Focus(); @@ -269,7 +269,7 @@ void TabContentsViewWin::StoreFocus() { view_storage->RemoveView(last_focused_view_storage_id_); views::FocusManager* focus_manager = - views::FocusManager::GetFocusManagerForNativeView(GetNativeView()); + views::FocusManager::GetFocusManager(GetNativeView()); if (focus_manager) { // |focus_manager| can be NULL if the tab has been detached but still // exists. @@ -301,7 +301,7 @@ void TabContentsViewWin::RestoreFocus() { SetInitialFocus(); } else { views::FocusManager* focus_manager = - views::FocusManager::GetFocusManagerForNativeView(GetNativeView()); + views::FocusManager::GetFocusManager(GetNativeView()); // If you hit this DCHECK, please report it to Jay (jcampan). DCHECK(focus_manager != NULL) << "No focus manager when restoring focus."; @@ -333,7 +333,7 @@ void TabContentsViewWin::GotFocus() { void TabContentsViewWin::TakeFocus(bool reverse) { if (!tab_contents()->delegate()->TakeFocus(reverse)) { views::FocusManager* focus_manager = - views::FocusManager::GetFocusManagerForNativeView(GetNativeView()); + views::FocusManager::GetFocusManager(GetNativeView()); // We may not have a focus manager if the tab has been switched before this // message arrived. @@ -357,7 +357,7 @@ void TabContentsViewWin::HandleKeyboardEvent( // a keyboard shortcut that we have to process. if (event.type == WebInputEvent::RawKeyDown) { views::FocusManager* focus_manager = - views::FocusManager::GetFocusManagerForNativeView(GetNativeView()); + views::FocusManager::GetFocusManager(GetNativeView()); // We may not have a focus_manager at this point (if the tab has been // switched by the time this message returned). if (focus_manager) { diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc index adf7903..b4fea1d 100644 --- a/chrome/browser/views/tabs/dragged_tab_controller.cc +++ b/chrome/browser/views/tabs/dragged_tab_controller.cc @@ -198,7 +198,7 @@ class DraggedTabController::DockDisplayer : public AnimationDelegate { popup->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW | WS_EX_TOPMOST); popup->SetOpacity(0x00); - popup->Init(NULL, info.GetPopupRect()); + popup->Init(NULL, info.GetPopupRect(), false); popup->SetContentsView(new DockView(info.type())); if (info.in_enable_area()) animation_.Reset(1); diff --git a/chrome/browser/views/tabs/dragged_tab_view.cc b/chrome/browser/views/tabs/dragged_tab_view.cc index b77ace5..f3101d9 100644 --- a/chrome/browser/views/tabs/dragged_tab_view.cc +++ b/chrome/browser/views/tabs/dragged_tab_view.cc @@ -48,7 +48,7 @@ DraggedTabView::DraggedTabView(TabContents* datasource, container_->set_window_ex_style( WS_EX_LAYERED | WS_EX_TOPMOST | WS_EX_TOOLWINDOW); container_->set_can_update_layered_window(false); - container_->Init(NULL, gfx::Rect(0, 0, 0, 0)); + container_->Init(NULL, gfx::Rect(0, 0, 0, 0), false); container_->SetContentsView(this); BOOL drag; diff --git a/chrome/browser/views/tabs/native_view_photobooth_win.cc b/chrome/browser/views/tabs/native_view_photobooth_win.cc index 6f78ea9..430e009 100644 --- a/chrome/browser/views/tabs/native_view_photobooth_win.cc +++ b/chrome/browser/views/tabs/native_view_photobooth_win.cc @@ -155,7 +155,7 @@ void NativeViewPhotoboothWin::CreateCaptureWindow(HWND initial_hwnd) { // WS_EX_TOOLWINDOW ensures the capture window doesn't produce a Taskbar // button. capture_window_->set_window_ex_style(WS_EX_LAYERED | WS_EX_TOOLWINDOW); - capture_window_->Init(NULL, capture_bounds); + capture_window_->Init(NULL, capture_bounds, false); // If the capture window isn't visible, blitting from the TabContents' // HWND's DC to the capture bitmap produces blankness. capture_window_->Show(); diff --git a/chrome/browser/views/tabs/tab_strip.cc b/chrome/browser/views/tabs/tab_strip.cc index b5f0aae..d669be3 100644 --- a/chrome/browser/views/tabs/tab_strip.cc +++ b/chrome/browser/views/tabs/tab_strip.cc @@ -1382,7 +1382,8 @@ TabStrip::DropInfo::DropInfo(int drop_index, bool drop_before, bool point_down) arrow_window->Init( NULL, - gfx::Rect(0, 0, drop_indicator_width, drop_indicator_height)); + gfx::Rect(0, 0, drop_indicator_width, drop_indicator_height), + true); arrow_window->SetContentsView(arrow_view); #else NOTIMPLEMENTED(); -- cgit v1.1