Add ICU message format support
[chromium-blink-merge.git] / ios / third_party / blink / src / html_markup_tokenizer_inlines.h
blobf510fd10a9524a9f56d4fd3786f680af76a9b62b
1 /*
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/
4 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef MarkupTokenizerInlines_h
29 #define MarkupTokenizerInlines_h
31 #include "html_character_provider.h"
33 namespace WebCore {
35 template <typename CharType>
36 inline bool isTokenizerWhitespace(CharType cc)
38 return cc == ' ' || cc == '\x0A' || cc == '\x09' || cc == '\x0C';
41 void advanceStringAndASSERTIgnoringCase(CharacterProvider& source, const LChar* expectedCharacters)
43 while (*expectedCharacters) {
44 #ifndef NDEBUG
45 ASSERT(isASCIILower(*expectedCharacters));
47 UChar currentCharacter = source.currentCharacter();
48 if (isASCIIUpper(currentCharacter))
49 currentCharacter = toLowerCase(currentCharacter);
51 ASSERT(currentCharacter == *expectedCharacters);
52 #endif
54 ++expectedCharacters;
55 source.next();
59 inline void advanceAndASSERT(CharacterProvider& source, UChar expectedCharacter)
61 ASSERT(source.currentCharacter() == expectedCharacter);
62 source.next();
65 #define BEGIN_STATE(prefix, stateName) case prefix::stateName: stateName:
66 #define END_STATE() ASSERT_NOT_REACHED(); break;
68 // We use this macro when the HTML5 spec says "reconsume the current input
69 // character in the <mumble> state."
70 #define RECONSUME_IN(prefix, stateName) \
71 do { \
72 m_state = prefix::stateName; \
73 goto stateName; \
74 } while (false)
76 // We use this macro when the HTML5 spec says "consume the next input
77 // character ... and switch to the <mumble> state."
78 #define ADVANCE_TO(prefix, stateName) \
79 do { \
80 m_state = prefix::stateName; \
81 if (!m_inputStreamPreprocessor.advance(source)) \
82 return haveBufferedCharacterToken(); \
83 cc = m_inputStreamPreprocessor.nextInputCharacter(); \
84 goto stateName; \
85 } while (false)
87 // Sometimes there's more complicated logic in the spec that separates when
88 // we consume the next input character and when we switch to a particular
89 // state. We handle those cases by advancing the source directly and using
90 // this macro to switch to the indicated state.
91 #define SWITCH_TO(prefix, stateName) \
92 do { \
93 m_state = prefix::stateName; \
94 if (source.isEmpty() || !m_inputStreamPreprocessor.peek(source)) \
95 return haveBufferedCharacterToken(); \
96 cc = m_inputStreamPreprocessor.nextInputCharacter(); \
97 goto stateName; \
98 } while (false)
102 #endif // MarkupTokenizerInlines_h