Chromium Code Reviews| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 60 double parseToDoubleForNumberType(const String&, double fallbackValue); | 60 double parseToDoubleForNumberType(const String&, double fallbackValue); |
| 61 | 61 |
| 62 // http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-integers | 62 // http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-integers |
| 63 bool parseHTMLInteger(const String&, int&); | 63 bool parseHTMLInteger(const String&, int&); |
| 64 | 64 |
| 65 // http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-non-nega tive-integers | 65 // http://www.whatwg.org/specs/web-apps/current-work/#rules-for-parsing-non-nega tive-integers |
| 66 bool parseHTMLNonNegativeInteger(const String&, unsigned int&); | 66 bool parseHTMLNonNegativeInteger(const String&, unsigned int&); |
| 67 | 67 |
| 68 // Inline implementations of some of the functions declared above. | 68 // Inline implementations of some of the functions declared above. |
| 69 | 69 |
| 70 inline bool isHTMLSpace(UChar character) | 70 template<typename CharType> |
| 71 inline bool isHTMLSpace(CharType character) | |
| 71 { | 72 { |
| 72 // Histogram from Apple's page load test combined with some ad hoc browsing some other test suites. | 73 // Histogram from Apple's page load test combined with some ad hoc browsing some other test suites. |
| 73 // | 74 // |
| 74 // 82%: 216330 non-space characters, all > U+0020 | 75 // 82%: 216330 non-space characters, all > U+0020 |
| 75 // 11%: 30017 plain space characters, U+0020 | 76 // 11%: 30017 plain space characters, U+0020 |
| 76 // 5%: 12099 newline characters, U+000A | 77 // 5%: 12099 newline characters, U+000A |
| 77 // 2%: 5346 tab characters, U+0009 | 78 // 2%: 5346 tab characters, U+0009 |
| 78 // | 79 // |
| 79 // No other characters seen. No U+000C or U+000D, and no other control chara cters. | 80 // No other characters seen. No U+000C or U+000D, and no other control chara cters. |
| 80 // Accordingly, we check for non-spaces first, then space, then newline, the n tab, then the other characters. | 81 // Accordingly, we check for non-spaces first, then space, then newline, the n tab, then the other characters. |
| 81 | 82 |
| 82 return character <= ' ' && (character == ' ' || character == '\n' || charact er == '\t' || character == '\r' || character == '\f'); | 83 return character <= ' ' && (character == ' ' || character == '\n' || charact er == '\t' || character == '\r' || character == '\f'); |
| 83 } | 84 } |
| 84 | 85 |
| 86 inline bool isHTMLSpace(UChar character) | |
| 87 { | |
| 88 return isHTMLSpace<UChar>(character); | |
| 89 } | |
|
abarth-chromium
2013/09/19 18:09:52
Why is this needed?
| |
| 90 | |
| 91 template<typename CharType> | |
| 92 inline bool isHTMLSpaceOrComma(CharType character) | |
| 93 { | |
| 94 return isHTMLSpace(character) || character == ','; | |
| 95 } | |
| 96 | |
| 85 inline bool isHTMLLineBreak(UChar character) | 97 inline bool isHTMLLineBreak(UChar character) |
| 86 { | 98 { |
| 87 return character <= '\r' && (character == '\n' || character == '\r'); | 99 return character <= '\r' && (character == '\n' || character == '\r'); |
| 88 } | 100 } |
| 89 | 101 |
| 90 inline bool isNotHTMLSpace(UChar character) | 102 inline bool isNotHTMLSpace(UChar character) |
| 91 { | 103 { |
| 92 return !isHTMLSpace(character); | 104 return !isHTMLSpace<UChar>(character); |
| 105 } | |
|
abarth-chromium
2013/09/19 18:09:52
Why do you need these concrete specializations?
Yoav Weiss
2013/09/20 04:54:27
I've added that to avoid changing the calls to isH
abarth-chromium
2013/09/20 16:08:07
Most of the callers should be able to infer the ty
| |
| 106 | |
| 107 template<typename CharType> | |
| 108 inline bool isNotHTMLSpace(CharType character) | |
| 109 { | |
| 110 return !isHTMLSpace<CharType>(character); | |
| 93 } | 111 } |
| 94 | 112 |
| 95 bool threadSafeMatch(const QualifiedName&, const QualifiedName&); | 113 bool threadSafeMatch(const QualifiedName&, const QualifiedName&); |
| 96 bool threadSafeMatch(const HTMLIdentifier&, const QualifiedName&); | 114 bool threadSafeMatch(const HTMLIdentifier&, const QualifiedName&); |
| 97 inline bool threadSafeHTMLNamesMatch(const HTMLIdentifier& tagName, const Qualif iedName& qName) | 115 inline bool threadSafeHTMLNamesMatch(const HTMLIdentifier& tagName, const Qualif iedName& qName) |
| 98 { | 116 { |
| 99 // When the QualifiedName is known to HTMLIdentifier, | 117 // When the QualifiedName is known to HTMLIdentifier, |
| 100 // all we have to do is a pointer compare. | 118 // all we have to do is a pointer compare. |
| 101 ASSERT(HTMLIdentifier::isKnown(qName.localName().impl())); | 119 ASSERT(HTMLIdentifier::isKnown(qName.localName().impl())); |
| 102 return tagName.asStringImpl() == qName.localName().impl(); | 120 return tagName.asStringImpl() == qName.localName().impl(); |
| 103 } | 121 } |
| 104 | 122 |
| 105 } | 123 } |
| 106 | 124 |
| 107 #endif | 125 #endif |
| OLD | NEW |