Index: third_party/harfbuzz-ng/src/hb-ot-layout-gsubgpos-private.hh |
diff --git a/third_party/harfbuzz-ng/src/hb-ot-layout-gsubgpos-private.hh b/third_party/harfbuzz-ng/src/hb-ot-layout-gsubgpos-private.hh |
index fc9eed0063a0796a3f376e1336b9e6c89b311269..57fc1e05f767a4b0fcbc5e73451831b91d45b1c7 100644 |
--- a/third_party/harfbuzz-ng/src/hb-ot-layout-gsubgpos-private.hh |
+++ b/third_party/harfbuzz-ng/src/hb-ot-layout-gsubgpos-private.hh |
@@ -38,10 +38,10 @@ namespace OT { |
-#define TRACE_DISPATCH(this) \ |
+#define TRACE_DISPATCH(this, format) \ |
hb_auto_trace_t<context_t::max_debug_depth, typename context_t::return_t> trace \ |
(&c->debug_depth, c->get_name (), this, HB_FUNC, \ |
- ""); |
+ "format %d", (int) format); |
#ifndef HB_DEBUG_CLOSURE |
#define HB_DEBUG_CLOSURE (HB_DEBUG+0) |
@@ -168,6 +168,10 @@ struct hb_collect_glyphs_context_t |
if (output == hb_set_get_empty ()) |
return HB_VOID; |
+ /* Return if new lookup was recursed to before. */ |
+ if (recursed_lookups.has (lookup_index)) |
+ return HB_VOID; |
+ |
hb_set_t *old_before = before; |
hb_set_t *old_input = input; |
hb_set_t *old_after = after; |
@@ -181,6 +185,8 @@ struct hb_collect_glyphs_context_t |
input = old_input; |
after = old_after; |
+ recursed_lookups.add (lookup_index); |
+ |
return HB_VOID; |
} |
@@ -190,6 +196,7 @@ struct hb_collect_glyphs_context_t |
hb_set_t *after; |
hb_set_t *output; |
recurse_func_t recurse_func; |
+ hb_set_t recursed_lookups; |
unsigned int nesting_level_left; |
unsigned int debug_depth; |
@@ -205,18 +212,30 @@ struct hb_collect_glyphs_context_t |
after (glyphs_after ? glyphs_after : hb_set_get_empty ()), |
output (glyphs_output ? glyphs_output : hb_set_get_empty ()), |
recurse_func (NULL), |
+ recursed_lookups (), |
nesting_level_left (nesting_level_left_), |
- debug_depth (0) {} |
+ debug_depth (0) |
+ { |
+ recursed_lookups.init (); |
+ } |
+ ~hb_collect_glyphs_context_t (void) |
+ { |
+ recursed_lookups.fini (); |
+ } |
void set_recurse_func (recurse_func_t func) { recurse_func = func; } |
}; |
+#ifndef HB_DEBUG_GET_COVERAGE |
+#define HB_DEBUG_GET_COVERAGE (HB_DEBUG+0) |
+#endif |
+ |
struct hb_get_coverage_context_t |
{ |
inline const char *get_name (void) { return "GET_COVERAGE"; } |
- static const unsigned int max_debug_depth = 0; |
+ static const unsigned int max_debug_depth = HB_DEBUG_GET_COVERAGE; |
typedef const Coverage &return_t; |
template <typename T> |
inline return_t dispatch (const T &obj) { return obj.get_coverage (); } |
@@ -1117,9 +1136,9 @@ struct Rule |
inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const |
{ |
TRACE_CLOSURE (this); |
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0)); |
+ const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); |
context_closure_lookup (c, |
- inputCount, input, |
+ inputCount, inputZ, |
lookupCount, lookupRecord, |
lookup_context); |
} |
@@ -1127,9 +1146,9 @@ struct Rule |
inline void collect_glyphs (hb_collect_glyphs_context_t *c, ContextCollectGlyphsLookupContext &lookup_context) const |
{ |
TRACE_COLLECT_GLYPHS (this); |
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0)); |
+ const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); |
context_collect_glyphs_lookup (c, |
- inputCount, input, |
+ inputCount, inputZ, |
lookupCount, lookupRecord, |
lookup_context); |
} |
@@ -1137,15 +1156,15 @@ struct Rule |
inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContext &lookup_context) const |
{ |
TRACE_WOULD_APPLY (this); |
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0)); |
- return TRACE_RETURN (context_would_apply_lookup (c, inputCount, input, lookupCount, lookupRecord, lookup_context)); |
+ const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); |
+ return TRACE_RETURN (context_would_apply_lookup (c, inputCount, inputZ, lookupCount, lookupRecord, lookup_context)); |
} |
inline bool apply (hb_apply_context_t *c, ContextApplyLookupContext &lookup_context) const |
{ |
TRACE_APPLY (this); |
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (input, input[0].static_size * (inputCount ? inputCount - 1 : 0)); |
- return TRACE_RETURN (context_apply_lookup (c, inputCount, input, lookupCount, lookupRecord, lookup_context)); |
+ const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (inputZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0)); |
+ return TRACE_RETURN (context_apply_lookup (c, inputCount, inputZ, lookupCount, lookupRecord, lookup_context)); |
} |
public: |
@@ -1153,8 +1172,8 @@ struct Rule |
TRACE_SANITIZE (this); |
return inputCount.sanitize (c) |
&& lookupCount.sanitize (c) |
- && c->check_range (input, |
- input[0].static_size * inputCount |
+ && c->check_range (inputZ, |
+ inputZ[0].static_size * inputCount |
+ lookupRecordX[0].static_size * lookupCount); |
} |
@@ -1163,12 +1182,12 @@ struct Rule |
* glyph sequence--includes the first |
* glyph */ |
USHORT lookupCount; /* Number of LookupRecords */ |
- USHORT input[VAR]; /* Array of match inputs--start with |
+ USHORT inputZ[VAR]; /* Array of match inputs--start with |
* second glyph */ |
LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in |
* design order */ |
public: |
- DEFINE_SIZE_ARRAY2 (4, input, lookupRecordX); |
+ DEFINE_SIZE_ARRAY2 (4, inputZ, lookupRecordX); |
}; |
struct RuleSet |
@@ -1413,16 +1432,16 @@ struct ContextFormat3 |
inline void closure (hb_closure_context_t *c) const |
{ |
TRACE_CLOSURE (this); |
- if (!(this+coverage[0]).intersects (c->glyphs)) |
+ if (!(this+coverageZ[0]).intersects (c->glyphs)) |
return; |
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount); |
+ const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ, coverageZ[0].static_size * glyphCount); |
struct ContextClosureLookupContext lookup_context = { |
{intersects_coverage}, |
this |
}; |
context_closure_lookup (c, |
- glyphCount, (const USHORT *) (coverage + 1), |
+ glyphCount, (const USHORT *) (coverageZ + 1), |
lookupCount, lookupRecord, |
lookup_context); |
} |
@@ -1430,16 +1449,16 @@ struct ContextFormat3 |
inline void collect_glyphs (hb_collect_glyphs_context_t *c) const |
{ |
TRACE_COLLECT_GLYPHS (this); |
- (this+coverage[0]).add_coverage (c->input); |
+ (this+coverageZ[0]).add_coverage (c->input); |
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount); |
+ const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ, coverageZ[0].static_size * glyphCount); |
struct ContextCollectGlyphsLookupContext lookup_context = { |
{collect_coverage}, |
this |
}; |
context_collect_glyphs_lookup (c, |
- glyphCount, (const USHORT *) (coverage + 1), |
+ glyphCount, (const USHORT *) (coverageZ + 1), |
lookupCount, lookupRecord, |
lookup_context); |
} |
@@ -1448,42 +1467,42 @@ struct ContextFormat3 |
{ |
TRACE_WOULD_APPLY (this); |
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount); |
+ const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ, coverageZ[0].static_size * glyphCount); |
struct ContextApplyLookupContext lookup_context = { |
{match_coverage}, |
this |
}; |
- return TRACE_RETURN (context_would_apply_lookup (c, glyphCount, (const USHORT *) (coverage + 1), lookupCount, lookupRecord, lookup_context)); |
+ return TRACE_RETURN (context_would_apply_lookup (c, glyphCount, (const USHORT *) (coverageZ + 1), lookupCount, lookupRecord, lookup_context)); |
} |
inline const Coverage &get_coverage (void) const |
{ |
- return this+coverage[0]; |
+ return this+coverageZ[0]; |
} |
inline bool apply (hb_apply_context_t *c) const |
{ |
TRACE_APPLY (this); |
- unsigned int index = (this+coverage[0]).get_coverage (c->buffer->cur().codepoint); |
+ unsigned int index = (this+coverageZ[0]).get_coverage (c->buffer->cur().codepoint); |
if (likely (index == NOT_COVERED)) return TRACE_RETURN (false); |
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount); |
+ const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ, coverageZ[0].static_size * glyphCount); |
struct ContextApplyLookupContext lookup_context = { |
{match_coverage}, |
this |
}; |
- return TRACE_RETURN (context_apply_lookup (c, glyphCount, (const USHORT *) (coverage + 1), lookupCount, lookupRecord, lookup_context)); |
+ return TRACE_RETURN (context_apply_lookup (c, glyphCount, (const USHORT *) (coverageZ + 1), lookupCount, lookupRecord, lookup_context)); |
} |
inline bool sanitize (hb_sanitize_context_t *c) { |
TRACE_SANITIZE (this); |
if (!c->check_struct (this)) return TRACE_RETURN (false); |
unsigned int count = glyphCount; |
- if (!count) return TRACE_RETURN (false); /* We want to access coverage[0] freely. */ |
- if (!c->check_array (coverage, coverage[0].static_size, count)) return TRACE_RETURN (false); |
+ if (!count) return TRACE_RETURN (false); /* We want to access coverageZ[0] freely. */ |
+ if (!c->check_array (coverageZ, coverageZ[0].static_size, count)) return TRACE_RETURN (false); |
for (unsigned int i = 0; i < count; i++) |
- if (!coverage[i].sanitize (c, this)) return TRACE_RETURN (false); |
- LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * count); |
+ if (!coverageZ[i].sanitize (c, this)) return TRACE_RETURN (false); |
+ LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ, coverageZ[0].static_size * count); |
return TRACE_RETURN (c->check_array (lookupRecord, lookupRecord[0].static_size, lookupCount)); |
} |
@@ -1493,12 +1512,12 @@ struct ContextFormat3 |
* sequence */ |
USHORT lookupCount; /* Number of LookupRecords */ |
OffsetTo<Coverage> |
- coverage[VAR]; /* Array of offsets to Coverage |
+ coverageZ[VAR]; /* Array of offsets to Coverage |
* table in glyph sequence order */ |
LookupRecord lookupRecordX[VAR]; /* Array of LookupRecords--in |
* design order */ |
public: |
- DEFINE_SIZE_ARRAY2 (6, coverage, lookupRecordX); |
+ DEFINE_SIZE_ARRAY2 (6, coverageZ, lookupRecordX); |
}; |
struct Context |
@@ -1506,7 +1525,7 @@ struct Context |
template <typename context_t> |
inline typename context_t::return_t dispatch (context_t *c) const |
{ |
- TRACE_DISPATCH (this); |
+ TRACE_DISPATCH (this, u.format); |
switch (u.format) { |
case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
case 2: return TRACE_RETURN (c->dispatch (u.format2)); |
@@ -2124,7 +2143,7 @@ struct ChainContext |
template <typename context_t> |
inline typename context_t::return_t dispatch (context_t *c) const |
{ |
- TRACE_DISPATCH (this); |
+ TRACE_DISPATCH (this, u.format); |
switch (u.format) { |
case 1: return TRACE_RETURN (c->dispatch (u.format1)); |
case 2: return TRACE_RETURN (c->dispatch (u.format2)); |