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

Side by Side Diff: Source/core/css/FontLoader.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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google 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 are met: 5 * modification, are permitted provided that the following conditions are met:
6 * 6 *
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 params.get("onsuccess", onsuccess); 57 params.get("onsuccess", onsuccess);
58 params.get("onerror", onerror); 58 params.get("onerror", onerror);
59 if (!onsuccess && !onerror) 59 if (!onsuccess && !onerror)
60 return 0; 60 return 0;
61 int numFamilies = 0; 61 int numFamilies = 0;
62 for (const FontFamily* f = &family; f; f = f->next()) 62 for (const FontFamily* f = &family; f; f = f->next())
63 numFamilies++; 63 numFamilies++;
64 return LoadFontCallback::create(numFamilies, onsuccess, onerror); 64 return LoadFontCallback::create(numFamilies, onsuccess, onerror);
65 } 65 }
66 66
67 virtual void notifyLoaded(CSSSegmentedFontFace*) OVERRIDE; 67 virtual void notifyLoaded(Handle<CSSSegmentedFontFace>) OVERRIDE;
68 virtual void notifyError(CSSSegmentedFontFace*) OVERRIDE; 68 virtual void notifyError(Handle<CSSSegmentedFontFace>) OVERRIDE;
69 void loaded(Document*); 69 void loaded(Document*);
70 void error(Document*); 70 void error(Document*);
71 private: 71 private:
72 LoadFontCallback(int numLoading, PassRefPtr<VoidCallback> loadCallback, Pass RefPtr<VoidCallback> errorCallback) 72 LoadFontCallback(int numLoading, PassRefPtr<VoidCallback> loadCallback, Pass RefPtr<VoidCallback> errorCallback)
73 : m_numLoading(numLoading) 73 : m_numLoading(numLoading)
74 , m_errorOccured(false) 74 , m_errorOccured(false)
75 , m_loadCallback(loadCallback) 75 , m_loadCallback(loadCallback)
76 , m_errorCallback(errorCallback) 76 , m_errorCallback(errorCallback)
77 { } 77 { }
78 78
(...skipping 17 matching lines...) Expand all
96 document->fontloader()->scheduleCallback(m_loadCallback.release()); 96 document->fontloader()->scheduleCallback(m_loadCallback.release());
97 } 97 }
98 } 98 }
99 99
100 void LoadFontCallback::error(Document* document) 100 void LoadFontCallback::error(Document* document)
101 { 101 {
102 m_errorOccured = true; 102 m_errorOccured = true;
103 loaded(document); 103 loaded(document);
104 } 104 }
105 105
106 void LoadFontCallback::notifyLoaded(CSSSegmentedFontFace* face) 106 void LoadFontCallback::notifyLoaded(Handle<CSSSegmentedFontFace> face)
107 { 107 {
108 loaded(face->fontSelector()->document()); 108 CSSFontSelector* fontSelector = face->fontSelector();
109 ASSERT(fontSelector);
110 loaded(fontSelector->document());
109 } 111 }
110 112
111 void LoadFontCallback::notifyError(CSSSegmentedFontFace* face) 113 void LoadFontCallback::notifyError(Handle<CSSSegmentedFontFace> face)
112 { 114 {
113 error(face->fontSelector()->document()); 115 CSSFontSelector* fontSelector = face->fontSelector();
116 ASSERT(fontSelector);
117 error(fontSelector->document());
114 } 118 }
115 119
116 FontLoader::FontLoader(Document* document) 120 FontLoader::FontLoader(Document* document)
117 : ActiveDOMObject(document) 121 : ActiveDOMObject(document)
118 , m_document(document) 122 , m_document(document)
119 , m_loadingCount(0) 123 , m_loadingCount(0)
120 , m_timer(this, &FontLoader::timerFired) 124 , m_timer(this, &FontLoader::timerFired)
121 { 125 {
122 suspendIfNeeded(); 126 suspendIfNeeded();
123 } 127 }
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 // FIXME: The text member of params is ignored. 272 // FIXME: The text member of params is ignored.
269 String fontString; 273 String fontString;
270 if (!params.get("font", fontString)) 274 if (!params.get("font", fontString))
271 return; 275 return;
272 Font font; 276 Font font;
273 if (!resolveFontStyle(fontString, font)) 277 if (!resolveFontStyle(fontString, font))
274 return; 278 return;
275 RefPtr<LoadFontCallback> callback = LoadFontCallback::createFromParams(param s, font.family()); 279 RefPtr<LoadFontCallback> callback = LoadFontCallback::createFromParams(param s, font.family());
276 280
277 for (const FontFamily* f = &font.family(); f; f = f->next()) { 281 for (const FontFamily* f = &font.family(); f; f = f->next()) {
278 CSSSegmentedFontFace* face = m_document->styleResolver()->fontSelector() ->getFontFace(font.fontDescription(), f->family()); 282 Handle<CSSSegmentedFontFace> face = m_document->styleResolver()->fontSel ector()->getFontFace(font.fontDescription(), f->family());
279 if (!face) { 283 if (!face) {
280 if (callback) 284 if (callback)
281 callback->error(m_document); 285 callback->error(m_document);
282 continue; 286 continue;
283 } 287 }
284 face->loadFont(font.fontDescription(), callback); 288 face->loadFont(font.fontDescription(), callback);
285 } 289 }
286 } 290 }
287 291
288 bool FontLoader::checkFont(const String& fontString, const String&) 292 bool FontLoader::checkFont(const String& fontString, const String&)
289 { 293 {
290 // FIXME: The second parameter (text) is ignored. 294 // FIXME: The second parameter (text) is ignored.
291 Font font; 295 Font font;
292 if (!resolveFontStyle(fontString, font)) 296 if (!resolveFontStyle(fontString, font))
293 return false; 297 return false;
294 for (const FontFamily* f = &font.family(); f; f = f->next()) { 298 for (const FontFamily* f = &font.family(); f; f = f->next()) {
295 CSSSegmentedFontFace* face = m_document->styleResolver()->fontSelector() ->getFontFace(font.fontDescription(), f->family()); 299 Handle<CSSSegmentedFontFace> face = m_document->styleResolver()->fontSel ector()->getFontFace(font.fontDescription(), f->family());
296 if (!face || !face->checkFont()) 300 if (!face || !face->checkFont())
297 return false; 301 return false;
298 } 302 }
299 return true; 303 return true;
300 } 304 }
301 305
302 static void applyPropertyToCurrentStyle(StyleResolver* styleResolver, CSSPropert yID id, const Handle<StylePropertySet>& parsedStyle) 306 static void applyPropertyToCurrentStyle(StyleResolver* styleResolver, CSSPropert yID id, const Handle<StylePropertySet>& parsedStyle)
303 { 307 {
304 styleResolver->applyPropertyToCurrentStyle(id, Handle<CSSValue>(parsedStyle- >getPropertyCSSValue(id)).raw()); 308 styleResolver->applyPropertyToCurrentStyle(id, Handle<CSSValue>(parsedStyle- >getPropertyCSSValue(id)).raw());
305 } 309 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 applyPropertyToCurrentStyle(styleResolver, CSSPropertyFontSize, parsedStyle) ; 348 applyPropertyToCurrentStyle(styleResolver, CSSPropertyFontSize, parsedStyle) ;
345 styleResolver->updateFont(); 349 styleResolver->updateFont();
346 applyPropertyToCurrentStyle(styleResolver, CSSPropertyLineHeight, parsedStyl e); 350 applyPropertyToCurrentStyle(styleResolver, CSSPropertyLineHeight, parsedStyl e);
347 351
348 font = style->font(); 352 font = style->font();
349 font.update(styleResolver->fontSelector()); 353 font.update(styleResolver->fontSelector());
350 return true; 354 return true;
351 } 355 }
352 356
353 } // namespace WebCore 357 } // namespace WebCore
OLDNEW
« Source/core/css/CSSFontSelector.h ('K') | « Source/core/css/CSSSegmentedFontFace.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698