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 // 4. If the user agent is exposing a user interface for video, add to | 76 // 4. If the user agent is exposing a user interface for video, add to |
77 // output one or more completely transparent positioned CSS block boxes that | 77 // output one or more completely transparent positioned CSS block boxes that |
78 // cover the same region as the user interface. | 78 // cover the same region as the user interface. |
79 | 79 |
| 80 // Note: Overlap checking for the controls is implemented in LayoutVTTCue |
| 81 // without a placeholder box (element or layout object). |
| 82 |
80 // 5. If the last time these rules were run, the user agent was not exposing | 83 // 5. If the last time these rules were run, the user agent was not exposing |
81 // a user interface for video, but now it is, let reset be true. Otherwise, | 84 // a user interface for video, but now it is, optionally let reset be true. |
82 // let reset be false. | 85 // Otherwise, let reset be false. |
83 | 86 bool reset = exposingControls == DidStartExposingControls; |
84 // TODO(philipj): Implement step 4 and 5. | |
85 | 87 |
86 // 6. Let tracks be the subset of video's list of text tracks that have as | 88 // 6. Let tracks be the subset of video's list of text tracks that have as |
87 // their rules for updating the text track rendering these rules for | 89 // their rules for updating the text track rendering these rules for |
88 // updating the display of WebVTT text tracks, and whose text track mode is | 90 // updating the display of WebVTT text tracks, and whose text track mode is |
89 // showing or showing by default. | 91 // showing or showing by default. |
90 // 7. Let cues be an empty list of text track cues. | 92 // 7. Let cues be an empty list of text track cues. |
91 // 8. For each track track in tracks, append to cues all the cues from | 93 // 8. For each track track in tracks, append to cues all the cues from |
92 // track's list of cues that have their text track cue active flag set. | 94 // track's list of cues that have their text track cue active flag set. |
93 const CueList& activeCues = video.cueTimeline().currentlyActiveCues(); | 95 const CueList& activeCues = video.cueTimeline().currentlyActiveCues(); |
94 | 96 |
95 // 9. If reset is false, then, for each text track cue cue in cues: if cue's | 97 // 9. If reset is false, then, for each text track cue cue in cues: if cue's |
96 // text track cue display state has a set of CSS boxes, then add those boxes | 98 // text track cue display state has a set of CSS boxes, then add those boxes |
97 // to output, and remove cue from cues. | 99 // to output, and remove cue from cues. |
98 | 100 |
99 // There is nothing explicitly to be done here, as all the caching occurs | 101 // Note: Removing all children will cause them to be re-inserted below, |
100 // within the TextTrackCue instance itself. If parameters of the cue change, | 102 // invalidating the layout. |
101 // the display tree is cleared. | 103 // effect |
| 104 if (reset) |
| 105 removeChildren(); |
102 | 106 |
103 // 10. For each text track cue cue in cues that has not yet had | 107 // 10. For each text track cue cue in cues that has not yet had |
104 // corresponding CSS boxes added to output, in text track cue order, run the | 108 // corresponding CSS boxes added to output, in text track cue order, run the |
105 // following substeps: | 109 // following substeps: |
106 double movieTime = video.currentTime(); | 110 double movieTime = video.currentTime(); |
107 for (size_t i = 0; i < activeCues.size(); ++i) { | 111 for (size_t i = 0; i < activeCues.size(); ++i) { |
108 TextTrackCue* cue = activeCues[i].data(); | 112 TextTrackCue* cue = activeCues[i].data(); |
109 | 113 |
110 ASSERT(cue->isActive()); | 114 ASSERT(cue->isActive()); |
111 if (!cue->track() || !cue->track()->isRendered() || !cue->isActive()) | 115 if (!cue->track() || !cue->track()->isRendered() || !cue->isActive()) |
112 continue; | 116 continue; |
113 | 117 |
114 cue->updateDisplay(*this); | 118 cue->updateDisplay(*this); |
115 cue->updatePastAndFutureNodes(movieTime); | 119 cue->updatePastAndFutureNodes(movieTime); |
116 } | 120 } |
117 | 121 |
118 // 11. Return output. | 122 // 11. Return output. |
119 } | 123 } |
120 | 124 |
121 } // namespace blink | 125 } // namespace blink |
OLD | NEW |