blob: 7de982a7e6b86913b88f0bb6309a11e89e72e491 [file] [log] [blame]
commit-queue@webkit.orga1cafe02012-12-05 04:01:13 +00001/*
2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc.
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
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 *
15 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include "config.h"
29
30#if ENABLE(VIDEO)
31#include "RenderMediaControlElements.h"
32
33#include "RenderTheme.h"
34#include "RenderView.h"
35
36namespace WebCore {
37
akling@apple.com8f40c5b2013-10-27 22:54:07 +000038RenderMediaVolumeSliderContainer::RenderMediaVolumeSliderContainer(Element& element, PassRef<RenderStyle> style)
39 : RenderBlockFlow(element, std::move(style))
commit-queue@webkit.orga1cafe02012-12-05 04:01:13 +000040{
41}
42
43void RenderMediaVolumeSliderContainer::layout()
44{
hyatt@apple.com86965c12013-09-09 22:15:41 +000045 RenderBlockFlow::layout();
commit-queue@webkit.orga1cafe02012-12-05 04:01:13 +000046
akling@apple.com827be9c2013-10-29 02:58:43 +000047 if (style().display() == NONE || !nextSibling() || !nextSibling()->isBox())
commit-queue@webkit.orga1cafe02012-12-05 04:01:13 +000048 return;
49
50 RenderBox* buttonBox = toRenderBox(nextSibling());
51 int absoluteOffsetTop = buttonBox->localToAbsolute(FloatPoint(0, -size().height())).y();
52
akling@apple.com691cf5c2013-08-24 16:33:15 +000053 LayoutStateDisabler layoutStateDisabler(&view());
commit-queue@webkit.orga1cafe02012-12-05 04:01:13 +000054
55 // If the slider would be rendered outside the page, it should be moved below the controls.
56 if (UNLIKELY(absoluteOffsetTop < 0))
akling@apple.comc6de8d12013-12-14 18:58:48 +000057 setY(buttonBox->offsetTop() + theme().volumeSliderOffsetFromMuteButton(buttonBox, pixelSnappedSize()).y());
commit-queue@webkit.orga1cafe02012-12-05 04:01:13 +000058}
59
60// ----------------------------
61
akling@apple.com8f40c5b2013-10-27 22:54:07 +000062RenderMediaControlTimelineContainer::RenderMediaControlTimelineContainer(Element& element, PassRef<RenderStyle> style)
63 : RenderFlexibleBox(element, std::move(style))
commit-queue@webkit.orga1cafe02012-12-05 04:01:13 +000064{
65}
66
67// We want the timeline slider to be at least 100 pixels wide.
68// FIXME: Eliminate hard-coded widths altogether.
69static const int minWidthToDisplayTimeDisplays = 45 + 100 + 45;
70
jer.noble@apple.com9501cbc2013-03-27 16:43:02 +000071void RenderMediaControlTimelineContainer::layout()
commit-queue@webkit.orga1cafe02012-12-05 04:01:13 +000072{
commit-queue@webkit.org3f379e82013-02-15 01:39:18 +000073 RenderFlexibleBox::layout();
commit-queue@webkit.orga1cafe02012-12-05 04:01:13 +000074
akling@apple.com691cf5c2013-08-24 16:33:15 +000075 LayoutStateDisabler layoutStateDisabler(&view());
antti@apple.com8f335082013-09-09 19:54:33 +000076 MediaControlTimelineContainerElement* container = static_cast<MediaControlTimelineContainerElement*>(element());
jer.noble@apple.com9501cbc2013-03-27 16:43:02 +000077 container->setTimeDisplaysHidden(width().toInt() < minWidthToDisplayTimeDisplays);
commit-queue@webkit.orga1cafe02012-12-05 04:01:13 +000078}
79
80// ----------------------------
81
82#if ENABLE(VIDEO_TRACK)
83
akling@apple.com8f40c5b2013-10-27 22:54:07 +000084RenderTextTrackContainerElement::RenderTextTrackContainerElement(Element& element, PassRef<RenderStyle> style)
85 : RenderBlockFlow(element, std::move(style))
commit-queue@webkit.orga1cafe02012-12-05 04:01:13 +000086{
87}
88
89void RenderTextTrackContainerElement::layout()
90{
hyatt@apple.com86965c12013-09-09 22:15:41 +000091 RenderBlockFlow::layout();
akling@apple.com827be9c2013-10-29 02:58:43 +000092 if (style().display() == NONE)
commit-queue@webkit.orga1cafe02012-12-05 04:01:13 +000093 return;
94
antti@apple.com8f335082013-09-09 19:54:33 +000095 ASSERT(mediaControlElementType(element()) == MediaTextTrackDisplayContainer);
commit-queue@webkit.orga1cafe02012-12-05 04:01:13 +000096
akling@apple.com691cf5c2013-08-24 16:33:15 +000097 LayoutStateDisabler layoutStateDisabler(&view());
antti@apple.com8f335082013-09-09 19:54:33 +000098 static_cast<MediaControlTextTrackContainerElement*>(element())->updateSizes();
commit-queue@webkit.orga1cafe02012-12-05 04:01:13 +000099}
100
101#endif // ENABLE(VIDEO_TRACK)
102
103} // namespace WebCore
104
105#endif // ENABLE(VIDEO)
106