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

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: no aa 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
« no previous file with comments | « ui/views/view.h ('k') | ui/views/window/non_client_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 TRACE_EVENT1("views", "View::Paint", "class", GetClassName()); 797 TRACE_EVENT1("views", "View::Paint", "class", GetClassName());
798 798
799 // If the view is backed by a layer, it should paint with itself as the origin 799 // If the view is backed by a layer, it should paint with itself as the origin
800 // rather than relative to its parent. 800 // rather than relative to its parent.
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, or |clip_path_| if it's
808 // position we pass to ClipRect takes into consideration whether or not the 808 // been set. Note that the X (or left) position we pass to ClipRect takes
809 // View uses a right-to-left layout so that we paint the View in its 809 // into consideration whether or not the View uses a right-to-left layout so
810 // mirrored position if need be. 810 // that we paint the View in its mirrored position if need be.
811 gfx::Rect clip_rect_in_parent = bounds(); 811 if (clip_path_.isEmpty()) {
812 clip_rect_in_parent.Inset(clip_insets_); 812 clip_recorder.ClipRect(GetMirroredBounds());
813 if (parent_) 813 } else {
814 clip_rect_in_parent.set_x( 814 gfx::Path clip_path_in_parent = clip_path_;
815 parent_->GetMirroredXForRect(clip_rect_in_parent)); 815 clip_path_in_parent.offset(GetMirroredX(), y());
816 clip_recorder.ClipRect(clip_rect_in_parent); 816 clip_recorder.ClipPath(clip_path_in_parent);
817 }
817 } 818 }
818 819
819 ui::TransformRecorder transform_recorder(context); 820 ui::TransformRecorder transform_recorder(context);
820 if (paint_relative_to_parent) { 821 if (paint_relative_to_parent) {
821 // Translate the graphics such that 0,0 corresponds to where 822 // Translate the graphics such that 0,0 corresponds to where
822 // this View is located relative to its parent. 823 // this View is located relative to its parent.
823 gfx::Transform transform_from_parent; 824 gfx::Transform transform_from_parent;
824 gfx::Vector2d offset_from_parent = GetMirroredPosition().OffsetFromOrigin(); 825 gfx::Vector2d offset_from_parent = GetMirroredPosition().OffsetFromOrigin();
825 transform_from_parent.Translate(offset_from_parent.x(), 826 transform_from_parent.Translate(offset_from_parent.x(),
826 offset_from_parent.y()); 827 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 2425 // 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. 2426 // the RootView can detect it and avoid calling us back.
2426 gfx::Point widget_location(event.location()); 2427 gfx::Point widget_location(event.location());
2427 ConvertPointToWidget(this, &widget_location); 2428 ConvertPointToWidget(this, &widget_location);
2428 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2429 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2429 // WARNING: we may have been deleted. 2430 // WARNING: we may have been deleted.
2430 return true; 2431 return true;
2431 } 2432 }
2432 2433
2433 } // namespace views 2434 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.h ('k') | ui/views/window/non_client_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698