8158302: Handle contextual glyph substitutions
authorvadim
Wed, 01 Jun 2016 14:37:38 +0300
changeset 41564 c0b5de99deef
parent 41563 af8478174e7b
child 41565 31d2aac15a77
8158302: Handle contextual glyph substitutions Reviewed-by: prr, serb, mschoene
jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualGlyphSubstProc.cpp
jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualGlyphSubstProc.h
jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.cpp
jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.h
jdk/src/java.desktop/share/native/libfontmanager/layout/LigatureSubstProc.cpp
jdk/src/java.desktop/share/native/libfontmanager/layout/LigatureSubstProc.h
jdk/src/java.desktop/share/native/libfontmanager/layout/StateTableProcessor.cpp
jdk/src/java.desktop/share/native/libfontmanager/layout/StateTableProcessor.h
--- a/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualGlyphSubstProc.cpp	Fri Jun 03 15:04:26 2016 +0100
+++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualGlyphSubstProc.cpp	Wed Jun 01 14:37:38 2016 +0300
@@ -46,6 +46,7 @@
 ContextualGlyphSubstitutionProcessor::ContextualGlyphSubstitutionProcessor(const LEReferenceTo<MorphSubtableHeader> &morphSubtableHeader, LEErrorCode &success)
   : StateTableProcessor(morphSubtableHeader, success), entryTable(), contextualGlyphSubstitutionHeader(morphSubtableHeader, success)
 {
+  if (LE_FAILURE(success)) return;
   contextualGlyphSubstitutionHeader.orphan();
   substitutionTableOffset = SWAPW(contextualGlyphSubstitutionHeader->substitutionTableOffset);
 
@@ -66,10 +67,10 @@
     markGlyph = 0;
 }
 
-ByteOffset ContextualGlyphSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index)
+ByteOffset ContextualGlyphSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index, LEErrorCode &success)
 {
-  LEErrorCode success = LE_NO_ERROR;
   const ContextualGlyphSubstitutionStateEntry *entry = entryTable.getAlias(index, success);
+  if (LE_FAILURE(success)) return 0;
   ByteOffset newState = SWAPW(entry->newStateOffset);
   le_int16 flags = SWAPW(entry->flags);
   WordOffset markOffset = SWAPW(entry->markOffset);
--- a/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualGlyphSubstProc.h	Fri Jun 03 15:04:26 2016 +0100
+++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/ContextualGlyphSubstProc.h	Wed Jun 01 14:37:38 2016 +0300
@@ -52,7 +52,7 @@
 public:
     virtual void beginStateTable();
 
-    virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index);
+    virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index, LEErrorCode &success);
 
     virtual void endStateTable();
 
--- a/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.cpp	Fri Jun 03 15:04:26 2016 +0100
+++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.cpp	Wed Jun 01 14:37:38 2016 +0300
@@ -63,10 +63,10 @@
     lastGlyph = 0;
 }
 
-ByteOffset IndicRearrangementProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index)
+ByteOffset IndicRearrangementProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index, LEErrorCode &success)
 {
-  LEErrorCode success = LE_NO_ERROR; // todo- make a param?
-  const IndicRearrangementStateEntry *entry = entryTable.getAlias(index,success);
+    const IndicRearrangementStateEntry *entry = entryTable.getAlias(index, success);
+    if (LE_FAILURE(success)) return 0;
     ByteOffset newState = SWAPW(entry->newStateOffset);
     IndicRearrangementFlags flags = (IndicRearrangementFlags) SWAPW(entry->flags);
 
--- a/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.h	Fri Jun 03 15:04:26 2016 +0100
+++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/IndicRearrangementProcessor.h	Wed Jun 01 14:37:38 2016 +0300
@@ -52,7 +52,7 @@
 public:
     virtual void beginStateTable();
 
-    virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index);
+    virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index, LEErrorCode &success);
 
     virtual void endStateTable();
 
--- a/jdk/src/java.desktop/share/native/libfontmanager/layout/LigatureSubstProc.cpp	Fri Jun 03 15:04:26 2016 +0100
+++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/LigatureSubstProc.cpp	Wed Jun 01 14:37:38 2016 +0300
@@ -67,9 +67,8 @@
     m = -1;
 }
 
-ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index)
+ByteOffset LigatureSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index, LEErrorCode &success)
 {
-  LEErrorCode success = LE_NO_ERROR;
   const LigatureSubstitutionStateEntry *entry = entryTable.getAlias(index, success);
   if (LE_FAILURE(success)) {
       currGlyph++;
--- a/jdk/src/java.desktop/share/native/libfontmanager/layout/LigatureSubstProc.h	Fri Jun 03 15:04:26 2016 +0100
+++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/LigatureSubstProc.h	Wed Jun 01 14:37:38 2016 +0300
@@ -54,7 +54,7 @@
 public:
     virtual void beginStateTable();
 
-    virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index);
+    virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index, LEErrorCode &success);
 
     virtual void endStateTable();
 
--- a/jdk/src/java.desktop/share/native/libfontmanager/layout/StateTableProcessor.cpp	Fri Jun 03 15:04:26 2016 +0100
+++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/StateTableProcessor.cpp	Wed Jun 01 14:37:38 2016 +0300
@@ -81,6 +81,7 @@
 
     while (currGlyph <= glyphCount) {
         if(LE_STATE_PATIENCE_DECR()) break; // patience exceeded.
+        if (LE_FAILURE(success)) break;
         ClassCode classCode = classCodeOOB;
         if (currGlyph == glyphCount) {
             // XXX: How do we handle EOT vs. EOL?
@@ -100,7 +101,7 @@
         EntryTableIndex entryTableIndex = stateArray.getObject((le_uint8)classCode, success);
         if (LE_FAILURE(success)) { break; }
         LE_STATE_PATIENCE_CURR(le_int32, currGlyph);
-        currentState = processStateEntry(glyphStorage, currGlyph, entryTableIndex);
+        currentState = processStateEntry(glyphStorage, currGlyph, entryTableIndex, success);
         LE_STATE_PATIENCE_INCR(currGlyph);
     }
 
--- a/jdk/src/java.desktop/share/native/libfontmanager/layout/StateTableProcessor.h	Fri Jun 03 15:04:26 2016 +0100
+++ b/jdk/src/java.desktop/share/native/libfontmanager/layout/StateTableProcessor.h	Wed Jun 01 14:37:38 2016 +0300
@@ -53,7 +53,7 @@
 
     virtual void beginStateTable() = 0;
 
-    virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index) = 0;
+    virtual ByteOffset processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index, LEErrorCode &success) = 0;
 
     virtual void endStateTable() = 0;