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

Side by Side Diff: samples/ui_lib/layout/ViewLayout.dart

Issue 11367040: Removing Element.rect. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** The interface that the layout algorithms use to talk to the view. */ 5 /** The interface that the layout algorithms use to talk to the view. */
6 abstract class Positionable { 6 abstract class Positionable {
7 ViewLayout get layout; 7 ViewLayout get layout;
8 8
9 /** Gets our custom CSS properties, as provided by the CSS preprocessor. */ 9 /** Gets our custom CSS properties, as provided by the CSS preprocessor. */
10 Map<String, String> get customStyle; 10 Map<String, String> get customStyle;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 * Abstract base class for View layout. Tracks relevant layout state. 64 * Abstract base class for View layout. Tracks relevant layout state.
65 * This code was inspired by code in Android's View.java; it's needed for the 65 * This code was inspired by code in Android's View.java; it's needed for the
66 * rest of the layout system. 66 * rest of the layout system.
67 */ 67 */
68 class ViewLayout { 68 class ViewLayout {
69 /** 69 /**
70 * The layout parameters associated with this view and used by the parent 70 * The layout parameters associated with this view and used by the parent
71 * to determine how this view should be laid out. 71 * to determine how this view should be laid out.
72 */ 72 */
73 LayoutParams layoutParams; 73 LayoutParams layoutParams;
74 Future<ElementRect> _cachedViewRect; 74 int _offsetWidth;
75 int _offsetHeight;
75 76
76 /** The view that this layout belongs to. */ 77 /** The view that this layout belongs to. */
77 final Positionable view; 78 final Positionable view;
78 79
79 /** 80 /**
80 * To get a perforant positioning model on top of the DOM, we read all 81 * To get a perforant positioning model on top of the DOM, we read all
81 * properties in the first pass while computing positions. Then we have a 82 * properties in the first pass while computing positions. Then we have a
82 * second pass that actually moves everything. 83 * second pass that actually moves everything.
83 */ 84 */
84 int _measuredLeft, _measuredTop, _measuredWidth, _measuredHeight; 85 int _measuredLeft, _measuredTop, _measuredWidth, _measuredHeight;
(...skipping 13 matching lines...) Expand all
98 } 99 }
99 } 100 }
100 101
101 static bool hasCustomLayout(Positionable view) { 102 static bool hasCustomLayout(Positionable view) {
102 return view.customStyle['display'] == "-dart-grid"; 103 return view.customStyle['display'] == "-dart-grid";
103 } 104 }
104 105
105 CSSStyleDeclaration get _style => layoutParams.style.value; 106 CSSStyleDeclaration get _style => layoutParams.style.value;
106 107
107 void cacheExistingBrowserLayout() { 108 void cacheExistingBrowserLayout() {
108 _cachedViewRect = view.node.rect; 109 _offsetWidth = view.node.offsetWidth;
110 _offsetHeight = view.node.offsetHeight;
109 } 111 }
110 112
111 int get currentWidth { 113 int get currentWidth {
112 return _cachedViewRect.value.offset.width; 114 return _offsetWidth;
113 } 115 }
114 116
115 int get currentHeight { 117 int get currentHeight {
116 return _cachedViewRect.value.offset.height; 118 return _offsetHeight;
117 } 119 }
118 120
119 int get borderLeftWidth => _toPixels(_style.borderLeftWidth); 121 int get borderLeftWidth => _toPixels(_style.borderLeftWidth);
120 int get borderTopWidth => _toPixels(_style.borderTopWidth); 122 int get borderTopWidth => _toPixels(_style.borderTopWidth);
121 int get borderRightWidth => _toPixels(_style.borderRightWidth); 123 int get borderRightWidth => _toPixels(_style.borderRightWidth);
122 int get borderBottomWidth => _toPixels(_style.borderBottomWidth); 124 int get borderBottomWidth => _toPixels(_style.borderBottomWidth);
123 int get borderWidth => borderLeftWidth + borderRightWidth; 125 int get borderWidth => borderLeftWidth + borderRightWidth;
124 int get borderHeight => borderTopWidth + borderBottomWidth; 126 int get borderHeight => borderTopWidth + borderBottomWidth;
125 127
126 /** Implements the custom layout computation. */ 128 /** Implements the custom layout computation. */
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 // For an unset max-content size, use the actual size 225 // For an unset max-content size, use the actual size
224 return size; 226 return size;
225 } 227 }
226 if (style.endsWith('%')) { 228 if (style.endsWith('%')) {
227 num percent = double.parse(style.substring(0, style.length - 1)); 229 num percent = double.parse(style.substring(0, style.length - 1));
228 return ((percent / 100) * parentSize).toInt(); 230 return ((percent / 100) * parentSize).toInt();
229 } 231 }
230 return _toPixels(style); 232 return _toPixels(style);
231 } 233 }
232 } 234 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698