Changeset 164498 in webkit


Ignore:
Timestamp:
Feb 21, 2014 2:04:06 PM (10 years ago)
Author:
eric.carlson@apple.com
Message:

Fix TimeRanges layering violations
https://bugs.webkit.org/show_bug.cgi?id=128717

Reviewed by NOBODY (OOPS!).

Source/WebCore:

No new tests, no functionality changed.

  • CMakeLists.txt:
  • GNUmakefile.list.am: Add PlatformTimeRanges.
  • Modules/mediasource/MediaSource.cpp:

(WebCore::MediaSource::buffered): TimeRanges -> PlatformTimeRanges.

  • Modules/mediasource/MediaSource.h:
  • Modules/mediasource/SourceBuffer.cpp:

(WebCore::SourceBuffer::sourceBufferPrivateDidReceiveSample): TimeRanges* -> TimeRanges&.

  • WebCore.exp.in: Update for signature changes.
  • WebCore.vcxproj/WebCore.vcxproj:
  • WebCore.vcxproj/WebCore.vcxproj.filters:
  • WebCore.xcodeproj/project.pbxproj: Add PlatformTimeRanges.
  • html/HTMLMediaElement.cpp:

(WebCore::HTMLMediaElement::percentLoaded): Create TimeRanges from PlatformTimeRanges.
(WebCore::HTMLMediaElement::buffered): Ditto.
(WebCore::HTMLMediaElement::seekable): Ditto.

  • html/MediaController.cpp:

(MediaController::buffered): TimeRanges* -> TimeRanges&.
(MediaController::seekable): Ditto.
(MediaController::played): Ditto.

Move all of the logic into PlatformTimeRanges. Change API to take TimeRanges& instead of TimeRanges*.

  • html/TimeRanges.cpp:

(WebCore::TimeRanges::create): Move to .cpp from .h.
(WebCore::TimeRanges::TimeRanges): Initialize the PlatformTimeRanges member variable.
(WebCore::TimeRanges::start): Passthrough to PlatformTimeRanges.
(WebCore::TimeRanges::end): Ditto.
(WebCore::TimeRanges::invert): Ditto.
(WebCore::TimeRanges::copy): Ditto.
(WebCore::TimeRanges::intersectWith): Ditto.
(WebCore::TimeRanges::unionWith): Ditto.
(WebCore::TimeRanges::length): Ditto.
(WebCore::TimeRanges::add): Ditto.
(WebCore::TimeRanges::contain): Ditto.
(WebCore::TimeRanges::find): Ditto.
(WebCore::TimeRanges::nearest): Ditto.
(WebCore::TimeRanges::totalDuration): Ditto.

  • html/TimeRanges.h:
  • platform/graphics/MediaPlayer.cpp:

(WebCore::NullMediaPlayerPrivate::buffered): TimeRanges -> PlatformTimeRanges.
(WebCore::MediaPlayer::buffered): Ditto.
(WebCore::MediaPlayer::seekable): Ditto.

  • platform/graphics/MediaPlayer.h:
  • platform/graphics/MediaPlayerPrivate.h:
  • platform/graphics/MediaSourcePrivateClient.h:
  • platform/graphics/PlatformTimeRanges.cpp: Added.
  • platform/graphics/PlatformTimeRanges.h: Added.
  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:

(WebCore::MediaPlayerPrivateAVFoundation::buffered): TimeRanges -> PlatformTimeRanges.
(WebCore::MediaPlayerPrivateAVFoundation::loadedTimeRangesChanged): Drive-by fix to log

FunctionType notifications. ASSERT when passed an unknown notification.

  • platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h:
  • platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp:

(WebCore::MediaPlayerPrivateAVFoundationCF::platformBufferedTimeRanges): TimeRanges -> PlatformTimeRanges.

  • platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:

(WebCore::MediaPlayerPrivateAVFoundationObjC::currentTime): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::platformBufferedTimeRanges): Ditto.

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm:

(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::seekable): Ditto.
(WebCore::MediaPlayerPrivateMediaSourceAVFObjC::buffered): Ditto.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp:

(WebCore::MediaPlayerPrivateGStreamer::buffered): Ditto.

  • platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h:
  • platform/graphics/ios/MediaPlayerPrivateIOS.h:
  • platform/graphics/ios/MediaPlayerPrivateIOS.mm:

(WebCore::MediaPlayerPrivateIOS::buffered): Ditto.

  • platform/graphics/mac/MediaPlayerPrivateQTKit.h:
  • platform/graphics/mac/MediaPlayerPrivateQTKit.mm:

(WebCore::MediaPlayerPrivateQTKit::buffered): Ditto.

  • platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp:

(WebCore::MediaPlayerPrivateQuickTimeVisualContext::buffered): Ditto.

  • platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h:
  • platform/graphics/wince/MediaPlayerPrivateWinCE.h:
  • platform/mock/mediasource/MockMediaPlayerMediaSource.cpp:

(WebCore::MockMediaPlayerMediaSource::buffered): Ditto.
(WebCore::MockMediaPlayerMediaSource::advanceCurrentTime): Ditto.

  • platform/mock/mediasource/MockMediaPlayerMediaSource.h:

Source/WebKit:

  • WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in: TimeRanges::create(void) for Internals.

