| Index: Source/core/css/CSSFontSelector.cpp
|
| diff --git a/Source/core/css/CSSFontSelector.cpp b/Source/core/css/CSSFontSelector.cpp
|
| index 192577b8f2357efe8821a2c6d3f36eb4d1e0a55e..836ffd6f3df1b623b414e1176a186aa04f03dae6 100644
|
| --- a/Source/core/css/CSSFontSelector.cpp
|
| +++ b/Source/core/css/CSSFontSelector.cpp
|
| @@ -206,7 +206,7 @@ void CSSFontSelector::addFontFaceRule(const Handle<StyleRuleFontFace>& fontFaceR
|
| traitsMask |= FontVariantMask;
|
|
|
| // Each item in the src property's list is a single CSSFontFaceSource. Put them all into a CSSFontFace.
|
| - RefPtr<CSSFontFace> fontFace;
|
| + Handle<CSSFontFace> fontFace;
|
|
|
| int srcLength = srcList->length();
|
|
|
| @@ -307,29 +307,33 @@ void CSSFontSelector::addFontFaceRule(const Handle<StyleRuleFontFace>& fontFaceR
|
| if (familyName.isEmpty())
|
| continue;
|
|
|
| - OwnPtr<Vector<RefPtr<CSSFontFace> > >& familyFontFaces = m_fontFaces.add(familyName, nullptr).iterator->value;
|
| + // FIXME(oilpan): Using a raw pointer is safe because we're inside CSSFontSelector's
|
| + // method and the CSSFontSelector keeps lifetime of the collection.
|
| + CSSFontFaceVectorCollection* familyFontFaces = m_fontFaces.add(familyName, nullptr).iterator->value.get();
|
| if (!familyFontFaces) {
|
| - familyFontFaces = adoptPtr(new Vector<RefPtr<CSSFontFace> >);
|
| + familyFontFaces = new CSSFontFaceVectorCollection;
|
| + m_fontFaces.set(familyName, adoptPtr(familyFontFaces));
|
|
|
| ASSERT(!m_locallyInstalledFontFaces.contains(familyName));
|
|
|
| Vector<unsigned> locallyInstalledFontsTraitsMasks;
|
| fontCache()->getTraitsInFamily(familyName, locallyInstalledFontsTraitsMasks);
|
| if (unsigned numLocallyInstalledFaces = locallyInstalledFontsTraitsMasks.size()) {
|
| - OwnPtr<Vector<RefPtr<CSSFontFace> > > familyLocallyInstalledFaces = adoptPtr(new Vector<RefPtr<CSSFontFace> >);
|
| + OwnPtr<CSSFontFaceVectorCollection> familyLocallyInstalledFaces = adoptPtr(new CSSFontFaceVectorCollection);
|
|
|
| for (unsigned i = 0; i < numLocallyInstalledFaces; ++i) {
|
| - RefPtr<CSSFontFace> locallyInstalledFontFace = CSSFontFace::create(static_cast<FontTraitsMask>(locallyInstalledFontsTraitsMasks[i]), nullptr, true);
|
| + HandleScope scope;
|
| + Handle<CSSFontFace> locallyInstalledFontFace = CSSFontFace::create(static_cast<FontTraitsMask>(locallyInstalledFontsTraitsMasks[i]), nullptr, true);
|
| locallyInstalledFontFace->addSource(adoptPtr(new CSSFontFaceSource(familyName)));
|
| ASSERT(locallyInstalledFontFace->isValid());
|
| - familyLocallyInstalledFaces->append(locallyInstalledFontFace);
|
| + (*familyLocallyInstalledFaces)->append(locallyInstalledFontFace);
|
| }
|
|
|
| m_locallyInstalledFontFaces.set(familyName, familyLocallyInstalledFaces.release());
|
| }
|
| }
|
|
|
| - familyFontFaces->append(fontFace);
|
| + (*familyFontFaces)->append(fontFace);
|
|
|
| ++m_version;
|
| }
|
| @@ -407,7 +411,7 @@ static PassRefPtr<FontData> fontDataForGenericFamily(Document* document, const F
|
|
|
| static FontTraitsMask desiredTraitsMaskForComparison;
|
|
|
| -static inline bool compareFontFaces(CSSFontFace* first, CSSFontFace* second)
|
| +static inline bool compareFontFaces(Handle<CSSFontFace> first, Handle<CSSFontFace> second)
|
| {
|
| FontTraitsMask firstTraitsMask = first->traitsMask();
|
| FontTraitsMask secondTraitsMask = second->traitsMask();
|
| @@ -513,8 +517,10 @@ PassRefPtr<FontData> CSSFontSelector::getFontData(const FontDescription& fontDes
|
|
|
| Result<CSSSegmentedFontFace> CSSFontSelector::getFontFace(const FontDescription& fontDescription, const AtomicString& family)
|
| {
|
| - Vector<RefPtr<CSSFontFace> >* familyFontFaces = m_fontFaces.get(family);
|
| - if (!familyFontFaces || familyFontFaces->isEmpty())
|
| + // FIXME(oilpan): Using a raw pointer is safe because we're inside CSSFontSelector's
|
| + // method and the CSSFontSelector keeps lifetime of the collection.
|
| + CSSFontFaceVectorCollection* familyFontFaces = m_fontFaces.get(family);
|
| + if (!familyFontFaces || (*familyFontFaces)->isEmpty())
|
| return nullptr;
|
|
|
| OwnPtr<HashMap<unsigned, Persistent<CSSSegmentedFontFace> > >& segmentedFontFaceCache = m_fonts.add(family, nullptr).iterator->value;
|
| @@ -529,9 +535,10 @@ Result<CSSSegmentedFontFace> CSSFontSelector::getFontFace(const FontDescription&
|
| segmentedFontFaceCache->set(traitsMask, face);
|
|
|
| // Collect all matching faces and sort them in order of preference.
|
| - Vector<CSSFontFace*, 32> candidateFontFaces;
|
| - for (int i = familyFontFaces->size() - 1; i >= 0; --i) {
|
| - CSSFontFace* candidate = familyFontFaces->at(i).get();
|
| + CollectionRoot<Vector<Member<CSSFontFace>, 32> > candidateFontFaces;
|
| + for (int i = (*familyFontFaces)->size() - 1; i >= 0; --i) {
|
| + HandleScope scope;
|
| + Handle<CSSFontFace> candidate = (*familyFontFaces)->at(i);
|
| unsigned candidateTraitsMask = candidate->traitsMask();
|
| if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & FontStyleNormalMask))
|
| continue;
|
| @@ -543,27 +550,28 @@ Result<CSSSegmentedFontFace> CSSFontSelector::getFontFace(const FontDescription&
|
| if (candidate->hasSVGFontFaceSource() && (traitsMask & FontVariantSmallCapsMask) && !(candidateTraitsMask & FontVariantSmallCapsMask))
|
| continue;
|
| #endif
|
| - candidateFontFaces.append(candidate);
|
| + candidateFontFaces->append(candidate);
|
| }
|
|
|
| - if (Vector<RefPtr<CSSFontFace> >* familyLocallyInstalledFontFaces = m_locallyInstalledFontFaces.get(family)) {
|
| - unsigned numLocallyInstalledFontFaces = familyLocallyInstalledFontFaces->size();
|
| + CSSFontFaceVectorCollection* familyLocallyInstalledFontFaces = m_locallyInstalledFontFaces.get(family);
|
| + if (familyLocallyInstalledFontFaces) {
|
| + unsigned numLocallyInstalledFontFaces = (*familyLocallyInstalledFontFaces)->size();
|
| for (unsigned i = 0; i < numLocallyInstalledFontFaces; ++i) {
|
| - CSSFontFace* candidate = familyLocallyInstalledFontFaces->at(i).get();
|
| + Handle<CSSFontFace> candidate = (*familyLocallyInstalledFontFaces)->at(i);
|
| unsigned candidateTraitsMask = candidate->traitsMask();
|
| if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & FontStyleNormalMask))
|
| continue;
|
| if ((traitsMask & FontVariantNormalMask) && !(candidateTraitsMask & FontVariantNormalMask))
|
| continue;
|
| - candidateFontFaces.append(candidate);
|
| + candidateFontFaces->append(candidate);
|
| }
|
| }
|
|
|
| desiredTraitsMaskForComparison = traitsMask;
|
| - stable_sort(candidateFontFaces.begin(), candidateFontFaces.end(), compareFontFaces);
|
| - unsigned numCandidates = candidateFontFaces.size();
|
| + stable_sort(candidateFontFaces->begin(), candidateFontFaces->end(), compareFontFaces);
|
| + unsigned numCandidates = candidateFontFaces->size();
|
| for (unsigned i = 0; i < numCandidates; ++i)
|
| - face->appendFontFace(candidateFontFaces[i]);
|
| + face->appendFontFace(candidateFontFaces->at(i));
|
| }
|
| return face;
|
| }
|
|
|