Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(465)

Unified Diff: third_party/harfbuzz-ng/src/hb-ot-layout-gpos-table.hh

Issue 10510004: Roll harfbuzz-ng 3b8fd9c48f4bde368bf2d465c148b9743a9216ee (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/harfbuzz-ng/src/hb-ot-layout-gpos-table.hh
diff --git a/third_party/harfbuzz-ng/src/hb-ot-layout-gpos-table.hh b/third_party/harfbuzz-ng/src/hb-ot-layout-gpos-table.hh
index 412850ba3506e7f1ba7ece0fb08966def4ca7be7..71c13a2e06f562354d5cadc2a07e41e3fe79d37c 100644
--- a/third_party/harfbuzz-ng/src/hb-ot-layout-gpos-table.hh
+++ b/third_party/harfbuzz-ng/src/hb-ot-layout-gpos-table.hh
@@ -1,6 +1,6 @@
/*
* Copyright © 2007,2008,2009,2010 Red Hat, Inc.
- * Copyright © 2010 Google, Inc.
+ * Copyright © 2010,2012 Google, Inc.
*
* This is part of HarfBuzz, a text shaping library.
*
@@ -46,8 +46,7 @@ typedef Value ValueRecord[VAR];
struct ValueFormat : USHORT
{
- enum
- {
+ enum Flags {
xPlacement = 0x0001, /* Includes horizontal adjustment for placement */
yPlacement = 0x0002, /* Includes vertical adjustment for placement */
xAdvance = 0x0004, /* Includes horizontal adjustment for advance */
@@ -172,40 +171,39 @@ struct ValueFormat : USHORT
inline bool sanitize_value (hb_sanitize_context_t *c, void *base, Value *values) {
TRACE_SANITIZE ();
- return c->check_range (values, get_size ())
- && (!has_device () || sanitize_value_devices (c, base, values));
+ return TRACE_RETURN (c->check_range (values, get_size ()) && (!has_device () || sanitize_value_devices (c, base, values)));
}
inline bool sanitize_values (hb_sanitize_context_t *c, void *base, Value *values, unsigned int count) {
TRACE_SANITIZE ();
unsigned int len = get_len ();
- if (!c->check_array (values, get_size (), count)) return false;
+ if (!c->check_array (values, get_size (), count)) return TRACE_RETURN (false);
- if (!has_device ()) return true;
+ if (!has_device ()) return TRACE_RETURN (true);
for (unsigned int i = 0; i < count; i++) {
if (!sanitize_value_devices (c, base, values))
- return false;
+ return TRACE_RETURN (false);
values += len;
}
- return true;
+ return TRACE_RETURN (true);
}
/* Just sanitize referenced Device tables. Doesn't check the values themselves. */
inline bool sanitize_values_stride_unsafe (hb_sanitize_context_t *c, void *base, Value *values, unsigned int count, unsigned int stride) {
TRACE_SANITIZE ();
- if (!has_device ()) return true;
+ if (!has_device ()) return TRACE_RETURN (true);
for (unsigned int i = 0; i < count; i++) {
if (!sanitize_value_devices (c, base, values))
- return false;
+ return TRACE_RETURN (false);
values += stride;
}
- return true;
+ return TRACE_RETURN (true);
}
};
@@ -224,7 +222,7 @@ struct AnchorFormat1
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return c->check_struct (this);
+ return TRACE_RETURN (c->check_struct (this));
}
private:
@@ -256,7 +254,7 @@ struct AnchorFormat2
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return c->check_struct (this);
+ return TRACE_RETURN (c->check_struct (this));
}
private:
@@ -287,9 +285,7 @@ struct AnchorFormat3
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return c->check_struct (this)
- && xDeviceTable.sanitize (c, this)
- && yDeviceTable.sanitize (c, this);
+ return TRACE_RETURN (c->check_struct (this) && xDeviceTable.sanitize (c, this) && yDeviceTable.sanitize (c, this));
}
private:
@@ -324,12 +320,12 @@ struct Anchor
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (!u.format.sanitize (c)) return false;
+ if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
- case 1: return u.format1.sanitize (c);
- case 2: return u.format2.sanitize (c);
- case 3: return u.format3.sanitize (c);
- default:return true;
+ case 1: return TRACE_RETURN (u.format1.sanitize (c));
+ case 2: return TRACE_RETURN (u.format2.sanitize (c));
+ case 3: return TRACE_RETURN (u.format3.sanitize (c));
+ default:return TRACE_RETURN (true);
}
}
@@ -354,13 +350,13 @@ struct AnchorMatrix
inline bool sanitize (hb_sanitize_context_t *c, unsigned int cols) {
TRACE_SANITIZE ();
- if (!c->check_struct (this)) return false;
- if (unlikely (rows > 0 && cols >= ((unsigned int) -1) / rows)) return false;
+ if (!c->check_struct (this)) return TRACE_RETURN (false);
+ if (unlikely (rows > 0 && cols >= ((unsigned int) -1) / rows)) return TRACE_RETURN (false);
unsigned int count = rows * cols;
- if (!c->check_array (matrix, matrix[0].static_size, count)) return false;
+ if (!c->check_array (matrix, matrix[0].static_size, count)) return TRACE_RETURN (false);
for (unsigned int i = 0; i < count; i++)
- if (!matrix[i].sanitize (c, this)) return false;
- return true;
+ if (!matrix[i].sanitize (c, this)) return TRACE_RETURN (false);
+ return TRACE_RETURN (true);
}
USHORT rows; /* Number of rows */
@@ -379,8 +375,7 @@ struct MarkRecord
inline bool sanitize (hb_sanitize_context_t *c, void *base) {
TRACE_SANITIZE ();
- return c->check_struct (this)
- && markAnchor.sanitize (c, base);
+ return TRACE_RETURN (c->check_struct (this) && markAnchor.sanitize (c, base));
}
private:
@@ -408,21 +403,21 @@ struct MarkArray : ArrayOf<MarkRecord> /* Array of MarkRecords--in Coverage orde
hb_position_t mark_x, mark_y, base_x, base_y;
- mark_anchor.get_anchor (c->font, c->buffer->info[c->buffer->idx].codepoint, &mark_x, &mark_y);
+ mark_anchor.get_anchor (c->font, c->buffer->cur().codepoint, &mark_x, &mark_y);
glyph_anchor.get_anchor (c->font, c->buffer->info[glyph_pos].codepoint, &base_x, &base_y);
- hb_glyph_position_t &o = c->buffer->pos[c->buffer->idx];
+ hb_glyph_position_t &o = c->buffer->cur_pos();
o.x_offset = base_x - mark_x;
o.y_offset = base_y - mark_y;
o.attach_lookback() = c->buffer->idx - glyph_pos;
c->buffer->idx++;
- return true;
+ return TRACE_RETURN (true);
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return ArrayOf<MarkRecord>::sanitize (c, this);
+ return TRACE_RETURN (ArrayOf<MarkRecord>::sanitize (c, this));
}
};
@@ -437,22 +432,19 @@ struct SinglePosFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
- if (likely (index == NOT_COVERED))
- return false;
+ unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
+ if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
valueFormat.apply_value (c->font, c->direction, this,
- values, c->buffer->pos[c->buffer->idx]);
+ values, c->buffer->cur_pos());
c->buffer->idx++;
- return true;
+ return TRACE_RETURN (true);
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return c->check_struct (this)
- && coverage.sanitize (c, this)
- && valueFormat.sanitize_value (c, this, values);
+ return TRACE_RETURN (c->check_struct (this) && coverage.sanitize (c, this) && valueFormat.sanitize_value (c, this, values));
}
private:
@@ -477,26 +469,22 @@ struct SinglePosFormat2
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
- if (likely (index == NOT_COVERED))
- return false;
+ unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
+ if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
- if (likely (index >= valueCount))
- return false;
+ if (likely (index >= valueCount)) return TRACE_RETURN (false);
valueFormat.apply_value (c->font, c->direction, this,
&values[index * valueFormat.get_len ()],
- c->buffer->pos[c->buffer->idx]);
+ c->buffer->cur_pos());
c->buffer->idx++;
- return true;
+ return TRACE_RETURN (true);
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return c->check_struct (this)
- && coverage.sanitize (c, this)
- && valueFormat.sanitize_values (c, this, values, valueCount);
+ return TRACE_RETURN (c->check_struct (this) && coverage.sanitize (c, this) && valueFormat.sanitize_values (c, this, values, valueCount));
}
private:
@@ -522,19 +510,19 @@ struct SinglePos
{
TRACE_APPLY ();
switch (u.format) {
- case 1: return u.format1.apply (c);
- case 2: return u.format2.apply (c);
- default:return false;
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ case 2: return TRACE_RETURN (u.format2.apply (c));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (!u.format.sanitize (c)) return false;
+ if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
- case 1: return u.format1.sanitize (c);
- case 2: return u.format2.sanitize (c);
- default:return true;
+ case 1: return TRACE_RETURN (u.format1.sanitize (c));
+ case 2: return TRACE_RETURN (u.format2.sanitize (c));
+ default:return TRACE_RETURN (true);
}
}
@@ -581,18 +569,18 @@ struct PairSet
if (c->buffer->info[pos].codepoint == record->secondGlyph)
{
valueFormats[0].apply_value (c->font, c->direction, this,
- &record->values[0], c->buffer->pos[c->buffer->idx]);
+ &record->values[0], c->buffer->cur_pos());
valueFormats[1].apply_value (c->font, c->direction, this,
&record->values[len1], c->buffer->pos[pos]);
if (len2)
pos++;
c->buffer->idx = pos;
- return true;
+ return TRACE_RETURN (true);
}
record = &StructAtOffset<PairValueRecord> (record, record_size);
}
- return false;
+ return TRACE_RETURN (false);
}
struct sanitize_closure_t {
@@ -605,12 +593,12 @@ struct PairSet
inline bool sanitize (hb_sanitize_context_t *c, const sanitize_closure_t *closure) {
TRACE_SANITIZE ();
if (!(c->check_struct (this)
- && c->check_array (array, USHORT::static_size * closure->stride, len))) return false;
+ && c->check_array (array, USHORT::static_size * closure->stride, len))) return TRACE_RETURN (false);
unsigned int count = len;
PairValueRecord *record = CastP<PairValueRecord> (array);
- return closure->valueFormats[0].sanitize_values_stride_unsafe (c, closure->base, &record->values[0], count, closure->stride)
- && closure->valueFormats[1].sanitize_values_stride_unsafe (c, closure->base, &record->values[closure->len1], count, closure->stride);
+ return TRACE_RETURN (closure->valueFormats[0].sanitize_values_stride_unsafe (c, closure->base, &record->values[0], count, closure->stride)
+ && closure->valueFormats[1].sanitize_values_stride_unsafe (c, closure->base, &record->values[closure->len1], count, closure->stride));
}
private:
@@ -630,17 +618,14 @@ struct PairPosFormat1
{
TRACE_APPLY ();
hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
- if (skippy_iter.has_no_chance ())
- return false;
+ if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
- unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
- if (likely (index == NOT_COVERED))
- return false;
+ unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
+ if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
- if (!skippy_iter.next ())
- return false;
+ if (!skippy_iter.next ()) return TRACE_RETURN (false);
- return (this+pairSet[index]).apply (c, &valueFormat1, skippy_iter.idx);
+ return TRACE_RETURN ((this+pairSet[index]).apply (c, &valueFormat1, skippy_iter.idx));
}
inline bool sanitize (hb_sanitize_context_t *c) {
@@ -655,9 +640,7 @@ struct PairPosFormat1
1 + len1 + len2
};
- return c->check_struct (this)
- && coverage.sanitize (c, this)
- && pairSet.sanitize (c, this, &closure);
+ return TRACE_RETURN (c->check_struct (this) && coverage.sanitize (c, this) && pairSet.sanitize (c, this, &closure));
}
private:
@@ -687,28 +670,24 @@ struct PairPosFormat2
{
TRACE_APPLY ();
hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
- if (skippy_iter.has_no_chance ())
- return false;
+ if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
- unsigned int index = (this+coverage) (c->buffer->info[c->buffer->idx].codepoint);
- if (likely (index == NOT_COVERED))
- return false;
+ unsigned int index = (this+coverage) (c->buffer->cur().codepoint);
+ if (likely (index == NOT_COVERED)) return TRACE_RETURN (false);
- if (!skippy_iter.next ())
- return false;
+ if (!skippy_iter.next ()) return TRACE_RETURN (false);
unsigned int len1 = valueFormat1.get_len ();
unsigned int len2 = valueFormat2.get_len ();
unsigned int record_len = len1 + len2;
- unsigned int klass1 = (this+classDef1) (c->buffer->info[c->buffer->idx].codepoint);
+ unsigned int klass1 = (this+classDef1) (c->buffer->cur().codepoint);
unsigned int klass2 = (this+classDef2) (c->buffer->info[skippy_iter.idx].codepoint);
- if (unlikely (klass1 >= class1Count || klass2 >= class2Count))
- return false;
+ if (unlikely (klass1 >= class1Count || klass2 >= class2Count)) return TRACE_RETURN (false);
const Value *v = &values[record_len * (klass1 * class2Count + klass2)];
valueFormat1.apply_value (c->font, c->direction, this,
- v, c->buffer->pos[c->buffer->idx]);
+ v, c->buffer->cur_pos());
valueFormat2.apply_value (c->font, c->direction, this,
v + len1, c->buffer->pos[skippy_iter.idx]);
@@ -716,7 +695,7 @@ struct PairPosFormat2
if (len2)
c->buffer->idx++;
- return true;
+ return TRACE_RETURN (true);
}
inline bool sanitize (hb_sanitize_context_t *c) {
@@ -724,16 +703,16 @@ struct PairPosFormat2
if (!(c->check_struct (this)
&& coverage.sanitize (c, this)
&& classDef1.sanitize (c, this)
- && classDef2.sanitize (c, this))) return false;
+ && classDef2.sanitize (c, this))) return TRACE_RETURN (false);
unsigned int len1 = valueFormat1.get_len ();
unsigned int len2 = valueFormat2.get_len ();
unsigned int stride = len1 + len2;
unsigned int record_size = valueFormat1.get_size () + valueFormat2.get_size ();
unsigned int count = (unsigned int) class1Count * (unsigned int) class2Count;
- return c->check_array (values, record_size, count) &&
- valueFormat1.sanitize_values_stride_unsafe (c, this, &values[0], count, stride) &&
- valueFormat2.sanitize_values_stride_unsafe (c, this, &values[len1], count, stride);
+ return TRACE_RETURN (c->check_array (values, record_size, count) &&
+ valueFormat1.sanitize_values_stride_unsafe (c, this, &values[0], count, stride) &&
+ valueFormat2.sanitize_values_stride_unsafe (c, this, &values[len1], count, stride));
}
private:
@@ -775,19 +754,19 @@ struct PairPos
{
TRACE_APPLY ();
switch (u.format) {
- case 1: return u.format1.apply (c);
- case 2: return u.format2.apply (c);
- default:return false;
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ case 2: return TRACE_RETURN (u.format2.apply (c));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (!u.format.sanitize (c)) return false;
+ if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
- case 1: return u.format1.sanitize (c);
- case 2: return u.format2.sanitize (c);
- default:return true;
+ case 1: return TRACE_RETURN (u.format1.sanitize (c));
+ case 2: return TRACE_RETURN (u.format2.sanitize (c));
+ default:return TRACE_RETURN (true);
}
}
@@ -806,8 +785,7 @@ struct EntryExitRecord
inline bool sanitize (hb_sanitize_context_t *c, void *base) {
TRACE_SANITIZE ();
- return entryAnchor.sanitize (c, base)
- && exitAnchor.sanitize (c, base);
+ return TRACE_RETURN (entryAnchor.sanitize (c, base) && exitAnchor.sanitize (c, base));
}
private:
@@ -833,23 +811,18 @@ struct CursivePosFormat1
TRACE_APPLY ();
/* We don't handle mark glyphs here. */
- if (c->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)
- return false;
+ if (c->property & HB_OT_LAYOUT_GLYPH_CLASS_MARK) return TRACE_RETURN (false);
hb_apply_context_t::mark_skipping_forward_iterator_t skippy_iter (c, c->buffer->idx, 1);
- if (skippy_iter.has_no_chance ())
- return false;
+ if (skippy_iter.has_no_chance ()) return TRACE_RETURN (false);
- const EntryExitRecord &this_record = entryExitRecord[(this+coverage) (c->buffer->info[c->buffer->idx].codepoint)];
- if (!this_record.exitAnchor)
- return false;
+ const EntryExitRecord &this_record = entryExitRecord[(this+coverage) (c->buffer->cur().codepoint)];
+ if (!this_record.exitAnchor) return TRACE_RETURN (false);
- if (!skippy_iter.next ())
- return false;
+ if (!skippy_iter.next ()) return TRACE_RETURN (false);
const EntryExitRecord &next_record = entryExitRecord[(this+coverage) (c->buffer->info[skippy_iter.idx].codepoint)];
- if (!next_record.entryAnchor)
- return false;
+ if (!next_record.entryAnchor) return TRACE_RETURN (false);
unsigned int i = c->buffer->idx;
unsigned int j = skippy_iter.idx;
@@ -912,13 +885,12 @@ struct CursivePosFormat1
}
c->buffer->idx = j;
- return true;
+ return TRACE_RETURN (true);
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return coverage.sanitize (c, this)
- && entryExitRecord.sanitize (c, this);
+ return TRACE_RETURN (coverage.sanitize (c, this) && entryExitRecord.sanitize (c, this));
}
private:
@@ -942,17 +914,17 @@ struct CursivePos
{
TRACE_APPLY ();
switch (u.format) {
- case 1: return u.format1.apply (c);
- default:return false;
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (!u.format.sanitize (c)) return false;
+ if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
- case 1: return u.format1.sanitize (c);
- default:return true;
+ case 1: return TRACE_RETURN (u.format1.sanitize (c));
+ default:return TRACE_RETURN (true);
}
}
@@ -977,34 +949,27 @@ struct MarkBasePosFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- unsigned int mark_index = (this+markCoverage) (c->buffer->info[c->buffer->idx].codepoint);
- if (likely (mark_index == NOT_COVERED))
- return false;
+ unsigned int mark_index = (this+markCoverage) (c->buffer->cur().codepoint);
+ if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a non-mark glyph */
unsigned int property;
hb_apply_context_t::mark_skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1);
- if (!skippy_iter.prev (&property, LookupFlag::IgnoreMarks))
- return false;
+ if (!skippy_iter.prev (&property, LookupFlag::IgnoreMarks)) return TRACE_RETURN (false);
/* The following assertion is too strong, so we've disabled it. */
- if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH))
- {/*return false;*/}
+ if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_BASE_GLYPH)) {/*return TRACE_RETURN (false);*/}
unsigned int base_index = (this+baseCoverage) (c->buffer->info[skippy_iter.idx].codepoint);
- if (base_index == NOT_COVERED)
- return false;
+ if (base_index == NOT_COVERED) return TRACE_RETURN (false);
- return (this+markArray).apply (c, mark_index, base_index, this+baseArray, classCount, skippy_iter.idx);
+ return TRACE_RETURN ((this+markArray).apply (c, mark_index, base_index, this+baseArray, classCount, skippy_iter.idx));
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return c->check_struct (this)
- && markCoverage.sanitize (c, this)
- && baseCoverage.sanitize (c, this)
- && markArray.sanitize (c, this)
- && baseArray.sanitize (c, this, (unsigned int) classCount);
+ return TRACE_RETURN (c->check_struct (this) && markCoverage.sanitize (c, this) && baseCoverage.sanitize (c, this) &&
+ markArray.sanitize (c, this) && baseArray.sanitize (c, this, (unsigned int) classCount));
}
private:
@@ -1035,17 +1000,17 @@ struct MarkBasePos
{
TRACE_APPLY ();
switch (u.format) {
- case 1: return u.format1.apply (c);
- default:return false;
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (!u.format.sanitize (c)) return false;
+ if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
- case 1: return u.format1.sanitize (c);
- default:return true;
+ case 1: return TRACE_RETURN (u.format1.sanitize (c));
+ default:return TRACE_RETURN (true);
}
}
@@ -1075,56 +1040,51 @@ struct MarkLigPosFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- unsigned int mark_index = (this+markCoverage) (c->buffer->info[c->buffer->idx].codepoint);
- if (likely (mark_index == NOT_COVERED))
- return false;
+ unsigned int mark_index = (this+markCoverage) (c->buffer->cur().codepoint);
+ if (likely (mark_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a non-mark glyph */
unsigned int property;
hb_apply_context_t::mark_skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1);
- if (!skippy_iter.prev (&property, LookupFlag::IgnoreMarks))
- return false;
+ if (!skippy_iter.prev (&property, LookupFlag::IgnoreMarks)) return TRACE_RETURN (false);
/* The following assertion is too strong, so we've disabled it. */
- if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE))
- {/*return false;*/}
+ if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_LIGATURE)) {/*return TRACE_RETURN (false);*/}
unsigned int j = skippy_iter.idx;
unsigned int lig_index = (this+ligatureCoverage) (c->buffer->info[j].codepoint);
- if (lig_index == NOT_COVERED)
- return false;
+ if (lig_index == NOT_COVERED) return TRACE_RETURN (false);
const LigatureArray& lig_array = this+ligatureArray;
const LigatureAttach& lig_attach = lig_array[lig_index];
/* Find component to attach to */
unsigned int comp_count = lig_attach.rows;
- if (unlikely (!comp_count))
- return false;
+ if (unlikely (!comp_count)) return TRACE_RETURN (false);
+
unsigned int comp_index;
/* We must now check whether the ligature ID of the current mark glyph
* is identical to the ligature ID of the found ligature. If yes, we
* can directly use the component index. If not, we attach the mark
* glyph to the last component of the ligature. */
- if (c->buffer->info[j].lig_id() && c->buffer->info[j].lig_id() == c->buffer->info[c->buffer->idx].lig_id() && c->buffer->info[c->buffer->idx].lig_comp())
+ if (get_lig_id (c->buffer->info[j]) &&
+ get_lig_id (c->buffer->cur()) &&
+ get_lig_comp (c->buffer->cur()) > 0)
{
- comp_index = c->buffer->info[c->buffer->idx].lig_comp() - 1;
+ comp_index = get_lig_comp (c->buffer->cur()) - 1;
if (comp_index >= comp_count)
comp_index = comp_count - 1;
}
else
comp_index = comp_count - 1;
- return (this+markArray).apply (c, mark_index, comp_index, lig_attach, classCount, j);
+ return TRACE_RETURN ((this+markArray).apply (c, mark_index, comp_index, lig_attach, classCount, j));
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return c->check_struct (this)
- && markCoverage.sanitize (c, this)
- && ligatureCoverage.sanitize (c, this)
- && markArray.sanitize (c, this)
- && ligatureArray.sanitize (c, this, (unsigned int) classCount);
+ return TRACE_RETURN (c->check_struct (this) && markCoverage.sanitize (c, this) && ligatureCoverage.sanitize (c, this) &&
+ markArray.sanitize (c, this) && ligatureArray.sanitize (c, this, (unsigned int) classCount));
}
private:
@@ -1156,17 +1116,17 @@ struct MarkLigPos
{
TRACE_APPLY ();
switch (u.format) {
- case 1: return u.format1.apply (c);
- default:return false;
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (!u.format.sanitize (c)) return false;
+ if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
- case 1: return u.format1.sanitize (c);
- default:return true;
+ case 1: return TRACE_RETURN (u.format1.sanitize (c));
+ default:return TRACE_RETURN (true);
}
}
@@ -1191,42 +1151,37 @@ struct MarkMarkPosFormat1
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- unsigned int mark1_index = (this+mark1Coverage) (c->buffer->info[c->buffer->idx].codepoint);
- if (likely (mark1_index == NOT_COVERED))
- return false;
+ unsigned int mark1_index = (this+mark1Coverage) (c->buffer->cur().codepoint);
+ if (likely (mark1_index == NOT_COVERED)) return TRACE_RETURN (false);
/* now we search backwards for a suitable mark glyph until a non-mark glyph */
unsigned int property;
hb_apply_context_t::mark_skipping_backward_iterator_t skippy_iter (c, c->buffer->idx, 1);
- if (!skippy_iter.prev (&property))
- return false;
+ if (!skippy_iter.prev (&property)) return TRACE_RETURN (false);
- if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK))
- return false;
+ if (!(property & HB_OT_LAYOUT_GLYPH_CLASS_MARK)) return TRACE_RETURN (false);
unsigned int j = skippy_iter.idx;
/* Two marks match only if they belong to the same base, or same component
* of the same ligature. That is, the component numbers must match, and
* if those are non-zero, the ligid number should also match. */
- if ((c->buffer->info[j].lig_comp() != c->buffer->info[c->buffer->idx].lig_comp()) ||
- (c->buffer->info[j].lig_comp() && c->buffer->info[j].lig_id() != c->buffer->info[c->buffer->idx].lig_id()))
- return false;
+ if ((get_lig_comp (c->buffer->cur())) ||
+ (get_lig_comp (c->buffer->info[j]) > 0 &&
+ get_lig_id (c->buffer->cur())))
+ return TRACE_RETURN (false);
unsigned int mark2_index = (this+mark2Coverage) (c->buffer->info[j].codepoint);
- if (mark2_index == NOT_COVERED)
- return false;
+ if (mark2_index == NOT_COVERED) return TRACE_RETURN (false);
- return (this+mark1Array).apply (c, mark1_index, mark2_index, this+mark2Array, classCount, j);
+ return TRACE_RETURN ((this+mark1Array).apply (c, mark1_index, mark2_index, this+mark2Array, classCount, j));
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- return c->check_struct (this)
- && mark1Coverage.sanitize (c, this)
- && mark2Coverage.sanitize (c, this)
- && mark1Array.sanitize (c, this)
- && mark2Array.sanitize (c, this, (unsigned int) classCount);
+ return TRACE_RETURN (c->check_struct (this) && mark1Coverage.sanitize (c, this) &&
+ mark2Coverage.sanitize (c, this) && mark1Array.sanitize (c, this)
+ && mark2Array.sanitize (c, this, (unsigned int) classCount));
}
private:
@@ -1259,17 +1214,17 @@ struct MarkMarkPos
{
TRACE_APPLY ();
switch (u.format) {
- case 1: return u.format1.apply (c);
- default:return false;
+ case 1: return TRACE_RETURN (u.format1.apply (c));
+ default:return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (!u.format.sanitize (c)) return false;
+ if (!u.format.sanitize (c)) return TRACE_RETURN (false);
switch (u.format) {
- case 1: return u.format1.sanitize (c);
- default:return true;
+ case 1: return TRACE_RETURN (u.format1.sanitize (c));
+ default:return TRACE_RETURN (true);
}
}
@@ -1291,7 +1246,7 @@ struct ContextPos : Context
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- return Context::apply (c, position_lookup);
+ return TRACE_RETURN (Context::apply (c, position_lookup));
}
};
@@ -1303,7 +1258,7 @@ struct ChainContextPos : ChainContext
inline bool apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- return ChainContext::apply (c, position_lookup);
+ return TRACE_RETURN (ChainContext::apply (c, position_lookup));
}
};
@@ -1336,7 +1291,7 @@ struct PosLookupSubTable
{
friend struct PosLookup;
- enum {
+ enum Type {
Single = 1,
Pair = 2,
Cursive = 3,
@@ -1352,32 +1307,32 @@ struct PosLookupSubTable
{
TRACE_APPLY ();
switch (lookup_type) {
- case Single: return u.single.apply (c);
- case Pair: return u.pair.apply (c);
- case Cursive: return u.cursive.apply (c);
- case MarkBase: return u.markBase.apply (c);
- case MarkLig: return u.markLig.apply (c);
- case MarkMark: return u.markMark.apply (c);
- case Context: return u.c.apply (c);
- case ChainContext: return u.chainContext.apply (c);
- case Extension: return u.extension.apply (c);
- default:return false;
+ case Single: return TRACE_RETURN (u.single.apply (c));
+ case Pair: return TRACE_RETURN (u.pair.apply (c));
+ case Cursive: return TRACE_RETURN (u.cursive.apply (c));
+ case MarkBase: return TRACE_RETURN (u.markBase.apply (c));
+ case MarkLig: return TRACE_RETURN (u.markLig.apply (c));
+ case MarkMark: return TRACE_RETURN (u.markMark.apply (c));
+ case Context: return TRACE_RETURN (u.c.apply (c));
+ case ChainContext: return TRACE_RETURN (u.chainContext.apply (c));
+ case Extension: return TRACE_RETURN (u.extension.apply (c));
+ default: return TRACE_RETURN (false);
}
}
inline bool sanitize (hb_sanitize_context_t *c, unsigned int lookup_type) {
TRACE_SANITIZE ();
switch (lookup_type) {
- case Single: return u.single.sanitize (c);
- case Pair: return u.pair.sanitize (c);
- case Cursive: return u.cursive.sanitize (c);
- case MarkBase: return u.markBase.sanitize (c);
- case MarkLig: return u.markLig.sanitize (c);
- case MarkMark: return u.markMark.sanitize (c);
- case Context: return u.c.sanitize (c);
- case ChainContext: return u.chainContext.sanitize (c);
- case Extension: return u.extension.sanitize (c);
- default:return true;
+ case Single: return TRACE_RETURN (u.single.sanitize (c));
+ case Pair: return TRACE_RETURN (u.pair.sanitize (c));
+ case Cursive: return TRACE_RETURN (u.cursive.sanitize (c));
+ case MarkBase: return TRACE_RETURN (u.markBase.sanitize (c));
+ case MarkLig: return TRACE_RETURN (u.markLig.sanitize (c));
+ case MarkMark: return TRACE_RETURN (u.markMark.sanitize (c));
+ case Context: return TRACE_RETURN (u.c.sanitize (c));
+ case ChainContext: return TRACE_RETURN (u.chainContext.sanitize (c));
+ case Extension: return TRACE_RETURN (u.extension.sanitize (c));
+ default: return TRACE_RETURN (true);
}
}
@@ -1404,25 +1359,11 @@ struct PosLookup : Lookup
inline const PosLookupSubTable& get_subtable (unsigned int i) const
{ return this+CastR<OffsetArrayOf<PosLookupSubTable> > (subTable)[i]; }
- inline bool apply_once (hb_font_t *font,
- hb_buffer_t *buffer,
- hb_mask_t lookup_mask,
- unsigned int context_length,
- unsigned int nesting_level_left) const
+ inline bool apply_once (hb_apply_context_t *c) const
{
unsigned int lookup_type = get_type ();
- hb_apply_context_t c[1] = {{0}};
-
- c->font = font;
- c->face = font->face;
- c->buffer = buffer;
- c->direction = buffer->props.direction;
- c->lookup_mask = lookup_mask;
- c->context_length = context_length;
- c->nesting_level_left = nesting_level_left;
- c->lookup_props = get_props ();
-
- if (!_hb_ot_layout_check_glyph_property (c->face, &c->buffer->info[c->buffer->idx], c->lookup_props, &c->property))
+
+ if (!_hb_ot_layout_check_glyph_property (c->face, &c->buffer->cur(), c->lookup_props, &c->property))
return false;
for (unsigned int i = 0; i < get_subtable_count (); i++)
@@ -1432,23 +1373,22 @@ struct PosLookup : Lookup
return false;
}
- inline bool apply_string (hb_font_t *font,
- hb_buffer_t *buffer,
- hb_mask_t mask) const
+ inline bool apply_string (hb_apply_context_t *c) const
{
bool ret = false;
- if (unlikely (!buffer->len))
+ if (unlikely (!c->buffer->len))
return false;
- buffer->idx = 0;
- while (buffer->idx < buffer->len)
+ c->set_lookup (*this);
+
+ c->buffer->idx = 0;
+ while (c->buffer->idx < c->buffer->len)
{
- if ((buffer->info[buffer->idx].mask & mask) &&
- apply_once (font, buffer, mask, NO_CONTEXT, MAX_NESTING_LEVEL))
+ if ((c->buffer->cur().mask & c->lookup_mask) && apply_once (c))
ret = true;
else
- buffer->idx++;
+ c->buffer->idx++;
}
return ret;
@@ -1456,9 +1396,9 @@ struct PosLookup : Lookup
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (unlikely (!Lookup::sanitize (c))) return false;
+ if (unlikely (!Lookup::sanitize (c))) return TRACE_RETURN (false);
OffsetArrayOf<PosLookupSubTable> &list = CastR<OffsetArrayOf<PosLookupSubTable> > (subTable);
- return list.sanitize (c, this, get_type ());
+ return TRACE_RETURN (list.sanitize (c, this, get_type ()));
}
};
@@ -1475,20 +1415,17 @@ struct GPOS : GSUBGPOS
inline const PosLookup& get_lookup (unsigned int i) const
{ return CastR<PosLookup> (GSUBGPOS::get_lookup (i)); }
- inline bool position_lookup (hb_font_t *font,
- hb_buffer_t *buffer,
- unsigned int lookup_index,
- hb_mask_t mask) const
- { return get_lookup (lookup_index).apply_string (font, buffer, mask); }
+ inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index) const
+ { return get_lookup (lookup_index).apply_string (c); }
static inline void position_start (hb_buffer_t *buffer);
static inline void position_finish (hb_buffer_t *buffer);
inline bool sanitize (hb_sanitize_context_t *c) {
TRACE_SANITIZE ();
- if (unlikely (!GSUBGPOS::sanitize (c))) return false;
+ if (unlikely (!GSUBGPOS::sanitize (c))) return TRACE_RETURN (false);
OffsetTo<PosLookupList> &list = CastR<OffsetTo<PosLookupList> > (lookupList);
- return list.sanitize (c, this);
+ return TRACE_RETURN (list.sanitize (c, this));
}
public:
DEFINE_SIZE_STATIC (10);
@@ -1564,8 +1501,8 @@ GPOS::position_finish (hb_buffer_t *buffer)
for (unsigned int i = 0; i < len; i++)
fix_mark_attachment (pos, i, direction);
- HB_BUFFER_DEALLOCATE_VAR (buffer, lig_comp);
- HB_BUFFER_DEALLOCATE_VAR (buffer, lig_id);
+ HB_BUFFER_DEALLOCATE_VAR (buffer, syllable);
+ HB_BUFFER_DEALLOCATE_VAR (buffer, lig_props);
HB_BUFFER_DEALLOCATE_VAR (buffer, props_cache);
}
@@ -1575,16 +1512,16 @@ GPOS::position_finish (hb_buffer_t *buffer)
inline bool ExtensionPos::apply (hb_apply_context_t *c) const
{
TRACE_APPLY ();
- return get_subtable ().apply (c, get_type ());
+ return TRACE_RETURN (get_subtable ().apply (c, get_type ()));
}
inline bool ExtensionPos::sanitize (hb_sanitize_context_t *c)
{
TRACE_SANITIZE ();
- if (unlikely (!Extension::sanitize (c))) return false;
+ if (unlikely (!Extension::sanitize (c))) return TRACE_RETURN (false);
unsigned int offset = get_offset ();
- if (unlikely (!offset)) return true;
- return StructAtOffset<PosLookupSubTable> (this, offset).sanitize (c, get_type ());
+ if (unlikely (!offset)) return TRACE_RETURN (true);
+ return TRACE_RETURN (StructAtOffset<PosLookupSubTable> (this, offset).sanitize (c, get_type ()));
}
static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_index)
@@ -1595,10 +1532,10 @@ static inline bool position_lookup (hb_apply_context_t *c, unsigned int lookup_i
if (unlikely (c->nesting_level_left == 0))
return false;
- if (unlikely (c->context_length < 1))
- return false;
-
- return l.apply_once (c->font, c->buffer, c->lookup_mask, c->context_length, c->nesting_level_left - 1);
+ hb_apply_context_t new_c (*c);
+ new_c.nesting_level_left--;
+ new_c.set_lookup (l);
+ return l.apply_once (&new_c);
}
« no previous file with comments | « third_party/harfbuzz-ng/src/hb-ot-layout-gdef-table.hh ('k') | third_party/harfbuzz-ng/src/hb-ot-layout-gsub-table.hh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698