Changeset 164498 in webkit
- Timestamp:
- Feb 21, 2014, 2:04:06 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 41 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r164477 r164498 1911 1911 platform/graphics/PathTraversalState.cpp 1912 1912 platform/graphics/Pattern.cpp 1913 platform/graphics/PlatformTimeRanges.cpp 1913 1914 platform/graphics/Region.cpp 1914 1915 platform/graphics/RoundedRect.cpp -
trunk/Source/WebCore/ChangeLog
r164497 r164498 1 2014-02-21 Eric Carlson <eric.carlson@apple.com> 2 3 Fix TimeRanges layering violations 4 https://bugs.webkit.org/show_bug.cgi?id=128717 5 6 Reviewed by Jer Noble. 7 8 No new tests, no functionality changed. 9 10 * CMakeLists.txt: 11 * GNUmakefile.list.am: Add PlatformTimeRanges. 12 13 * Modules/mediasource/MediaSource.cpp: 14 (WebCore::MediaSource::buffered): TimeRanges -> PlatformTimeRanges. 15 * Modules/mediasource/MediaSource.h: 16 17 * Modules/mediasource/SourceBuffer.cpp: 18 (WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample): TimeRanges* -> TimeRanges&. 19 20 * WebCore.exp.in: Update for signature changes. 21 22 * WebCore.vcxproj/WebCore.vcxproj: 23 * WebCore.vcxproj/WebCore.vcxproj.filters: 24 * WebCore.xcodeproj/project.pbxproj: Add PlatformTimeRanges. 25 26 * html/HTMLMediaElement.cpp: 27 (WebCore::HTMLMediaElement::percentLoaded): Create TimeRanges from PlatformTimeRanges. 28 (WebCore::HTMLMediaElement::buffered): Ditto. 29 (WebCore::HTMLMediaElement::seekable): Ditto. 30 31 * html/MediaController.cpp: 32 (MediaController::buffered): TimeRanges* -> TimeRanges&. 33 (MediaController::seekable): Ditto. 34 (MediaController::played): Ditto. 35 36 Move all of the logic into PlatformTimeRanges. Change API to take TimeRanges& instead of TimeRanges*. 37 * html/TimeRanges.cpp: 38 (WebCore::TimeRanges::create): Move to .cpp from .h. 39 (WebCore::TimeRanges::TimeRanges): Initialize the PlatformTimeRanges member variable. 40 (WebCore::TimeRanges::start): Passthrough to PlatformTimeRanges. 41 (WebCore::TimeRanges::end): Ditto. 42 (WebCore::TimeRanges::invert): Ditto. 43 (WebCore::TimeRanges::copy): Ditto. 44 (WebCore::TimeRanges::intersectWith): Ditto. 45 (WebCore::TimeRanges::unionWith): Ditto. 46 (WebCore::TimeRanges::length): Ditto. 47 (WebCore::TimeRanges::add): Ditto. 48 (WebCore::TimeRanges::contain): Ditto. 49 (WebCore::TimeRanges::find): Ditto. 50 (WebCore::TimeRanges::nearest): Ditto. 51 (WebCore::TimeRanges::totalDuration): Ditto. 52 * html/TimeRanges.h: 53 54 * platform/graphics/MediaPlayer.cpp: 55 (WebCore::NullMediaPlayerPrivate::buffered): TimeRanges -> PlatformTimeRanges. 56 (WebCore::MediaPlayer::buffered): Ditto. 57 (WebCore::MediaPlayer::seekable): Ditto. 58 * platform/graphics/MediaPlayer.h: 59 * platform/graphics/MediaPlayerPrivate.h: 60 61 * platform/graphics/MediaSourcePrivateClient.h: 62 63 * platform/graphics/PlatformTimeRanges.cpp: Added. 64 * platform/graphics/PlatformTimeRanges.h: Added. 65 66 * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp: 67 (WebCore::MediaPlayerPrivateAVFoundation::buffered): TimeRanges -> PlatformTimeRanges. 68 (WebCore::MediaPlayerPrivateAVFoundation::loadedTimeRangesChanged): Drive-by fix to log 69 FunctionType notifications. ASSERT when passed an unknown notification. 70 71 * platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h: 72 * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp: 73 (WebCore::MediaPlayerPrivateAVFoundationCF::platformBufferedTimeRanges): TimeRanges -> PlatformTimeRanges. 74 * platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h: 75 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h: 76 * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm: 77 (WebCore::MediaPlayerPrivateAVFoundationObjC::currentTime): Ditto. 78 (WebCore::MediaPlayerPrivateAVFoundationObjC::platformBufferedTimeRanges): Ditto. 79 80 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h: 81 * platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm: 82 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekable): Ditto. 83 (WebCore::MediaPlayerPrivateMediaSourceAVFObjC::buffered): Ditto. 84 85 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp: 86 (WebCore::MediaPlayerPrivateGStreamer::buffered): Ditto. 87 * platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h: 88 89 * platform/graphics/ios/MediaPlayerPrivateIOS.h: 90 * platform/graphics/ios/MediaPlayerPrivateIOS.mm: 91 (WebCore::MediaPlayerPrivateIOS::buffered): Ditto. 92 93 * platform/graphics/mac/MediaPlayerPrivateQTKit.h: 94 * platform/graphics/mac/MediaPlayerPrivateQTKit.mm: 95 (WebCore::MediaPlayerPrivateQTKit::buffered): Ditto. 96 97 * platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp: 98 (WebCore::MediaPlayerPrivateQuickTimeVisualContext::buffered): Ditto. 99 * platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h: 100 101 * platform/graphics/wince/MediaPlayerPrivateWinCE.h: 102 103 * platform/mock/mediasource/MockMediaPlayerMediaSource.cpp: 104 (WebCore::MockMediaPlayerMediaSource::buffered): Ditto. 105 (WebCore::MockMediaPlayerMediaSource::advanceCurrentTime): Ditto. 106 * platform/mock/mediasource/MockMediaPlayerMediaSource.h: 107 1 108 2014-02-21 Enrica Casucci <enrica@apple.com> 2 109 -
trunk/Source/WebCore/GNUmakefile.list.am
r164477 r164498 5339 5339 Source/WebCore/platform/graphics/MediaPlayer.h \ 5340 5340 Source/WebCore/platform/graphics/MediaPlayerPrivate.h \ 5341 Source/WebCore/platform/graphics/PlatformTimeRanges.cpp \ 5342 Source/WebCore/platform/graphics/PlatformTimeRanges.h \ 5341 5343 Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp \ 5342 5344 Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.cpp \ -
trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp
r163816 r164498 132 132 } 133 133 134 PassRefPtr<TimeRanges> MediaSource::buffered() const134 std::unique_ptr<PlatformTimeRanges> MediaSource::buffered() const 135 135 { 136 136 // Implements MediaSource algorithm for HTMLMediaElement.buffered. … … 140 140 // 1. If activeSourceBuffers.length equals 0 then return an empty TimeRanges object and abort these steps. 141 141 if (ranges.isEmpty()) 142 return TimeRanges::create();142 return PlatformTimeRanges::create(); 143 143 144 144 // 2. Let active ranges be the ranges returned by buffered for each SourceBuffer object in activeSourceBuffers. … … 153 153 // Return an empty range if all ranges are empty. 154 154 if (highestEndTime < 0) 155 return TimeRanges::create();155 return PlatformTimeRanges::create(); 156 156 157 157 // 4. Let intersection ranges equal a TimeRange object containing a single range from 0 to highest end time. … … 170 170 // 5.3 Let new intersection ranges equal the the intersection between the intersection ranges and the source ranges. 171 171 // 5.4 Replace the ranges in intersection ranges with the new intersection ranges. 172 intersectionRanges->intersectWith( sourceRanges);173 } 174 175 return intersectionRanges.release();172 intersectionRanges->intersectWith(*sourceRanges); 173 } 174 175 return PlatformTimeRanges::create(intersectionRanges->ranges()); 176 176 } 177 177 -
trunk/Source/WebCore/Modules/mediasource/MediaSource.h
r163816 r164498 73 73 virtual void setPrivateAndOpen(PassRef<MediaSourcePrivate>) override; 74 74 virtual double duration() const override; 75 virtual PassRefPtr<TimeRanges> buffered() const override;75 virtual std::unique_ptr<PlatformTimeRanges> buffered() const override; 76 76 77 77 bool attachToElement(HTMLMediaElement*); -
trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp
r161768 r164498 968 968 969 969 erasedRanges->invert(); 970 m_buffered->intersectWith( erasedRanges.get());970 m_buffered->intersectWith(*erasedRanges.get()); 971 971 } 972 972 -
trunk/Source/WebCore/WebCore.exp.in
r164497 r164498 1424 1424 __ZN7WebCore9unionRectERKN3WTF6VectorINS_9FloatRectELm0ENS0_15CrashOnOverflowEEE 1425 1425 __ZN7WebCore10Pasteboard21createForCopyAndPasteEv 1426 __ZN7WebCore10TimeRanges13intersectWithEPKS0_ 1426 __ZN7WebCore10TimeRanges6createEv 1427 __ZN7WebCore10TimeRanges6createEdd 1427 1428 __ZN7WebCore10TimeRangesC1Edd 1429 __ZN7WebCore10TimeRanges13intersectWithERKS0_ 1428 1430 __ZN7WebCore13SelectionRectC1ERKNS_7IntRectEbi 1429 1431 __ZNK3JSC8Bindings10RootObject12globalObjectEv … … 1463 1465 __ZNK7WebCore10TimeRanges4copyEv 1464 1466 __ZNK7WebCore10TimeRanges5startEjRi 1467 __ZNK7WebCore10TimeRanges6lengthEv 1465 1468 __ZNK7WebCore11FrameLoader10isCompleteEv 1466 1469 __ZNK7WebCore11FrameLoader14cancelledErrorERKNS_15ResourceRequestE -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj
r164477 r164498 7676 7676 <ClCompile Include="..\platform\graphics\PathTraversalState.cpp" /> 7677 7677 <ClCompile Include="..\platform\graphics\Pattern.cpp" /> 7678 <ClCompile Include="..\platform\graphics\PlatformTimeRanges.cpp" /> 7678 7679 <ClCompile Include="..\platform\graphics\Region.cpp" /> 7679 7680 <ClCompile Include="..\platform\graphics\RoundedRect.cpp" /> … … 19112 19113 <ClInclude Include="..\platform\graphics\Pattern.h" /> 19113 19114 <ClInclude Include="..\platform\graphics\PlatformLayer.h" /> 19115 <ClInclude Include="..\platform\graphics\PlatformTimeRanges.h" /> 19114 19116 <ClInclude Include="..\platform\graphics\Region.h" /> 19115 19117 <ClInclude Include="..\platform\graphics\RoundedRect.h" /> -
trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters
r164477 r164498 1384 1384 <Filter>platform\graphics</Filter> 1385 1385 </ClCompile> 1386 <ClCompile Include="..\platform\graphics\PlatformTimeRanges.cpp"> 1387 <Filter>platform\graphics</Filter> 1388 </ClCompile> 1386 1389 <ClCompile Include="..\platform\graphics\RoundedRect.cpp"> 1387 1390 <Filter>platform\graphics</Filter> … … 8323 8326 </ClInclude> 8324 8327 <ClInclude Include="..\platform\graphics\PlatformLayer.h"> 8328 <Filter>platform\graphics</Filter> 8329 </ClInclude> 8330 <ClInclude Include="..\platform\graphics\PlatformTimeRanges.h"> 8325 8331 <Filter>platform\graphics</Filter> 8326 8332 </ClInclude> -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r164477 r164498 173 173 074300A50F4B8BCF008076CD /* MediaPlayerPrivateIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 074300A30F4B8BCF008076CD /* MediaPlayerPrivateIOS.mm */; }; 174 174 074300A60F4B8BCF008076CD /* MediaPlayerPrivateIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 074300A40F4B8BCF008076CD /* MediaPlayerPrivateIOS.h */; }; 175 074E82BA18A69F0E007EF54C /* PlatformTimeRanges.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 074E82B818A69F0E007EF54C /* PlatformTimeRanges.cpp */; }; 176 074E82BB18A69F0E007EF54C /* PlatformTimeRanges.h in Headers */ = {isa = PBXBuildFile; fileRef = 074E82B918A69F0E007EF54C /* PlatformTimeRanges.h */; settings = {ATTRIBUTES = (Private, ); }; }; 175 177 0753860214489E9800B78452 /* CachedTextTrack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0753860014489E9800B78452 /* CachedTextTrack.cpp */; }; 176 178 0753860314489E9800B78452 /* CachedTextTrack.h in Headers */ = {isa = PBXBuildFile; fileRef = 0753860114489E9800B78452 /* CachedTextTrack.h */; }; … … 6962 6964 074300A30F4B8BCF008076CD /* MediaPlayerPrivateIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaPlayerPrivateIOS.mm; sourceTree = "<group>"; }; 6963 6965 074300A40F4B8BCF008076CD /* MediaPlayerPrivateIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaPlayerPrivateIOS.h; sourceTree = "<group>"; }; 6966 074E82B818A69F0E007EF54C /* PlatformTimeRanges.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformTimeRanges.cpp; sourceTree = "<group>"; }; 6967 074E82B918A69F0E007EF54C /* PlatformTimeRanges.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformTimeRanges.h; sourceTree = "<group>"; }; 6964 6968 0753860014489E9800B78452 /* CachedTextTrack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedTextTrack.cpp; sourceTree = "<group>"; }; 6965 6969 0753860114489E9800B78452 /* CachedTextTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedTextTrack.h; sourceTree = "<group>"; }; … … 19900 19904 072847E216EBC5B00043CFA4 /* PlatformTextTrack.h */, 19901 19905 072847E316EBC5B00043CFA4 /* PlatformTextTrackMenu.h */, 19906 074E82B818A69F0E007EF54C /* PlatformTimeRanges.cpp */, 19907 074E82B918A69F0E007EF54C /* PlatformTimeRanges.h */, 19902 19908 BCAB417F13E356E800D8AAF3 /* Region.cpp */, 19903 19909 BCAB418013E356E800D8AAF3 /* Region.h */, … … 24838 24844 297BE3D716C03C0E003316BD /* PlatformSpeechSynthesizer.h in Headers */, 24839 24845 1AD8F81B11CAB9E900E93E54 /* PlatformStrategies.h in Headers */, 24846 074E82BB18A69F0E007EF54C /* PlatformTimeRanges.h in Headers */, 24840 24847 935C476B09AC4D4F00A6AAB4 /* PlatformWheelEvent.h in Headers */, 24841 24848 31D591B316697A6C00E6BF02 /* PlugInClient.h in Headers */, … … 28219 28226 297BE3D816C03CCE003316BD /* PlatformSpeechSynthesizerMac.mm in Sources */, 28220 28227 1AD8F81C11CAB9E900E93E54 /* PlatformStrategies.cpp in Sources */, 28228 074E82BA18A69F0E007EF54C /* PlatformTimeRanges.cpp in Sources */, 28221 28229 A9C6E4F30D745E48006442E9 /* PluginData.cpp in Sources */, 28222 28230 97205ABB1239292700B17380 /* PluginDocument.cpp in Sources */, -
trunk/Source/WebCore/html/HTMLMediaElement.cpp
r164318 r164498 3076 3076 3077 3077 double buffered = 0; 3078 RefPtr<TimeRanges> timeRanges = m_player->buffered(); 3078 bool ignored; 3079 std::unique_ptr<PlatformTimeRanges> timeRanges = m_player->buffered(); 3079 3080 for (unsigned i = 0; i < timeRanges->length(); ++i) { 3080 double start = timeRanges->start(i, IGNORE_EXCEPTION);3081 double end = timeRanges->end(i, IGNORE_EXCEPTION);3081 double start = timeRanges->start(i, ignored); 3082 double end = timeRanges->end(i, ignored); 3082 3083 buffered += end - start; 3083 3084 } … … 4113 4114 #if ENABLE(MEDIA_SOURCE) 4114 4115 if (m_mediaSource) 4115 return m_mediaSource->buffered();4116 #endif 4117 4118 return m_player->buffered();4116 return TimeRanges::create(*m_mediaSource->buffered()); 4117 #endif 4118 4119 return TimeRanges::create(*m_player->buffered()); 4119 4120 } 4120 4121 … … 4135 4136 PassRefPtr<TimeRanges> HTMLMediaElement::seekable() const 4136 4137 { 4137 return m_player ? m_player->seekable() : TimeRanges::create(); 4138 if (m_player) 4139 return TimeRanges::create(*m_player->seekable()); 4140 4141 return TimeRanges::create(); 4138 4142 } 4139 4143 -
trunk/Source/WebCore/html/MediaController.cpp
r164365 r164498 96 96 RefPtr<TimeRanges> bufferedRanges = m_mediaElements.first()->buffered(); 97 97 for (size_t index = 1; index < m_mediaElements.size(); ++index) 98 bufferedRanges->intersectWith( m_mediaElements[index]->buffered().get());98 bufferedRanges->intersectWith(*m_mediaElements[index]->buffered().get()); 99 99 return bufferedRanges; 100 100 } … … 110 110 RefPtr<TimeRanges> seekableRanges = m_mediaElements.first()->seekable(); 111 111 for (size_t index = 1; index < m_mediaElements.size(); ++index) 112 seekableRanges->intersectWith( m_mediaElements[index]->seekable().get());112 seekableRanges->intersectWith(*m_mediaElements[index]->seekable().get()); 113 113 return seekableRanges; 114 114 } … … 124 124 RefPtr<TimeRanges> playedRanges = m_mediaElements.first()->played(); 125 125 for (size_t index = 1; index < m_mediaElements.size(); ++index) 126 playedRanges->unionWith( m_mediaElements[index]->played().get());126 playedRanges->unionWith(*m_mediaElements[index]->played().get()); 127 127 return playedRanges; 128 128 } -
trunk/Source/WebCore/html/TimeRanges.cpp
r160749 r164498 30 30 #include "ExceptionCode.h" 31 31 #include "ExceptionCodePlaceholder.h" 32 #include <math.h>33 32 34 33 namespace WebCore { 35 34 35 PassRefPtr<TimeRanges> TimeRanges::create() 36 { 37 return adoptRef(new TimeRanges); 38 } 39 40 PassRefPtr<TimeRanges> TimeRanges::create(double start, double end) 41 { 42 return adoptRef(new TimeRanges(start, end)); 43 } 44 45 PassRefPtr<TimeRanges> TimeRanges::create(const PlatformTimeRanges& other) 46 { 47 return adoptRef(new TimeRanges(other)); 48 } 49 50 TimeRanges::TimeRanges() 51 { 52 } 53 36 54 TimeRanges::TimeRanges(double start, double end) 55 : m_ranges(PlatformTimeRanges(start, end)) 37 56 { 38 add(start, end); 57 } 58 59 TimeRanges::TimeRanges(const PlatformTimeRanges& other) 60 : m_ranges(other) 61 { 62 } 63 64 double TimeRanges::start(unsigned index, ExceptionCode& ec) const 65 { 66 bool valid; 67 double result = m_ranges.start(index, valid); 68 69 if (!valid) { 70 ec = INDEX_SIZE_ERR; 71 return 0; 72 } 73 return result; 74 } 75 76 double TimeRanges::end(unsigned index, ExceptionCode& ec) const 77 { 78 bool valid; 79 double result = m_ranges.end(index, valid); 80 81 if (!valid) { 82 ec = INDEX_SIZE_ERR; 83 return 0; 84 } 85 return result; 86 } 87 88 void TimeRanges::invert() 89 { 90 m_ranges.invert(); 39 91 } 40 92 41 93 PassRefPtr<TimeRanges> TimeRanges::copy() const 42 94 { 43 RefPtr<TimeRanges> newSession = TimeRanges::create(); 44 45 unsigned size = m_ranges.size(); 46 for (unsigned i = 0; i < size; i++) 47 newSession->add(m_ranges[i].m_start, m_ranges[i].m_end); 48 49 return newSession.release(); 95 return TimeRanges::create(m_ranges); 50 96 } 51 97 52 void TimeRanges::in vert()98 void TimeRanges::intersectWith(const TimeRanges& other) 53 99 { 54 RefPtr<TimeRanges> inverted = TimeRanges::create(); 55 double posInf = std::numeric_limits<double>::infinity(); 56 double negInf = -std::numeric_limits<double>::infinity(); 57 58 if (!m_ranges.size()) 59 inverted->add(negInf, posInf); 60 else { 61 double start = m_ranges.first().m_start; 62 if (start != negInf) 63 inverted->add(negInf, start); 64 65 for (size_t index = 0; index + 1 < m_ranges.size(); ++index) 66 inverted->add(m_ranges[index].m_end, m_ranges[index + 1].m_start); 67 68 double end = m_ranges.last().m_end; 69 if (end != posInf) 70 inverted->add(end, posInf); 71 } 72 73 m_ranges.swap(inverted->m_ranges); 100 m_ranges.intersectWith(other.ranges()); 74 101 } 75 102 76 void TimeRanges:: intersectWith(const TimeRanges*other)103 void TimeRanges::unionWith(const TimeRanges& other) 77 104 { 78 ASSERT(other); 79 80 if (other == this) 81 return; 82 83 RefPtr<TimeRanges> invertedOther = other->copy(); 84 invertedOther->invert(); 85 86 invert(); 87 unionWith(invertedOther.get()); 88 invert(); 105 m_ranges.unionWith(other.ranges()); 89 106 } 90 107 91 void TimeRanges::unionWith(const TimeRanges* other) 108 unsigned TimeRanges::length() const 92 109 { 93 ASSERT(other); 94 RefPtr<TimeRanges> unioned = copy(); 95 for (size_t index = 0; index < other->m_ranges.size(); ++index) { 96 const Range& range = other->m_ranges[index]; 97 unioned->add(range.m_start, range.m_end); 98 } 99 100 m_ranges.swap(unioned->m_ranges); 110 return m_ranges.length(); 101 111 } 102 112 103 double TimeRanges::start(unsigned index, ExceptionCode& ec) const 104 { 105 if (index >= length()) { 106 ec = INDEX_SIZE_ERR; 107 return 0; 108 } 109 return m_ranges[index].m_start; 110 } 111 112 double TimeRanges::end(unsigned index, ExceptionCode& ec) const 113 { 114 if (index >= length()) { 115 ec = INDEX_SIZE_ERR; 116 return 0; 117 } 118 return m_ranges[index].m_end; 119 } 120 121 void TimeRanges::add(double start, double end) 113 void TimeRanges::add(double start, double end) 122 114 { 123 ASSERT(start <= end); 124 unsigned int overlappingArcIndex; 125 Range addedRange(start, end); 126 127 // For each present range check if we need to: 128 // - merge with the added range, in case we are overlapping or contiguous 129 // - Need to insert in place, we we are completely, not overlapping and not contiguous 130 // in between two ranges. 131 // 132 // TODO: Given that we assume that ranges are correctly ordered, this could be optimized. 133 134 for (overlappingArcIndex = 0; overlappingArcIndex < m_ranges.size(); overlappingArcIndex++) { 135 if (addedRange.isOverlappingRange(m_ranges[overlappingArcIndex]) 136 || addedRange.isContiguousWithRange(m_ranges[overlappingArcIndex])) { 137 // We need to merge the addedRange and that range. 138 addedRange = addedRange.unionWithOverlappingOrContiguousRange(m_ranges[overlappingArcIndex]); 139 m_ranges.remove(overlappingArcIndex); 140 overlappingArcIndex--; 141 } else { 142 // Check the case for which there is no more to do 143 if (!overlappingArcIndex) { 144 if (addedRange.isBeforeRange(m_ranges[0])) { 145 // First index, and we are completely before that range (and not contiguous, nor overlapping). 146 // We just need to be inserted here. 147 break; 148 } 149 } else { 150 if (m_ranges[overlappingArcIndex - 1].isBeforeRange(addedRange) 151 && addedRange.isBeforeRange(m_ranges[overlappingArcIndex])) { 152 // We are exactly after the current previous range, and before the current range, while 153 // not overlapping with none of them. Insert here. 154 break; 155 } 156 } 157 } 158 } 159 160 // Now that we are sure we don't overlap with any range, just add it. 161 m_ranges.insert(overlappingArcIndex, addedRange); 115 m_ranges.add(start, end); 162 116 } 163 117 164 118 bool TimeRanges::contain(double time) const 165 119 { 166 return find(time) != notFound;120 return m_ranges.contain(time); 167 121 } 168 122 169 123 size_t TimeRanges::find(double time) const 170 124 { 171 for (unsigned n = 0; n < length(); n++) { 172 if (time >= start(n, IGNORE_EXCEPTION) && time <= end(n, IGNORE_EXCEPTION)) 173 return n; 174 } 175 return notFound; 125 return m_ranges.find(time); 176 126 } 177 127 178 128 double TimeRanges::nearest(double time) const 179 129 { 180 double closestDelta = std::numeric_limits<double>::infinity(); 181 double closestTime = 0; 182 unsigned count = length(); 183 for (unsigned ndx = 0; ndx < count; ndx++) { 184 double startTime = start(ndx, IGNORE_EXCEPTION); 185 double endTime = end(ndx, IGNORE_EXCEPTION); 186 if (time >= startTime && time <= endTime) 187 return time; 188 if (fabs(startTime - time) < closestDelta) { 189 closestTime = startTime; 190 closestDelta = fabsf(startTime - time); 191 } 192 if (fabs(endTime - time) < closestDelta) { 193 closestTime = endTime; 194 closestDelta = fabsf(endTime - time); 195 } 196 } 197 return closestTime; 130 return m_ranges.nearest(time); 198 131 } 199 132 200 133 double TimeRanges::totalDuration() const 201 134 { 202 double total = 0; 203 for (unsigned n = 0; n < length(); n++) 204 total += fabs(end(n, IGNORE_EXCEPTION) - start(n, IGNORE_EXCEPTION)); 205 return total; 135 return m_ranges.totalDuration(); 206 136 } 207 137 -
trunk/Source/WebCore/html/TimeRanges.h
r158821 r164498 27 27 #define TimeRanges_h 28 28 29 #include "PlatformTimeRanges.h" 29 30 #include <algorithm> 30 31 #include <wtf/PassRefPtr.h> … … 38 39 class TimeRanges : public RefCounted<TimeRanges> { 39 40 public: 40 static PassRefPtr<TimeRanges> create() 41 { 42 return adoptRef(new TimeRanges); 43 } 44 static PassRefPtr<TimeRanges> create(double start, double end) 45 { 46 return adoptRef(new TimeRanges(start, end)); 47 } 41 static PassRefPtr<TimeRanges> create(); 42 static PassRefPtr<TimeRanges> create(double start, double end); 43 static PassRefPtr<TimeRanges> create(const PlatformTimeRanges&); 44 45 double start(unsigned index, ExceptionCode&) const; 46 double end(unsigned index, ExceptionCode&) const; 48 47 49 48 PassRefPtr<TimeRanges> copy() const; 50 49 void invert(); 51 void intersectWith(const TimeRanges*); 52 void unionWith(const TimeRanges*); 53 54 unsigned length() const { return m_ranges.size(); } 55 double start(unsigned index, ExceptionCode&) const; 56 double end(unsigned index, ExceptionCode&) const; 50 void intersectWith(const TimeRanges&); 51 void unionWith(const TimeRanges&); 52 53 unsigned length() const; 57 54 58 55 void add(double start, double end); 56 bool contain(double time) const; 59 57 60 bool contain(double time) const;61 62 58 size_t find(double time) const; 63 64 59 double nearest(double time) const; 65 66 60 double totalDuration() const; 67 61 62 const PlatformTimeRanges& ranges() const { return m_ranges; } 63 68 64 private: 69 TimeRanges() { }65 explicit TimeRanges(); 70 66 TimeRanges(double start, double end); 71 TimeRanges(const TimeRanges&);67 TimeRanges(const PlatformTimeRanges&); 72 68 73 // We consider all the Ranges to be semi-bounded as follow: [start, end[74 struct Range {75 Range() { }76 Range(double start, double end)77 {78 m_start = start;79 m_end = end;80 }81 double m_start;82 double m_end;83 69 84 inline bool isPointInRange(double point) const 85 { 86 return m_start <= point && point < m_end; 87 } 88 89 inline bool isOverlappingRange(const Range& range) const 90 { 91 return isPointInRange(range.m_start) || isPointInRange(range.m_end) || range.isPointInRange(m_start); 92 } 93 94 inline bool isContiguousWithRange(const Range& range) const 95 { 96 return range.m_start == m_end || range.m_end == m_start; 97 } 98 99 inline Range unionWithOverlappingOrContiguousRange(const Range& range) const 100 { 101 Range ret; 102 103 ret.m_start = std::min(m_start, range.m_start); 104 ret.m_end = std::max(m_end, range.m_end); 105 106 return ret; 107 } 108 109 inline bool isBeforeRange(const Range& range) const 110 { 111 return range.m_start >= m_end; 112 } 113 }; 114 115 Vector<Range> m_ranges; 70 PlatformTimeRanges m_ranges; 116 71 }; 117 72 -
trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp
r164358 r164498 37 37 #include "MIMETypeRegistry.h" 38 38 #include "MediaPlayerPrivate.h" 39 #include "PlatformTimeRanges.h" 39 40 #include "Settings.h" 40 #include "TimeRanges.h"41 41 #include <wtf/text/CString.h> 42 42 … … 128 128 virtual double maxTimeSeekableDouble() const { return 0; } 129 129 virtual double minTimeSeekable() const { return 0; } 130 virtual PassRefPtr<TimeRanges> buffered() const { returnTimeRanges::create(); }130 virtual std::unique_ptr<PlatformTimeRanges> buffered() const { return PlatformTimeRanges::create(); } 131 131 132 132 virtual unsigned totalBytes() const { return 0; } … … 704 704 } 705 705 706 PassRefPtr<TimeRanges> MediaPlayer::buffered()706 std::unique_ptr<PlatformTimeRanges> MediaPlayer::buffered() 707 707 { 708 708 return m_private->buffered(); 709 709 } 710 710 711 PassRefPtr<TimeRanges> MediaPlayer::seekable()711 std::unique_ptr<PlatformTimeRanges> MediaPlayer::seekable() 712 712 { 713 713 return m_private->seekable(); -
trunk/Source/WebCore/platform/graphics/MediaPlayer.h
r163907 r164498 129 129 class GraphicsContext; 130 130 class GraphicsContext3D; 131 class HostWindow; 131 132 class IntRect; 132 133 class IntSize; 133 134 class MediaPlayer; 134 135 struct MediaPlayerFactory; 135 class TimeRanges; 136 class HostWindow; 136 class PlatformTimeRanges; 137 137 138 138 #if PLATFORM(WIN) && USE(AVFOUNDATION) … … 353 353 void setPreservesPitch(bool); 354 354 355 PassRefPtr<TimeRanges> buffered();356 PassRefPtr<TimeRanges> seekable();355 std::unique_ptr<PlatformTimeRanges> buffered(); 356 std::unique_ptr<PlatformTimeRanges> seekable(); 357 357 double minTimeSeekable(); 358 358 double maxTimeSeekable(); -
trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h
r164160 r164498 30 30 31 31 #include "MediaPlayer.h" 32 #include " TimeRanges.h"32 #include "PlatformTimeRanges.h" 33 33 #include <wtf/Forward.h> 34 #include <wtf/OwnPtr.h> 34 35 35 36 namespace WebCore { … … 109 110 virtual MediaPlayer::ReadyState readyState() const = 0; 110 111 111 virtual PassRefPtr<TimeRanges> seekable() const { return maxTimeSeekableDouble() ? TimeRanges::create(minTimeSeekable(), maxTimeSeekableDouble()) :TimeRanges::create(); }112 virtual std::unique_ptr<PlatformTimeRanges> seekable() const { return maxTimeSeekableDouble() ? PlatformTimeRanges::create(minTimeSeekable(), maxTimeSeekableDouble()) : PlatformTimeRanges::create(); } 112 113 virtual float maxTimeSeekable() const { return 0; } 113 114 virtual double maxTimeSeekableDouble() const { return maxTimeSeekable(); } 114 115 virtual double minTimeSeekable() const { return 0; } 115 virtual PassRefPtr<TimeRanges> buffered() const = 0;116 virtual std::unique_ptr<PlatformTimeRanges> buffered() const = 0; 116 117 117 118 virtual bool didLoadingProgress() const = 0; -
trunk/Source/WebCore/platform/graphics/MediaSourcePrivateClient.h
r163816 r164498 29 29 #if ENABLE(MEDIA_SOURCE) 30 30 31 #include " TimeRanges.h"31 #include "PlatformTimeRanges.h" 32 32 #include <wtf/RefCounted.h> 33 33 … … 42 42 virtual void setPrivateAndOpen(PassRef<MediaSourcePrivate>) = 0; 43 43 virtual double duration() const = 0; 44 virtual PassRefPtr<TimeRanges> buffered() const = 0;44 virtual std::unique_ptr<PlatformTimeRanges> buffered() const = 0; 45 45 }; 46 46 -
trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp
r163816 r164498 39 39 #include "Logging.h" 40 40 #include "PlatformLayer.h" 41 #include "PlatformTimeRanges.h" 41 42 #include "Settings.h" 42 43 #include "SoftLinking.h" 43 #include "TimeRanges.h"44 44 #include <CoreMedia/CoreMedia.h> 45 45 #include <wtf/MainThread.h> 46 #include <wtf/text/CString.h> 46 47 47 48 namespace WebCore { … … 386 387 } 387 388 388 PassRefPtr<TimeRanges> MediaPlayerPrivateAVFoundation::buffered() const389 std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateAVFoundation::buffered() const 389 390 { 390 391 if (!m_cachedLoadedTimeRanges) 391 392 m_cachedLoadedTimeRanges = platformBufferedTimeRanges(); 392 393 393 return m_cachedLoadedTimeRanges->copy();394 return PlatformTimeRanges::create(*m_cachedLoadedTimeRanges); 394 395 } 395 396 … … 621 622 void MediaPlayerPrivateAVFoundation::loadedTimeRangesChanged() 622 623 { 623 m_cachedLoadedTimeRanges = 0;624 m_cachedLoadedTimeRanges = nullptr; 624 625 m_cachedMaxTimeLoaded = 0; 625 626 invalidateCachedDuration(); … … 769 770 #define DEFINE_TYPE_STRING_CASE(type) case MediaPlayerPrivateAVFoundation::Notification::type: return #type; 770 771 switch (notification.type()) { 771 FOR_EACH_MEDIAPLAYERPRIVATEAVFOUNDATION_NOTIFICATION_TYPE(DEFINE_TYPE_STRING_CASE) 772 default: return ""; 772 FOR_EACH_MEDIAPLAYERPRIVATEAVFOUNDATION_NOTIFICATION_TYPE(DEFINE_TYPE_STRING_CASE) 773 case MediaPlayerPrivateAVFoundation::Notification::FunctionType: return "FunctionType"; 774 default: ASSERT_NOT_REACHED(); return ""; 773 775 } 774 776 #undef DEFINE_TYPE_STRING_CASE -
trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h
r163816 r164498 175 175 virtual double maxTimeSeekableDouble() const override; 176 176 virtual double minTimeSeekable() const override; 177 virtual PassRefPtr<TimeRanges> buffered() const override;177 virtual std::unique_ptr<PlatformTimeRanges> buffered() const override; 178 178 virtual bool didLoadingProgress() const override; 179 179 virtual void setSize(const IntSize&) override; … … 230 230 virtual void seekToTime(double time, double negativeTolerance, double positiveTolerance) = 0; 231 231 virtual unsigned long long totalBytes() const = 0; 232 virtual PassRefPtr<TimeRanges> platformBufferedTimeRanges() const = 0;232 virtual std::unique_ptr<PlatformTimeRanges> platformBufferedTimeRanges() const = 0; 233 233 virtual double platformMaxTimeSeekable() const = 0; 234 234 virtual double platformMinTimeSeekable() const = 0; … … 305 305 mutable Mutex m_queueMutex; 306 306 307 mutable RefPtr<TimeRanges> m_cachedLoadedTimeRanges;307 mutable std::unique_ptr<PlatformTimeRanges> m_cachedLoadedTimeRanges; 308 308 309 309 MediaPlayer::NetworkState m_networkState; -
trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp
r164412 r164498 619 619 } 620 620 621 PassRefPtr<TimeRanges> MediaPlayerPrivateAVFoundationCF::platformBufferedTimeRanges() const622 { 623 RefPtr<TimeRanges> timeRanges =TimeRanges::create();621 std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateAVFoundationCF::platformBufferedTimeRanges() const 622 { 623 auto timeRanges = PlatformTimeRanges::create(); 624 624 625 625 if (!avPlayerItem(m_avfWrapper)) 626 return timeRanges .release();626 return timeRanges; 627 627 628 628 RetainPtr<CFArrayRef> loadedRanges = adoptCF(AVCFPlayerItemCopyLoadedTimeRanges(avPlayerItem(m_avfWrapper))); 629 629 if (!loadedRanges) 630 return timeRanges .release();630 return timeRanges; 631 631 632 632 CFIndex rangeCount = CFArrayGetCount(loadedRanges.get()); … … 643 643 } 644 644 645 return timeRanges .release();645 return timeRanges; 646 646 } 647 647 -
trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h
r162139 r164498 79 79 virtual void seekToTime(double time, double negativeTolerance, double positiveTolerance); 80 80 virtual unsigned long long totalBytes() const; 81 virtual PassRefPtr<TimeRanges> platformBufferedTimeRanges() const;81 virtual std::unique_ptr<PlatformTimeRanges> platformBufferedTimeRanges() const; 82 82 virtual double platformMinTimeSeekable() const; 83 83 virtual double platformMaxTimeSeekable() const; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h
r163907 r164498 154 154 virtual void seekToTime(double time, double negativeTolerance, double positiveTolerance); 155 155 virtual unsigned long long totalBytes() const; 156 virtual PassRefPtr<TimeRanges> platformBufferedTimeRanges() const;156 virtual std::unique_ptr<PlatformTimeRanges> platformBufferedTimeRanges() const; 157 157 virtual double platformMinTimeSeekable() const; 158 158 virtual double platformMaxTimeSeekable() const; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm
r164160 r164498 44 44 #import "URL.h" 45 45 #import "Logging.h" 46 #import "PlatformTimeRanges.h" 46 47 #import "SecurityOrigin.h" 47 48 #import "SoftLinking.h" 48 #import "TimeRanges.h"49 49 #import "UUID.h" 50 50 #import "VideoTrackPrivateAVFObjC.h" … … 753 753 } 754 754 755 PassRefPtr<TimeRanges> MediaPlayerPrivateAVFoundationObjC::platformBufferedTimeRanges() const756 { 757 RefPtr<TimeRanges> timeRanges =TimeRanges::create();755 std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateAVFoundationObjC::platformBufferedTimeRanges() const 756 { 757 auto timeRanges = PlatformTimeRanges::create(); 758 758 759 759 if (!m_avPlayerItem) 760 return timeRanges .release();760 return timeRanges; 761 761 762 762 for (NSValue *thisRangeValue in m_cachedLoadedRanges.get()) { … … 768 768 } 769 769 } 770 return timeRanges .release();770 return timeRanges; 771 771 } 772 772 -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h
r163907 r164498 117 117 virtual void setRateDouble(double) override; 118 118 119 virtual PassRefPtr<TimeRanges> seekable() const override;119 virtual std::unique_ptr<PlatformTimeRanges> seekable() const override; 120 120 virtual double maxTimeSeekableDouble() const override; 121 121 virtual double minTimeSeekable() const override; 122 virtual PassRefPtr<TimeRanges> buffered() const override;122 virtual std::unique_ptr<PlatformTimeRanges> buffered() const override; 123 123 124 124 virtual bool didLoadingProgress() const override; -
trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm
r163907 r164498 389 389 } 390 390 391 PassRefPtr<TimeRanges> MediaPlayerPrivateMediaSourceAVFObjC::seekable() const392 { 393 return TimeRanges::create(minTimeSeekable(), maxTimeSeekableDouble());391 std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateMediaSourceAVFObjC::seekable() const 392 { 393 return PlatformTimeRanges::create(minTimeSeekable(), maxTimeSeekableDouble()); 394 394 } 395 395 … … 404 404 } 405 405 406 PassRefPtr<TimeRanges> MediaPlayerPrivateMediaSourceAVFObjC::buffered() const406 std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateMediaSourceAVFObjC::buffered() const 407 407 { 408 408 return m_mediaSource->buffered(); -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp
r164362 r164498 891 891 } 892 892 893 PassRefPtr<TimeRanges> MediaPlayerPrivateGStreamer::buffered() const894 { 895 RefPtr<TimeRanges> timeRanges =TimeRanges::create();893 std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateGStreamer::buffered() const 894 { 895 auto timeRanges = PlatformTimeRanges::create(); 896 896 if (m_errorOccured || isLiveStream()) 897 return timeRanges .release();897 return timeRanges; 898 898 899 899 #if GST_CHECK_VERSION(0, 10, 31) 900 900 float mediaDuration(duration()); 901 901 if (!mediaDuration || std::isinf(mediaDuration)) 902 return timeRanges .release();902 return timeRanges; 903 903 904 904 GstQuery* query = gst_query_new_buffering(GST_FORMAT_PERCENT); … … 906 906 if (!gst_element_query(m_playBin.get(), query)) { 907 907 gst_query_unref(query); 908 return timeRanges .release();908 return timeRanges; 909 909 } 910 910 … … 928 928 timeRanges->add(0, loaded); 929 929 #endif 930 return timeRanges .release();930 return timeRanges; 931 931 } 932 932 -
trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h
r163816 r164498 82 82 void fillTimerFired(Timer<MediaPlayerPrivateGStreamer>*); 83 83 84 PassRefPtr<TimeRanges> buffered() const;84 std::unique_ptr<PlatformTimeRanges> buffered() const; 85 85 float maxTimeSeekable() const; 86 86 bool didLoadingProgress() const; -
trunk/Source/WebCore/platform/graphics/ios/MediaPlayerPrivateIOS.h
r163816 r164498 120 120 float maxTimeBuffered() const; 121 121 virtual float maxTimeSeekable() const override; 122 virtual PassRefPtr<TimeRanges> buffered() const override;122 virtual std::unique_ptr<PlatformTimeRanges> buffered() const override; 123 123 124 124 virtual bool didLoadingProgress() const override; -
trunk/Source/WebCore/platform/graphics/ios/MediaPlayerPrivateIOS.mm
r163079 r164498 498 498 } 499 499 500 PassRefPtr<TimeRanges> MediaPlayerPrivateIOS::buffered() const 501 { 502 RefPtr<TimeRanges> timeRanges =TimeRanges::create();503 504 if (!m_mediaPlayerHelper) 505 return timeRanges .release();500 std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateIOS::buffered() 501 { 502 auto timeRanges = PlatformTimeRanges::create(); 503 504 if (!m_mediaPlayerHelper) 505 return timeRanges; 506 506 507 507 NSArray *ranges = [m_mediaPlayerHelper.get() _bufferedTimeRanges]; 508 508 if (!ranges) 509 return timeRanges .release();509 return timeRanges; 510 510 511 511 float timeRange[2]; … … 518 518 } 519 519 520 return timeRanges .release();520 return timeRanges; 521 521 } 522 522 -
trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h
r163816 r164498 121 121 MediaPlayer::ReadyState readyState() const { return m_readyState; } 122 122 123 PassRefPtr<TimeRanges> buffered() const;123 std::unique_ptr<PlatformTimeRanges> buffered() const; 124 124 float maxTimeSeekable() const; 125 125 bool didLoadingProgress() const; -
trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm
r163816 r164498 40 40 #import "MIMETypeRegistry.h" 41 41 #import "PlatformLayer.h" 42 #import "PlatformTimeRanges.h" 42 43 #import "SecurityOrigin.h" 43 44 #import "SoftLinking.h" 44 #import "TimeRanges.h"45 45 #import "WebCoreSystemInterface.h" 46 46 #import <QTKit/QTKit.h> … … 918 918 } 919 919 920 PassRefPtr<TimeRanges> MediaPlayerPrivateQTKit::buffered() const921 { 922 RefPtr<TimeRanges> timeRanges =TimeRanges::create();920 std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateQTKit::buffered() const 921 { 922 auto timeRanges = PlatformTimeRanges::create(); 923 923 float loaded = maxTimeLoaded(); 924 924 if (loaded > 0) 925 925 timeRanges->add(0, loaded); 926 return timeRanges .release();926 return timeRanges; 927 927 } 928 928 -
trunk/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp
r163079 r164498 548 548 } 549 549 550 PassRefPtr<TimeRanges> MediaPlayerPrivateQuickTimeVisualContext::buffered() const 551 { 552 RefPtr<TimeRanges> timeRanges = TimeRanges::create(); 550 std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateQuickTimeVisualContext::buffered() const 551 { 552 auto timeRanges = PlatformTimeRanges::create(); 553 553 554 float loaded = maxTimeLoaded(); 554 555 // rtsp streams are not buffered 555 556 if (!m_isStreaming && loaded > 0) 556 557 timeRanges->add(0, loaded); 557 return timeRanges .release();558 return timeRanges; 558 559 } 559 560 -
trunk/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h
r163079 r164498 93 93 MediaPlayer::ReadyState readyState() const { return m_readyState; } 94 94 95 PassRefPtr<TimeRanges> buffered() const;95 std::unique_ptr<PlatformTimeRanges> buffered() const; 96 96 float maxTimeSeekable() const; 97 97 bool didLoadingProgress() const; -
trunk/Source/WebCore/platform/graphics/wince/MediaPlayerPrivateWinCE.h
r157834 r164498 69 69 MediaPlayer::ReadyState readyState() const { return m_readyState; } 70 70 71 PassRefPtr<TimeRanges> buffered() const;71 std::unique_ptr<PlatformTimeRanges> buffered() const; 72 72 float maxTimeSeekable() const; 73 73 // FIXME: bytesLoaded() should be replaced with didLoadingProgress() (by somebody who can find the implementation of this class). -
trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.cpp
r163816 r164498 167 167 } 168 168 169 PassRefPtr<TimeRanges> MockMediaPlayerMediaSource::buffered() const 170 { 171 return m_mediaSource ? m_mediaSource->buffered() : TimeRanges::create(); 169 std::unique_ptr<PlatformTimeRanges> MockMediaPlayerMediaSource::buffered() const 170 { 171 if (m_mediaSource) 172 return m_mediaSource->buffered(); 173 174 return PlatformTimeRanges::create(); 172 175 } 173 176 … … 210 213 void MockMediaPlayerMediaSource::advanceCurrentTime() 211 214 { 212 RefPtr<TimeRanges> buffered = this->buffered(); 215 if (!m_mediaSource) 216 return; 217 218 auto buffered = m_mediaSource->buffered(); 213 219 size_t pos = buffered->find(m_currentTime.toDouble()); 214 220 if (pos == notFound) 215 221 return; 216 222 217 m_currentTime = MediaTime::createWithDouble(std::min(m_duration, buffered->end(pos, IGNORE_EXCEPTION))); 223 bool ignoreError; 224 m_currentTime = MediaTime::createWithDouble(std::min(m_duration, buffered->end(pos, ignoreError))); 218 225 m_player->timeChanged(); 219 226 } -
trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h
r163816 r164498 71 71 virtual MediaPlayer::NetworkState networkState() const override; 72 72 virtual double maxTimeSeekableDouble() const override; 73 virtual PassRefPtr<TimeRanges> buffered() const override;73 virtual std::unique_ptr<PlatformTimeRanges> buffered() const override; 74 74 virtual bool didLoadingProgress() const override; 75 75 virtual void setSize(const IntSize&) override; -
trunk/Source/WebKit/ChangeLog
r164438 r164498 1 2014-02-21 Eric Carlson <eric.carlson@apple.com> 2 3 Fix TimeRanges layering violations 4 https://bugs.webkit.org/show_bug.cgi?id=128717 5 6 Reviewed by Jer Noble. 7 8 * WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in: TimeRanges::create(void) for Internals. 9 1 10 2014-02-20 Enrique Ocaña González <eocanha@igalia.com> 2 11 -
trunk/Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in
r164401 r164498 453 453 symbolWithPointer(?nearest@TimeRanges@WebCore@@QBENN@Z, ?nearest@TimeRanges@WebCore@@QEBANN@Z) 454 454 symbolWithPointer(?add@TimeRanges@WebCore@@QAEXNN@Z, ?add@TimeRanges@WebCore@@QEAAXNN@Z) 455 symbolWithPointer(?create@TimeRanges@WebCore@@SA?AV?$PassRefPtr@VTimeRanges@WebCore@@@WTF@@XZ, ?create@TimeRanges@WebCore@@SA?AV?$PassRefPtr@VTimeRanges@WebCore@@@WTF@@XZ) 455 456 #if USE(GSTREAMER) 456 457 symbolWithPointer(?simulateAudioInterruption@MediaPlayer@WebCore@@QAEXXZ, ?simulateAudioInterruption@MediaPlayer@WebCore@@QEAAXXZ) -
trunk/Tools/ChangeLog
r164487 r164498 1 2014-02-21 Eric Carlson <eric.carlson@apple.com> 2 3 Fix TimeRanges layering violations 4 https://bugs.webkit.org/show_bug.cgi?id=128717 5 6 Reviewed by Jer Noble. 7 8 * TestWebKitAPI/Tests/WebCore/TimeRanges.cpp: TimeRanges* -> TimeRanges&. 9 (TestWebKitAPI::TEST): 10 1 11 2014-02-21 Diego Pino García <dpino@igalia.com> 2 12 -
trunk/Tools/TestWebKitAPI/Tests/WebCore/TimeRanges.cpp
r160749 r164498 116 116 ASSERT_RANGE("{ [0,2) }", ranges); 117 117 118 ranges->intersectWith( ranges.get());118 ranges->intersectWith(*ranges.get()); 119 119 120 120 ASSERT_RANGE("{ [0,2) }", ranges); … … 129 129 ASSERT_RANGE("{ [0,2) }", rangesB); 130 130 131 rangesA->intersectWith( rangesB.get());131 rangesA->intersectWith(*rangesB.get()); 132 132 133 133 ASSERT_RANGE("{ [0,2) }", rangesA); … … 143 143 ASSERT_RANGE("{ }", rangesB); 144 144 145 rangesA->intersectWith( rangesB.get());145 rangesA->intersectWith(*rangesB.get()); 146 146 147 147 ASSERT_RANGE("{ }", rangesA); … … 151 151 TEST(TimeRanges, IntersectWith_DisjointRanges1) 152 152 { 153 153 154 RefPtr<TimeRanges> rangesA = TimeRanges::create(); 154 155 RefPtr<TimeRanges> rangesB = TimeRanges::create(); … … 163 164 ASSERT_RANGE("{ [2,3) [6,7) }", rangesB); 164 165 165 rangesA->intersectWith( rangesB.get());166 rangesA->intersectWith(*rangesB.get()); 166 167 167 168 ASSERT_RANGE("{ }", rangesA); … … 183 184 ASSERT_RANGE("{ [1,4) [5,7) }", rangesB); 184 185 185 rangesA->intersectWith( rangesB.get());186 rangesA->intersectWith(*rangesB.get()); 186 187 187 188 ASSERT_RANGE("{ }", rangesA); … … 203 204 ASSERT_RANGE("{ [0,10) }", rangesB); 204 205 205 rangesA->intersectWith( rangesB.get());206 rangesA->intersectWith(*rangesB.get()); 206 207 207 208 ASSERT_RANGE("{ [1,3) [4,5) [6,9) }", rangesA); … … 223 224 ASSERT_RANGE("{ [1,9) }", rangesB); 224 225 225 rangesA->intersectWith( rangesB.get());226 rangesA->intersectWith(*rangesB.get()); 226 227 227 228 ASSERT_RANGE("{ [1,3) [4,5) [6,9) }", rangesA); … … 242 243 ASSERT_RANGE("{ [1,5) }", rangesB); 243 244 244 rangesA->intersectWith( rangesB.get());245 rangesA->intersectWith(*rangesB.get()); 245 246 246 247 ASSERT_RANGE("{ [1,2) [4,5) }", rangesA); … … 262 263 ASSERT_RANGE("{ [1,9) }", rangesB); 263 264 264 rangesA->intersectWith( rangesB.get());265 rangesA->intersectWith(*rangesB.get()); 265 266 266 267 ASSERT_RANGE("{ [1,2) [4,6) [8,9) }", rangesA); … … 283 284 ASSERT_RANGE("{ [1,5) [6,9) }", rangesB); 284 285 285 rangesA->intersectWith( rangesB.get());286 rangesA->intersectWith(*rangesB.get()); 286 287 287 288 ASSERT_RANGE("{ [1,2) [4,5) [6,7) [8,9) }", rangesA);
Note:
See TracChangeset
for help on using the changeset viewer.