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 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1887 void View::PropagateVisibilityNotifications(View* start, bool is_visible) { | 1887 void View::PropagateVisibilityNotifications(View* start, bool is_visible) { |
1888 for (int i = 0, count = child_count(); i < count; ++i) | 1888 for (int i = 0, count = child_count(); i < count; ++i) |
1889 child_at(i)->PropagateVisibilityNotifications(start, is_visible); | 1889 child_at(i)->PropagateVisibilityNotifications(start, is_visible); |
1890 VisibilityChangedImpl(start, is_visible); | 1890 VisibilityChangedImpl(start, is_visible); |
1891 } | 1891 } |
1892 | 1892 |
1893 void View::VisibilityChangedImpl(View* starting_from, bool is_visible) { | 1893 void View::VisibilityChangedImpl(View* starting_from, bool is_visible) { |
1894 VisibilityChanged(starting_from, is_visible); | 1894 VisibilityChanged(starting_from, is_visible); |
1895 } | 1895 } |
1896 | 1896 |
1897 void View::BoundsChanged(const gfx::Rect& previous_bounds) { | 1897 void View::MirroredBoundsChanged(const gfx::Rect& previous_bounds) { |
1898 // Mark our bounds as dirty for the paint root, also see if we need to | 1898 // Mark our bounds as dirty for the paint root, also see if we need to |
1899 // recompute our children's bounds due to origin change. | 1899 // recompute our children's bounds due to origin change. |
1900 bool origin_changed = | 1900 bool origin_changed = |
1901 previous_bounds.OffsetFromOrigin() != bounds_.OffsetFromOrigin(); | 1901 previous_bounds.OffsetFromOrigin() != bounds_.OffsetFromOrigin(); |
1902 SetRootBoundsDirty(origin_changed); | 1902 SetRootBoundsDirty(origin_changed); |
1903 | 1903 |
1904 if (visible_) { | 1904 if (visible_) { |
1905 // Paint the new bounds. | 1905 // Paint the new bounds. |
1906 SchedulePaintBoundsChanged( | 1906 SchedulePaintBoundsChanged( |
1907 bounds_.size() == previous_bounds.size() ? SCHEDULE_PAINT_SIZE_SAME : | 1907 bounds_.size() == previous_bounds.size() ? SCHEDULE_PAINT_SIZE_SAME : |
1908 SCHEDULE_PAINT_SIZE_CHANGED); | 1908 SCHEDULE_PAINT_SIZE_CHANGED); |
1909 } | 1909 } |
1910 | 1910 |
1911 if (layer()) { | 1911 if (layer()) { |
1912 if (parent_) { | 1912 if (parent_) { |
1913 SetLayerBounds(GetLocalBounds() + | 1913 SetLayerBounds(GetLocalBounds() + |
1914 gfx::Vector2d(GetMirroredX(), y()) + | 1914 gfx::Vector2d(GetMirroredX(), y()) + |
1915 parent_->CalculateOffsetToAncestorWithLayer(NULL)); | 1915 parent_->CalculateOffsetToAncestorWithLayer(NULL)); |
1916 } else { | 1916 } else { |
1917 SetLayerBounds(bounds_); | 1917 SetLayerBounds(bounds_); |
1918 } | 1918 } |
1919 } else { | 1919 } else { |
1920 // If our bounds have changed, then any descendant layer bounds may have | 1920 // If our bounds have changed, then any descendant layer bounds may have |
1921 // changed. Update them accordingly. | 1921 // changed. Update them accordingly. |
1922 UpdateChildLayerBounds(CalculateOffsetToAncestorWithLayer(NULL)); | 1922 UpdateChildLayerBounds(CalculateOffsetToAncestorWithLayer(NULL)); |
1923 } | 1923 } |
1924 | 1924 |
1925 // In RTL mode, if our width has changed, our children's mirrored bounds will | |
1926 // have changed. Notify them, so that they can update their layer bounds, etc. | |
1927 if (base::i18n::IsRTL() && bounds_.width() != previous_bounds.width()) { | |
sky
2015/01/06 16:45:50
I get that you need to do something in this case,
Matt Giuca
2015/01/07 00:48:44
You can't just call UpdateChildLayerBounds on the
sky
2015/01/07 16:55:56
UpdateChildLayerBounds calls SetLayerBounds.
Matt Giuca
2015/01/07 23:30:00
Hmm, yeah it does (didn't notice that before), but
| |
1928 for (int i = 0; i < child_count(); ++i) { | |
1929 View* child = child_at(i); | |
1930 child->MirroredBoundsChanged(child->bounds()); | |
1931 } | |
1932 } | |
1933 } | |
1934 | |
1935 void View::BoundsChanged(const gfx::Rect& previous_bounds) { | |
1936 MirroredBoundsChanged(previous_bounds); | |
1937 | |
1925 OnBoundsChanged(previous_bounds); | 1938 OnBoundsChanged(previous_bounds); |
1926 | 1939 |
1927 if (previous_bounds.size() != size()) { | 1940 if (previous_bounds.size() != size()) { |
1928 needs_layout_ = false; | 1941 needs_layout_ = false; |
1929 Layout(); | 1942 Layout(); |
1930 } | 1943 } |
1931 | 1944 |
1932 if (GetNeedsNotificationWhenVisibleBoundsChange()) | 1945 if (GetNeedsNotificationWhenVisibleBoundsChange()) |
1933 OnVisibleBoundsChanged(); | 1946 OnVisibleBoundsChanged(); |
1934 | 1947 |
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2452 // Message the RootView to do the drag and drop. That way if we're removed | 2465 // Message the RootView to do the drag and drop. That way if we're removed |
2453 // the RootView can detect it and avoid calling us back. | 2466 // the RootView can detect it and avoid calling us back. |
2454 gfx::Point widget_location(event.location()); | 2467 gfx::Point widget_location(event.location()); |
2455 ConvertPointToWidget(this, &widget_location); | 2468 ConvertPointToWidget(this, &widget_location); |
2456 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2469 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
2457 // WARNING: we may have been deleted. | 2470 // WARNING: we may have been deleted. |
2458 return true; | 2471 return true; |
2459 } | 2472 } |
2460 | 2473 |
2461 } // namespace views | 2474 } // namespace views |
OLD | NEW |