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 |
1770 // Tree operations ------------------------------------------------------------- | 1778 // Tree operations ------------------------------------------------------------- |
1771 | 1779 |
1772 void View::DoRemoveChildView(View* view, | 1780 void View::DoRemoveChildView(View* view, |
1773 bool update_focus_cycle, | 1781 bool update_focus_cycle, |
1774 bool update_tool_tip, | 1782 bool update_tool_tip, |
1775 bool delete_removed_view, | 1783 bool delete_removed_view, |
1776 View* new_parent) { | 1784 View* new_parent) { |
1777 DCHECK(view); | 1785 DCHECK(view); |
1778 | 1786 |
1779 const Views::iterator i(std::find(children_.begin(), children_.end(), view)); | 1787 const Views::iterator i(std::find(children_.begin(), children_.end(), view)); |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2073 | 2081 |
2074 // The new layer needs to be ordered in the layer tree according | 2082 // The new layer needs to be ordered in the layer tree according |
2075 // to the view tree. Children of this layer were added in order | 2083 // to the view tree. Children of this layer were added in order |
2076 // in UpdateParentLayers(). | 2084 // in UpdateParentLayers(). |
2077 if (parent()) | 2085 if (parent()) |
2078 parent()->ReorderLayers(); | 2086 parent()->ReorderLayers(); |
2079 | 2087 |
2080 Widget* widget = GetWidget(); | 2088 Widget* widget = GetWidget(); |
2081 if (widget) | 2089 if (widget) |
2082 widget->UpdateRootLayers(); | 2090 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(); |
2083 } | 2097 } |
2084 | 2098 |
2085 void View::UpdateParentLayers() { | 2099 void View::UpdateParentLayers() { |
2086 // Attach all top-level un-parented layers. | 2100 // Attach all top-level un-parented layers. |
2087 if (layer() && !layer()->parent()) { | 2101 if (layer() && !layer()->parent()) { |
2088 UpdateParentLayer(); | 2102 UpdateParentLayer(); |
2089 } else { | 2103 } else { |
2090 for (int i = 0, count = child_count(); i < count; ++i) | 2104 for (int i = 0, count = child_count(); i < count; ++i) |
2091 child_at(i)->UpdateParentLayers(); | 2105 child_at(i)->UpdateParentLayers(); |
2092 } | 2106 } |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2388 // Message the RootView to do the drag and drop. That way if we're removed | 2402 // Message the RootView to do the drag and drop. That way if we're removed |
2389 // the RootView can detect it and avoid calling us back. | 2403 // the RootView can detect it and avoid calling us back. |
2390 gfx::Point widget_location(event.location()); | 2404 gfx::Point widget_location(event.location()); |
2391 ConvertPointToWidget(this, &widget_location); | 2405 ConvertPointToWidget(this, &widget_location); |
2392 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2406 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2393 // WARNING: we may have been deleted. | 2407 // WARNING: we may have been deleted. |
2394 return true; | 2408 return true; |
2395 } | 2409 } |
2396 | 2410 |
2397 } // namespace views | 2411 } // namespace views |
OLD | NEW |