예제 #1
0
FontFace::FontFace(nsISupports* aParent, FontFaceSet* aFontFaceSet)
  : mParent(aParent)
  , mLoadedRejection(NS_OK)
  , mStatus(FontFaceLoadStatus::Unloaded)
  , mSourceType(SourceType(0))
  , mSourceBuffer(nullptr)
  , mSourceBufferLength(0)
  , mFontFaceSet(aFontFaceSet)
  , mInFontFaceSet(false)
{
}
예제 #2
0
FontFace::FontFace(nsISupports* aParent, FontFaceSet* aFontFaceSet)
  : mParent(aParent)
  , mStatus(FontFaceLoadStatus::Unloaded)
  , mSourceType(SourceType(0))
  , mSourceBuffer(nullptr)
  , mSourceBufferLength(0)
  , mFontFaceSet(aFontFaceSet)
  , mInFontFaceSet(false)
{
  MOZ_COUNT_CTOR(FontFace);

  nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aParent);

  // If the pref is not set, don't create the Promise (which the page wouldn't
  // be able to get to anyway) as it causes the window.FontFace constructor
  // to be created.
  if (global && FontFaceSet::PrefEnabled()) {
    ErrorResult rv;
    mLoaded = Promise::Create(global, rv);
  }
}
예제 #3
0
inline void
doXercesTranscode(
            const SourceType*           theSourceString,
            XalanDOMString::size_type   theSourceStringLength,
            bool                        theSourceStringIsNullTerminated,
            XalanVector<TargetType>&    theTargetVector,
            bool                        terminate,
            char                        theSubstitutionChar)
{
    assert(
        theSourceStringIsNullTerminated == false ||
        theSourceStringLength == XalanDOMString::length(theSourceString));

    const SourceType*   theRealSourceString = theSourceString;

    XalanVector<SourceType>     theCopiedSource(theTargetVector.getMemoryManager());

    if (theSourceStringIsNullTerminated == false)
    {
        theCopiedSource.reserve(theSourceStringLength + 1);

        theCopiedSource.assign(
            theSourceString,
            theSourceString + theSourceStringLength);

        theCopiedSource.push_back(static_cast<SourceType>(0));

        theRealSourceString = &*theCopiedSource.begin();
    }

    // Initially, let's guess the the transcoded string will be the same
    // length as the source string.
    theTargetVector.resize(theSourceStringLength + 1);

    assert(theRealSourceString != 0);

    bool            fSuccess = false;

    XALAN_USING_XERCES(XMLString)

    fSuccess = XMLString::transcode(
        theRealSourceString,
        &*theTargetVector.begin(),
        theTargetVector.size() - 1,
        &theTargetVector.getMemoryManager());

    if (fSuccess == false)
    {
        // Do the "manual" transcoding.  But first, clean up from the
        // previous phase
        theTargetVector.clear();

        // See if there are any unrepresentable characters for the
        // local code page.
        SourceType oneCharArray[2];

        oneCharArray[1] = SourceType(0);

        TargetType theOneTranslatedWbChar[theOneTranslatedWbCharLen]; 

        for (XalanDOMString::size_type i = 0; i < theSourceStringLength; ++i)
        {
            oneCharArray[0] = theRealSourceString[i];

            theOneTranslatedWbChar[0] = TargetType(0);

            fSuccess = XMLString::transcode(
                oneCharArray,
                theOneTranslatedWbChar,
                theOneTranslatedWbCharLen - 1,
                &theTargetVector.getMemoryManager());

            if (fSuccess == false)
            {
                theTargetVector.push_back(theSubstitutionChar);
            }
            else
            {
                XalanDOMString::size_type theRealCharLength =
                    XalanDOMString::length(theOneTranslatedWbChar);

                // When we transcode the character '\0', that looks like "\0\0", 
                // XalanDOMString::length returns a size of 0.  In this case, the
                // real size should be 1
                if (theRealCharLength == 0)
                {
                    theRealCharLength = 1;
                }

                // append the translated set of characters
                theTargetVector.insert(
                    theTargetVector.end(),
                    theOneTranslatedWbChar,
                    theOneTranslatedWbChar + theRealCharLength);
            }
        }

    }

    while(theTargetVector.back() == static_cast<TargetType>(0))
    {
        theTargetVector.pop_back();
    }

    if (terminate == true)
    {
        theTargetVector.push_back(static_cast<TargetType>(0));
    }
}