The width of a nullptr TextRun should be zero
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Aug 2018 19:37:37 +0000 (19:37 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Aug 2018 19:37:37 +0000 (19:37 +0000)
commit5846b4792a7af4ff5d55aba6c8c9c1782da1320f
tree9954ac345e7c9722f1c1da37bf48af8bc51b9d36
parentfd998742920cd2a9e42bf4aa609623ddb00b0355
The width of a nullptr TextRun should be zero
https://bugs.webkit.org/show_bug.cgi?id=189154
<rdar://problem/43685926>

Reviewed by Zalan Bujtas.

Source/WebCore:

If a page has an empty TextRun and attempts to paint it we can crash with a nullptr.

This patch recognizes that an empty TextRun should always produce a zero width, rather than
attempt to compute this value from font data.

Test: fast/text/null-string-textrun.html

* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::widthOfTextRange const): An empty TextRun has zero width.
(WebCore::FontCascade::width const): Ditto.
(WebCore::FontCascade::codePath const): ASSERT that the TextRun is non-empty.

LayoutTests:

* fast/text/null-string-textrun-expected.txt: Added.
* fast/text/null-string-textrun.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235516 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/text/null-string-textrun-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/null-string-textrun.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/FontCascade.cpp