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

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: 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 | « no previous file | 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 d3fea6a483f2ce6428ae99c00a1d1b85c09081cd..2069a366a9e3966198cca86a6cdf5c558af19e2b 100644
--- a/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
+++ b/third_party/WebKit/Source/core/html/shadow/MediaControls.cpp
@@ -731,13 +731,13 @@ void MediaControls::computeWhichControlsFit()
int usedWidth = 0;
- // Assume that all controls require 48px, unless we can get the computed
+ // Assume that all controls require 32px, 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
// called after layout. This will
// also be the first time we have m_panelWidth!=0, so it won't matter if
// we get this wrong before that.
- int minimumWidth = 48;
+ int minimumWidth = 32;
if (m_playButton->layoutObject() && m_playButton->layoutObject()->style()) {
const ComputedStyle* style = m_playButton->layoutObject()->style();
minimumWidth = ceil(style->width().pixels() / style->effectiveZoom());
@@ -746,6 +746,10 @@ void MediaControls::computeWhichControlsFit()
minimumWidth = ceil(style->width().pixels() / style->effectiveZoom());
}
+ // TODO(mlamouri): we need a more dynamic way to find out the width of an
+ // element.
+ int largeMinimumWidth = minimumWidth * 2;
liberato (no reviews please) 2016/09/27 16:33:53 is this enough on desktop? there is 18px margin o
mlamouri (slow - plz ping) 2016/09/29 13:00:39 Done.
+
if (!m_panelWidth) {
// No layout yet -- hide everything, then make them show up later.
// This prevents the wrong controls from being shown briefly
@@ -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 = largeMinimumWidth;
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,9 +807,16 @@ 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 = largeMinimumWidth;
+ if (usedWidth + width <= m_panelWidth)
+ firstDisplacedElement->setDoesFit(true);
+ }
} else if (overflowElements.size() == 1) {
+ LOG(INFO) << "set first element";
liberato (no reviews please) 2016/09/27 16:33:53 :)
mlamouri (slow - plz ping) 2016/09/29 13:00:39 Done.
m_overflowMenu->setIsWanted(false);
overflowElements.front()->setDoesFit(true);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698