Cleanup RenderMediaControls.cpp and RenderMediaControlElements.cpp
authorpeng.liu6@apple.com <peng.liu6@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 Mar 2020 19:19:16 +0000 (19:19 +0000)
committerpeng.liu6@apple.com <peng.liu6@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 14 Mar 2020 19:19:16 +0000 (19:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=209008

Reviewed by Daniel Bates.

Source/WebCore:

Merge RenderMediaControls.[h|cpp] and RenderMediaControlElements.[h|cpp].
Remove class RenderMediaVolumeSliderContainer because we can use RenderBlockFlow
to render MediaControlTextTrackContainerElement.

No new tests, no functional change.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* html/shadow/MediaControlElementTypes.cpp:
* html/shadow/MediaControlElements.cpp:
(WebCore::MediaControlTextTrackContainerElement::createElementRenderer):
* rendering/RenderMediaControlElements.cpp: Removed.
* rendering/RenderMediaControlElements.h: Removed.
* rendering/RenderMediaControls.cpp:
(WebCore::RenderMediaVolumeSliderContainer::RenderMediaVolumeSliderContainer):
(WebCore::RenderMediaVolumeSliderContainer::layout):
(WebCore::RenderMediaControlTimelineContainer::RenderMediaControlTimelineContainer):
(WebCore::RenderMediaControlTimelineContainer::layout):
* rendering/RenderMediaControls.h:
* rendering/RenderThemeMac.mm:

LayoutTests:

Remove unused code in a test.

* media/track/track-cue-rendering-rtl.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@258469 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
LayoutTests/ChangeLog
LayoutTests/media/track/track-cue-rendering-rtl.html
Source/WebCore/ChangeLog
Source/WebCore/Sources.txt
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/shadow/MediaControlElementTypes.cpp
Source/WebCore/html/shadow/MediaControlElements.cpp
Source/WebCore/rendering/RenderMediaControlElements.cpp [deleted file]
Source/WebCore/rendering/RenderMediaControlElements.h [deleted file]
Source/WebCore/rendering/RenderMediaControls.cpp
Source/WebCore/rendering/RenderMediaControls.h
Source/WebCore/rendering/RenderThemeMac.mm

index 968460d..3de244a 100644 (file)
@@ -1,3 +1,14 @@
+2020-03-14  Peng Liu  <peng.liu6@apple.com>
+
+        Cleanup RenderMediaControls.cpp and RenderMediaControlElements.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=209008
+
+        Reviewed by Daniel Bates.
+
+        Remove unused code in a test.
+
+        * media/track/track-cue-rendering-rtl.html:
+
 2020-03-14  Zalan Bujtas  <zalan@apple.com>
 
         [Tree building] Reset the fragmented flow status before calling child.willBeRemovedFromTree.
index 2369344..7b3152f 100644 (file)
                     ";1234تجربة",
                     "\t०१२३४५६७८९  \t"];
 
