2013-07-19 19:08:33 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2012-09-06 08:57:54 +04:00
|
|
|
|
|
|
|
#include "gfxSVGGlyphs.h"
|
|
|
|
|
|
|
|
#include "nscore.h"
|
|
|
|
#include "nsError.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "nsIParser.h"
|
2013-08-22 10:30:55 +04:00
|
|
|
#include "nsIDOMDocument.h"
|
2012-09-06 08:57:54 +04:00
|
|
|
#include "nsIDOMNodeList.h"
|
|
|
|
#include "nsString.h"
|
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsICategoryManager.h"
|
|
|
|
#include "nsIDocumentLoaderFactory.h"
|
|
|
|
#include "nsIContentViewer.h"
|
|
|
|
#include "nsIStreamListener.h"
|
|
|
|
#include "nsServiceManagerUtils.h"
|
|
|
|
#include "nsIPresShell.h"
|
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsQueryFrame.h"
|
|
|
|
#include "nsIContentSink.h"
|
|
|
|
#include "nsXMLContentSink.h"
|
|
|
|
#include "nsNetUtil.h"
|
|
|
|
#include "nsIInputStream.h"
|
|
|
|
#include "nsStringStream.h"
|
|
|
|
#include "nsStreamUtils.h"
|
|
|
|
#include "nsIPrincipal.h"
|
|
|
|
#include "Element.h"
|
2012-12-12 03:15:07 +04:00
|
|
|
#include "nsSVGUtils.h"
|
2013-05-16 20:29:20 +04:00
|
|
|
#include "harfbuzz/hb.h"
|
2012-09-06 08:57:54 +04:00
|
|
|
|
|
|
|
#define SVG_CONTENT_TYPE NS_LITERAL_CSTRING("image/svg+xml")
|
|
|
|
#define UTF8_CHARSET NS_LITERAL_CSTRING("utf-8")
|
|
|
|
|
2012-09-06 08:58:47 +04:00
|
|
|
typedef mozilla::dom::Element Element;
|
2012-09-06 08:57:54 +04:00
|
|
|
|
2012-09-06 08:58:46 +04:00
|
|
|
mozilla::gfx::UserDataKey gfxTextObjectPaint::sUserDataKey;
|
2012-09-06 08:57:54 +04:00
|
|
|
|
2012-09-06 08:58:46 +04:00
|
|
|
const float gfxSVGGlyphs::SVG_UNITS_PER_EM = 1000.0f;
|
|
|
|
|
2012-09-06 08:58:47 +04:00
|
|
|
const gfxRGBA SimpleTextObjectPaint::sZero = gfxRGBA(0.0f, 0.0f, 0.0f, 0.0f);
|
|
|
|
|
2013-08-19 17:08:43 +04:00
|
|
|
gfxSVGGlyphs::gfxSVGGlyphs(hb_blob_t *aSVGTable)
|
2012-09-06 08:57:54 +04:00
|
|
|
{
|
2013-05-16 20:29:20 +04:00
|
|
|
mSVGData = aSVGTable;
|
2012-09-06 08:57:54 +04:00
|
|
|
|
2013-05-16 20:29:20 +04:00
|
|
|
const char* svgData = hb_blob_get_data(mSVGData, nullptr);
|
|
|
|
mHeader = reinterpret_cast<const Header*>(svgData);
|
|
|
|
mIndex = reinterpret_cast<const IndexEntry*>(svgData + sizeof(Header));
|
2012-09-06 08:57:54 +04:00
|
|
|
|
2012-09-06 08:58:47 +04:00
|
|
|
mGlyphDocs.Init();
|
|
|
|
mGlyphIdMap.Init();
|
|
|
|
}
|
|
|
|
|
2013-05-16 20:29:20 +04:00
|
|
|
gfxSVGGlyphs::~gfxSVGGlyphs()
|
2012-09-06 08:58:47 +04:00
|
|
|
{
|
2013-05-16 20:29:20 +04:00
|
|
|
hb_blob_destroy(mSVGData);
|
2012-09-06 08:58:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Comparison operator for finding a range containing a given glyph ID. Simply
|
|
|
|
* checks whether |key| is less (greater) than every element of |range|, in
|
|
|
|
* which case return |key| < |range| (|key| > |range|). Otherwise |key| is in
|
|
|
|
* |range|, in which case return equality.
|
|
|
|
* The total ordering here is guaranteed by
|
|
|
|
* (1) the index ranges being disjoint; and
|
|
|
|
* (2) the (sole) key always being a singleton, so intersection => containment
|
|
|
|
* (note that this is wrong if we have more than one intersection or two
|
|
|
|
* sets intersecting of size > 1 -- so... don't do that)
|
|
|
|
*/
|
|
|
|
/* static */ int
|
2013-06-12 13:48:35 +04:00
|
|
|
gfxSVGGlyphs::CompareIndexEntries(const void *aKey, const void *aEntry)
|
2012-09-06 08:58:47 +04:00
|
|
|
{
|
2013-06-12 13:48:35 +04:00
|
|
|
const uint32_t key = *(uint32_t*)aKey;
|
|
|
|
const IndexEntry *entry = (const IndexEntry*)aEntry;
|
2012-09-06 08:58:47 +04:00
|
|
|
|
2013-06-12 13:48:35 +04:00
|
|
|
if (key < uint16_t(entry->mStartGlyph)) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (key > uint16_t(entry->mEndGlyph)) {
|
|
|
|
return 1;
|
|
|
|
}
|
2012-09-06 08:58:47 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxSVGGlyphsDocument *
|
|
|
|
gfxSVGGlyphs::FindOrCreateGlyphsDocument(uint32_t aGlyphId)
|
|
|
|
{
|
2013-08-19 17:08:43 +04:00
|
|
|
if (uint16_t(mHeader->mVersion) != 0) {
|
|
|
|
// Version not understood
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2012-09-06 08:58:47 +04:00
|
|
|
IndexEntry *entry = (IndexEntry*)bsearch(&aGlyphId, mIndex,
|
2013-05-16 20:29:20 +04:00
|
|
|
uint16_t(mHeader->mIndexLength),
|
2012-09-06 08:58:47 +04:00
|
|
|
sizeof(IndexEntry),
|
|
|
|
CompareIndexEntries);
|
|
|
|
if (!entry) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxSVGGlyphsDocument *result = mGlyphDocs.Get(entry->mDocOffset);
|
|
|
|
|
|
|
|
if (!result) {
|
2013-05-16 20:29:20 +04:00
|
|
|
const uint8_t *data = (const uint8_t*)hb_blob_get_data(mSVGData, nullptr);
|
|
|
|
result = new gfxSVGGlyphsDocument(data + entry->mDocOffset,
|
2013-08-19 17:08:43 +04:00
|
|
|
entry->mDocLength);
|
2012-09-06 08:58:47 +04:00
|
|
|
mGlyphDocs.Put(entry->mDocOffset, result);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
gfxSVGGlyphsDocument::SetupPresentation()
|
|
|
|
{
|
|
|
|
mDocument->SetIsBeingUsedAsImage();
|
2012-09-06 08:57:54 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsICategoryManager> catMan = do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
|
|
|
|
nsXPIDLCString contractId;
|
2012-09-06 08:58:47 +04:00
|
|
|
nsresult rv = catMan->GetCategoryEntry("Gecko-Content-Viewers", "image/svg+xml", getter_Copies(contractId));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2012-09-06 08:57:54 +04:00
|
|
|
|
|
|
|
nsCOMPtr<nsIDocumentLoaderFactory> docLoaderFactory = do_GetService(contractId);
|
|
|
|
NS_ASSERTION(docLoaderFactory, "Couldn't get DocumentLoaderFactory");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContentViewer> viewer;
|
2012-09-06 08:58:47 +04:00
|
|
|
rv = docLoaderFactory->CreateInstanceForDocument(nullptr, mDocument, nullptr, getter_AddRefs(viewer));
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2012-09-06 08:57:54 +04:00
|
|
|
|
|
|
|
rv = viewer->Init(nullptr, nsIntRect(0, 0, 1000, 1000));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
|
|
|
rv = viewer->Open(nullptr, nullptr);
|
2012-09-06 08:58:47 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2012-09-06 08:57:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPresShell> presShell;
|
|
|
|
rv = viewer->GetPresShell(getter_AddRefs(presShell));
|
2012-09-06 08:58:47 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2012-09-06 08:58:46 +04:00
|
|
|
presShell->GetPresContext()->SetIsGlyph(true);
|
2012-09-06 08:57:54 +04:00
|
|
|
|
2012-09-07 08:16:09 +04:00
|
|
|
if (!presShell->DidInitialize()) {
|
2012-09-06 08:57:54 +04:00
|
|
|
nsRect rect = presShell->GetPresContext()->GetVisibleArea();
|
2012-09-07 08:16:09 +04:00
|
|
|
rv = presShell->Initialize(rect.width, rect.height);
|
2012-09-06 08:58:47 +04:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2012-09-06 08:57:54 +04:00
|
|
|
}
|
|
|
|
|
2012-09-06 08:58:47 +04:00
|
|
|
mDocument->FlushPendingNotifications(Flush_Layout);
|
2012-09-06 08:57:54 +04:00
|
|
|
|
2012-09-06 08:58:47 +04:00
|
|
|
mViewer = viewer;
|
|
|
|
mPresShell = presShell;
|
2012-09-06 08:57:54 +04:00
|
|
|
|
2012-09-06 08:58:47 +04:00
|
|
|
return NS_OK;
|
2012-09-06 08:57:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Walk the DOM tree to find all glyph elements and insert them into the lookup
|
|
|
|
* table
|
|
|
|
* @param aElem The element to search from
|
|
|
|
*/
|
|
|
|
void
|
2013-08-19 17:08:43 +04:00
|
|
|
gfxSVGGlyphsDocument::FindGlyphElements(Element *aElem)
|
2012-09-06 08:57:54 +04:00
|
|
|
{
|
|
|
|
for (nsIContent *child = aElem->GetLastChild(); child;
|
|
|
|
child = child->GetPreviousSibling()) {
|
|
|
|
if (!child->IsElement()) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-08-19 17:08:43 +04:00
|
|
|
FindGlyphElements(child->AsElement());
|
2012-09-06 08:57:54 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
InsertGlyphId(aElem);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* If there exists an SVG glyph with the specified glyph id, render it and return true
|
|
|
|
* If no such glyph exists, or in the case of an error return false
|
|
|
|
* @param aContext The thebes aContext to draw to
|
|
|
|
* @param aGlyphId The glyph id
|
|
|
|
* @param aDrawMode Whether to fill or stroke or both (see |gfxFont::DrawMode|)
|
|
|
|
* @return true iff rendering succeeded
|
|
|
|
*/
|
|
|
|
bool
|
|
|
|
gfxSVGGlyphs::RenderGlyph(gfxContext *aContext, uint32_t aGlyphId,
|
2012-09-06 08:58:46 +04:00
|
|
|
DrawMode aDrawMode, gfxTextObjectPaint *aObjectPaint)
|
2012-09-06 08:57:54 +04:00
|
|
|
{
|
|
|
|
if (aDrawMode == gfxFont::GLYPH_PATH) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfxContextAutoSaveRestore aContextRestorer(aContext);
|
|
|
|
|
|
|
|
Element *glyph = mGlyphIdMap.Get(aGlyphId);
|
|
|
|
NS_ASSERTION(glyph, "No glyph element. Should check with HasSVGGlyph() first!");
|
|
|
|
|
2012-12-12 03:15:07 +04:00
|
|
|
return nsSVGUtils::PaintSVGGlyph(glyph, aContext, aDrawMode, aObjectPaint);
|
2012-09-06 08:57:54 +04:00
|
|
|
}
|
|
|
|
|
2012-09-06 08:58:46 +04:00
|
|
|
bool
|
|
|
|
gfxSVGGlyphs::GetGlyphExtents(uint32_t aGlyphId, const gfxMatrix& aSVGToAppSpace,
|
|
|
|
gfxRect *aResult)
|
|
|
|
{
|
|
|
|
Element *glyph = mGlyphIdMap.Get(aGlyphId);
|
|
|
|
NS_ASSERTION(glyph, "No glyph element. Should check with HasSVGGlyph() first!");
|
|
|
|
|
2012-12-12 03:15:07 +04:00
|
|
|
return nsSVGUtils::GetSVGGlyphExtents(glyph, aSVGToAppSpace, aResult);
|
2012-09-06 08:58:46 +04:00
|
|
|
}
|
|
|
|
|
2012-09-06 08:58:47 +04:00
|
|
|
Element *
|
|
|
|
gfxSVGGlyphs::GetGlyphElement(uint32_t aGlyphId)
|
|
|
|
{
|
|
|
|
Element *elem;
|
|
|
|
|
|
|
|
if (!mGlyphIdMap.Get(aGlyphId, &elem)) {
|
|
|
|
elem = nullptr;
|
|
|
|
if (gfxSVGGlyphsDocument *set = FindOrCreateGlyphsDocument(aGlyphId)) {
|
|
|
|
elem = set->GetGlyphElement(aGlyphId);
|
|
|
|
}
|
|
|
|
mGlyphIdMap.Put(aGlyphId, elem);
|
|
|
|
}
|
|
|
|
|
|
|
|
return elem;
|
|
|
|
}
|
|
|
|
|
2012-09-06 08:57:54 +04:00
|
|
|
bool
|
|
|
|
gfxSVGGlyphs::HasSVGGlyph(uint32_t aGlyphId)
|
|
|
|
{
|
2012-09-06 08:58:47 +04:00
|
|
|
return !!GetGlyphElement(aGlyphId);
|
2012-09-06 08:57:54 +04:00
|
|
|
}
|
|
|
|
|
2012-09-06 08:58:47 +04:00
|
|
|
Element *
|
|
|
|
gfxSVGGlyphsDocument::GetGlyphElement(uint32_t aGlyphId)
|
|
|
|
{
|
|
|
|
return mGlyphIdMap.Get(aGlyphId);
|
|
|
|
}
|
|
|
|
|
2013-08-19 17:08:43 +04:00
|
|
|
gfxSVGGlyphsDocument::gfxSVGGlyphsDocument(const uint8_t *aBuffer, uint32_t aBufLen)
|
2012-09-06 08:58:47 +04:00
|
|
|
{
|
|
|
|
mGlyphIdMap.Init();
|
|
|
|
ParseDocument(aBuffer, aBufLen);
|
|
|
|
if (!mDocument) {
|
|
|
|
NS_WARNING("Could not parse SVG glyphs document");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Element *root = mDocument->GetRootElement();
|
|
|
|
if (!root) {
|
|
|
|
NS_WARNING("Could not parse SVG glyphs document");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult rv = SetupPresentation();
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
NS_WARNING("Couldn't setup presentation for SVG glyphs document");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-19 17:08:43 +04:00
|
|
|
FindGlyphElements(root);
|
2012-09-06 08:58:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static nsresult
|
2013-05-16 20:29:20 +04:00
|
|
|
CreateBufferedStream(const uint8_t *aBuffer, uint32_t aBufLen,
|
2012-09-06 08:57:54 +04:00
|
|
|
nsCOMPtr<nsIInputStream> &aResult)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIInputStream> stream;
|
|
|
|
nsresult rv = NS_NewByteInputStream(getter_AddRefs(stream),
|
|
|
|
reinterpret_cast<const char *>(aBuffer),
|
|
|
|
aBufLen, NS_ASSIGNMENT_DEPEND);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIInputStream> aBufferedStream;
|
|
|
|
if (!NS_InputStreamIsBuffered(stream)) {
|
|
|
|
rv = NS_NewBufferedInputStream(getter_AddRefs(aBufferedStream), stream, 4096);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
stream = aBufferedStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
aResult = stream;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2012-09-06 08:58:47 +04:00
|
|
|
nsresult
|
2013-05-16 20:29:20 +04:00
|
|
|
gfxSVGGlyphsDocument::ParseDocument(const uint8_t *aBuffer, uint32_t aBufLen)
|
2012-09-06 08:57:54 +04:00
|
|
|
{
|
|
|
|
// Mostly pulled from nsDOMParser::ParseFromStream
|
|
|
|
|
|
|
|
nsCOMPtr<nsIInputStream> stream;
|
|
|
|
nsresult rv = CreateBufferedStream(aBuffer, aBufLen, stream);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIPrincipal> principal =
|
|
|
|
do_CreateInstance("@mozilla.org/nullprincipal;1", &rv);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
|
|
principal->GetURI(getter_AddRefs(uri));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMDocument> domDoc;
|
|
|
|
rv = NS_NewDOMDocument(getter_AddRefs(domDoc),
|
|
|
|
EmptyString(), // aNamespaceURI
|
|
|
|
EmptyString(), // aQualifiedName
|
|
|
|
nullptr, // aDoctype
|
|
|
|
uri, uri, principal,
|
|
|
|
false, // aLoadedAsData
|
|
|
|
nullptr, // aEventObject
|
|
|
|
DocumentFlavorSVG);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIChannel> channel;
|
|
|
|
rv = NS_NewInputStreamChannel(getter_AddRefs(channel), uri, nullptr /* stream */,
|
|
|
|
SVG_CONTENT_TYPE, UTF8_CHARSET);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
channel->SetOwner(principal);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocument> document(do_QueryInterface(domDoc));
|
|
|
|
if (!document) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
document->SetReadyStateInternal(nsIDocument::READYSTATE_UNINITIALIZED);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIStreamListener> listener;
|
|
|
|
rv = document->StartDocumentLoad("external-resource", channel,
|
|
|
|
nullptr, // aLoadGroup
|
|
|
|
nullptr, // aContainer
|
|
|
|
getter_AddRefs(listener),
|
|
|
|
true /* aReset */);
|
|
|
|
if (NS_FAILED(rv) || !listener) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
document->SetBaseURI(uri);
|
|
|
|
document->SetPrincipal(principal);
|
|
|
|
|
|
|
|
rv = listener->OnStartRequest(channel, nullptr /* aContext */);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
channel->Cancel(rv);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult status;
|
|
|
|
channel->GetStatus(&status);
|
|
|
|
if (NS_SUCCEEDED(rv) && NS_SUCCEEDED(status)) {
|
|
|
|
rv = listener->OnDataAvailable(channel, nullptr /* aContext */, stream, 0, aBufLen);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
channel->Cancel(rv);
|
|
|
|
}
|
|
|
|
channel->GetStatus(&status);
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = listener->OnStopRequest(channel, nullptr /* aContext */, status);
|
|
|
|
NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE);
|
|
|
|
|
2012-09-06 08:58:47 +04:00
|
|
|
document.swap(mDocument);
|
2012-09-06 08:57:54 +04:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-09-06 08:58:47 +04:00
|
|
|
gfxSVGGlyphsDocument::InsertGlyphId(Element *aGlyphElement)
|
2012-09-06 08:57:54 +04:00
|
|
|
{
|
|
|
|
nsAutoString glyphIdStr;
|
2013-08-19 17:08:43 +04:00
|
|
|
static const uint32_t glyphPrefixLength = 5;
|
|
|
|
// The maximum glyph ID is 65535 so the maximum length of the numeric part
|
|
|
|
// is 5.
|
|
|
|
if (!aGlyphElement->GetAttr(kNameSpaceID_None, nsGkAtoms::id, glyphIdStr) ||
|
|
|
|
!StringBeginsWith(glyphIdStr, NS_LITERAL_STRING("glyph")) ||
|
|
|
|
glyphIdStr.Length() > glyphPrefixLength + 5) {
|
2012-09-06 08:57:54 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-08-19 17:08:43 +04:00
|
|
|
uint32_t id = 0;
|
|
|
|
for (uint32_t i = glyphPrefixLength; i < glyphIdStr.Length(); ++i) {
|
|
|
|
PRUnichar ch = glyphIdStr.CharAt(i);
|
|
|
|
if (ch < '0' || ch > '9') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (ch == '0' && i == glyphPrefixLength) {
|
2012-09-06 08:57:54 +04:00
|
|
|
return;
|
2013-08-19 17:08:43 +04:00
|
|
|
}
|
|
|
|
id = id * 10 + (ch - '0');
|
2012-09-06 08:57:54 +04:00
|
|
|
}
|
|
|
|
|
2013-08-19 17:08:43 +04:00
|
|
|
mGlyphIdMap.Put(id, aGlyphElement);
|
2012-09-06 08:57:54 +04:00
|
|
|
}
|
|
|
|
|
2012-09-06 08:58:47 +04:00
|
|
|
void
|
|
|
|
gfxTextObjectPaint::InitStrokeGeometry(gfxContext *aContext,
|
|
|
|
float devUnitsPerSVGUnit)
|
|
|
|
{
|
|
|
|
mStrokeWidth = aContext->CurrentLineWidth() / devUnitsPerSVGUnit;
|
|
|
|
aContext->CurrentDash(mDashes, &mDashOffset);
|
|
|
|
for (uint32_t i = 0; i < mDashes.Length(); i++) {
|
|
|
|
mDashes[i] /= devUnitsPerSVGUnit;
|
|
|
|
}
|
|
|
|
mDashOffset /= devUnitsPerSVGUnit;
|
|
|
|
}
|