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

Side by Side Diff: Source/core/html/track/WebVTTTokenizer.cpp

Issue 66503013: Support the 'lrm', 'rlm' and 'nbsp' entities in the WebVTTTokenizer (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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
« no previous file with comments | « LayoutTests/media/track/track-webvtt-tc022-entities-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 32
33 #include "core/html/track/WebVTTTokenizer.h" 33 #include "core/html/track/WebVTTTokenizer.h"
34 34
35 #include "core/xml/parser/MarkupTokenizerInlines.h" 35 #include "core/xml/parser/MarkupTokenizerInlines.h"
36 #include "wtf/unicode/CharacterNames.h"
36 37
37 namespace WebCore { 38 namespace WebCore {
38 39
39 #define WEBVTT_BEGIN_STATE(stateName) BEGIN_STATE(WebVTTTokenizerState, stateNam e) 40 #define WEBVTT_BEGIN_STATE(stateName) BEGIN_STATE(WebVTTTokenizerState, stateNam e)
40 #define WEBVTT_ADVANCE_TO(stateName) ADVANCE_TO(WebVTTTokenizerState, stateName) 41 #define WEBVTT_ADVANCE_TO(stateName) ADVANCE_TO(WebVTTTokenizerState, stateName)
41 42
42 WebVTTTokenizer::WebVTTTokenizer() 43 WebVTTTokenizer::WebVTTTokenizer()
43 : m_inputStreamPreprocessor(this) 44 : m_inputStreamPreprocessor(this)
44 { 45 {
45 reset(); 46 reset();
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 END_STATE() 101 END_STATE()
101 102
102 WEBVTT_BEGIN_STATE(EscapeState) { 103 WEBVTT_BEGIN_STATE(EscapeState) {
103 if (cc == ';') { 104 if (cc == ';') {
104 if (vectorEqualsString(m_buffer, "&amp")) 105 if (vectorEqualsString(m_buffer, "&amp"))
105 bufferCharacter('&'); 106 bufferCharacter('&');
106 else if (vectorEqualsString(m_buffer, "&lt")) 107 else if (vectorEqualsString(m_buffer, "&lt"))
107 bufferCharacter('<'); 108 bufferCharacter('<');
108 else if (vectorEqualsString(m_buffer, "&gt")) 109 else if (vectorEqualsString(m_buffer, "&gt"))
109 bufferCharacter('>'); 110 bufferCharacter('>');
111 else if (vectorEqualsString(m_buffer, "&lrm"))
112 bufferCharacter(leftToRightMark);
113 else if (vectorEqualsString(m_buffer, "&rlm"))
114 bufferCharacter(rightToLeftMark);
115 else if (vectorEqualsString(m_buffer, "&nbsp"))
116 bufferCharacter(noBreakSpace);
110 else { 117 else {
111 m_buffer.append(static_cast<LChar>(cc)); 118 m_buffer.append(static_cast<LChar>(cc));
112 m_token->appendToCharacter(m_buffer); 119 m_token->appendToCharacter(m_buffer);
113 } 120 }
114 m_buffer.clear(); 121 m_buffer.clear();
115 WEBVTT_ADVANCE_TO(DataState); 122 WEBVTT_ADVANCE_TO(DataState);
116 } else if (isASCIIAlphanumeric(cc)) { 123 } else if (isASCIIAlphanumeric(cc)) {
117 m_buffer.append(static_cast<LChar>(cc)); 124 m_buffer.append(static_cast<LChar>(cc));
118 WEBVTT_ADVANCE_TO(EscapeState); 125 WEBVTT_ADVANCE_TO(EscapeState);
119 } else if (cc == kEndOfFileMarker) { 126 } else if (cc == kEndOfFileMarker) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 END_STATE() 226 END_STATE()
220 227
221 } 228 }
222 229
223 ASSERT_NOT_REACHED(); 230 ASSERT_NOT_REACHED();
224 return false; 231 return false;
225 } 232 }
226 233
227 } 234 }
228 235
OLDNEW
« no previous file with comments | « LayoutTests/media/track/track-webvtt-tc022-entities-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698