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

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

Issue 297513008: Decrease call sites of ScriptState::current() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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
« no previous file with comments | « Source/core/css/FontFace.idl ('k') | Source/core/css/MediaQueryListListener.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "core/frame/LocalFrame.h" 43 #include "core/frame/LocalFrame.h"
44 #include "public/platform/Platform.h" 44 #include "public/platform/Platform.h"
45 45
46 namespace WebCore { 46 namespace WebCore {
47 47
48 static const int defaultFontSize = 10; 48 static const int defaultFontSize = 10;
49 static const char defaultFontFamily[] = "sans-serif"; 49 static const char defaultFontFamily[] = "sans-serif";
50 50
51 class LoadFontPromiseResolver FINAL : public FontFace::LoadFontCallback { 51 class LoadFontPromiseResolver FINAL : public FontFace::LoadFontCallback {
52 public: 52 public:
53 static PassRefPtrWillBeRawPtr<LoadFontPromiseResolver> create(FontFaceArray faces, ExecutionContext* context) 53 static PassRefPtrWillBeRawPtr<LoadFontPromiseResolver> create(FontFaceArray faces, ScriptState* scriptState)
54 { 54 {
55 return adoptRefWillBeNoop(new LoadFontPromiseResolver(faces, context)); 55 return adoptRefWillBeNoop(new LoadFontPromiseResolver(faces, scriptState ));
56 } 56 }
57 57
58 void loadFonts(ExecutionContext*); 58 void loadFonts(ExecutionContext*);
59 ScriptPromise promise() { return m_resolver->promise(); } 59 ScriptPromise promise() { return m_resolver->promise(); }
60 60
61 virtual void notifyLoaded(FontFace*) OVERRIDE; 61 virtual void notifyLoaded(FontFace*) OVERRIDE;
62 virtual void notifyError(FontFace*) OVERRIDE; 62 virtual void notifyError(FontFace*) OVERRIDE;
63 63
64 virtual void trace(Visitor*) OVERRIDE; 64 virtual void trace(Visitor*) OVERRIDE;
65 65
66 private: 66 private:
67 LoadFontPromiseResolver(FontFaceArray faces, ExecutionContext* context) 67 LoadFontPromiseResolver(FontFaceArray faces, ScriptState* scriptState)
68 : m_numLoading(faces.size()) 68 : m_numLoading(faces.size())
69 , m_errorOccured(false) 69 , m_errorOccured(false)
70 , m_resolver(ScriptPromiseResolverWithContext::create(ScriptState::curre nt(toIsolate(context)))) 70 , m_resolver(ScriptPromiseResolverWithContext::create(scriptState))
71 { 71 {
72 m_fontFaces.swap(faces); 72 m_fontFaces.swap(faces);
73 } 73 }
74 74
75 WillBeHeapVector<RefPtrWillBeMember<FontFace> > m_fontFaces; 75 WillBeHeapVector<RefPtrWillBeMember<FontFace> > m_fontFaces;
76 int m_numLoading; 76 int m_numLoading;
77 bool m_errorOccured; 77 bool m_errorOccured;
78 RefPtr<ScriptPromiseResolverWithContext> m_resolver; 78 RefPtr<ScriptPromiseResolverWithContext> m_resolver;
79 }; 79 };
80 80
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 } 450 }
451 451
452 FontFaceCache* fontFaceCache = document()->styleEngine()->fontSelector()->fo ntFaceCache(); 452 FontFaceCache* fontFaceCache = document()->styleEngine()->fontSelector()->fo ntFaceCache();
453 FontFaceArray faces; 453 FontFaceArray faces;
454 for (const FontFamily* f = &font.fontDescription().family(); f; f = f->next( )) { 454 for (const FontFamily* f = &font.fontDescription().family(); f; f = f->next( )) {
455 CSSSegmentedFontFace* segmentedFontFace = fontFaceCache->get(font.fontDe scription(), f->family()); 455 CSSSegmentedFontFace* segmentedFontFace = fontFaceCache->get(font.fontDe scription(), f->family());
456 if (segmentedFontFace) 456 if (segmentedFontFace)
457 segmentedFontFace->match(nullToSpace(text), faces); 457 segmentedFontFace->match(nullToSpace(text), faces);
458 } 458 }
459 459
460 RefPtrWillBeRawPtr<LoadFontPromiseResolver> resolver = LoadFontPromiseResolv er::create(faces, executionContext()); 460 RefPtrWillBeRawPtr<LoadFontPromiseResolver> resolver = LoadFontPromiseResolv er::create(faces, scriptState);
461 ScriptPromise promise = resolver->promise(); 461 ScriptPromise promise = resolver->promise();
462 resolver->loadFonts(executionContext()); // After this, resolver->promise() may return null. 462 resolver->loadFonts(executionContext()); // After this, resolver->promise() may return null.
463 return promise; 463 return promise;
464 } 464 }
465 465
466 bool FontFaceSet::check(const String& fontString, const String& text, ExceptionS tate& exceptionState) 466 bool FontFaceSet::check(const String& fontString, const String& text, ExceptionS tate& exceptionState)
467 { 467 {
468 if (!inActiveDocumentContext()) 468 if (!inActiveDocumentContext())
469 return false; 469 return false;
470 470
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 { 578 {
579 visitor->trace(m_loadingFonts); 579 visitor->trace(m_loadingFonts);
580 visitor->trace(m_loadedFonts); 580 visitor->trace(m_loadedFonts);
581 visitor->trace(m_failedFonts); 581 visitor->trace(m_failedFonts);
582 visitor->trace(m_nonCSSConnectedFaces); 582 visitor->trace(m_nonCSSConnectedFaces);
583 DocumentSupplement::trace(visitor); 583 DocumentSupplement::trace(visitor);
584 } 584 }
585 #endif 585 #endif
586 586
587 } // namespace WebCore 587 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/css/FontFace.idl ('k') | Source/core/css/MediaQueryListListener.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698