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

Side by Side Diff: Source/core/css/CSSSegmentedFontFace.cpp

Issue 18375005: [oilpan] Move CSSFontFace and 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 19 matching lines...) Expand all
30 #include "core/css/CSSFontFaceSource.h" 30 #include "core/css/CSSFontFaceSource.h"
31 #include "core/css/CSSFontSelector.h" 31 #include "core/css/CSSFontSelector.h"
32 #include "core/dom/Document.h" 32 #include "core/dom/Document.h"
33 #include "RuntimeEnabledFeatures.h" 33 #include "RuntimeEnabledFeatures.h"
34 #include "core/platform/graphics/FontDescription.h" 34 #include "core/platform/graphics/FontDescription.h"
35 #include "core/platform/graphics/SegmentedFontData.h" 35 #include "core/platform/graphics/SegmentedFontData.h"
36 #include "core/platform/graphics/SimpleFontData.h" 36 #include "core/platform/graphics/SimpleFontData.h"
37 37
38 namespace WebCore { 38 namespace WebCore {
39 39
40 DEFINE_GC_TYPE_MARKER(CSSSegmentedFontFace);
41 DEFINE_GC_TYPE_MARKER(CSSSegmentedFontFace::LoadFontCallback);
42
40 CSSSegmentedFontFace::CSSSegmentedFontFace(CSSFontSelector* fontSelector) 43 CSSSegmentedFontFace::CSSSegmentedFontFace(CSSFontSelector* fontSelector)
41 : m_fontSelector(fontSelector) 44 : m_fontSelector(fontSelector)
42 { 45 {
43 } 46 }
44 47
45 CSSSegmentedFontFace::~CSSSegmentedFontFace() 48 CSSSegmentedFontFace::~CSSSegmentedFontFace()
46 { 49 {
47 pruneTable(); 50 pruneTable();
48 unsigned size = m_fontFaces.size(); 51 unsigned size = m_fontFaces.size();
49 for (unsigned i = 0; i < size; i++) 52 for (unsigned i = 0; i < size; i++)
50 m_fontFaces[i]->removedFromSegmentedFontFace(this); 53 m_fontFaces[i]->removedFromSegmentedFontFace(Handle<CSSSegmentedFontFace >(this));
51 } 54 }
52 55
53 void CSSSegmentedFontFace::pruneTable() 56 void CSSSegmentedFontFace::pruneTable()
54 { 57 {
55 // Make sure the glyph page tree prunes out all uses of this custom font. 58 // Make sure the glyph page tree prunes out all uses of this custom font.
56 if (m_fontDataTable.isEmpty()) 59 if (m_fontDataTable.isEmpty())
57 return; 60 return;
58 61
59 m_fontDataTable.clear(); 62 m_fontDataTable.clear();
60 } 63 }
61 64
62 bool CSSSegmentedFontFace::isValid() const 65 bool CSSSegmentedFontFace::isValid() const
63 { 66 {
64 // Valid if at least one font face is valid. 67 // Valid if at least one font face is valid.
65 unsigned size = m_fontFaces.size(); 68 unsigned size = m_fontFaces.size();
66 for (unsigned i = 0; i < size; i++) { 69 for (unsigned i = 0; i < size; i++) {
67 if (m_fontFaces[i]->isValid()) 70 if (m_fontFaces[i]->isValid())
68 return true; 71 return true;
69 } 72 }
70 return false; 73 return false;
71 } 74 }
72 75
73 void CSSSegmentedFontFace::fontLoaded(CSSFontFace*) 76 void CSSSegmentedFontFace::fontLoaded(Handle<CSSFontFace>)
74 { 77 {
75 pruneTable(); 78 pruneTable();
76 79
77 if (RuntimeEnabledFeatures::fontLoadEventsEnabled() && !isLoading()) { 80 if (RuntimeEnabledFeatures::fontLoadEventsEnabled() && !isLoading()) {
78 Vector<RefPtr<LoadFontCallback> > callbacks; 81 CollectionRoot<Vector<Member<LoadFontCallback> > > callbacks;
79 m_callbacks.swap(callbacks); 82 m_callbacks.swap(*callbacks);
80 for (size_t index = 0; index < callbacks.size(); ++index) { 83 for (size_t index = 0; index < callbacks->size(); ++index) {
81 if (checkFont()) 84 if (checkFont())
82 callbacks[index]->notifyLoaded(this); 85 callbacks->at(index)->notifyLoaded(Handle<CSSSegmentedFontFace>( this));
83 else 86 else
84 callbacks[index]->notifyError(this); 87 callbacks->at(index)->notifyError(Handle<CSSSegmentedFontFace>(t his));
85 } 88 }
86 } 89 }
87 } 90 }
88 91
89 void CSSSegmentedFontFace::appendFontFace(PassRefPtr<CSSFontFace> fontFace) 92 void CSSSegmentedFontFace::appendFontFace(Handle<CSSFontFace> fontFace)
90 { 93 {
91 pruneTable(); 94 pruneTable();
92 fontFace->addedToSegmentedFontFace(this); 95 fontFace->addedToSegmentedFontFace(Handle<CSSSegmentedFontFace>(this));
93 m_fontFaces.append(fontFace); 96 m_fontFaces.append(fontFace);
94 } 97 }
95 98
96 static void appendFontDataWithInvalidUnicodeRangeIfLoading(SegmentedFontData* ne wFontData, PassRefPtr<SimpleFontData> prpFaceFontData, const Vector<CSSFontFace: :UnicodeRange>& ranges) 99 static void appendFontDataWithInvalidUnicodeRangeIfLoading(SegmentedFontData* ne wFontData, PassRefPtr<SimpleFontData> prpFaceFontData, const Vector<CSSFontFace: :UnicodeRange>& ranges)
97 { 100 {
98 RefPtr<SimpleFontData> faceFontData = prpFaceFontData; 101 RefPtr<SimpleFontData> faceFontData = prpFaceFontData;
99 if (faceFontData->isLoading()) { 102 if (faceFontData->isLoading()) {
100 newFontData->appendRange(FontDataRange(0, 0, faceFontData)); 103 newFontData->appendRange(FontDataRange(0, 0, faceFontData));
101 return; 104 return;
102 } 105 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 bool CSSSegmentedFontFace::checkFont() const 163 bool CSSSegmentedFontFace::checkFont() const
161 { 164 {
162 unsigned size = m_fontFaces.size(); 165 unsigned size = m_fontFaces.size();
163 for (unsigned i = 0; i < size; i++) { 166 for (unsigned i = 0; i < size; i++) {
164 if (m_fontFaces[i]->loadState() != CSSFontFace::Loaded) 167 if (m_fontFaces[i]->loadState() != CSSFontFace::Loaded)
165 return false; 168 return false;
166 } 169 }
167 return true; 170 return true;
168 } 171 }
169 172
170 void CSSSegmentedFontFace::loadFont(const FontDescription& fontDescription, Pass RefPtr<LoadFontCallback> callback) 173 void CSSSegmentedFontFace::loadFont(const FontDescription& fontDescription, Hand le<LoadFontCallback> callback)
171 { 174 {
172 getFontData(fontDescription); // Kick off the load. 175 getFontData(fontDescription); // Kick off the load.
173 176
174 if (callback) { 177 if (callback) {
175 if (isLoading()) 178 if (isLoading())
176 m_callbacks.append(callback); 179 m_callbacks.append(callback);
177 else if (checkFont()) 180 else if (checkFont())
178 callback->notifyLoaded(this); 181 callback->notifyLoaded(Handle<CSSSegmentedFontFace>(this));
179 else 182 else
180 callback->notifyError(this); 183 callback->notifyError(Handle<CSSSegmentedFontFace>(this));
181 } 184 }
182 } 185 }
183 186
187 void CSSSegmentedFontFace::accept(Visitor* visitor) const
188 {
189 visitor->visit(m_fontFaces);
190 visitor->visit(m_callbacks);
184 } 191 }
192
193 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698