Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Side by Side Diff: ui/views/view.cc

Issue 1773393002: Address some bubble clipping issues (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 bool paint_relative_to_parent = !layer(); 801 bool paint_relative_to_parent = !layer();
802 802
803 // TODO(danakj): Rework clip and transform recorder usage here to use 803 // TODO(danakj): Rework clip and transform recorder usage here to use
804 // std::optional once we can do so. 804 // std::optional once we can do so.
805 ui::ClipRecorder clip_recorder(parent_context); 805 ui::ClipRecorder clip_recorder(parent_context);
806 if (paint_relative_to_parent) { 806 if (paint_relative_to_parent) {
807 // Set the clip rect to the bounds of this View. Note that the X (or left) 807 // Set the clip rect to the bounds of this View. Note that the X (or left)
808 // position we pass to ClipRect takes into consideration whether or not the 808 // position we pass to ClipRect takes into consideration whether or not the
809 // View uses a right-to-left layout so that we paint the View in its 809 // View uses a right-to-left layout so that we paint the View in its
810 // mirrored position if need be. 810 // mirrored position if need be.
811 gfx::Rect clip_rect_in_parent = bounds(); 811 gfx::Path clip_path_in_parent = clip_path_;
812 clip_rect_in_parent.Inset(clip_insets_); 812 if (clip_path_in_parent.isEmpty())
813 if (parent_) 813 clip_path_in_parent.addRect(gfx::RectToSkRect(GetLocalBounds()));
814 clip_rect_in_parent.set_x( 814 clip_path_in_parent.offset(GetMirroredX(), y());
815 parent_->GetMirroredXForRect(clip_rect_in_parent)); 815 clip_recorder.ClipPathWithAntiAliasing(clip_path_in_parent);
tapted 2016/03/22 07:38:04 I don't have a sense for how computationally expen
Evan Stade 2016/03/22 17:59:58 I was hoping it would be smart, i.e. if the path i
816 clip_recorder.ClipRect(clip_rect_in_parent);
817 } 816 }
818 817
819 ui::TransformRecorder transform_recorder(context); 818 ui::TransformRecorder transform_recorder(context);
820 if (paint_relative_to_parent) { 819 if (paint_relative_to_parent) {
821 // Translate the graphics such that 0,0 corresponds to where 820 // Translate the graphics such that 0,0 corresponds to where
822 // this View is located relative to its parent. 821 // this View is located relative to its parent.
823 gfx::Transform transform_from_parent; 822 gfx::Transform transform_from_parent;
824 gfx::Vector2d offset_from_parent = GetMirroredPosition().OffsetFromOrigin(); 823 gfx::Vector2d offset_from_parent = GetMirroredPosition().OffsetFromOrigin();
825 transform_from_parent.Translate(offset_from_parent.x(), 824 transform_from_parent.Translate(offset_from_parent.x(),
826 offset_from_parent.y()); 825 offset_from_parent.y());
(...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after
2424 // Message the RootView to do the drag and drop. That way if we're removed 2423 // Message the RootView to do the drag and drop. That way if we're removed
2425 // the RootView can detect it and avoid calling us back. 2424 // the RootView can detect it and avoid calling us back.
2426 gfx::Point widget_location(event.location()); 2425 gfx::Point widget_location(event.location());
2427 ConvertPointToWidget(this, &widget_location); 2426 ConvertPointToWidget(this, &widget_location);
2428 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2427 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2429 // WARNING: we may have been deleted. 2428 // WARNING: we may have been deleted.
2430 return true; 2429 return true;
2431 } 2430 }
2432 2431
2433 } // namespace views 2432 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698