| 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 'box.dart'; | 7 import 'box.dart'; |
| 8 import 'object.dart'; | 8 import 'object.dart'; |
| 9 | 9 |
| 10 enum FontWeight { | 10 enum FontWeight { |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 if (fontWeight != null) | 96 if (fontWeight != null) |
| 97 result.add('${prefix}fontWeight: $fontWeight'); | 97 result.add('${prefix}fontWeight: $fontWeight'); |
| 98 if (textAlign != null) | 98 if (textAlign != null) |
| 99 result.add('${prefix}textAlign: $textAlign'); | 99 result.add('${prefix}textAlign: $textAlign'); |
| 100 if (result.isEmpty) | 100 if (result.isEmpty) |
| 101 return '${prefix}<no style specified>'; | 101 return '${prefix}<no style specified>'; |
| 102 return result.join('\n'); | 102 return result.join('\n'); |
| 103 } | 103 } |
| 104 } | 104 } |
| 105 | 105 |
| 106 class InlineBase { | 106 abstract class InlineBase { |
| 107 sky.Node _toDOM(sky.Document owner); | 107 sky.Node _toDOM(sky.Document owner); |
| 108 String toString([String prefix = '']); | 108 String toString([String prefix = '']); |
| 109 } | 109 } |
| 110 | 110 |
| 111 class InlineText extends InlineBase { | 111 class InlineText extends InlineBase { |
| 112 InlineText(this.text) { | 112 InlineText(this.text) { |
| 113 assert(text != null); | 113 assert(text != null); |
| 114 } | 114 } |
| 115 | 115 |
| 116 final String text; | 116 final String text; |
| 117 | 117 |
| 118 sky.Node _toDOM(sky.Document owner) { | 118 sky.Node _toDOM(sky.Document owner) { |
| 119 return owner.createText(text); | 119 return owner.createText(text); |
| 120 } | 120 } |
| 121 | 121 |
| 122 String toString([String prefix = '']) => '${prefix}InlineText: "${text}"'; | 122 String toString([String prefix = '']) => '${prefix}InlineText: "${text}"'; |
| 123 } | 123 } |
| 124 | 124 |
| 125 class InlineStyle extends InlineBase { | 125 class InlineStyle extends InlineBase { |
| 126 InlineStyle(this.style, this.children) { | 126 InlineStyle(this.style, this.children) { |
| 127 assert(style != null && children != null); | 127 assert(style != null); |
| 128 assert(children != null); |
| 128 } | 129 } |
| 129 | 130 |
| 130 final TextStyle style; | 131 final TextStyle style; |
| 131 final List<InlineBase> children; | 132 final List<InlineBase> children; |
| 132 | 133 |
| 133 sky.Node _toDOM(sky.Document owner) { | 134 sky.Node _toDOM(sky.Document owner) { |
| 134 sky.Element parent = owner.createElement('t'); | 135 sky.Element parent = owner.createElement('t'); |
| 135 style._applyToCSSStyle(parent.style); | 136 style._applyToCSSStyle(parent.style); |
| 136 for (InlineBase child in children) { | 137 for (InlineBase child in children) { |
| 137 parent.appendChild(child._toDOM(owner)); | 138 parent.appendChild(child._toDOM(owner)); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 InlineBase _inline; | 176 InlineBase _inline; |
| 176 BoxConstraints _constraintsForCurrentLayout; | 177 BoxConstraints _constraintsForCurrentLayout; |
| 177 | 178 |
| 178 InlineBase get inline => _inline; | 179 InlineBase get inline => _inline; |
| 179 void set inline (InlineBase value) { | 180 void set inline (InlineBase value) { |
| 180 _inline = value; | 181 _inline = value; |
| 181 _layoutRoot.rootElement.setChild(_inline._toDOM(_document)); | 182 _layoutRoot.rootElement.setChild(_inline._toDOM(_document)); |
| 182 markNeedsLayout(); | 183 markNeedsLayout(); |
| 183 } | 184 } |
| 184 | 185 |
| 185 sky.Element _layout(BoxConstraints constraints) { | 186 void _layout(BoxConstraints constraints) { |
| 186 _layoutRoot.maxWidth = constraints.maxWidth; | 187 _layoutRoot.maxWidth = constraints.maxWidth; |
| 187 _layoutRoot.minWidth = constraints.minWidth; | 188 _layoutRoot.minWidth = constraints.minWidth; |
| 188 _layoutRoot.minHeight = constraints.minHeight; | 189 _layoutRoot.minHeight = constraints.minHeight; |
| 189 _layoutRoot.maxHeight = constraints.maxHeight; | 190 _layoutRoot.maxHeight = constraints.maxHeight; |
| 190 _layoutRoot.layout(); | 191 _layoutRoot.layout(); |
| 191 _constraintsForCurrentLayout = constraints; | 192 _constraintsForCurrentLayout = constraints; |
| 192 } | 193 } |
| 193 | 194 |
| 194 double getMinIntrinsicWidth(BoxConstraints constraints) { | 195 double getMinIntrinsicWidth(BoxConstraints constraints) { |
| 195 _layout(constraints); | 196 _layout(constraints); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 241 } |
| 241 | 242 |
| 242 // we should probably expose a way to do precise (inter-glpyh) hit testing | 243 // we should probably expose a way to do precise (inter-glpyh) hit testing |
| 243 | 244 |
| 244 String debugDescribeSettings(String prefix) { | 245 String debugDescribeSettings(String prefix) { |
| 245 String result = '${super.debugDescribeSettings(prefix)}'; | 246 String result = '${super.debugDescribeSettings(prefix)}'; |
| 246 result += '${prefix}inline: ${inline}\n'; | 247 result += '${prefix}inline: ${inline}\n'; |
| 247 return result; | 248 return result; |
| 248 } | 249 } |
| 249 } | 250 } |
| OLD | NEW |