OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2010 Apple 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 | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
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 12 matching lines...) Expand all Loading... |
23 */ | 23 */ |
24 | 24 |
25 #ifndef HTMLParserIdioms_h | 25 #ifndef HTMLParserIdioms_h |
26 #define HTMLParserIdioms_h | 26 #define HTMLParserIdioms_h |
27 | 27 |
28 #include "core/dom/QualifiedName.h" | 28 #include "core/dom/QualifiedName.h" |
29 #include "platform/Decimal.h" | 29 #include "platform/Decimal.h" |
30 #include "wtf/Forward.h" | 30 #include "wtf/Forward.h" |
31 #include "wtf/text/WTFString.h" | 31 #include "wtf/text/WTFString.h" |
32 | 32 |
33 namespace WTF { | |
34 class TextEncoding; | |
35 } | |
36 | |
37 namespace WebCore { | 33 namespace WebCore { |
38 | 34 |
39 // Space characters as defined by the HTML specification. | 35 // Space characters as defined by the HTML specification. |
40 bool isHTMLSpace(UChar); | 36 bool isHTMLSpace(UChar); |
41 bool isHTMLLineBreak(UChar); | 37 bool isHTMLLineBreak(UChar); |
42 bool isNotHTMLSpace(UChar); | 38 bool isNotHTMLSpace(UChar); |
43 | 39 |
44 // Strip leading and trailing whitespace as defined by the HTML specification. | 40 // Strip leading and trailing whitespace as defined by the HTML specification. |
45 String stripLeadingAndTrailingHTMLSpaces(const String&); | 41 String stripLeadingAndTrailingHTMLSpaces(const String&); |
46 template<size_t inlineCapacity> | 42 template<size_t inlineCapacity> |
(...skipping 11 matching lines...) Expand all Loading... |
58 // The double* parameter may be 0 to check if the string can be parsed without g
etting the result. | 54 // The double* parameter may be 0 to check if the string can be parsed without g
etting the result. |
59 Decimal parseToDecimalForNumberType(const String&, const Decimal& fallbackValue
= Decimal::nan()); | 55 Decimal parseToDecimalForNumberType(const String&, const Decimal& fallbackValue
= Decimal::nan()); |
60 double parseToDoubleForNumberType(const String&, double fallbackValue = std::num
eric_limits<double>::quiet_NaN()); | 56 double parseToDoubleForNumberType(const String&, double fallbackValue = std::num
eric_limits<double>::quiet_NaN()); |
61 | 57 |
62 // http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-integers | 58 // http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-integers |
63 bool parseHTMLInteger(const String&, int&); | 59 bool parseHTMLInteger(const String&, int&); |
64 | 60 |
65 // http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-non-nega
tive-integers | 61 // http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-non-nega
tive-integers |
66 bool parseHTMLNonNegativeInteger(const String&, unsigned int&); | 62 bool parseHTMLNonNegativeInteger(const String&, unsigned int&); |
67 | 63 |
68 typedef Vector<pair<String, String> > HTMLAttributeList; | |
69 // The returned encoding might not be valid. | |
70 WTF::TextEncoding encodingFromMetaAttributes(const HTMLAttributeList&); | |
71 | |
72 // Inline implementations of some of the functions declared above. | 64 // Inline implementations of some of the functions declared above. |
73 | 65 |
74 template<typename CharType> | 66 template<typename CharType> |
75 inline bool isHTMLSpace(CharType character) | 67 inline bool isHTMLSpace(CharType character) |
76 { | 68 { |
77 // Histogram from Apple's page load test combined with some ad hoc browsing
some other test suites. | 69 // Histogram from Apple's page load test combined with some ad hoc browsing
some other test suites. |
78 // | 70 // |
79 // 82%: 216330 non-space characters, all > U+0020 | 71 // 82%: 216330 non-space characters, all > U+0020 |
80 // 11%: 30017 plain space characters, U+0020 | 72 // 11%: 30017 plain space characters, U+0020 |
81 // 5%: 12099 newline characters, U+000A | 73 // 5%: 12099 newline characters, U+000A |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 else if (width == Force8Bit) | 118 else if (width == Force8Bit) |
127 string = String::make8BitFrom16BitSource(vector); | 119 string = String::make8BitFrom16BitSource(vector); |
128 else | 120 else |
129 string = String(vector); | 121 string = String(vector); |
130 | 122 |
131 return string; | 123 return string; |
132 } | 124 } |
133 | 125 |
134 } | 126 } |
135 #endif | 127 #endif |
OLD | NEW |