[Mac] DataCues do not work properly when rewinding video
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 May 2014 04:08:33 +0000 (04:08 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 May 2014 04:08:33 +0000 (04:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=133138
<rdar://problem/16979086>

Reviewed by Eric Carlson.

Make the TrackPrivateBase responsible for knowing if a type of track needs a non-zero
startTimeVariance value.

Also, correct a bug in the equality test for DataCue objects.

* html/track/DataCue.cpp:
(WebCore::DataCue::isEqual): Handle the JSValue data types consistently, so that we don't attempt
to compare a JSNull against a default JSValue object.
* html/track/InbandTextTrack.cpp:
(WebCore::InbandTextTrack::startTimeVariance): Added.
* html/track/InbandTextTrack.h:
* html/track/TextTrack.cpp:
(WebCore::TextTrack::hasCue): Use new startTimeVariance method location.
* html/track/TextTrack.h:
(WebCore::TextTrack::startTimeVariance): Added.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::hasEquivalentStartTime): Use new startTimeVariance location.
* html/track/TextTrackCue.h:
(WebCore::TextTrackCue::startTimeVariance): Deleted.
* html/track/TextTrackCueGeneric.h:
* platform/graphics/TrackPrivateBase.h:
(WebCore::TrackPrivateBase::startTimeVariance): Added.
* platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@169146 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/html/track/DataCue.cpp
Source/WebCore/html/track/InbandTextTrack.cpp
Source/WebCore/html/track/InbandTextTrack.h
Source/WebCore/html/track/TextTrack.cpp
Source/WebCore/html/track/TextTrack.h
Source/WebCore/html/track/TextTrackCue.cpp
Source/WebCore/html/track/TextTrackCue.h
Source/WebCore/html/track/TextTrackCueGeneric.h
Source/WebCore/platform/graphics/TrackPrivateBase.h
Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h

index 3c0811c..3ab28ad 100644 (file)
@@ -1,3 +1,35 @@
+2014-05-20  Brent Fulgham  <bfulgham@apple.com>
+
+        [Mac] DataCues do not work properly when rewinding video
+        https://bugs.webkit.org/show_bug.cgi?id=133138
+        <rdar://problem/16979086>
+
+        Reviewed by Eric Carlson.
+
+        Make the TrackPrivateBase responsible for knowing if a type of track needs a non-zero
+        startTimeVariance value.
+
+        Also, correct a bug in the equality test for DataCue objects.
+
+        * html/track/DataCue.cpp:
+        (WebCore::DataCue::isEqual): Handle the JSValue data types consistently, so that we don't attempt
+        to compare a JSNull against a default JSValue object.
+        * html/track/InbandTextTrack.cpp:
+        (WebCore::InbandTextTrack::startTimeVariance): Added.
+        * html/track/InbandTextTrack.h:
+        * html/track/TextTrack.cpp:
+        (WebCore::TextTrack::hasCue): Use new startTimeVariance method location.
+        * html/track/TextTrack.h:
+        (WebCore::TextTrack::startTimeVariance): Added.
+        * html/track/TextTrackCue.cpp:
+        (WebCore::TextTrackCue::hasEquivalentStartTime): Use new startTimeVariance location.
+        * html/track/TextTrackCue.h:
+        (WebCore::TextTrackCue::startTimeVariance): Deleted.
+        * html/track/TextTrackCueGeneric.h:
+        * platform/graphics/TrackPrivateBase.h:
+        (WebCore::TrackPrivateBase::startTimeVariance): Added.
+        * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.h:
+
 2014-05-20  Mark Hahnenberg  <mhahnenberg@apple.com>
 
         Watchdog timer should be lazily allocated
index 79961ad..f252484 100644 (file)
@@ -145,10 +145,11 @@ bool DataCue::isEqual(const TextTrackCue& cue, TextTrackCue::CueMatchRules match
     if (m_platformValue && !m_platformValue->isEqual(*otherPlatformValue.get()))
         return false;
 
+    JSC::JSValue thisValue = value(nullptr);
     JSC::JSValue otherValue = dataCue->value(nullptr);
-    if ((otherValue && !m_value) || (!otherValue && m_value))
+    if ((otherValue && !thisValue) || (!otherValue && thisValue))
         return false;
-    if (!JSC::JSValue::strictEqual(nullptr, m_value ? m_value : JSC::JSValue(), otherValue))
+    if (!JSC::JSValue::strictEqual(nullptr, thisValue, otherValue))
         return false;
 #endif
 
index 7100b86..03ecf4e 100644 (file)
@@ -213,6 +213,14 @@ void InbandTextTrack::updateKindFromPrivate()
     }
 }
 
