OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 Loading... |
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 final firstCellRect = firstCell.rect; | 50 window.requestMeasurementFrame(() { |
51 final style = firstCell.computedStyle; | 51 final firstCellRect = firstCell.rect; |
52 window.requestLayoutFrame(() { | 52 final style = firstCell.computedStyle; |
53 int height = firstCellRect.value.client.height | 53 |
54 - HtmlUtils.fromPx(style.value.getPropertyValue('padding-top')) | 54 int height = firstCell.rect.client.height |
55 - HtmlUtils.fromPx(style.value.getPropertyValue('padding-bottom')); | 55 - HtmlUtils.fromPx(style.paddingTop) |
56 firstCell.style.setProperty('height', HtmlUtils.toPx(height)); | 56 - HtmlUtils.fromPx(style.paddingBottom); |
| 57 return () { firstCell.style.height = HtmlUtils.toPx(height); }; |
57 }); | 58 }); |
58 } | 59 } |
59 | 60 |
60 // Reverses the damage done by _pinHeight. | 61 // Reverses the damage done by _pinHeight. |
61 static void _unpinHeight(TableRowElement row) { | 62 static void _unpinHeight(TableRowElement row) { |
62 Element firstCell = row.cells[0]; | 63 Element firstCell = row.cells[0]; |
63 firstCell.style.removeProperty('height'); | 64 firstCell.style.removeProperty('height'); |
64 } | 65 } |
65 | 66 |
66 ColorPicker _backgroundColorPicker; | 67 ColorPicker _backgroundColorPicker; |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 bool isAttachedTo(TableRowElement row) => _row == row; | 206 bool isAttachedTo(TableRowElement row) => _row == row; |
206 | 207 |
207 void updateSize() { | 208 void updateSize() { |
208 if (_row.parent == null) { | 209 if (_row.parent == null) { |
209 // The row we were attached to has disappeared (e.g., by scrolling), so cl
ean up the menu bar | 210 // The row we were attached to has disappeared (e.g., by scrolling), so cl
ean up the menu bar |
210 _bar.remove(); | 211 _bar.remove(); |
211 return; | 212 return; |
212 } | 213 } |
213 | 214 |
214 // Must take into account the top of the table due to scrolling. | 215 // Must take into account the top of the table due to scrolling. |
215 final offsetParentRect = _row.offsetParent.rect; | 216 window.requestMeasurementFrame(() { |
216 final rowRect = _row.rect; | 217 int tableTop = _row.offsetParent.rect.bounding.top.toInt(); |
217 window.requestLayoutFrame(() { | |
218 int tableTop = offsetParentRect.value.bounding.top.toInt(); | |
219 | 218 |
220 // Get the current bounding box of the row we're attached to. | 219 // Get the current bounding box of the row we're attached to. |
221 ClientRect boundingRowRect = rowRect.value.bounding; | 220 ClientRect boundingRowRect = _row.rect.bounding; |
222 CSSStyleDeclaration style = _bar.style; | 221 CSSStyleDeclaration style = _bar.style; |
223 | 222 |
224 int top = boundingRowRect.top.toInt() + _initialRowHeight - tableTop; | 223 int top = boundingRowRect.top.toInt() + _initialRowHeight - tableTop; |
225 int height = boundingRowRect.height.toInt() - _initialRowHeight; | 224 int height = boundingRowRect.height.toInt() - _initialRowHeight; |
226 | 225 |
227 _currentRowHeight = height; | 226 _currentRowHeight = height; |
228 | 227 |
229 style.setProperty("top", HtmlUtils.toPx(top)); | 228 return () { |
230 style.setProperty("height", HtmlUtils.toPx(height)); | 229 style.setProperty("top", HtmlUtils.toPx(top)); |
| 230 style.setProperty("height", HtmlUtils.toPx(height)); |
231 | 231 |
232 _innerMenuMoved(); | 232 _innerMenuMoved(); |
| 233 }; |
233 }); | 234 }); |
234 } | 235 } |
235 | 236 |
236 // Update the style buttons for the selected style. | 237 // Update the style buttons for the selected style. |
237 void updateStyleUI(Style style) { | 238 void updateStyleUI(Style style) { |
238 // Text format buttons | 239 // Text format buttons |
239 for (int i = 0; i < 4; i++) { | 240 for (int i = 0; i < 4; i++) { |
240 int mask = _textStyleValues[i]; | 241 int mask = _textStyleValues[i]; |
241 _selectTextStyle(i, _textStyleClassNames[i], (style.textFormatIndex & mask
) != 0); | 242 _selectTextStyle(i, _textStyleClassNames[i], (style.textFormatIndex & mask
) != 0); |
242 } | 243 } |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 for (int i = 0; i < 4; i++) { | 417 for (int i = 0; i < 4; i++) { |
417 if (_textStyleButtons[i].attributes["class"].length > 1) { | 418 if (_textStyleButtons[i].attributes["class"].length > 1) { |
418 textStyle += _textStyleValues[i]; | 419 textStyle += _textStyleValues[i]; |
419 } | 420 } |
420 } | 421 } |
421 | 422 |
422 _execute(Style _(Style s, int selectedIndex) | 423 _execute(Style _(Style s, int selectedIndex) |
423 => s.setTextFormatByIndex(selectedIndex), textStyle); | 424 => s.setTextFormatByIndex(selectedIndex), textStyle); |
424 } | 425 } |
425 } | 426 } |
OLD | NEW |