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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 | 95 |
96 // Creation and lifetime ------------------------------------------------------- | 96 // Creation and lifetime ------------------------------------------------------- |
97 | 97 |
98 View::View() | 98 View::View() |
99 : owned_by_client_(false), | 99 : owned_by_client_(false), |
100 id_(0), | 100 id_(0), |
101 group_(-1), | 101 group_(-1), |
102 parent_(NULL), | 102 parent_(NULL), |
103 visible_(true), | 103 visible_(true), |
104 enabled_(true), | 104 enabled_(true), |
105 painting_enabled_(true), | |
106 notify_enter_exit_on_child_(false), | 105 notify_enter_exit_on_child_(false), |
107 registered_for_visible_bounds_notification_(false), | 106 registered_for_visible_bounds_notification_(false), |
108 clip_insets_(0, 0, 0, 0), | 107 clip_insets_(0, 0, 0, 0), |
109 needs_layout_(true), | 108 needs_layout_(true), |
110 flip_canvas_on_paint_for_rtl_ui_(false), | 109 flip_canvas_on_paint_for_rtl_ui_(false), |
111 paint_to_layer_(false), | 110 paint_to_layer_(false), |
112 accelerator_registration_delayed_(false), | 111 accelerator_registration_delayed_(false), |
113 accelerator_focus_manager_(NULL), | 112 accelerator_focus_manager_(NULL), |
114 registered_accelerator_count_(0), | 113 registered_accelerator_count_(0), |
115 next_focusable_view_(NULL), | 114 next_focusable_view_(NULL), |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 return x_rect; | 682 return x_rect; |
684 } | 683 } |
685 | 684 |
686 // Painting -------------------------------------------------------------------- | 685 // Painting -------------------------------------------------------------------- |
687 | 686 |
688 void View::SchedulePaint() { | 687 void View::SchedulePaint() { |
689 SchedulePaintInRect(GetLocalBounds()); | 688 SchedulePaintInRect(GetLocalBounds()); |
690 } | 689 } |
691 | 690 |
692 void View::SchedulePaintInRect(const gfx::Rect& rect) { | 691 void View::SchedulePaintInRect(const gfx::Rect& rect) { |
693 if (!visible_ || !painting_enabled_) | 692 if (!visible_) |
694 return; | 693 return; |
695 | 694 |
696 if (layer()) { | 695 if (layer()) { |
697 layer()->SchedulePaint(rect); | 696 layer()->SchedulePaint(rect); |
698 } else if (parent_) { | 697 } else if (parent_) { |
699 // Translate the requested paint rect to the parent's coordinate system | 698 // Translate the requested paint rect to the parent's coordinate system |
700 // then pass this notification up to the parent. | 699 // then pass this notification up to the parent. |
701 parent_->SchedulePaintInRect(ConvertRectToParent(rect)); | 700 parent_->SchedulePaintInRect(ConvertRectToParent(rect)); |
702 } | 701 } |
703 } | 702 } |
(...skipping 790 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1494 } else if (parent_ && type == SCHEDULE_PAINT_SIZE_SAME) { | 1493 } else if (parent_ && type == SCHEDULE_PAINT_SIZE_SAME) { |
1495 // The compositor doesn't Draw() until something on screen changes, so | 1494 // The compositor doesn't Draw() until something on screen changes, so |
1496 // if our position changes but nothing is being animated on screen, then | 1495 // if our position changes but nothing is being animated on screen, then |
1497 // tell the compositor to redraw the scene. We know layer() exists due to | 1496 // tell the compositor to redraw the scene. We know layer() exists due to |
1498 // the above if clause. | 1497 // the above if clause. |
1499 layer()->ScheduleDraw(); | 1498 layer()->ScheduleDraw(); |
1500 } | 1499 } |
1501 } | 1500 } |
1502 | 1501 |
1503 void View::PaintCommon(gfx::Canvas* canvas) { | 1502 void View::PaintCommon(gfx::Canvas* canvas) { |
1504 if (!visible_ || !painting_enabled_) | 1503 if (!visible_) |
1505 return; | 1504 return; |
1506 | 1505 |
1507 { | 1506 { |
1508 // If the View we are about to paint requested the canvas to be flipped, we | 1507 // If the View we are about to paint requested the canvas to be flipped, we |
1509 // should change the transform appropriately. | 1508 // should change the transform appropriately. |
1510 // The canvas mirroring is undone once the View is done painting so that we | 1509 // The canvas mirroring is undone once the View is done painting so that we |
1511 // don't pass the canvas with the mirrored transform to Views that didn't | 1510 // don't pass the canvas with the mirrored transform to Views that didn't |
1512 // request the canvas to be flipped. | 1511 // request the canvas to be flipped. |
1513 ScopedCanvas scoped(canvas); | 1512 ScopedCanvas scoped(canvas); |
1514 if (FlipCanvasOnPaintForRTLUI()) { | 1513 if (FlipCanvasOnPaintForRTLUI()) { |
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2107 gfx::Point widget_location(event.location()); | 2106 gfx::Point widget_location(event.location()); |
2108 ConvertPointToWidget(this, &widget_location); | 2107 ConvertPointToWidget(this, &widget_location); |
2109 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations); | 2108 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations); |
2110 return true; | 2109 return true; |
2111 #else | 2110 #else |
2112 return false; | 2111 return false; |
2113 #endif // !defined(OS_MACOSX) | 2112 #endif // !defined(OS_MACOSX) |
2114 } | 2113 } |
2115 | 2114 |
2116 } // namespace views | 2115 } // namespace views |
OLD | NEW |