-        function testCueStyle()
-        {
-            endTest();
-        }
-
         function seeked()
         {
             testCueDisplayBox = textTrackDisplayElement(video, 'display');
index feb4b16..80bba84 100644 (file)
@@ -1,3 +1,31 @@
+2020-03-14  Peng Liu  <peng.liu6@apple.com>
+
+        Cleanup RenderMediaControls.cpp and RenderMediaControlElements.cpp
+        https://bugs.webkit.org/show_bug.cgi?id=209008
+
+        Reviewed by Daniel Bates.
+
+        Merge RenderMediaControls.[h|cpp] and RenderMediaControlElements.[h|cpp].
+        Remove class RenderMediaVolumeSliderContainer because we can use RenderBlockFlow
+        to render MediaControlTextTrackContainerElement.
+
+        No new tests, no functional change.
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/shadow/MediaControlElementTypes.cpp:
+        * html/shadow/MediaControlElements.cpp:
+        (WebCore::MediaControlTextTrackContainerElement::createElementRenderer):
+        * rendering/RenderMediaControlElements.cpp: Removed.
+        * rendering/RenderMediaControlElements.h: Removed.
+        * rendering/RenderMediaControls.cpp:
+        (WebCore::RenderMediaVolumeSliderContainer::RenderMediaVolumeSliderContainer):
+        (WebCore::RenderMediaVolumeSliderContainer::layout):
+        (WebCore::RenderMediaControlTimelineContainer::RenderMediaControlTimelineContainer):
+        (WebCore::RenderMediaControlTimelineContainer::layout):
+        * rendering/RenderMediaControls.h:
+        * rendering/RenderThemeMac.mm:
+
 2020-03-14  Daniel Bates  <dabates@apple.com>
 
         Share HitTestResult::addNodeToListBasedTestResult() impl for LayoutRect and FloatRect overloads
index b076c23..778263e 100644 (file)
@@ -2159,7 +2159,6 @@ rendering/RenderListItem.cpp
 rendering/RenderListMarker.cpp
 rendering/RenderMarquee.cpp
 rendering/RenderMedia.cpp
-rendering/RenderMediaControlElements.cpp
 rendering/RenderMediaControls.cpp
 rendering/RenderMenuList.cpp
 rendering/RenderMeter.cpp
index 6e1971b..73f3a9f 100644 (file)
                DE5F86591FA2AF24006DB63A /* UnifiedSource60-mm.mm in Sources */ = {isa = PBXBuildFile; fileRef = DE5F863A1FA2AF07006DB63A /* UnifiedSource60-mm.mm */; };
                DE5F86591FA2AF24006DB63B /* UnifiedSource61-mm.mm in Sources */ = {isa = PBXBuildFile; fileRef = DE5F863A1FA2AF07006DB63B /* UnifiedSource61-mm.mm */; };
                DE7710861FA2F0D600460016 /* WebArchiveDumpSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1763F3C1E205234001D58DE /* WebArchiveDumpSupport.mm */; };
-               DEBCCDD216646E8200A452E1 /* RenderMediaControlElements.h in Headers */ = {isa = PBXBuildFile; fileRef = DE49B308165F2FE10010338D /* RenderMediaControlElements.h */; };
+               DEBCCDD216646E8200A452E1 /* RenderMediaControls.h in Headers */ = {isa = PBXBuildFile; fileRef = DE49B308165F2FE10010338D /* RenderMediaControls.h */; };
                DEBCCDD416646EAF00A452E1 /* MediaControlElementTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = DE49B300165F2FC60010338D /* MediaControlElementTypes.h */; };
                DECA7D931F9E67B500E3B661 /* UnifiedSource131.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DECA7D6D1F9E61CF00E3B661 /* UnifiedSource131.cpp */; };
                DECA7D941F9E67B500E3B661 /* UnifiedSource132.cpp in Sources */ = {isa = PBXBuildFile; fileRef = DECA7D7E1F9E61E300E3B661 /* UnifiedSource132.cpp */; };
                DD763BB10992C2C900740B8E /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = /usr/lib/libxml2.dylib; sourceTree = "<absolute>"; };
                DE49B2FF165F2FC60010338D /* MediaControlElementTypes.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaControlElementTypes.cpp; sourceTree = "<group>"; };
                DE49B300165F2FC60010338D /* MediaControlElementTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaControlElementTypes.h; sourceTree = "<group>"; };
-               DE49B307165F2FE10010338D /* RenderMediaControlElements.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMediaControlElements.cpp; sourceTree = "<group>"; };
-               DE49B308165F2FE10010338D /* RenderMediaControlElements.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMediaControlElements.h; sourceTree = "<group>"; };
+               DE49B307165F2FE10010338D /* RenderMediaControls.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderMediaControls.cpp; sourceTree = "<group>"; };
+               DE49B308165F2FE10010338D /* RenderMediaControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderMediaControls.h; sourceTree = "<group>"; };
                DE5F83B21FA18676006DB63A /* UnifiedSource301.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnifiedSource301.cpp; path = "DerivedSources/WebCore/unified-sources/UnifiedSource301.cpp"; sourceTree = BUILT_PRODUCTS_DIR; };
                DE5F83B31FA18677006DB63A /* UnifiedSource355.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnifiedSource355.cpp; path = "DerivedSources/WebCore/unified-sources/UnifiedSource355.cpp"; sourceTree = BUILT_PRODUCTS_DIR; };
                DE5F83B41FA18678006DB63A /* UnifiedSource378.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UnifiedSource378.cpp; path = "DerivedSources/WebCore/unified-sources/UnifiedSource378.cpp"; sourceTree = BUILT_PRODUCTS_DIR; };
                                0F56028D0E4B76580065B038 /* RenderMarquee.h */,
                                E4C279560CF9741900E97B98 /* RenderMedia.cpp */,
                                E4C279570CF9741900E97B98 /* RenderMedia.h */,
