| Index: third_party/WebKit/Source/platform/fonts/VDMXParser.cpp
|
| diff --git a/third_party/WebKit/Source/platform/fonts/VDMXParser.cpp b/third_party/WebKit/Source/platform/fonts/VDMXParser.cpp
|
| index 677ad7dd5487550d1bd801f9df62250acc07d27f..22b7b03867331b488429acbd89dbaa8e82755bdf 100644
|
| --- a/third_party/WebKit/Source/platform/fonts/VDMXParser.cpp
|
| +++ b/third_party/WebKit/Source/platform/fonts/VDMXParser.cpp
|
| @@ -37,6 +37,9 @@
|
| #include <stdlib.h>
|
| #include <string.h>
|
|
|
| +namespace blink {
|
| +namespace {
|
| +
|
| // Buffer helper class
|
| //
|
| // This class perform some trival buffer operations while checking for
|
| @@ -48,46 +51,48 @@ class Buffer {
|
|
|
| public:
|
| Buffer(const uint8_t* buffer, size_t length)
|
| - : m_buffer(buffer), m_length(length), m_offset(0) {}
|
| + : buffer_(buffer), length_(length), offset_(0) {}
|
|
|
| bool skip(size_t numBytes) {
|
| - if (m_offset + numBytes > m_length)
|
| + if (offset_ + numBytes > length_)
|
| return false;
|
| - m_offset += numBytes;
|
| + offset_ += numBytes;
|
| return true;
|
| }
|
|
|
| - bool readU8(uint8_t* value) {
|
| - if (m_offset + sizeof(uint8_t) > m_length)
|
| + bool ReadU8(uint8_t* value) {
|
| + if (offset_ + sizeof(uint8_t) > length_)
|
| return false;
|
| - *value = m_buffer[m_offset];
|
| - m_offset += sizeof(uint8_t);
|
| + *value = buffer_[offset_];
|
| + offset_ += sizeof(uint8_t);
|
| return true;
|
| }
|
|
|
| - bool readU16(uint16_t* value) {
|
| - if (m_offset + sizeof(uint16_t) > m_length)
|
| + bool ReadU16(uint16_t* value) {
|
| + if (offset_ + sizeof(uint16_t) > length_)
|
| return false;
|
| - memcpy(value, m_buffer + m_offset, sizeof(uint16_t));
|
| + memcpy(value, buffer_ + offset_, sizeof(uint16_t));
|
| *value = ntohs(*value);
|
| - m_offset += sizeof(uint16_t);
|
| + offset_ += sizeof(uint16_t);
|
| return true;
|
| }
|
|
|
| - bool readS16(int16_t* value) {
|
| - return readU16(reinterpret_cast<uint16_t*>(value));
|
| + bool ReadS16(int16_t* value) {
|
| + return ReadU16(reinterpret_cast<uint16_t*>(value));
|
| }
|
|
|
| - size_t offset() const { return m_offset; }
|
| + size_t Offset() const { return offset_; }
|
|
|
| - void setOffset(size_t newoffset) { m_offset = newoffset; }
|
| + void SetOffset(size_t newoffset) { offset_ = newoffset; }
|
|
|
| private:
|
| - const uint8_t* const m_buffer;
|
| - const size_t m_length;
|
| - size_t m_offset;
|
| + const uint8_t* const buffer_;
|
| + const size_t length_;
|
| + size_t offset_;
|
| };
|
|
|
| +} // namespace
|
| +
|
| // VDMX parsing code.
|
| //
|
| // VDMX tables are found in some TrueType/OpenType fonts and contain
|
| @@ -96,8 +101,6 @@ class Buffer {
|
| //
|
| // Freetype does not parse these tables so we do so here.
|
|
|
| -namespace blink {
|
| -
|
| // Parse a TrueType VDMX table.
|
| // yMax: (output) the ascender value from the table
|
| // yMin: (output) the descender value from the table (negative!)
|
| @@ -119,7 +122,7 @@ bool ParseVDMX(int* y_max,
|
| // We ignore the version. Future tables should be backwards compatible with
|
| // this layout.
|
| uint16_t num_ratios;
|
| - if (!buf.skip(4) || !buf.readU16(&num_ratios))
|
| + if (!buf.skip(4) || !buf.ReadU16(&num_ratios))
|
| return false;
|
|
|
| // Now we have two tables. Firstly we have @numRatios Ratio records, then a
|
| @@ -128,7 +131,7 @@ bool ParseVDMX(int* y_max,
|
| //
|
| // Range 6 <= x <= 262146
|
| unsigned long offset_table_offset =
|
| - buf.offset() + 4 /* sizeof struct ratio */ * num_ratios;
|
| + buf.Offset() + 4 /* sizeof struct ratio */ * num_ratios;
|
|
|
| unsigned desired_ratio = 0xffffffff;
|
| // We read 4 bytes per record, so the offset range is
|
| @@ -136,8 +139,8 @@ bool ParseVDMX(int* y_max,
|
| for (unsigned i = 0; i < num_ratios; ++i) {
|
| uint8_t x_ratio, y_ratio1, y_ratio2;
|
|
|
| - if (!buf.skip(1) || !buf.readU8(&x_ratio) || !buf.readU8(&y_ratio1) ||
|
| - !buf.readU8(&y_ratio2))
|
| + if (!buf.skip(1) || !buf.ReadU8(&x_ratio) || !buf.ReadU8(&y_ratio1) ||
|
| + !buf.ReadU8(&y_ratio2))
|
| return false;
|
|
|
| // This either covers 1:1, or this is the default entry (0, 0, 0)
|
| @@ -152,24 +155,24 @@ bool ParseVDMX(int* y_max,
|
| return false;
|
|
|
| // Range 10 <= x <= 393216
|
| - buf.setOffset(offset_table_offset + sizeof(uint16_t) * desired_ratio);
|
| + buf.SetOffset(offset_table_offset + sizeof(uint16_t) * desired_ratio);
|
|
|
| // Now we read from the offset table to get the offset of another array
|
| uint16_t group_offset;
|
| - if (!buf.readU16(&group_offset))
|
| + if (!buf.ReadU16(&group_offset))
|
| return false;
|
| // Range 0 <= x <= 65535
|
| - buf.setOffset(group_offset);
|
| + buf.SetOffset(group_offset);
|
|
|
| uint16_t num_records;
|
| - if (!buf.readU16(&num_records) || !buf.skip(sizeof(uint16_t)))
|
| + if (!buf.ReadU16(&num_records) || !buf.skip(sizeof(uint16_t)))
|
| return false;
|
|
|
| // We read 6 bytes per record, so the offset range is
|
| // 4 <= x <= 458749
|
| for (unsigned i = 0; i < num_records; ++i) {
|
| uint16_t pixel_size;
|
| - if (!buf.readU16(&pixel_size))
|
| + if (!buf.ReadU16(&pixel_size))
|
| return false;
|
| // the entries are sorted, so we can abort early if need be
|
| if (pixel_size > target_pixel_size)
|
| @@ -177,7 +180,7 @@ bool ParseVDMX(int* y_max,
|
|
|
| if (pixel_size == target_pixel_size) {
|
| int16_t temp_y_max, temp_y_min;
|
| - if (!buf.readS16(&temp_y_max) || !buf.readS16(&temp_y_min))
|
| + if (!buf.ReadS16(&temp_y_max) || !buf.ReadS16(&temp_y_min))
|
| return false;
|
| *y_min = temp_y_min;
|
| *y_max = temp_y_max;
|
|
|