summaryrefslogtreecommitdiff
path: root/Source/WebCore/xml/parser/MarkupTokenizerInlines.h
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2017-06-27 06:07:23 +0000
commit1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch)
tree46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/xml/parser/MarkupTokenizerInlines.h
parent32761a6cee1d0dee366b885b7b9c777e67885688 (diff)
downloadWebKitGtk-tarball-master.tar.gz
Diffstat (limited to 'Source/WebCore/xml/parser/MarkupTokenizerInlines.h')
-rw-r--r--Source/WebCore/xml/parser/MarkupTokenizerInlines.h107
1 files changed, 54 insertions, 53 deletions
diff --git a/Source/WebCore/xml/parser/MarkupTokenizerInlines.h b/Source/WebCore/xml/parser/MarkupTokenizerInlines.h
index e0b3156bb..58ef106ae 100644
--- a/Source/WebCore/xml/parser/MarkupTokenizerInlines.h
+++ b/Source/WebCore/xml/parser/MarkupTokenizerInlines.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008-2016 Apple Inc. All Rights Reserved.
* Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/
* Copyright (C) 2010 Google, Inc. All Rights Reserved.
*
@@ -25,71 +25,72 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef MarkupTokenizerInlines_h
-#define MarkupTokenizerInlines_h
+#pragma once
-#include "SegmentedString.h"
+#if COMPILER(MSVC)
+// Disable the "unreachable code" warning so we can compile the ASSERT_NOT_REACHED in the END_STATE macro.
+#pragma warning(disable: 4702)
+#endif
namespace WebCore {
-inline bool isTokenizerWhitespace(UChar cc)
+inline bool isTokenizerWhitespace(UChar character)
{
- return cc == ' ' || cc == '\x0A' || cc == '\x09' || cc == '\x0C';
+ return character == ' ' || character == '\x0A' || character == '\x09' || character == '\x0C';
}
-inline void advanceStringAndASSERTIgnoringCase(SegmentedString& source, const char* expectedCharacters)
-{
- while (*expectedCharacters)
- source.advanceAndASSERTIgnoringCase(*expectedCharacters++);
-}
+#define BEGIN_STATE(stateName) \
+ case stateName: \
+ stateName: { \
+ constexpr auto currentState = stateName; \
+ UNUSED_PARAM(currentState);
-inline void advanceStringAndASSERT(SegmentedString& source, const char* expectedCharacters)
-{
- while (*expectedCharacters)
- source.advanceAndASSERT(*expectedCharacters++);
-}
+#define END_STATE() \
+ ASSERT_NOT_REACHED(); \
+ break; \
+ }
-#if COMPILER(MSVC)
-// We need to disable the "unreachable code" warning because we want to assert
-// that some code points aren't reached in the state machine.
-#pragma warning(disable: 4702)
-#endif
-
-#define BEGIN_STATE(prefix, stateName) case prefix::stateName: stateName:
-#define END_STATE() ASSERT_NOT_REACHED(); break;
-
-// We use this macro when the HTML5 spec says "reconsume the current input
-// character in the <mumble> state."
-#define RECONSUME_IN(prefix, stateName) \
- do { \
- m_state = prefix::stateName; \
- goto stateName; \
+#define RETURN_IN_CURRENT_STATE(expression) \
+ do { \
+ m_state = currentState; \
+ return expression; \
} while (false)
-// We use this macro when the HTML5 spec says "consume the next input
-// character ... and switch to the <mumble> state."
-#define ADVANCE_TO(prefix, stateName) \
- do { \
- m_state = prefix::stateName; \
- if (!m_inputStreamPreprocessor.advance(source)) \
- return haveBufferedCharacterToken(); \
- cc = m_inputStreamPreprocessor.nextInputCharacter(); \
- goto stateName; \
+// We use this macro when the HTML spec says "reconsume the current input character in the <mumble> state."
+#define RECONSUME_IN(newState) \
+ do { \
+ goto newState; \
} while (false)
-// Sometimes there's more complicated logic in the spec that separates when
-// we consume the next input character and when we switch to a particular
-// state. We handle those cases by advancing the source directly and using
-// this macro to switch to the indicated state.
-#define SWITCH_TO(prefix, stateName) \
- do { \
- m_state = prefix::stateName; \
- if (source.isEmpty() || !m_inputStreamPreprocessor.peek(source)) \
- return haveBufferedCharacterToken(); \
- cc = m_inputStreamPreprocessor.nextInputCharacter(); \
- goto stateName; \
+// We use this macro when the HTML spec says "consume the next input character ... and switch to the <mumble> state."
+#define ADVANCE_TO(newState) \
+ do { \
+ if (!m_preprocessor.advance(source, isNullCharacterSkippingState(newState))) { \
+ m_state = newState; \
+ return haveBufferedCharacterToken(); \
+ } \
+ character = m_preprocessor.nextInputCharacter(); \
+ goto newState; \
+ } while (false)
+#define ADVANCE_PAST_NON_NEWLINE_TO(newState) \
+ do { \
+ if (!m_preprocessor.advancePastNonNewline(source, isNullCharacterSkippingState(newState))) { \
+ m_state = newState; \
+ return haveBufferedCharacterToken(); \
+ } \
+ character = m_preprocessor.nextInputCharacter(); \
+ goto newState; \
} while (false)
-}
+// For more complex cases, caller consumes the characters first and then uses this macro.
+#define SWITCH_TO(newState) \
+ do { \
+ if (!m_preprocessor.peek(source, isNullCharacterSkippingState(newState))) { \
+ m_state = newState; \
+ return haveBufferedCharacterToken(); \
+ } \
+ character = m_preprocessor.nextInputCharacter(); \
+ goto newState; \
+ } while (false)
-#endif // MarkupTokenizerInlines_h
+} // namespace WebCore