Title: [177620] trunk/Source/WebCore
- Revision
- 177620
- Author
- mmaxfi...@apple.com
- Date
- 2014-12-19 20:41:57 -0800 (Fri, 19 Dec 2014)
Log Message
[SVG -> OTF Converter] Make placeholders more robust
https://bugs.webkit.org/show_bug.cgi?id=139836
Reviewed by Dan Bernstein.
This patch creates a Placeholder object which hides the complexity of
populating offsets to subtables.
No new tests because there is no behavior change.
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::Placeholder::Placeholder):
(WebCore::SVGToOTFFontConverter::Placeholder::populate):
(WebCore::SVGToOTFFontConverter::Placeholder::~Placeholder):
(WebCore::SVGToOTFFontConverter::appendArabicReplacementSubtable):
(WebCore::SVGToOTFFontConverter::appendGSUBTable):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (177619 => 177620)
--- trunk/Source/WebCore/ChangeLog 2014-12-20 04:39:03 UTC (rev 177619)
+++ trunk/Source/WebCore/ChangeLog 2014-12-20 04:41:57 UTC (rev 177620)
@@ -1,3 +1,22 @@
+2014-12-19 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ [SVG -> OTF Converter] Make placeholders more robust
+ https://bugs.webkit.org/show_bug.cgi?id=139836
+
+ Reviewed by Dan Bernstein.
+
+ This patch creates a Placeholder object which hides the complexity of
+ populating offsets to subtables.
+
+ No new tests because there is no behavior change.
+
+ * svg/SVGToOTFFontConversion.cpp:
+ (WebCore::SVGToOTFFontConverter::Placeholder::Placeholder):
+ (WebCore::SVGToOTFFontConverter::Placeholder::populate):
+ (WebCore::SVGToOTFFontConverter::Placeholder::~Placeholder):
+ (WebCore::SVGToOTFFontConverter::appendArabicReplacementSubtable):
+ (WebCore::SVGToOTFFontConverter::appendGSUBTable):
+
2014-12-19 Chris Dumez <cdu...@apple.com>
Fix initial / inherit support for '-webkit-perspective-origin' CSS property
Modified: trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp (177619 => 177620)
--- trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp 2014-12-20 04:39:03 UTC (rev 177619)
+++ trunk/Source/WebCore/svg/SVGToOTFFontConversion.cpp 2014-12-20 04:41:57 UTC (rev 177620)
@@ -77,6 +77,41 @@
float verticalAdvance;
};
+ class Placeholder {
+ public:
+ Placeholder(SVGToOTFFontConverter& converter, size_t baseOfOffset)
+ : m_converter(converter)
+ , m_baseOfOffset(baseOfOffset)
+ , m_location(m_converter.m_result.size())
+#if !ASSERT_DISABLED
+ , m_written(false)
+#endif
+ {
+ m_converter.append16(0);
+ }
+ void populate()
+ {
+ ASSERT(!m_written);
+ size_t delta = m_converter.m_result.size() - m_baseOfOffset;
+ ASSERT(delta < std::numeric_limits<uint16_t>::max());
+ m_converter.overwrite16(m_location, delta);
+#if !ASSERT_DISABLED
+ m_written = true;
+#endif
+ }
+ ~Placeholder()
+ {
+ ASSERT(m_written);
+ }
+ private:
+ SVGToOTFFontConverter& m_converter;
+ const size_t m_baseOfOffset;
+ const size_t m_location;
+#if !ASSERT_DISABLED
+ bool m_written;
+#endif
+ };
+
struct KerningData {
KerningData(uint16_t glyph1, uint16_t glyph2, int16_t adjustment)
: glyph1(glyph1)
@@ -89,6 +124,11 @@
int16_t adjustment;
};
+ Placeholder placeholder(size_t baseOfOffset)
+ {
+ return Placeholder(*this, baseOfOffset);
+ }
+
void append32(uint32_t value)
{
WebCore::append32(m_result, value);
@@ -577,12 +617,12 @@
overwrite16(subtableRecordLocation + 6, m_result.size() - subtableRecordLocation);
auto subtableLocation = m_result.size();
append16(2); // Format 2
- append16(0); // Placeholder for offset to coverage table, relative to beginning of substitution table
+ Placeholder toCoverageTable = placeholder(subtableLocation);
append16(arabicFinalReplacements.size()); // GlyphCount
for (auto& pair : arabicFinalReplacements)
append16(pair.second);
- overwrite16(subtableLocation + 2, m_result.size() - subtableLocation);
+ toCoverageTable.populate();
append16(1); // CoverageFormat
append16(arabicFinalReplacements.size()); // GlyphCount
for (auto& pair : arabicFinalReplacements)
@@ -596,10 +636,8 @@
append32(0x00010000); // Version
append16(headerSize); // Offset to ScriptList
- auto featureListOffsetLocation = m_result.size();
- append16(0); // Placeholder for FeatureList offset
- auto lookupListOffsetLocation = m_result.size();
- append16(0); // Placeholder for LookupList offset
+ Placeholder toFeatureList = placeholder(tableLocation);
+ Placeholder toLookupList = placeholder(tableLocation);
ASSERT(tableLocation + headerSize == m_result.size());
// ScriptList
@@ -622,7 +660,7 @@
append16(i); // Index of our feature into the FeatureList
// FeatureList
- overwrite16(featureListOffsetLocation, m_result.size() - tableLocation);
+ toFeatureList.populate();
auto featureListLocation = m_result.size();
size_t featureListSize = 2 + 6 * featureCount;
size_t featureTableSize = 6;
@@ -646,7 +684,7 @@
}
// LookupList
- overwrite16(lookupListOffsetLocation, m_result.size() - tableLocation);
+ toLookupList.populate();
auto lookupListLocation = m_result.size();
append16(featureCount); // LookupCount
for (unsigned i = 0; i < featureCount; ++i)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes