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

Side by Side Diff: pkg/polymer/lib/src/declaration.dart

Issue 76013002: "Reverting 30387" -- failures on IE (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 | « pkg/polymer/lib/src/build/linter.dart ('k') | pkg/polymer/test/build/linter_test.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) 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 * Takes external stylesheets loaded in an `<element>` element and moves 358 * Takes external stylesheets loaded in an `<element>` element and moves
359 * their content into a style element inside the `<element>`'s template. 359 * their content into a style element inside the `<element>`'s template.
360 * The sheet is then removed from the `<element>`. This is done only so 360 * The sheet is then removed from the `<element>`. This is done only so
361 * that if the element is loaded in the main document, the sheet does 361 * that if the element is loaded in the main document, the sheet does
362 * not become active. 362 * not become active.
363 * Note, ignores sheets with the attribute 'polymer-scope'. 363 * Note, ignores sheets with the attribute 'polymer-scope'.
364 */ 364 */
365 void installLocalSheets() { 365 void installLocalSheets() {
366 var sheets = this.sheets.where( 366 var sheets = this.sheets.where(
367 (s) => !s.attributes.containsKey(_SCOPE_ATTR)); 367 (s) => !s.attributes.containsKey(_SCOPE_ATTR));
368 var content = templateContent; 368 var content = this.templateContent;
369 if (content != null) { 369 if (content != null) {
370 var cssText = new StringBuffer(); 370 var cssText = new StringBuffer();
371 for (var sheet in sheets) { 371 for (var sheet in sheets) {
372 cssText..write(_cssTextFromSheet(sheet))..write('\n'); 372 cssText..write(_cssTextFromSheet(sheet))..write('\n');
373 } 373 }
374 if (cssText.length > 0) { 374 if (cssText.length > 0) {
375 content.insertBefore( 375 content.insertBefore(
376 new StyleElement()..text = '$cssText', 376 new StyleElement()..text = '$cssText',
377 content.firstChild); 377 content.firstChild);
378 } 378 }
379 } 379 }
380 } 380 }
381 381
382 List<Element> findNodes(String selector, [bool matcher(Element e)]) { 382 List<Element> findNodes(String selector, [bool matcher(Element e)]) {
383 var nodes = this.querySelectorAll(selector).toList(); 383 var nodes = this.queryAll(selector).toList();
384 var content = templateContent; 384 var content = this.templateContent;
385 if (content != null) { 385 if (content != null) {
386 nodes = nodes..addAll(content.queryAll(selector)); 386 nodes = nodes..addAll(content.queryAll(selector));
387 } 387 }
388 if (matcher != null) return nodes.where(matcher).toList(); 388 if (matcher != null) return nodes.where(matcher).toList();
389 return nodes; 389 return nodes;
390 } 390 }
391 391
392 /** 392 /**
393 * Promotes external stylesheets and style elements with the attribute 393 * Promotes external stylesheets and style elements with the attribute
394 * polymer-scope='global' into global scope. 394 * polymer-scope='global' into global scope.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 shadowCss.callMethod('shimStyling', [template, name, extendee]); 563 shadowCss.callMethod('shimStyling', [template, name, extendee]);
564 } 564 }
565 565
566 const _STYLE_SELECTOR = 'style'; 566 const _STYLE_SELECTOR = 'style';
567 const _SHEET_SELECTOR = '[rel=stylesheet]'; 567 const _SHEET_SELECTOR = '[rel=stylesheet]';
568 const _STYLE_GLOBAL_SCOPE = 'global'; 568 const _STYLE_GLOBAL_SCOPE = 'global';
569 const _SCOPE_ATTR = 'polymer-scope'; 569 const _SCOPE_ATTR = 'polymer-scope';
570 const _STYLE_SCOPE_ATTRIBUTE = 'element'; 570 const _STYLE_SCOPE_ATTRIBUTE = 'element';
571 const _STYLE_CONTROLLER_SCOPE = 'controller'; 571 const _STYLE_CONTROLLER_SCOPE = 'controller';
572 572
573 String _cssTextFromSheet(LinkElement sheet) { 573 String _cssTextFromSheet(Element sheet) {
574 if (sheet == null) return ''; 574 if (sheet == null || js.context == null) return '';
575 575 var resource = new js.JsObject.fromBrowserObject(sheet)['__resource'];
576 // TODO(jmesserly): sometimes the href property is wrong after deployment. 576 return resource != null ? resource : '';
577 var href = sheet.href;
578 if (href == '') href = sheet.attributes["href"];
579
580 if (js.context != null && js.context.hasProperty('HTMLImports')) {
581 var jsSheet = new js.JsObject.fromBrowserObject(sheet);
582 var resource = jsSheet['__resource'];
583 if (resource != null) return resource;
584 _sheetLog.fine('failed to get stylesheet text href="$href"');
585 return '';
586 }
587 // TODO(jmesserly): it seems like polymer-js is always polyfilling
588 // HTMLImports, because their code depends on "__resource" to work.
589 // We work around this by using a sync XHR to get the stylesheet text.
590 // Right now this code is only used in Dartium, but if it's going to stick
591 // around we will need to find a different approach.
592 try {
593 return (new HttpRequest()
594 ..open('GET', href, async: false)
595 ..send())
596 .responseText;
597 } on DomException catch (e, t) {
598 _sheetLog.fine('failed to get stylesheet text href="$href" error: '
599 '$e, trace: $t');
600 return '';
601 }
602 } 577 }
603 578
604 final Logger _sheetLog = new Logger('polymer.stylesheet');
605
606 const _OBSERVE_SUFFIX = 'Changed'; 579 const _OBSERVE_SUFFIX = 'Changed';
607 580
608 // TODO(jmesserly): is this list complete? 581 // TODO(jmesserly): is this list complete?
609 final _eventTranslations = const { 582 final _eventTranslations = const {
610 // TODO(jmesserly): these three Polymer.js translations won't work in Dart, 583 // TODO(jmesserly): these three Polymer.js translations won't work in Dart,
611 // because we strip the webkit prefix (below). Reconcile. 584 // because we strip the webkit prefix (below). Reconcile.
612 'webkitanimationstart': 'webkitAnimationStart', 585 'webkitanimationstart': 'webkitAnimationStart',
613 'webkitanimationend': 'webkitAnimationEnd', 586 'webkitanimationend': 'webkitAnimationEnd',
614 'webkittransitionend': 'webkitTransitionEnd', 587 'webkittransitionend': 'webkitTransitionEnd',
615 588
(...skipping 22 matching lines...) Expand all
638 return map; 611 return map;
639 }(); 612 }();
640 613
641 // Dart note: we need this function because we have additional renames JS does 614 // Dart note: we need this function because we have additional renames JS does
642 // not have. The JS renames are simply case differences, whereas we have ones 615 // not have. The JS renames are simply case differences, whereas we have ones
643 // like doubleclick -> dblclick and stripping the webkit prefix. 616 // like doubleclick -> dblclick and stripping the webkit prefix.
644 String _eventNameFromType(String eventType) { 617 String _eventNameFromType(String eventType) {
645 final result = _reverseEventTranslations[eventType]; 618 final result = _reverseEventTranslations[eventType];
646 return result != null ? result : eventType; 619 return result != null ? result : eventType;
647 } 620 }
OLDNEW
« no previous file with comments | « pkg/polymer/lib/src/build/linter.dart ('k') | pkg/polymer/test/build/linter_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698