| OLD | NEW |
| (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 SKY_ENGINE_CORE_HTML_PARSER_MARKUPTOKENIZERINLINES_H_ | |
| 29 #define SKY_ENGINE_CORE_HTML_PARSER_MARKUPTOKENIZERINLINES_H_ | |
| 30 | |
| 31 #include "sky/engine/platform/text/SegmentedString.h" | |
| 32 | |
| 33 namespace blink { | |
| 34 | |
| 35 inline bool isTokenizerWhitespace(UChar cc) | |
| 36 { | |
| 37 return cc == ' ' || cc == '\x0A'; | |
| 38 } | |
| 39 | |
| 40 inline bool isTokenizerTagName(UChar cc) | |
| 41 { | |
| 42 if (cc >= 'a' && cc <= 'z') | |
| 43 return true; | |
| 44 if (cc >= 'A' && cc <= 'Z') | |
| 45 return true; | |
| 46 if (cc >= '0' && cc <= '9') | |
| 47 return true; | |
| 48 return cc == '-' || cc == '_' || cc == '.'; | |
| 49 } | |
| 50 | |
| 51 inline void advanceStringAndASSERTIgnoringCase(SegmentedString& source, const ch
ar* expectedCharacters) | |
| 52 { | |
| 53 while (*expectedCharacters) | |
| 54 source.advanceAndASSERTIgnoringCase(*expectedCharacters++); | |
| 55 } | |
| 56 | |
| 57 inline void advanceStringAndASSERT(SegmentedString& source, const char* expected
Characters) | |
| 58 { | |
| 59 while (*expectedCharacters) | |
| 60 source.advanceAndASSERT(*expectedCharacters++); | |
| 61 } | |
| 62 | |
| 63 #define BEGIN_STATE(prefix, stateName) case prefix::stateName: stateName: | |
| 64 #define END_STATE() ASSERT_NOT_REACHED(); break; | |
| 65 | |
| 66 // We use this macro when the HTML5 spec says "reconsume the current input | |
| 67 // character in the <mumble> state." | |
| 68 #define RECONSUME_IN(prefix, stateName) \ | |
| 69 do { \ | |
| 70 m_state = prefix::stateName; \ | |
| 71 goto stateName; \ | |
| 72 } while (false) | |
| 73 | |
| 74 // We use this macro when the HTML5 spec says "consume the next input | |
| 75 // character ... and switch to the <mumble> state." | |
| 76 #define ADVANCE_TO(prefix, stateName) \ | |
| 77 do { \ | |
| 78 m_state = prefix::stateName; \ | |
| 79 if (!m_inputStreamPreprocessor.advance(source)) \ | |
| 80 return haveBufferedCharacterToken(); \ | |
| 81 cc = m_inputStreamPreprocessor.nextInputCharacter(); \ | |
| 82 goto stateName; \ | |
| 83 } while (false) | |
| 84 | |
| 85 // Sometimes there's more complicated logic in the spec that separates when | |
| 86 // we consume the next input character and when we switch to a particular | |
| 87 // state. We handle those cases by advancing the source directly and using | |
| 88 // this macro to switch to the indicated state. | |
| 89 #define SWITCH_TO(prefix, stateName) \ | |
| 90 do { \ | |
| 91 m_state = prefix::stateName; \ | |
| 92 if (source.isEmpty() || !m_inputStreamPreprocessor.peek(source)) \ | |
| 93 return haveBufferedCharacterToken(); \ | |
| 94 cc = m_inputStreamPreprocessor.nextInputCharacter(); \ | |
| 95 goto stateName; \ | |
| 96 } while (false) | |
| 97 | |
| 98 } | |
| 99 | |
| 100 #endif // SKY_ENGINE_CORE_HTML_PARSER_MARKUPTOKENIZERINLINES_H_ | |
| OLD | NEW |