Stop processing multiline text after maxLines. (flutter/engine#3342)
Added a Paragraph.didExceedMaxLines property to query when this occurs. Needed for https://github.com/flutter/flutter/issues/7271
This commit is contained in:
@@ -693,9 +693,13 @@ abstract class Paragraph extends NativeFieldWrapperClass2 {
|
||||
double get alphabeticBaseline native "Paragraph_alphabeticBaseline";
|
||||
|
||||
/// The distance from the top of the paragraph to the ideographic
|
||||
/// baseline of the first line, in logical pixels.
|
||||
/// baseline of the first line, in logical pixels.
|
||||
double get ideographicBaseline native "Paragraph_ideographicBaseline";
|
||||
|
||||
/// True if there is more vertical content, but the text was truncated
|
||||
/// because we reached [ParagraphStyle.maxLines] lines of text.
|
||||
bool get didExceedMaxLines native "Paragraph_didExceedMaxLines";
|
||||
|
||||
/// Computes the size and position of each glyph in the paragraph.
|
||||
void layout(ParagraphConstraints constraints) => _layout(constraints.width);
|
||||
void _layout(double width) native "Paragraph_layout";
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "flutter/common/threads.h"
|
||||
#include "flutter/sky/engine/core/rendering/PaintInfo.h"
|
||||
#include "flutter/sky/engine/core/rendering/RenderText.h"
|
||||
#include "flutter/sky/engine/core/rendering/RenderParagraph.h"
|
||||
#include "flutter/sky/engine/core/rendering/style/RenderStyle.h"
|
||||
#include "flutter/sky/engine/platform/fonts/FontCache.h"
|
||||
#include "flutter/sky/engine/platform/graphics/GraphicsContext.h"
|
||||
@@ -30,6 +31,7 @@ IMPLEMENT_WRAPPERTYPEINFO(ui, Paragraph);
|
||||
V(Paragraph, maxIntrinsicWidth) \
|
||||
V(Paragraph, alphabeticBaseline) \
|
||||
V(Paragraph, ideographicBaseline) \
|
||||
V(Paragraph, didExceedMaxLines) \
|
||||
V(Paragraph, layout) \
|
||||
V(Paragraph, paint) \
|
||||
V(Paragraph, getWordBoundary) \
|
||||
@@ -75,6 +77,13 @@ double Paragraph::ideographicBaseline() {
|
||||
FontBaselineOrAuto(IdeographicBaseline));
|
||||
}
|
||||
|
||||
bool Paragraph::didExceedMaxLines() {
|
||||
RenderBox* box = firstChildBox();
|
||||
ASSERT(box->isRenderParagraph());
|
||||
RenderParagraph* paragraph = static_cast<RenderParagraph*>(box);
|
||||
return paragraph->didExceedMaxLines();
|
||||
}
|
||||
|
||||
void Paragraph::layout(double width) {
|
||||
FontCachePurgePreventer fontCachePurgePreventer;
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ class Paragraph : public ftl::RefCountedThreadSafe<Paragraph>,
|
||||
double maxIntrinsicWidth();
|
||||
double alphabeticBaseline();
|
||||
double ideographicBaseline();
|
||||
bool didExceedMaxLines();
|
||||
|
||||
void layout(double width);
|
||||
void paint(Canvas* canvas, double x, double y);
|
||||
|
||||
Reference in New Issue
Block a user