-                               DE49B307165F2FE10010338D /* RenderMediaControlElements.cpp */,
-                               DE49B308165F2FE10010338D /* RenderMediaControlElements.h */,
+                               DE49B307165F2FE10010338D /* RenderMediaControls.cpp */,
+                               DE49B308165F2FE10010338D /* RenderMediaControls.h */,
                                ABDDFE730A5C6E6F00A3E11D /* RenderMenuList.cpp */,
                                ABDDFE740A5C6E7000A3E11D /* RenderMenuList.h */,
                                A454424C119B3687009BE912 /* RenderMeter.cpp */,
                                B2FA3D570AB75A6F000E5AC4 /* JSSVGAnimationElement.h in Headers */,
                                B2FA3D590AB75A6F000E5AC4 /* JSSVGCircleElement.h in Headers */,
                                B2FA3D5B0AB75A6F000E5AC4 /* JSSVGClipPathElement.h in Headers */,
-                               E45A6C772417BA59006E4CD5 /* PseudoClassChangeInvalidation.h in Headers */,
                                B2FA3D5F0AB75A6F000E5AC4 /* JSSVGComponentTransferFunctionElement.h in Headers */,
                                B2FA3D610AB75A6F000E5AC4 /* JSSVGCursorElement.h in Headers */,
                                B2FA3D630AB75A6F000E5AC4 /* JSSVGDefsElement.h in Headers */,
                                372ADA38197F47B900FC501E /* ProtectionSpaceCocoa.h in Headers */,
                                51A052561058874000CC9E95 /* ProtectionSpaceHash.h in Headers */,
                                1AF8E11A1256592600230FF7 /* ProxyServer.h in Headers */,
+                               E45A6C772417BA59006E4CD5 /* PseudoClassChangeInvalidation.h in Headers */,
                                FF945ECC161F7F3600971BC8 /* PseudoElement.h in Headers */,
                                57D8462E1FEAF69900CA3682 /* PublicKeyCredential.h in Headers */,
                                57303BE92009748D00355965 /* PublicKeyCredentialCreationOptions.h in Headers */,
                                439046EC12DA25E800AF80A9 /* RenderMathMLToken.h in Headers */,
                                439046EA12DA25E800AF80A2 /* RenderMathMLUnderOver.h in Headers */,
                                E4C279590CF9741900E97B98 /* RenderMedia.h in Headers */,
-                               DEBCCDD216646E8200A452E1 /* RenderMediaControlElements.h in Headers */,
+                               DEBCCDD216646E8200A452E1 /* RenderMediaControls.h in Headers */,
                                ABDDFE7A0A5C6E7000A3E11D /* RenderMenuList.h in Headers */,
                                A454424F119B3687009BE912 /* RenderMeter.h in Headers */,
                                1A3586E015264C450022A659 /* RenderMultiColumnFlow.h in Headers */,
