Bug 575855 - Fix for transitions from fullscreen briefly show an aero basic window...
[mozilla-central.git] / parser / html / nsHtml5NamedCharacters.cpp
blobe8eb6bad8b7484cdef32e754ad99af1a786bbc9f
1 #define nsHtml5NamedCharacters_cpp_
2 #include "prtypes.h"
3 #include "jArray.h"
4 #include "nscore.h"
5 #include "nsDebug.h"
6 #include "prlog.h"
7 #include "nsMemory.h"
9 #include "nsHtml5NamedCharacters.h"
11 jArray<jArray<PRInt8,PRInt32>,PRInt32> nsHtml5NamedCharacters::NAMES;
13 const PRUnichar nsHtml5NamedCharacters::VALUES[][2] = {
14 #define NAMED_CHARACTER_REFERENCE(N, CHARS, LEN, FLAG, VALUE) \
15 { VALUE },
16 #include "nsHtml5NamedCharactersInclude.h"
17 #undef NAMED_CHARACTER_REFERENCE
18 {0, 0} };
20 PRUnichar** nsHtml5NamedCharacters::WINDOWS_1252;
21 static PRUnichar const WINDOWS_1252_DATA[] = {
22 0x20AC,
23 0x0081,
24 0x201A,
25 0x0192,
26 0x201E,
27 0x2026,
28 0x2020,
29 0x2021,
30 0x02C6,
31 0x2030,
32 0x0160,
33 0x2039,
34 0x0152,
35 0x008D,
36 0x017D,
37 0x008F,
38 0x0090,
39 0x2018,
40 0x2019,
41 0x201C,
42 0x201D,
43 0x2022,
44 0x2013,
45 0x2014,
46 0x02DC,
47 0x2122,
48 0x0161,
49 0x203A,
50 0x0153,
51 0x009D,
52 0x017E,
53 0x0178
56 /**
57 * To avoid having lots of pointers in the |charData| array, below,
58 * which would cause us to have to do lots of relocations at library
59 * load time, store all the string data for the names in one big array.
60 * Then use tricks with enums to help us build an array that contains
61 * the positions of each within the big arrays.
64 static const PRInt8 ALL_NAMES[] = {
65 #define NAMED_CHARACTER_REFERENCE(N, CHARS, LEN, FLAG, VALUE) \
66 CHARS ,
67 #include "nsHtml5NamedCharactersInclude.h"
68 #undef NAMED_CHARACTER_REFERENCE
71 enum NamePositions {
72 DUMMY_INITIAL_NAME_POSITION = 0,
73 /* enums don't take up space, so generate _START and _END */
74 #define NAMED_CHARACTER_REFERENCE(N, CHARS, LEN, FLAG, VALUE) \
75 NAME_##N##_DUMMY, /* automatically one higher than previous */ \
76 NAME_##N##_START = NAME_##N##_DUMMY - 1, \
77 NAME_##N##_END = NAME_##N##_START + LEN + FLAG,
78 #include "nsHtml5NamedCharactersInclude.h"
79 #undef NAMED_CHARACTER_REFERENCE
80 DUMMY_FINAL_NAME_VALUE
83 #define NAMED_CHARACTERS_COUNT 2138
85 /* check that the start positions will fit in 16 bits */
86 PR_STATIC_ASSERT(NS_ARRAY_LENGTH(ALL_NAMES) < 0x10000);
88 struct NamedCharacterData {
89 PRUint16 nameStart;
90 PRUint16 nameLen;
91 #ifdef DEBUG
92 PRInt32 n;
93 #endif
96 static const NamedCharacterData charData[NAMED_CHARACTERS_COUNT] = {
97 #ifdef DEBUG
98 #define NAMED_CHARACTER_REFERENCE(N, CHARS, LEN, FLAG, VALUE) \
99 { NAME_##N##_START, LEN, N },
100 #else
101 #define NAMED_CHARACTER_REFERENCE(N, CHARS, LEN, FLAG, VALUE) \
102 { NAME_##N##_START, LEN, },
103 #endif
104 #include "nsHtml5NamedCharactersInclude.h"
105 #undef NAMED_CHARACTER_REFERENCE
108 void
109 nsHtml5NamedCharacters::initializeStatics()
111 NAMES = jArray<jArray<PRInt8,PRInt32>,PRInt32>(NAMED_CHARACTERS_COUNT);
112 PRInt8* allNames = const_cast<PRInt8*>(ALL_NAMES);
113 for (PRInt32 i = 0; i < NAMED_CHARACTERS_COUNT; ++i) {
114 const NamedCharacterData &data = charData[i];
115 NS_ABORT_IF_FALSE(data.n == i,
116 "index error in nsHtml5NamedCharactersInclude.h");
117 NAMES[i] = jArray<PRInt8,PRInt32>(allNames + data.nameStart, data.nameLen);
120 WINDOWS_1252 = new PRUnichar*[32];
121 for (PRInt32 i = 0; i < 32; ++i) {
122 WINDOWS_1252[i] = (PRUnichar*)&(WINDOWS_1252_DATA[i]);
126 void
127 nsHtml5NamedCharacters::releaseStatics()
129 NAMES.release();
130 delete[] WINDOWS_1252;