+double InbandTextTrack::startTimeVariance() const
+{
+    if (!m_private)
+        return false;
+    
+    return m_private->startTimeVariance();
+}
+
 } // namespace WebCore
 
 #endif
index 51fc805..2b3ff1a 100644 (file)
@@ -82,6 +82,7 @@ private:
     virtual void removeGenericCue(InbandTextTrackPrivate*, GenericCueData*) override { ASSERT_NOT_REACHED(); }
 
     virtual void parseWebVTTCueData(InbandTextTrackPrivate*, const char*, unsigned) override { ASSERT_NOT_REACHED(); }
+    virtual double startTimeVariance() const;
 
 #if USE(PLATFORM_TEXT_TRACK_MENU)
     virtual InbandTextTrackPrivate* privateTrack() override { return m_private.get(); }
index 14e5e21..f376a78 100644 (file)
@@ -519,7 +519,7 @@ bool TextTrack::hasCue(TextTrackCue* cue, TextTrackCue::CueMatchRules match)
                     return false;
 
                 existingCue = m_cues->item(searchStart - 1);
-                if (!existingCue || cue->startTime() > (existingCue->startTime() + existingCue->startTimeVariance()))
+                if (!existingCue || cue->startTime() > (existingCue->startTime() + startTimeVariance()))
                     return false;
 
                 if (!existingCue->isEqual(*cue, match))
@@ -531,7 +531,7 @@ bool TextTrack::hasCue(TextTrackCue* cue, TextTrackCue::CueMatchRules match)
         
         size_t index = (searchStart + searchEnd) / 2;
         existingCue = m_cues->item(index);
-        if ((cue->startTime() + existingCue->startTimeVariance()) < existingCue->startTime() || (match != TextTrackCue::IgnoreDuration && cue->hasEquivalentStartTime(*existingCue) && cue->endTime() > existingCue->endTime()))
+        if ((cue->startTime() + startTimeVariance()) < existingCue->startTime() || (match != TextTrackCue::IgnoreDuration && cue->hasEquivalentStartTime(*existingCue) && cue->endTime() > existingCue->endTime()))
             searchEnd = index;
         else
             searchStart = index + 1;
index 771b710..9a26445 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2011 Google Inc. All rights reserved.
- * Copyright (C) 2011, 2012, 2013 Apple Inc.  All rights reserved.
+ * Copyright (C) 2011, 2012, 2013, 2014 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -158,6 +158,8 @@ public:
 
     virtual bool isInband() const { return false; }
 
+    virtual double startTimeVariance() const { return 0; }
+
     using RefCounted<TrackBase>::ref;
     using RefCounted<TrackBase>::deref;
 
index e686455..41f4e24 100644 (file)
@@ -219,7 +219,13 @@ bool TextTrackCue::isEqual(const TextTrackCue& cue, TextTrackCue::CueMatchRules
 
 bool TextTrackCue::hasEquivalentStartTime(const TextTrackCue& cue) const
 {
-    return std::abs(std::abs(startTime()) - std::abs(cue.startTime())) < startTimeVariance();
+    double startTimeVariance = 0;
+    if (track())
+        startTimeVariance = track()->startTimeVariance();
+    else if (cue.track())
+        startTimeVariance = cue.track()->startTimeVariance();
+
+    return std::abs(std::abs(startTime()) - std::abs(cue.startTime())) <= startTimeVariance;
 }
 
 } // namespace WebCore
index b86611a..207e43d 100644 (file)
@@ -84,7 +84,6 @@ public:
     virtual bool isOrderedBefore(const TextTrackCue*) const;
 
     bool hasEquivalentStartTime(const TextTrackCue&) const;
-    virtual double startTimeVariance() const { return 0; }
 
     enum CueType {
         Data,
index 7ef8ae9..c1134ad 100644 (file)
@@ -78,7 +78,6 @@ public:
 
 private:
     virtual bool isOrderedBefore(const TextTrackCue*) const override;
-    virtual double startTimeVariance() const override { return 0.25; }
 
     TextTrackCueGeneric(ScriptExecutionContext&, double start, double end, const String&);
     
index 602b469..a7339bc 100644 (file)
@@ -61,6 +61,8 @@ public:
 
     virtual int trackIndex() const { return 0; }
 
+    virtual double startTimeVariance() const { return 0; }
+    
     void willBeRemoved()
     {
         if (TrackPrivateBaseClient* client = this->client())
index 2361561..4f9f517 100644 (file)
@@ -69,6 +69,8 @@ public:
     };
     virtual Category textTrackCategory() const = 0;
     
+    virtual double startTimeVariance() const override { return 0.25; }
+    
 protected:
     InbandTextTrackPrivateAVF(AVFInbandTrackParent*);