Commit 5f292a7d authored by Liquan(Max) Gu's avatar Liquan(Max) Gu Committed by Commit Bot

[FCP++] Text: ignore text blocking on webfont

Currently FCP++ doesn't ignore the text paint in the block stage. The block
stage happens when we have font-display:block for a text node and the
webfont of the text is not yet loaded.

FCP++ should ignore the text because it's not visible to users. The text should
be captured only after the text starts to be visible.

The block stage is controlled by Font::ShouldSkipDrawing(). When a text node
is blocked on web-font, the text would be set to invisible-font. So FCP++ should
use this method to tell whether the text would not be drawn due to the
invisible font.

Bug: 944530
Change-Id: If80a5bdeccce0896d0e4e836c89bfd9aefbd627d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1609669
Commit-Queue: Liquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarLiquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarXianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659661}
parent 2e62194f
...@@ -72,7 +72,8 @@ void EllipsisBoxPainter::PaintEllipsis(const PaintInfo& paint_info, ...@@ -72,7 +72,8 @@ void EllipsisBoxPainter::PaintEllipsis(const PaintInfo& paint_info,
// TODO(npm): Check that there are non-whitespace characters. See // TODO(npm): Check that there are non-whitespace characters. See
// crbug.com/788444. // crbug.com/788444.
context.GetPaintController().SetTextPainted(); context.GetPaintController().SetTextPainted();
if (RuntimeEnabledFeatures::FirstContentfulPaintPlusPlusEnabled()) { if (RuntimeEnabledFeatures::FirstContentfulPaintPlusPlusEnabled() &&
!font.ShouldSkipDrawing()) {
// We should consider using the text node as the tracking node, instead of // We should consider using the text node as the tracking node, instead of
// the line layout item. // the line layout item.
Node* node = ellipsis_box_.GetLineLayoutItem().GetNode(); Node* node = ellipsis_box_.GetLineLayoutItem().GetNode();
......
...@@ -78,7 +78,8 @@ void FileUploadControlPainter::PaintObject(const PaintInfo& paint_info, ...@@ -78,7 +78,8 @@ void FileUploadControlPainter::PaintObject(const PaintInfo& paint_info,
paint_info.context.DrawBidiText( paint_info.context.DrawBidiText(
font, text_run_paint_info, font, text_run_paint_info,
FloatPoint(RoundToInt(text_x), RoundToInt(text_y))); FloatPoint(RoundToInt(text_x), RoundToInt(text_y)));
if (RuntimeEnabledFeatures::FirstContentfulPaintPlusPlusEnabled()) { if (RuntimeEnabledFeatures::FirstContentfulPaintPlusPlusEnabled() &&
!font.ShouldSkipDrawing()) {
PaintTimingDetector::NotifyTextPaint( PaintTimingDetector::NotifyTextPaint(
layout_file_upload_control_, paint_info.context.GetPaintController() layout_file_upload_control_, paint_info.context.GetPaintController()
.CurrentPaintChunkProperties()); .CurrentPaintChunkProperties());
......
...@@ -430,7 +430,8 @@ void InlineTextBoxPainter::Paint(const PaintInfo& paint_info, ...@@ -430,7 +430,8 @@ void InlineTextBoxPainter::Paint(const PaintInfo& paint_info,
context.ConcatCTM(TextPainterBase::Rotation( context.ConcatCTM(TextPainterBase::Rotation(
box_rect, TextPainterBase::kCounterclockwise)); box_rect, TextPainterBase::kCounterclockwise));
} }
if (RuntimeEnabledFeatures::FirstContentfulPaintPlusPlusEnabled()) { if (RuntimeEnabledFeatures::FirstContentfulPaintPlusPlusEnabled() &&
!font.ShouldSkipDrawing()) {
PaintTimingDetector::NotifyTextPaint( PaintTimingDetector::NotifyTextPaint(
InlineLayoutObject(), InlineLayoutObject(),
paint_info.context.GetPaintController().CurrentPaintChunkProperties()); paint_info.context.GetPaintController().CurrentPaintChunkProperties());
......
...@@ -64,7 +64,8 @@ void NGTextPainter::PaintInternalFragment( ...@@ -64,7 +64,8 @@ void NGTextPainter::PaintInternalFragment(
// TODO(npm): Check that there are non-whitespace characters. See // TODO(npm): Check that there are non-whitespace characters. See
// crbug.com/788444. // crbug.com/788444.
graphics_context_.GetPaintController().SetTextPainted(); graphics_context_.GetPaintController().SetTextPainted();
if (RuntimeEnabledFeatures::FirstContentfulPaintPlusPlusEnabled()) { if (RuntimeEnabledFeatures::FirstContentfulPaintPlusPlusEnabled() &&
!font_.ShouldSkipDrawing()) {
PaintTimingDetector::NotifyTextPaint( PaintTimingDetector::NotifyTextPaint(
*fragment_.GetLayoutObject(), *fragment_.GetLayoutObject(),
graphics_context_.GetPaintController().CurrentPaintChunkProperties()); graphics_context_.GetPaintController().CurrentPaintChunkProperties());
......
...@@ -470,7 +470,8 @@ void SVGInlineTextBoxPainter::PaintText(const PaintInfo& paint_info, ...@@ -470,7 +470,8 @@ void SVGInlineTextBoxPainter::PaintText(const PaintInfo& paint_info,
// TODO(npm): Check that there are non-whitespace characters. See // TODO(npm): Check that there are non-whitespace characters. See
// crbug.com/788444. // crbug.com/788444.
context.GetPaintController().SetTextPainted(); context.GetPaintController().SetTextPainted();
if (RuntimeEnabledFeatures::FirstContentfulPaintPlusPlusEnabled()) { if (RuntimeEnabledFeatures::FirstContentfulPaintPlusPlusEnabled() &&
!scaled_font.ShouldSkipDrawing()) {
PaintTimingDetector::NotifyTextPaint( PaintTimingDetector::NotifyTextPaint(
InlineLayoutObject(), InlineLayoutObject(),
paint_info.context.GetPaintController().CurrentPaintChunkProperties()); paint_info.context.GetPaintController().CurrentPaintChunkProperties());
......
...@@ -238,11 +238,11 @@ class PLATFORM_EXPORT Font { ...@@ -238,11 +238,11 @@ class PLATFORM_EXPORT Font {
bool LoadingCustomFonts() const; bool LoadingCustomFonts() const;
bool IsFallbackValid() const; bool IsFallbackValid() const;
private:
bool ShouldSkipDrawing() const { bool ShouldSkipDrawing() const {
return font_fallback_list_ && font_fallback_list_->ShouldSkipDrawing(); return font_fallback_list_ && font_fallback_list_->ShouldSkipDrawing();
} }
private:
FontDescription font_description_; FontDescription font_description_;
mutable scoped_refptr<FontFallbackList> font_fallback_list_; mutable scoped_refptr<FontFallbackList> font_fallback_list_;
mutable unsigned can_shape_word_by_word_ : 1; mutable unsigned can_shape_word_by_word_ : 1;
......
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