| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 RefPtrWillBeRawPtr<TextTrackContainer> element = adoptRefWillBeNoop(new Text
TrackContainer(document)); | 46 RefPtrWillBeRawPtr<TextTrackContainer> element = adoptRefWillBeNoop(new Text
TrackContainer(document)); |
| 47 element->setShadowPseudoId(AtomicString("-webkit-media-text-track-container"
, AtomicString::ConstructFromLiteral)); | 47 element->setShadowPseudoId(AtomicString("-webkit-media-text-track-container"
, AtomicString::ConstructFromLiteral)); |
| 48 return element.release(); | 48 return element.release(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 LayoutObject* TextTrackContainer::createLayoutObject(const LayoutStyle&) | 51 LayoutObject* TextTrackContainer::createLayoutObject(const LayoutStyle&) |
| 52 { | 52 { |
| 53 return new LayoutTextTrackContainer(this); | 53 return new LayoutTextTrackContainer(this); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void TextTrackContainer::updateDisplay(HTMLMediaElement& mediaElement) | 56 void TextTrackContainer::updateDisplay(HTMLMediaElement& mediaElement, ExposingC
ontrols exposingControls) |
| 57 { | 57 { |
| 58 if (!mediaElement.closedCaptionsVisible()) { | 58 if (!mediaElement.closedCaptionsVisible()) { |
| 59 removeChildren(); | 59 removeChildren(); |
| 60 return; | 60 return; |
| 61 } | 61 } |
| 62 | 62 |
| 63 // http://dev.w3.org/html5/webvtt/#dfn-rules-for-updating-the-display-of-web
vtt-text-tracks | 63 // http://dev.w3.org/html5/webvtt/#dfn-rules-for-updating-the-display-of-web
vtt-text-tracks |
| 64 | 64 |
| 65 // 1. If the media element is an audio element, or is another playback | 65 // 1. If the media element is an audio element, or is another playback |
| 66 // mechanism with no rendering area, abort these steps. There is nothing to | 66 // mechanism with no rendering area, abort these steps. There is nothing to |
| 67 // render. | 67 // render. |
| 68 if (isHTMLAudioElement(mediaElement)) | 68 if (isHTMLAudioElement(mediaElement)) |
| 69 return; | 69 return; |
| 70 | 70 |
| 71 // 2. Let video be the media element or other playback mechanism. | 71 // 2. Let video be the media element or other playback mechanism. |
| 72 HTMLVideoElement& video = toHTMLVideoElement(mediaElement); | 72 HTMLVideoElement& video = toHTMLVideoElement(mediaElement); |
| 73 | 73 |
| 74 // 3. Let output be an empty list of absolutely positioned CSS block boxes. | 74 // 3. Let output be an empty list of absolutely positioned CSS block boxes. |
| 75 | 75 |
| 76 // Note: This is a layout algorithm, expressed terms of appending CSS block | 76 // Note: This is a layout algorithm, expressed terms of appending CSS block |
| 77 // boxes to output, and the "apply WebVTT cue settings" part is implemented | 77 // boxes to output, and the "apply WebVTT cue settings" part is implemented |
| 78 // in LayoutVTTCue. Here we merely create the DOM tree from which the layout | 78 // in LayoutVTTCue. Here we merely create the DOM tree from which the layout |
| 79 // tree is built and append it to this TextTrackContainer. | 79 // tree is built and append it to this TextTrackContainer. |
| 80 | 80 |
| 81 // 4. If the user agent is exposing a user interface for video, add to | 81 // 4. If the user agent is exposing a user interface for video, add to |
| 82 // output one or more completely transparent positioned CSS block boxes that | 82 // output one or more completely transparent positioned CSS block boxes that |
| 83 // cover the same region as the user interface. | 83 // cover the same region as the user interface. |
| 84 | 84 |
| 85 // Note: Overlap checking for the controls is implemented in LayoutVTTCue |
| 86 // without a placeholder box (element or layout object). |
| 87 |
| 85 // 5. If the last time these rules were run, the user agent was not exposing | 88 // 5. If the last time these rules were run, the user agent was not exposing |
| 86 // a user interface for video, but now it is, let reset be true. Otherwise, | 89 // a user interface for video, but now it is, optionally let reset be true. |
| 87 // let reset be false. | 90 // Otherwise, let reset be false. |
| 88 | 91 bool reset = exposingControls == DidStartExposingControls; |
| 89 // TODO(philipj): Implement step 4 and 5. | |
| 90 | 92 |
| 91 // 6. Let tracks be the subset of video's list of text tracks that have as | 93 // 6. Let tracks be the subset of video's list of text tracks that have as |
| 92 // their rules for updating the text track rendering these rules for | 94 // their rules for updating the text track rendering these rules for |
| 93 // updating the display of WebVTT text tracks, and whose text track mode is | 95 // updating the display of WebVTT text tracks, and whose text track mode is |
| 94 // showing or showing by default. | 96 // showing or showing by default. |
| 95 // 7. Let cues be an empty list of text track cues. | 97 // 7. Let cues be an empty list of text track cues. |
| 96 // 8. For each track track in tracks, append to cues all the cues from | 98 // 8. For each track track in tracks, append to cues all the cues from |
| 97 // track's list of cues that have their text track cue active flag set. | 99 // track's list of cues that have their text track cue active flag set. |
| 98 const CueList& activeCues = video.cueTimeline().currentlyActiveCues(); | 100 const CueList& activeCues = video.cueTimeline().currentlyActiveCues(); |
| 99 | 101 |
| 100 // 9. If reset is false, then, for each text track cue cue in cues: if cue's | 102 // 9. If reset is false, then, for each text track cue cue in cues: if cue's |
| 101 // text track cue display state has a set of CSS boxes, then add those boxes | 103 // text track cue display state has a set of CSS boxes, then add those boxes |
| 102 // to output, and remove cue from cues. | 104 // to output, and remove cue from cues. |
| 103 | 105 |
| 104 // There is nothing explicitly to be done here, as all the caching occurs | 106 // Note: Removing all children will cause them to be re-inserted below, |
| 105 // within the TextTrackCue instance itself. If parameters of the cue change, | 107 // invalidating the layout. |
| 106 // the display tree is cleared. | 108 // effect |
| 109 if (reset) |
| 110 removeChildren(); |
| 107 | 111 |
| 108 // 10. For each text track cue cue in cues that has not yet had | 112 // 10. For each text track cue cue in cues that has not yet had |
| 109 // corresponding CSS boxes added to output, in text track cue order, run the | 113 // corresponding CSS boxes added to output, in text track cue order, run the |
| 110 // following substeps: | 114 // following substeps: |
| 111 double movieTime = video.currentTime(); | 115 double movieTime = video.currentTime(); |
| 112 for (size_t i = 0; i < activeCues.size(); ++i) { | 116 for (size_t i = 0; i < activeCues.size(); ++i) { |
| 113 TextTrackCue* cue = activeCues[i].data(); | 117 TextTrackCue* cue = activeCues[i].data(); |
| 114 | 118 |
| 115 ASSERT(cue->isActive()); | 119 ASSERT(cue->isActive()); |
| 116 if (!cue->track() || !cue->track()->isRendered() || !cue->isActive()) | 120 if (!cue->track() || !cue->track()->isRendered() || !cue->isActive()) |
| 117 continue; | 121 continue; |
| 118 | 122 |
| 119 cue->updateDisplay(*this); | 123 cue->updateDisplay(*this); |
| 120 cue->updatePastAndFutureNodes(movieTime); | 124 cue->updatePastAndFutureNodes(movieTime); |
| 121 } | 125 } |
| 122 | 126 |
| 123 // 11. Return output. | 127 // 11. Return output. |
| 124 // See the note for step 3 for why there is no output to return. | 128 // See the note for step 3 for why there is no output to return. |
| 125 } | 129 } |
| 126 | 130 |
| 127 } // namespace blink | 131 } // namespace blink |
| OLD | NEW |