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 | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "core/events/EventFactory.h" | 51 #include "core/events/EventFactory.h" |
52 #include "core/fetch/FetchInitiatorTypeNames.h" | 52 #include "core/fetch/FetchInitiatorTypeNames.h" |
53 #include "core/html/canvas/CanvasRenderingContextFactory.h" | 53 #include "core/html/canvas/CanvasRenderingContextFactory.h" |
54 #include "core/html/parser/HTMLParserThread.h" | 54 #include "core/html/parser/HTMLParserThread.h" |
55 #include "core/workers/WorkerThread.h" | 55 #include "core/workers/WorkerThread.h" |
56 #include "platform/EventTracer.h" | 56 #include "platform/EventTracer.h" |
57 #include "platform/FontFamilyNames.h" | 57 #include "platform/FontFamilyNames.h" |
58 #include "platform/weborigin/KURL.h" | 58 #include "platform/weborigin/KURL.h" |
59 #include "platform/weborigin/SecurityPolicy.h" | 59 #include "platform/weborigin/SecurityPolicy.h" |
60 #include "wtf/Partitions.h" | 60 #include "wtf/Partitions.h" |
61 #include "wtf/text/StringStatics.h" | |
62 | 61 |
63 namespace blink { | 62 namespace blink { |
64 | 63 |
65 void CoreInitializer::registerEventFactory() | 64 void CoreInitializer::registerEventFactory() |
66 { | 65 { |
67 static bool isRegistered = false; | 66 static bool isRegistered = false; |
68 if (isRegistered) | 67 if (isRegistered) |
69 return; | 68 return; |
70 isRegistered = true; | 69 isRegistered = true; |
71 | 70 |
72 Document::registerEventFactory(EventFactory::create()); | 71 Document::registerEventFactory(EventFactory::create()); |
73 } | 72 } |
74 | 73 |
75 void CoreInitializer::init() | 74 void CoreInitializer::init() |
76 { | 75 { |
77 ASSERT(!m_isInited); | 76 ASSERT(!m_isInited); |
78 m_isInited = true; | 77 m_isInited = true; |
| 78 // Note: in order to add core static strings for a new module (1) |
| 79 // the value of 'coreStaticStringsCount' must be updated with the |
| 80 // added strings count, (2) if the added strings are quialified names |
| 81 // the 'qualifiedNamesCount' must be updated as well, (3) the strings |
| 82 // 'init()' function call must be added. |
| 83 // TODO(mikhail.pozdnyakov@intel.com): We should generate static strings ini
tialization code. |
| 84 const unsigned qualifiedNamesCount = HTMLNames::HTMLTagsCount + HTMLNames::H
TMLAttrsCount |
| 85 + MathMLNames::MathMLTagsCount + MathMLNames::MathMLAttrsCount |
| 86 + SVGNames::SVGTagsCount + SVGNames::SVGAttrsCount |
| 87 + XLinkNames::XLinkAttrsCount |
| 88 + XMLNSNames::XMLNSAttrsCount |
| 89 + XMLNames::XMLAttrsCount; |
| 90 |
| 91 const unsigned coreStaticStringsCount = qualifiedNamesCount |
| 92 + EventNames::EventNamesCount |
| 93 + EventTargetNames::EventTargetNamesCount |
| 94 + EventTypeNames::EventTypeNamesCount |
| 95 + FetchInitiatorTypeNames::FetchInitiatorTypeNamesCount |
| 96 + FontFamilyNames::FontFamilyNamesCount |
| 97 + HTMLTokenizerNames::HTMLTokenizerNamesCount |
| 98 + InputTypeNames::InputTypeNamesCount |
| 99 + MediaFeatureNames::MediaFeatureNamesCount |
| 100 + MediaTypeNames::MediaTypeNamesCount; |
| 101 |
| 102 StringImpl::reserveStaticStringsCapacityForSize(coreStaticStringsCount + Str
ingImpl::allStaticStrings().size()); |
| 103 QualifiedName::initAndReserveCapacityForSize(qualifiedNamesCount); |
79 | 104 |
80 HTMLNames::init(); | 105 HTMLNames::init(); |
81 SVGNames::init(); | 106 SVGNames::init(); |
82 XLinkNames::init(); | 107 XLinkNames::init(); |
83 MathMLNames::init(); | 108 MathMLNames::init(); |
84 XMLNSNames::init(); | 109 XMLNSNames::init(); |
85 XMLNames::init(); | 110 XMLNames::init(); |
86 | 111 |
87 EventNames::init(); | 112 EventNames::init(); |
88 EventTargetNames::init(); | 113 EventTargetNames::init(); |
89 EventTypeNames::init(); | 114 EventTypeNames::init(); |
90 FetchInitiatorTypeNames::init(); | 115 FetchInitiatorTypeNames::init(); |
91 FontFamilyNames::init(); | 116 FontFamilyNames::init(); |
92 HTMLTokenizerNames::init(); | 117 HTMLTokenizerNames::init(); |
93 InputTypeNames::init(); | 118 InputTypeNames::init(); |
94 MediaFeatureNames::init(); | 119 MediaFeatureNames::init(); |
95 MediaTypeNames::init(); | 120 MediaTypeNames::init(); |
96 | 121 |
97 CSSPrimitiveValue::initUnitTable(); | 122 CSSPrimitiveValue::initUnitTable(); |
98 CSSParserTokenRange::initStaticEOFToken(); | 123 CSSParserTokenRange::initStaticEOFToken(); |
99 | 124 |
100 // It would make logical sense to do this in WTF::initialize() but there are | |
101 // ordering dependencies, e.g. about "xmlns". | |
102 WTF::StringStatics::init(); | |
103 | |
104 StyleChangeExtraData::init(); | 125 StyleChangeExtraData::init(); |
105 | 126 |
106 QualifiedName::init(); | |
107 EventTracer::initialize(); | 127 EventTracer::initialize(); |
108 KURL::initialize(); | 128 KURL::initialize(); |
109 SecurityPolicy::init(); | 129 SecurityPolicy::init(); |
110 | 130 |
111 registerEventFactory(); | 131 registerEventFactory(); |
112 | 132 |
113 StringImpl::freezeStaticStrings(); | 133 StringImpl::freezeStaticStrings(); |
114 | 134 |
115 // Creates HTMLParserThread::shared and ScriptStreamerThread::shared, but | 135 // Creates HTMLParserThread::shared and ScriptStreamerThread::shared, but |
116 // does not start the threads. | 136 // does not start the threads. |
117 HTMLParserThread::init(); | 137 HTMLParserThread::init(); |
118 ScriptStreamerThread::init(); | 138 ScriptStreamerThread::init(); |
119 } | 139 } |
120 | 140 |
121 void CoreInitializer::shutdown() | 141 void CoreInitializer::shutdown() |
122 { | 142 { |
123 // Make sure we stop the HTMLParserThread before Platform::current() is | 143 // Make sure we stop the HTMLParserThread before Platform::current() is |
124 // cleared. | 144 // cleared. |
125 HTMLParserThread::shutdown(); | 145 HTMLParserThread::shutdown(); |
126 } | 146 } |
127 | 147 |
128 } // namespace blink | 148 } // namespace blink |
OLD | NEW |