Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(51)

Side by Side Diff: ui/views/view.cc

Issue 819273003: View: Resizing a layer in RTL now correctly repositions its children. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Directly call UpdateChildLayerBounds instead of a new method. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/views/view_unittest.cc » ('j') | ui/views/view_unittest.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1904 matching lines...) Expand 10 before | Expand all | Expand 10 after
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. Update the child's layer bounds, or if it is not a layer, the
1927 // bounds of any layers inside the child.
1928 if (base::i18n::IsRTL() && bounds_.width() != previous_bounds.width()) {
1929 for (int i = 0; i < child_count(); ++i) {
1930 View* child = child_at(i);
1931 gfx::Vector2d offset;
1932 if (child->layer()) {
1933 offset = gfx::Vector2d(child->GetMirroredX(), child->y()) +
1934 CalculateOffsetToAncestorWithLayer(NULL);
1935 } else {
1936 // If the child's bounds have changed, then any descendant layer bounds
1937 // may have changed. Update them accordingly.
1938 offset = child->CalculateOffsetToAncestorWithLayer(NULL);
1939 }
1940 child->UpdateChildLayerBounds(offset);
1941 }
1942 }
1943
1925 OnBoundsChanged(previous_bounds); 1944 OnBoundsChanged(previous_bounds);
1926 1945
1927 if (previous_bounds.size() != size()) { 1946 if (previous_bounds.size() != size()) {
1928 needs_layout_ = false; 1947 needs_layout_ = false;
1929 Layout(); 1948 Layout();
1930 } 1949 }
1931 1950
1932 if (GetNeedsNotificationWhenVisibleBoundsChange()) 1951 if (GetNeedsNotificationWhenVisibleBoundsChange())
1933 OnVisibleBoundsChanged(); 1952 OnVisibleBoundsChanged();
1934 1953
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
2452 // Message the RootView to do the drag and drop. That way if we're removed 2471 // 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. 2472 // the RootView can detect it and avoid calling us back.
2454 gfx::Point widget_location(event.location()); 2473 gfx::Point widget_location(event.location());
2455 ConvertPointToWidget(this, &widget_location); 2474 ConvertPointToWidget(this, &widget_location);
2456 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2475 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2457 // WARNING: we may have been deleted. 2476 // WARNING: we may have been deleted.
2458 return true; 2477 return true;
2459 } 2478 }
2460 2479
2461 } // namespace views 2480 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/view_unittest.cc » ('j') | ui/views/view_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698