| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/non_client_view.h" | 5 #include "ui/views/window/non_client_view.h" |
| 6 | 6 |
| 7 #include "ui/base/accessibility/accessible_view_state.h" | 7 #include "ui/base/accessibility/accessible_view_state.h" |
| 8 #include "ui/base/hit_test.h" | 8 #include "ui/base/hit_test.h" |
| 9 #include "ui/views/widget/root_view.h" | 9 #include "ui/views/widget/root_view.h" |
| 10 #include "ui/views/widget/widget.h" | 10 #include "ui/views/widget/widget.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 | 181 |
| 182 void NonClientView::GetAccessibleState(ui::AccessibleViewState* state) { | 182 void NonClientView::GetAccessibleState(ui::AccessibleViewState* state) { |
| 183 state->role = ui::AccessibilityTypes::ROLE_CLIENT; | 183 state->role = ui::AccessibilityTypes::ROLE_CLIENT; |
| 184 state->name = accessible_name_; | 184 state->name = accessible_name_; |
| 185 } | 185 } |
| 186 | 186 |
| 187 const char* NonClientView::GetClassName() const { | 187 const char* NonClientView::GetClassName() const { |
| 188 return kViewClassName; | 188 return kViewClassName; |
| 189 } | 189 } |
| 190 | 190 |
| 191 views::View* NonClientView::GetEventHandlerForPoint(const gfx::Point& point) { | 191 views::View* NonClientView::GetEventHandlerForRect(const gfx::Rect& rect) { |
| 192 if (!View::UsePointBasedTargeting(rect)) |
| 193 return View::GetEventHandlerForRect(rect); |
| 194 |
| 192 // Because of the z-ordering of our child views (the client view is positioned | 195 // Because of the z-ordering of our child views (the client view is positioned |
| 193 // over the non-client frame view, if the client view ever overlaps the frame | 196 // over the non-client frame view, if the client view ever overlaps the frame |
| 194 // view visually (as it does for the browser window), then it will eat mouse | 197 // view visually (as it does for the browser window), then it will eat |
| 195 // events for the window controls. We override this method here so that we can | 198 // events for the window controls. We override this method here so that we can |
| 196 // detect this condition and re-route the events to the non-client frame view. | 199 // detect this condition and re-route the events to the non-client frame view. |
| 197 // The assumption is that the frame view's implementation of HitTest will only | 200 // The assumption is that the frame view's implementation of HitTest will only |
| 198 // return true for area not occupied by the client view. | 201 // return true for area not occupied by the client view. |
| 199 if (frame_view_->parent() == this) { | 202 if (frame_view_->parent() == this) { |
| 200 // During the reset of the frame_view_ it's possible to be in this code | 203 // During the reset of the frame_view_ it's possible to be in this code |
| 201 // after it's been removed from the view hierarchy but before it's been | 204 // after it's been removed from the view hierarchy but before it's been |
| 202 // removed from the NonClientView. | 205 // removed from the NonClientView. |
| 203 gfx::Point point_in_child_coords(point); | 206 gfx::Rect rect_in_child_coords(rect); |
| 204 View::ConvertPointToTarget(this, frame_view_.get(), &point_in_child_coords); | 207 View::ConvertRectToTarget(this, frame_view_.get(), &rect_in_child_coords); |
| 205 if (frame_view_->HitTestPoint(point_in_child_coords)) | 208 if (frame_view_->HitTestRect(rect_in_child_coords)) |
| 206 return frame_view_->GetEventHandlerForPoint(point_in_child_coords); | 209 return frame_view_->GetEventHandlerForRect(rect_in_child_coords); |
| 207 } | 210 } |
| 208 | 211 |
| 209 return View::GetEventHandlerForPoint(point); | 212 return View::GetEventHandlerForRect(rect); |
| 210 } | 213 } |
| 211 | 214 |
| 212 views::View* NonClientView::GetTooltipHandlerForPoint(const gfx::Point& point) { | 215 views::View* NonClientView::GetTooltipHandlerForPoint(const gfx::Point& point) { |
| 213 // The same logic as for |GetEventHandlerForPoint()| applies here. | 216 // The same logic as for |GetEventHandlerForRect()| applies here. |
| 214 if (frame_view_->parent() == this) { | 217 if (frame_view_->parent() == this) { |
| 215 // During the reset of the frame_view_ it's possible to be in this code | 218 // During the reset of the frame_view_ it's possible to be in this code |
| 216 // after it's been removed from the view hierarchy but before it's been | 219 // after it's been removed from the view hierarchy but before it's been |
| 217 // removed from the NonClientView. | 220 // removed from the NonClientView. |
| 218 gfx::Point point_in_child_coords(point); | 221 gfx::Point point_in_child_coords(point); |
| 219 View::ConvertPointToTarget(this, frame_view_.get(), &point_in_child_coords); | 222 View::ConvertPointToTarget(this, frame_view_.get(), &point_in_child_coords); |
| 220 views::View* handler = | 223 views::View* handler = |
| 221 frame_view_->GetTooltipHandlerForPoint(point_in_child_coords); | 224 frame_view_->GetTooltipHandlerForPoint(point_in_child_coords); |
| 222 if (handler) | 225 if (handler) |
| 223 return handler; | 226 return handler; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 const char* NonClientFrameView::GetClassName() const { | 316 const char* NonClientFrameView::GetClassName() const { |
| 314 return kViewClassName; | 317 return kViewClassName; |
| 315 } | 318 } |
| 316 | 319 |
| 317 void NonClientFrameView::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 320 void NonClientFrameView::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 318 // Overridden to do nothing. The NonClientView manually calls Layout on the | 321 // Overridden to do nothing. The NonClientView manually calls Layout on the |
| 319 // FrameView when it is itself laid out, see comment in NonClientView::Layout. | 322 // FrameView when it is itself laid out, see comment in NonClientView::Layout. |
| 320 } | 323 } |
| 321 | 324 |
| 322 } // namespace views | 325 } // namespace views |
| OLD | NEW |