OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. | 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved. |
3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ | 3 * Copyright (C) 2009 Torch Mobile, Inc. http://www.torchmobile.com/ |
4 * Copyright (C) 2013 Google, Inc. All Rights Reserved. | 4 * Copyright (C) 2013 Google, Inc. All Rights Reserved. |
5 * | 5 * |
6 * Redistribution and use in source and binary forms, with or without | 6 * Redistribution and use in source and binary forms, with or without |
7 * modification, are permitted provided that the following conditions | 7 * modification, are permitted provided that the following conditions |
8 * are met: | 8 * are met: |
9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 source.advancePastNewlineAndUpdateLineNumber(); | 94 source.advancePastNewlineAndUpdateLineNumber(); |
95 if (source.isEmpty()) | 95 if (source.isEmpty()) |
96 return false; | 96 return false; |
97 m_nextInputCharacter = source.currentChar(); | 97 m_nextInputCharacter = source.currentChar(); |
98 } | 98 } |
99 if (m_nextInputCharacter == '\r') { | 99 if (m_nextInputCharacter == '\r') { |
100 m_nextInputCharacter = '\n'; | 100 m_nextInputCharacter = '\n'; |
101 m_skipNextNewLine = true; | 101 m_skipNextNewLine = true; |
102 } else { | 102 } else { |
103 m_skipNextNewLine = false; | 103 m_skipNextNewLine = false; |
104 // FIXME: The spec indicates that the surrogate pair range as well as | 104 // FIXME: The spec indicates that the surrogate pair range as well as a |
105 // a number of specific character values are parse errors and should be re
placed | 105 // number of specific character values are parse errors and should be |
106 // by the replacement character. We suspect this is a problem with the spe
c as doing | 106 // replaced by the replacement character. We suspect this is a problem |
107 // that filtering breaks surrogate pair handling and causes us not to matc
h Minefield. | 107 // with the spec as doing that filtering breaks surrogate pair handling |
| 108 // and causes us not to match Minefield. |
108 if (m_nextInputCharacter == '\0' && | 109 if (m_nextInputCharacter == '\0' && |
109 !shouldTreatNullAsEndOfFileMarker(source)) { | 110 !shouldTreatNullAsEndOfFileMarker(source)) { |
110 if (m_tokenizer->shouldSkipNullCharacters()) { | 111 if (m_tokenizer->shouldSkipNullCharacters()) { |
111 source.advancePastNonNewline(); | 112 source.advancePastNonNewline(); |
112 if (source.isEmpty()) | 113 if (source.isEmpty()) |
113 return false; | 114 return false; |
114 m_nextInputCharacter = source.currentChar(); | 115 m_nextInputCharacter = source.currentChar(); |
115 goto ProcessAgain; | 116 goto ProcessAgain; |
116 } | 117 } |
117 m_nextInputCharacter = 0xFFFD; | 118 m_nextInputCharacter = 0xFFFD; |
118 } | 119 } |
119 } | 120 } |
120 return true; | 121 return true; |
121 } | 122 } |
122 | 123 |
123 bool shouldTreatNullAsEndOfFileMarker(SegmentedString& source) const { | 124 bool shouldTreatNullAsEndOfFileMarker(SegmentedString& source) const { |
124 return source.isClosed() && source.length() == 1; | 125 return source.isClosed() && source.length() == 1; |
125 } | 126 } |
126 | 127 |
127 Tokenizer* m_tokenizer; | 128 Tokenizer* m_tokenizer; |
128 | 129 |
129 // http://www.whatwg.org/specs/web-apps/current-work/#next-input-character | 130 // http://www.whatwg.org/specs/web-apps/current-work/#next-input-character |
130 UChar m_nextInputCharacter; | 131 UChar m_nextInputCharacter; |
131 bool m_skipNextNewLine; | 132 bool m_skipNextNewLine; |
132 }; | 133 }; |
133 | 134 |
134 } // namespace blink | 135 } // namespace blink |
135 | 136 |
136 #endif // InputStreamPreprocessor_h | 137 #endif // InputStreamPreprocessor_h |
OLD | NEW |