[Mac, iOS] Captions are appearing multiple times during repeated video play through
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Aug 2014 16:23:05 +0000 (16:23 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 7 Aug 2014 16:23:05 +0000 (16:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=135680
Source/WebCore:

<rdar://problem/17926802>

Reviewed by Eric Carlson.

Test: media/track/track-in-band-cues-added-once.html

Revert TextTrackCueGeneric::isOrderedBefore logic to its original form, and add
a new 'isOrderedBeforeDuringDisplay' for the special case of displaying captions.

* html/shadow/MediaControlElements.cpp:
(WebCore::compareCueIntervalForDisplay): Added helper function.
(WebCore::MediaControlTextTrackContainerElement::updateDisplay): Use the new
'isOrderedBeforeDuringDisplay' to order the cues for display.
* html/track/TextTrackCue.h:
(WebCore::TextTrackCue::isOrderedBeforeDuringDisplay): Added. This just
calls the existing 'isOrderedBefore' method.
* html/track/TextTrackCueGeneric.cpp:
(WebCore::TextTrackCueGeneric::isOrderedBefore): Revert to logic used
prior to r171700.
(WebCore::TextTrackCueGeneric::isOrderedBeforeDuringDisplay): New method that
implements the behavior in r171700.
* html/track/TextTrackCueGeneric.h:

LayoutTests:

<rdar://problem/17926802>

Reviewed by Eric Carlson.

Reactivate the 'track-in-band-cues-added-once.html' test. We would have caught
this bug immediately if the test had been enabled.

* platform/mac/TestExpectations: Turn 'track-in-band-cues-added-once.html' back
on.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/html/track/TextTrackCue.h
Source/WebCore/html/track/TextTrackCueGeneric.cpp
Source/WebCore/html/track/TextTrackCueGeneric.h

index 3930a80..f871629 100644 (file)
@@ -1,3 +1,17 @@
+2014-08-06  Brent Fulgham  <bfulgham@apple.com>
+
+        [Mac, iOS] Captions are appearing multiple times during repeated video play through
+        https://bugs.webkit.org/show_bug.cgi?id=135680
+        <rdar://problem/17926802> 
+
+        Reviewed by Eric Carlson.
+
+        Reactivate the 'track-in-band-cues-added-once.html' test. We would have caught
+        this bug immediately if the test had been enabled.
+
+        * platform/mac/TestExpectations: Turn 'track-in-band-cues-added-once.html' back
+        on.
+
 2014-08-07  Michał Pakuła vel Rutka  <m.pakula@samsung.com>
 
         Unreviewed EFL gardening
index bba7bea..3bfad43 100755 (executable)
@@ -1195,8 +1195,6 @@ webkit.org/b/123489 [ Mavericks ] inspector-protocol/debugger/setBreakpoint-opti
 
 webkit.org/b/123490 [ Mavericks ] webaudio/oscillator-sawtooth.html [ Failure ]
 
-webkit.org/b/123498 [ Mavericks ] media/track/track-in-band-cues-added-once.html [ Failure ]
-
 webkit.org/b/123522 [ Mavericks ] media/track/track-in-band-legacy-api.html [ Pass Failure ]
 
 # Audio and video tracks aren't supported on mac
index a748fee..ada0af4 100644 (file)
@@ -1,3 +1,30 @@
+2014-08-06  Brent Fulgham  <bfulgham@apple.com>
+
+        [Mac, iOS] Captions are appearing multiple times during repeated video play through
+        https://bugs.webkit.org/show_bug.cgi?id=135680
+        <rdar://problem/17926802>
+
+        Reviewed by Eric Carlson.
+
+        Test: media/track/track-in-band-cues-added-once.html
+
+        Revert TextTrackCueGeneric::isOrderedBefore logic to its original form, and add
+        a new 'isOrderedBeforeDuringDisplay' for the special case of displaying captions.
+
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::compareCueIntervalForDisplay): Added helper function.
+        (WebCore::MediaControlTextTrackContainerElement::updateDisplay): Use the new
+        'isOrderedBeforeDuringDisplay' to order the cues for display.
+        * html/track/TextTrackCue.h:
+        (WebCore::TextTrackCue::isOrderedBeforeDuringDisplay): Added. This just
+        calls the existing 'isOrderedBefore' method.
+        * html/track/TextTrackCueGeneric.cpp:
+        (WebCore::TextTrackCueGeneric::isOrderedBefore): Revert to logic used
+        prior to r171700.
+        (WebCore::TextTrackCueGeneric::isOrderedBeforeDuringDisplay): New method that
+        implements the behavior in r171700.
+        * html/track/TextTrackCueGeneric.h:
+
 2014-08-07  Jer Noble  <jer.noble@apple.com>
 
         [Mac] Taking a paused video full screen flashes black at beginning of animation.
index 7583518..fef21eb 100644 (file)
@@ -1096,6 +1096,11 @@ RenderPtr<RenderElement> MediaControlTextTrackContainerElement::createElementRen
     return createRenderer<RenderTextTrackContainerElement>(*this, WTF::move(style));
 }
 
