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 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 } | 771 } |
772 | 772 |
773 TRACE_EVENT1("views", "View::Paint", "class", GetClassName()); | 773 TRACE_EVENT1("views", "View::Paint", "class", GetClassName()); |
774 | 774 |
775 gfx::Canvas* canvas = context.canvas(); | 775 gfx::Canvas* canvas = context.canvas(); |
776 gfx::ScopedCanvas scoped_canvas(canvas); | 776 gfx::ScopedCanvas scoped_canvas(canvas); |
777 | 777 |
778 // If the view is backed by a layer, it should paint with itself as the origin | 778 // If the view is backed by a layer, it should paint with itself as the origin |
779 // rather than relative to its parent. | 779 // rather than relative to its parent. |
780 if (!layer()) { | 780 if (!layer()) { |
781 // Set the clip rect to the bounds of this View and translating the origin | 781 // Set the clip rect to the bounds of this View. Note that the X (or left) |
782 // to the local bounds' top left point. | 782 // position we pass to ClipRect takes into consideration whether or not the |
783 // | 783 // View uses a right-to-left layout so that we paint the View in its |
784 // Note that the X (or left) position we pass to ClipRectInt takes into | 784 // mirrored position if need be. |
785 // consideration whether or not the view uses a right-to-left layout so that | |
786 // we paint our view in its mirrored position if need be. | |
787 gfx::Rect clip_rect = bounds(); | 785 gfx::Rect clip_rect = bounds(); |
788 clip_rect.Inset(clip_insets_); | 786 clip_rect.Inset(clip_insets_); |
789 if (parent_) | 787 if (parent_) |
790 clip_rect.set_x(parent_->GetMirroredXForRect(clip_rect)); | 788 clip_rect.set_x(parent_->GetMirroredXForRect(clip_rect)); |
791 canvas->ClipRect(clip_rect); | 789 canvas->ClipRect(clip_rect); |
792 if (canvas->IsClipEmpty()) | |
793 return; | |
794 | 790 |
795 // Non-empty clip, translate the graphics such that 0,0 corresponds to where | 791 // Translate the graphics such that 0,0 corresponds to where |
796 // this view is located (related to its parent). | 792 // this View is located relative to its parent. |
797 canvas->Translate(GetMirroredPosition().OffsetFromOrigin()); | 793 canvas->Translate(GetMirroredPosition().OffsetFromOrigin()); |
798 canvas->Transform(GetTransform()); | 794 canvas->Transform(GetTransform()); |
799 } | 795 } |
800 | 796 |
801 { | 797 { |
802 // If the View we are about to paint requested the canvas to be flipped, we | 798 // If the View we are about to paint requested the canvas to be flipped, we |
803 // should change the transform appropriately. | 799 // should change the transform appropriately. |
804 // The canvas mirroring is undone once the View is done painting so that we | 800 // The canvas mirroring is undone once the View is done painting so that we |
805 // don't pass the canvas with the mirrored transform to Views that didn't | 801 // don't pass the canvas with the mirrored transform to Views that didn't |
806 // request the canvas to be flipped. | 802 // request the canvas to be flipped. |
(...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2358 // Message the RootView to do the drag and drop. That way if we're removed | 2354 // Message the RootView to do the drag and drop. That way if we're removed |
2359 // the RootView can detect it and avoid calling us back. | 2355 // the RootView can detect it and avoid calling us back. |
2360 gfx::Point widget_location(event.location()); | 2356 gfx::Point widget_location(event.location()); |
2361 ConvertPointToWidget(this, &widget_location); | 2357 ConvertPointToWidget(this, &widget_location); |
2362 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2358 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2363 // WARNING: we may have been deleted. | 2359 // WARNING: we may have been deleted. |
2364 return true; | 2360 return true; |
2365 } | 2361 } |
2366 | 2362 |
2367 } // namespace views | 2363 } // namespace views |
OLD | NEW |