| 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 #include "ui/views/view.h" | 5 #include "ui/views/view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 void View::CalculateOffsetToAncestorWithLayer(gfx::Point* offset, | 1172 void View::CalculateOffsetToAncestorWithLayer(gfx::Point* offset, |
| 1173 ui::Layer** layer_parent) { | 1173 ui::Layer** layer_parent) { |
| 1174 if (layer()) { | 1174 if (layer()) { |
| 1175 if (layer_parent) | 1175 if (layer_parent) |
| 1176 *layer_parent = layer(); | 1176 *layer_parent = layer(); |
| 1177 return; | 1177 return; |
| 1178 } | 1178 } |
| 1179 if (!parent_) | 1179 if (!parent_) |
| 1180 return; | 1180 return; |
| 1181 | 1181 |
| 1182 offset->Offset(x(), y()); | 1182 offset->Offset(GetMirroredX(), y()); |
| 1183 parent_->CalculateOffsetToAncestorWithLayer(offset, layer_parent); | 1183 parent_->CalculateOffsetToAncestorWithLayer(offset, layer_parent); |
| 1184 } | 1184 } |
| 1185 | 1185 |
| 1186 void View::MoveLayerToParent(ui::Layer* parent_layer, | 1186 void View::MoveLayerToParent(ui::Layer* parent_layer, |
| 1187 const gfx::Point& point) { | 1187 const gfx::Point& point) { |
| 1188 gfx::Point local_point(point); | 1188 gfx::Point local_point(point); |
| 1189 if (parent_layer != layer()) | 1189 if (parent_layer != layer()) |
| 1190 local_point.Offset(x(), y()); | 1190 local_point.Offset(GetMirroredX(), y()); |
| 1191 if (layer() && parent_layer != layer()) { | 1191 if (layer() && parent_layer != layer()) { |
| 1192 parent_layer->Add(layer()); | 1192 parent_layer->Add(layer()); |
| 1193 layer()->SetBounds(gfx::Rect(local_point.x(), local_point.y(), | 1193 layer()->SetBounds(gfx::Rect(local_point.x(), local_point.y(), |
| 1194 width(), height())); | 1194 width(), height())); |
| 1195 } else { | 1195 } else { |
| 1196 for (int i = 0, count = child_count(); i < count; ++i) | 1196 for (int i = 0, count = child_count(); i < count; ++i) |
| 1197 child_at(i)->MoveLayerToParent(parent_layer, local_point); | 1197 child_at(i)->MoveLayerToParent(parent_layer, local_point); |
| 1198 } | 1198 } |
| 1199 } | 1199 } |
| 1200 | 1200 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1215 for (int i = 0, count = child_count(); i < count; ++i) | 1215 for (int i = 0, count = child_count(); i < count; ++i) |
| 1216 child_at(i)->UpdateChildLayerVisibility(ancestor_visible && visible_); | 1216 child_at(i)->UpdateChildLayerVisibility(ancestor_visible && visible_); |
| 1217 } | 1217 } |
| 1218 } | 1218 } |
| 1219 | 1219 |
| 1220 void View::UpdateChildLayerBounds(const gfx::Point& offset) { | 1220 void View::UpdateChildLayerBounds(const gfx::Point& offset) { |
| 1221 if (layer()) { | 1221 if (layer()) { |
| 1222 layer()->SetBounds(gfx::Rect(offset.x(), offset.y(), width(), height())); | 1222 layer()->SetBounds(gfx::Rect(offset.x(), offset.y(), width(), height())); |
| 1223 } else { | 1223 } else { |
| 1224 for (int i = 0, count = child_count(); i < count; ++i) { | 1224 for (int i = 0, count = child_count(); i < count; ++i) { |
| 1225 gfx::Point new_offset(offset.x() + child_at(i)->x(), | 1225 gfx::Point new_offset(offset.x() + child_at(i)->GetMirroredX(), |
| 1226 offset.y() + child_at(i)->y()); | 1226 offset.y() + child_at(i)->y()); |
| 1227 child_at(i)->UpdateChildLayerBounds(new_offset); | 1227 child_at(i)->UpdateChildLayerBounds(new_offset); |
| 1228 } | 1228 } |
| 1229 } | 1229 } |
| 1230 } | 1230 } |
| 1231 | 1231 |
| 1232 void View::OnPaintLayer(gfx::Canvas* canvas) { | 1232 void View::OnPaintLayer(gfx::Canvas* canvas) { |
| 1233 if (!layer() || !layer()->fills_bounds_opaquely()) | 1233 if (!layer() || !layer()->fills_bounds_opaquely()) |
| 1234 canvas->DrawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); | 1234 canvas->DrawColor(SK_ColorBLACK, SkXfermode::kClear_Mode); |
| 1235 PaintCommon(canvas); | 1235 PaintCommon(canvas); |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1630 SchedulePaintBoundsChanged( | 1630 SchedulePaintBoundsChanged( |
| 1631 bounds_.size() == previous_bounds.size() ? SCHEDULE_PAINT_SIZE_SAME : | 1631 bounds_.size() == previous_bounds.size() ? SCHEDULE_PAINT_SIZE_SAME : |
| 1632 SCHEDULE_PAINT_SIZE_CHANGED); | 1632 SCHEDULE_PAINT_SIZE_CHANGED); |
| 1633 } | 1633 } |
| 1634 | 1634 |
| 1635 if (use_acceleration_when_possible) { | 1635 if (use_acceleration_when_possible) { |
| 1636 if (layer()) { | 1636 if (layer()) { |
| 1637 if (parent_) { | 1637 if (parent_) { |
| 1638 gfx::Point offset; | 1638 gfx::Point offset; |
| 1639 parent_->CalculateOffsetToAncestorWithLayer(&offset, NULL); | 1639 parent_->CalculateOffsetToAncestorWithLayer(&offset, NULL); |
| 1640 offset.Offset(x(), y()); | 1640 offset.Offset(GetMirroredX(), y()); |
| 1641 layer()->SetBounds(gfx::Rect(offset, size())); | 1641 layer()->SetBounds(gfx::Rect(offset, size())); |
| 1642 } else { | 1642 } else { |
| 1643 layer()->SetBounds(bounds_); | 1643 layer()->SetBounds(bounds_); |
| 1644 } | 1644 } |
| 1645 // TODO(beng): this seems redundant with the SchedulePaint at the top of | 1645 // TODO(beng): this seems redundant with the SchedulePaint at the top of |
| 1646 // this function. explore collapsing. | 1646 // this function. explore collapsing. |
| 1647 if (previous_bounds.size() != bounds_.size() && | 1647 if (previous_bounds.size() != bounds_.size() && |
| 1648 !layer()->layer_updated_externally()) { | 1648 !layer()->layer_updated_externally()) { |
| 1649 // If our bounds have changed then we need to update the complete | 1649 // If our bounds have changed then we need to update the complete |
| 1650 // texture. | 1650 // texture. |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1802 for (int i = 0, count = child_count(); i < count; ++i) | 1802 for (int i = 0, count = child_count(); i < count; ++i) |
| 1803 child_at(i)->UpdateParentLayers(); | 1803 child_at(i)->UpdateParentLayers(); |
| 1804 } | 1804 } |
| 1805 } | 1805 } |
| 1806 | 1806 |
| 1807 void View::UpdateParentLayer() { | 1807 void View::UpdateParentLayer() { |
| 1808 if (!layer()) | 1808 if (!layer()) |
| 1809 return; | 1809 return; |
| 1810 | 1810 |
| 1811 ui::Layer* parent_layer = NULL; | 1811 ui::Layer* parent_layer = NULL; |
| 1812 gfx::Point offset(x(), y()); | 1812 gfx::Point offset(GetMirroredX(), y()); |
| 1813 | 1813 |
| 1814 // TODO(sad): The NULL check here for parent_ essentially is to check if this | 1814 // TODO(sad): The NULL check here for parent_ essentially is to check if this |
| 1815 // is the RootView. Instead of doing this, this function should be made | 1815 // is the RootView. Instead of doing this, this function should be made |
| 1816 // virtual and overridden from the RootView. | 1816 // virtual and overridden from the RootView. |
| 1817 if (parent_) | 1817 if (parent_) |
| 1818 parent_->CalculateOffsetToAncestorWithLayer(&offset, &parent_layer); | 1818 parent_->CalculateOffsetToAncestorWithLayer(&offset, &parent_layer); |
| 1819 else if (!parent_ && GetWidget()) | 1819 else if (!parent_ && GetWidget()) |
| 1820 GetWidget()->CalculateOffsetToAncestorWithLayer(&offset, &parent_layer); | 1820 GetWidget()->CalculateOffsetToAncestorWithLayer(&offset, &parent_layer); |
| 1821 | 1821 |
| 1822 ReparentLayer(offset, parent_layer); | 1822 ReparentLayer(offset, parent_layer); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2063 | 2063 |
| 2064 // Message the RootView to do the drag and drop. That way if we're removed | 2064 // Message the RootView to do the drag and drop. That way if we're removed |
| 2065 // the RootView can detect it and avoid calling us back. | 2065 // the RootView can detect it and avoid calling us back. |
| 2066 gfx::Point widget_location(event.location()); | 2066 gfx::Point widget_location(event.location()); |
| 2067 ConvertPointToWidget(this, &widget_location); | 2067 ConvertPointToWidget(this, &widget_location); |
| 2068 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations); | 2068 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations); |
| 2069 #endif // !defined(OS_MACOSX) | 2069 #endif // !defined(OS_MACOSX) |
| 2070 } | 2070 } |
| 2071 | 2071 |
| 2072 } // namespace views | 2072 } // namespace views |
| OLD | NEW |