Chromium Code Reviews| 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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. | 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. |
| 6 | 6 |
| 7 #include "ui/views/view.h" | 7 #include "ui/views/view.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cmath> | 10 #include <cmath> |
| (...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 814 // been set. Note that the X (or left) position we pass to ClipRect takes | 814 // been set. Note that the X (or left) position we pass to ClipRect takes |
| 815 // into consideration whether or not the View uses a right-to-left layout so | 815 // into consideration whether or not the View uses a right-to-left layout so |
| 816 // that we paint the View in its mirrored position if need be. | 816 // that we paint the View in its mirrored position if need be. |
| 817 if (clip_path_.isEmpty()) { | 817 if (clip_path_.isEmpty()) { |
| 818 clip_recorder.ClipRect(GetMirroredBounds()); | 818 clip_recorder.ClipRect(GetMirroredBounds()); |
| 819 } else { | 819 } else { |
| 820 gfx::Path clip_path_in_parent = clip_path_; | 820 gfx::Path clip_path_in_parent = clip_path_; |
| 821 clip_path_in_parent.offset(GetMirroredX(), y()); | 821 clip_path_in_parent.offset(GetMirroredX(), y()); |
| 822 clip_recorder.ClipPathWithAntiAliasing(clip_path_in_parent); | 822 clip_recorder.ClipPathWithAntiAliasing(clip_path_in_parent); |
| 823 } | 823 } |
| 824 } else { | |
| 825 DCHECK(layer()); | |
| 826 clip_recorder.ClipRect(GetVisibleBounds()); | |
|
sky
2016/11/29 18:08:13
Is this really enough? What happens if an animatio
Evan Stade
2016/11/29 18:38:01
when the layer is moved that affects the view's tr
sky
2016/11/29 20:27:09
That's assuming you end up here, right? If the lay
| |
| 824 } | 827 } |
| 825 | 828 |
| 826 ui::TransformRecorder transform_recorder(context); | 829 ui::TransformRecorder transform_recorder(context); |
| 827 if (paint_relative_to_parent) { | 830 if (paint_relative_to_parent) { |
| 828 // Translate the graphics such that 0,0 corresponds to where | 831 // Translate the graphics such that 0,0 corresponds to where |
| 829 // this View is located relative to its parent. | 832 // this View is located relative to its parent. |
| 830 gfx::Transform transform_from_parent; | 833 gfx::Transform transform_from_parent; |
| 831 gfx::Vector2d offset_from_parent = GetMirroredPosition().OffsetFromOrigin(); | 834 gfx::Vector2d offset_from_parent = GetMirroredPosition().OffsetFromOrigin(); |
| 832 transform_from_parent.Translate(offset_from_parent.x(), | 835 transform_from_parent.Translate(offset_from_parent.x(), |
| 833 offset_from_parent.y()); | 836 offset_from_parent.y()); |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1372 void View::OnBoundsChanged(const gfx::Rect& previous_bounds) { | 1375 void View::OnBoundsChanged(const gfx::Rect& previous_bounds) { |
| 1373 } | 1376 } |
| 1374 | 1377 |
| 1375 void View::PreferredSizeChanged() { | 1378 void View::PreferredSizeChanged() { |
| 1376 InvalidateLayout(); | 1379 InvalidateLayout(); |
| 1377 if (parent_) | 1380 if (parent_) |
| 1378 parent_->ChildPreferredSizeChanged(this); | 1381 parent_->ChildPreferredSizeChanged(this); |
| 1379 } | 1382 } |
| 1380 | 1383 |
| 1381 bool View::GetNeedsNotificationWhenVisibleBoundsChange() const { | 1384 bool View::GetNeedsNotificationWhenVisibleBoundsChange() const { |
| 1382 return false; | 1385 return true; |
| 1383 } | 1386 } |
| 1384 | 1387 |
| 1385 void View::OnVisibleBoundsChanged() { | 1388 void View::OnVisibleBoundsChanged() { |
| 1389 if (layer()) | |
| 1390 SchedulePaint(); | |
| 1386 } | 1391 } |
| 1387 | 1392 |
| 1388 // Tree operations ------------------------------------------------------------- | 1393 // Tree operations ------------------------------------------------------------- |
| 1389 | 1394 |
| 1390 void View::ViewHierarchyChanged(const ViewHierarchyChangedDetails& details) { | 1395 void View::ViewHierarchyChanged(const ViewHierarchyChangedDetails& details) { |
| 1391 } | 1396 } |
| 1392 | 1397 |
| 1393 void View::VisibilityChanged(View* starting_from, bool is_visible) { | 1398 void View::VisibilityChanged(View* starting_from, bool is_visible) { |
| 1394 } | 1399 } |
| 1395 | 1400 |
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2415 // Message the RootView to do the drag and drop. That way if we're removed | 2420 // Message the RootView to do the drag and drop. That way if we're removed |
| 2416 // the RootView can detect it and avoid calling us back. | 2421 // the RootView can detect it and avoid calling us back. |
| 2417 gfx::Point widget_location(event.location()); | 2422 gfx::Point widget_location(event.location()); |
| 2418 ConvertPointToWidget(this, &widget_location); | 2423 ConvertPointToWidget(this, &widget_location); |
| 2419 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2424 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
| 2420 // WARNING: we may have been deleted. | 2425 // WARNING: we may have been deleted. |
| 2421 return true; | 2426 return true; |
| 2422 } | 2427 } |
| 2423 | 2428 |
| 2424 } // namespace views | 2429 } // namespace views |
| OLD | NEW |