Title: [228507] trunk/Source/WebCore
- Revision
- 228507
- Author
- [email protected]
- Date
- 2018-02-15 02:10:21 -0800 (Thu, 15 Feb 2018)
Log Message
HarfBuzzFace should not be ref-counted
https://bugs.webkit.org/show_bug.cgi?id=182823
Reviewed by Carlos Garcia Campos.
The HarfBuzzFace objects shouldn't be copied along in FontPlatformData
copy assignment operator, which made it a requirement for that class to
be ref-counted. Cairo-based HarfBuzzFace implementation uses the
cairo_scaled_font_t object from FontPlatformData internally, but upon
FontPlatformData cloning that scaled font object could change, meaning
HarfBuzzFace object that's shared with another FontPlatformData object
would end up using a different cairo_scaled_font_t object from the one
that's been regenerated in the newly-cloned FontPlatformData object.
Instead of ref-counting the HarfBuzzFace objects, they should be handled
in FontPlatformData through std::unique_ptr<>. In the FontPlatformData
copy assignment operator, the copy target's m_harfBuzzFace object is
nulled out, allowing the next harfBuzzFace() call to construct an
object that properly leverages the cairo_scaled_font_t object that could
have changed during cloning.
* platform/graphics/FontPlatformData.h:
* platform/graphics/freetype/FontPlatformDataFreeType.cpp:
(WebCore::FontPlatformData::operator=):
(WebCore::FontPlatformData::harfBuzzFace const):
* platform/graphics/harfbuzz/HarfBuzzFace.h:
(WebCore::HarfBuzzFace::create): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (228506 => 228507)
--- trunk/Source/WebCore/ChangeLog 2018-02-15 07:48:14 UTC (rev 228506)
+++ trunk/Source/WebCore/ChangeLog 2018-02-15 10:10:21 UTC (rev 228507)
@@ -1,3 +1,33 @@
+2018-02-15 Zan Dobersek <[email protected]>
+
+ HarfBuzzFace should not be ref-counted
+ https://bugs.webkit.org/show_bug.cgi?id=182823
+
+ Reviewed by Carlos Garcia Campos.
+
+ The HarfBuzzFace objects shouldn't be copied along in FontPlatformData
+ copy assignment operator, which made it a requirement for that class to
+ be ref-counted. Cairo-based HarfBuzzFace implementation uses the
+ cairo_scaled_font_t object from FontPlatformData internally, but upon
+ FontPlatformData cloning that scaled font object could change, meaning
+ HarfBuzzFace object that's shared with another FontPlatformData object
+ would end up using a different cairo_scaled_font_t object from the one
+ that's been regenerated in the newly-cloned FontPlatformData object.
+
+ Instead of ref-counting the HarfBuzzFace objects, they should be handled
+ in FontPlatformData through std::unique_ptr<>. In the FontPlatformData
+ copy assignment operator, the copy target's m_harfBuzzFace object is
+ nulled out, allowing the next harfBuzzFace() call to construct an
+ object that properly leverages the cairo_scaled_font_t object that could
+ have changed during cloning.
+
+ * platform/graphics/FontPlatformData.h:
+ * platform/graphics/freetype/FontPlatformDataFreeType.cpp:
+ (WebCore::FontPlatformData::operator=):
+ (WebCore::FontPlatformData::harfBuzzFace const):
+ * platform/graphics/harfbuzz/HarfBuzzFace.h:
+ (WebCore::HarfBuzzFace::create): Deleted.
+
2018-02-14 Zalan Bujtas <[email protected]>
[RenderTreeBuilder] Move RenderMathMLFenced::addChild() to RenderTreeBuilder
Modified: trunk/Source/WebCore/platform/graphics/FontPlatformData.h (228506 => 228507)
--- trunk/Source/WebCore/platform/graphics/FontPlatformData.h 2018-02-15 07:48:14 UTC (rev 228506)
+++ trunk/Source/WebCore/platform/graphics/FontPlatformData.h 2018-02-15 10:10:21 UTC (rev 228507)
@@ -41,6 +41,7 @@
#if USE(FREETYPE)
#include "FcUniquePtr.h"
#include "HarfBuzzFace.h"
+#include <memory>
#endif
#if USE(APPKIT)
@@ -242,7 +243,7 @@
#if USE(FREETYPE)
RefPtr<FcPattern> m_pattern;
mutable FcUniquePtr<FcFontSet> m_fallbacks;
- mutable RefPtr<HarfBuzzFace> m_harfBuzzFace;
+ mutable std::unique_ptr<HarfBuzzFace> m_harfBuzzFace;
#endif
// The values below are common to all ports
Modified: trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp (228506 => 228507)
--- trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp 2018-02-15 07:48:14 UTC (rev 228506)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp 2018-02-15 10:10:21 UTC (rev 228507)
@@ -195,12 +195,12 @@
m_fixedWidth = other.m_fixedWidth;
m_pattern = other.m_pattern;
+ m_scaledFont = other.m_scaledFont;
+
// This will be re-created on demand.
m_fallbacks = nullptr;
+ m_harfBuzzFace = nullptr;
- m_scaledFont = other.m_scaledFont;
- m_harfBuzzFace = other.m_harfBuzzFace;
-
return *this;
}
@@ -241,8 +241,7 @@
HarfBuzzFace* FontPlatformData::harfBuzzFace() const
{
if (!m_harfBuzzFace)
- m_harfBuzzFace = HarfBuzzFace::create(const_cast<FontPlatformData*>(this), hash());
-
+ m_harfBuzzFace = std::make_unique<HarfBuzzFace>(const_cast<FontPlatformData*>(this), hash());
return m_harfBuzzFace.get();
}
Modified: trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFace.h (228506 => 228507)
--- trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFace.h 2018-02-15 07:48:14 UTC (rev 228506)
+++ trunk/Source/WebCore/platform/graphics/harfbuzz/HarfBuzzFace.h 2018-02-15 10:10:21 UTC (rev 228507)
@@ -33,24 +33,22 @@
#include <hb.h>
+#include <memory>
+#include <wtf/FastMalloc.h>
#include <wtf/HashMap.h>
-#include <wtf/Ref.h>
-#include <wtf/RefCounted.h>
namespace WebCore {
class FontPlatformData;
-class HarfBuzzFace : public RefCounted<HarfBuzzFace> {
+class HarfBuzzFace {
+ WTF_MAKE_FAST_ALLOCATED;
public:
static const hb_tag_t vertTag;
static const hb_tag_t vrt2Tag;
static const hb_tag_t kernTag;
- static Ref<HarfBuzzFace> create(FontPlatformData* platformData, uint64_t uniqueID)
- {
- return adoptRef(*new HarfBuzzFace(platformData, uniqueID));
- }
+ HarfBuzzFace(FontPlatformData*, uint64_t);
~HarfBuzzFace();
hb_font_t* createFont();
@@ -58,8 +56,6 @@
void setScriptForVerticalGlyphSubstitution(hb_buffer_t*);
private:
- HarfBuzzFace(FontPlatformData*, uint64_t);
-
hb_face_t* createFace();
FontPlatformData* m_platformData;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes