OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of polymer; | 5 part of polymer; |
6 | 6 |
7 /** | 7 /** |
8 * **Warning**: this class is experiental and subject to change. | 8 * **Warning**: this class is experiental and subject to change. |
9 * | 9 * |
10 * The implementation for the `polymer-element` element. | 10 * The implementation for the `polymer-element` element. |
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 * above Polymer. | 472 * above Polymer. |
473 */ | 473 */ |
474 // TODO(sjmiles): perf: reflection is slow, relatively speaking | 474 // TODO(sjmiles): perf: reflection is slow, relatively speaking |
475 // If an element may take 6us to create, getCustomPropertyNames might | 475 // If an element may take 6us to create, getCustomPropertyNames might |
476 // cost 1.6us more. | 476 // cost 1.6us more. |
477 void inferObservers(ClassMirror cls) { | 477 void inferObservers(ClassMirror cls) { |
478 for (var method in cls.methods.values) { | 478 for (var method in cls.methods.values) { |
479 if (method.isStatic || !method.isRegularMethod) continue; | 479 if (method.isStatic || !method.isRegularMethod) continue; |
480 | 480 |
481 String name = MirrorSystem.getName(method.simpleName); | 481 String name = MirrorSystem.getName(method.simpleName); |
482 if (name.endsWith('Changed')) { | 482 if (name.endsWith(_OBSERVE_SUFFIX) && name != 'attributeChanged') { |
483 if (_observe == null) _observe = {}; | 483 if (_observe == null) _observe = {}; |
484 name = name.substring(0, name.length - 7); | 484 name = name.substring(0, name.length - 7); |
485 _observe[name] = method.simpleName; | 485 _observe[name] = method.simpleName; |
486 } | 486 } |
487 } | 487 } |
488 } | 488 } |
489 | 489 |
490 void publishProperties(Type type) { | 490 void publishProperties(Type type) { |
491 // Dart note: _publish was already populated by publishAttributes | 491 // Dart note: _publish was already populated by publishAttributes |
492 if (_publish != null) _publishLC = _lowerCaseMap(_publish); | 492 if (_publish != null) _publishLC = _lowerCaseMap(_publish); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 var attr = style.attributes[_STYLE_SCOPE_ATTRIBUTE]; | 631 var attr = style.attributes[_STYLE_SCOPE_ATTRIBUTE]; |
632 if (attr != null) { | 632 if (attr != null) { |
633 clone.attributes[_STYLE_SCOPE_ATTRIBUTE] = attr; | 633 clone.attributes[_STYLE_SCOPE_ATTRIBUTE] = attr; |
634 } | 634 } |
635 | 635 |
636 scope.append(clone); | 636 scope.append(clone); |
637 } | 637 } |
638 | 638 |
639 String _cssTextFromSheet(Element sheet) { | 639 String _cssTextFromSheet(Element sheet) { |
640 if (sheet == null || js.context == null) return ''; | 640 if (sheet == null || js.context == null) return ''; |
641 var resource = new JsObject.fromBrowserObject(sheet)['__resource']; | 641 var resource = new js.JsObject.fromBrowserObject(sheet)['__resource']; |
642 return resource != null ? resource : ''; | 642 return resource != null ? resource : ''; |
643 } | 643 } |
644 | 644 |
645 const _OBSERVE_SUFFIX = 'Changed'; | 645 const _OBSERVE_SUFFIX = 'Changed'; |
646 | 646 |
647 // TODO(jmesserly): is this list complete? | 647 // TODO(jmesserly): is this list complete? |
648 final _eventTranslations = const { | 648 final _eventTranslations = const { |
649 // TODO(jmesserly): these three Polymer.js translations won't work in Dart, | 649 // TODO(jmesserly): these three Polymer.js translations won't work in Dart, |
650 // because we strip the webkit prefix (below). Reconcile. | 650 // because we strip the webkit prefix (below). Reconcile. |
651 'webkitanimationstart': 'webkitAnimationStart', | 651 'webkitanimationstart': 'webkitAnimationStart', |
(...skipping 25 matching lines...) Expand all Loading... |
677 return map; | 677 return map; |
678 }(); | 678 }(); |
679 | 679 |
680 // Dart note: we need this function because we have additional renames JS does | 680 // Dart note: we need this function because we have additional renames JS does |
681 // not have. The JS renames are simply case differences, whereas we have ones | 681 // not have. The JS renames are simply case differences, whereas we have ones |
682 // like doubleclick -> dblclick and stripping the webkit prefix. | 682 // like doubleclick -> dblclick and stripping the webkit prefix. |
683 String _eventNameFromType(String eventType) { | 683 String _eventNameFromType(String eventType) { |
684 final result = _reverseEventTranslations[eventType]; | 684 final result = _reverseEventTranslations[eventType]; |
685 return result != null ? result : eventType; | 685 return result != null ? result : eventType; |
686 } | 686 } |
OLD | NEW |