Diff
Modified: trunk/Source/WebCore/ChangeLog (174557 => 174558)
--- trunk/Source/WebCore/ChangeLog 2014-10-10 03:57:14 UTC (rev 174557)
+++ trunk/Source/WebCore/ChangeLog 2014-10-10 04:21:57 UTC (rev 174558)
@@ -1,3 +1,25 @@
+2014-10-09 Chris Dumez <[email protected]>
+
+ Use is<>() / downcast<>() for FontData subclasses
+ https://bugs.webkit.org/show_bug.cgi?id=137591
+
+ Reviewed by Andreas Kling.
+
+ Use is<>() / downcast<>() for FontData subclasses.
+
+ No new tests, no behavior change.
+
+ * platform/graphics/FontData.h:
+ * platform/graphics/FontGlyphs.cpp:
+ (WebCore::FontGlyphs::releaseFontData):
+ (WebCore::FontGlyphs::determinePitch):
+ * platform/graphics/GlyphPageTreeNode.cpp:
+ (WebCore::GlyphPageTreeNode::initializePage):
+ * platform/graphics/SegmentedFontData.h:
+ (isType):
+ * platform/graphics/SimpleFontData.h:
+ (isType):
+
2014-10-09 Simon Fraser <[email protected]>
Revert part of r174543 that broke grid layout tests.
Modified: trunk/Source/WebCore/platform/graphics/FontData.h (174557 => 174558)
--- trunk/Source/WebCore/platform/graphics/FontData.h 2014-10-10 03:57:14 UTC (rev 174557)
+++ trunk/Source/WebCore/platform/graphics/FontData.h 2014-10-10 04:21:57 UTC (rev 174558)
@@ -64,10 +64,6 @@
mutable unsigned m_maxGlyphPageTreeLevel;
};
-#define FONT_DATA_TYPE_CASTS(ToValueTypeName, pointerPredicate, referencePredicate) \
- template<typename T> inline ToValueTypeName* to##ToValueTypeName(const RefPtr<T>& fontData) { return to##ToValueTypeName(fontData.get()); } \
- TYPE_CASTS_BASE(ToValueTypeName, FontData, fontData, pointerPredicate, referencePredicate)
-
} // namespace WebCore
#endif // FontData_h
Modified: trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp (174557 => 174558)
--- trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp 2014-10-10 03:57:14 UTC (rev 174557)
+++ trunk/Source/WebCore/platform/graphics/FontGlyphs.cpp 2014-10-10 04:21:57 UTC (rev 174558)
@@ -70,18 +70,17 @@
for (unsigned i = 0; i < numFonts; ++i) {
if (m_realizedFontData[i]->isCustomFont())
continue;
- ASSERT(!m_realizedFontData[i]->isSegmented());
- fontCache().releaseFontData(toSimpleFontData(m_realizedFontData[i]));
+ fontCache().releaseFontData(downcast<SimpleFontData>(m_realizedFontData[i].get()));
}
}
void FontGlyphs::determinePitch(const FontDescription& description) const
{
const FontData* fontData = primaryFontData(description);
- if (!fontData->isSegmented())
- m_pitch = toSimpleFontData(*fontData).pitch();
+ if (is<SimpleFontData>(*fontData))
+ m_pitch = downcast<SimpleFontData>(*fontData).pitch();
else {
- const SegmentedFontData& segmentedFontData = toSegmentedFontData(*fontData);
+ const SegmentedFontData& segmentedFontData = downcast<SegmentedFontData>(*fontData);
unsigned numRanges = segmentedFontData.numRanges();
if (numRanges == 1)
m_pitch = segmentedFontData.rangeAt(0).fontData()->pitch();
Modified: trunk/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp (174557 => 174558)
--- trunk/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp 2014-10-10 03:57:14 UTC (rev 174557)
+++ trunk/Source/WebCore/platform/graphics/GlyphPageTreeNode.cpp 2014-10-10 04:21:57 UTC (rev 174558)
@@ -206,31 +206,31 @@
// Success is not guaranteed. For example, Times fails to fill page 260, giving glyph data
// for only 128 out of 256 characters.
bool haveGlyphs;
- if (!fontData->isSegmented()) {
- if (GlyphPage::mayUseMixedFontDataWhenFilling(buffer, bufferLength, toSimpleFontData(fontData)))
+ if (is<SimpleFontData>(*fontData)) {
+ if (GlyphPage::mayUseMixedFontDataWhenFilling(buffer, bufferLength, downcast<SimpleFontData>(fontData)))
m_page = GlyphPage::createForMixedFontData(this);
else
- m_page = GlyphPage::createForSingleFontData(this, toSimpleFontData(fontData));
+ m_page = GlyphPage::createForSingleFontData(this, downcast<SimpleFontData>(fontData));
#if PLATFORM(IOS)
// FIXME: Times New Roman contains Arabic glyphs, but Core Text doesn't know how to shape them. See <rdar://problem/9823975>.
// Once we have the fix for <rdar://problem/9823975> then remove this code together with SimpleFontData::shouldNotBeUsedForArabic()
// in <rdar://problem/12096835>.
- if (pageNumber == 6 && toSimpleFontData(fontData)->shouldNotBeUsedForArabic())
+ if (pageNumber == 6 && downcast<SimpleFontData>(*fontData).shouldNotBeUsedForArabic())
haveGlyphs = false;
else
#endif
- haveGlyphs = fill(m_page.get(), 0, GlyphPage::size, buffer, bufferLength, toSimpleFontData(fontData));
+ haveGlyphs = fill(m_page.get(), 0, GlyphPage::size, buffer, bufferLength, downcast<SimpleFontData>(fontData));
} else {
m_page = GlyphPage::createForMixedFontData(this);
haveGlyphs = false;
- const SegmentedFontData* segmentedFontData = toSegmentedFontData(fontData);
- unsigned numRanges = segmentedFontData->numRanges();
+ const SegmentedFontData& segmentedFontData = downcast<SegmentedFontData>(*fontData);
+ unsigned numRanges = segmentedFontData.numRanges();
bool zeroFilled = false;
RefPtr<GlyphPage> scratchPage;
GlyphPage* pageToFill = m_page.get();
for (unsigned i = 0; i < numRanges; i++) {
- const FontDataRange& range = segmentedFontData->rangeAt(i);
+ const FontDataRange& range = segmentedFontData.rangeAt(i);
// all this casting is to ensure all the parameters to min and max have the same type,
// to avoid ambiguous template parameter errors on Windows
int from = std::max(0, static_cast<int>(range.from()) - static_cast<int>(start));
Modified: trunk/Source/WebCore/platform/graphics/SegmentedFontData.h (174557 => 174558)
--- trunk/Source/WebCore/platform/graphics/SegmentedFontData.h 2014-10-10 03:57:14 UTC (rev 174557)
+++ trunk/Source/WebCore/platform/graphics/SegmentedFontData.h 2014-10-10 04:21:57 UTC (rev 174558)
@@ -27,6 +27,7 @@
#define SegmentedFontData_h
#include "FontData.h"
+#include <wtf/TypeCasts.h>
#include <wtf/Vector.h>
namespace WebCore {
@@ -80,8 +81,10 @@
Vector<FontDataRange, 1> m_ranges;
};
-FONT_DATA_TYPE_CASTS(SegmentedFontData, fontData->isSegmented(), fontData.isSegmented())
-
} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SegmentedFontData)
+ static bool isType(const WebCore::FontData& fontData) { return fontData.isSegmented(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif // SegmentedFontData_h
Modified: trunk/Source/WebCore/platform/graphics/SimpleFontData.h (174557 => 174558)
--- trunk/Source/WebCore/platform/graphics/SimpleFontData.h 2014-10-10 03:57:14 UTC (rev 174557)
+++ trunk/Source/WebCore/platform/graphics/SimpleFontData.h 2014-10-10 04:21:57 UTC (rev 174558)
@@ -39,6 +39,7 @@
#include "TypesettingFeatures.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
+#include <wtf/TypeCasts.h>
#include <wtf/text/StringHash.h>
#if PLATFORM(COCOA)
@@ -391,7 +392,10 @@
return width;
}
-FONT_DATA_TYPE_CASTS(SimpleFontData, !fontData->isSegmented(), !fontData.isSegmented())
+} // namespace WebCore
-} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::SimpleFontData)
+ static bool isType(const WebCore::FontData& fontData) { return !fontData.isSegmented(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
#endif // SimpleFontData_h