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 import 'dart:sky' as sky; | 5 import 'dart:sky' as sky; |
6 | 6 |
7 import 'package:vector_math/vector_math.dart'; | 7 import 'package:vector_math/vector_math.dart'; |
8 | 8 |
9 import '../painting/text_style.dart'; | 9 import '../painting/text_style.dart'; |
10 import '../rendering/block.dart'; | 10 import '../rendering/block.dart'; |
11 import '../rendering/box.dart'; | 11 import '../rendering/box.dart'; |
12 import '../rendering/flex.dart'; | 12 import '../rendering/flex.dart'; |
13 import '../rendering/object.dart'; | 13 import '../rendering/object.dart'; |
14 import '../rendering/paragraph.dart'; | 14 import '../rendering/paragraph.dart'; |
15 import '../rendering/stack.dart'; | 15 import '../rendering/stack.dart'; |
| 16 import 'default_text_style.dart'; |
16 import 'widget.dart'; | 17 import 'widget.dart'; |
17 | 18 |
18 export '../rendering/box.dart' show BoxConstraints, BoxDecoration, Border, Borde
rSide, EdgeDims; | 19 export '../rendering/box.dart' show BoxConstraints, BoxDecoration, Border, Borde
rSide, EdgeDims; |
19 export '../rendering/flex.dart' show FlexDirection, FlexJustifyContent, FlexAlig
nItems; | 20 export '../rendering/flex.dart' show FlexDirection, FlexJustifyContent, FlexAlig
nItems; |
20 export '../rendering/object.dart' show Point, Size, Rect, Color, Paint, Path; | 21 export '../rendering/object.dart' show Point, Size, Rect, Color, Paint, Path; |
21 export 'widget.dart' show Widget, Component, App, runApp, Listener, ParentDataNo
de; | 22 export 'widget.dart' show Widget, Component, App, runApp, Listener, ParentDataNo
de; |
22 | 23 |
23 | 24 |
24 // PAINTING NODES | 25 // PAINTING NODES |
25 | 26 |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 } | 404 } |
404 } | 405 } |
405 | 406 |
406 class Text extends Component { | 407 class Text extends Component { |
407 Text(this.data, { String key, TextStyle this.style }) : super(key: key); | 408 Text(this.data, { String key, TextStyle this.style }) : super(key: key); |
408 final String data; | 409 final String data; |
409 final TextStyle style; | 410 final TextStyle style; |
410 bool get interchangeable => true; | 411 bool get interchangeable => true; |
411 Widget build() { | 412 Widget build() { |
412 InlineBase text = new InlineText(data); | 413 InlineBase text = new InlineText(data); |
413 if (style != null) text = new InlineStyle(style, [text]); | 414 TextStyle defaultStyle = DefaultTextStyle.of(this); |
| 415 TextStyle combinedStyle; |
| 416 if (defaultStyle != null) { |
| 417 if (style != null) |
| 418 combinedStyle = defaultStyle.merge(style); |
| 419 else |
| 420 combinedStyle = defaultStyle; |
| 421 } else { |
| 422 combinedStyle = style; |
| 423 } |
| 424 if (combinedStyle != null) |
| 425 text = new InlineStyle(combinedStyle, [text]); |
414 return new Inline(text: text); | 426 return new Inline(text: text); |
415 } | 427 } |
416 } | 428 } |
417 | 429 |
418 class Image extends LeafRenderObjectWrapper { | 430 class Image extends LeafRenderObjectWrapper { |
419 | 431 |
420 Image({ | 432 Image({ |
421 src, | 433 src, |
422 this.size | 434 this.size |
423 }) : src = src, | 435 }) : src = src, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 } | 471 } |
460 | 472 |
461 void remove() { | 473 void remove() { |
462 RenderObjectWrapper ancestor = findAncestor(RenderObjectWrapper); | 474 RenderObjectWrapper ancestor = findAncestor(RenderObjectWrapper); |
463 assert(ancestor is RenderObjectWrapper); | 475 assert(ancestor is RenderObjectWrapper); |
464 ancestor.detachChildRoot(this); | 476 ancestor.detachChildRoot(this); |
465 super.remove(); | 477 super.remove(); |
466 } | 478 } |
467 | 479 |
468 } | 480 } |
OLD | NEW |