1 | /* |
2 | * Copyright (C) 2018 Apple Inc. All rights reserved. |
3 | * |
4 | * Redistribution and use in source and binary forms, with or without |
5 | * modification, are permitted provided that the following conditions |
6 | * are met: |
7 | * 1. Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. |
9 | * 2. Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. |
12 | * |
13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
14 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
15 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
17 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
18 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
19 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
20 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
21 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
22 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
23 | * THE POSSIBILITY OF SUCH DAMAGE. |
24 | */ |
25 | |
26 | #include "config.h" |
27 | #include "ProcessWarming.h" |
28 | |
29 | #include "CSSDefaultStyleSheets.h" |
30 | #include "CommonVM.h" |
31 | #include "Font.h" |
32 | #include "FontCache.h" |
33 | #include "FontCascadeDescription.h" |
34 | #include "HTMLNames.h" |
35 | #include "MathMLNames.h" |
36 | #include "MediaFeatureNames.h" |
37 | #include "QualifiedName.h" |
38 | #include "SVGNames.h" |
39 | #include "Settings.h" |
40 | #include "TelephoneNumberDetector.h" |
41 | #include "WebKitFontFamilyNames.h" |
42 | #include "XLinkNames.h" |
43 | #include "XMLNSNames.h" |
44 | #include "XMLNames.h" |
45 | |
46 | namespace WebCore { |
47 | |
48 | void ProcessWarming::initializeNames() |
49 | { |
50 | AtomicString::init(); |
51 | HTMLNames::init(); |
52 | QualifiedName::init(); |
53 | MediaFeatureNames::init(); |
54 | SVGNames::init(); |
55 | XLinkNames::init(); |
56 | MathMLNames::init(); |
57 | XMLNSNames::init(); |
58 | XMLNames::init(); |
59 | WebKitFontFamilyNames::init(); |
60 | } |
61 | |
62 | void ProcessWarming::prewarmGlobally() |
63 | { |
64 | initializeNames(); |
65 | |
66 | // Initializes default font families. |
67 | Settings::create(nullptr); |
68 | |
69 | // Prewarms user agent stylesheet. |
70 | CSSDefaultStyleSheets::loadFullDefaultStyle(); |
71 | |
72 | // Prewarms JS VM. |
73 | commonVM(); |
74 | |
75 | #if USE_PLATFORM_SYSTEM_FALLBACK_LIST |
76 | // Cache system UI font fallbacks. Almost every web process needs these. |
77 | // Initializing one size is sufficient to warm CoreText caches. |
78 | FontCascadeDescription systemFontDescription; |
79 | systemFontDescription.setOneFamily("system-ui" ); |
80 | systemFontDescription.setComputedSize(11); |
81 | systemFontDescription.effectiveFamilyCount(); |
82 | #endif |
83 | |
84 | #if ENABLE(TELEPHONE_NUMBER_DETECTION) |
85 | TelephoneNumberDetector::isSupported(); |
86 | #endif |
87 | } |
88 | |
89 | WebCore::PrewarmInformation ProcessWarming::collectPrewarmInformation() |
90 | { |
91 | return { FontCache::singleton().collectPrewarmInformation() }; |
92 | } |
93 | |
94 | void ProcessWarming::prewarmWithInformation(const PrewarmInformation& prewarmInfo) |
95 | { |
96 | FontCache::singleton().prewarm(prewarmInfo.fontCache); |
97 | } |
98 | |
99 | } |
100 | |