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

Unified Diff: client/layout/ViewLayout.dart

Issue 9148015: Example showing alternate async measurement solution (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Final version Created 8 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 side-by-side diff with in-line comments
Download patch
Index: client/layout/ViewLayout.dart
diff --git a/client/layout/ViewLayout.dart b/client/layout/ViewLayout.dart
index a19c64fe4f3bdffe44379187ba48755b7f5a83d1..b79ad29b77df456c7d16c5a95560e79c44203c5f 100644
--- a/client/layout/ViewLayout.dart
+++ b/client/layout/ViewLayout.dart
@@ -1,4 +1,4 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -27,7 +27,7 @@ interface Positionable {
class LayoutParams {
// TODO(jmesserly): should be const, but there's a bug in DartC preventing us
// from calling "window." in an initializer. See b/5332777
- Future<CSSStyleDeclaration> style;
+ CSSStyleDeclaration style;
int get layer() => 0;
@@ -71,7 +71,8 @@ class ViewLayout {
* to determine how this view should be laid out.
*/
LayoutParams layoutParams;
- Future<ElementRect> _cachedViewRect;
+ int _currentWidth;
+ int _currentHeight;
/** The view that this layout belongs to. */
final Positionable view;
@@ -102,19 +103,17 @@ class ViewLayout {
return view.customStyle['display'] == "-dart-grid";
}
- CSSStyleDeclaration get _style() => layoutParams.style.value;
+ CSSStyleDeclaration get _style() => layoutParams.style;
void cacheExistingBrowserLayout() {
- _cachedViewRect = view.node.rect;
+ assert(window.inMeasurementFrame);
+ final rect = view.node.rect.offset;
+ _currentWidth = rect.width;
+ _currentHeight = rect.height;
}
- int get currentWidth() {
- return _cachedViewRect.value.offset.width;
- }
-
- int get currentHeight() {
- return _cachedViewRect.value.offset.height;
- }
+ int get currentWidth() => _currentWidth;
+ int get currentHeight() => _currentHeight;
int get borderLeftWidth() => _toPixels(_style.borderLeftWidth);
int get borderTopWidth() => _toPixels(_style.borderTopWidth);
@@ -124,7 +123,7 @@ class ViewLayout {
int get borderHeight() => borderTopWidth + borderBottomWidth;
/** Implements the custom layout computation. */
- void measureLayout(Future<Size> size, Completer<bool> changed) {
+ bool measureLayout(int width, int height) {
}
/**
@@ -140,13 +139,12 @@ class ViewLayout {
// Note: we need to save the client height
_measuredWidth = width - borderWidth;
_measuredHeight = height - borderHeight;
- final completer = new Completer<Size>();
- completer.complete(new Size(_measuredWidth, _measuredHeight));
- measureLayout(completer.future, null);
+ measureLayout(_measuredWidth, _measuredHeight);
}
/** Applies the layout to the node. */
void applyLayout() {
+ assert(!window.inMeasurementFrame);
if (_measuredLeft != null) {
// TODO(jmesserly): benchmark the performance of this DOM interaction
final style = view.node.style;
@@ -188,7 +186,7 @@ class ViewLayout {
}
int measureWidth(ViewLayout parent, ContentSizeMode mode) {
- final style = layoutParams.style.value;
+ final style = layoutParams.style;
switch (mode) {
case ContentSizeMode.MIN:
return _styleToPixels(
@@ -201,7 +199,7 @@ class ViewLayout {
}
int measureHeight(ViewLayout parent, ContentSizeMode mode) {
- final style = layoutParams.style.value;
+ final style = layoutParams.style;
switch (mode) {
case ContentSizeMode.MIN:
return _styleToPixels(

Powered by Google App Engine
This is Rietveld 408576698