Chromium Code Reviews| Index: Source/core/css/CSSFontSelector.cpp |
| diff --git a/Source/core/css/CSSFontSelector.cpp b/Source/core/css/CSSFontSelector.cpp |
| index 3871cdf714f693ee1c50d4f81ede65514fe17b17..022ba8d9bb526d8ca97accccf2de6b7776e06801 100644 |
| --- a/Source/core/css/CSSFontSelector.cpp |
| +++ b/Source/core/css/CSSFontSelector.cpp |
| @@ -195,7 +195,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(); |
| @@ -292,29 +292,29 @@ void CSSFontSelector::addFontFaceRule(const Handle<StyleRuleFontFace>& fontFaceR |
| if (familyName.isEmpty()) |
| continue; |
| - OwnPtr<Vector<RefPtr<CSSFontFace> > >& familyFontFaces = m_fontFaces.add(familyName, nullptr).iterator->value; |
| + OwnPtr<CSSFontFaceVectorCollection>& familyFontFaces = m_fontFaces.add(familyName, nullptr).iterator->value; |
| if (!familyFontFaces) { |
| - familyFontFaces = adoptPtr(new Vector<RefPtr<CSSFontFace> >); |
| + familyFontFaces = adoptPtr(new CSSFontFaceVectorCollection); |
| 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) { |
|
zerny-google
2013/07/02 14:24:04
Handle scope.
haraken
2013/07/02 14:31:30
Done.
|
| - RefPtr<CSSFontFace> locallyInstalledFontFace = CSSFontFace::create(static_cast<FontTraitsMask>(locallyInstalledFontsTraitsMasks[i]), nullptr, true); |
| + 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; |
| } |
| @@ -392,7 +392,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(); |
| @@ -482,7 +482,7 @@ PassRefPtr<FontData> CSSFontSelector::getFontData(const FontDescription& fontDes |
| return 0; |
| } |
| - CSSSegmentedFontFace* face = getFontFace(fontDescription, familyName); |
| + Handle<CSSSegmentedFontFace> face = getFontFace(fontDescription, familyName); |
| // If no face was found, then return 0 and let the OS come up with its best match for the name. |
| if (!face) { |
| // If we were handed a generic family, but there was no match, go ahead and return the correct font based off our |
| @@ -496,26 +496,26 @@ PassRefPtr<FontData> CSSFontSelector::getFontData(const FontDescription& fontDes |
| return face->getFontData(fontDescription); |
| } |
| -CSSSegmentedFontFace* CSSFontSelector::getFontFace(const FontDescription& fontDescription, const AtomicString& family) |
| +Result<CSSSegmentedFontFace> CSSFontSelector::getFontFace(const FontDescription& fontDescription, const AtomicString& family) |
| { |
| - Vector<RefPtr<CSSFontFace> >* familyFontFaces = m_fontFaces.get(family); |
| - if (!familyFontFaces || familyFontFaces->isEmpty()) |
| - return 0; |
| + CSSFontFaceVectorCollection* familyFontFaces = m_fontFaces.get(family); |
| + if (!familyFontFaces || (*familyFontFaces)->isEmpty()) |
| + return nullptr; |
| - OwnPtr<HashMap<unsigned, RefPtr<CSSSegmentedFontFace> > >& segmentedFontFaceCache = m_fonts.add(family, nullptr).iterator->value; |
| + OwnPtr<HashMap<unsigned, Persistent<CSSSegmentedFontFace> > >& segmentedFontFaceCache = m_fonts.add(family, nullptr).iterator->value; |
| if (!segmentedFontFaceCache) |
| - segmentedFontFaceCache = adoptPtr(new HashMap<unsigned, RefPtr<CSSSegmentedFontFace> >); |
| + segmentedFontFaceCache = adoptPtr(new HashMap<unsigned, Persistent<CSSSegmentedFontFace> >); |
| FontTraitsMask traitsMask = fontDescription.traitsMask(); |
| - RefPtr<CSSSegmentedFontFace>& face = segmentedFontFaceCache->add(traitsMask, 0).iterator->value; |
| + Persistent<CSSSegmentedFontFace>& face = segmentedFontFaceCache->add(traitsMask, nullptr).iterator->value; |
| if (!face) { |
| face = CSSSegmentedFontFace::create(this); |
| // 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(); |
| + Vector<Handle<CSSFontFace>, 32> candidateFontFaces; |
| + for (int i = (*familyFontFaces)->size() - 1; i >= 0; --i) { |
| + Handle<CSSFontFace> candidate = (*familyFontFaces)->at(i); |
| unsigned candidateTraitsMask = candidate->traitsMask(); |
| if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & FontStyleNormalMask)) |
| continue; |
| @@ -530,10 +530,11 @@ CSSSegmentedFontFace* CSSFontSelector::getFontFace(const FontDescription& fontDe |
| 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) { |
|
zerny-google
2013/07/02 14:24:04
Handle scope
haraken
2013/07/02 14:31:30
Done.
|
| - CSSFontFace* candidate = familyLocallyInstalledFontFaces->at(i).get(); |
| + Handle<CSSFontFace> candidate = (*familyLocallyInstalledFontFaces)->at(i); |
| unsigned candidateTraitsMask = candidate->traitsMask(); |
| if ((traitsMask & FontStyleNormalMask) && !(candidateTraitsMask & FontStyleNormalMask)) |
| continue; |
| @@ -549,7 +550,7 @@ CSSSegmentedFontFace* CSSFontSelector::getFontFace(const FontDescription& fontDe |
| for (unsigned i = 0; i < numCandidates; ++i) |
| face->appendFontFace(candidateFontFaces[i]); |
| } |
| - return face.get(); |
| + return face; |
| } |
| void CSSFontSelector::clearDocument() |