index 26aaa15..3ab82a1 100644 (file)
@@ -37,7 +37,7 @@
 #include "HTMLNames.h"
 #include "MouseEvent.h"
 #include "RenderMedia.h"
-#include "RenderMediaControlElements.h"
+#include "RenderMediaControls.h"
 #include "StyleProperties.h"
 #include <wtf/IsoMallocInlines.h>
 
index ca602e3..32b4b4c 100644 (file)
@@ -52,7 +52,7 @@
 #include "Page.h"
 #include "PageGroup.h"
 #include "RenderLayer.h"
-#include "RenderMediaControlElements.h"
+#include "RenderMediaControls.h"
 #include "RenderSlider.h"
 #include "RenderTheme.h"
 #include "RenderVideo.h"
@@ -1106,7 +1106,7 @@ Ref<MediaControlTextTrackContainerElement> MediaControlTextTrackContainerElement
 
 RenderPtr<RenderElement> MediaControlTextTrackContainerElement::createElementRenderer(RenderStyle&& style, const RenderTreePosition&)
 {
-    return createRenderer<RenderMediaControlTextTrackContainer>(*this, WTFMove(style));
+    return createRenderer<RenderBlockFlow>(*this, WTFMove(style));
 }
 
 static bool compareCueIntervalForDisplay(const CueInterval& one, const CueInterval& two)
