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

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

Issue 18856015: [oilpan] Move CSSFontFace 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) 2007, 2008, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2011 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 10 matching lines...) Expand all
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27 #include "core/css/CSSFontFace.h" 27 #include "core/css/CSSFontFace.h"
28 28
29 #include "core/css/CSSFontFaceSource.h" 29 #include "core/css/CSSFontFaceSource.h"
30 #include "core/css/CSSFontSelector.h" 30 #include "core/css/CSSFontSelector.h"
31 #include "core/css/CSSSegmentedFontFace.h"
32 #include "core/css/FontLoader.h" 31 #include "core/css/FontLoader.h"
33 #include "core/dom/Document.h" 32 #include "core/dom/Document.h"
34 #include "RuntimeEnabledFeatures.h" 33 #include "RuntimeEnabledFeatures.h"
35 #include "core/platform/graphics/FontDescription.h" 34 #include "core/platform/graphics/FontDescription.h"
36 #include "core/platform/graphics/SimpleFontData.h" 35 #include "core/platform/graphics/SimpleFontData.h"
37 36
38 namespace WebCore { 37 namespace WebCore {
39 38
39 DEFINE_GC_TYPE_MARKER(CSSFontFace);
40
40 bool CSSFontFace::isLoaded() const 41 bool CSSFontFace::isLoaded() const
41 { 42 {
42 size_t size = m_sources.size(); 43 size_t size = m_sources.size();
43 for (size_t i = 0; i < size; i++) { 44 for (size_t i = 0; i < size; i++) {
44 if (!m_sources[i]->isLoaded()) 45 if (!m_sources[i]->isLoaded())
45 return false; 46 return false;
46 } 47 }
47 return true; 48 return true;
48 } 49 }
49 50
50 bool CSSFontFace::isValid() const 51 bool CSSFontFace::isValid() const
51 { 52 {
52 size_t size = m_sources.size(); 53 size_t size = m_sources.size();
53 for (size_t i = 0; i < size; i++) { 54 for (size_t i = 0; i < size; i++) {
54 if (m_sources[i]->isValid()) 55 if (m_sources[i]->isValid())
55 return true; 56 return true;
56 } 57 }
57 return false; 58 return false;
58 } 59 }
59 60
61 // FIXME(oilpan): Move CSSFontFaceSource to the managed heap and remove this.
62 // Then CSSFontFaceSource and CSSFontFace die in the same round of GC,
63 // and thus we don't need to call dispose().
64 void CSSFontFace::dispose()
65 {
66 m_sources.clear();
67 }
68
60 void CSSFontFace::addedToSegmentedFontFace(Handle<CSSSegmentedFontFace> segmente dFontFace) 69 void CSSFontFace::addedToSegmentedFontFace(Handle<CSSSegmentedFontFace> segmente dFontFace)
61 { 70 {
62 m_segmentedFontFaces.add(segmentedFontFace.raw()); 71 m_segmentedFontFaces.add(segmentedFontFace);
63 }
64
65 void CSSFontFace::removedFromSegmentedFontFace(Handle<CSSSegmentedFontFace> segm entedFontFace)
66 {
67 m_segmentedFontFaces.remove(segmentedFontFace.raw());
68 } 72 }
69 73
70 void CSSFontFace::addSource(PassOwnPtr<CSSFontFaceSource> source) 74 void CSSFontFace::addSource(PassOwnPtr<CSSFontFaceSource> source)
71 { 75 {
72 source->setFontFace(this); 76 source->setFontFace(Handle<CSSFontFace>(this));
73 m_sources.append(source); 77 m_sources.append(source);
74 } 78 }
75 79
76 void CSSFontFace::fontLoaded(CSSFontFaceSource* source) 80 void CSSFontFace::fontLoaded(CSSFontFaceSource* source)
77 { 81 {
78 if (source != m_activeSource) 82 if (source != m_activeSource)
79 return; 83 return;
80 84
81 // FIXME: Can we assert that m_segmentedFontFaces is not empty? That may 85 // FIXME: Can we assert that m_segmentedFontFaces is not empty? That may
82 // require stopping in-progress font loading when the last 86 // require stopping in-progress font loading when the last
83 // CSSSegmentedFontFace is removed. 87 // CSSSegmentedFontFace is removed.
84 if (m_segmentedFontFaces.isEmpty()) 88 if (m_segmentedFontFaces.isEmpty())
85 return; 89 return;
86 90
87 // Use one of the CSSSegmentedFontFaces' font selector. They all have 91 // Use one of the CSSSegmentedFontFaces' font selector. They all have
88 // the same font selector, so it's wasteful to store it in the CSSFontFace. 92 // the same font selector, so it's wasteful to store it in the CSSFontFace.
89 CSSFontSelector* fontSelector = (*m_segmentedFontFaces.begin())->fontSelecto r(); 93 CSSFontSelector* fontSelector = (*m_segmentedFontFaces.begin())->fontSelecto r();
90 ASSERT(fontSelector); 94 ASSERT(fontSelector);
91 fontSelector->fontLoaded(); 95 fontSelector->fontLoaded();
92 96
93 if (RuntimeEnabledFeatures::fontLoadEventsEnabled() && m_loadState == Loadin g) { 97 if (RuntimeEnabledFeatures::fontLoadEventsEnabled() && m_loadState == Loadin g) {
94 if (source->ensureFontData()) 98 if (source->ensureFontData())
95 notifyFontLoader(Loaded); 99 notifyFontLoader(Loaded);
96 else if (!isValid()) 100 else if (!isValid())
97 notifyFontLoader(Error); 101 notifyFontLoader(Error);
98 } 102 }
99 103
100 HashSet<CSSSegmentedFontFace*>::iterator end = m_segmentedFontFaces.end(); 104 HashSet<Member<CSSSegmentedFontFace> >::iterator end = m_segmentedFontFaces. end();
101 for (HashSet<CSSSegmentedFontFace*>::iterator it = m_segmentedFontFaces.begi n(); it != end; ++it) 105 for (HashSet<Member<CSSSegmentedFontFace> >::iterator it = m_segmentedFontFa ces.begin(); it != end; ++it) {
102 (*it)->fontLoaded(this); 106 HandleScope scope;
107 (*it)->fontLoaded(Handle<CSSFontFace>(this));
108 }
103 } 109 }
104 110
105 PassRefPtr<SimpleFontData> CSSFontFace::getFontData(const FontDescription& fontD escription, bool syntheticBold, bool syntheticItalic) 111 PassRefPtr<SimpleFontData> CSSFontFace::getFontData(const FontDescription& fontD escription, bool syntheticBold, bool syntheticItalic)
106 { 112 {
107 m_activeSource = 0; 113 m_activeSource = 0;
108 if (!isValid()) 114 if (!isValid())
109 return 0; 115 return 0;
110 116
111 ASSERT(!m_segmentedFontFaces.isEmpty()); 117 ASSERT(!m_segmentedFontFaces.isEmpty());
112 CSSFontSelector* fontSelector = (*m_segmentedFontFaces.begin())->fontSelecto r(); 118 CSSFontSelector* fontSelector = (*m_segmentedFontFaces.begin())->fontSelecto r();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 { 166 {
161 size_t size = m_sources.size(); 167 size_t size = m_sources.size();
162 for (size_t i = 0; i < size; i++) { 168 for (size_t i = 0; i < size; i++) {
163 if (m_sources[i]->isSVGFontFaceSource()) 169 if (m_sources[i]->isSVGFontFaceSource())
164 return true; 170 return true;
165 } 171 }
166 return false; 172 return false;
167 } 173 }
168 #endif 174 #endif
169 175
176 void CSSFontFace::accept(Visitor* visitor) const
177 {
178 visitor->visit(m_rule);
179 visitor->visit(m_segmentedFontFaces);
170 } 180 }
181
182 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698