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

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

Issue 244493002: Oilpan: add transition types to track interface objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 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
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 21 matching lines...) Expand all
32 #define VTTParser_h 32 #define VTTParser_h
33 33
34 #include "HTMLNames.h" 34 #include "HTMLNames.h"
35 #include "RuntimeEnabledFeatures.h" 35 #include "RuntimeEnabledFeatures.h"
36 #include "core/dom/DocumentFragment.h" 36 #include "core/dom/DocumentFragment.h"
37 #include "core/html/parser/TextResourceDecoder.h" 37 #include "core/html/parser/TextResourceDecoder.h"
38 #include "core/html/track/vtt/BufferedLineReader.h" 38 #include "core/html/track/vtt/BufferedLineReader.h"
39 #include "core/html/track/vtt/VTTCue.h" 39 #include "core/html/track/vtt/VTTCue.h"
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 "platform/heap/Handle.h"
42 #include "wtf/PassOwnPtr.h" 43 #include "wtf/PassOwnPtr.h"
43 #include "wtf/text/StringBuilder.h" 44 #include "wtf/text/StringBuilder.h"
44 45
45 namespace WebCore { 46 namespace WebCore {
46 47
47 class Document; 48 class Document;
48 class VTTScanner; 49 class VTTScanner;
49 50
50 class VTTParserClient { 51 class VTTParserClient {
51 public: 52 public:
52 virtual ~VTTParserClient() { } 53 virtual ~VTTParserClient() { }
53 54
54 virtual void newCuesParsed() = 0; 55 virtual void newCuesParsed() = 0;
55 virtual void newRegionsParsed() = 0; 56 virtual void newRegionsParsed() = 0;
56 virtual void fileFailedToParse() = 0; 57 virtual void fileFailedToParse() = 0;
57 }; 58 };
58 59
59 class VTTParser FINAL { 60 class VTTParser FINAL : public NoBaseWillBeGarbageCollectedFinalized<VTTParser> {
60 public: 61 public:
61 enum ParseState { 62 enum ParseState {
62 Initial, 63 Initial,
63 Header, 64 Header,
64 Id, 65 Id,
65 TimingsAndSettings, 66 TimingsAndSettings,
66 CueText, 67 CueText,
67 BadCue 68 BadCue
68 }; 69 };
69 70
70 static PassOwnPtr<VTTParser> create(VTTParserClient* client, Document& docum ent) 71 static PassOwnPtrWillBeRawPtr<VTTParser> create(VTTParserClient* client, Doc ument& document)
71 { 72 {
72 return adoptPtr(new VTTParser(client, document)); 73 return adoptPtrWillBeNoop(new VTTParser(client, document));
73 } 74 }
74 75
75 static inline bool isRecognizedTag(const AtomicString& tagName) 76 static inline bool isRecognizedTag(const AtomicString& tagName)
76 { 77 {
77 return tagName == HTMLNames::iTag 78 return tagName == HTMLNames::iTag
78 || tagName == HTMLNames::bTag 79 || tagName == HTMLNames::bTag
79 || tagName == HTMLNames::uTag 80 || tagName == HTMLNames::uTag
80 || tagName == HTMLNames::rubyTag 81 || tagName == HTMLNames::rubyTag
81 || tagName == HTMLNames::rtTag; 82 || tagName == HTMLNames::rtTag;
82 } 83 }
(...skipping 15 matching lines...) Expand all
98 static bool parseFloatPercentageValuePair(VTTScanner&, char, FloatPoint&); 99 static bool parseFloatPercentageValuePair(VTTScanner&, char, FloatPoint&);
99 100
100 // Create the DocumentFragment representation of the WebVTT cue text. 101 // Create the DocumentFragment representation of the WebVTT cue text.
101 static PassRefPtr<DocumentFragment> createDocumentFragmentFromCueText(Docume nt&, const String&); 102 static PassRefPtr<DocumentFragment> createDocumentFragmentFromCueText(Docume nt&, const String&);
102 103
103 // Input data to the parser to parse. 104 // Input data to the parser to parse.
104 void parseBytes(const char* data, unsigned length); 105 void parseBytes(const char* data, unsigned length);
105 void flush(); 106 void flush();
106 107
107 // Transfers ownership of last parsed cues to caller. 108 // Transfers ownership of last parsed cues to caller.
108 void getNewCues(Vector<RefPtr<VTTCue> >&); 109 void getNewCues(WillBeHeapVector<RefPtrWillBeMember<VTTCue> >&);
109 void getNewRegions(Vector<RefPtr<VTTRegion> >&); 110 void getNewRegions(WillBeHeapVector<RefPtrWillBeMember<VTTRegion> >&);
111
112 void trace(Visitor*);
110 113
111 private: 114 private:
112 VTTParser(VTTParserClient*, Document&); 115 VTTParser(VTTParserClient*, Document&);
113 116
114 Document* m_document; 117 Document* m_document;
haraken 2014/04/21 01:30:54 Let me confirm: The VTTParser object can outlive t
sof 2014/04/21 15:23:42 The client object is owned by a media element (by
115 ParseState m_state; 118 ParseState m_state;
116 119
117 void parse(); 120 void parse();
118 void flushPendingCue(); 121 void flushPendingCue();
119 bool hasRequiredFileIdentifier(const String& line); 122 bool hasRequiredFileIdentifier(const String& line);
120 ParseState collectCueId(const String&); 123 ParseState collectCueId(const String&);
121 ParseState collectTimingsAndSettings(const String&); 124 ParseState collectTimingsAndSettings(const String&);
122 ParseState collectCueText(const String&); 125 ParseState collectCueText(const String&);
123 ParseState recoverCue(const String&); 126 ParseState recoverCue(const String&);
124 ParseState ignoreBadCue(const String&); 127 ParseState ignoreBadCue(const String&);
125 128
126 void createNewCue(); 129 void createNewCue();
127 void resetCueValues(); 130 void resetCueValues();
128 131
129 void collectMetadataHeader(const String&); 132 void collectMetadataHeader(const String&);
130 void createNewRegion(const String& headerValue); 133 void createNewRegion(const String& headerValue);
131 134
132 static bool collectTimeStamp(VTTScanner& input, double& timeStamp); 135 static bool collectTimeStamp(VTTScanner& input, double& timeStamp);
133 136
134 BufferedLineReader m_lineReader; 137 BufferedLineReader m_lineReader;
135 OwnPtr<TextResourceDecoder> m_decoder; 138 OwnPtr<TextResourceDecoder> m_decoder;
136 AtomicString m_currentId; 139 AtomicString m_currentId;
137 double m_currentStartTime; 140 double m_currentStartTime;
138 double m_currentEndTime; 141 double m_currentEndTime;
139 StringBuilder m_currentContent; 142 StringBuilder m_currentContent;
140 String m_currentSettings; 143 String m_currentSettings;
141 144
142 VTTParserClient* m_client; 145 VTTParserClient* m_client;
haraken 2014/04/21 01:30:54 Let me confirm: The VTTParser object can outlive t
sof 2014/04/21 15:23:42 That is correct; TextTrackLoader is the only clien
143 146
144 Vector<RefPtr<VTTCue> > m_cuelist; 147 WillBeHeapVector<RefPtrWillBeMember<VTTCue> > m_cueList;
145 148
146 Vector<RefPtr<VTTRegion> > m_regionList; 149 WillBeHeapVector<RefPtrWillBeMember<VTTRegion> > m_regionList;
147 }; 150 };
148 151
149 } // namespace WebCore 152 } // namespace WebCore
150 153
151 #endif 154 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698