Unverified Commit 67606281 authored by Kate Lovett's avatar Kate Lovett Committed by GitHub

Typos & Style clean up (#42006)

parent 0917cb00
...@@ -110,7 +110,7 @@ class RenderParagraph extends RenderBox ...@@ -110,7 +110,7 @@ class RenderParagraph extends RenderBox
final TextPainter _textPainter; final TextPainter _textPainter;
/// The text to display /// The text to display.
InlineSpan get text => _textPainter.text; InlineSpan get text => _textPainter.text;
set text(InlineSpan value) { set text(InlineSpan value) {
assert(value != null); assert(value != null);
...@@ -220,11 +220,12 @@ class RenderParagraph extends RenderBox ...@@ -220,11 +220,12 @@ class RenderParagraph extends RenderBox
markNeedsLayout(); markNeedsLayout();
} }
/// An optional maximum number of lines for the text to span, wrapping if necessary. /// An optional maximum number of lines for the text to span, wrapping if
/// If the text exceeds the given number of lines, it will be truncated according /// necessary. If the text exceeds the given number of lines, it will be
/// to [overflow] and [softWrap]. /// truncated according to [overflow] and [softWrap].
int get maxLines => _textPainter.maxLines; int get maxLines => _textPainter.maxLines;
/// The value may be null. If it is not null, then it must be greater than zero. /// The value may be null. If it is not null, then it must be greater than
/// zero.
set maxLines(int value) { set maxLines(int value) {
assert(value == null || value > 0); assert(value == null || value > 0);
if (_textPainter.maxLines == value) if (_textPainter.maxLines == value)
...@@ -234,10 +235,11 @@ class RenderParagraph extends RenderBox ...@@ -234,10 +235,11 @@ class RenderParagraph extends RenderBox
markNeedsLayout(); markNeedsLayout();
} }
/// Used by this paragraph's internal [TextPainter] to select a locale-specific /// Used by this paragraph's internal [TextPainter] to select a
/// font. /// locale-specific font.
/// ///
/// In some cases the same Unicode character may be rendered differently depending /// In some cases the same Unicode character may be rendered differently
/// depending
/// on the locale. For example the '骨' character is rendered differently in /// on the locale. For example the '骨' character is rendered differently in
/// the Chinese and Japanese locales. In these cases the [locale] may be used /// the Chinese and Japanese locales. In these cases the [locale] may be used
/// to select a locale-specific font. /// to select a locale-specific font.
...@@ -318,11 +320,12 @@ class RenderParagraph extends RenderBox ...@@ -318,11 +320,12 @@ class RenderParagraph extends RenderBox
assert(constraints != null); assert(constraints != null);
assert(constraints.debugAssertIsValid()); assert(constraints.debugAssertIsValid());
_layoutTextWithConstraints(constraints); _layoutTextWithConstraints(constraints);
// TODO(garyq): Since our metric for ideographic baseline is currently inacurrate // TODO(garyq): Since our metric for ideographic baseline is currently
// and the non-alphabetic baselines are based off of the alphabetic baseline, we // inaccurate and the non-alphabetic baselines are based off of the
// use the alphabetic for now to produce correct layouts. We should eventually change // alphabetic baseline, we use the alphabetic for now to produce correct
// this back to pass the `baseline` property when the ideographic baseline is properly // layouts. We should eventually change this back to pass the `baseline`
// implemented (https://github.com/flutter/flutter/issues/22625). // property when the ideographic baseline is properly implemented
// (https://github.com/flutter/flutter/issues/22625).
return _textPainter.computeDistanceToActualBaseline(TextBaseline.alphabetic); return _textPainter.computeDistanceToActualBaseline(TextBaseline.alphabetic);
} }
...@@ -412,8 +415,15 @@ class RenderParagraph extends RenderBox ...@@ -412,8 +415,15 @@ class RenderParagraph extends RenderBox
RenderBox child = firstChild; RenderBox child = firstChild;
while (child != null) { while (child != null) {
final TextParentData textParentData = child.parentData; final TextParentData textParentData = child.parentData;
final Matrix4 transform = Matrix4.translationValues(textParentData.offset.dx, textParentData.offset.dy, 0.0) final Matrix4 transform = Matrix4.translationValues(
..scale(textParentData.scale, textParentData.scale, textParentData.scale); textParentData.offset.dx,
textParentData.offset.dy,
0.0,
)..scale(
textParentData.scale,
textParentData.scale,
textParentData.scale,
);
final bool isHit = result.addWithPaintTransform( final bool isHit = result.addWithPaintTransform(
transform: transform, transform: transform,
position: position, position: position,
...@@ -464,7 +474,12 @@ class RenderParagraph extends RenderBox ...@@ -464,7 +474,12 @@ class RenderParagraph extends RenderBox
void _layoutText({ double minWidth = 0.0, double maxWidth = double.infinity }) { void _layoutText({ double minWidth = 0.0, double maxWidth = double.infinity }) {
final bool widthMatters = softWrap || overflow == TextOverflow.ellipsis; final bool widthMatters = softWrap || overflow == TextOverflow.ellipsis;
_textPainter.layout(minWidth: minWidth, maxWidth: widthMatters ? maxWidth : double.infinity); _textPainter.layout(
minWidth: minWidth,
maxWidth: widthMatters ?
maxWidth :
double.infinity,
);
} }
@override @override
...@@ -500,7 +515,9 @@ class RenderParagraph extends RenderBox ...@@ -500,7 +515,9 @@ class RenderParagraph extends RenderBox
double baselineOffset; double baselineOffset;
switch (_placeholderSpans[childIndex].alignment) { switch (_placeholderSpans[childIndex].alignment) {
case ui.PlaceholderAlignment.baseline: { case ui.PlaceholderAlignment.baseline: {
baselineOffset = child.getDistanceToBaseline(_placeholderSpans[childIndex].baseline); baselineOffset = child.getDistanceToBaseline(
_placeholderSpans[childIndex].baseline
);
break; break;
} }
default: { default: {
...@@ -618,11 +635,11 @@ class RenderParagraph extends RenderBox ...@@ -618,11 +635,11 @@ class RenderParagraph extends RenderBox
void paint(PaintingContext context, Offset offset) { void paint(PaintingContext context, Offset offset) {
// Ideally we could compute the min/max intrinsic width/height with a // Ideally we could compute the min/max intrinsic width/height with a
// non-destructive operation. However, currently, computing these values // non-destructive operation. However, currently, computing these values
// will destroy state inside the painter. If that happens, we need to // will destroy state inside the painter. If that happens, we need to get
// get back the correct state by calling _layout again. // back the correct state by calling _layout again.
// //
// TODO(abarth): Make computing the min/max intrinsic width/height // TODO(abarth): Make computing the min/max intrinsic width/height a
// a non-destructive operation. // non-destructive operation.
// //
// If you remove this call, make sure that changing the textAlign still // If you remove this call, make sure that changing the textAlign still
// works properly. // works properly.
...@@ -640,8 +657,8 @@ class RenderParagraph extends RenderBox ...@@ -640,8 +657,8 @@ class RenderParagraph extends RenderBox
if (_needsClipping) { if (_needsClipping) {
final Rect bounds = offset & size; final Rect bounds = offset & size;
if (_overflowShader != null) { if (_overflowShader != null) {
// This layer limits what the shader below blends with to be just the text // This layer limits what the shader below blends with to be just the
// (as opposed to the text and its background). // text (as opposed to the text and its background).
context.canvas.saveLayer(bounds, Paint()); context.canvas.saveLayer(bounds, Paint());
} else { } else {
context.canvas.save(); context.canvas.save();
...@@ -819,7 +836,10 @@ class RenderParagraph extends RenderBox ...@@ -819,7 +836,10 @@ class RenderParagraph extends RenderBox
RenderBox child = firstChild; RenderBox child = firstChild;
for (InlineSpanSemanticsInformation info in _combineSemanticsInfo()) { for (InlineSpanSemanticsInformation info in _combineSemanticsInfo()) {
final TextDirection initialDirection = currentDirection; final TextDirection initialDirection = currentDirection;
final TextSelection selection = TextSelection(baseOffset: start, extentOffset: start + info.text.length); final TextSelection selection = TextSelection(
baseOffset: start,
extentOffset: start + info.text.length,
);
final List<ui.TextBox> rects = getBoxesForSelection(selection); final List<ui.TextBox> rects = getBoxesForSelection(selection);
if (rects.isEmpty) { if (rects.isEmpty) {
continue; continue;
...@@ -887,7 +907,12 @@ class RenderParagraph extends RenderBox ...@@ -887,7 +907,12 @@ class RenderParagraph extends RenderBox
@override @override
List<DiagnosticsNode> debugDescribeChildren() { List<DiagnosticsNode> debugDescribeChildren() {
return <DiagnosticsNode>[text.toDiagnosticsNode(name: 'text', style: DiagnosticsTreeStyle.transition)]; return <DiagnosticsNode>[
text.toDiagnosticsNode(
name: 'text',
style: DiagnosticsTreeStyle.transition,
)
];
} }
@override @override
...@@ -895,10 +920,30 @@ class RenderParagraph extends RenderBox ...@@ -895,10 +920,30 @@ class RenderParagraph extends RenderBox
super.debugFillProperties(properties); super.debugFillProperties(properties);
properties.add(EnumProperty<TextAlign>('textAlign', textAlign)); properties.add(EnumProperty<TextAlign>('textAlign', textAlign));
properties.add(EnumProperty<TextDirection>('textDirection', textDirection)); properties.add(EnumProperty<TextDirection>('textDirection', textDirection));
properties.add(FlagProperty('softWrap', value: softWrap, ifTrue: 'wrapping at box width', ifFalse: 'no wrapping except at line break characters', showName: true)); properties.add(
FlagProperty(
'softWrap',
value: softWrap,
ifTrue: 'wrapping at box width',
ifFalse: 'no wrapping except at line break characters',
showName: true,
)
);
properties.add(EnumProperty<TextOverflow>('overflow', overflow)); properties.add(EnumProperty<TextOverflow>('overflow', overflow));
properties.add(DoubleProperty('textScaleFactor', textScaleFactor, defaultValue: 1.0)); properties.add(
properties.add(DiagnosticsProperty<Locale>('locale', locale, defaultValue: null)); DoubleProperty(
'textScaleFactor',
textScaleFactor,
defaultValue: 1.0,
)
);
properties.add(
DiagnosticsProperty<Locale>(
'locale',
locale,
defaultValue: null,
)
);
properties.add(IntProperty('maxLines', maxLines, ifNull: 'unlimited')); properties.add(IntProperty('maxLines', maxLines, ifNull: 'unlimited'));
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment