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

Side by Side Diff: Source/core/html/track/vtt/VTTParser.h

Issue 119143002: Introduce VTTScanner - a parser helper for various VTT parsing needs (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: struct Run -> class Run; explicit constructor; make non-copyable. Created 6 years, 11 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
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/html/track/vtt/VTTParser.cpp » ('j') | 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 29 matching lines...) Expand all
40 #include "core/html/track/vtt/VTTRegion.h" 40 #include "core/html/track/vtt/VTTRegion.h"
41 #include "core/html/track/vtt/VTTTokenizer.h" 41 #include "core/html/track/vtt/VTTTokenizer.h"
42 #include "wtf/PassOwnPtr.h" 42 #include "wtf/PassOwnPtr.h"
43 #include "wtf/text/StringBuilder.h" 43 #include "wtf/text/StringBuilder.h"
44 44
45 namespace WebCore { 45 namespace WebCore {
46 46
47 using namespace HTMLNames; 47 using namespace HTMLNames;
48 48
49 class Document; 49 class Document;
50 class VTTScanner;
50 51
51 class VTTParserClient { 52 class VTTParserClient {
52 public: 53 public:
53 virtual ~VTTParserClient() { } 54 virtual ~VTTParserClient() { }
54 55
55 virtual void newCuesParsed() = 0; 56 virtual void newCuesParsed() = 0;
56 virtual void newRegionsParsed() = 0; 57 virtual void newRegionsParsed() = 0;
57 virtual void fileFailedToParse() = 0; 58 virtual void fileFailedToParse() = 0;
58 }; 59 };
59 60
(...skipping 14 matching lines...) Expand all
74 } 75 }
75 76
76 static inline bool isRecognizedTag(const AtomicString& tagName) 77 static inline bool isRecognizedTag(const AtomicString& tagName)
77 { 78 {
78 return tagName == iTag 79 return tagName == iTag
79 || tagName == bTag 80 || tagName == bTag
80 || tagName == uTag 81 || tagName == uTag
81 || tagName == rubyTag 82 || tagName == rubyTag
82 || tagName == rtTag; 83 || tagName == rtTag;
83 } 84 }
84 85 static inline bool isASpace(UChar c)
85 static inline bool isASpace(char c)
86 { 86 {
87 // WebVTT space characters are U+0020 SPACE, U+0009 CHARACTER TABULATION (tab), U+000A LINE FEED (LF), U+000C FORM FEED (FF), and U+000D CARRIAGE RETURN (CR). 87 // WebVTT space characters are U+0020 SPACE, U+0009 CHARACTER TABULATION (tab), U+000A LINE FEED (LF), U+000C FORM FEED (FF), and U+000D CARRIAGE RETURN (CR).
88 return c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r'; 88 return c == ' ' || c == '\t' || c == '\n' || c == '\f' || c == '\r';
89 } 89 }
90 static inline bool isValidSettingDelimiter(char c) 90 static inline bool isValidSettingDelimiter(UChar c)
91 { 91 {
92 // ... a WebVTT cue consists of zero or more of the following components , in any order, separated from each other by one or more 92 // ... a WebVTT cue consists of zero or more of the following components , in any order, separated from each other by one or more
93 // U+0020 SPACE characters or U+0009 CHARACTER TABULATION (tab) characte rs. 93 // U+0020 SPACE characters or U+0009 CHARACTER TABULATION (tab) characte rs.
94 return c == ' ' || c == '\t'; 94 return c == ' ' || c == '\t';
95 } 95 }
96 static unsigned collectDigitsToInt(const String& input, unsigned* position, int& number); 96 static unsigned collectDigitsToInt(const String& input, unsigned* position, int& number);
97 static String collectWord(const String&, unsigned*); 97 static String collectWord(const String&, unsigned*);
98 static bool collectTimeStamp(const String&, unsigned*, double& timeStamp); 98 static bool collectTimeStamp(const String&, unsigned*, double& timeStamp);
99 99
100 // Useful functions for parsing percentage settings. 100 // Useful functions for parsing percentage settings.
(...skipping 25 matching lines...) Expand all
126 ParseState collectCueText(const String&); 126 ParseState collectCueText(const String&);
127 ParseState recoverCue(const String&); 127 ParseState recoverCue(const String&);
128 ParseState ignoreBadCue(const String&); 128 ParseState ignoreBadCue(const String&);
129 129
130 void createNewCue(); 130 void createNewCue();
131 void resetCueValues(); 131 void resetCueValues();
132 132
133 void collectMetadataHeader(const String&); 133 void collectMetadataHeader(const String&);
134 void createNewRegion(const String& headerValue); 134 void createNewRegion(const String& headerValue);
135 135
136 static void skipWhiteSpace(const String&, unsigned*); 136 static bool collectTimeStamp(VTTScanner& input, double& timeStamp);
137 137
138 BufferedLineReader m_lineReader; 138 BufferedLineReader m_lineReader;
139 OwnPtr<TextResourceDecoder> m_decoder; 139 OwnPtr<TextResourceDecoder> m_decoder;
140 String m_currentId; 140 String m_currentId;
141 double m_currentStartTime; 141 double m_currentStartTime;
142 double m_currentEndTime; 142 double m_currentEndTime;
143 StringBuilder m_currentContent; 143 StringBuilder m_currentContent;
144 String m_currentSettings; 144 String m_currentSettings;
145 145
146 VTTParserClient* m_client; 146 VTTParserClient* m_client;
147 147
148 Vector<RefPtr<VTTCue> > m_cuelist; 148 Vector<RefPtr<VTTCue> > m_cuelist;
149 149
150 Vector<RefPtr<VTTRegion> > m_regionList; 150 Vector<RefPtr<VTTRegion> > m_regionList;
151 }; 151 };
152 152
153 } // namespace WebCore 153 } // namespace WebCore
154 154
155 #endif 155 #endif
OLDNEW
« no previous file with comments | « Source/core/core.gypi ('k') | Source/core/html/track/vtt/VTTParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698