+static bool compareCueIntervalForDisplay(const CueInterval& one, const CueInterval& two)
+{
+    return one.data()->isPositionedAbove(two.data());
+};
+
 void MediaControlTextTrackContainerElement::updateDisplay()
 {
     if (!mediaController()->closedCaptionsVisible())
@@ -1149,7 +1154,12 @@ void MediaControlTextTrackContainerElement::updateDisplay()
     // them so that the new cue is at the bottom.
     if (childNodeCount() < activeCues.size())
         removeChildren();
-    
+
+    // Sort the active cues for the appropriate display order. For example, for roll-up
+    // or paint-on captions, we need to add the cues in reverse chronological order,
+    // so that the newest captions appear at the bottom.
+    std::sort(activeCues.begin(), activeCues.end(), &compareCueIntervalForDisplay);
+
     // 10. For each text track cue cue in cues that has not yet had
     // corresponding CSS boxes added to output, in text track cue order, run the
     // following substeps:
index bc399fb..1e3421d 100644 (file)
@@ -82,6 +82,7 @@ public:
     virtual ScriptExecutionContext* scriptExecutionContext() const override final { return &m_scriptExecutionContext; }
 
     virtual bool isOrderedBefore(const TextTrackCue*) const;
+    virtual bool isPositionedAbove(const TextTrackCue* cue) const { return isOrderedBefore(cue); }
 
     bool hasEquivalentStartTime(const TextTrackCue&) const;
 
index 7723201..887947c 100644 (file)
@@ -202,6 +202,9 @@ bool TextTrackCueGeneric::doesExtendCue(const TextTrackCue& cue) const
 
 bool TextTrackCueGeneric::isOrderedBefore(const TextTrackCue* that) const
 {
+    if (VTTCue::isOrderedBefore(that))
+        return true;
+
     if (that->cueType() == Generic && startTime() == that->startTime() && endTime() == that->endTime()) {
         // Further order generic cues by their calculated line value.
         std::pair<double, double> thisPosition = getPositionCoordinates();
@@ -209,6 +212,18 @@ bool TextTrackCueGeneric::isOrderedBefore(const TextTrackCue* that) const
         return thisPosition.second > thatPosition.second || (thisPosition.second == thatPosition.second && thisPosition.first < thatPosition.first);
     }
 
+    return false;
+}
+
+bool TextTrackCueGeneric::isPositionedAbove(const TextTrackCue* that) const
+{
+    if (that->cueType() == Generic && startTime() == that->startTime() && endTime() == that->endTime()) {
+        // Further order generic cues by their calculated line value.
+        std::pair<double, double> thisPosition = getPositionCoordinates();
+        std::pair<double, double> thatPosition = toVTTCue(that)->getPositionCoordinates();
+        return thisPosition.second > thatPosition.second || (thisPosition.second == thatPosition.second && thisPosition.first < thatPosition.first);
+    }
+    
     if (that->cueType() == Generic)
         return startTime() > that->startTime();
     
index 686e3dd..6db791b 100644 (file)
@@ -80,6 +80,7 @@ public:
 
 private:
     virtual bool isOrderedBefore(const TextTrackCue*) const override;
+    virtual bool isPositionedAbove(const TextTrackCue*) const override;
 
     TextTrackCueGeneric(ScriptExecutionContext&, double start, double end, const String&);