Tools:

  • TestWebKitAPI/Tests/WebCore/TimeRanges.cpp: TimeRanges* -> TimeRanges&.

(TestWebKitAPI::TEST):

Location:
trunk
Files:
2 added
41 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r164477 r164498  
    19111911    platform/graphics/PathTraversalState.cpp
    19121912    platform/graphics/Pattern.cpp
     1913    platform/graphics/PlatformTimeRanges.cpp
    19131914    platform/graphics/Region.cpp
    19141915    platform/graphics/RoundedRect.cpp
  • trunk/Source/WebCore/ChangeLog

    r164497 r164498  
     12014-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
    11082014-02-21  Enrica Casucci  <enrica@apple.com>
    2109
  • trunk/Source/WebCore/GNUmakefile.list.am

    r164477 r164498  
    53395339        Source/WebCore/platform/graphics/MediaPlayer.h \
    53405340        Source/WebCore/platform/graphics/MediaPlayerPrivate.h \
     5341        Source/WebCore/platform/graphics/PlatformTimeRanges.cpp \
     5342        Source/WebCore/platform/graphics/PlatformTimeRanges.h \
    53415343        Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp \
    53425344        Source/WebCore/platform/graphics/opengl/TemporaryOpenGLSetting.cpp \
  • trunk/Source/WebCore/Modules/mediasource/MediaSource.cpp

    r163816 r164498  
    132132}
    133133
    134 PassRefPtr<TimeRanges> MediaSource::buffered() const
     134std::unique_ptr<PlatformTimeRanges> MediaSource::buffered() const
    135135{
    136136    // Implements MediaSource algorithm for HTMLMediaElement.buffered.
     
    140140    // 1. If activeSourceBuffers.length equals 0 then return an empty TimeRanges object and abort these steps.
    141141    if (ranges.isEmpty())
    142         return TimeRanges::create();
     142        return PlatformTimeRanges::create();
    143143
    144144    // 2. Let active ranges be the ranges returned by buffered for each SourceBuffer object in activeSourceBuffers.
     
    153153    // Return an empty range if all ranges are empty.
    154154    if (highestEndTime < 0)
    155         return TimeRanges::create();
     155        return PlatformTimeRanges::create();
    156156
    157157    // 4. Let intersection ranges equal a TimeRange object containing a single range from 0 to highest end time.
     
    170170        // 5.3 Let new intersection ranges equal the the intersection between the intersection ranges and the source ranges.
    171171        // 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());
    176176}
    177177
  • trunk/Source/WebCore/Modules/mediasource/MediaSource.h

    r163816 r164498  
    7373    virtual void setPrivateAndOpen(PassRef<MediaSourcePrivate>) override;
    7474    virtual double duration() const override;
    75     virtual PassRefPtr<TimeRanges> buffered() const override;
     75    virtual std::unique_ptr<PlatformTimeRanges> buffered() const override;
    7676
    7777    bool attachToElement(HTMLMediaElement*);
  • trunk/Source/WebCore/Modules/mediasource/SourceBuffer.cpp

    r161768 r164498  
    968968
    969969            erasedRanges->invert();
    970             m_buffered->intersectWith(erasedRanges.get());
     970            m_buffered->intersectWith(*erasedRanges.get());
    971971        }
    972972
  • trunk/Source/WebCore/WebCore.exp.in

    r164497 r164498  
    14241424__ZN7WebCore9unionRectERKN3WTF6VectorINS_9FloatRectELm0ENS0_15CrashOnOverflowEEE
    14251425__ZN7WebCore10Pasteboard21createForCopyAndPasteEv
    1426 __ZN7WebCore10TimeRanges13intersectWithEPKS0_
     1426__ZN7WebCore10TimeRanges6createEv
     1427__ZN7WebCore10TimeRanges6createEdd
    14271428__ZN7WebCore10TimeRangesC1Edd
     1429__ZN7WebCore10TimeRanges13intersectWithERKS0_
    14281430__ZN7WebCore13SelectionRectC1ERKNS_7IntRectEbi
    14291431__ZNK3JSC8Bindings10RootObject12globalObjectEv
     
    14631465__ZNK7WebCore10TimeRanges4copyEv
    14641466__ZNK7WebCore10TimeRanges5startEjRi
     1467__ZNK7WebCore10TimeRanges6lengthEv
    14651468__ZNK7WebCore11FrameLoader10isCompleteEv
    14661469__ZNK7WebCore11FrameLoader14cancelledErrorERKNS_15ResourceRequestE
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj

    r164477 r164498  
    76767676    <ClCompile Include="..\platform\graphics\PathTraversalState.cpp" />
    76777677    <ClCompile Include="..\platform\graphics\Pattern.cpp" />
     7678    <ClCompile Include="..\platform\graphics\PlatformTimeRanges.cpp" />
    76787679    <ClCompile Include="..\platform\graphics\Region.cpp" />
    76797680    <ClCompile Include="..\platform\graphics\RoundedRect.cpp" />
     
    1911219113    <ClInclude Include="..\platform\graphics\Pattern.h" />
    1911319114    <ClInclude Include="..\platform\graphics\PlatformLayer.h" />
     19115    <ClInclude Include="..\platform\graphics\PlatformTimeRanges.h" />
    1911419116    <ClInclude Include="..\platform\graphics\Region.h" />
    1911519117    <ClInclude Include="..\platform\graphics\RoundedRect.h" />
  • trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters

    r164477 r164498  
    13841384      <Filter>platform\graphics</Filter>
    13851385    </ClCompile>
     1386    <ClCompile Include="..\platform\graphics\PlatformTimeRanges.cpp">
     1387      <Filter>platform\graphics</Filter>
     1388    </ClCompile>
    13861389    <ClCompile Include="..\platform\graphics\RoundedRect.cpp">
    13871390      <Filter>platform\graphics</Filter>
     
    83238326    </ClInclude>
    83248327    <ClInclude Include="..\platform\graphics\PlatformLayer.h">
     8328      <Filter>platform\graphics</Filter>
     8329    </ClInclude>
     8330    <ClInclude Include="..\platform\graphics\PlatformTimeRanges.h">
    83258331      <Filter>platform\graphics</Filter>
    83268332    </ClInclude>
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r164477 r164498  
    173173                074300A50F4B8BCF008076CD /* MediaPlayerPrivateIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 074300A30F4B8BCF008076CD /* MediaPlayerPrivateIOS.mm */; };
    174174                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, ); }; };
    175177                0753860214489E9800B78452 /* CachedTextTrack.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0753860014489E9800B78452 /* CachedTextTrack.cpp */; };
    176178                0753860314489E9800B78452 /* CachedTextTrack.h in Headers */ = {isa = PBXBuildFile; fileRef = 0753860114489E9800B78452 /* CachedTextTrack.h */; };
     
    69626964                074300A30F4B8BCF008076CD /* MediaPlayerPrivateIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MediaPlayerPrivateIOS.mm; sourceTree = "<group>"; };
    69636965                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>"; };
    69646968                0753860014489E9800B78452 /* CachedTextTrack.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CachedTextTrack.cpp; sourceTree = "<group>"; };
    69656969                0753860114489E9800B78452 /* CachedTextTrack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CachedTextTrack.h; sourceTree = "<group>"; };
     
    1990019904                                072847E216EBC5B00043CFA4 /* PlatformTextTrack.h */,
    1990119905                                072847E316EBC5B00043CFA4 /* PlatformTextTrackMenu.h */,
     19906                                074E82B818A69F0E007EF54C /* PlatformTimeRanges.cpp */,
     19907                                074E82B918A69F0E007EF54C /* PlatformTimeRanges.h */,
    1990219908                                BCAB417F13E356E800D8AAF3 /* Region.cpp */,
    1990319909                                BCAB418013E356E800D8AAF3 /* Region.h */,
     
    2483824844                                297BE3D716C03C0E003316BD /* PlatformSpeechSynthesizer.h in Headers */,
    2483924845                                1AD8F81B11CAB9E900E93E54 /* PlatformStrategies.h in Headers */,
     24846                                074E82BB18A69F0E007EF54C /* PlatformTimeRanges.h in Headers */,
    2484024847                                935C476B09AC4D4F00A6AAB4 /* PlatformWheelEvent.h in Headers */,
    2484124848                                31D591B316697A6C00E6BF02 /* PlugInClient.h in Headers */,
     
    2821928226                                297BE3D816C03CCE003316BD /* PlatformSpeechSynthesizerMac.mm in Sources */,
    2822028227                                1AD8F81C11CAB9E900E93E54 /* PlatformStrategies.cpp in Sources */,
     28228                                074E82BA18A69F0E007EF54C /* PlatformTimeRanges.cpp in Sources */,
    2822128229                                A9C6E4F30D745E48006442E9 /* PluginData.cpp in Sources */,
    2822228230                                97205ABB1239292700B17380 /* PluginDocument.cpp in Sources */,
  • trunk/Source/WebCore/html/HTMLMediaElement.cpp

    r164318 r164498  
    30763076
    30773077    double buffered = 0;
    3078     RefPtr<TimeRanges> timeRanges = m_player->buffered();
     3078    bool ignored;
     3079    std::unique_ptr<PlatformTimeRanges> timeRanges = m_player->buffered();
    30793080    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);
    30823083        buffered += end - start;
    30833084    }
     
    41134114#if ENABLE(MEDIA_SOURCE)
    41144115    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());
    41194120}
    41204121
     
    41354136PassRefPtr<TimeRanges> HTMLMediaElement::seekable() const
    41364137{
    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();
    41384142}
    41394143
  • trunk/Source/WebCore/html/MediaController.cpp

    r164365 r164498  
    9696    RefPtr<TimeRanges> bufferedRanges = m_mediaElements.first()->buffered();
    9797    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());
    9999    return bufferedRanges;
    100100}
     
    110110    RefPtr<TimeRanges> seekableRanges = m_mediaElements.first()->seekable();
    111111    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());
    113113    return seekableRanges;
    114114}
     
    124124    RefPtr<TimeRanges> playedRanges = m_mediaElements.first()->played();
    125125    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());
    127127    return playedRanges;
    128128}
  • trunk/Source/WebCore/html/TimeRanges.cpp

    r160749 r164498  
    3030#include "ExceptionCode.h"
    3131#include "ExceptionCodePlaceholder.h"
    32 #include <math.h>
    3332
    3433namespace WebCore {
    3534
     35PassRefPtr<TimeRanges> TimeRanges::create()
     36{
     37    return adoptRef(new TimeRanges);
     38}
     39
     40PassRefPtr<TimeRanges> TimeRanges::create(double start, double end)
     41{
     42    return adoptRef(new TimeRanges(start, end));
     43}
     44
     45PassRefPtr<TimeRanges> TimeRanges::create(const PlatformTimeRanges& other)
     46{
     47    return adoptRef(new TimeRanges(other));
     48}
     49
     50TimeRanges::TimeRanges()
     51{
     52}
     53
    3654TimeRanges::TimeRanges(double start, double end)
     55    : m_ranges(PlatformTimeRanges(start, end))
    3756{
    38     add(start, end);
     57}
     58
     59TimeRanges::TimeRanges(const PlatformTimeRanges& other)
     60    : m_ranges(other)
     61{
     62}
     63
     64double 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
     76double 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
     88void TimeRanges::invert()
     89{
     90    m_ranges.invert();
    3991}
    4092
    4193PassRefPtr<TimeRanges> TimeRanges::copy() const
    4294{
    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);
    5096}
    5197
    52 void TimeRanges::invert()
     98void TimeRanges::intersectWith(const TimeRanges& other)
    5399{
    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());
    74101}
    75102
    76 void TimeRanges::intersectWith(const TimeRanges* other)
     103void TimeRanges::unionWith(const TimeRanges& other)
    77104{
    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());
    89106}
    90107
    91 void TimeRanges::unionWith(const TimeRanges* other)
     108unsigned TimeRanges::length() const
    92109{
    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();
    101111}
    102112
    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)
     113void TimeRanges::add(double start, double end)
    122114{
    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);
    162116}
    163117
    164118bool TimeRanges::contain(double time) const
    165119{
    166     return find(time) != notFound;
     120    return m_ranges.contain(time);
    167121}
    168122
    169123size_t TimeRanges::find(double time) const
    170124{
    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);
    176126}
    177127
    178128double TimeRanges::nearest(double time) const
    179129{
    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);
    198131}
    199132
    200133double TimeRanges::totalDuration() const
    201134{
    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();
    206136}
    207137
  • trunk/Source/WebCore/html/TimeRanges.h

    r158821 r164498  
    2727#define TimeRanges_h
    2828
     29#include "PlatformTimeRanges.h"
    2930#include <algorithm>
    3031#include <wtf/PassRefPtr.h>
     
    3839class TimeRanges : public RefCounted<TimeRanges> {
    3940public:
    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;
    4847
    4948    PassRefPtr<TimeRanges> copy() const;
    5049    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;
    5754
    5855    void add(double start, double end);
     56    bool contain(double time) const;
    5957   
    60     bool contain(double time) const;
    61 
    6258    size_t find(double time) const;
    63    
    6459    double nearest(double time) const;
    65 
    6660    double totalDuration() const;
    6761
     62    const PlatformTimeRanges& ranges() const { return m_ranges; }
     63
    6864private:
    69     TimeRanges() { }
     65    explicit TimeRanges();
    7066    TimeRanges(double start, double end);
    71     TimeRanges(const TimeRanges&);
     67    TimeRanges(const PlatformTimeRanges&);
    7268
    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;
    8369
    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;
    11671};
    11772
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.cpp

    r164358 r164498  
    3737#include "MIMETypeRegistry.h"
    3838#include "MediaPlayerPrivate.h"
     39#include "PlatformTimeRanges.h"
    3940#include "Settings.h"
    40 #include "TimeRanges.h"
    4141#include <wtf/text/CString.h>
    4242
     
    128128    virtual double maxTimeSeekableDouble() const { return 0; }
    129129    virtual double minTimeSeekable() const { return 0; }
    130     virtual PassRefPtr<TimeRanges> buffered() const { return TimeRanges::create(); }
     130    virtual std::unique_ptr<PlatformTimeRanges> buffered() const { return PlatformTimeRanges::create(); }
    131131
    132132    virtual unsigned totalBytes() const { return 0; }
     
    704704}
    705705
    706 PassRefPtr<TimeRanges> MediaPlayer::buffered()
     706std::unique_ptr<PlatformTimeRanges> MediaPlayer::buffered()
    707707{
    708708    return m_private->buffered();
    709709}
    710710
    711 PassRefPtr<TimeRanges> MediaPlayer::seekable()
     711std::unique_ptr<PlatformTimeRanges> MediaPlayer::seekable()
    712712{
    713713    return m_private->seekable();
  • trunk/Source/WebCore/platform/graphics/MediaPlayer.h

    r163907 r164498  
    129129class GraphicsContext;
    130130class GraphicsContext3D;
     131class HostWindow;
    131132class IntRect;
    132133class IntSize;
    133134class MediaPlayer;
    134135struct MediaPlayerFactory;
    135 class TimeRanges;
    136 class HostWindow;
     136class PlatformTimeRanges;
    137137
    138138#if PLATFORM(WIN) && USE(AVFOUNDATION)
     
    353353    void setPreservesPitch(bool);
    354354
    355     PassRefPtr<TimeRanges> buffered();
    356     PassRefPtr<TimeRanges> seekable();
     355    std::unique_ptr<PlatformTimeRanges> buffered();
     356    std::unique_ptr<PlatformTimeRanges> seekable();
    357357    double minTimeSeekable();
    358358    double maxTimeSeekable();
  • trunk/Source/WebCore/platform/graphics/MediaPlayerPrivate.h

    r164160 r164498  
    3030
    3131#include "MediaPlayer.h"
    32 #include "TimeRanges.h"
     32#include "PlatformTimeRanges.h"
    3333#include <wtf/Forward.h>
     34#include <wtf/OwnPtr.h>
    3435
    3536namespace WebCore {
     
    109110    virtual MediaPlayer::ReadyState readyState() const = 0;
    110111
    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(); }
    112113    virtual float maxTimeSeekable() const { return 0; }
    113114    virtual double maxTimeSeekableDouble() const { return maxTimeSeekable(); }
    114115    virtual double minTimeSeekable() const { return 0; }
    115     virtual PassRefPtr<TimeRanges> buffered() const = 0;
     116    virtual std::unique_ptr<PlatformTimeRanges> buffered() const = 0;
    116117
    117118    virtual bool didLoadingProgress() const = 0;
  • trunk/Source/WebCore/platform/graphics/MediaSourcePrivateClient.h

    r163816 r164498  
    2929#if ENABLE(MEDIA_SOURCE)
    3030
    31 #include "TimeRanges.h"
     31#include "PlatformTimeRanges.h"
    3232#include <wtf/RefCounted.h>
    3333
     
    4242    virtual void setPrivateAndOpen(PassRef<MediaSourcePrivate>) = 0;
    4343    virtual double duration() const = 0;
    44     virtual PassRefPtr<TimeRanges> buffered() const = 0;
     44    virtual std::unique_ptr<PlatformTimeRanges> buffered() const = 0;
    4545};
    4646
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp

    r163816 r164498  
    3939#include "Logging.h"
    4040#include "PlatformLayer.h"
     41#include "PlatformTimeRanges.h"
    4142#include "Settings.h"
    4243#include "SoftLinking.h"
    43 #include "TimeRanges.h"
    4444#include <CoreMedia/CoreMedia.h>
    4545#include <wtf/MainThread.h>
     46#include <wtf/text/CString.h>
    4647
    4748namespace WebCore {
     
    386387}
    387388
    388 PassRefPtr<TimeRanges> MediaPlayerPrivateAVFoundation::buffered() const
     389std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateAVFoundation::buffered() const
    389390{
    390391    if (!m_cachedLoadedTimeRanges)
    391392        m_cachedLoadedTimeRanges = platformBufferedTimeRanges();
    392393
    393     return m_cachedLoadedTimeRanges->copy();
     394    return PlatformTimeRanges::create(*m_cachedLoadedTimeRanges);
    394395}
    395396
     
    621622void MediaPlayerPrivateAVFoundation::loadedTimeRangesChanged()
    622623{
    623     m_cachedLoadedTimeRanges = 0;
     624    m_cachedLoadedTimeRanges = nullptr;
    624625    m_cachedMaxTimeLoaded = 0;
    625626    invalidateCachedDuration();
     
    769770#define DEFINE_TYPE_STRING_CASE(type) case MediaPlayerPrivateAVFoundation::Notification::type: return #type;
    770771    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 "";
    773775    }
    774776#undef DEFINE_TYPE_STRING_CASE
  • trunk/Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.h

    r163816 r164498  
    175175    virtual double maxTimeSeekableDouble() const override;
    176176    virtual double minTimeSeekable() const override;
    177     virtual PassRefPtr<TimeRanges> buffered() const override;
     177    virtual std::unique_ptr<PlatformTimeRanges> buffered() const override;
    178178    virtual bool didLoadingProgress() const override;
    179179    virtual void setSize(const IntSize&) override;
     
    230230    virtual void seekToTime(double time, double negativeTolerance, double positiveTolerance) = 0;
    231231    virtual unsigned long long totalBytes() const = 0;
    232     virtual PassRefPtr<TimeRanges> platformBufferedTimeRanges() const = 0;
     232    virtual std::unique_ptr<PlatformTimeRanges> platformBufferedTimeRanges() const = 0;
    233233    virtual double platformMaxTimeSeekable() const = 0;
    234234    virtual double platformMinTimeSeekable() const = 0;
     
    305305    mutable Mutex m_queueMutex;
    306306
    307     mutable RefPtr<TimeRanges> m_cachedLoadedTimeRanges;
     307    mutable std::unique_ptr<PlatformTimeRanges> m_cachedLoadedTimeRanges;
    308308
    309309    MediaPlayer::NetworkState m_networkState;
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.cpp

    r164412 r164498  
    619619}
    620620
    621 PassRefPtr<TimeRanges> MediaPlayerPrivateAVFoundationCF::platformBufferedTimeRanges() const
    622 {
    623     RefPtr<TimeRanges> timeRanges = TimeRanges::create();
     621std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateAVFoundationCF::platformBufferedTimeRanges() const
     622{
     623    auto timeRanges = PlatformTimeRanges::create();
    624624
    625625    if (!avPlayerItem(m_avfWrapper))
    626         return timeRanges.release();
     626        return timeRanges;
    627627
    628628    RetainPtr<CFArrayRef> loadedRanges = adoptCF(AVCFPlayerItemCopyLoadedTimeRanges(avPlayerItem(m_avfWrapper)));
    629629    if (!loadedRanges)
    630         return timeRanges.release();
     630        return timeRanges;
    631631
    632632    CFIndex rangeCount = CFArrayGetCount(loadedRanges.get());
     
    643643    }
    644644
    645     return timeRanges.release();
     645    return timeRanges;
    646646}
    647647
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/MediaPlayerPrivateAVFoundationCF.h

    r162139 r164498  
    7979    virtual void seekToTime(double time, double negativeTolerance, double positiveTolerance);
    8080    virtual unsigned long long totalBytes() const;
    81     virtual PassRefPtr<TimeRanges> platformBufferedTimeRanges() const;
     81    virtual std::unique_ptr<PlatformTimeRanges> platformBufferedTimeRanges() const;
    8282    virtual double platformMinTimeSeekable() const;
    8383    virtual double platformMaxTimeSeekable() const;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h

    r163907 r164498  
    154154    virtual void seekToTime(double time, double negativeTolerance, double positiveTolerance);
    155155    virtual unsigned long long totalBytes() const;
    156     virtual PassRefPtr<TimeRanges> platformBufferedTimeRanges() const;
     156    virtual std::unique_ptr<PlatformTimeRanges> platformBufferedTimeRanges() const;
    157157    virtual double platformMinTimeSeekable() const;
    158158    virtual double platformMaxTimeSeekable() const;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r164160 r164498  
    4444#import "URL.h"
    4545#import "Logging.h"
     46#import "PlatformTimeRanges.h"
    4647#import "SecurityOrigin.h"
    4748#import "SoftLinking.h"
    48 #import "TimeRanges.h"
    4949#import "UUID.h"
    5050#import "VideoTrackPrivateAVFObjC.h"
     
    753753}
    754754
    755 PassRefPtr<TimeRanges> MediaPlayerPrivateAVFoundationObjC::platformBufferedTimeRanges() const
    756 {
    757     RefPtr<TimeRanges> timeRanges = TimeRanges::create();
     755std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateAVFoundationObjC::platformBufferedTimeRanges() const
     756{
     757    auto timeRanges = PlatformTimeRanges::create();
    758758
    759759    if (!m_avPlayerItem)
    760         return timeRanges.release();
     760        return timeRanges;
    761761
    762762    for (NSValue *thisRangeValue in m_cachedLoadedRanges.get()) {
     
    768768        }
    769769    }
    770     return timeRanges.release();
     770    return timeRanges;
    771771}
    772772
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.h

    r163907 r164498  
    117117    virtual void setRateDouble(double) override;
    118118
    119     virtual PassRefPtr<TimeRanges> seekable() const override;
     119    virtual std::unique_ptr<PlatformTimeRanges> seekable() const override;
    120120    virtual double maxTimeSeekableDouble() const override;
    121121    virtual double minTimeSeekable() const override;
    122     virtual PassRefPtr<TimeRanges> buffered() const override;
     122    virtual std::unique_ptr<PlatformTimeRanges> buffered() const override;
    123123
    124124    virtual bool didLoadingProgress() const override;
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateMediaSourceAVFObjC.mm

    r163907 r164498  
    389389}
    390390
    391 PassRefPtr<TimeRanges> MediaPlayerPrivateMediaSourceAVFObjC::seekable() const
    392 {
    393     return TimeRanges::create(minTimeSeekable(), maxTimeSeekableDouble());
     391std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateMediaSourceAVFObjC::seekable() const
     392{
     393    return PlatformTimeRanges::create(minTimeSeekable(), maxTimeSeekableDouble());
    394394}
    395395
     
    404404}
    405405
    406 PassRefPtr<TimeRanges> MediaPlayerPrivateMediaSourceAVFObjC::buffered() const
     406std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateMediaSourceAVFObjC::buffered() const
    407407{
    408408    return m_mediaSource->buffered();
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.cpp

    r164362 r164498  
    891891}
    892892
    893 PassRefPtr<TimeRanges> MediaPlayerPrivateGStreamer::buffered() const
    894 {
    895     RefPtr<TimeRanges> timeRanges = TimeRanges::create();
     893std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateGStreamer::buffered() const
     894{
     895    auto timeRanges = PlatformTimeRanges::create();
    896896    if (m_errorOccured || isLiveStream())
    897         return timeRanges.release();
     897        return timeRanges;
    898898
    899899#if GST_CHECK_VERSION(0, 10, 31)
    900900    float mediaDuration(duration());
    901901    if (!mediaDuration || std::isinf(mediaDuration))
    902         return timeRanges.release();
     902        return timeRanges;
    903903
    904904    GstQuery* query = gst_query_new_buffering(GST_FORMAT_PERCENT);
     
    906906    if (!gst_element_query(m_playBin.get(), query)) {
    907907        gst_query_unref(query);
    908         return timeRanges.release();
     908        return timeRanges;
    909909    }
    910910
     
    928928        timeRanges->add(0, loaded);
    929929#endif
    930     return timeRanges.release();
     930    return timeRanges;
    931931}
    932932
  • trunk/Source/WebCore/platform/graphics/gstreamer/MediaPlayerPrivateGStreamer.h

    r163816 r164498  
    8282    void fillTimerFired(Timer<MediaPlayerPrivateGStreamer>*);
    8383
    84     PassRefPtr<TimeRanges> buffered() const;
     84    std::unique_ptr<PlatformTimeRanges> buffered() const;
    8585    float maxTimeSeekable() const;
    8686    bool didLoadingProgress() const;
  • trunk/Source/WebCore/platform/graphics/ios/MediaPlayerPrivateIOS.h

    r163816 r164498  
    120120    float maxTimeBuffered() const;
    121121    virtual float maxTimeSeekable() const override;
    122     virtual PassRefPtr<TimeRanges> buffered() const override;
     122    virtual std::unique_ptr<PlatformTimeRanges> buffered() const override;
    123123
    124124    virtual bool didLoadingProgress() const override;
  • trunk/Source/WebCore/platform/graphics/ios/MediaPlayerPrivateIOS.mm

    r163079 r164498  
    498498}
    499499
    500 PassRefPtr<TimeRanges> MediaPlayerPrivateIOS::buffered() const
    501 {
    502     RefPtr<TimeRanges> timeRanges = TimeRanges::create();
    503 
    504     if (!m_mediaPlayerHelper)
    505         return timeRanges.release();
     500std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateIOS::buffered()
     501{
     502    auto timeRanges = PlatformTimeRanges::create();
     503
     504    if (!m_mediaPlayerHelper)
     505        return timeRanges;
    506506
    507507    NSArray *ranges = [m_mediaPlayerHelper.get() _bufferedTimeRanges];
    508508    if (!ranges)
    509         return timeRanges.release();
     509        return timeRanges;
    510510
    511511    float timeRange[2];
     
    518518    }
    519519
    520     return timeRanges.release();
     520    return timeRanges;
    521521}
    522522
  • trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.h

    r163816 r164498  
    121121    MediaPlayer::ReadyState readyState() const { return m_readyState; }
    122122   
    123     PassRefPtr<TimeRanges> buffered() const;
     123    std::unique_ptr<PlatformTimeRanges> buffered() const;
    124124    float maxTimeSeekable() const;
    125125    bool didLoadingProgress() const;
  • trunk/Source/WebCore/platform/graphics/mac/MediaPlayerPrivateQTKit.mm

    r163816 r164498  
    4040#import "MIMETypeRegistry.h"
    4141#import "PlatformLayer.h"
     42#import "PlatformTimeRanges.h"
    4243#import "SecurityOrigin.h"
    4344#import "SoftLinking.h"
    44 #import "TimeRanges.h"
    4545#import "WebCoreSystemInterface.h"
    4646#import <QTKit/QTKit.h>
     
    918918}
    919919
    920 PassRefPtr<TimeRanges> MediaPlayerPrivateQTKit::buffered() const
    921 {
    922     RefPtr<TimeRanges> timeRanges = TimeRanges::create();
     920std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateQTKit::buffered() const
     921{
     922    auto timeRanges = PlatformTimeRanges::create();
    923923    float loaded = maxTimeLoaded();
    924924    if (loaded > 0)
    925925        timeRanges->add(0, loaded);
    926     return timeRanges.release();
     926    return timeRanges;
    927927}
    928928
  • trunk/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.cpp

    r163079 r164498  
    548548}
    549549
    550 PassRefPtr<TimeRanges> MediaPlayerPrivateQuickTimeVisualContext::buffered() const
    551 {
    552     RefPtr<TimeRanges> timeRanges = TimeRanges::create();
     550std::unique_ptr<PlatformTimeRanges> MediaPlayerPrivateQuickTimeVisualContext::buffered() const
     551{
     552    auto timeRanges = PlatformTimeRanges::create();
     553
    553554    float loaded = maxTimeLoaded();
    554555    // rtsp streams are not buffered
    555556    if (!m_isStreaming && loaded > 0)
    556557        timeRanges->add(0, loaded);
    557     return timeRanges.release();
     558    return timeRanges;
    558559}
    559560
  • trunk/Source/WebCore/platform/graphics/win/MediaPlayerPrivateQuickTimeVisualContext.h

    r163079 r164498  
    9393    MediaPlayer::ReadyState readyState() const { return m_readyState; }
    9494   
    95     PassRefPtr<TimeRanges> buffered() const;
     95    std::unique_ptr<PlatformTimeRanges> buffered() const;
    9696    float maxTimeSeekable() const;
    9797    bool didLoadingProgress() const;
  • trunk/Source/WebCore/platform/graphics/wince/MediaPlayerPrivateWinCE.h

    r157834 r164498  
    6969        MediaPlayer::ReadyState readyState() const { return m_readyState; }
    7070
    71         PassRefPtr<TimeRanges> buffered() const;
     71        std::unique_ptr<PlatformTimeRanges> buffered() const;
    7272        float maxTimeSeekable() const;
    7373        // 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  
    167167}
    168168
    169 PassRefPtr<TimeRanges> MockMediaPlayerMediaSource::buffered() const
    170 {
    171     return m_mediaSource ? m_mediaSource->buffered() : TimeRanges::create();
     169std::unique_ptr<PlatformTimeRanges> MockMediaPlayerMediaSource::buffered() const
     170{
     171    if (m_mediaSource)
     172        return m_mediaSource->buffered();
     173
     174    return PlatformTimeRanges::create();
    172175}
    173176
     
    210213void MockMediaPlayerMediaSource::advanceCurrentTime()
    211214{
    212     RefPtr<TimeRanges> buffered = this->buffered();
     215    if (!m_mediaSource)
     216        return;
     217
     218    auto buffered = m_mediaSource->buffered();
    213219    size_t pos = buffered->find(m_currentTime.toDouble());
    214220    if (pos == notFound)
    215221        return;
    216222
    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)));
    218225    m_player->timeChanged();
    219226}
  • trunk/Source/WebCore/platform/mock/mediasource/MockMediaPlayerMediaSource.h

    r163816 r164498  
    7171    virtual MediaPlayer::NetworkState networkState() const override;
    7272    virtual double maxTimeSeekableDouble() const override;
    73     virtual PassRefPtr<TimeRanges> buffered() const override;
     73    virtual std::unique_ptr<PlatformTimeRanges> buffered() const override;
    7474    virtual bool didLoadingProgress() const override;
    7575    virtual void setSize(const IntSize&) override;
  • trunk/Source/WebKit/ChangeLog

    r164438 r164498  
     12014-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
    1102014-02-20  Enrique Ocaña González  <eocanha@igalia.com>
    211
  • trunk/Source/WebKit/WebKit.vcxproj/WebKitExportGenerator/WebKitExports.def.in

    r164401 r164498  
    453453        symbolWithPointer(?nearest@TimeRanges@WebCore@@QBENN@Z, ?nearest@TimeRanges@WebCore@@QEBANN@Z)
    454454        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)
    455456#if USE(GSTREAMER)
    456457        symbolWithPointer(?simulateAudioInterruption@MediaPlayer@WebCore@@QAEXXZ, ?simulateAudioInterruption@MediaPlayer@WebCore@@QEAAXXZ)
  • trunk/Tools/ChangeLog

    r164487 r164498  
     12014-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
    1112014-02-21  Diego Pino García  <dpino@igalia.com>
    212
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/TimeRanges.cpp

    r160749 r164498  
    116116    ASSERT_RANGE("{ [0,2) }", ranges);
    117117
    118     ranges->intersectWith(ranges.get());
     118    ranges->intersectWith(*ranges.get());
    119119
    120120    ASSERT_RANGE("{ [0,2) }", ranges);
     
    129129    ASSERT_RANGE("{ [0,2) }", rangesB);
    130130
    131     rangesA->intersectWith(rangesB.get());
     131    rangesA->intersectWith(*rangesB.get());
    132132
    133133    ASSERT_RANGE("{ [0,2) }", rangesA);
     
    143143    ASSERT_RANGE("{ }", rangesB);
    144144
    145     rangesA->intersectWith(rangesB.get());
     145    rangesA->intersectWith(*rangesB.get());
    146146
    147147    ASSERT_RANGE("{ }", rangesA);
     
    151151TEST(TimeRanges, IntersectWith_DisjointRanges1)
    152152{
     153   
    153154    RefPtr<TimeRanges> rangesA = TimeRanges::create();
    154155    RefPtr<TimeRanges> rangesB = TimeRanges::create();
     
    163164    ASSERT_RANGE("{ [2,3) [6,7) }", rangesB);
    164165
    165     rangesA->intersectWith(rangesB.get());
     166    rangesA->intersectWith(*rangesB.get());
    166167
    167168    ASSERT_RANGE("{ }", rangesA);
     
    183184    ASSERT_RANGE("{ [1,4) [5,7) }", rangesB);
    184185
    185     rangesA->intersectWith(rangesB.get());
     186    rangesA->intersectWith(*rangesB.get());
    186187
    187188    ASSERT_RANGE("{ }", rangesA);
     
    203204    ASSERT_RANGE("{ [0,10) }", rangesB);
    204205
    205     rangesA->intersectWith(rangesB.get());
     206    rangesA->intersectWith(*rangesB.get());
    206207
    207208    ASSERT_RANGE("{ [1,3) [4,5) [6,9) }", rangesA);
     
    223224    ASSERT_RANGE("{ [1,9) }", rangesB);
    224225
    225     rangesA->intersectWith(rangesB.get());
     226    rangesA->intersectWith(*rangesB.get());
    226227
    227228    ASSERT_RANGE("{ [1,3) [4,5) [6,9) }", rangesA);
     
    242243    ASSERT_RANGE("{ [1,5) }", rangesB);
    243244
    244     rangesA->intersectWith(rangesB.get());
     245    rangesA->intersectWith(*rangesB.get());
    245246
    246247    ASSERT_RANGE("{ [1,2) [4,5) }", rangesA);
     
    262263    ASSERT_RANGE("{ [1,9) }", rangesB);
    263264
    264     rangesA->intersectWith(rangesB.get());
     265    rangesA->intersectWith(*rangesB.get());
    265266
    266267    ASSERT_RANGE("{ [1,2) [4,6) [8,9) }", rangesA);
     
    283284    ASSERT_RANGE("{ [1,5) [6,9) }", rangesB);
    284285
    285     rangesA->intersectWith(rangesB.get());
     286    rangesA->intersectWith(*rangesB.get());
    286287
    287288    ASSERT_RANGE("{ [1,2) [4,5) [6,7) [8,9) }", rangesA);
Note: See TracChangeset for help on using the changeset viewer.