Bug 75646

Summary: Replace TextTrackCue "getCueAsSource" method with "text" attribute
Product: WebKit Reporter: Eric Carlson <eric.carlson>
Component: MediaAssignee: Eric Carlson <eric.carlson>
Status: RESOLVED FIXED    
Severity: Normal CC: abarth, ojan, webkit-bug-importer, webkit.review.bot
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 43668    
Attachments:
Description Flags
Proposed patch darin: review+

Eric Carlson
Reported 2012-01-05 13:05:49 PST
TextTrackCue's 'getCueAsSource' method has been replaced with a mutable 'text' attribute
Attachments
Proposed patch (43.87 KB, patch)
2012-01-09 21:24 PST, Eric Carlson
darin: review+
Eric Carlson
Comment 1 2012-01-09 21:24:04 PST
Created attachment 121788 [details] Proposed patch
Radar WebKit Bug Importer
Comment 2 2012-01-09 21:24:32 PST
Darin Adler
Comment 3 2012-01-10 09:18:27 PST
Comment on attachment 121788 [details] Proposed patch View in context: https://bugs.webkit.org/attachment.cgi?id=121788&action=review > Source/WebCore/html/TextTrackCue.cpp:331 > + OwnPtr<WebVTTParser> parser = WebVTTParser::create(0, m_scriptExecutionContext); > + m_documentFragment = parser->createDocumentFragmentFromCueText(m_content); Could we do this without a local variable? Or would that make the line too long? > Source/WebCore/html/TextTrackCue.h:92 > + String text() const { return m_content; } Seems we should return const String& here instead of String to avoid a bit of reference count churn. > Source/WebCore/html/track/WebVTTParser.cpp:252 > + if (!text.length()) > + return 0; Is it important to optimize the empty string case? Are there other cases we should optimize, such as “all whitespace”? > Source/WebCore/html/track/WebVTTParser.cpp:272 > + if (!m_currentContent.length()) > + return; Why is it important to special-case the empty case? Is that a common case? > Source/WebCore/html/track/WebVTTParser.cpp:274 > + RefPtr<DocumentFragment> attachmentRoot = createDocumentFragmentFromCueText(m_currentContent.toString()); I don’t see a check for 0 here. What guarantees this won’t return 0? > Source/WebCore/html/track/WebVTTParser.h:92 > + PassRefPtr<DocumentFragment> createDocumentFragmentFromCueText(const String&); There’s an extra space here after the > character.
Eric Carlson
Comment 4 2012-01-10 13:18:12 PST
(In reply to comment #3) > (From update of attachment 121788 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=121788&action=review > > > Source/WebCore/html/TextTrackCue.cpp:331 > > + OwnPtr<WebVTTParser> parser = WebVTTParser::create(0, m_scriptExecutionContext); > > + m_documentFragment = parser->createDocumentFragmentFromCueText(m_content); > > Could we do this without a local variable? Or would that make the line too long? > Good suggestion, fixed. > > Source/WebCore/html/TextTrackCue.h:92 > > + String text() const { return m_content; } > > Seems we should return const String& here instead of String to avoid a bit of reference count churn. > Fixed. > > Source/WebCore/html/track/WebVTTParser.cpp:252 > > + if (!text.length()) > > + return 0; > > Is it important to optimize the empty string case? Are there other cases we should optimize, such as “all whitespace”? > > > Source/WebCore/html/track/WebVTTParser.cpp:272 > > + if (!m_currentContent.length()) > > + return; > > Why is it important to special-case the empty case? Is that a common case? > I removed these and found that we have a layout test that checks to make sure no cue is created for an entry without text. I don't see that requirement in the spec, but I am checking with people in the WebVTT community group to see if I am missing something. If it is not a spec requirement, I will write a bug to fix this. > > Source/WebCore/html/track/WebVTTParser.cpp:274 > > + RefPtr<DocumentFragment> attachmentRoot = createDocumentFragmentFromCueText(m_currentContent.toString()); > > I don’t see a check for 0 here. What guarantees this won’t return 0? > A NULL fragment should not be a problem. > > Source/WebCore/html/track/WebVTTParser.h:92 > > + PassRefPtr<DocumentFragment> createDocumentFragmentFromCueText(const String&); > > There’s an extra space here after the > character. Fixed.
Eric Carlson
Comment 5 2012-01-10 13:18:26 PST
Note You need to log in before you can comment on or make changes to this bug.