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 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
791 TRACE_EVENT1("views", "View::Paint", "class", GetClassName()); | 791 TRACE_EVENT1("views", "View::Paint", "class", GetClassName()); |
792 | 792 |
793 // If the view is backed by a layer, it should paint with itself as the origin | 793 // If the view is backed by a layer, it should paint with itself as the origin |
794 // rather than relative to its parent. | 794 // rather than relative to its parent. |
795 bool paint_relative_to_parent = !layer(); | 795 bool paint_relative_to_parent = !layer(); |
796 | 796 |
797 // TODO(danakj): Rework clip and transform recorder usage here to use | 797 // TODO(danakj): Rework clip and transform recorder usage here to use |
798 // std::optional once we can do so. | 798 // std::optional once we can do so. |
799 ui::ClipRecorder clip_recorder(parent_context); | 799 ui::ClipRecorder clip_recorder(parent_context); |
800 if (paint_relative_to_parent) { | 800 if (paint_relative_to_parent) { |
801 // Set the clip rect to the bounds of this View. Note that the X (or left) | 801 // If the View is a root view (has no parent) and if the window shape is |
tapted
2016/01/28 05:59:22
only-do-if-root-view logic probably belongs in vie
karandeepb
2016/02/04 03:39:28
Removed the changes in view.cc.
| |
802 // position we pass to ClipRect takes into consideration whether or not the | 802 // non-rectangular, retreive the window mask from the non-client view and |
803 // View uses a right-to-left layout so that we paint the View in its | 803 // use it as the clipping path. Else set the clip rect to the bounds of this |
804 // mirrored position if need be. | 804 // View. Note that the X (or left) position we pass to ClipRect takes into |
805 gfx::Rect clip_rect_in_parent = bounds(); | 805 // consideration whether or not the View uses a right-to-left layout so that |
806 clip_rect_in_parent.Inset(clip_insets_); | 806 // we paint the View in its mirrored position if need be. |
807 if (parent_) | 807 bool clip_set = false; |
karandeepb
2016/01/27 23:25:03
I have added this to prevent the distortion that o
tapted
2016/01/28 05:59:22
Does this fix the rounded bottom corners on the bo
karandeepb
2016/02/04 03:39:28
This didn't fix the bug on other platforms since a
| |
808 clip_rect_in_parent.set_x( | 808 if (!parent() && GetWidget()->non_client_view()) { |
809 parent_->GetMirroredXForRect(clip_rect_in_parent)); | 809 gfx::Path path; |
810 clip_recorder.ClipRect(clip_rect_in_parent); | 810 GetWidget()->non_client_view()->GetWindowMask(bounds().size(), &path); |
811 if (!path.isEmpty()) { | |
812 clip_recorder.ClipPathWithAntiAliasing(path); | |
813 clip_set = true; | |
814 } | |
815 } else if (!clip_set) { | |
tapted
2016/01/28 05:59:22
I think this is equivalent to `else` -- |clip_set|
karandeepb
2016/02/04 03:39:28
Done.
| |
816 gfx::Rect clip_rect_in_parent = bounds(); | |
817 clip_rect_in_parent.Inset(clip_insets_); | |
818 if (parent_) | |
819 clip_rect_in_parent.set_x( | |
820 parent_->GetMirroredXForRect(clip_rect_in_parent)); | |
821 clip_recorder.ClipRect(clip_rect_in_parent); | |
822 } | |
811 } | 823 } |
812 | 824 |
813 ui::TransformRecorder transform_recorder(context); | 825 ui::TransformRecorder transform_recorder(context); |
814 if (paint_relative_to_parent) { | 826 if (paint_relative_to_parent) { |
815 // Translate the graphics such that 0,0 corresponds to where | 827 // Translate the graphics such that 0,0 corresponds to where |
816 // this View is located relative to its parent. | 828 // this View is located relative to its parent. |
817 gfx::Transform transform_from_parent; | 829 gfx::Transform transform_from_parent; |
818 gfx::Vector2d offset_from_parent = GetMirroredPosition().OffsetFromOrigin(); | 830 gfx::Vector2d offset_from_parent = GetMirroredPosition().OffsetFromOrigin(); |
819 transform_from_parent.Translate(offset_from_parent.x(), | 831 transform_from_parent.Translate(offset_from_parent.x(), |
820 offset_from_parent.y()); | 832 offset_from_parent.y()); |
(...skipping 1583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2404 // Message the RootView to do the drag and drop. That way if we're removed | 2416 // Message the RootView to do the drag and drop. That way if we're removed |
2405 // the RootView can detect it and avoid calling us back. | 2417 // the RootView can detect it and avoid calling us back. |
2406 gfx::Point widget_location(event.location()); | 2418 gfx::Point widget_location(event.location()); |
2407 ConvertPointToWidget(this, &widget_location); | 2419 ConvertPointToWidget(this, &widget_location); |
2408 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2420 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2409 // WARNING: we may have been deleted. | 2421 // WARNING: we may have been deleted. |
2410 return true; | 2422 return true; |
2411 } | 2423 } |
2412 | 2424 |
2413 } // namespace views | 2425 } // namespace views |
OLD | NEW |