Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Unified Diff: Source/core/css/CSSFontSelector.cpp

Issue 18882002: [oilpan] Move CSSSegmentedFontFace to the managed heap (Closed) Base URL: svn://svn.chromium.org/blink/branches/oilpan
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/css/CSSFontSelector.cpp
diff --git a/Source/core/css/CSSFontSelector.cpp b/Source/core/css/CSSFontSelector.cpp
index 8828f1d8863ead16c88051f5398f29cf4830c88e..192577b8f2357efe8821a2c6d3f36eb4d1e0a55e 100644
--- a/Source/core/css/CSSFontSelector.cpp
+++ b/Source/core/css/CSSFontSelector.cpp
@@ -78,6 +78,16 @@ CSSFontSelector::~CSSFontSelector()
{
clearDocument();
fontCache()->removeClient(this);
+
+ // FIXME(oilpan): This code iterates over all CSSSegmentedFontFace's CSSFontSelector owns
+ // and ask their CSSFontFace's to clear their lists of CSSFontFaceSource.
+ // When CSSFontSelector is moved to the managed heap we should move this
+ // clearing to the moment when StyleResolver is detached from the document (by clearStyleResolver()).
+ 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->dispose();
+ }
}
bool CSSFontSelector::isEmpty() const
@@ -487,7 +497,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 +511,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 +565,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()

Powered by Google App Engine
This is Rietveld 408576698