Bug 1240007 - Update graphite2 library to release 1.3.5. r=jdaggett

This commit is contained in:
Jonathan Kew 2016-01-20 08:50:32 +00:00
parent 106a017a08
commit 5570ade175
6 changed files with 44 additions and 20 deletions

26
gfx/graphite2/COPYING Normal file
View File

@ -0,0 +1,26 @@
/* GRAPHITE2 LICENSING
Copyright 2010, SIL International
All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation; either version 2.1 of License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should also have received a copy of the GNU Lesser General Public
License along with this library in the file named "LICENSE".
If not, write to the Free Software Foundation, 51 Franklin Street,
Suite 500, Boston, MA 02110-1335, USA or visit their web page on the
internet at http://www.fsf.org/licenses/lgpl.html.
Alternatively, you may use this library under the terms of the Mozilla
Public License (http://mozilla.org/MPL) or under the GNU General Public
License, as published by the Free Sofware Foundation; either version
2 of the license or (at your option) any later version.
*/

View File

@ -1,6 +1,3 @@
This directory contains the Graphite2 library release 1.3.4 from
https://github.com/silnrsi/graphite/releases/download/1.3.4/graphite2-minimal-1.3.4.tgz
See ./gfx/graphite2/moz-gr-update.sh for update procedure.
Bug 1223002: Updated to upstream commit 6106dcbd5bc4df2e6ef6a7c632c69ca71ba2b518
to fix recently-discovered fuzzbugs.
This directory contains the Graphite2 library release 1.3.5 from
https://github.com/silnrsi/graphite/releases/download/1.3.5/graphite2-minimal-1.3.5.tgz
See gfx/graphite2/moz-gr-update.sh for update procedure.

View File

@ -30,7 +30,7 @@
#define GR2_VERSION_MAJOR 1
#define GR2_VERSION_MINOR 3
#define GR2_VERSION_BUGFIX 4
#define GR2_VERSION_BUGFIX 5
#ifdef __cplusplus
extern "C"

View File

