| 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 15 matching lines...) Expand all Loading... |
| 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | 26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 */ | 28 */ |
| 29 | 29 |
| 30 #include "config.h" | 30 #include "config.h" |
| 31 #include "core/html/track/TextTrackContainer.h" | 31 #include "core/html/track/TextTrackContainer.h" |
| 32 | 32 |
| 33 #include "core/html/HTMLVideoElement.h" | 33 #include "core/html/HTMLVideoElement.h" |
| 34 #include "core/html/track/CueTimeline.h" | 34 #include "core/html/track/CueTimeline.h" |
| 35 #include "core/layout/LayoutTextTrackContainer.h" | 35 #include "core/layout/LayoutTextTrackContainer.h" |
| 36 #include "core/layout/LayoutVideo.h" | |
| 37 | 36 |
| 38 namespace blink { | 37 namespace blink { |
| 39 | 38 |
| 40 TextTrackContainer::TextTrackContainer(Document& document) | 39 TextTrackContainer::TextTrackContainer(Document& document) |
| 41 : HTMLDivElement(document) | 40 : HTMLDivElement(document) |
| 42 , m_fontSize(0) | |
| 43 { | 41 { |
| 44 } | 42 } |
| 45 | 43 |
| 46 PassRefPtrWillBeRawPtr<TextTrackContainer> TextTrackContainer::create(Document&
document) | 44 PassRefPtrWillBeRawPtr<TextTrackContainer> TextTrackContainer::create(Document&
document) |
| 47 { | 45 { |
| 48 RefPtrWillBeRawPtr<TextTrackContainer> element = adoptRefWillBeNoop(new Text
TrackContainer(document)); | 46 RefPtrWillBeRawPtr<TextTrackContainer> element = adoptRefWillBeNoop(new Text
TrackContainer(document)); |
| 49 element->setShadowPseudoId(AtomicString("-webkit-media-text-track-container"
, AtomicString::ConstructFromLiteral)); | 47 element->setShadowPseudoId(AtomicString("-webkit-media-text-track-container"
, AtomicString::ConstructFromLiteral)); |
| 50 element->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone); | 48 element->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone); |
| 51 return element.release(); | 49 return element.release(); |
| 52 } | 50 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 cue->updateDisplay(*this); | 114 cue->updateDisplay(*this); |
| 117 } | 115 } |
| 118 | 116 |
| 119 // 11. Return output. | 117 // 11. Return output. |
| 120 if (hasChildren()) | 118 if (hasChildren()) |
| 121 removeInlineStyleProperty(CSSPropertyDisplay); | 119 removeInlineStyleProperty(CSSPropertyDisplay); |
| 122 else | 120 else |
| 123 setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone); | 121 setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone); |
| 124 } | 122 } |
| 125 | 123 |
| 126 void TextTrackContainer::updateSizes(LayoutObject* mediaElementLayoutObject) | |
| 127 { | |
| 128 if (!document().isActive()) | |
| 129 return; | |
| 130 | |
| 131 if (!mediaElementLayoutObject || !mediaElementLayoutObject->isVideo()) | |
| 132 return; | |
| 133 | |
| 134 // FIXME: The video size is used to calculate the font size (a workaround | |
| 135 // for lack of per-spec vh/vw support) but the whole media element is used | |
| 136 // for cue rendering. This is inconsistent. See also the somewhat related | |
| 137 // spec bug: https://www.w3.org/Bugs/Public/show_bug.cgi?id=28105 | |
| 138 IntSize videoSize = toLayoutVideo(mediaElementLayoutObject)->videoBox().size
(); | |
| 139 | |
| 140 if (m_videoSize == videoSize) | |
| 141 return; | |
| 142 m_videoSize = videoSize; | |
| 143 | |
| 144 float smallestDimension = std::min(m_videoSize.height(), m_videoSize.width()
); | |
| 145 | |
| 146 float fontSize = smallestDimension * 0.05f; | |
| 147 if (fontSize != m_fontSize) { | |
| 148 m_fontSize = fontSize; | |
| 149 setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue:
:CSS_PX); | |
| 150 } | |
| 151 } | |
| 152 | |
| 153 } // namespace blink | 124 } // namespace blink |
| OLD | NEW |