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/view.h" | 5 #include "ui/views/view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 gfx::Rect View::GetVisibleBounds() const { | 325 gfx::Rect View::GetVisibleBounds() const { |
326 if (!IsDrawn()) | 326 if (!IsDrawn()) |
327 return gfx::Rect(); | 327 return gfx::Rect(); |
328 gfx::Rect vis_bounds(GetLocalBounds()); | 328 gfx::Rect vis_bounds(GetLocalBounds()); |
329 gfx::Rect ancestor_bounds; | 329 gfx::Rect ancestor_bounds; |
330 const View* view = this; | 330 const View* view = this; |
331 gfx::Transform transform; | 331 gfx::Transform transform; |
332 | 332 |
333 while (view != NULL && !vis_bounds.IsEmpty()) { | 333 while (view != NULL && !vis_bounds.IsEmpty()) { |
334 transform.ConcatTransform(view->GetTransform()); | 334 transform.ConcatTransform(view->GetTransform()); |
335 transform.ConcatTranslate(static_cast<float>(view->GetMirroredX()), | 335 gfx::Transform translation; |
336 static_cast<float>(view->y())); | 336 translation.Translate(static_cast<float>(view->GetMirroredX()), |
| 337 static_cast<float>(view->y())); |
| 338 transform.ConcatTransform(translation); |
337 | 339 |
338 vis_bounds = view->ConvertRectToParent(vis_bounds); | 340 vis_bounds = view->ConvertRectToParent(vis_bounds); |
339 const View* ancestor = view->parent_; | 341 const View* ancestor = view->parent_; |
340 if (ancestor != NULL) { | 342 if (ancestor != NULL) { |
341 ancestor_bounds.SetRect(0, 0, ancestor->width(), ancestor->height()); | 343 ancestor_bounds.SetRect(0, 0, ancestor->width(), ancestor->height()); |
342 vis_bounds.Intersect(ancestor_bounds); | 344 vis_bounds.Intersect(ancestor_bounds); |
343 } else if (!view->GetWidget()) { | 345 } else if (!view->GetWidget()) { |
344 // If the view has no Widget, we're not visible. Return an empty rect. | 346 // If the view has no Widget, we're not visible. Return an empty rect. |
345 return gfx::Rect(); | 347 return gfx::Rect(); |
346 } | 348 } |
(...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1791 } | 1793 } |
1792 | 1794 |
1793 // Transformations ------------------------------------------------------------- | 1795 // Transformations ------------------------------------------------------------- |
1794 | 1796 |
1795 bool View::GetTransformRelativeTo(const View* ancestor, | 1797 bool View::GetTransformRelativeTo(const View* ancestor, |
1796 gfx::Transform* transform) const { | 1798 gfx::Transform* transform) const { |
1797 const View* p = this; | 1799 const View* p = this; |
1798 | 1800 |
1799 while (p && p != ancestor) { | 1801 while (p && p != ancestor) { |
1800 transform->ConcatTransform(p->GetTransform()); | 1802 transform->ConcatTransform(p->GetTransform()); |
1801 transform->ConcatTranslate(static_cast<float>(p->GetMirroredX()), | 1803 gfx::Transform translation; |
1802 static_cast<float>(p->y())); | 1804 translation.Translate(static_cast<float>(p->GetMirroredX()), |
| 1805 static_cast<float>(p->y())); |
| 1806 transform->ConcatTransform(translation); |
1803 | 1807 |
1804 p = p->parent_; | 1808 p = p->parent_; |
1805 } | 1809 } |
1806 | 1810 |
1807 return p == ancestor; | 1811 return p == ancestor; |
1808 } | 1812 } |
1809 | 1813 |
1810 // Coordinate conversion ------------------------------------------------------- | 1814 // Coordinate conversion ------------------------------------------------------- |
1811 | 1815 |
1812 bool View::ConvertPointForAncestor(const View* ancestor, | 1816 bool View::ConvertPointForAncestor(const View* ancestor, |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 ConvertPointToWidget(this, &widget_location); | 2160 ConvertPointToWidget(this, &widget_location); |
2157 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations, | 2161 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations, |
2158 source); | 2162 source); |
2159 return true; | 2163 return true; |
2160 #else | 2164 #else |
2161 return false; | 2165 return false; |
2162 #endif // !defined(OS_MACOSX) | 2166 #endif // !defined(OS_MACOSX) |
2163 } | 2167 } |
2164 | 2168 |
2165 } // namespace views | 2169 } // namespace views |
OLD | NEW |