[OpenType] OpenTypeVerticalData object should not be created if the font is not OpenType
https://bugs.webkit.org/show_bug.cgi?id=157172

Reviewed by Michael Catanzaro.

It's a bit weird that the object is always created and has an isOpenType() method to check whether it's an
OpenType or not. The caller is always deleting the object when it's not an OpenType, so it would be better if
the create method returned nullptr instead of creating the object when the font is not OpenType.

* platform/graphics/FontCache.cpp:
(WebCore::FontCache::verticalData): Do not use isOpenType(), we can now simply use the return value of OpenTypeVerticalData::create().
* platform/graphics/opentype/OpenTypeVerticalData.cpp:
(WebCore::loadHmtxTable): Moved to a helper funtion that returns false if the font is not OpenType.
(WebCore::OpenTypeVerticalData::create): Try to load the Hmtx table, and create the object if succeeded or
return nullptr otherwise.
(WebCore::OpenTypeVerticalData::OpenTypeVerticalData): Receive the advanceWidths as constructor parameter.
(WebCore::OpenTypeVerticalData::loadMetrics): Load all other tables.
* platform/graphics/opentype/OpenTypeVerticalData.h:
(WebCore::OpenTypeVerticalData::isOpenType): Deleted.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@200364 268f45cc-cd09-0410-ab3c-d52691b4dbfc
4 files changed