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

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

Issue 2243473002: Adding overflow menu to media player (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: small changes 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
Index: third_party/WebKit/Source/core/html/shadow/MediaControlElementTypes.cpp
diff --git a/third_party/WebKit/Source/core/html/shadow/MediaControlElementTypes.cpp b/third_party/WebKit/Source/core/html/shadow/MediaControlElementTypes.cpp
index 45baeee686422bc5e60875db56b63dcc492aa276..d681ea90b6b951dad90d33d8858b1f296aad7cff 100644
--- a/third_party/WebKit/Source/core/html/shadow/MediaControlElementTypes.cpp
+++ b/third_party/WebKit/Source/core/html/shadow/MediaControlElementTypes.cpp
@@ -33,9 +33,12 @@
#include "core/CSSValueKeywords.h"
#include "core/HTMLNames.h"
#include "core/css/StylePropertySet.h"
+#include "core/dom/Text.h"
#include "core/events/MouseEvent.h"
+#include "core/html/HTMLLabelElement.h"
#include "core/html/HTMLMediaElement.h"
#include "core/html/shadow/MediaControls.h"
+#include "platform/text/PlatformLocale.h"
namespace blink {
@@ -116,10 +119,34 @@ void MediaControlElement::setDisplayType(MediaControlElementType displayType)
object->setShouldDoFullPaintInvalidation();
}
+void MediaControlElement::shouldShowButtonInOverflowMenu(bool shouldShow)
+{
+ if (!hasOverflowButton())
+ return;
+ DCHECK(m_overflowMenuText->wholeText() == getOverflowMenuString());
mlamouri (slow - plz ping) 2016/09/07 09:07:54 nit: `DCHECK_EQ(getOverflowMenuString(), m_overflo
kdsilva 2016/09/07 11:01:09 Done.
+ if (shouldShow)
+ m_overflowMenuElement->removeInlineStyleProperty(CSSPropertyDisplay);
+ else
+ m_overflowMenuElement->setInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
+}
+
+String MediaControlElement::getOverflowMenuString()
+{
+ return mediaElement().locale().queryString(getOverflowStringName());
+}
+
+void MediaControlElement::updateOverflowString()
+{
+ if (m_overflowMenuElement && m_overflowMenuText)
+ m_overflowMenuText->replaceWholeText(getOverflowMenuString());
+}
+
DEFINE_TRACE(MediaControlElement)
{
visitor->trace(m_mediaControls);
visitor->trace(m_element);
+ visitor->trace(m_overflowMenuElement);
+ visitor->trace(m_overflowMenuText);
}
// ----------------------------
@@ -149,6 +176,26 @@ bool MediaControlInputElement::isMouseFocusable() const
return false;
}
+HTMLElement* MediaControlInputElement::createOverflowElement(MediaControls& mediaControls, MediaControlInputElement* button)
+{
+ if (!button)
+ return nullptr;
+
+ // We don't want the button visible within the overflow menu.
+ button->setIsWanted(false);
+
+ m_overflowMenuText = Text::create(mediaControls.document(), button->getOverflowMenuString());
+
+ HTMLLabelElement* element = HTMLLabelElement::create(mediaControls.document());
+ element->setShadowPseudoId(AtomicString("-internal-media-controls-overflow-menu-list-item"));
+ // Appending a button to a label element ensures that clicks on the label
+ // are passed down to the button, performing the action we'd expect.
+ element->appendChild(button);
+ element->appendChild(m_overflowMenuText);
+ m_overflowMenuElement = element;
+ return element;
+}
+
DEFINE_TRACE(MediaControlInputElement)
{
MediaControlElement::trace(visitor);

Powered by Google App Engine
This is Rietveld 408576698