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 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1760 SchedulePaint(); | 1760 SchedulePaint(); |
1761 } else if (parent_ && type == SCHEDULE_PAINT_SIZE_SAME) { | 1761 } else if (parent_ && type == SCHEDULE_PAINT_SIZE_SAME) { |
1762 // The compositor doesn't Draw() until something on screen changes, so | 1762 // The compositor doesn't Draw() until something on screen changes, so |
1763 // if our position changes but nothing is being animated on screen, then | 1763 // if our position changes but nothing is being animated on screen, then |
1764 // tell the compositor to redraw the scene. We know layer() exists due to | 1764 // tell the compositor to redraw the scene. We know layer() exists due to |
1765 // the above if clause. | 1765 // the above if clause. |
1766 layer()->ScheduleDraw(); | 1766 layer()->ScheduleDraw(); |
1767 } | 1767 } |
1768 } | 1768 } |
1769 | 1769 |
1770 void View::SchedulePaintOnParent() { | |
1771 if (parent_) { | |
1772 // Translate the requested paint rect to the parent's coordinate system | |
1773 // then pass this notification up to the parent. | |
1774 parent_->SchedulePaintInRect(ConvertRectToParent(GetLocalBounds())); | |
1775 } | |
1776 } | |
1777 | |
1778 // Tree operations ------------------------------------------------------------- | 1770 // Tree operations ------------------------------------------------------------- |
1779 | 1771 |
1780 void View::DoRemoveChildView(View* view, | 1772 void View::DoRemoveChildView(View* view, |
1781 bool update_focus_cycle, | 1773 bool update_focus_cycle, |
1782 bool update_tool_tip, | 1774 bool update_tool_tip, |
1783 bool delete_removed_view, | 1775 bool delete_removed_view, |
1784 View* new_parent) { | 1776 View* new_parent) { |
1785 DCHECK(view); | 1777 DCHECK(view); |
1786 | 1778 |
1787 const Views::iterator i(std::find(children_.begin(), children_.end(), view)); | 1779 const Views::iterator i(std::find(children_.begin(), children_.end(), view)); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2081 | 2073 |
2082 // The new layer needs to be ordered in the layer tree according | 2074 // The new layer needs to be ordered in the layer tree according |
2083 // to the view tree. Children of this layer were added in order | 2075 // to the view tree. Children of this layer were added in order |
2084 // in UpdateParentLayers(). | 2076 // in UpdateParentLayers(). |
2085 if (parent()) | 2077 if (parent()) |
2086 parent()->ReorderLayers(); | 2078 parent()->ReorderLayers(); |
2087 | 2079 |
2088 Widget* widget = GetWidget(); | 2080 Widget* widget = GetWidget(); |
2089 if (widget) | 2081 if (widget) |
2090 widget->UpdateRootLayers(); | 2082 widget->UpdateRootLayers(); |
2091 | |
2092 // Before having its own Layer, this View may have painted in to a Layer owned | |
2093 // by an ancestor View. Scheduling a paint on the parent View will erase this | |
2094 // View's painting effects on the ancestor View's Layer. | |
2095 // (See crbug.com/551492) | |
2096 SchedulePaintOnParent(); | |
2097 } | 2083 } |
2098 | 2084 |
2099 void View::UpdateParentLayers() { | 2085 void View::UpdateParentLayers() { |
2100 // Attach all top-level un-parented layers. | 2086 // Attach all top-level un-parented layers. |
2101 if (layer() && !layer()->parent()) { | 2087 if (layer() && !layer()->parent()) { |
2102 UpdateParentLayer(); | 2088 UpdateParentLayer(); |
2103 } else { | 2089 } else { |
2104 for (int i = 0, count = child_count(); i < count; ++i) | 2090 for (int i = 0, count = child_count(); i < count; ++i) |
2105 child_at(i)->UpdateParentLayers(); | 2091 child_at(i)->UpdateParentLayers(); |
2106 } | 2092 } |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2402 // Message the RootView to do the drag and drop. That way if we're removed | 2388 // Message the RootView to do the drag and drop. That way if we're removed |
2403 // the RootView can detect it and avoid calling us back. | 2389 // the RootView can detect it and avoid calling us back. |
2404 gfx::Point widget_location(event.location()); | 2390 gfx::Point widget_location(event.location()); |
2405 ConvertPointToWidget(this, &widget_location); | 2391 ConvertPointToWidget(this, &widget_location); |
2406 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2392 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2407 // WARNING: we may have been deleted. | 2393 // WARNING: we may have been deleted. |
2408 return true; | 2394 return true; |
2409 } | 2395 } |
2410 | 2396 |
2411 } // namespace views | 2397 } // namespace views |
OLD | NEW |