diff --git a/Source/WebCore/rendering/RenderMediaControlElements.cpp b/Source/WebCore/rendering/RenderMediaControlElements.cpp
deleted file mode 100644 (file)
index 897abcf..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
- * Copyright (C) 2012 Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-
-#if ENABLE(VIDEO)
-#include "RenderMediaControlElements.h"
-
-#include "MediaControlElements.h"
-#include "RenderLayoutState.h"
-#include "RenderTheme.h"
-#include "RenderView.h"
-#include <wtf/IsoMallocInlines.h>
-
-namespace WebCore {
-
-WTF_MAKE_ISO_ALLOCATED_IMPL(RenderMediaVolumeSliderContainer);
-WTF_MAKE_ISO_ALLOCATED_IMPL(RenderMediaControlTimelineContainer);
-#if ENABLE(VIDEO_TRACK)
-WTF_MAKE_ISO_ALLOCATED_IMPL(RenderMediaControlTextTrackContainer);
-#endif
-
-RenderMediaVolumeSliderContainer::RenderMediaVolumeSliderContainer(Element& element, RenderStyle&& style)
-    : RenderBlockFlow(element, WTFMove(style))
-{
-}
-
-void RenderMediaVolumeSliderContainer::layout()
-{
-    RenderBlockFlow::layout();
-
-    if (style().display() == DisplayType::None || !is<RenderBox>(nextSibling()))
-        return;
-
-    RenderBox& buttonBox = downcast<RenderBox>(*nextSibling());
-    int absoluteOffsetTop = buttonBox.localToAbsolute(FloatPoint(0, -size().height())).y();
-
-    LayoutStateDisabler layoutStateDisabler(view().frameView().layoutContext());
-
-    // If the slider would be rendered outside the page, it should be moved below the controls.
-    if (UNLIKELY(absoluteOffsetTop < 0))
-        setY(buttonBox.offsetTop() + theme().volumeSliderOffsetFromMuteButton(buttonBox, size()).y());
-}
-
-// ----------------------------
-
-RenderMediaControlTimelineContainer::RenderMediaControlTimelineContainer(Element& element, RenderStyle&& style)
-    : RenderFlexibleBox(element, WTFMove(style))
-{
-}
-
-// We want the timeline slider to be at least 100 pixels wide.
-// FIXME: Eliminate hard-coded widths altogether.
-static const int minWidthToDisplayTimeDisplays = 45 + 100 + 45;
-
-void RenderMediaControlTimelineContainer::layout()
-{
-    RenderFlexibleBox::layout();
-
-    LayoutStateDisabler layoutStateDisabler(view().frameView().layoutContext());
-    MediaControlTimelineContainerElement* container = static_cast<MediaControlTimelineContainerElement*>(element());
-    container->setTimeDisplaysHidden(width().toInt() < minWidthToDisplayTimeDisplays);
-}
-
-// ----------------------------
-
-#if ENABLE(VIDEO_TRACK)
-
-RenderMediaControlTextTrackContainer::RenderMediaControlTextTrackContainer(Element& element, RenderStyle&& style)
-    : RenderBlockFlow(element, WTFMove(style))
-{
-}
-
-void RenderMediaControlTextTrackContainer::layout()
-{
-    RenderBlockFlow::layout();
-    if (style().display() == DisplayType::None)
-        return;
-
-    ASSERT(mediaControlElementType(element()) == MediaTextTrackDisplayContainer);
-
-    LayoutStateDisabler layoutStateDisabler(view().frameView().layoutContext());
-}
-
-#endif // ENABLE(VIDEO_TRACK)
-
-} // namespace WebCore
-
-#endif // ENABLE(VIDEO)
-
diff --git a/Source/WebCore/rendering/RenderMediaControlElements.h b/Source/WebCore/rendering/RenderMediaControlElements.h
deleted file mode 100644 (file)
index d1bf1b3..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
- * Copyright (C) 2012 Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(VIDEO)
-
-#include "RenderBlockFlow.h"
-#include "RenderFlexibleBox.h"
-
-namespace WebCore {
-
-class RenderMediaVolumeSliderContainer final : public RenderBlockFlow {
-    WTF_MAKE_ISO_ALLOCATED(RenderMediaVolumeSliderContainer);
-public:
-    RenderMediaVolumeSliderContainer(Element&, RenderStyle&&);
-
-private:
-    void layout() override;
-};
-
-// ----------------------------
-
-class RenderMediaControlTimelineContainer final : public RenderFlexibleBox {
-    WTF_MAKE_ISO_ALLOCATED(RenderMediaControlTimelineContainer);
-public:
-    RenderMediaControlTimelineContainer(Element&, RenderStyle&&);
-
-private:
-    void layout() override;
-    bool isFlexibleBoxImpl() const override { return true; }
-};
-
-// ----------------------------
-
-#if ENABLE(VIDEO_TRACK)
-
-class RenderMediaControlTextTrackContainer final : public RenderBlockFlow {
-    WTF_MAKE_ISO_ALLOCATED(RenderMediaControlTextTrackContainer);
-public:
-    RenderMediaControlTextTrackContainer(Element&, RenderStyle&&);
-
-private:
-    void layout() override;
-};
-
-#endif // ENABLE(VIDEO_TRACK)
-
-} // namespace WebCore
-
-#endif // ENABLE(VIDEO)
index a50c1be..8696636 100644 (file)
@@ -1,5 +1,7 @@
 /*
- * Copyright (C) 2009-2017 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Google Inc.
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #include "config.h"
 #include "RenderMediaControls.h"
 
-#if ENABLE(VIDEO) && PLATFORM(WIN) && USE(CG)
+#if ENABLE(VIDEO)
+
+#include "MediaControlElements.h"
+#include "RenderLayoutState.h"
+#include "RenderTheme.h"
+#include "RenderView.h"
+#include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {
 
+WTF_MAKE_ISO_ALLOCATED_IMPL(RenderMediaVolumeSliderContainer);
+WTF_MAKE_ISO_ALLOCATED_IMPL(RenderMediaControlTimelineContainer);
+
+RenderMediaVolumeSliderContainer::RenderMediaVolumeSliderContainer(Element& element, RenderStyle&& style)
+    : RenderBlockFlow(element, WTFMove(style))
+{
+}
+
+void RenderMediaVolumeSliderContainer::layout()
+{
+    RenderBlockFlow::layout();
+
+    if (style().display() == DisplayType::None || !is<RenderBox>(nextSibling()))
+        return;
+
+    RenderBox& buttonBox = downcast<RenderBox>(*nextSibling());
+    int absoluteOffsetTop = buttonBox.localToAbsolute(FloatPoint(0, -size().height())).y();
+
+    LayoutStateDisabler layoutStateDisabler(view().frameView().layoutContext());
+
+    // If the slider would be rendered outside the page, it should be moved below the controls.
+    if (UNLIKELY(absoluteOffsetTop < 0))
+        setY(buttonBox.offsetTop() + theme().volumeSliderOffsetFromMuteButton(buttonBox, size()).y());
+}
+
+// ----------------------------
+
+RenderMediaControlTimelineContainer::RenderMediaControlTimelineContainer(Element& element, RenderStyle&& style)
+    : RenderFlexibleBox(element, WTFMove(style))
+{
+}
+
+// We want the timeline slider to be at least 100 pixels wide.
+// FIXME: Eliminate hard-coded widths altogether.
+static const int minWidthToDisplayTimeDisplays = 45 + 100 + 45;
+
+void RenderMediaControlTimelineContainer::layout()
+{
+    RenderFlexibleBox::layout();
+
+    LayoutStateDisabler layoutStateDisabler(view().frameView().layoutContext());
+    MediaControlTimelineContainerElement* container = static_cast<MediaControlTimelineContainerElement*>(element());
+    container->setTimeDisplaysHidden(width().toInt() < minWidthToDisplayTimeDisplays);
+}
+
+#if PLATFORM(WIN) && USE(CG)
+
 void RenderMediaControls::adjustMediaSliderThumbSize(RenderStyle& style)
 {
     ASSERT_NOT_REACHED();
 }
 
-}
+#endif // PLATFORM(WIN) && USE(CG)
+
+} // namespace WebCore
+
+#endif // ENABLE(VIDEO)
 
-#endif
index d417939..9f61136 100644 (file)
@@ -1,5 +1,7 @@
 /*
- * Copyright (C) 2009 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
+ * Copyright (C) 2012 Google Inc.
+ * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
 #pragma once
 
-#if ENABLE(VIDEO) && PLATFORM(WIN) && USE(CG)
+#if ENABLE(VIDEO)
+
+#include "RenderBlockFlow.h"
+#include "RenderFlexibleBox.h"
 
 namespace WebCore {
 
-class RenderStyle;
+class RenderMediaVolumeSliderContainer final : public RenderBlockFlow {
+    WTF_MAKE_ISO_ALLOCATED(RenderMediaVolumeSliderContainer);
+public:
+    RenderMediaVolumeSliderContainer(Element&, RenderStyle&&);
+
+private:
+    void layout() override;
+};
+
+// ----------------------------
+
+class RenderMediaControlTimelineContainer final : public RenderFlexibleBox {
+    WTF_MAKE_ISO_ALLOCATED(RenderMediaControlTimelineContainer);
+public:
+    RenderMediaControlTimelineContainer(Element&, RenderStyle&&);
+
+private:
+    void layout() override;
+    bool isFlexibleBoxImpl() const override { return true; }
+};
+
+#if PLATFORM(WIN) && USE(CG)
 
 class RenderMediaControls {
 public:
     static void adjustMediaSliderThumbSize(RenderStyle&);
 };
 
+#endif // PLATFORM(WIN) && USE(CG)
+
 } // namespace WebCore
 
-#endif // ENABLE(VIDEO) && PLATFORM(WIN) && USE(CG)
+#endif // ENABLE(VIDEO)
index c624b52..318eb82 100644 (file)
@@ -55,7 +55,7 @@
 #import "RenderAttachment.h"
 #import "RenderLayer.h"
 #import "RenderMedia.h"
-#import "RenderMediaControlElements.h"
+#import "RenderMediaControls.h"
 #import "RenderProgress.h"
 #import "RenderSlider.h"
 #import "RenderSnapshottedPlugIn.h"