OLD | NEW |
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 Loading... |
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 Loading... |
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 if (!fontSelector) |
| 110 return; |
| 111 loaded(fontSelector->document()); |
109 } | 112 } |
110 | 113 |
111 void LoadFontCallback::notifyError(CSSSegmentedFontFace* face) | 114 void LoadFontCallback::notifyError(Handle<CSSSegmentedFontFace> face) |
112 { | 115 { |
113 error(face->fontSelector()->document()); | 116 CSSFontSelector* fontSelector = face->fontSelector(); |
| 117 if (!fontSelector) |
| 118 return; |
| 119 error(fontSelector->document()); |
114 } | 120 } |
115 | 121 |
116 FontLoader::FontLoader(Document* document) | 122 FontLoader::FontLoader(Document* document) |
117 : ActiveDOMObject(document) | 123 : ActiveDOMObject(document) |
118 , m_document(document) | 124 , m_document(document) |
119 , m_loadingCount(0) | 125 , m_loadingCount(0) |
120 , m_timer(this, &FontLoader::timerFired) | 126 , m_timer(this, &FontLoader::timerFired) |
121 { | 127 { |
122 suspendIfNeeded(); | 128 suspendIfNeeded(); |
123 } | 129 } |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 // FIXME: The text member of params is ignored. | 274 // FIXME: The text member of params is ignored. |
269 String fontString; | 275 String fontString; |
270 if (!params.get("font", fontString)) | 276 if (!params.get("font", fontString)) |
271 return; | 277 return; |
272 Font font; | 278 Font font; |
273 if (!resolveFontStyle(fontString, font)) | 279 if (!resolveFontStyle(fontString, font)) |
274 return; | 280 return; |
275 RefPtr<LoadFontCallback> callback = LoadFontCallback::createFromParams(param
s, font.family()); | 281 RefPtr<LoadFontCallback> callback = LoadFontCallback::createFromParams(param
s, font.family()); |
276 | 282 |
277 for (const FontFamily* f = &font.family(); f; f = f->next()) { | 283 for (const FontFamily* f = &font.family(); f; f = f->next()) { |
278 CSSSegmentedFontFace* face = m_document->styleResolver()->fontSelector()
->getFontFace(font.fontDescription(), f->family()); | 284 Handle<CSSSegmentedFontFace> face = m_document->styleResolver()->fontSel
ector()->getFontFace(font.fontDescription(), f->family()); |
279 if (!face) { | 285 if (!face) { |
280 if (callback) | 286 if (callback) |
281 callback->error(m_document); | 287 callback->error(m_document); |
282 continue; | 288 continue; |
283 } | 289 } |
284 face->loadFont(font.fontDescription(), callback); | 290 face->loadFont(font.fontDescription(), callback); |
285 } | 291 } |
286 } | 292 } |
287 | 293 |
288 bool FontLoader::checkFont(const String& fontString, const String&) | 294 bool FontLoader::checkFont(const String& fontString, const String&) |
289 { | 295 { |
290 // FIXME: The second parameter (text) is ignored. | 296 // FIXME: The second parameter (text) is ignored. |
291 Font font; | 297 Font font; |
292 if (!resolveFontStyle(fontString, font)) | 298 if (!resolveFontStyle(fontString, font)) |
293 return false; | 299 return false; |
294 for (const FontFamily* f = &font.family(); f; f = f->next()) { | 300 for (const FontFamily* f = &font.family(); f; f = f->next()) { |
295 CSSSegmentedFontFace* face = m_document->styleResolver()->fontSelector()
->getFontFace(font.fontDescription(), f->family()); | 301 Handle<CSSSegmentedFontFace> face = m_document->styleResolver()->fontSel
ector()->getFontFace(font.fontDescription(), f->family()); |
296 if (!face || !face->checkFont()) | 302 if (!face || !face->checkFont()) |
297 return false; | 303 return false; |
298 } | 304 } |
299 return true; | 305 return true; |
300 } | 306 } |
301 | 307 |
302 static void applyPropertyToCurrentStyle(StyleResolver* styleResolver, CSSPropert
yID id, const Handle<StylePropertySet>& parsedStyle) | 308 static void applyPropertyToCurrentStyle(StyleResolver* styleResolver, CSSPropert
yID id, const Handle<StylePropertySet>& parsedStyle) |
303 { | 309 { |
304 styleResolver->applyPropertyToCurrentStyle(id, Handle<CSSValue>(parsedStyle-
>getPropertyCSSValue(id)).raw()); | 310 styleResolver->applyPropertyToCurrentStyle(id, Handle<CSSValue>(parsedStyle-
>getPropertyCSSValue(id)).raw()); |
305 } | 311 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 applyPropertyToCurrentStyle(styleResolver, CSSPropertyFontSize, parsedStyle)
; | 350 applyPropertyToCurrentStyle(styleResolver, CSSPropertyFontSize, parsedStyle)
; |
345 styleResolver->updateFont(); | 351 styleResolver->updateFont(); |
346 applyPropertyToCurrentStyle(styleResolver, CSSPropertyLineHeight, parsedStyl
e); | 352 applyPropertyToCurrentStyle(styleResolver, CSSPropertyLineHeight, parsedStyl
e); |
347 | 353 |
348 font = style->font(); | 354 font = style->font(); |
349 font.update(styleResolver->fontSelector()); | 355 font.update(styleResolver->fontSelector()); |
350 return true; | 356 return true; |
351 } | 357 } |
352 | 358 |
353 } // namespace WebCore | 359 } // namespace WebCore |
OLD | NEW |