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

Side by Side Diff: client/samples/total/src/InnerMenuView.dart

Issue 9145004: Revert "Example showing alternate async measurement solution" (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « client/samples/total/src/HtmlTable.dart ('k') | client/samples/total/src/SelectionManager.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, 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 // TODO: RE: implements RequestAnimationFrameCallback. File bug 5 // TODO: RE: implements RequestAnimationFrameCallback. File bug
6 // against dom libs because it should be possible to pass a function 6 // against dom libs because it should be possible to pass a function
7 // to webkitRequestAnimationFrame just like addEventListener. 7 // to webkitRequestAnimationFrame just like addEventListener.
8 class InnerMenuView { 8 class InnerMenuView {
9 static final List<String> _textAlignmentClassNames = const <String>[ "l", "c", "r" ]; 9 static final List<String> _textAlignmentClassNames = const <String>[ "l", "c", "r" ];
10 static final List<int> _textAlignmentValues = const <int>[ 10 static final List<int> _textAlignmentValues = const <int>[
11 Style.LEFT, Style.CENTER, Style.RIGHT 11 Style.LEFT, Style.CENTER, Style.RIGHT
(...skipping 28 matching lines...) Expand all
40 40
41 // TODO: HACK. When we expand the border on our table cells, 41 // TODO: HACK. When we expand the border on our table cells,
42 // the sizes for the table will be contradictory since the row is 42 // the sizes for the table will be contradictory since the row is
43 // set to a height that is smaller than the offsetHeight of row. This 43 // set to a height that is smaller than the offsetHeight of row. This
44 // will cause the cells to become smaller (visual jitter). To work around 44 // will cause the cells to become smaller (visual jitter). To work around
45 // we set the height of the cell explicitly. Sadly this requires us 45 // we set the height of the cell explicitly. Sadly this requires us
46 // to use the computed style to determine the current padding of the 46 // to use the computed style to determine the current padding of the
47 // cell. 47 // cell.
48 static void _pinHeight(Window window, TableRowElement row) { 48 static void _pinHeight(Window window, TableRowElement row) {
49 Element firstCell = row.cells[0]; 49 Element firstCell = row.cells[0];
50 window.requestMeasurementFrame(() { 50 final firstCellRect = firstCell.rect;
51 final firstCellRect = firstCell.rect; 51 final style = firstCell.computedStyle;
52 final style = firstCell.computedStyle; 52 window.requestLayoutFrame(() {
53 53 int height = firstCellRect.value.client.height
54 int height = firstCell.rect.client.height 54 - HtmlUtils.fromPx(style.value.getPropertyValue('padding-top'))
55 - HtmlUtils.fromPx(style.paddingTop) 55 - HtmlUtils.fromPx(style.value.getPropertyValue('padding-bottom'));
56 - HtmlUtils.fromPx(style.paddingBottom); 56 firstCell.style.setProperty('height', HtmlUtils.toPx(height));
57 return () { firstCell.style.height = HtmlUtils.toPx(height); };
58 }); 57 });
59 } 58 }
60 59
61 // Reverses the damage done by _pinHeight. 60 // Reverses the damage done by _pinHeight.
62 static void _unpinHeight(TableRowElement row) { 61 static void _unpinHeight(TableRowElement row) {
63 Element firstCell = row.cells[0]; 62 Element firstCell = row.cells[0];
64 firstCell.style.removeProperty('height'); 63 firstCell.style.removeProperty('height');
65 } 64 }
66 65
67 ColorPicker _backgroundColorPicker; 66 ColorPicker _backgroundColorPicker;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 bool isAttachedTo(TableRowElement row) => _row == row; 205 bool isAttachedTo(TableRowElement row) => _row == row;
207 206
208 void updateSize() { 207 void updateSize() {
209 if (_row.parent == null) { 208 if (_row.parent == null) {
210 // The row we were attached to has disappeared (e.g., by scrolling), so cl ean up the menu bar 209 // The row we were attached to has disappeared (e.g., by scrolling), so cl ean up the menu bar
211 _bar.remove(); 210 _bar.remove();
212 return; 211 return;
213 } 212 }
214 213
215 // Must take into account the top of the table due to scrolling. 214 // Must take into account the top of the table due to scrolling.
216 window.requestMeasurementFrame(() { 215 final offsetParentRect = _row.offsetParent.rect;
217 int tableTop = _row.offsetParent.rect.bounding.top.toInt(); 216 final rowRect = _row.rect;
217 window.requestLayoutFrame(() {
218 int tableTop = offsetParentRect.value.bounding.top.toInt();
218 219
219 // Get the current bounding box of the row we're attached to. 220 // Get the current bounding box of the row we're attached to.
220 ClientRect boundingRowRect = _row.rect.bounding; 221 ClientRect boundingRowRect = rowRect.value.bounding;
221 CSSStyleDeclaration style = _bar.style; 222 CSSStyleDeclaration style = _bar.style;
222 223
223 int top = boundingRowRect.top.toInt() + _initialRowHeight - tableTop; 224 int top = boundingRowRect.top.toInt() + _initialRowHeight - tableTop;
224 int height = boundingRowRect.height.toInt() - _initialRowHeight; 225 int height = boundingRowRect.height.toInt() - _initialRowHeight;
225 226
226 _currentRowHeight = height; 227 _currentRowHeight = height;
227 228
228 return () { 229 style.setProperty("top", HtmlUtils.toPx(top));
229 style.setProperty("top", HtmlUtils.toPx(top)); 230 style.setProperty("height", HtmlUtils.toPx(height));
230 style.setProperty("height", HtmlUtils.toPx(height));
231 231
232 _innerMenuMoved(); 232 _innerMenuMoved();
233 };
234 }); 233 });
235 } 234 }
236 235
237 // Update the style buttons for the selected style. 236 // Update the style buttons for the selected style.
238 void updateStyleUI(Style style) { 237 void updateStyleUI(Style style) {
239 // Text format buttons 238 // Text format buttons
240 for (int i = 0; i < 4; i++) { 239 for (int i = 0; i < 4; i++) {
241 int mask = _textStyleValues[i]; 240 int mask = _textStyleValues[i];
242 _selectTextStyle(i, _textStyleClassNames[i], (style.textFormatIndex & mask ) != 0); 241 _selectTextStyle(i, _textStyleClassNames[i], (style.textFormatIndex & mask ) != 0);
243 } 242 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 for (int i = 0; i < 4; i++) { 416 for (int i = 0; i < 4; i++) {
418 if (_textStyleButtons[i].attributes["class"].length > 1) { 417 if (_textStyleButtons[i].attributes["class"].length > 1) {
419 textStyle += _textStyleValues[i]; 418 textStyle += _textStyleValues[i];
420 } 419 }
421 } 420 }
422 421
423 _execute(Style _(Style s, int selectedIndex) 422 _execute(Style _(Style s, int selectedIndex)
424 => s.setTextFormatByIndex(selectedIndex), textStyle); 423 => s.setTextFormatByIndex(selectedIndex), textStyle);
425 } 424 }
426 } 425 }
OLDNEW
« no previous file with comments | « client/samples/total/src/HtmlTable.dart ('k') | client/samples/total/src/SelectionManager.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698