2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
15 * its contributors may be used to endorse or promote products derived
16 * from this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
19 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
22 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
31 #include "core/html/shadow/MediaControlElements.h"
33 #include "bindings/v8/ExceptionStatePlaceholder.h"
34 #include "core/dom/DOMTokenList.h"
35 #include "core/dom/FullscreenElementStack.h"
36 #include "core/dom/shadow/ShadowRoot.h"
37 #include "core/events/MouseEvent.h"
38 #include "core/frame/LocalFrame.h"
39 #include "core/html/HTMLVideoElement.h"
40 #include "core/html/MediaController.h"
41 #include "core/html/shadow/MediaControls.h"
42 #include "core/html/track/TextTrack.h"
43 #include "core/html/track/vtt/VTTRegionList.h"
44 #include "core/page/EventHandler.h"
45 #include "core/rendering/RenderMediaControlElements.h"
46 #include "core/rendering/RenderSlider.h"
47 #include "core/rendering/RenderTheme.h"
48 #include "core/rendering/RenderVideo.h"
49 #include "platform/RuntimeEnabledFeatures.h"
53 using namespace HTMLNames;
55 static const AtomicString& getMediaControlCurrentTimeDisplayElementShadowPseudoId();
56 static const AtomicString& getMediaControlTimeRemainingDisplayElementShadowPseudoId();
58 // If you change any of the following fade durations, then also update the
59 // corresponding values in LayoutTests/media/media-controls.js.
60 static const double fadeInDuration = 0.1;
61 static const double fadeOutDuration = 0.3;
63 MediaControlPanelElement::MediaControlPanelElement(MediaControls& mediaControls)
64 : MediaControlDivElement(mediaControls, MediaControlsPanel)
65 , m_isDisplayed(false)
67 , m_transitionTimer(this, &MediaControlPanelElement::transitionTimerFired)
71 PassRefPtrWillBeRawPtr<MediaControlPanelElement> MediaControlPanelElement::create(MediaControls& mediaControls)
73 return adoptRefWillBeNoop(new MediaControlPanelElement(mediaControls));
76 const AtomicString& MediaControlPanelElement::shadowPseudoId() const
78 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-panel", AtomicString::ConstructFromLiteral));
82 void MediaControlPanelElement::defaultEventHandler(Event* event)
84 // Suppress the media element activation behavior (toggle play/pause) when
85 // any part of the control panel is clicked.
86 if (event->type() == EventTypeNames::click) {
87 event->setDefaultHandled();
90 HTMLDivElement::defaultEventHandler(event);
93 void MediaControlPanelElement::startTimer()
97 // The timer is required to set the property display:'none' on the panel,
98 // such that captions are correctly displayed at the bottom of the video
99 // at the end of the fadeout transition.
100 // FIXME: Racing a transition with a setTimeout like this is wrong.
101 m_transitionTimer.startOneShot(fadeOutDuration, FROM_HERE);
104 void MediaControlPanelElement::stopTimer()
106 if (m_transitionTimer.isActive())
107 m_transitionTimer.stop();
110 void MediaControlPanelElement::transitionTimerFired(Timer<MediaControlPanelElement>*)
118 void MediaControlPanelElement::makeOpaque()
123 setInlineStyleProperty(CSSPropertyTransitionProperty, CSSPropertyOpacity);
124 setInlineStyleProperty(CSSPropertyTransitionDuration, fadeInDuration, CSSPrimitiveValue::CSS_S);
125 setInlineStyleProperty(CSSPropertyOpacity, 1.0, CSSPrimitiveValue::CSS_NUMBER);
133 void MediaControlPanelElement::makeTransparent()
138 setInlineStyleProperty(CSSPropertyTransitionProperty, CSSPropertyOpacity);
139 setInlineStyleProperty(CSSPropertyTransitionDuration, fadeOutDuration, CSSPrimitiveValue::CSS_S);
140 setInlineStyleProperty(CSSPropertyOpacity, 0.0, CSSPrimitiveValue::CSS_NUMBER);
146 void MediaControlPanelElement::setIsDisplayed(bool isDisplayed)
148 m_isDisplayed = isDisplayed;
151 // ----------------------------
153 MediaControlPanelEnclosureElement::MediaControlPanelEnclosureElement(MediaControls& mediaControls)
154 // Mapping onto same MediaControlElementType as panel element, since it has similar properties.
155 : MediaControlDivElement(mediaControls, MediaControlsPanel)
159 PassRefPtrWillBeRawPtr<MediaControlPanelEnclosureElement> MediaControlPanelEnclosureElement::create(MediaControls& mediaControls)
161 return adoptRefWillBeNoop(new MediaControlPanelEnclosureElement(mediaControls));
164 const AtomicString& MediaControlPanelEnclosureElement::shadowPseudoId() const
166 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-enclosure", AtomicString::ConstructFromLiteral));
170 // ----------------------------
172 MediaControlOverlayEnclosureElement::MediaControlOverlayEnclosureElement(MediaControls& mediaControls)
173 // Mapping onto same MediaControlElementType as panel element, since it has similar properties.
174 : MediaControlDivElement(mediaControls, MediaControlsPanel)
178 PassRefPtrWillBeRawPtr<MediaControlOverlayEnclosureElement> MediaControlOverlayEnclosureElement::create(MediaControls& mediaControls)
180 return adoptRefWillBeNoop(new MediaControlOverlayEnclosureElement(mediaControls));
183 const AtomicString& MediaControlOverlayEnclosureElement::shadowPseudoId() const
185 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-overlay-enclosure", AtomicString::ConstructFromLiteral));
189 // ----------------------------
191 MediaControlMuteButtonElement::MediaControlMuteButtonElement(MediaControls& mediaControls)
192 : MediaControlInputElement(mediaControls, MediaMuteButton)
196 PassRefPtrWillBeRawPtr<MediaControlMuteButtonElement> MediaControlMuteButtonElement::create(MediaControls& mediaControls)
198 RefPtrWillBeRawPtr<MediaControlMuteButtonElement> button = adoptRefWillBeNoop(new MediaControlMuteButtonElement(mediaControls));
199 button->ensureUserAgentShadowRoot();
200 button->setType("button");
201 return button.release();
204 void MediaControlMuteButtonElement::defaultEventHandler(Event* event)
206 if (event->type() == EventTypeNames::click) {
207 mediaElement().setMuted(!mediaElement().muted());
208 event->setDefaultHandled();
211 HTMLInputElement::defaultEventHandler(event);
214 void MediaControlMuteButtonElement::updateDisplayType()
216 setDisplayType(mediaElement().muted() ? MediaUnMuteButton : MediaMuteButton);
219 const AtomicString& MediaControlMuteButtonElement::shadowPseudoId() const
221 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-mute-button", AtomicString::ConstructFromLiteral));
225 // ----------------------------
227 MediaControlPlayButtonElement::MediaControlPlayButtonElement(MediaControls& mediaControls)
228 : MediaControlInputElement(mediaControls, MediaPlayButton)
232 PassRefPtrWillBeRawPtr<MediaControlPlayButtonElement> MediaControlPlayButtonElement::create(MediaControls& mediaControls)
234 RefPtrWillBeRawPtr<MediaControlPlayButtonElement> button = adoptRefWillBeNoop(new MediaControlPlayButtonElement(mediaControls));
235 button->ensureUserAgentShadowRoot();
236 button->setType("button");
237 return button.release();
240 void MediaControlPlayButtonElement::defaultEventHandler(Event* event)
242 if (event->type() == EventTypeNames::click) {
243 mediaElement().togglePlayState();
245 event->setDefaultHandled();
247 HTMLInputElement::defaultEventHandler(event);
250 void MediaControlPlayButtonElement::updateDisplayType()
252 setDisplayType(mediaElement().togglePlayStateWillPlay() ? MediaPlayButton : MediaPauseButton);
255 const AtomicString& MediaControlPlayButtonElement::shadowPseudoId() const
257 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-play-button", AtomicString::ConstructFromLiteral));
261 // ----------------------------
263 MediaControlOverlayPlayButtonElement::MediaControlOverlayPlayButtonElement(MediaControls& mediaControls)
264 : MediaControlInputElement(mediaControls, MediaOverlayPlayButton)
268 PassRefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> MediaControlOverlayPlayButtonElement::create(MediaControls& mediaControls)
270 RefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> button = adoptRefWillBeNoop(new MediaControlOverlayPlayButtonElement(mediaControls));
271 button->ensureUserAgentShadowRoot();
272 button->setType("button");
273 return button.release();
276 void MediaControlOverlayPlayButtonElement::defaultEventHandler(Event* event)
278 if (event->type() == EventTypeNames::click && mediaElement().togglePlayStateWillPlay()) {
279 mediaElement().togglePlayState();
281 event->setDefaultHandled();
285 void MediaControlOverlayPlayButtonElement::updateDisplayType()
287 if (mediaElement().togglePlayStateWillPlay()) {
293 const AtomicString& MediaControlOverlayPlayButtonElement::shadowPseudoId() const
295 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-overlay-play-button", AtomicString::ConstructFromLiteral));
300 // ----------------------------
302 MediaControlToggleClosedCaptionsButtonElement::MediaControlToggleClosedCaptionsButtonElement(MediaControls& mediaControls)
303 : MediaControlInputElement(mediaControls, MediaShowClosedCaptionsButton)
307 PassRefPtrWillBeRawPtr<MediaControlToggleClosedCaptionsButtonElement> MediaControlToggleClosedCaptionsButtonElement::create(MediaControls& mediaControls)
309 RefPtrWillBeRawPtr<MediaControlToggleClosedCaptionsButtonElement> button = adoptRefWillBeNoop(new MediaControlToggleClosedCaptionsButtonElement(mediaControls));
310 button->ensureUserAgentShadowRoot();
311 button->setType("button");
313 return button.release();
316 void MediaControlToggleClosedCaptionsButtonElement::updateDisplayType()
318 bool captionsVisible = mediaElement().closedCaptionsVisible();
319 setDisplayType(captionsVisible ? MediaHideClosedCaptionsButton : MediaShowClosedCaptionsButton);
320 setChecked(captionsVisible);
323 void MediaControlToggleClosedCaptionsButtonElement::defaultEventHandler(Event* event)
325 if (event->type() == EventTypeNames::click) {
326 mediaElement().setClosedCaptionsVisible(!mediaElement().closedCaptionsVisible());
327 setChecked(mediaElement().closedCaptionsVisible());
329 event->setDefaultHandled();
332 HTMLInputElement::defaultEventHandler(event);
335 const AtomicString& MediaControlToggleClosedCaptionsButtonElement::shadowPseudoId() const
337 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-toggle-closed-captions-button", AtomicString::ConstructFromLiteral));
341 // ----------------------------
343 MediaControlTimelineElement::MediaControlTimelineElement(MediaControls& mediaControls)
344 : MediaControlInputElement(mediaControls, MediaSlider)
348 PassRefPtrWillBeRawPtr<MediaControlTimelineElement> MediaControlTimelineElement::create(MediaControls& mediaControls)
350 RefPtrWillBeRawPtr<MediaControlTimelineElement> timeline = adoptRefWillBeNoop(new MediaControlTimelineElement(mediaControls));
351 timeline->ensureUserAgentShadowRoot();
352 timeline->setType("range");
353 timeline->setAttribute(stepAttr, "any");
354 return timeline.release();
357 void MediaControlTimelineElement::defaultEventHandler(Event* event)
359 if (event->isMouseEvent() && toMouseEvent(event)->button() != LeftButton)
362 if (!inDocument() || !document().isActive())
365 if (event->type() == EventTypeNames::mousedown)
366 mediaControls().beginScrubbing();
368 if (event->type() == EventTypeNames::mouseup)
369 mediaControls().endScrubbing();
371 MediaControlInputElement::defaultEventHandler(event);
373 if (event->type() == EventTypeNames::mouseover || event->type() == EventTypeNames::mouseout || event->type() == EventTypeNames::mousemove)
376 double time = value().toDouble();
377 if (event->type() == EventTypeNames::input) {
378 // FIXME: This will need to take the timeline offset into consideration
379 // once that concept is supported, see https://crbug.com/312699
380 if (mediaElement().controller())
381 mediaElement().controller()->setCurrentTime(time, IGNORE_EXCEPTION);
383 mediaElement().setCurrentTime(time, IGNORE_EXCEPTION);
386 RenderSlider* slider = toRenderSlider(renderer());
387 if (slider && slider->inDragMode())
388 mediaControls().updateCurrentTimeDisplay();
391 bool MediaControlTimelineElement::willRespondToMouseClickEvents()
393 return inDocument() && document().isActive();
396 void MediaControlTimelineElement::setPosition(double currentTime)
398 setValue(String::number(currentTime));
401 void MediaControlTimelineElement::setDuration(double duration)
403 setFloatingPointAttribute(maxAttr, std::isfinite(duration) ? duration : 0);
407 const AtomicString& MediaControlTimelineElement::shadowPseudoId() const
409 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-timeline", AtomicString::ConstructFromLiteral));
413 // ----------------------------
415 MediaControlVolumeSliderElement::MediaControlVolumeSliderElement(MediaControls& mediaControls)
416 : MediaControlInputElement(mediaControls, MediaVolumeSlider)
420 PassRefPtrWillBeRawPtr<MediaControlVolumeSliderElement> MediaControlVolumeSliderElement::create(MediaControls& mediaControls)
422 RefPtrWillBeRawPtr<MediaControlVolumeSliderElement> slider = adoptRefWillBeNoop(new MediaControlVolumeSliderElement(mediaControls));
423 slider->ensureUserAgentShadowRoot();
424 slider->setType("range");
425 slider->setAttribute(stepAttr, "any");
426 slider->setAttribute(maxAttr, "1");
427 return slider.release();
430 void MediaControlVolumeSliderElement::defaultEventHandler(Event* event)
432 if (event->isMouseEvent() && toMouseEvent(event)->button() != LeftButton)
435 if (!inDocument() || !document().isActive())
438 MediaControlInputElement::defaultEventHandler(event);
440 if (event->type() == EventTypeNames::mouseover || event->type() == EventTypeNames::mouseout || event->type() == EventTypeNames::mousemove)
443 double volume = value().toDouble();
444 mediaElement().setVolume(volume, ASSERT_NO_EXCEPTION);
445 mediaElement().setMuted(false);
448 bool MediaControlVolumeSliderElement::willRespondToMouseMoveEvents()
450 if (!inDocument() || !document().isActive())
453 return MediaControlInputElement::willRespondToMouseMoveEvents();
456 bool MediaControlVolumeSliderElement::willRespondToMouseClickEvents()
458 if (!inDocument() || !document().isActive())
461 return MediaControlInputElement::willRespondToMouseClickEvents();
464 void MediaControlVolumeSliderElement::setVolume(double volume)
466 if (value().toDouble() != volume)
467 setValue(String::number(volume));
470 const AtomicString& MediaControlVolumeSliderElement::shadowPseudoId() const
472 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-volume-slider", AtomicString::ConstructFromLiteral));
476 // ----------------------------
478 MediaControlFullscreenButtonElement::MediaControlFullscreenButtonElement(MediaControls& mediaControls)
479 : MediaControlInputElement(mediaControls, MediaEnterFullscreenButton)
483 PassRefPtrWillBeRawPtr<MediaControlFullscreenButtonElement> MediaControlFullscreenButtonElement::create(MediaControls& mediaControls)
485 RefPtrWillBeRawPtr<MediaControlFullscreenButtonElement> button = adoptRefWillBeNoop(new MediaControlFullscreenButtonElement(mediaControls));
486 button->ensureUserAgentShadowRoot();
487 button->setType("button");
489 return button.release();
492 void MediaControlFullscreenButtonElement::defaultEventHandler(Event* event)
494 if (event->type() == EventTypeNames::click) {
495 if (FullscreenElementStack::isActiveFullScreenElement(&mediaElement()))
496 FullscreenElementStack::from(document()).webkitCancelFullScreen();
498 FullscreenElementStack::from(document()).requestFullScreenForElement(&mediaElement(), 0, FullscreenElementStack::ExemptIFrameAllowFullScreenRequirement);
499 event->setDefaultHandled();
501 HTMLInputElement::defaultEventHandler(event);
504 const AtomicString& MediaControlFullscreenButtonElement::shadowPseudoId() const
506 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-fullscreen-button", AtomicString::ConstructFromLiteral));
510 void MediaControlFullscreenButtonElement::setIsFullscreen(bool isFullscreen)
512 setDisplayType(isFullscreen ? MediaExitFullscreenButton : MediaEnterFullscreenButton);
515 // ----------------------------
517 MediaControlTimeRemainingDisplayElement::MediaControlTimeRemainingDisplayElement(MediaControls& mediaControls)
518 : MediaControlTimeDisplayElement(mediaControls, MediaTimeRemainingDisplay)
522 PassRefPtrWillBeRawPtr<MediaControlTimeRemainingDisplayElement> MediaControlTimeRemainingDisplayElement::create(MediaControls& mediaControls)
524 return adoptRefWillBeNoop(new MediaControlTimeRemainingDisplayElement(mediaControls));
527 static const AtomicString& getMediaControlTimeRemainingDisplayElementShadowPseudoId()
529 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-time-remaining-display", AtomicString::ConstructFromLiteral));
533 const AtomicString& MediaControlTimeRemainingDisplayElement::shadowPseudoId() const
535 return getMediaControlTimeRemainingDisplayElementShadowPseudoId();
538 // ----------------------------
540 MediaControlCurrentTimeDisplayElement::MediaControlCurrentTimeDisplayElement(MediaControls& mediaControls)
541 : MediaControlTimeDisplayElement(mediaControls, MediaCurrentTimeDisplay)
545 PassRefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> MediaControlCurrentTimeDisplayElement::create(MediaControls& mediaControls)
547 return adoptRefWillBeNoop(new MediaControlCurrentTimeDisplayElement(mediaControls));
550 static const AtomicString& getMediaControlCurrentTimeDisplayElementShadowPseudoId()
552 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-current-time-display", AtomicString::ConstructFromLiteral));
556 const AtomicString& MediaControlCurrentTimeDisplayElement::shadowPseudoId() const
558 return getMediaControlCurrentTimeDisplayElementShadowPseudoId();
561 // ----------------------------
563 MediaControlTextTrackContainerElement::MediaControlTextTrackContainerElement(MediaControls& mediaControls)
564 : MediaControlDivElement(mediaControls, MediaTextTrackDisplayContainer)
569 PassRefPtrWillBeRawPtr<MediaControlTextTrackContainerElement> MediaControlTextTrackContainerElement::create(MediaControls& mediaControls)
571 RefPtrWillBeRawPtr<MediaControlTextTrackContainerElement> element = adoptRefWillBeNoop(new MediaControlTextTrackContainerElement(mediaControls));
573 return element.release();
576 RenderObject* MediaControlTextTrackContainerElement::createRenderer(RenderStyle*)
578 return new RenderTextTrackContainerElement(this);
581 const AtomicString& MediaControlTextTrackContainerElement::textTrackContainerElementShadowPseudoId()
583 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-text-track-container", AtomicString::ConstructFromLiteral));
587 const AtomicString& MediaControlTextTrackContainerElement::shadowPseudoId() const
589 return textTrackContainerElementShadowPseudoId();
592 void MediaControlTextTrackContainerElement::updateDisplay()
594 if (!mediaElement().closedCaptionsVisible()) {
599 // 1. If the media element is an audio element, or is another playback
600 // mechanism with no rendering area, abort these steps. There is nothing to
602 if (isHTMLAudioElement(mediaElement()))
605 // 2. Let video be the media element or other playback mechanism.
606 HTMLVideoElement& video = toHTMLVideoElement(mediaElement());
608 // 3. Let output be an empty list of absolutely positioned CSS block boxes.
610 // 4. If the user agent is exposing a user interface for video, add to
611 // output one or more completely transparent positioned CSS block boxes that
612 // cover the same region as the user interface.
614 // 5. If the last time these rules were run, the user agent was not exposing
615 // a user interface for video, but now it is, let reset be true. Otherwise,
616 // let reset be false.
618 // There is nothing to be done explicitly for 4th and 5th steps, as
619 // everything is handled through CSS. The caption box is on top of the
620 // controls box, in a container set with the -webkit-box display property.
622 // 6. Let tracks be the subset of video's list of text tracks that have as
623 // their rules for updating the text track rendering these rules for
624 // updating the display of WebVTT text tracks, and whose text track mode is
625 // showing or showing by default.
626 // 7. Let cues be an empty list of text track cues.
627 // 8. For each track track in tracks, append to cues all the cues from
628 // track's list of cues that have their text track cue active flag set.
629 CueList activeCues = video.currentlyActiveCues();
631 // 9. If reset is false, then, for each text track cue cue in cues: if cue's
632 // text track cue display state has a set of CSS boxes, then add those boxes
633 // to output, and remove cue from cues.
635 // There is nothing explicitly to be done here, as all the caching occurs
636 // within the TextTrackCue instance itself. If parameters of the cue change,
637 // the display tree is cleared.
639 // 10. For each text track cue cue in cues that has not yet had
640 // corresponding CSS boxes added to output, in text track cue order, run the
641 // following substeps:
642 for (size_t i = 0; i < activeCues.size(); ++i) {
643 TextTrackCue* cue = activeCues[i].data();
645 ASSERT(cue->isActive());
646 if (!cue->track() || !cue->track()->isRendered() || !cue->isActive())
649 cue->updateDisplay(m_videoDisplaySize.size(), *this);
652 // 11. Return output.
659 void MediaControlTextTrackContainerElement::updateSizes()
661 if (!document().isActive())
666 if (!mediaElement().renderer() || !mediaElement().renderer()->isVideo())
668 videoBox = toRenderVideo(mediaElement().renderer())->videoBox();
670 if (m_videoDisplaySize == videoBox)
672 m_videoDisplaySize = videoBox;
674 float smallestDimension = std::min(m_videoDisplaySize.size().height(), m_videoDisplaySize.size().width());
676 float fontSize = smallestDimension * 0.05f;
677 if (fontSize != m_fontSize) {
678 m_fontSize = fontSize;
679 setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue::CSS_PX);
683 // ----------------------------
685 } // namespace WebCore