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

Unified Diff: Source/core/html/HTMLMediaElement.cpp

Issue 182613006: Remove media controls when not in use. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Add shouldDisplayControls and fix overlay logic Created 6 years, 10 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 | « Source/core/html/HTMLMediaElement.h ('k') | Source/web/ContextMenuClientImpl.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/HTMLMediaElement.cpp
diff --git a/Source/core/html/HTMLMediaElement.cpp b/Source/core/html/HTMLMediaElement.cpp
index 35f8cd734ac77d7fa55aba347ec080f1add8dda1..e37386b5cf2e302c269ecfd58018389b182b3aad 100644
--- a/Source/core/html/HTMLMediaElement.cpp
+++ b/Source/core/html/HTMLMediaElement.cpp
@@ -410,7 +410,7 @@ bool HTMLMediaElement::supportsFocus() const
return false;
// If no controls specified, we should still be able to focus the element if it has tabIndex.
- return controls() || HTMLElement::supportsFocus();
+ return shouldDisplayControls() || HTMLElement::supportsFocus();
}
bool HTMLMediaElement::isMouseFocusable() const
@@ -468,7 +468,7 @@ void HTMLMediaElement::finishParsingChildren()
bool HTMLMediaElement::rendererIsNeeded(const RenderStyle& style)
{
- return controls() ? HTMLElement::rendererIsNeeded(style) : false;
+ return shouldDisplayControls() ? HTMLElement::rendererIsNeeded(style) : false;
}
RenderObject* HTMLMediaElement::createRenderer(RenderStyle*)
@@ -2297,17 +2297,22 @@ void HTMLMediaElement::setLoop(bool b)
bool HTMLMediaElement::controls() const
{
+ return fastHasAttribute(controlsAttr);
+}
+
+bool HTMLMediaElement::shouldDisplayControls() const
+{
LocalFrame* frame = document().frame();
// always show controls when scripting is disabled
if (frame && !frame->script().canExecuteScripts(NotAboutToExecuteScript))
return true;
- // Always show controls when in full screen mode.
- if (isFullscreen())
+ // Show controls when in full screen mode unless there is an overlay player.
+ if (isFullscreen() && !RuntimeEnabledFeatures::overlayFullscreenVideoEnabled())
qinmin 2014/02/28 17:12:45 overlayFullscreenVideoEnabled is enabled by defaul
return true;
- return fastHasAttribute(controlsAttr);
+ return controls();
}
void HTMLMediaElement::setControls(bool b)
@@ -3586,7 +3591,7 @@ bool HTMLMediaElement::createMediaControls()
ensureUserAgentShadowRoot().appendChild(mediaControls);
- if (!controls() || !inDocument())
+ if (!shouldDisplayControls() || !inDocument())
mediaControls->hide();
return true;
@@ -3594,9 +3599,13 @@ bool HTMLMediaElement::createMediaControls()
void HTMLMediaElement::configureMediaControls()
{
- if (!controls() || !inDocument()) {
- if (hasMediaControls())
- mediaControls()->hide();
+ if (!shouldDisplayControls() || !inDocument()) {
+ if (hasMediaControls()) {
+ if (!shouldDisplayControls())
+ userAgentShadowRoot()->removeChild(mediaControls());
+ else
+ mediaControls()->hide();
+ }
return;
}
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/web/ContextMenuClientImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698