Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(692)

Side by Side Diff: ios/third_party/blink/src/html_markup_tokenizer_inlines.h

Issue 1031023002: Upstream ios/web/ HTML tokenizer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
5 *
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.
14 *
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.
26 */
27
28 #ifndef MarkupTokenizerInlines_h
29 #define MarkupTokenizerInlines_h
30
31 #include "html_character_provider.h"
32
33 namespace WebCore {
34
35 template <typename CharType>
36 inline bool isTokenizerWhitespace(CharType cc)
37 {
38 return cc == ' ' || cc == '\x0A' || cc == '\x09' || cc == '\x0C';
39 }
40
41 void advanceStringAndASSERTIgnoringCase(CharacterProvider& source, const LChar* expectedCharacters)
42 {
43 while (*expectedCharacters) {
44 #ifndef NDEBUG
45 ASSERT(isASCIILower(*expectedCharacters));
46
47 UChar currentCharacter = source.currentCharacter();
48 if (isASCIIUpper(currentCharacter))
49 currentCharacter = toLowerCase(currentCharacter);
50
51 ASSERT(currentCharacter == *expectedCharacters);
52 #endif
53
54 ++expectedCharacters;
55 source.next();
56 }
57 }
58
59 inline void advanceAndASSERT(CharacterProvider& source, UChar expectedCharacter)
60 {
61 ASSERT(source.currentCharacter() == expectedCharacter);
62 source.next();
63 }
64
65 #define BEGIN_STATE(prefix, stateName) case prefix::stateName: stateName:
66 #define END_STATE() ASSERT_NOT_REACHED(); break;
67
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)
75
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)
86
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)
99
100 }
101
102 #endif // MarkupTokenizerInlines_h
OLDNEW
« no previous file with comments | « ios/third_party/blink/src/html_input_stream_preprocessor.h ('k') | ios/third_party/blink/src/html_token.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698