| OLD | NEW |
| 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 // 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>[ |
| (...skipping 29 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 CSSStyleDeclaration s = window.getComputedStyle(firstCell, ""); | 50 final firstCellRect = firstCell.rect; |
| 51 int height = firstCell.clientHeight | 51 final style = firstCell.computedStyle; |
| 52 - HtmlUtils.fromPx(s.getPropertyValue('padding-top')) | 52 window.requestLayoutFrame(() { |
| 53 - HtmlUtils.fromPx(s.getPropertyValue('padding-bottom')); | 53 int height = firstCellRect.value.client.height |
| 54 firstCell.style.setProperty('height', HtmlUtils.toPx(height)); | 54 - HtmlUtils.fromPx(style.value.getPropertyValue('padding-top')) |
| 55 - HtmlUtils.fromPx(style.value.getPropertyValue('padding-bottom')); |
| 56 firstCell.style.setProperty('height', HtmlUtils.toPx(height)); |
| 57 }); |
| 55 } | 58 } |
| 56 | 59 |
| 57 // Reverses the damage done by _pinHeight. | 60 // Reverses the damage done by _pinHeight. |
| 58 static void _unpinHeight(TableRowElement row) { | 61 static void _unpinHeight(TableRowElement row) { |
| 59 Element firstCell = row.cells[0]; | 62 Element firstCell = row.cells[0]; |
| 60 firstCell.style.removeProperty('height'); | 63 firstCell.style.removeProperty('height'); |
| 61 } | 64 } |
| 62 | 65 |
| 63 ColorPicker _backgroundColorPicker; | 66 ColorPicker _backgroundColorPicker; |
| 64 // The interior UI of the menu. | 67 // The interior UI of the menu. |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 bool isAttachedTo(TableRowElement row) => _row == row; | 205 bool isAttachedTo(TableRowElement row) => _row == row; |
| 203 | 206 |
| 204 void updateSize() { | 207 void updateSize() { |
| 205 if (_row.parent == null) { | 208 if (_row.parent == null) { |
| 206 // 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 |
| 207 _bar.remove(); | 210 _bar.remove(); |
| 208 return; | 211 return; |
| 209 } | 212 } |
| 210 | 213 |
| 211 // 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. |
| 212 int tableTop = _row.offsetParent.getBoundingClientRect().top.toInt(); | 215 final offsetParentRect = _row.offsetParent.rect; |
| 216 final rowRect = _row.rect; |
| 217 window.requestLayoutFrame(() { |
| 218 int tableTop = offsetParentRect.value.bounding.top.toInt(); |
| 213 | 219 |
| 214 // 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. |
| 215 ClientRect rowRect = _row.getBoundingClientRect(); | 221 ClientRect boundingRowRect = rowRect.value.bounding; |
| 216 CSSStyleDeclaration style = _bar.style; | 222 CSSStyleDeclaration style = _bar.style; |
| 217 | 223 |
| 218 int top = rowRect.top.toInt() + _initialRowHeight - tableTop; | 224 int top = boundingRowRect.top.toInt() + _initialRowHeight - tableTop; |
| 219 int height = rowRect.height.toInt() - _initialRowHeight; | 225 int height = boundingRowRect.height.toInt() - _initialRowHeight; |
| 220 | 226 |
| 221 _currentRowHeight = height; | 227 _currentRowHeight = height; |
| 222 | 228 |
| 223 style.setProperty("top", HtmlUtils.toPx(top)); | 229 style.setProperty("top", HtmlUtils.toPx(top)); |
| 224 style.setProperty("height", HtmlUtils.toPx(height)); | 230 style.setProperty("height", HtmlUtils.toPx(height)); |
| 225 | 231 |
| 226 _innerMenuMoved(); | 232 _innerMenuMoved(); |
| 233 }); |
| 227 } | 234 } |
| 228 | 235 |
| 229 // Update the style buttons for the selected style. | 236 // Update the style buttons for the selected style. |
| 230 void updateStyleUI(Style style) { | 237 void updateStyleUI(Style style) { |
| 231 // Text format buttons | 238 // Text format buttons |
| 232 for (int i = 0; i < 4; i++) { | 239 for (int i = 0; i < 4; i++) { |
| 233 int mask = _textStyleValues[i]; | 240 int mask = _textStyleValues[i]; |
| 234 _selectTextStyle(i, _textStyleClassNames[i], (style.textFormatIndex & mask
) != 0); | 241 _selectTextStyle(i, _textStyleClassNames[i], (style.textFormatIndex & mask
) != 0); |
| 235 } | 242 } |
| 236 | 243 |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 for (int i = 0; i < 4; i++) { | 416 for (int i = 0; i < 4; i++) { |
| 410 if (_textStyleButtons[i].attributes["class"].length > 1) { | 417 if (_textStyleButtons[i].attributes["class"].length > 1) { |
| 411 textStyle += _textStyleValues[i]; | 418 textStyle += _textStyleValues[i]; |
| 412 } | 419 } |
| 413 } | 420 } |
| 414 | 421 |
| 415 _execute(Style _(Style s, int selectedIndex) | 422 _execute(Style _(Style s, int selectedIndex) |
| 416 => s.setTextFormatByIndex(selectedIndex), textStyle); | 423 => s.setTextFormatByIndex(selectedIndex), textStyle); |
| 417 } | 424 } |
| 418 } | 425 } |
| OLD | NEW |