Add |contains_only_whitespace_| to LayoutText and TextRun
This CL takes advantage of the loop through text in LayoutText to store a variable indicating whether text contains only 'whitespace' or not. The main purpose of the loop is to compute widths but this seems like a reasonable place to also store this new information, to avoid an extra iteration over the text. Now, TextRun has a boolean variable indicating whether the text to be painted contains a whitespace or not. For now, the boolean is only changed in InlineTextBox::ConstructTextRun to prevent Font::DrawText from returning true. The return value of this method is only used to determine whether SetTextPainted() is called in GraphicsContext::DrawTextInternal. PaintController::SetTextPainted is the method that triggers First Contentful Paint (caused by text) on PaintTiming. We do not want it to be triggered on trivial whitespace text rendering. Test: Check whether FCP is observed on a document with just <div> </div> Also, this fix should allow landing the test in: https://chromium-review.googlesource.com/c/chromium/src/+/769929 Bug: 785344 Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_slimming_paint_v2 Change-Id: Id219eeaced4679eda9c26acde7fd4fdb0cb1e891 Reviewed-on: https://chromium-review.googlesource.com/786336Reviewed-by:Philip Rogers <pdr@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Cr-Commit-Position: refs/heads/master@{#519455}
Showing
Please register or sign in to comment