Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Unified Diff: third_party/WebKit/Source/core/html/shadow/MediaControls.cpp

Issue 2374733002: Media Controls: take into consideration high margin on some elements. (Closed)
Patch Set: rebaseline Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win/media/video-zoom-controls-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
diff --git a/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp b/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
index a51eb6f9e8779a91d3ae3225550a0e0d48ba99e1..2cf3d774bb8f14b1286e371377c1c9e7c99e6857 100644
--- a/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
+++ b/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
@@ -731,6 +731,10 @@ void MediaControls::computeWhichControlsFit()
int usedWidth = 0;
+ // TODO(mlamouri): we need a more dynamic way to find out the width of an
+ // element.
+ const int sliderMargin = 36; // Sliders have 18px margin on each side.
+
// Assume that all controls require 48px, unless we can get the computed
// style for the play button. Since the play button or overflow is always
// shown, one of the two buttons should be available the first time we're
@@ -772,13 +776,18 @@ void MediaControls::computeWhichControlsFit()
for (MediaControlElement* element : elements) {
if (!element)
continue;
+ int width = minimumWidth;
+ if ((element == m_timeline.get()) || (element == m_volumeSlider.get()))
+ width += sliderMargin;
element->shouldShowButtonInOverflowMenu(false);
if (element->isWanted()) {
- if (usedWidth + minimumWidth <= m_panelWidth) {
+ if (usedWidth + width <= m_panelWidth) {
element->setDoesFit(true);
- usedWidth += minimumWidth;
+ usedWidth += width;
} else {
element->setDoesFit(false);
+ // TODO(mlamouri): we should probably no longer mark the cast
+ // button as dropped, it should appear in the overflow menu.
if (element == m_castButton.get())
droppedCastButton = true;
element->shouldShowButtonInOverflowMenu(true);
@@ -798,8 +807,14 @@ void MediaControls::computeWhichControlsFit()
// overflow menu.
if (overflowElements.empty()) {
m_overflowMenu->setIsWanted(false);
- if (firstDisplacedElement)
- firstDisplacedElement->setDoesFit(true);
+ usedWidth -= minimumWidth;
+ if (firstDisplacedElement) {
+ int width = minimumWidth;
+ if ((firstDisplacedElement == m_timeline.get()) || (firstDisplacedElement == m_volumeSlider.get()))
+ width += sliderMargin;
+ if (usedWidth + width <= m_panelWidth)
+ firstDisplacedElement->setDoesFit(true);
+ }
} else if (overflowElements.size() == 1) {
m_overflowMenu->setIsWanted(false);
overflowElements.front()->setDoesFit(true);
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win/media/video-zoom-controls-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698