Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/window/native_frame_view.h" | 5 #include "ui/views/window/native_frame_view.h" |
| 6 | 6 |
| 7 #include "ui/views/widget/native_widget.h" | 7 #include "ui/views/widget/native_widget.h" |
| 8 #include "ui/views/widget/widget.h" | 8 #include "ui/views/widget/widget.h" |
| 9 | 9 |
| 10 #if defined(OS_WIN) | 10 #if defined(OS_WIN) |
| 11 #include "ui/views/win/hwnd_util.h" | 11 #include "ui/views/win/hwnd_util.h" |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 namespace views { | 14 namespace views { |
| 15 | 15 |
| 16 //////////////////////////////////////////////////////////////////////////////// | 16 //////////////////////////////////////////////////////////////////////////////// |
| 17 // NativeFrameView, public: | 17 // NativeFrameView, public: |
| 18 | 18 |
| 19 // static | |
| 20 const char NativeFrameView::kViewClassName[] = "NativeFrameView"; | |
| 21 | |
| 19 NativeFrameView::NativeFrameView(Widget* frame) | 22 NativeFrameView::NativeFrameView(Widget* frame) |
| 20 : NonClientFrameView(), | 23 : NonClientFrameView(), |
| 21 frame_(frame) { | 24 frame_(frame) { |
| 22 } | 25 } |
| 23 | 26 |
| 24 NativeFrameView::~NativeFrameView() { | 27 NativeFrameView::~NativeFrameView() { |
| 25 } | 28 } |
| 26 | 29 |
| 27 //////////////////////////////////////////////////////////////////////////////// | 30 //////////////////////////////////////////////////////////////////////////////// |
| 28 // NativeFrameView, NonClientFrameView overrides: | 31 // NativeFrameView, NonClientFrameView overrides: |
| 29 | 32 |
| 30 gfx::Rect NativeFrameView::GetBoundsForClientView() const { | 33 gfx::Rect NativeFrameView::GetBoundsForClientView() const { |
| 31 return gfx::Rect(0, 0, width(), height()); | 34 return gfx::Rect(0, 0, width(), height()); |
| 32 } | 35 } |
| 33 | 36 |
| 34 gfx::Rect NativeFrameView::GetWindowBoundsForClientBounds( | 37 gfx::Rect NativeFrameView::GetWindowBoundsForClientBounds( |
| 35 const gfx::Rect& client_bounds) const { | 38 const gfx::Rect& client_bounds) const { |
| 36 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
| 37 return views::GetWindowBoundsForClientBounds( | 40 return views::GetWindowBoundsForClientBounds( |
| 38 static_cast<View*>(const_cast<NativeFrameView*>(this)), client_bounds); | 41 static_cast<View*>(const_cast<NativeFrameView*>(this)), client_bounds); |
| 39 #else | 42 #else |
| 40 // TODO(sad): | 43 // Enforce minimum size (1, 1) in case that |client_bounds| is passed with |
| 41 return client_bounds; | 44 // empty size. |
| 45 gfx::Rect window_bounds = client_bounds; | |
| 46 if (window_bounds.IsEmpty()) { | |
| 47 window_bounds.set_width(1); | |
| 48 window_bounds.set_height(1); | |
|
Matt Giuca
2014/05/14 06:16:38
Optional suggestion: window_bounds.set_size(gfx::S
| |
| 49 } | |
| 50 return window_bounds; | |
| 42 #endif | 51 #endif |
| 43 } | 52 } |
| 44 | 53 |
| 45 int NativeFrameView::NonClientHitTest(const gfx::Point& point) { | 54 int NativeFrameView::NonClientHitTest(const gfx::Point& point) { |
| 46 return frame_->client_view()->NonClientHitTest(point); | 55 return frame_->client_view()->NonClientHitTest(point); |
| 47 } | 56 } |
| 48 | 57 |
| 49 void NativeFrameView::GetWindowMask(const gfx::Size& size, | 58 void NativeFrameView::GetWindowMask(const gfx::Size& size, |
| 50 gfx::Path* window_mask) { | 59 gfx::Path* window_mask) { |
| 51 // Nothing to do, we use the default window mask. | 60 // Nothing to do, we use the default window mask. |
| 52 } | 61 } |
| 53 | 62 |
| 54 void NativeFrameView::ResetWindowControls() { | 63 void NativeFrameView::ResetWindowControls() { |
| 55 // Nothing to do. | 64 // Nothing to do. |
| 56 } | 65 } |
| 57 | 66 |
| 58 void NativeFrameView::UpdateWindowIcon() { | 67 void NativeFrameView::UpdateWindowIcon() { |
| 59 // Nothing to do. | 68 // Nothing to do. |
| 60 } | 69 } |
| 61 | 70 |
| 62 void NativeFrameView::UpdateWindowTitle() { | 71 void NativeFrameView::UpdateWindowTitle() { |
| 63 // Nothing to do. | 72 // Nothing to do. |
| 64 } | 73 } |
| 65 | 74 |
| 66 // Returns the client size. On Windows, this is the expected behavior for | |
| 67 // native frames (see |NativeWidgetWin::WidgetSizeIsClientSize()|), while other | |
| 68 // platforms currently always return client bounds from | |
| 69 // |GetWindowBoundsForClientBounds()|. | |
| 70 gfx::Size NativeFrameView::GetPreferredSize() { | 75 gfx::Size NativeFrameView::GetPreferredSize() { |
| 71 return frame_->client_view()->GetPreferredSize(); | 76 gfx::Size client_preferred_size = frame_->client_view()->GetPreferredSize(); |
| 77 #if defined(OS_WIN) | |
| 78 // Returns the client size. On Windows, this is the expected behavior for | |
| 79 // native frames (see |NativeWidgetWin::WidgetSizeIsClientSize()|), while | |
| 80 // other platforms currently always return client bounds from | |
| 81 // |GetWindowBoundsForClientBounds()|. | |
| 82 return client_preferred_size; | |
| 83 #else | |
| 84 return frame_->non_client_view()->GetWindowBoundsForClientBounds( | |
| 85 gfx::Rect(client_preferred_size)).size(); | |
| 86 #endif | |
| 72 } | 87 } |
| 73 | 88 |
| 74 gfx::Size NativeFrameView::GetMinimumSize() { | 89 gfx::Size NativeFrameView::GetMinimumSize() { |
| 75 return frame_->client_view()->GetMinimumSize(); | 90 return frame_->client_view()->GetMinimumSize(); |
| 76 } | 91 } |
| 77 | 92 |
| 78 gfx::Size NativeFrameView::GetMaximumSize() { | 93 gfx::Size NativeFrameView::GetMaximumSize() { |
| 79 return frame_->client_view()->GetMaximumSize(); | 94 return frame_->client_view()->GetMaximumSize(); |
| 80 } | 95 } |
| 81 | 96 |
| 97 const char* NativeFrameView::GetClassName() const { | |
| 98 return kViewClassName; | |
| 99 } | |
| 100 | |
| 82 } // namespace views | 101 } // namespace views |
| OLD | NEW |