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
final TextPainter _textPainter;
/// The text to display
/// The text to display.
InlineSpan get text => _textPainter.text;
set text(InlineSpan value) {
assert(value != null);
......@@ -220,11 +220,12 @@ class RenderParagraph extends RenderBox
markNeedsLayout();
}
/// An optional maximum number of lines for the text to span, wrapping if necessary.
/// If the text exceeds the given number of lines, it will be truncated according
/// to [overflow] and [softWrap].
/// An optional maximum number of lines for the text to span, wrapping if
/// necessary. If the text exceeds the given number of lines, it will be
/// truncated according to [overflow] and [softWrap].
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) {
assert(value == null || value > 0);
if (_textPainter.maxLines == value)
......@@ -234,10 +235,11 @@ class RenderParagraph extends RenderBox
markNeedsLayout();
}
/// Used by this paragraph's internal [TextPainter] to select a locale-specific
/// font.
/// Used by this paragraph's internal [TextPainter] to select a
/// 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
/// the Chinese and Japanese locales. In these cases the [locale] may be used
/// to select a locale-specific font.
......@@ -318,11 +320,12 @@ class RenderParagraph extends RenderBox
assert(constraints != null);
assert(constraints.debugAssertIsValid());
_layoutTextWithConstraints(constraints);
// TODO(garyq): Since our metric for ideographic baseline is currently inacurrate
// and the non-alphabetic baselines are based off of the alphabetic baseline, we
// use the alphabetic for now to produce correct layouts. We should eventually change
// this back to pass the `baseline` property when the ideographic baseline is properly
// implemented (https://github.com/flutter/flutter/issues/22625).
// TODO(garyq): Since our metric for ideographic baseline is currently
// inaccurate and the non-alphabetic baselines are based off of the
// alphabetic baseline, we use the alphabetic for now to produce correct
// layouts. We should eventually change this back to pass the `baseline`
// property when the ideographic baseline is properly implemented
// (https://github.com/flutter/flutter/issues/22625).
return _textPainter.computeDistanceToActualBaseline(TextBaseline.alphabetic);
}
......@@ -412,8 +415,15 @@ class RenderParagraph extends RenderBox
RenderBox child = firstChild;
while (child != null) {
final TextParentData textParentData = child.parentData;
final Matrix4 transform = Matrix4.translationValues(textParentData.offset.dx, textParentData.offset.dy, 0.0)
..scale(textParentData.scale, textParentData.scale, textParentData.scale);
final Matrix4 transform = Matrix4.translationValues(
textParentData.offset.dx,
textParentData.offset.dy,
0.0,
)..scale(
textParentData.scale,
textParentData.scale,
textParentData.scale,
);
final bool isHit = result.addWithPaintTransform(
transform: transform,
position: position,
......@@ -464,7 +474,12 @@ class RenderParagraph extends RenderBox
void _layoutText({ double minWidth = 0.0, double maxWidth = double.infinity }) {
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
......@@ -500,7 +515,9 @@ class RenderParagraph extends RenderBox
double baselineOffset;
switch (_placeholderSpans[childIndex].alignment) {
case ui.PlaceholderAlignment.baseline: {
baselineOffset = child.getDistanceToBaseline(_placeholderSpans[childIndex].baseline);
baselineOffset = child.getDistanceToBaseline(
_placeholderSpans[childIndex].baseline
);
break;
}
default: {
......@@ -618,11 +635,11 @@ class RenderParagraph extends RenderBox
void paint(PaintingContext context, Offset offset) {
// Ideally we could compute the min/max intrinsic width/height with a
// non-destructive operation. However, currently, computing these values
// will destroy state inside the painter. If that happens, we need to
// get back the correct state by calling _layout again.
// will destroy state inside the painter. If that happens, we need to get
// back the correct state by calling _layout again.
//
// TODO(abarth): Make computing the min/max intrinsic width/height
// a non-destructive operation.
// TODO(abarth): Make computing the min/max intrinsic width/height a
// non-destructive operation.
//
// If you remove this call, make sure that changing the textAlign still
// works properly.
......@@ -640,8 +657,8 @@ class RenderParagraph extends RenderBox
if (_needsClipping) {
final Rect bounds = offset & size;
if (_overflowShader != null) {
// This layer limits what the shader below blends with to be just the text
// (as opposed to the text and its background).
// This layer limits what the shader below blends with to be just the
// text (as opposed to the text and its background).
context.canvas.saveLayer(bounds, Paint());
} else {
context.canvas.save();
......@@ -819,7 +836,10 @@ class RenderParagraph extends RenderBox
RenderBox child = firstChild;
for (InlineSpanSemanticsInformation info in _combineSemanticsInfo()) {
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);
if (rects.isEmpty) {
continue;
......@@ -887,7 +907,12 @@ class RenderParagraph extends RenderBox
@override
List<DiagnosticsNode> debugDescribeChildren() {
return <DiagnosticsNode>[text.toDiagnosticsNode(name: 'text', style: DiagnosticsTreeStyle.transition)];
return <DiagnosticsNode>[
text.toDiagnosticsNode(
name: 'text',
style: DiagnosticsTreeStyle.transition,
)
];
}
@override
......@@ -895,10 +920,30 @@ class RenderParagraph extends RenderBox
super.debugFillProperties(properties);
properties.add(EnumProperty<TextAlign>('textAlign', textAlign));
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(DoubleProperty('textScaleFactor', textScaleFactor, defaultValue: 1.0));
properties.add(DiagnosticsProperty<Locale>('locale', locale, defaultValue: null));
properties.add(
DoubleProperty(
'textScaleFactor',
textScaleFactor,
defaultValue: 1.0,
)
);
properties.add(
DiagnosticsProperty<Locale>(
'locale',
locale,
defaultValue: null,
)
);
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