mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 906521. Part 1: Remove support for 'glyphchar' since it's no longer in the spec. r=jfkthame
--HG-- extra : rebase_source : 1d694f6e8579b20dbbe5c5d02411f078d7c67a83
This commit is contained in:
parent
be6c9d6c51
commit
2c53164bc5
@ -264,16 +264,9 @@ gfxFontEntry::TryGetSVGData()
|
||||
return false;
|
||||
}
|
||||
|
||||
hb_blob_t *cmapTable = GetFontTable(TRUETYPE_TAG('c','m','a','p'));
|
||||
if (!cmapTable) {
|
||||
NS_NOTREACHED("using a font with no cmap!");
|
||||
hb_blob_destroy(svgTable);
|
||||
return false;
|
||||
}
|
||||
|
||||
// gfxSVGGlyphs will hb_blob_destroy() the tables when it is finished
|
||||
// with them.
|
||||
mSVGGlyphs = new gfxSVGGlyphs(svgTable, cmapTable);
|
||||
// gfxSVGGlyphs will hb_blob_destroy() the table when it is finished
|
||||
// with it.
|
||||
mSVGGlyphs = new gfxSVGGlyphs(svgTable);
|
||||
}
|
||||
|
||||
return !!mSVGGlyphs;
|
||||
|
@ -42,7 +42,7 @@ const float gfxSVGGlyphs::SVG_UNITS_PER_EM = 1000.0f;
|
||||
|
||||
const gfxRGBA SimpleTextObjectPaint::sZero = gfxRGBA(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
gfxSVGGlyphs::gfxSVGGlyphs(hb_blob_t *aSVGTable, hb_blob_t *aCmapTable)
|
||||
gfxSVGGlyphs::gfxSVGGlyphs(hb_blob_t *aSVGTable)
|
||||
{
|
||||
mSVGData = aSVGTable;
|
||||
|
||||
@ -52,13 +52,11 @@ gfxSVGGlyphs::gfxSVGGlyphs(hb_blob_t *aSVGTable, hb_blob_t *aCmapTable)
|
||||
|
||||
mGlyphDocs.Init();
|
||||
mGlyphIdMap.Init();
|
||||
mCmapData = aCmapTable;
|
||||
}
|
||||
|
||||
gfxSVGGlyphs::~gfxSVGGlyphs()
|
||||
{
|
||||
hb_blob_destroy(mSVGData);
|
||||
hb_blob_destroy(mCmapData);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -103,7 +101,7 @@ gfxSVGGlyphs::FindOrCreateGlyphsDocument(uint32_t aGlyphId)
|
||||
if (!result) {
|
||||
const uint8_t *data = (const uint8_t*)hb_blob_get_data(mSVGData, nullptr);
|
||||
result = new gfxSVGGlyphsDocument(data + entry->mDocOffset,
|
||||
entry->mDocLength, mCmapData);
|
||||
entry->mDocLength);
|
||||
mGlyphDocs.Put(entry->mDocOffset, result);
|
||||
}
|
||||
|
||||
@ -156,20 +154,18 @@ gfxSVGGlyphsDocument::SetupPresentation()
|
||||
* Walk the DOM tree to find all glyph elements and insert them into the lookup
|
||||
* table
|
||||
* @param aElem The element to search from
|
||||
* @param aCmapTable Buffer containing the raw cmap table data
|
||||
*/
|
||||
void
|
||||
gfxSVGGlyphsDocument::FindGlyphElements(Element *aElem, hb_blob_t *aCmapTable)
|
||||
gfxSVGGlyphsDocument::FindGlyphElements(Element *aElem)
|
||||
{
|
||||
for (nsIContent *child = aElem->GetLastChild(); child;
|
||||
child = child->GetPreviousSibling()) {
|
||||
if (!child->IsElement()) {
|
||||
continue;
|
||||
}
|
||||
FindGlyphElements(child->AsElement(), aCmapTable);
|
||||
FindGlyphElements(child->AsElement());
|
||||
}
|
||||
|
||||
InsertGlyphChar(aElem, aCmapTable);
|
||||
InsertGlyphId(aElem);
|
||||
}
|
||||
|
||||
@ -235,8 +231,7 @@ gfxSVGGlyphsDocument::GetGlyphElement(uint32_t aGlyphId)
|
||||
return mGlyphIdMap.Get(aGlyphId);
|
||||
}
|
||||
|
||||
gfxSVGGlyphsDocument::gfxSVGGlyphsDocument(const uint8_t *aBuffer, uint32_t aBufLen,
|
||||
hb_blob_t *aCmapTable)
|
||||
gfxSVGGlyphsDocument::gfxSVGGlyphsDocument(const uint8_t *aBuffer, uint32_t aBufLen)
|
||||
{
|
||||
mGlyphIdMap.Init();
|
||||
ParseDocument(aBuffer, aBufLen);
|
||||
@ -257,7 +252,7 @@ gfxSVGGlyphsDocument::gfxSVGGlyphsDocument(const uint8_t *aBuffer, uint32_t aBuf
|
||||
return;
|
||||
}
|
||||
|
||||
FindGlyphElements(root, aCmapTable);
|
||||
FindGlyphElements(root);
|
||||
}
|
||||
|
||||
static nsresult
|
||||
@ -376,71 +371,6 @@ gfxSVGGlyphsDocument::InsertGlyphId(Element *aGlyphElement)
|
||||
mGlyphIdMap.Put(glyphId, aGlyphElement);
|
||||
}
|
||||
|
||||
// Get the Unicode character at index aPos in the string, and update aPos to
|
||||
// point to the next char (i.e. advance by one or two, depending whether we
|
||||
// found a surrogate pair).
|
||||
// This will assert (and return junk) if the string is not well-formed UTF16.
|
||||
// However, this is only used to process an attribute that comes from the
|
||||
// SVG-glyph XML document, and is not exposed to modification via the DOM,
|
||||
// so it must be well-formed UTF16 data (no unpaired surrogate codepoints)
|
||||
// unless our Unicode handling is seriously broken.
|
||||
static uint32_t
|
||||
NextUSV(const nsAString& aString, uint32_t& aPos)
|
||||
{
|
||||
mozilla::DebugOnly<uint32_t> len = aString.Length();
|
||||
NS_ASSERTION(aPos < len, "already at end of string");
|
||||
|
||||
uint32_t c1 = aString[aPos++];
|
||||
if (NS_IS_HIGH_SURROGATE(c1)) {
|
||||
NS_ASSERTION(aPos < len, "trailing high surrogate");
|
||||
uint32_t c2 = aString[aPos++];
|
||||
NS_ASSERTION(NS_IS_LOW_SURROGATE(c2), "isolated high surrogate");
|
||||
return SURROGATE_TO_UCS4(c1, c2);
|
||||
}
|
||||
|
||||
NS_ASSERTION(!NS_IS_LOW_SURROGATE(c1), "isolated low surrogate");
|
||||
return c1;
|
||||
}
|
||||
|
||||
void
|
||||
gfxSVGGlyphsDocument::InsertGlyphChar(Element *aGlyphElement,
|
||||
hb_blob_t *aCmapTable)
|
||||
{
|
||||
nsAutoString glyphChar;
|
||||
if (!aGlyphElement->GetAttr(kNameSpaceID_None, nsGkAtoms::glyphchar,
|
||||
glyphChar)) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t charCode, varSelector = 0, len = glyphChar.Length(), index = 0;
|
||||
if (!len) {
|
||||
NS_WARNING("glyphchar is empty");
|
||||
return;
|
||||
}
|
||||
|
||||
charCode = NextUSV(glyphChar, index);
|
||||
if (index < len) {
|
||||
varSelector = NextUSV(glyphChar, index);
|
||||
if (!gfxFontUtils::IsVarSelector(varSelector)) {
|
||||
NS_WARNING("glyphchar contains more than one character");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (index < len) {
|
||||
NS_WARNING("glyphchar contains more than one character");
|
||||
return;
|
||||
}
|
||||
|
||||
const uint8_t *data = (const uint8_t*)hb_blob_get_data(aCmapTable, &len);
|
||||
uint32_t glyphId =
|
||||
gfxFontUtils::MapCharToGlyph(data, len, charCode, varSelector);
|
||||
|
||||
if (glyphId) {
|
||||
mGlyphIdMap.Put(glyphId, aGlyphElement);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
gfxTextObjectPaint::InitStrokeGeometry(gfxContext *aContext,
|
||||
float devUnitsPerSVGUnit)
|
||||
|
@ -33,8 +33,7 @@ class gfxSVGGlyphsDocument
|
||||
typedef gfxFont::DrawMode DrawMode;
|
||||
|
||||
public:
|
||||
gfxSVGGlyphsDocument(const uint8_t *aBuffer, uint32_t aBufLen,
|
||||
hb_blob_t *aCmapTable);
|
||||
gfxSVGGlyphsDocument(const uint8_t *aBuffer, uint32_t aBufLen);
|
||||
|
||||
Element *GetGlyphElement(uint32_t aGlyphId);
|
||||
|
||||
@ -49,10 +48,9 @@ private:
|
||||
|
||||
nsresult SetupPresentation();
|
||||
|
||||
void FindGlyphElements(Element *aElement, hb_blob_t *aCmapTable);
|
||||
void FindGlyphElements(Element *aElement);
|
||||
|
||||
void InsertGlyphId(Element *aGlyphElement);
|
||||
void InsertGlyphChar(Element *aGlyphElement, hb_blob_t *aCmapTable);
|
||||
|
||||
nsCOMPtr<nsIDocument> mDocument;
|
||||
nsCOMPtr<nsIContentViewer> mViewer;
|
||||
@ -78,16 +76,15 @@ public:
|
||||
|
||||
/**
|
||||
* @param aSVGTable The SVG table from the OpenType font
|
||||
* @param aCmapTable The CMAP table from the OpenType font
|
||||
*
|
||||
* The gfxSVGGlyphs object takes over ownership of the blob references
|
||||
* that are passed in, and will hb_blob_destroy() them when finished;
|
||||
* the caller should -not- destroy these references.
|
||||
*/
|
||||
gfxSVGGlyphs(hb_blob_t *aSVGTable, hb_blob_t *aCmapTable);
|
||||
gfxSVGGlyphs(hb_blob_t *aSVGTable);
|
||||
|
||||
/**
|
||||
* Releases our references to the SVG and cmap tables.
|
||||
* Releases our references to the SVG table.
|
||||
*/
|
||||
~gfxSVGGlyphs();
|
||||
|
||||
@ -127,7 +124,6 @@ private:
|
||||
nsBaseHashtable<nsUint32HashKey, Element*, Element*> mGlyphIdMap;
|
||||
|
||||
hb_blob_t *mSVGData;
|
||||
hb_blob_t *mCmapData;
|
||||
|
||||
const struct Header {
|
||||
mozilla::AutoSwap_PRUint16 mVersion;
|
||||
|
Loading…
Reference in New Issue
Block a user