Chromium Code Reviews| Index: Source/core/css/CSSFontSelector.cpp |
| diff --git a/Source/core/css/CSSFontSelector.cpp b/Source/core/css/CSSFontSelector.cpp |
| index 8828f1d8863ead16c88051f5398f29cf4830c88e..061a91a87d326c05abd196670d4ba2cf4b238d3a 100644 |
| --- a/Source/core/css/CSSFontSelector.cpp |
| +++ b/Source/core/css/CSSFontSelector.cpp |
| @@ -78,6 +78,15 @@ CSSFontSelector::~CSSFontSelector() |
| { |
| clearDocument(); |
| fontCache()->removeClient(this); |
| + |
| + // FIXME(oilpan): This is code to clear a back pointer from CSSSegmentedFontFace to CSSFontSelector. |
| + // We should remove this hack by moving CSSFontSelector to the managed heap and having the |
| + // CSSFontSelector hold Member<CSSSegmentedFontFace>. |
|
haraken
2013/07/09 07:10:53
This is the part where I'm clearing the back point
|
| + for (HashMap<String, OwnPtr<SegmentedFontFaceHashMap>, WTF::FastAllocator, CaseFoldingHash>::iterator it = m_fonts.begin(); it != m_fonts.end(); ++it) { |
| + SegmentedFontFaceHashMap* segmentedFontFaceHashMap = it->value.get(); |
| + for (SegmentedFontFaceHashMap::iterator it2 = segmentedFontFaceHashMap->begin(); it2 != segmentedFontFaceHashMap->end(); ++it2) |
| + it2->value->clearFontSelector(); |
| + } |
| } |
| bool CSSFontSelector::isEmpty() const |
| @@ -487,7 +496,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 |
| @@ -501,21 +510,22 @@ 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; |
| + 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; |
| + Handle<CSSSegmentedFontFace> face = segmentedFontFaceCache->add(traitsMask, nullptr).iterator->value; |
| if (!face) { |
| face = CSSSegmentedFontFace::create(this); |
| + segmentedFontFaceCache->set(traitsMask, face); |
| // Collect all matching faces and sort them in order of preference. |
| Vector<CSSFontFace*, 32> candidateFontFaces; |
| @@ -554,7 +564,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() |