@ -61,8 +61,7 @@ SegCacheEntry::SegCacheEntry(const uint16* cmapGlyphs, size_t length, Segment *
}
const Slot * slot = seg->first();
m_glyph = new Slot[glyphCount];
int attrSize = seg->numAttrs() + (seg->hasCollisionInfo() ? (sizeof(SlotCollision) + 1) / 2 : 0);
m_attr = gralloc<int16>(glyphCount * attrSize);
m_attr = gralloc<int16>(glyphCount * seg->numAttrs());
if (!m_glyph || (!m_attr && seg->numAttrs())) return;
m_glyphLength = glyphCount;
Slot * slotCopy = m_glyph;
@ -71,9 +70,9 @@ SegCacheEntry::SegCacheEntry(const uint16* cmapGlyphs, size_t length, Segment *
uint16 pos = 0;
while (slot)
{
slotCopy->userAttrs(m_attr + pos * attrSize);
slotCopy->userAttrs(m_attr + pos * seg->numAttrs());
slotCopy->m_justs = m_justs ? reinterpret_cast<SlotJustify *>(m_justs + justs_pos++ * sizeof_sjust) : 0;
slotCopy->set(*slot, -static_cast<int32>(charOffset), attrSize, seg->silf()->numJustLevels(), length);
slotCopy->set(*slot, -static_cast<int32>(charOffset), seg->numAttrs(), seg->silf()->numJustLevels(), length);
slotCopy->index(pos);
if (slot->firstChild())
slotCopy->m_child = m_glyph + slot->firstChild()->index();

View File

@ -46,6 +46,7 @@ Segment::Segment(unsigned int numchars, const Face* face, uint32 script, int tex
: m_freeSlots(NULL),
m_freeJustifies(NULL),
m_charinfo(new CharInfo[numchars]),
m_collisions(NULL),
m_face(face),
m_silf(face->chooseSilf(script)),
m_first(NULL),
@ -71,6 +72,7 @@ Segment::~Segment()
for (JustifyRope::iterator i = m_justifies.begin(); i != m_justifies.end(); ++i)
free(*i);
delete[] m_charinfo;
free(m_collisions);
}
#ifndef GRAPHITE2_NSEGCACHE
@ -175,8 +177,7 @@ Slot *Segment::newSlot()
if (m_face->logger()) ++numUser;
#endif
Slot *newSlots = grzeroalloc<Slot>(m_bufSize);
int attrSize = numUser + (hasCollisionInfo() ? ((sizeof(SlotCollision) + 1) / 2) : 0);
int16 *newAttrs = grzeroalloc<int16>(m_bufSize * attrSize);
int16 *newAttrs = grzeroalloc<int16>(m_bufSize * numUser);
if (!newSlots || !newAttrs)
{
free(newSlots);
@ -185,7 +186,7 @@ Slot *Segment::newSlot()
}
for (size_t i = 0; i < m_bufSize; i++)
{
::new (newSlots + i) Slot(newAttrs + i * attrSize);
::new (newSlots + i) Slot(newAttrs + i * numUser);
newSlots[i].next(newSlots + i + 1);
}
newSlots[m_bufSize - 1].next(NULL);
@ -214,8 +215,7 @@ void Segment::freeSlot(Slot *aSlot)
}
// reset the slot incase it is reused
::new (aSlot) Slot(aSlot->userAttrs());
int attrSize = m_silf->numUser() + (hasCollisionInfo() ? ((sizeof(SlotCollision) + 1) / 2) : 0);
memset(aSlot->userAttrs(), 0, attrSize * sizeof(int16));
memset(aSlot->userAttrs(), 0, m_silf->numUser() * sizeof(int16));
// Update generation counter for debug
#if !defined GRAPHITE2_NTRACING
if (m_face->logger())
@ -304,14 +304,13 @@ void Segment::splice(size_t offset, size_t length, Slot * const startSlot,
assert(offset + numChars <= m_numCharinfo);
Slot * indexmap[eMaxSpliceSize*3];
assert(numGlyphs < sizeof indexmap/sizeof *indexmap);
int attrSize = m_silf->numUser() + (hasCollisionInfo() ? ((sizeof(SlotCollision) + 1) / 2) : 0);
Slot * slot = startSlot;
for (uint16 i=0; i < numGlyphs; slot = slot->next(), ++i)
indexmap[i] = slot;
for (slot = startSlot; slot != endSlot; slot = slot->next(), srcSlot = srcSlot->next())
{
slot->set(*srcSlot, offset, attrSize, m_silf->numJustLevels(), numChars);
slot->set(*srcSlot, offset, m_silf->numUser(), m_silf->numJustLevels(), numChars);
if (srcSlot->attachedTo()) slot->attachTo(indexmap[srcSlot->attachedTo()->index()]);
if (srcSlot->nextSibling()) slot->m_sibling = indexmap[srcSlot->nextSibling()->index()];
if (srcSlot->firstChild()) slot->m_child = indexmap[srcSlot->firstChild()->index()];
@ -523,6 +522,9 @@ void Segment::doMirror(uint16 aMirror)
bool Segment::initCollisions()
{
m_collisions = grzeroalloc<SlotCollision>(slotCount());
if (!m_collisions) return false;
for (Slot *p = m_first; p; p = p->next())
::new (collisionInfo(p)) SlotCollision(this, p);
return true;

View File

@ -160,8 +160,7 @@ public:
bool isWhitespace(const int cid) const;
bool hasCollisionInfo() const { return (m_flags & SEG_HASCOLLISIONS); }
SlotCollision *collisionInfo(const Slot *s) const { return hasCollisionInfo() ? reinterpret_cast<SlotCollision *>(s->userAttrs() + m_silf->numUser()) : 0; }
SlotCollision *collisionInfo(const Slot *s) const { return m_collisions ? m_collisions + s->index() : 0; }
CLASS_NEW_DELETE
public: //only used by: GrSegment* makeAndInitialize(const GrFont *font, const GrFace *face, uint32 script, const FeaturesHandle& pFeats/*must not be IsNull*/, encform enc, const void* pStart, size_t nChars, int dir);
@ -179,6 +178,7 @@ private:
Slot * m_freeSlots; // linked list of free slots
SlotJustify * m_freeJustifies; // Slot justification blocks free list
CharInfo * m_charinfo; // character info, one per input character
SlotCollision * m_collisions;
const Face * m_face; // GrFace
const Silf * m_silf;
Slot * m_first; // first slot in segment