| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/display/display_change_notifier.h" | 5 #include "ui/display/display_change_notifier.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "ui/display/display.h" | 9 #include "ui/display/display.h" |
| 10 #include "ui/display/display_observer.h" | 10 #include "ui/display/display_observer.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 void DisplayChangeNotifier::NotifyDisplaysChanged( | 43 void DisplayChangeNotifier::NotifyDisplaysChanged( |
| 44 const std::vector<Display>& old_displays, | 44 const std::vector<Display>& old_displays, |
| 45 const std::vector<Display>& new_displays) { | 45 const std::vector<Display>& new_displays) { |
| 46 // Display present in old_displays but not in new_displays has been removed. | 46 // Display present in old_displays but not in new_displays has been removed. |
| 47 std::vector<Display>::const_iterator old_it = old_displays.begin(); | 47 std::vector<Display>::const_iterator old_it = old_displays.begin(); |
| 48 for (; old_it != old_displays.end(); ++old_it) { | 48 for (; old_it != old_displays.end(); ++old_it) { |
| 49 if (std::find_if(new_displays.begin(), new_displays.end(), | 49 if (std::find_if(new_displays.begin(), new_displays.end(), |
| 50 DisplayComparator(*old_it)) == new_displays.end()) { | 50 DisplayComparator(*old_it)) == new_displays.end()) { |
| 51 FOR_EACH_OBSERVER(DisplayObserver, observer_list_, | 51 for (DisplayObserver& observer : observer_list_) |
| 52 OnDisplayRemoved(*old_it)); | 52 observer.OnDisplayRemoved(*old_it); |
| 53 } | 53 } |
| 54 } | 54 } |
| 55 | 55 |
| 56 // Display present in new_displays but not in old_displays has been added. | 56 // Display present in new_displays but not in old_displays has been added. |
| 57 // Display present in both might have been modified. | 57 // Display present in both might have been modified. |
| 58 for (std::vector<Display>::const_iterator new_it = new_displays.begin(); | 58 for (std::vector<Display>::const_iterator new_it = new_displays.begin(); |
| 59 new_it != new_displays.end(); ++new_it) { | 59 new_it != new_displays.end(); ++new_it) { |
| 60 std::vector<Display>::const_iterator old_it = std::find_if( | 60 std::vector<Display>::const_iterator old_it = std::find_if( |
| 61 old_displays.begin(), old_displays.end(), DisplayComparator(*new_it)); | 61 old_displays.begin(), old_displays.end(), DisplayComparator(*new_it)); |
| 62 | 62 |
| 63 if (old_it == old_displays.end()) { | 63 if (old_it == old_displays.end()) { |
| 64 FOR_EACH_OBSERVER(DisplayObserver, observer_list_, | 64 for (DisplayObserver& observer : observer_list_) |
| 65 OnDisplayAdded(*new_it)); | 65 observer.OnDisplayAdded(*new_it); |
| 66 continue; | 66 continue; |
| 67 } | 67 } |
| 68 | 68 |
| 69 uint32_t metrics = DisplayObserver::DISPLAY_METRIC_NONE; | 69 uint32_t metrics = DisplayObserver::DISPLAY_METRIC_NONE; |
| 70 | 70 |
| 71 if (new_it->bounds() != old_it->bounds()) | 71 if (new_it->bounds() != old_it->bounds()) |
| 72 metrics |= DisplayObserver::DISPLAY_METRIC_BOUNDS; | 72 metrics |= DisplayObserver::DISPLAY_METRIC_BOUNDS; |
| 73 | 73 |
| 74 if (new_it->rotation() != old_it->rotation()) | 74 if (new_it->rotation() != old_it->rotation()) |
| 75 metrics |= DisplayObserver::DISPLAY_METRIC_ROTATION; | 75 metrics |= DisplayObserver::DISPLAY_METRIC_ROTATION; |
| 76 | 76 |
| 77 if (new_it->work_area() != old_it->work_area()) | 77 if (new_it->work_area() != old_it->work_area()) |
| 78 metrics |= DisplayObserver::DISPLAY_METRIC_WORK_AREA; | 78 metrics |= DisplayObserver::DISPLAY_METRIC_WORK_AREA; |
| 79 | 79 |
| 80 if (new_it->device_scale_factor() != old_it->device_scale_factor()) | 80 if (new_it->device_scale_factor() != old_it->device_scale_factor()) |
| 81 metrics |= DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR; | 81 metrics |= DisplayObserver::DISPLAY_METRIC_DEVICE_SCALE_FACTOR; |
| 82 | 82 |
| 83 if (metrics != DisplayObserver::DISPLAY_METRIC_NONE) { | 83 if (metrics != DisplayObserver::DISPLAY_METRIC_NONE) { |
| 84 FOR_EACH_OBSERVER(DisplayObserver, observer_list_, | 84 for (DisplayObserver& observer : observer_list_) |
| 85 OnDisplayMetricsChanged(*new_it, metrics)); | 85 observer.OnDisplayMetricsChanged(*new_it, metrics); |
| 86 } | 86 } |
| 87 } | 87 } |
| 88 } | 88 } |
| 89 | 89 |
| 90 } // namespace display | 90 } // namespace display |
| OLD | NEW |