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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 RefPtrWillBeRawPtr<TextTrackContainer> element = adoptRefWillBeNoop(new Text
TrackContainer(document)); | 48 RefPtrWillBeRawPtr<TextTrackContainer> element = adoptRefWillBeNoop(new Text
TrackContainer(document)); |
49 element->setShadowPseudoId(AtomicString("-webkit-media-text-track-container"
, AtomicString::ConstructFromLiteral)); | 49 element->setShadowPseudoId(AtomicString("-webkit-media-text-track-container"
, AtomicString::ConstructFromLiteral)); |
50 return element.release(); | 50 return element.release(); |
51 } | 51 } |
52 | 52 |
53 LayoutObject* TextTrackContainer::createRenderer(const LayoutStyle&) | 53 LayoutObject* TextTrackContainer::createRenderer(const LayoutStyle&) |
54 { | 54 { |
55 return new LayoutTextTrackContainer(this); | 55 return new LayoutTextTrackContainer(this); |
56 } | 56 } |
57 | 57 |
58 void TextTrackContainer::updateDisplay(HTMLMediaElement& mediaElement) | 58 void TextTrackContainer::updateDisplay(HTMLVideoElement& video) |
59 { | 59 { |
60 if (!mediaElement.closedCaptionsVisible()) { | 60 if (!video.closedCaptionsVisible()) { |
61 removeChildren(); | 61 removeChildren(); |
62 return; | 62 return; |
63 } | 63 } |
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)) | |
69 return; | |
70 | 68 |
71 // 2. Let video be the media element or other playback mechanism. | 69 // 2. Let video be the media element or other playback mechanism. |
72 HTMLVideoElement& video = toHTMLVideoElement(mediaElement); | |
73 | 70 |
74 // 3. Let output be an empty list of absolutely positioned CSS block boxes. | 71 // 3. Let output be an empty list of absolutely positioned CSS block boxes. |
75 | 72 |
76 // 4. If the user agent is exposing a user interface for video, add to | 73 // 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 | 74 // output one or more completely transparent positioned CSS block boxes that |
78 // cover the same region as the user interface. | 75 // cover the same region as the user interface. |
79 | 76 |
80 // 5. If the last time these rules were run, the user agent was not exposing | 77 // 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, | 78 // a user interface for video, but now it is, let reset be true. Otherwise, |
82 // let reset be false. | 79 // let reset be false. |
(...skipping 28 matching lines...) Expand all Loading... |
111 ASSERT(cue->isActive()); | 108 ASSERT(cue->isActive()); |
112 if (!cue->track() || !cue->track()->isRendered() || !cue->isActive()) | 109 if (!cue->track() || !cue->track()->isRendered() || !cue->isActive()) |
113 continue; | 110 continue; |
114 | 111 |
115 cue->updateDisplay(*this); | 112 cue->updateDisplay(*this); |
116 } | 113 } |
117 | 114 |
118 // 11. Return output. | 115 // 11. Return output. |
119 } | 116 } |
120 | 117 |
121 void TextTrackContainer::updateSizes(HTMLMediaElement& mediaElement) | 118 void TextTrackContainer::updateSizes(const LayoutSize& videoSize) |
122 { | 119 { |
123 if (!document().isActive()) | |
124 return; | |
125 | |
126 if (!mediaElement.renderer() || !mediaElement.renderer()->isVideo()) | |
127 return; | |
128 | |
129 // FIXME: The video size is used to calculate the font size (a workaround | 120 // FIXME: The video size is used to calculate the font size (a workaround |
130 // for lack of per-spec vh/vw support) but the whole media element is used | 121 // for lack of per-spec vh/vw support) but the whole media element is used |
131 // for cue rendering. This is inconsistent. See also the somewhat related | 122 // for cue rendering. This is inconsistent. See also the somewhat related |
132 // spec bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=28105 | 123 // spec bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=28105 |
133 IntSize videoSize = toLayoutVideo(mediaElement.renderer())->videoBox().size(
); | |
134 | 124 |
135 if (m_videoSize == videoSize) | 125 if (m_videoSize == videoSize) |
136 return; | 126 return; |
137 m_videoSize = videoSize; | 127 m_videoSize = videoSize; |
138 | 128 |
139 float smallestDimension = std::min(m_videoSize.height(), m_videoSize.width()
); | 129 float smallestDimension = std::min(m_videoSize.height().toFloat(), m_videoSi
ze.width().toFloat()); |
140 | 130 |
141 float fontSize = smallestDimension * 0.05f; | 131 float fontSize = smallestDimension * 0.05f; |
142 if (fontSize != m_fontSize) { | 132 if (fontSize != m_fontSize) { |
143 m_fontSize = fontSize; | 133 m_fontSize = fontSize; |
144 setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue:
:CSS_PX); | 134 setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue:
:CSS_PX); |
145 } | 135 } |
146 } | 136 } |
147 | 137 |
148 } // namespace blink | 138 } // namespace blink |
OLD | NEW |