commit-queue@webkit.org | a1cafe0 | 2012-12-05 04:01:13 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
| 36 | namespace WebCore { |
| 37 | |
akling@apple.com | 8f40c5b | 2013-10-27 22:54:07 +0000 | [diff] [blame] | 38 | RenderMediaVolumeSliderContainer::RenderMediaVolumeSliderContainer(Element& element, PassRef<RenderStyle> style) |
| 39 | : RenderBlockFlow(element, std::move(style)) |
commit-queue@webkit.org | a1cafe0 | 2012-12-05 04:01:13 +0000 | [diff] [blame] | 40 | { |
| 41 | } |
| 42 | |
| 43 | void RenderMediaVolumeSliderContainer::layout() |
| 44 | { |
hyatt@apple.com | 86965c1 | 2013-09-09 22:15:41 +0000 | [diff] [blame] | 45 | RenderBlockFlow::layout(); |
commit-queue@webkit.org | a1cafe0 | 2012-12-05 04:01:13 +0000 | [diff] [blame] | 46 | |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 47 | if (style().display() == NONE || !nextSibling() || !nextSibling()->isBox()) |
commit-queue@webkit.org | a1cafe0 | 2012-12-05 04:01:13 +0000 | [diff] [blame] | 48 | return; |
| 49 | |
| 50 | RenderBox* buttonBox = toRenderBox(nextSibling()); |
| 51 | int absoluteOffsetTop = buttonBox->localToAbsolute(FloatPoint(0, -size().height())).y(); |
| 52 | |
akling@apple.com | 691cf5c | 2013-08-24 16:33:15 +0000 | [diff] [blame] | 53 | LayoutStateDisabler layoutStateDisabler(&view()); |
commit-queue@webkit.org | a1cafe0 | 2012-12-05 04:01:13 +0000 | [diff] [blame] | 54 | |
| 55 | // If the slider would be rendered outside the page, it should be moved below the controls. |
| 56 | if (UNLIKELY(absoluteOffsetTop < 0)) |
akling@apple.com | c6de8d1 | 2013-12-14 18:58:48 +0000 | [diff] [blame] | 57 | setY(buttonBox->offsetTop() + theme().volumeSliderOffsetFromMuteButton(buttonBox, pixelSnappedSize()).y()); |
commit-queue@webkit.org | a1cafe0 | 2012-12-05 04:01:13 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | // ---------------------------- |
| 61 | |
akling@apple.com | 8f40c5b | 2013-10-27 22:54:07 +0000 | [diff] [blame] | 62 | RenderMediaControlTimelineContainer::RenderMediaControlTimelineContainer(Element& element, PassRef<RenderStyle> style) |
| 63 | : RenderFlexibleBox(element, std::move(style)) |
commit-queue@webkit.org | a1cafe0 | 2012-12-05 04:01:13 +0000 | [diff] [blame] | 64 | { |
| 65 | } |
| 66 | |
| 67 | // We want the timeline slider to be at least 100 pixels wide. |
| 68 | // FIXME: Eliminate hard-coded widths altogether. |
| 69 | static const int minWidthToDisplayTimeDisplays = 45 + 100 + 45; |
| 70 | |
jer.noble@apple.com | 9501cbc | 2013-03-27 16:43:02 +0000 | [diff] [blame] | 71 | void RenderMediaControlTimelineContainer::layout() |
commit-queue@webkit.org | a1cafe0 | 2012-12-05 04:01:13 +0000 | [diff] [blame] | 72 | { |
commit-queue@webkit.org | 3f379e8 | 2013-02-15 01:39:18 +0000 | [diff] [blame] | 73 | RenderFlexibleBox::layout(); |
commit-queue@webkit.org | a1cafe0 | 2012-12-05 04:01:13 +0000 | [diff] [blame] | 74 | |
akling@apple.com | 691cf5c | 2013-08-24 16:33:15 +0000 | [diff] [blame] | 75 | LayoutStateDisabler layoutStateDisabler(&view()); |
antti@apple.com | 8f33508 | 2013-09-09 19:54:33 +0000 | [diff] [blame] | 76 | MediaControlTimelineContainerElement* container = static_cast<MediaControlTimelineContainerElement*>(element()); |
jer.noble@apple.com | 9501cbc | 2013-03-27 16:43:02 +0000 | [diff] [blame] | 77 | container->setTimeDisplaysHidden(width().toInt() < minWidthToDisplayTimeDisplays); |
commit-queue@webkit.org | a1cafe0 | 2012-12-05 04:01:13 +0000 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | // ---------------------------- |
| 81 | |
| 82 | #if ENABLE(VIDEO_TRACK) |
| 83 | |
akling@apple.com | 8f40c5b | 2013-10-27 22:54:07 +0000 | [diff] [blame] | 84 | RenderTextTrackContainerElement::RenderTextTrackContainerElement(Element& element, PassRef<RenderStyle> style) |
| 85 | : RenderBlockFlow(element, std::move(style)) |
commit-queue@webkit.org | a1cafe0 | 2012-12-05 04:01:13 +0000 | [diff] [blame] | 86 | { |
| 87 | } |
| 88 | |
| 89 | void RenderTextTrackContainerElement::layout() |
| 90 | { |
hyatt@apple.com | 86965c1 | 2013-09-09 22:15:41 +0000 | [diff] [blame] | 91 | RenderBlockFlow::layout(); |
akling@apple.com | 827be9c | 2013-10-29 02:58:43 +0000 | [diff] [blame] | 92 | if (style().display() == NONE) |
commit-queue@webkit.org | a1cafe0 | 2012-12-05 04:01:13 +0000 | [diff] [blame] | 93 | return; |
| 94 | |
antti@apple.com | 8f33508 | 2013-09-09 19:54:33 +0000 | [diff] [blame] | 95 | ASSERT(mediaControlElementType(element()) == MediaTextTrackDisplayContainer); |
commit-queue@webkit.org | a1cafe0 | 2012-12-05 04:01:13 +0000 | [diff] [blame] | 96 | |
akling@apple.com | 691cf5c | 2013-08-24 16:33:15 +0000 | [diff] [blame] | 97 | LayoutStateDisabler layoutStateDisabler(&view()); |
antti@apple.com | 8f33508 | 2013-09-09 19:54:33 +0000 | [diff] [blame] | 98 | static_cast<MediaControlTextTrackContainerElement*>(element())->updateSizes(); |
commit-queue@webkit.org | a1cafe0 | 2012-12-05 04:01:13 +0000 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | #endif // ENABLE(VIDEO_TRACK) |
| 102 | |
| 103 | } // namespace WebCore |
| 104 | |
| 105 | #endif // ENABLE(VIDEO) |
| 106 | |