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:mirrors'; | 9 import 'dart:mirrors'; |
10 import 'dart:sky' as sky; | 10 import 'dart:sky' as sky; |
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 | 536 |
537 Container({ | 537 Container({ |
538 Object key, | 538 Object key, |
539 List<UINode> children | 539 List<UINode> children |
540 }) : super( | 540 }) : super( |
541 key: key, | 541 key: key, |
542 children: children | 542 children: children |
543 ); | 543 ); |
544 } | 544 } |
545 | 545 |
546 class Paragraph extends OneChildListRenderNodeWrapper { | 546 class Paragraph extends RenderNodeWrapper { |
547 | 547 |
548 RenderCSSParagraph root; | 548 RenderParagraph root; |
549 RenderCSSParagraph createNode() => new RenderCSSParagraph(this); | 549 RenderParagraph createNode() => new RenderParagraph(text); |
| 550 String text; |
550 | 551 |
551 static final Paragraph _emptyContainer = new Paragraph(); | 552 static final Paragraph _emptyContainer = new Paragraph(); |
552 | 553 |
553 RenderNodeWrapper get emptyNode => _emptyContainer; | 554 RenderNodeWrapper get emptyNode => _emptyContainer; |
554 | 555 |
555 Paragraph({ | 556 Paragraph({ |
556 Object key, | 557 Object key, |
557 List<UINode> children | 558 this.text |
558 }) : super( | 559 }) : super( |
559 key: key, | 560 key: key |
560 children: children | |
561 ); | 561 ); |
| 562 |
| 563 void syncRenderNode(UINode old) { |
| 564 super.syncRenderNode(old); |
| 565 root.text = text; |
| 566 } |
562 } | 567 } |
563 | 568 |
564 class FlexContainer extends OneChildListRenderNodeWrapper { | 569 class FlexContainer extends OneChildListRenderNodeWrapper { |
565 | 570 |
566 RenderFlex root; | 571 RenderFlex root; |
567 RenderFlex createNode() => new RenderFlex(direction: this.direction); | 572 RenderFlex createNode() => new RenderFlex(direction: this.direction); |
568 | 573 |
569 static final FlexContainer _emptyContainer = new FlexContainer(); | 574 static final FlexContainer _emptyContainer = new FlexContainer(); |
570 // direction doesn't matter if it's empty | 575 // direction doesn't matter if it's empty |
571 | 576 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 root.child = child.root; | 644 root.child = child.root; |
640 } | 645 } |
641 | 646 |
642 void _remove() { | 647 void _remove() { |
643 assert(child != null); | 648 assert(child != null); |
644 removeChild(child); | 649 removeChild(child); |
645 super._remove(); | 650 super._remove(); |
646 } | 651 } |
647 } | 652 } |
648 | 653 |
649 class TextFragment extends RenderNodeWrapper { | |
650 | |
651 RenderCSSInline root; | |
652 RenderCSSInline createNode() => new RenderCSSInline(this, this.data); | |
653 | |
654 static final TextFragment _emptyText = new TextFragment(''); | |
655 | |
656 RenderNodeWrapper get emptyNode => _emptyText; | |
657 | |
658 final String data; | |
659 | |
660 TextFragment(this.data, { | |
661 Object key | |
662 }) : super( | |
663 key: key | |
664 ); | |
665 | |
666 void syncRenderNode(UINode old) { | |
667 super.syncRenderNode(old); | |
668 root.data = data; | |
669 } | |
670 } | |
671 | |
672 class Image extends RenderNodeWrapper { | 654 class Image extends RenderNodeWrapper { |
673 | 655 |
674 RenderCSSImage root; | 656 RenderCSSImage root; |
675 RenderCSSImage createNode() => new RenderCSSImage(this, this.src, this.width,
this.height); | 657 RenderCSSImage createNode() => new RenderCSSImage(this, this.src, this.width,
this.height); |
676 | 658 |
677 static final Image _emptyImage = new Image(); | 659 static final Image _emptyImage = new Image(); |
678 | 660 |
679 RenderNodeWrapper get emptyNode => _emptyImage; | 661 RenderNodeWrapper get emptyNode => _emptyImage; |
680 | 662 |
681 final String src; | 663 final String src; |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 if (root.parent == null) | 911 if (root.parent == null) |
930 _appView.root = root; | 912 _appView.root = root; |
931 assert(root.parent is RenderView); | 913 assert(root.parent is RenderView); |
932 } | 914 } |
933 } | 915 } |
934 | 916 |
935 class Text extends Component { | 917 class Text extends Component { |
936 Text(this.data) : super(key: '*text*'); | 918 Text(this.data) : super(key: '*text*'); |
937 final String data; | 919 final String data; |
938 bool get interchangeable => true; | 920 bool get interchangeable => true; |
939 UINode build() => new Paragraph(children: [new TextFragment(data)]); | 921 UINode build() => new Paragraph(text: data); |
940 } | 922 } |
941 | 923 |
942 | 924 |
943 // for now, but only for now: | 925 // for now, but only for now: |
944 | 926 |
945 class RenderSolidColor extends RenderDecoratedBox { | 927 class RenderSolidColor extends RenderDecoratedBox { |
946 final sky.Size desiredSize; | 928 final sky.Size desiredSize; |
947 final int backgroundColor; | 929 final int backgroundColor; |
948 | 930 |
949 RenderSolidColor(int backgroundColor, { this.desiredSize }) | 931 RenderSolidColor(int backgroundColor, { this.desiredSize }) |
(...skipping 28 matching lines...) Expand all Loading... |
978 | 960 |
979 final int color; | 961 final int color; |
980 | 962 |
981 RenderSolidColor root; | 963 RenderSolidColor root; |
982 RenderSolidColor createNode() => new RenderSolidColor(color, desiredSize: new
sky.Size(40.0, 130.0)); | 964 RenderSolidColor createNode() => new RenderSolidColor(color, desiredSize: new
sky.Size(40.0, 130.0)); |
983 | 965 |
984 static final Rectangle _emptyRectangle = new Rectangle(0); | 966 static final Rectangle _emptyRectangle = new Rectangle(0); |
985 RenderNodeWrapper get emptyNode => _emptyRectangle; | 967 RenderNodeWrapper get emptyNode => _emptyRectangle; |
986 | 968 |
987 } | 969 } |
OLD | NEW |