Diff
Modified: trunk/Source/WebCore/ChangeLog (158622 => 158623)
--- trunk/Source/WebCore/ChangeLog 2013-11-05 01:31:41 UTC (rev 158622)
+++ trunk/Source/WebCore/ChangeLog 2013-11-05 01:31:43 UTC (rev 158623)
@@ -1,3 +1,38 @@
+2013-11-04 Patrick Gansterer <par...@webkit.org>
+
+ Remove code duplications in createFontCustomPlatformData()
+ https://bugs.webkit.org/show_bug.cgi?id=123706
+
+ Reviewed by Darin Adler.
+
+ Move OpenTypeSanitizer and WOFF handling from the port specific
+ implementations in createFontCustomPlatformData() into the only
+ caller of this function CachedFont::ensureCustomFontData().
+ Also change the parameter passing the SharedBuffer from a
+ pointer to a reference since it is never null.
+
+ * loader/cache/CachedFont.cpp:
+ (WebCore::CachedFont::ensureCustomFontData):
+ * platform/graphics/blackberry/FontCustomPlatformData.h:
+ * platform/graphics/blackberry/FontCustomPlatformDataBlackBerry.cpp:
+ (WebCore::FontCustomPlatformData::FontCustomPlatformData):
+ (WebCore::createFontCustomPlatformData):
+ * platform/graphics/cairo/FontCustomPlatformData.h:
+ * platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp:
+ (WebCore::FontCustomPlatformData::FontCustomPlatformData):
+ (WebCore::createFontCustomPlatformData):
+ * platform/graphics/mac/FontCustomPlatformData.cpp:
+ (WebCore::createFontCustomPlatformData):
+ * platform/graphics/mac/FontCustomPlatformData.h:
+ * platform/graphics/win/FontCustomPlatformData.cpp:
+ (WebCore::createFontCustomPlatformData):
+ * platform/graphics/win/FontCustomPlatformData.h:
+ * platform/graphics/win/FontCustomPlatformDataCairo.cpp:
+ (WebCore::createFontCustomPlatformData):
+ * platform/graphics/wince/FontCustomPlatformData.cpp:
+ (WebCore::createFontCustomPlatformData):
+ * platform/graphics/wince/FontCustomPlatformData.h:
+
2013-11-04 Thiago de Barros Lacerda <thiago.lace...@openbossa.org>
Fixing MediaStreamDescriptor addSource and addTrack methods
Modified: trunk/Source/WebCore/loader/cache/CachedFont.cpp (158622 => 158623)
--- trunk/Source/WebCore/loader/cache/CachedFont.cpp 2013-11-05 01:31:41 UTC (rev 158622)
+++ trunk/Source/WebCore/loader/cache/CachedFont.cpp 2013-11-05 01:31:43 UTC (rev 158623)
@@ -33,8 +33,11 @@
#include "FontCustomPlatformData.h"
#include "FontPlatformData.h"
#include "MemoryCache.h"
+#include "OpenTypeSanitizer.h"
#include "ResourceBuffer.h"
+#include "SharedBuffer.h"
#include "TextResourceDecoder.h"
+#include "WOFFFileFormat.h"
#include <wtf/Vector.h>
#if ENABLE(SVG_FONTS)
@@ -92,7 +95,26 @@
bool CachedFont::ensureCustomFontData()
{
if (!m_fontData && !errorOccurred() && !isLoading() && m_data) {
- m_fontData = createFontCustomPlatformData(m_data.get()->sharedBuffer());
+ SharedBuffer* buffer = m_data.get()->sharedBuffer();
+ ASSERT(buffer);
+
+#if USE(OPENTYPE_SANITIZER)
+ OpenTypeSanitizer sanitizer(buffer);
+ RefPtr<SharedBuffer> transcodeBuffer = sanitizer.sanitize();
+ buffer = transcodeBuffer.get();
+#else
+ RefPtr<SharedBuffer> sfntBuffer;
+ if (isWOFF(buffer)) {
+ Vector<char> sfnt;
+ if (convertWOFFToSfnt(buffer, sfnt)) {
+ sfntBuffer = SharedBuffer::adoptVector(sfnt);
+ buffer = sfntBuffer.get();
+ } else
+ buffer = nullptr;
+ }
+#endif
+
+ m_fontData = buffer ? createFontCustomPlatformData(*buffer) : nullptr;
if (m_fontData)
m_hasCreatedFontData = true;
else
Modified: trunk/Source/WebCore/platform/graphics/blackberry/FontCustomPlatformData.h (158622 => 158623)
--- trunk/Source/WebCore/platform/graphics/blackberry/FontCustomPlatformData.h 2013-11-05 01:31:41 UTC (rev 158622)
+++ trunk/Source/WebCore/platform/graphics/blackberry/FontCustomPlatformData.h 2013-11-05 01:31:43 UTC (rev 158623)
@@ -36,7 +36,7 @@
struct FontCustomPlatformData {
WTF_MAKE_NONCOPYABLE(FontCustomPlatformData);
public:
- FontCustomPlatformData(FILECHAR* fontName, PassRefPtr<SharedBuffer>);
+ FontCustomPlatformData(FILECHAR* fontName, SharedBuffer&);
~FontCustomPlatformData();
FontPlatformData fontPlatformData(int size, bool syntheticBold, bool syntheticItalic, FontOrientation = Horizontal,
@@ -48,7 +48,7 @@
RefPtr<SharedBuffer> m_buffer;
};
-std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer*);
+std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer&);
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/graphics/blackberry/FontCustomPlatformDataBlackBerry.cpp (158622 => 158623)
--- trunk/Source/WebCore/platform/graphics/blackberry/FontCustomPlatformDataBlackBerry.cpp 2013-11-05 01:31:41 UTC (rev 158622)
+++ trunk/Source/WebCore/platform/graphics/blackberry/FontCustomPlatformDataBlackBerry.cpp 2013-11-05 01:31:43 UTC (rev 158623)
@@ -21,7 +21,6 @@
#include "FontPlatformData.h"
#include "ITypeUtils.h"
-#include "OpenTypeSanitizer.h"
#include "SharedBuffer.h"
#include <BlackBerryPlatformGraphicsContext.h>
@@ -29,9 +28,9 @@
namespace WebCore {
-FontCustomPlatformData::FontCustomPlatformData(FILECHAR* fontName, PassRefPtr<SharedBuffer> buffer)
+FontCustomPlatformData::FontCustomPlatformData(FILECHAR* fontName, SharedBuffer& buffer)
: m_fontName(strdup(fontName))
- , m_buffer(buffer)
+ , m_buffer(&buffer)
{
}
@@ -56,21 +55,11 @@
return isSupported;
}
-std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer* buffer)
+std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer& buffer)
{
- ASSERT_ARG(buffer, buffer);
-
-#if USE(OPENTYPE_SANITIZER)
- OpenTypeSanitizer sanitizer(buffer);
- RefPtr<SharedBuffer> transcodeBuffer = sanitizer.sanitize();
- if (!transcodeBuffer)
- return nullptr; // validation failed.
- buffer = transcodeBuffer.get();
-#endif
-
FILECHAR name[MAX_FONT_NAME_LEN+1];
memset(name, 0, MAX_FONT_NAME_LEN+1);
- if (FS_load_font(BlackBerry::Platform::Graphics::getIType(), 0, const_cast<FS_BYTE*>(reinterpret_cast<const FS_BYTE*>(buffer->data())), 0, MAX_FONT_NAME_LEN, name) != SUCCESS)
+ if (FS_load_font(BlackBerry::Platform::Graphics::getIType(), 0, const_cast<FS_BYTE*>(reinterpret_cast<const FS_BYTE*>(buffer.data())), 0, MAX_FONT_NAME_LEN, name) != SUCCESS)
return nullptr;
return std::make_unique<FontCustomPlatformData>(name, buffer);
Modified: trunk/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h (158622 => 158623)
--- trunk/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h 2013-11-05 01:31:41 UTC (rev 158622)
+++ trunk/Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h 2013-11-05 01:31:43 UTC (rev 158623)
@@ -39,7 +39,7 @@
struct FontCustomPlatformData {
WTF_MAKE_NONCOPYABLE(FontCustomPlatformData);
public:
- FontCustomPlatformData(FT_Face, SharedBuffer*);
+ FontCustomPlatformData(FT_Face, SharedBuffer&);
~FontCustomPlatformData();
FontPlatformData fontPlatformData(int size, bool bold, bool italic, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, FontRenderingMode = NormalRenderingMode);
static bool supportsFormat(const String&);
@@ -49,7 +49,7 @@
cairo_font_face_t* m_fontFace;
};
-std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer*);
+std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer&);
}
Modified: trunk/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp (158622 => 158623)
--- trunk/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp 2013-11-05 01:31:41 UTC (rev 158622)
+++ trunk/Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp 2013-11-05 01:31:43 UTC (rev 158623)
@@ -24,7 +24,6 @@
#include "FontPlatformData.h"
#include "SharedBuffer.h"
-#include "WOFFFileFormat.h"
#include <cairo-ft.h>
#include <cairo.h>
@@ -35,15 +34,15 @@
static_cast<SharedBuffer*>(data)->deref();
}
-FontCustomPlatformData::FontCustomPlatformData(FT_Face freeTypeFace, SharedBuffer* buffer)
+FontCustomPlatformData::FontCustomPlatformData(FT_Face freeTypeFace, SharedBuffer& buffer)
: m_freeTypeFace(freeTypeFace)
, m_fontFace(cairo_ft_font_face_create_for_ft_face(freeTypeFace, 0))
{
// FIXME Should we be setting some hinting options here?
- buffer->ref(); // This is balanced by the buffer->deref() in releaseCustomFontData.
+ buffer.ref(); // This is balanced by the buffer->deref() in releaseCustomFontData.
static cairo_user_data_key_t bufferKey;
- cairo_font_face_set_user_data(m_fontFace, &bufferKey, buffer,
+ cairo_font_face_set_user_data(m_fontFace, &bufferKey, &buffer,
static_cast<cairo_destroy_func_t>(releaseCustomFontData));
// Cairo doesn't do FreeType reference counting, so we need to ensure that when
@@ -64,20 +63,8 @@
return FontPlatformData(m_fontFace, size, bold, italic);
}
-std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer* buffer)
+std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer& buffer)
{
- ASSERT_ARG(buffer, buffer);
-
- RefPtr<SharedBuffer> sfntBuffer;
- if (isWOFF(buffer)) {
- Vector<char> sfnt;
- if (!convertWOFFToSfnt(buffer, sfnt))
- return nullptr;
-
- sfntBuffer = SharedBuffer::adoptVector(sfnt);
- buffer = sfntBuffer.get();
- }
-
static FT_Library library;
if (!library && FT_Init_FreeType(&library)) {
library = nullptr;
@@ -85,7 +72,7 @@
}
FT_Face freeTypeFace;
- if (FT_New_Memory_Face(library, reinterpret_cast<const FT_Byte*>(buffer->data()), buffer->size(), 0, &freeTypeFace))
+ if (FT_New_Memory_Face(library, reinterpret_cast<const FT_Byte*>(buffer.data()), buffer.size(), 0, &freeTypeFace))
return nullptr;
return std::make_unique<FontCustomPlatformData>(freeTypeFace, buffer);
}
Modified: trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp (158622 => 158623)
--- trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp 2013-11-05 01:31:41 UTC (rev 158622)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp 2013-11-05 01:31:43 UTC (rev 158623)
@@ -22,9 +22,7 @@
#include "FontCustomPlatformData.h"
#include "FontPlatformData.h"
-#include "OpenTypeSanitizer.h"
#include "SharedBuffer.h"
-#include "WOFFFileFormat.h"
#include <ApplicationServices/ApplicationServices.h>
namespace WebCore {
@@ -38,31 +36,11 @@
return FontPlatformData(m_cgFont.get(), size, bold, italic, orientation, widthVariant);
}
-std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer* buffer)
+std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer& buffer)
{
- ASSERT_ARG(buffer, buffer);
-
-#if USE(OPENTYPE_SANITIZER)
- OpenTypeSanitizer sanitizer(buffer);
- RefPtr<SharedBuffer> transcodeBuffer = sanitizer.sanitize();
- if (!transcodeBuffer)
- return nullptr; // validation failed.
- buffer = transcodeBuffer.get();
-#else
- RefPtr<SharedBuffer> sfntBuffer;
- if (isWOFF(buffer)) {
- Vector<char> sfnt;
- if (!convertWOFFToSfnt(buffer, sfnt))
- return nullptr;
-
- sfntBuffer = SharedBuffer::adoptVector(sfnt);
- buffer = sfntBuffer.get();
- }
-#endif
-
ATSFontContainerRef containerRef = 0;
- RetainPtr<CFDataRef> bufferData = buffer->createCFData();
+ RetainPtr<CFDataRef> bufferData = buffer.createCFData();
RetainPtr<CGDataProviderRef> dataProvider = adoptCF(CGDataProviderCreateWithCFData(bufferData.get()));
RetainPtr<CGFontRef> cgFontRef = adoptCF(CGFontCreateWithDataProvider(dataProvider.get()));
Modified: trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h (158622 => 158623)
--- trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h 2013-11-05 01:31:41 UTC (rev 158622)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h 2013-11-05 01:31:43 UTC (rev 158623)
@@ -57,7 +57,7 @@
RetainPtr<CGFontRef> m_cgFont;
};
-std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer*);
+std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer&);
}
Modified: trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp (158622 => 158623)
--- trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp 2013-11-05 01:31:41 UTC (rev 158622)
+++ trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp 2013-11-05 01:31:43 UTC (rev 158623)
@@ -24,7 +24,6 @@
#include "FontPlatformData.h"
#include "OpenTypeUtilities.h"
#include "SharedBuffer.h"
-#include "WOFFFileFormat.h"
#include <ApplicationServices/ApplicationServices.h>
#include <WebKitSystemInterface/WebKitSystemInterface.h>
#include <wtf/RetainPtr.h>
@@ -81,23 +80,11 @@
return fontName;
}
-std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer* buffer)
+std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer& buffer)
{
- ASSERT_ARG(buffer, buffer);
-
- RefPtr<SharedBuffer> sfntBuffer;
- if (isWOFF(buffer)) {
- Vector<char> sfnt;
- if (!convertWOFFToSfnt(buffer, sfnt))
- return nullptr;
-
- sfntBuffer = SharedBuffer::adoptVector(sfnt);
- buffer = sfntBuffer.get();
- }
-
String fontName = createUniqueFontName();
HANDLE fontReference;
- fontReference = renameAndActivateFont(*buffer, fontName);
+ fontReference = renameAndActivateFont(buffer, fontName);
if (!fontReference)
return nullptr;
return std::make_unique<FontCustomPlatformData>(fontReference, fontName);
Modified: trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h (158622 => 158623)
--- trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h 2013-11-05 01:31:41 UTC (rev 158622)
+++ trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformData.h 2013-11-05 01:31:43 UTC (rev 158623)
@@ -56,7 +56,7 @@
String m_name;
};
-std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer*);
+std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer&);
}
Modified: trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp (158622 => 158623)
--- trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp 2013-11-05 01:31:41 UTC (rev 158622)
+++ trunk/Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp 2013-11-05 01:31:43 UTC (rev 158623)
@@ -80,12 +80,10 @@
return fontName;
}
-std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer* buffer)
+std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer& buffer)
{
- ASSERT_ARG(buffer, buffer);
-
String fontName = createUniqueFontName();
- HANDLE fontReference = renameAndActivateFont(*buffer, fontName);
+ HANDLE fontReference = renameAndActivateFont(buffer, fontName);
if (!fontReference)
return nullptr;
Modified: trunk/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp (158622 => 158623)
--- trunk/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp 2013-11-05 01:31:41 UTC (rev 158622)
+++ trunk/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp 2013-11-05 01:31:43 UTC (rev 158623)
@@ -69,14 +69,12 @@
return fontName.replace('/', '_');
}
-std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(const SharedBuffer* buffer)
+std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer& buffer)
{
- ASSERT_ARG(buffer, buffer);
-
String fontName = createUniqueFontName();
Vector<char> rewrittenFontData;
- if (!renameFont(*buffer, fontName, rewrittenFontData))
+ if (!renameFont(buffer, fontName, rewrittenFontData))
return nullptr;
RefPtr<SharedBuffer> localBuffer = SharedBuffer::adoptVector(rewrittenFontData);
Modified: trunk/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h (158622 => 158623)
--- trunk/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h 2013-11-05 01:31:41 UTC (rev 158622)
+++ trunk/Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h 2013-11-05 01:31:43 UTC (rev 158623)
@@ -56,7 +56,7 @@
String m_name;
};
- std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(const SharedBuffer*);
+ std::unique_ptr<FontCustomPlatformData> createFontCustomPlatformData(SharedBuffer&);
void setCustomFontCache(CustomFontCache*);
}