OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" | 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" |
8 | 8 |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
25 const double kFinancialPrecision = 0.00000001; | 25 const double kFinancialPrecision = 0.00000001; |
26 | 26 |
27 struct XFA_FMHtmlReserveCode { | 27 struct XFA_FMHtmlReserveCode { |
28 uint32_t m_uCode; | 28 uint32_t m_uCode; |
29 const FX_WCHAR* m_htmlReserve; | 29 const FX_WCHAR* m_htmlReserve; |
30 }; | 30 }; |
31 | 31 |
32 struct XFA_FMHtmlHashedReserveCode { | 32 struct XFA_FMHtmlHashedReserveCode { |
33 uint32_t m_uHash; | 33 uint32_t m_uHash; |
34 const FX_WCHAR* m_htmlReserve; | |
35 uint32_t m_uCode; | 34 uint32_t m_uCode; |
36 }; | 35 }; |
37 | 36 |
38 const XFA_FMHtmlHashedReserveCode reservesForDecode[] = { | 37 const XFA_FMHtmlHashedReserveCode reservesForDecode[] = { |
39 {0x00018b62, L"Mu", 924}, {0x00019083, L"Nu", 925}, | 38 {0x00018b62, /*L"Mu",*/ 924}, {0x00019083, /*L"Nu",*/ 925}, |
40 {0x00019ab9, L"Pi", 928}, {0x0001c3c1, L"Xi", 926}, | 39 {0x00019ab9, /*L"Pi",*/ 928}, {0x0001c3c1, /*L"Xi",*/ 926}, |
41 {0x000210ac, L"ge", 8805}, {0x000210bb, L"gt", 62}, | 40 {0x000210ac, /*L"ge",*/ 8805}, {0x000210bb, /*L"gt",*/ 62}, |
42 {0x00022a51, L"le", 8804}, {0x00022a60, L"lt", 60}, | 41 {0x00022a51, /*L"le",*/ 8804}, {0x00022a60, /*L"lt",*/ 60}, |
43 {0x00022f82, L"mu", 956}, {0x00023493, L"ne", 8800}, | 42 {0x00022f82, /*L"mu",*/ 956}, {0x00023493, /*L"ne",*/ 8800}, |
44 {0x00023497, L"ni", 8715}, {0x000234a3, L"nu", 957}, | 43 {0x00023497, /*L"ni",*/ 8715}, {0x000234a3, /*L"nu",*/ 957}, |
45 {0x000239c1, L"or", 8744}, {0x00023ed9, L"pi", 960}, | 44 {0x000239c1, /*L"or",*/ 8744}, {0x00023ed9, /*L"pi",*/ 960}, |
46 {0x000267e1, L"xi", 958}, {0x00c41789, L"lceil", 8968}, | 45 {0x000267e1, /*L"xi",*/ 958}, {0x00c41789, /*L"lceil",*/ 8968}, |
47 {0x00eef34f, L"thetasym", 977}, {0x012d7ead, L"lcirc", 206}, | 46 {0x00eef34f, /*L"thetasym",*/ 977}, {0x012d7ead, /*L"lcirc",*/ 206}, |
48 {0x01637b56, L"agrave", 224}, {0x020856da, L"crarr", 8629}, | 47 {0x01637b56, /*L"agrave",*/ 224}, {0x020856da, /*L"crarr",*/ 8629}, |
49 {0x022188c3, L"gamma", 947}, {0x033586d3, L"nbsp", 160}, | 48 {0x022188c3, /*L"gamma",*/ 947}, {0x033586d3, /*L"nbsp",*/ 160}, |
50 {0x04f4c358, L"nsub", 8836}, {0x0581466a, L"dagger", 8224}, | 49 {0x04f4c358, /*L"nsub",*/ 8836}, {0x0581466a, /*L"dagger",*/ 8224}, |
51 {0x06b1f790, L"oelig", 339}, {0x06e490d4, L"Chi", 935}, | 50 {0x06b1f790, /*L"oelig",*/ 339}, {0x06e490d4, /*L"Chi",*/ 935}, |
52 {0x0718c6a1, L"ETH", 208}, {0x07196ada, L"Eta", 919}, | 51 {0x0718c6a1, /*L"ETH",*/ 208}, {0x07196ada, /*L"Eta",*/ 919}, |
53 {0x07f667ca, L"Ugrave", 217}, {0x083a8a21, L"Phi", 934}, | 52 {0x07f667ca, /*L"Ugrave",*/ 217}, {0x083a8a21, /*L"Phi",*/ 934}, |
54 {0x083ac28c, L"Psi", 936}, {0x086f26a9, L"Rho", 929}, | 53 {0x083ac28c, /*L"Psi",*/ 936}, {0x086f26a9, /*L"Rho",*/ 929}, |
55 {0x089b5b51, L"aring", 229}, {0x08a39f4a, L"Tau", 932}, | 54 {0x089b5b51, /*L"aring",*/ 229}, {0x08a39f4a, /*L"Tau",*/ 932}, |
56 {0x08b6188b, L"THORN", 222}, {0x09ce792a, L"icirc", 238}, | 55 {0x08b6188b, /*L"THORN",*/ 222}, {0x09ce792a, /*L"icirc",*/ 238}, |
57 {0x09f9d61e, L"amp", 38}, {0x09f9db33, L"and", 8743}, | 56 {0x09f9d61e, /*L"amp",*/ 38}, {0x09f9db33, /*L"and",*/ 8743}, |
58 {0x09f9db36, L"ang", 8736}, {0x0a2e3514, L"cap", 8745}, | 57 {0x09f9db36, /*L"ang",*/ 8736}, {0x0a2e3514, /*L"cap",*/ 8745}, |
59 {0x0a2e58f4, L"chi", 967}, {0x0a2e9ba8, L"cup", 8746}, | 58 {0x0a2e58f4, /*L"chi",*/ 967}, {0x0a2e9ba8, /*L"cup",*/ 8746}, |
60 {0x0a4897d0, L"deg", 176}, {0x0a6332fa, L"eta", 951}, | 59 {0x0a4897d0, /*L"deg",*/ 176}, {0x0a6332fa, /*L"eta",*/ 951}, |
61 {0x0a633301, L"eth", 240}, {0x0acc4d4b, L"int", 8747}, | 60 {0x0a633301, /*L"eth",*/ 240}, {0x0acc4d4b, /*L"int",*/ 8747}, |
62 {0x0b1b3d35, L"loz", 9674}, {0x0b1b4c8b, L"lrm", 8206}, | 61 {0x0b1b3d35, /*L"loz",*/ 9674}, {0x0b1b4c8b, /*L"lrm",*/ 8206}, |
63 {0x0b4fd9b1, L"not", 172}, {0x0b845241, L"phi", 966}, | 62 {0x0b4fd9b1, /*L"not",*/ 172}, {0x0b845241, /*L"phi",*/ 966}, |
64 {0x0b84576f, L"piv", 982}, {0x0b848aac, L"psi", 968}, | 63 {0x0b84576f, /*L"piv",*/ 982}, {0x0b848aac, /*L"psi",*/ 968}, |
65 {0x0bb8df5e, L"reg", 174}, {0x0bb8eec9, L"rho", 961}, | 64 {0x0bb8df5e, /*L"reg",*/ 174}, {0x0bb8eec9, /*L"rho",*/ 961}, |
66 {0x0bb9034b, L"rlm", 8207}, {0x0bd33d14, L"shy", 173}, | 65 {0x0bb9034b, /*L"rlm",*/ 8207}, {0x0bd33d14, /*L"shy",*/ 173}, |
67 {0x0bd34229, L"sim", 8764}, {0x0bd37faa, L"sub", 8834}, | 66 {0x0bd34229, /*L"sim",*/ 8764}, {0x0bd37faa, /*L"sub",*/ 8834}, |
68 {0x0bd37fb5, L"sum", 8721}, {0x0bd37fb8, L"sup", 8835}, | 67 {0x0bd37fb5, /*L"sum",*/ 8721}, {0x0bd37fb8, /*L"sup",*/ 8835}, |
69 {0x0bed676a, L"tau", 964}, {0x0c07f32e, L"uml", 168}, | 68 {0x0bed676a, /*L"tau",*/ 964}, {0x0c07f32e, /*L"uml",*/ 168}, |
70 {0x0c71032c, L"yen", 165}, {0x0c7f2889, L"szlig", 223}, | 69 {0x0c71032c, /*L"yen",*/ 165}, {0x0c7f2889, /*L"szlig",*/ 223}, |
71 {0x0c8badbb, L"zwj", 8205}, {0x10ba4dba, L"Egrave", 200}, | 70 {0x0c8badbb, /*L"zwj",*/ 8205}, {0x10ba4dba, /*L"Egrave",*/ 200}, |
72 {0x10f1ea24, L"para", 182}, {0x10f1ea37, L"part", 8706}, | 71 {0x10f1ea24, /*L"para",*/ 182}, {0x10f1ea37, /*L"part",*/ 8706}, |
73 {0x115b2337, L"perp", 8869}, {0x12b10d15, L"prod", 8719}, | 72 {0x115b2337, /*L"perp",*/ 8869}, {0x12b10d15, /*L"prod",*/ 8719}, |
74 {0x12b10d21, L"prop", 8733}, {0x12dfa9f4, L"rfloor", 8971}, | 73 {0x12b10d21, /*L"prop",*/ 8733}, {0x12dfa9f4, /*L"rfloor",*/ 8971}, |
75 {0x12eb4736, L"Agrave", 192}, {0x12fff2b7, L"pund", 163}, | 74 {0x12eb4736, /*L"Agrave",*/ 192}, {0x12fff2b7, /*L"pund",*/ 163}, |
76 {0x13fda9f2, L"tilde", 732}, {0x1417fd62, L"times", 215}, | 75 {0x13fda9f2, /*L"tilde",*/ 732}, {0x1417fd62, /*L"times",*/ 215}, |
77 {0x154fc726, L"ecirc", 234}, {0x165aa451, L"sigma", 963}, | 76 {0x154fc726, /*L"ecirc",*/ 234}, {0x165aa451, /*L"sigma",*/ 963}, |
78 {0x1709124a, L"Dagger", 8225}, {0x192f78d5, L"iexcl", 161}, | 77 {0x1709124a, /*L"Dagger",*/ 8225}, {0x192f78d5, /*L"iexcl",*/ 161}, |
79 {0x1b7ed8d7, L"rArr", 8658}, {0x1ec88c68, L"rang", 9002}, | 78 {0x1b7ed8d7, /*L"rArr",*/ 8658}, {0x1ec88c68, /*L"rang",*/ 9002}, |
80 {0x1ec8a0f7, L"rarr", 8594}, {0x1eda07f3, L"atilde", 227}, | 79 {0x1ec8a0f7, /*L"rarr",*/ 8594}, {0x1eda07f3, /*L"atilde",*/ 227}, |
81 {0x1f3182c4, L"real", 8476}, {0x1fc34f8b, L"yacute", 253}, | 80 {0x1f3182c4, /*L"real",*/ 8476}, {0x1fc34f8b, /*L"yacute",*/ 253}, |
82 {0x20d11522, L"acirc", 226}, {0x21933a9b, L"rsaquo", 8250}, | 81 {0x20d11522, /*L"acirc",*/ 226}, {0x21933a9b, /*L"rsaquo",*/ 8250}, |
83 {0x21f44907, L"uacute", 250}, {0x220cca72, L"acute", 180}, | 82 {0x21f44907, /*L"uacute",*/ 250}, {0x220cca72, /*L"acute",*/ 180}, |
84 {0x242cded1, L"alefsym", 8501}, {0x2655c66a, L"delta", 948}, | 83 {0x242cded1, /*L"alefsym",*/ 8501}, {0x2655c66a, /*L"delta",*/ 948}, |
85 {0x269e4b4d, L"exist", 8707}, {0x273379fa, L"micro", 181}, | 84 {0x269e4b4d, /*L"exist",*/ 8707}, {0x273379fa, /*L"micro",*/ 181}, |
86 {0x27a37440, L"forall", 8704}, {0x2854e62c, L"minus", 8722}, | 85 {0x27a37440, /*L"forall",*/ 8704}, {0x2854e62c, /*L"minus",*/ 8722}, |
87 {0x28636f81, L"cedil", 184}, {0x2887357b, L"iacute", 237}, | 86 {0x28636f81, /*L"cedil",*/ 184}, {0x2887357b, /*L"iacute",*/ 237}, |
88 {0x2994d5ff, L"frac12", 189}, {0x2994d601, L"frac14", 188}, | 87 {0x2994d5ff, /*L"frac12",*/ 189}, {0x2994d601, /*L"frac14",*/ 188}, |
89 {0x2994e043, L"frac34", 190}, {0x2a1feb41, L"lambda", 955}, | 88 {0x2994e043, /*L"frac34",*/ 190}, {0x2a1feb41, /*L"lambda",*/ 955}, |
90 {0x2ab215f3, L"apos", 39}, {0x2ab82ef7, L"eacute", 233}, | 89 {0x2ab215f3, /*L"apos",*/ 39}, {0x2ab82ef7, /*L"eacute",*/ 233}, |
91 {0x2b3592ef, L"auml", 228}, {0x2ce92873, L"aacute", 225}, | 90 {0x2b3592ef, /*L"auml",*/ 228}, {0x2ce92873, /*L"aacute",*/ 225}, |
92 {0x2daff48a, L"oslash", 248}, {0x2ef68882, L"aelig", 230}, | 91 {0x2daff48a, /*L"oslash",*/ 248}, {0x2ef68882, /*L"aelig",*/ 230}, |
93 {0x3061d3d3, L"Atilde", 195}, {0x314b1b6b, L"Yacute", 221}, | 92 {0x3061d3d3, /*L"Atilde",*/ 195}, {0x314b1b6b, /*L"Yacute",*/ 221}, |
94 {0x337c14e7, L"Uacute", 218}, {0x37676aca, L"cent", 162}, | 93 {0x337c14e7, /*L"Uacute",*/ 218}, {0x37676aca, /*L"cent",*/ 162}, |
95 {0x37d0b841, L"circ", 710}, {0x386e7947, L"cong", 8773}, | 94 {0x37d0b841, /*L"circ",*/ 710}, {0x386e7947, /*L"cong",*/ 8773}, |
96 {0x386e839b, L"copy", 169}, {0x3a0e225a, L"Epsilon", 917}, | 95 {0x386e839b, /*L"copy",*/ 169}, {0x3a0e225a, /*L"Epsilon",*/ 917}, |
97 {0x3ba7b721, L"Lambda", 923}, {0x3bd9abe6, L"Alpha", 913}, | 96 {0x3ba7b721, /*L"Lambda",*/ 923}, {0x3bd9abe6, /*L"Alpha",*/ 913}, |
98 {0x3c3ffad7, L"Eacute", 201}, {0x3cfaf69f, L"brvbar", 166}, | 97 {0x3c3ffad7, /*L"Eacute",*/ 201}, {0x3cfaf69f, /*L"brvbar",*/ 166}, |
99 {0x3d54a489, L"omega", 969}, {0x3e70f453, L"Aacute", 193}, | 98 {0x3d54a489, /*L"omega",*/ 969}, {0x3e70f453, /*L"Aacute",*/ 193}, |
100 {0x3f37c06a, L"Oslash", 216}, {0x40e1b34e, L"diams", 9830}, | 99 {0x3f37c06a, /*L"Oslash",*/ 216}, {0x40e1b34e, /*L"diams",*/ 9830}, |
101 {0x416596df, L"plusmn", 177}, {0x4354ff16, L"Ucirc", 219}, | 100 {0x416596df, /*L"plusmn",*/ 177}, {0x4354ff16, /*L"Ucirc",*/ 219}, |
102 {0x454fce6a, L"Upsilon", 933}, {0x4610ad35, L"emsp", 8195}, | 101 {0x454fce6a, /*L"Upsilon",*/ 933}, {0x4610ad35, /*L"emsp",*/ 8195}, |
103 {0x462afb76, L"ensp", 8194}, {0x46e30073, L"euml", 235}, | 102 {0x462afb76, /*L"ensp",*/ 8194}, {0x46e30073, /*L"euml",*/ 235}, |
104 {0x46e31a1b, L"euro", 8364}, {0x46f2eada, L"lowast", 8727}, | 103 {0x46e31a1b, /*L"euro",*/ 8364}, {0x46f2eada, /*L"lowast",*/ 8727}, |
105 {0x4dca26cf, L"Auml", 196}, {0x4e2d6083, L"image", 8465}, | 104 {0x4dca26cf, /*L"Auml",*/ 196}, {0x4e2d6083, /*L"image",*/ 8465}, |
106 {0x4f964ee8, L"notin", 8713}, {0x50917a7a, L"epsilon", 949}, | 105 {0x4f964ee8, /*L"notin",*/ 8713}, {0x50917a7a, /*L"epsilon",*/ 949}, |
107 {0x52f9a4cd, L"Kappa", 922}, {0x5496f410, L"Ocirc", 212}, | 106 {0x52f9a4cd, /*L"Kappa",*/ 922}, {0x5496f410, /*L"Ocirc",*/ 212}, |
108 {0x568cbf34, L"zeta", 950}, {0x57badd20, L"ntilde", 241}, | 107 {0x568cbf34, /*L"zeta",*/ 950}, {0x57badd20, /*L"ntilde",*/ 241}, |
109 {0x58662109, L"zwnj", 8204}, {0x5b39870f, L"empty", 8709}, | 108 {0x58662109, /*L"zwnj",*/ 8204}, {0x5b39870f, /*L"empty",*/ 8709}, |
110 {0x5bd3268a, L"upsilon", 965}, {0x5e2bf8a3, L"Gamma", 915}, | 109 {0x5bd3268a, /*L"upsilon",*/ 965}, {0x5e2bf8a3, /*L"Gamma",*/ 915}, |
111 {0x5f73c13a, L"rsquo", 8217}, {0x61f2bc4d, L"iota", 953}, | 110 {0x5f73c13a, /*L"rsquo",*/ 8217}, {0x61f2bc4d, /*L"iota",*/ 953}, |
112 {0x625bbcf3, L"isin", 8712}, {0x62906df7, L"iuml", 239}, | 111 {0x625bbcf3, /*L"isin",*/ 8712}, {0x62906df7, /*L"iuml",*/ 239}, |
113 {0x64a5cb31, L"Aring", 197}, {0x66f25c4a, L"sbquo", 8218}, | 112 {0x64a5cb31, /*L"Aring",*/ 197}, {0x66f25c4a, /*L"sbquo",*/ 8218}, |
114 {0x6851ab60, L"spades", 9824}, {0x6942a900, L"Ntilde", 209}, | 113 {0x6851ab60, /*L"spades",*/ 9824}, {0x6942a900, /*L"Ntilde",*/ 209}, |
115 {0x69779453, L"Euml", 203}, {0x6cda6e23, L"current", 164}, | 114 {0x69779453, /*L"Euml",*/ 203}, {0x6cda6e23, /*L"current",*/ 164}, |
116 {0x70b5b634, L"lsquo", 8216}, {0x715a3706, L"Ecirc", 202}, | 115 {0x70b5b634, /*L"lsquo",*/ 8216}, {0x715a3706, /*L"Ecirc",*/ 202}, |
117 {0x71e8bf8d, L"tdquo", 8221}, {0x72651431, L"Sigma", 931}, | 116 {0x71e8bf8d, /*L"tdquo",*/ 8221}, {0x72651431, /*L"Sigma",*/ 931}, |
118 {0x7569813b, L"iquest", 191}, {0x776a436a, L"equiv", 8801}, | 117 {0x7569813b, /*L"iquest",*/ 191}, {0x776a436a, /*L"equiv",*/ 8801}, |
119 {0x79215314, L"Zeta", 918}, {0x79b81224, L"ograve", 242}, | 118 {0x79215314, /*L"Zeta",*/ 918}, {0x79b81224, /*L"ograve",*/ 242}, |
120 {0x7c2f8b23, L"macr", 175}, {0x7cdb8502, L"Acirc", 194}, | 119 {0x7c2f8b23, /*L"macr",*/ 175}, {0x7cdb8502, /*L"Acirc",*/ 194}, |
121 {0x8185c62e, L"ndash", 8211}, {0x8260364a, L"Delta", 916}, | 120 {0x8185c62e, /*L"ndash",*/ 8211}, {0x8260364a, /*L"Delta",*/ 916}, |
122 {0x846619ad, L"mdash", 8212}, {0x8550fb50, L"OElig", 338}, | 121 {0x846619ad, /*L"mdash",*/ 8212}, {0x8550fb50, /*L"OElig",*/ 338}, |
123 {0x88eb5b85, L"ldquo", 8220}, {0x8b3fde04, L"Ograve", 210}, | 122 {0x88eb5b85, /*L"ldquo",*/ 8220}, {0x8b3fde04, /*L"Ograve",*/ 210}, |
124 {0x8bc5794b, L"ordf", 170}, {0x8bc57952, L"ordm", 186}, | 123 {0x8bc5794b, /*L"ordf",*/ 170}, {0x8bc57952, /*L"ordm",*/ 186}, |
125 {0x8c14923d, L"ouml", 246}, {0x8c5a7cd6, L"theta", 952}, | 124 {0x8c14923d, /*L"ouml",*/ 246}, {0x8c5a7cd6, /*L"theta",*/ 952}, |
126 {0x8d61812b, L"thorn", 254}, {0x912b95aa, L"asymp", 8776}, | 125 {0x8d61812b, /*L"thorn",*/ 254}, {0x912b95aa, /*L"asymp",*/ 8776}, |
127 {0x947faf81, L"middot", 183}, {0x9629202e, L"lfloor", 8970}, | 126 {0x947faf81, /*L"middot",*/ 183}, {0x9629202e, /*L"lfloor",*/ 8970}, |
128 {0x972e9ec1, L"otilde", 245}, {0x9748f231, L"otimes", 8855}, | 127 {0x972e9ec1, /*L"otilde",*/ 245}, {0x9748f231, /*L"otimes",*/ 8855}, |
129 {0x995f1469, L"Omega", 937}, {0x99eb5349, L"quot", 34}, | 128 {0x995f1469, /*L"Omega",*/ 937}, {0x99eb5349, /*L"quot",*/ 34}, |
130 {0x9aeb639e, L"hellip", 8230}, {0xa0ae2f86, L"Scaron", 352}, | 129 {0x9aeb639e, /*L"hellip",*/ 8230}, {0xa0ae2f86, /*L"Scaron",*/ 352}, |
131 {0xa4dcb0d5, L"lsaquo", 8249}, {0xa53dbf41, L"oacute", 243}, | 130 {0xa4dcb0d5, /*L"lsaquo",*/ 8249}, {0xa53dbf41, /*L"oacute",*/ 243}, |
132 {0xa5ae9e7b, L"bdquo", 8222}, {0xa602d7ba, L"sdot", 8901}, | 131 {0xa5ae9e7b, /*L"bdquo",*/ 8222}, {0xa602d7ba, /*L"sdot",*/ 8901}, |
133 {0xa61ce86f, L"sect", 167}, {0xa6e4c3d7, L"sigmaf", 962}, | 132 {0xa61ce86f, /*L"sect",*/ 167}, {0xa6e4c3d7, /*L"sigmaf",*/ 962}, |
134 {0xa7c1c74f, L"sube", 8838}, {0xa7c20ee9, L"sup1", 185}, | 133 {0xa7c1c74f, /*L"sube",*/ 8838}, {0xa7c20ee9, /*L"sup1",*/ 185}, |
135 {0xa7c20eea, L"sup2", 178}, {0xa7c20eeb, L"sup3", 179}, | 134 {0xa7c20eea, /*L"sup2",*/ 178}, {0xa7c20eeb, /*L"sup3",*/ 179}, |
136 {0xa7c20f1d, L"supe", 8839}, {0xa8b66aa1, L"Otilde", 213}, | 135 {0xa7c20f1d, /*L"supe",*/ 8839}, {0xa8b66aa1, /*L"Otilde",*/ 213}, |
137 {0xad958c42, L"AElig", 198}, {0xaea9261d, L"Ouml", 214}, | 136 {0xad958c42, /*L"AElig",*/ 198}, {0xaea9261d, /*L"Ouml",*/ 214}, |
138 {0xb040eafa, L"uArr", 8657}, {0xb07c2e1c, L"beta", 946}, | 137 {0xb040eafa, /*L"uArr",*/ 8657}, {0xb07c2e1c, /*L"beta",*/ 946}, |
139 {0xb220e92f, L"bull", 8226}, {0xb22750c4, L"ccedil", 231}, | 138 {0xb220e92f, /*L"bull",*/ 8226}, {0xb22750c4, /*L"ccedil",*/ 231}, |
140 {0xb38ab31a, L"uarr", 8593}, {0xb598b683, L"uuml", 252}, | 139 {0xb38ab31a, /*L"uarr",*/ 8593}, {0xb598b683, /*L"uuml",*/ 252}, |
141 {0xb6c58b21, L"Oacute", 211}, {0xb6d2a617, L"oline", 8254}, | 140 {0xb6c58b21, /*L"Oacute",*/ 211}, {0xb6d2a617, /*L"oline",*/ 8254}, |
142 {0xba9fd989, L"dArr", 8659}, {0xbb5ccd41, L"lgrave", 204}, | 141 {0xba9fd989, /*L"dArr",*/ 8659}, {0xbb5ccd41, /*L"lgrave",*/ 204}, |
143 {0xbd39b44c, L"weierp", 8472}, {0xbde9a1a9, L"darr", 8595}, | 142 {0xbd39b44c, /*L"weierp",*/ 8472}, {0xbde9a1a9, /*L"darr",*/ 8595}, |
144 {0xc027e329, L"permil", 8240}, {0xc2451389, L"upsih", 978}, | 143 {0xc027e329, /*L"permil",*/ 8240}, {0xc2451389, /*L"upsih",*/ 978}, |
145 {0xc3af1ca4, L"Ccedil", 199}, {0xcd164249, L"fnof", 402}, | 144 {0xc3af1ca4, /*L"Ccedil",*/ 199}, {0xcd164249, /*L"fnof",*/ 402}, |
146 {0xcf6c8467, L"hearts", 9829}, {0xd1228390, L"trade", 8482}, | 145 {0xcf6c8467, /*L"hearts",*/ 9829}, {0xd1228390, /*L"trade",*/ 8482}, |
147 {0xd1462407, L"yuml", 255}, {0xd2cf2253, L"oplus", 8853}, | 146 {0xd1462407, /*L"yuml",*/ 255}, {0xd2cf2253, /*L"oplus",*/ 8853}, |
148 {0xd310c1fc, L"Beta", 914}, {0xd59c4d74, L"infin", 8734}, | 147 {0xd310c1fc, /*L"Beta",*/ 914}, {0xd59c4d74, /*L"infin",*/ 8734}, |
149 {0xd64d470d, L"hArr", 8660}, {0xd67d9c75, L"divide", 247}, | 148 {0xd64d470d, /*L"hArr",*/ 8660}, {0xd67d9c75, /*L"divide",*/ 247}, |
150 {0xd698dd37, L"Omicron", 927}, {0xd82d4a63, L"Uuml", 220}, | 149 {0xd698dd37, /*L"Omicron",*/ 927}, {0xd82d4a63, /*L"Uuml",*/ 220}, |
151 {0xd9970f2d, L"harr", 8596}, {0xda91fd99, L"clubs", 9827}, | 150 {0xd9970f2d, /*L"harr",*/ 8596}, {0xda91fd99, /*L"clubs",*/ 9827}, |
152 {0xdbe5bdcc, L"there4", 8756}, {0xdd7671bd, L"prime", 8242}, | 151 {0xdbe5bdcc, /*L"there4",*/ 8756}, {0xdd7671bd, /*L"prime",*/ 8242}, |
153 {0xdfcf3c06, L"alpha", 945}, {0xe0213063, L"saron", 353}, | 152 {0xdfcf3c06, /*L"alpha",*/ 945}, {0xe0213063, /*L"saron",*/ 353}, |
154 {0xe1911d83, L"radic", 8730}, {0xe2e75468, L"raquo", 187}, | 153 {0xe1911d83, /*L"radic",*/ 8730}, {0xe2e75468, /*L"raquo",*/ 187}, |
155 {0xe6e27a5e, L"lacute", 205}, {0xe74a8f36, L"ucirc", 251}, | 154 {0xe6e27a5e, /*L"lacute",*/ 205}, {0xe74a8f36, /*L"ucirc",*/ 251}, |
156 {0xe864ecb6, L"Theta", 920}, {0xecddde5e, L"nabla", 8711}, | 155 {0xe864ecb6, /*L"Theta",*/ 920}, {0xecddde5e, /*L"nabla",*/ 8711}, |
157 {0xed1c3557, L"omicron", 959}, {0xef82228f, L"rceil", 8969}, | 156 {0xed1c3557, /*L"omicron",*/ 959}, {0xef82228f, /*L"rceil",*/ 8969}, |
158 {0xf1fab491, L"lArr", 8656}, {0xf3dab7e7, L"Yuml", 376}, | 157 {0xf1fab491, /*L"lArr",*/ 8656}, {0xf3dab7e7, /*L"Yuml",*/ 376}, |
159 {0xf4294962, L"laquo", 171}, {0xf5446822, L"lang", 9001}, | 158 {0xf4294962, /*L"laquo",*/ 171}, {0xf5446822, /*L"lang",*/ 9001}, |
160 {0xf5447cb1, L"larr", 8592}, {0xf66e9bea, L"ugrave", 249}, | 159 {0xf5447cb1, /*L"larr",*/ 8592}, {0xf66e9bea, /*L"ugrave",*/ 249}, |
161 {0xf6b4ce70, L"lota", 921}, {0xf6ef34ed, L"kappa", 954}, | 160 {0xf6b4ce70, /*L"lota",*/ 921}, {0xf6ef34ed, /*L"kappa",*/ 954}, |
162 {0xf72a3a56, L"thinsp", 8201}, {0xf752801a, L"luml", 207}, | 161 {0xf72a3a56, /*L"thinsp",*/ 8201}, {0xf752801a, /*L"luml",*/ 207}, |
163 {0xf88c8430, L"ocirc", 244}, {0xf9676178, L"frasl", 8260}, | 162 {0xf88c8430, /*L"ocirc",*/ 244}, {0xf9676178, /*L"frasl",*/ 8260}, |
164 {0xfd01885e, L"igrave", 236}, {0xff3281da, L"egrave", 232}, | 163 {0xfd01885e, /*L"igrave",*/ 236}, {0xff3281da, /*L"egrave",*/ 232}, |
165 }; | 164 }; |
166 | 165 |
167 const XFA_FMHtmlReserveCode reservesForEncode[] = { | 166 const XFA_FMHtmlReserveCode reservesForEncode[] = { |
168 {34, L"quot"}, {38, L"amp"}, {39, L"apos"}, | 167 {34, L"quot"}, {38, L"amp"}, {39, L"apos"}, |
169 {60, L"lt"}, {62, L"gt"}, {160, L"nbsp"}, | 168 {60, L"lt"}, {62, L"gt"}, {160, L"nbsp"}, |
170 {161, L"iexcl"}, {162, L"cent"}, {163, L"pund"}, | 169 {161, L"iexcl"}, {162, L"cent"}, {163, L"pund"}, |
171 {164, L"current"}, {165, L"yen"}, {166, L"brvbar"}, | 170 {164, L"current"}, {165, L"yen"}, {166, L"brvbar"}, |
172 {167, L"sect"}, {168, L"uml"}, {169, L"copy"}, | 171 {167, L"sect"}, {168, L"uml"}, {169, L"copy"}, |
173 {170, L"ordf"}, {171, L"laquo"}, {172, L"not"}, | 172 {170, L"ordf"}, {171, L"laquo"}, {172, L"not"}, |
174 {173, L"shy"}, {174, L"reg"}, {175, L"macr"}, | 173 {173, L"shy"}, {174, L"reg"}, {175, L"macr"}, |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 } | 493 } |
495 return false; | 494 return false; |
496 } | 495 } |
497 | 496 |
498 } // namespace | 497 } // namespace |
499 | 498 |
500 // static | 499 // static |
501 void CXFA_FM2JSContext::Abs(CFXJSE_Value* pThis, | 500 void CXFA_FM2JSContext::Abs(CFXJSE_Value* pThis, |
502 const CFX_ByteStringC& szFuncName, | 501 const CFX_ByteStringC& szFuncName, |
503 CFXJSE_Arguments& args) { | 502 CFXJSE_Arguments& args) { |
504 if (args.GetLength() == 1) { | 503 if (args.GetLength() != 1) { |
505 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); | |
506 if (ValueIsNull(pThis, argOne.get())) { | |
507 FXJSE_Value_SetNull(args.GetReturnValue()); | |
508 } else { | |
509 FX_DOUBLE dValue = ValueToDouble(pThis, argOne.get()); | |
510 if (dValue < 0) { | |
511 dValue = -dValue; | |
512 } | |
513 FXJSE_Value_SetDouble(args.GetReturnValue(), dValue); | |
514 } | |
515 } else { | |
516 CXFA_FM2JSContext* pContext = | 504 CXFA_FM2JSContext* pContext = |
517 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 505 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
518 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 506 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
519 L"Abs"); | 507 L"Abs"); |
| 508 return; |
520 } | 509 } |
| 510 |
| 511 std::unique_ptr<CFXJSE_Value> argOne = args.GetValue(0); |
| 512 if (ValueIsNull(pThis, argOne.get())) { |
| 513 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 514 return; |
| 515 } |
| 516 |
| 517 FX_DOUBLE dValue = ValueToDouble(pThis, argOne.get()); |
| 518 if (dValue < 0) |
| 519 dValue = -dValue; |
| 520 |
| 521 FXJSE_Value_SetDouble(args.GetReturnValue(), dValue); |
521 } | 522 } |
522 | 523 |
523 // static | 524 // static |
524 void CXFA_FM2JSContext::Avg(CFXJSE_Value* pThis, | 525 void CXFA_FM2JSContext::Avg(CFXJSE_Value* pThis, |
525 const CFX_ByteStringC& szFuncName, | 526 const CFX_ByteStringC& szFuncName, |
526 CFXJSE_Arguments& args) { | 527 CFXJSE_Arguments& args) { |
| 528 int32_t argc = args.GetLength(); |
| 529 if (argc < 1) { |
| 530 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 531 return; |
| 532 } |
| 533 |
527 CXFA_FM2JSContext* pContext = | 534 CXFA_FM2JSContext* pContext = |
528 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 535 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
529 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 536 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
530 int32_t argc = args.GetLength(); | |
531 uint32_t uCount = 0; | 537 uint32_t uCount = 0; |
532 FX_DOUBLE dSum = 0.0; | 538 FX_DOUBLE dSum = 0.0; |
533 if (argc >= 1) { | 539 for (int32_t i = 0; i < argc; i++) { |
534 for (int32_t i = 0; i < argc; i++) { | 540 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); |
535 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); | 541 if (FXJSE_Value_IsNull(argValue.get())) |
536 if (FXJSE_Value_IsNull(argValue.get())) { | 542 continue; |
537 continue; | |
538 } else if (FXJSE_Value_IsArray(argValue.get())) { | |
539 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | |
540 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); | |
541 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); | |
542 | 543 |
543 if (iLength > 2) { | 544 if (!FXJSE_Value_IsArray(argValue.get())) { |
544 std::unique_ptr<CFXJSE_Value> propertyValue( | 545 dSum += ValueToDouble(pThis, argValue.get()); |
| 546 uCount++; |
| 547 continue; |
| 548 } |
| 549 |
| 550 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
| 551 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); |
| 552 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
| 553 |
| 554 if (iLength > 2) { |
| 555 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
| 556 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); |
| 557 |
| 558 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
| 559 if (FXJSE_Value_IsNull(propertyValue.get())) { |
| 560 for (int32_t j = 2; j < iLength; j++) { |
| 561 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, |
| 562 jsObjectValue.get()); |
| 563 std::unique_ptr<CFXJSE_Value> defaultPropValue( |
545 new CFXJSE_Value(pIsolate)); | 564 new CFXJSE_Value(pIsolate)); |
546 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, | 565 GetObjectDefaultValue(jsObjectValue.get(), defaultPropValue.get()); |
547 propertyValue.get()); | 566 if (FXJSE_Value_IsNull(defaultPropValue.get())) |
548 std::unique_ptr<CFXJSE_Value> jsObjectValue( | 567 continue; |
549 new CFXJSE_Value(pIsolate)); | 568 |
550 if (FXJSE_Value_IsNull(propertyValue.get())) { | 569 dSum += ValueToDouble(pThis, defaultPropValue.get()); |
551 for (int32_t j = 2; j < iLength; j++) { | 570 uCount++; |
552 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, | |
553 jsObjectValue.get()); | |
554 std::unique_ptr<CFXJSE_Value> defaultPropValue( | |
555 new CFXJSE_Value(pIsolate)); | |
556 GetObjectDefaultValue(jsObjectValue.get(), | |
557 defaultPropValue.get()); | |
558 if (!FXJSE_Value_IsNull(defaultPropValue.get())) { | |
559 dSum += ValueToDouble(pThis, defaultPropValue.get()); | |
560 uCount++; | |
561 } | |
562 } | |
563 } else { | |
564 CFX_ByteString propertyStr; | |
565 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | |
566 std::unique_ptr<CFXJSE_Value> newPropertyValue( | |
567 new CFXJSE_Value(pIsolate)); | |
568 for (int32_t j = 2; j < iLength; j++) { | |
569 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, | |
570 jsObjectValue.get()); | |
571 FXJSE_Value_GetObjectProp(jsObjectValue.get(), | |
572 propertyStr.AsStringC(), | |
573 newPropertyValue.get()); | |
574 if (!FXJSE_Value_IsNull(newPropertyValue.get())) { | |
575 dSum += ValueToDouble(pThis, newPropertyValue.get()); | |
576 uCount++; | |
577 } | |
578 } | |
579 } | |
580 } | 571 } |
581 } else { | 572 } else { |
582 dSum += ValueToDouble(pThis, argValue.get()); | 573 CFX_ByteString propertyStr; |
583 uCount++; | 574 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
| 575 for (int32_t j = 2; j < iLength; j++) { |
| 576 FXJSE_Value_GetObjectPropByIdx(argValue.get(), j, |
| 577 jsObjectValue.get()); |
| 578 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
| 579 new CFXJSE_Value(pIsolate)); |
| 580 FXJSE_Value_GetObjectProp(jsObjectValue.get(), |
| 581 propertyStr.AsStringC(), |
| 582 newPropertyValue.get()); |
| 583 if (FXJSE_Value_IsNull(newPropertyValue.get())) |
| 584 continue; |
| 585 |
| 586 dSum += ValueToDouble(pThis, newPropertyValue.get()); |
| 587 uCount++; |
| 588 } |
584 } | 589 } |
585 } | 590 } |
586 } | 591 } |
587 if (0 == uCount) { | 592 if (uCount == 0) { |
588 FXJSE_Value_SetNull(args.GetReturnValue()); | 593 FXJSE_Value_SetNull(args.GetReturnValue()); |
589 } else { | 594 return; |
590 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount); | |
591 } | 595 } |
| 596 |
| 597 FXJSE_Value_SetDouble(args.GetReturnValue(), dSum / uCount); |
592 } | 598 } |
593 | 599 |
594 // static | 600 // static |
595 void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis, | 601 void CXFA_FM2JSContext::Ceil(CFXJSE_Value* pThis, |
596 const CFX_ByteStringC& szFuncName, | 602 const CFX_ByteStringC& szFuncName, |
597 CFXJSE_Arguments& args) { | 603 CFXJSE_Arguments& args) { |
598 if (args.GetLength() == 1) { | 604 if (args.GetLength() != 1) { |
599 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); | |
600 if (ValueIsNull(pThis, argValue.get())) { | |
601 FXJSE_Value_SetNull(args.GetReturnValue()); | |
602 } else { | |
603 FXJSE_Value_SetFloat(args.GetReturnValue(), | |
604 FXSYS_ceil(ValueToFloat(pThis, argValue.get()))); | |
605 } | |
606 } else { | |
607 CXFA_FM2JSContext* pContext = | 605 CXFA_FM2JSContext* pContext = |
608 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 606 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
609 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 607 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
610 L"Ceil"); | 608 L"Ceil"); |
| 609 return; |
611 } | 610 } |
| 611 |
| 612 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); |
| 613 if (ValueIsNull(pThis, argValue.get())) { |
| 614 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 615 return; |
| 616 } |
| 617 |
| 618 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 619 FXSYS_ceil(ValueToFloat(pThis, argValue.get()))); |
612 } | 620 } |
613 | 621 |
614 // static | 622 // static |
615 void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis, | 623 void CXFA_FM2JSContext::Count(CFXJSE_Value* pThis, |
616 const CFX_ByteStringC& szFuncName, | 624 const CFX_ByteStringC& szFuncName, |
617 CFXJSE_Arguments& args) { | 625 CFXJSE_Arguments& args) { |
618 CXFA_FM2JSContext* pContext = | 626 CXFA_FM2JSContext* pContext = |
619 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 627 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
620 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 628 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
621 uint32_t uCount = 0; | 629 int32_t iCount = 0; |
622 for (int32_t i = 0; i < args.GetLength(); i++) { | 630 for (int32_t i = 0; i < args.GetLength(); i++) { |
623 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); | 631 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); |
624 if (FXJSE_Value_IsNull(argValue.get())) { | 632 if (FXJSE_Value_IsNull(argValue.get())) |
625 continue; | 633 continue; |
626 } else if (FXJSE_Value_IsArray(argValue.get())) { | 634 |
| 635 if (FXJSE_Value_IsArray(argValue.get())) { |
627 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 636 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
628 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); | 637 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); |
| 638 |
629 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 639 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
| 640 if (iLength <= 2) { |
| 641 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 642 return; |
| 643 } |
630 | 644 |
631 if (iLength > 2) { | 645 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
632 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 646 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
633 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 647 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
634 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 648 new CFXJSE_Value(pIsolate)); |
635 new CFXJSE_Value(pIsolate)); | 649 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); |
636 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); | 650 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); |
637 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); | 651 if (FXJSE_Value_IsNull(propertyValue.get())) { |
638 if (FXJSE_Value_IsNull(propertyValue.get())) { | 652 for (int32_t i = 2; i < iLength; i++) { |
639 for (int32_t i = 2; i < iLength; i++) { | 653 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, |
640 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, | 654 jsObjectValue.get()); |
641 jsObjectValue.get()); | 655 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
642 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 656 if (!FXJSE_Value_IsNull(newPropertyValue.get())) |
643 if (!FXJSE_Value_IsNull(newPropertyValue.get())) { | 657 iCount++; |
644 uCount++; | |
645 } | |
646 } | |
647 } else { | |
648 CFX_ByteString propertyStr; | |
649 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | |
650 for (int32_t i = 2; i < iLength; i++) { | |
651 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, | |
652 jsObjectValue.get()); | |
653 FXJSE_Value_GetObjectProp(jsObjectValue.get(), | |
654 propertyStr.AsStringC(), | |
655 newPropertyValue.get()); | |
656 uCount += (FXJSE_Value_IsNull(newPropertyValue.get()) ? 0 : 1); | |
657 } | |
658 } | 658 } |
659 } else { | 659 } else { |
660 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 660 CFX_ByteString propertyStr; |
| 661 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
| 662 for (int32_t i = 2; i < iLength; i++) { |
| 663 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, |
| 664 jsObjectValue.get()); |
| 665 FXJSE_Value_GetObjectProp(jsObjectValue.get(), |
| 666 propertyStr.AsStringC(), |
| 667 newPropertyValue.get()); |
| 668 iCount += (FXJSE_Value_IsNull(newPropertyValue.get()) ? 0 : 1); |
| 669 } |
661 } | 670 } |
662 } else if (FXJSE_Value_IsObject(argValue.get())) { | 671 } else if (FXJSE_Value_IsObject(argValue.get())) { |
663 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 672 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
664 new CFXJSE_Value(pIsolate)); | 673 new CFXJSE_Value(pIsolate)); |
665 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); | 674 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); |
666 if (!FXJSE_Value_IsNull(newPropertyValue.get())) { | 675 if (!FXJSE_Value_IsNull(newPropertyValue.get())) |
667 uCount++; | 676 iCount++; |
668 } | |
669 } else { | 677 } else { |
670 uCount++; | 678 iCount++; |
671 } | 679 } |
672 } | 680 } |
673 FXJSE_Value_SetInteger(args.GetReturnValue(), (int32_t)uCount); | 681 FXJSE_Value_SetInteger(args.GetReturnValue(), iCount); |
674 } | 682 } |
675 | 683 |
676 // static | 684 // static |
677 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis, | 685 void CXFA_FM2JSContext::Floor(CFXJSE_Value* pThis, |
678 const CFX_ByteStringC& szFuncName, | 686 const CFX_ByteStringC& szFuncName, |
679 CFXJSE_Arguments& args) { | 687 CFXJSE_Arguments& args) { |
680 if (args.GetLength() == 1) { | 688 if (args.GetLength() != 1) { |
681 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); | |
682 if (ValueIsNull(pThis, argValue.get())) { | |
683 FXJSE_Value_SetNull(args.GetReturnValue()); | |
684 } else { | |
685 FXJSE_Value_SetFloat(args.GetReturnValue(), | |
686 FXSYS_floor(ValueToFloat(pThis, argValue.get()))); | |
687 } | |
688 } else { | |
689 CXFA_FM2JSContext* pContext = | 689 CXFA_FM2JSContext* pContext = |
690 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 690 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
691 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, | 691 pContext->ThrowScriptErrorMessage(XFA_IDS_INCORRECT_NUMBER_OF_METHOD, |
692 L"Floor"); | 692 L"Floor"); |
| 693 return; |
693 } | 694 } |
| 695 |
| 696 std::unique_ptr<CFXJSE_Value> argValue = GetSimpleValue(pThis, args, 0); |
| 697 if (ValueIsNull(pThis, argValue.get())) { |
| 698 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 699 return; |
| 700 } |
| 701 |
| 702 FXJSE_Value_SetFloat(args.GetReturnValue(), |
| 703 FXSYS_floor(ValueToFloat(pThis, argValue.get()))); |
694 } | 704 } |
695 | 705 |
696 // static | 706 // static |
697 void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis, | 707 void CXFA_FM2JSContext::Max(CFXJSE_Value* pThis, |
698 const CFX_ByteStringC& szFuncName, | 708 const CFX_ByteStringC& szFuncName, |
699 CFXJSE_Arguments& args) { | 709 CFXJSE_Arguments& args) { |
700 CXFA_FM2JSContext* pContext = | 710 CXFA_FM2JSContext* pContext = |
701 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 711 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
702 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 712 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
703 uint32_t uCount = 0; | 713 uint32_t uCount = 0; |
704 FX_DOUBLE dMaxValue = 0.0; | 714 FX_DOUBLE dMaxValue = 0.0; |
705 for (int32_t i = 0; i < args.GetLength(); i++) { | 715 for (int32_t i = 0; i < args.GetLength(); i++) { |
706 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); | 716 std::unique_ptr<CFXJSE_Value> argValue = args.GetValue(i); |
707 if (FXJSE_Value_IsNull(argValue.get())) { | 717 if (FXJSE_Value_IsNull(argValue.get())) |
708 continue; | 718 continue; |
709 } else if (FXJSE_Value_IsArray(argValue.get())) { | 719 |
| 720 if (FXJSE_Value_IsArray(argValue.get())) { |
710 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); | 721 std::unique_ptr<CFXJSE_Value> lengthValue(new CFXJSE_Value(pIsolate)); |
711 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); | 722 FXJSE_Value_GetObjectProp(argValue.get(), "length", lengthValue.get()); |
712 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); | 723 int32_t iLength = FXJSE_Value_ToInteger(lengthValue.get()); |
| 724 if (iLength <= 2) { |
| 725 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); |
| 726 return; |
| 727 } |
713 | 728 |
714 if (iLength > 2) { | 729 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); |
715 std::unique_ptr<CFXJSE_Value> propertyValue(new CFXJSE_Value(pIsolate)); | 730 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); |
716 std::unique_ptr<CFXJSE_Value> jsObjectValue(new CFXJSE_Value(pIsolate)); | 731 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
717 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 732 new CFXJSE_Value(pIsolate)); |
718 new CFXJSE_Value(pIsolate)); | 733 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); |
719 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 1, propertyValue.get()); | 734 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); |
720 FXJSE_Value_GetObjectPropByIdx(argValue.get(), 2, jsObjectValue.get()); | 735 if (FXJSE_Value_IsNull(propertyValue.get())) { |
721 if (FXJSE_Value_IsNull(propertyValue.get())) { | 736 for (int32_t i = 2; i < iLength; i++) { |
722 for (int32_t i = 2; i < iLength; i++) { | 737 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, |
723 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, | 738 jsObjectValue.get()); |
724 jsObjectValue.get()); | 739 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); |
725 GetObjectDefaultValue(jsObjectValue.get(), newPropertyValue.get()); | 740 if (FXJSE_Value_IsNull(newPropertyValue.get())) |
726 if (!FXJSE_Value_IsNull(newPropertyValue.get())) { | 741 continue; |
727 uCount++; | 742 |
728 if (uCount == 1) { | 743 uCount++; |
729 dMaxValue = ValueToDouble(pThis, newPropertyValue.get()); | 744 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
730 } else { | 745 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); |
731 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | |
732 if (dMaxValue < dValue) { | |
733 dMaxValue = dValue; | |
734 } | |
735 } | |
736 } | |
737 } | |
738 } else { | |
739 CFX_ByteString propertyStr; | |
740 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); | |
741 for (int32_t i = 2; i < iLength; i++) { | |
742 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, | |
743 jsObjectValue.get()); | |
744 FXJSE_Value_GetObjectProp(jsObjectValue.get(), | |
745 propertyStr.AsStringC(), | |
746 newPropertyValue.get()); | |
747 if (!FXJSE_Value_IsNull(newPropertyValue.get())) { | |
748 uCount++; | |
749 if (uCount == 1) { | |
750 dMaxValue = ValueToDouble(pThis, newPropertyValue.get()); | |
751 } else { | |
752 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | |
753 if (dMaxValue < dValue) { | |
754 dMaxValue = dValue; | |
755 } | |
756 } | |
757 } | |
758 } | |
759 } | 746 } |
760 } else { | 747 } else { |
761 pContext->ThrowScriptErrorMessage(XFA_IDS_ARGUMENT_MISMATCH); | 748 CFX_ByteString propertyStr; |
| 749 FXJSE_Value_ToUTF8String(propertyValue.get(), propertyStr); |
| 750 for (int32_t i = 2; i < iLength; i++) { |
| 751 FXJSE_Value_GetObjectPropByIdx(argValue.get(), i, |
| 752 jsObjectValue.get()); |
| 753 FXJSE_Value_GetObjectProp(jsObjectValue.get(), |
| 754 propertyStr.AsStringC(), |
| 755 newPropertyValue.get()); |
| 756 if (FXJSE_Value_IsNull(newPropertyValue.get())) |
| 757 continue; |
| 758 |
| 759 uCount++; |
| 760 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
| 761 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); |
| 762 } |
762 } | 763 } |
763 } else if (FXJSE_Value_IsObject(argValue.get())) { | 764 } else if (FXJSE_Value_IsObject(argValue.get())) { |
764 std::unique_ptr<CFXJSE_Value> newPropertyValue( | 765 std::unique_ptr<CFXJSE_Value> newPropertyValue( |
765 new CFXJSE_Value(pIsolate)); | 766 new CFXJSE_Value(pIsolate)); |
766 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); | 767 GetObjectDefaultValue(argValue.get(), newPropertyValue.get()); |
767 if (!FXJSE_Value_IsNull(newPropertyValue.get())) { | 768 if (FXJSE_Value_IsNull(newPropertyValue.get())) |
768 uCount++; | 769 continue; |
769 if (uCount == 1) { | 770 |
770 dMaxValue = ValueToDouble(pThis, newPropertyValue.get()); | 771 uCount++; |
771 } else { | 772 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); |
772 FX_DOUBLE dValue = ValueToDouble(pThis, newPropertyValue.get()); | 773 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); |
773 if (dMaxValue < dValue) { | |
774 dMaxValue = dValue; | |
775 } | |
776 } | |
777 } | |
778 } else { | 774 } else { |
779 uCount++; | 775 uCount++; |
780 if (uCount == 1) { | 776 FX_DOUBLE dValue = ValueToDouble(pThis, argValue.get()); |
781 dMaxValue = ValueToDouble(pThis, argValue.get()); | 777 dMaxValue = (uCount == 1) ? dValue : std::max(dMaxValue, dValue); |
782 } else { | |
783 FX_DOUBLE dValue = ValueToDouble(pThis, argValue.get()); | |
784 if (dMaxValue < dValue) { | |
785 dMaxValue = dValue; | |
786 } | |
787 } | |
788 } | 778 } |
789 } | 779 } |
| 780 if (uCount == 0) { |
| 781 FXJSE_Value_SetNull(args.GetReturnValue()); |
| 782 return; |
| 783 } |
790 | 784 |
791 if (uCount) { | 785 FXJSE_Value_SetDouble(args.GetReturnValue(), dMaxValue); |
792 FXJSE_Value_SetDouble(args.GetReturnValue(), dMaxValue); | |
793 } else { | |
794 FXJSE_Value_SetNull(args.GetReturnValue()); | |
795 } | |
796 } | 786 } |
797 | 787 |
798 // static | 788 // static |
799 void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis, | 789 void CXFA_FM2JSContext::Min(CFXJSE_Value* pThis, |
800 const CFX_ByteStringC& szFuncName, | 790 const CFX_ByteStringC& szFuncName, |
801 CFXJSE_Arguments& args) { | 791 CFXJSE_Arguments& args) { |
802 CXFA_FM2JSContext* pContext = | 792 CXFA_FM2JSContext* pContext = |
803 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); | 793 (CXFA_FM2JSContext*)FXJSE_Value_ToObject(pThis, nullptr); |
804 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); | 794 v8::Isolate* pIsolate = pContext->GetScriptRuntime(); |
805 uint32_t uCount = 0; | 795 uint32_t uCount = 0; |
(...skipping 6349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7155 CFX_WideString wsFormat; | 7145 CFX_WideString wsFormat; |
7156 pAppProvider->LoadString(iStringID, wsFormat); | 7146 pAppProvider->LoadString(iStringID, wsFormat); |
7157 CFX_WideString wsMessage; | 7147 CFX_WideString wsMessage; |
7158 va_list arg_ptr; | 7148 va_list arg_ptr; |
7159 va_start(arg_ptr, iStringID); | 7149 va_start(arg_ptr, iStringID); |
7160 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 7150 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
7161 va_end(arg_ptr); | 7151 va_end(arg_ptr); |
7162 FXJSE_ThrowMessage( | 7152 FXJSE_ThrowMessage( |
7163 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 7153 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
7164 } | 7154 } |
OLD | NEW |