 Chromium Code Reviews
 Chromium Code Reviews Issue 1003553002:
  Update Button to be made of Material  (Closed) 
  Base URL: git@github.com:domokit/mojo.git@master
    
  
    Issue 1003553002:
  Update Button to be made of Material  (Closed) 
  Base URL: git@github.com:domokit/mojo.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 library fn; | 5 library fn; | 
| 6 | 6 | 
| 7 import 'dart:async'; | 7 import 'dart:async'; | 
| 8 import 'dart:collection'; | 8 import 'dart:collection'; | 
| 9 import 'dart:sky' as sky; | 9 import 'dart:sky' as sky; | 
| 10 import 'reflect.dart' as reflect; | 10 import 'reflect.dart' as reflect; | 
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 | 128 | 
| 129 abstract class Element extends Node { | 129 abstract class Element extends Node { | 
| 130 | 130 | 
| 131 String get _tagName; | 131 String get _tagName; | 
| 132 | 132 | 
| 133 Element get _emptyElement; | 133 Element get _emptyElement; | 
| 134 | 134 | 
| 135 String inlineStyle; | 135 String inlineStyle; | 
| 136 | 136 | 
| 137 List<Node> _children = null; | 137 List<Node> _children = null; | 
| 138 String _className = ''; | 138 String _class = ''; | 
| 139 | 139 | 
| 140 Element({ | 140 Element({ | 
| 141 Object key, | 141 Object key, | 
| 142 List<Node> children, | 142 List<Node> children, | 
| 143 Style style, | 143 List<Style> styles, | 
| 144 | 144 | 
| 145 this.inlineStyle | 145 this.inlineStyle | 
| 146 }) : super(key:key) { | 146 }) : super(key:key) { | 
| 147 _class = ''; | |
| 
rafaelw
2015/03/11 21:17:15
bit:
_class = styles == null ? '' : styles.map((s
 
abarth-chromium
2015/03/11 21:20:05
Done.
 | |
| 148 if (styles != null) { | |
| 149 for (Style style in styles) { | |
| 150 _class += ' ' + style._className; | |
| 151 } | |
| 152 } | |
| 147 | 153 | 
| 148 _className = style == null ? '': style._className; | |
| 149 _children = children == null ? _emptyList : children; | 154 _children = children == null ? _emptyList : children; | 
| 150 | 155 | 
| 151 if (_isInCheckedMode) { | 156 if (_isInCheckedMode) { | 
| 152 _debugReportDuplicateIds(); | 157 _debugReportDuplicateIds(); | 
| 153 } | 158 } | 
| 154 } | 159 } | 
| 155 | 160 | 
| 156 void _remove() { | 161 void _remove() { | 
| 157 super._remove(); | 162 super._remove(); | 
| 158 if (_children != null) { | 163 if (_children != null) { | 
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 } | 227 } | 
| 223 | 228 | 
| 224 void _syncNode([Element old]) { | 229 void _syncNode([Element old]) { | 
| 225 if (old == null) { | 230 if (old == null) { | 
| 226 old = _emptyElement; | 231 old = _emptyElement; | 
| 227 } | 232 } | 
| 228 | 233 | 
| 229 _syncEvents(old); | 234 _syncEvents(old); | 
| 230 | 235 | 
| 231 sky.Element root = _root as sky.Element; | 236 sky.Element root = _root as sky.Element; | 
| 232 if (_className != old._className) { | 237 if (_class != old._class) { | 
| 233 root.setAttribute('class', _className); | 238 root.setAttribute('class', _class); | 
| 234 } | 239 } | 
| 235 | 240 | 
| 236 if (inlineStyle != old.inlineStyle) { | 241 if (inlineStyle != old.inlineStyle) { | 
| 237 root.setAttribute('style', inlineStyle); | 242 root.setAttribute('style', inlineStyle); | 
| 238 } | 243 } | 
| 239 } | 244 } | 
| 240 | 245 | 
| 241 bool _sync(Node old, sky.ParentNode host, sky.Node insertBefore) { | 246 bool _sync(Node old, sky.ParentNode host, sky.Node insertBefore) { | 
| 242 // print("---Syncing children of $_key"); | 247 // print("---Syncing children of $_key"); | 
| 243 | 248 | 
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 406 class Container extends Element { | 411 class Container extends Element { | 
| 407 | 412 | 
| 408 String get _tagName => 'div'; | 413 String get _tagName => 'div'; | 
| 409 | 414 | 
| 410 static final Container _emptyContainer = new Container(); | 415 static final Container _emptyContainer = new Container(); | 
| 411 Element get _emptyElement => _emptyContainer; | 416 Element get _emptyElement => _emptyContainer; | 
| 412 | 417 | 
| 413 Container({ | 418 Container({ | 
| 414 Object key, | 419 Object key, | 
| 415 List<Node> children, | 420 List<Node> children, | 
| 416 Style style, | 421 List<Style> styles, | 
| 417 String inlineStyle | 422 String inlineStyle | 
| 418 }) : super( | 423 }) : super( | 
| 419 key: key, | 424 key: key, | 
| 420 children: children, | 425 children: children, | 
| 421 style: style, | 426 styles: styles, | 
| 422 inlineStyle: inlineStyle | 427 inlineStyle: inlineStyle | 
| 423 ); | 428 ); | 
| 424 } | 429 } | 
| 425 | 430 | 
| 426 class Image extends Element { | 431 class Image extends Element { | 
| 427 | 432 | 
| 428 String get _tagName => 'img'; | 433 String get _tagName => 'img'; | 
| 429 | 434 | 
| 430 static final Image _emptyImage = new Image(); | 435 static final Image _emptyImage = new Image(); | 
| 431 Element get _emptyElement => _emptyImage; | 436 Element get _emptyElement => _emptyImage; | 
| 432 | 437 | 
| 433 String src; | 438 String src; | 
| 434 int width; | 439 int width; | 
| 435 int height; | 440 int height; | 
| 436 | 441 | 
| 437 Image({ | 442 Image({ | 
| 438 Object key, | 443 Object key, | 
| 439 List<Node> children, | 444 List<Node> children, | 
| 440 Style style, | 445 List<Style> styles, | 
| 441 String inlineStyle, | 446 String inlineStyle, | 
| 442 this.width, | 447 this.width, | 
| 443 this.height, | 448 this.height, | 
| 444 this.src | 449 this.src | 
| 445 }) : super( | 450 }) : super( | 
| 446 key: key, | 451 key: key, | 
| 447 children: children, | 452 children: children, | 
| 448 style: style, | 453 styles: styles, | 
| 449 inlineStyle: inlineStyle | 454 inlineStyle: inlineStyle | 
| 450 ); | 455 ); | 
| 451 | 456 | 
| 452 void _syncNode([Element old]) { | 457 void _syncNode([Element old]) { | 
| 453 super._syncNode(old); | 458 super._syncNode(old); | 
| 454 | 459 | 
| 455 Image oldImage = old != null ? old : _emptyImage; | 460 Image oldImage = old != null ? old : _emptyImage; | 
| 456 sky.HTMLImageElement skyImage = _root as sky.HTMLImageElement; | 461 sky.HTMLImageElement skyImage = _root as sky.HTMLImageElement; | 
| 457 if (src != oldImage.src) { | 462 if (src != oldImage.src) { | 
| 458 skyImage.src = src; | 463 skyImage.src = src; | 
| (...skipping 15 matching lines...) Expand all Loading... | |
| 474 static final Anchor _emptyAnchor = new Anchor(); | 479 static final Anchor _emptyAnchor = new Anchor(); | 
| 475 Element get _emptyElement => _emptyAnchor; | 480 Element get _emptyElement => _emptyAnchor; | 
| 476 | 481 | 
| 477 String href; | 482 String href; | 
| 478 int width; | 483 int width; | 
| 479 int height; | 484 int height; | 
| 480 | 485 | 
| 481 Anchor({ | 486 Anchor({ | 
| 482 Object key, | 487 Object key, | 
| 483 List<Node> children, | 488 List<Node> children, | 
| 484 Style style, | 489 List<Style> styles, | 
| 485 String inlineStyle, | 490 String inlineStyle, | 
| 486 this.width, | 491 this.width, | 
| 487 this.height, | 492 this.height, | 
| 488 this.href | 493 this.href | 
| 489 }) : super( | 494 }) : super( | 
| 490 key: key, | 495 key: key, | 
| 491 children: children, | 496 children: children, | 
| 492 style: style, | 497 styles: styles, | 
| 493 inlineStyle: inlineStyle | 498 inlineStyle: inlineStyle | 
| 494 ); | 499 ); | 
| 495 | 500 | 
| 496 void _syncNode([Element old]) { | 501 void _syncNode([Element old]) { | 
| 497 Anchor oldAnchor = old != null ? old as Anchor : _emptyAnchor; | 502 Anchor oldAnchor = old != null ? old as Anchor : _emptyAnchor; | 
| 498 super._syncNode(oldAnchor); | 503 super._syncNode(oldAnchor); | 
| 499 | 504 | 
| 500 sky.HTMLAnchorElement skyAnchor = _root as sky.HTMLAnchorElement; | 505 sky.HTMLAnchorElement skyAnchor = _root as sky.HTMLAnchorElement; | 
| 501 if (href != oldAnchor.href) { | 506 if (href != oldAnchor.href) { | 
| 502 skyAnchor.href = href; | 507 skyAnchor.href = href; | 
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 | 684 | 
| 680 _sync(null, _host, null); | 685 _sync(null, _host, null); | 
| 681 assert(_root is sky.Node); | 686 assert(_root is sky.Node); | 
| 682 | 687 | 
| 683 sw.stop(); | 688 sw.stop(); | 
| 684 if (_shouldLogRenderDuration) | 689 if (_shouldLogRenderDuration) | 
| 685 print("Initial build: ${sw.elapsedMicroseconds} microseconds"); | 690 print("Initial build: ${sw.elapsedMicroseconds} microseconds"); | 
| 686 }); | 691 }); | 
| 687 } | 692 } | 
| 688 } | 693 } | 
| OLD | NEW |