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

Side by Side Diff: Source/core/html/HTMLMediaElement.cpp

Issue 351213007: Ensure that the controls attribute is correctly reflected in JS. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: REbase Created 6 years, 5 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 unified diff | Download patch
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/HTMLMediaElement.idl » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 ActiveDOMObject::didMoveToNewExecutionContext(&document()); 474 ActiveDOMObject::didMoveToNewExecutionContext(&document());
475 HTMLElement::didMoveToNewDocument(oldDocument); 475 HTMLElement::didMoveToNewDocument(oldDocument);
476 } 476 }
477 477
478 bool HTMLMediaElement::supportsFocus() const 478 bool HTMLMediaElement::supportsFocus() const
479 { 479 {
480 if (ownerDocument()->isMediaDocument()) 480 if (ownerDocument()->isMediaDocument())
481 return false; 481 return false;
482 482
483 // If no controls specified, we should still be able to focus the element if it has tabIndex. 483 // If no controls specified, we should still be able to focus the element if it has tabIndex.
484 return controls() || HTMLElement::supportsFocus(); 484 return shouldShowControls() || HTMLElement::supportsFocus();
485 } 485 }
486 486
487 bool HTMLMediaElement::isMouseFocusable() const 487 bool HTMLMediaElement::isMouseFocusable() const
488 { 488 {
489 return false; 489 return false;
490 } 490 }
491 491
492 void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value) 492 void HTMLMediaElement::parseAttribute(const QualifiedName& name, const AtomicStr ing& value)
493 { 493 {
494 if (name == srcAttr) { 494 if (name == srcAttr) {
(...skipping 29 matching lines...) Expand all
524 void HTMLMediaElement::finishParsingChildren() 524 void HTMLMediaElement::finishParsingChildren()
525 { 525 {
526 HTMLElement::finishParsingChildren(); 526 HTMLElement::finishParsingChildren();
527 527
528 if (Traversal<HTMLTrackElement>::firstChild(*this)) 528 if (Traversal<HTMLTrackElement>::firstChild(*this))
529 scheduleDelayedAction(LoadTextTrackResource); 529 scheduleDelayedAction(LoadTextTrackResource);
530 } 530 }
531 531
532 bool HTMLMediaElement::rendererIsNeeded(const RenderStyle& style) 532 bool HTMLMediaElement::rendererIsNeeded(const RenderStyle& style)
533 { 533 {
534 return controls() ? HTMLElement::rendererIsNeeded(style) : false; 534 return shouldShowControls() && HTMLElement::rendererIsNeeded(style);
535 } 535 }
536 536
537 RenderObject* HTMLMediaElement::createRenderer(RenderStyle*) 537 RenderObject* HTMLMediaElement::createRenderer(RenderStyle*)
538 { 538 {
539 return new RenderMedia(this); 539 return new RenderMedia(this);
540 } 540 }
541 541
542 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint) 542 Node::InsertionNotificationRequest HTMLMediaElement::insertedInto(ContainerNode* insertionPoint)
543 { 543 {
544 WTF_LOG(Media, "HTMLMediaElement::insertedInto"); 544 WTF_LOG(Media, "HTMLMediaElement::insertedInto");
(...skipping 1700 matching lines...) Expand 10 before | Expand all | Expand 10 after
2245 { 2245 {
2246 return fastHasAttribute(loopAttr); 2246 return fastHasAttribute(loopAttr);
2247 } 2247 }
2248 2248
2249 void HTMLMediaElement::setLoop(bool b) 2249 void HTMLMediaElement::setLoop(bool b)
2250 { 2250 {
2251 WTF_LOG(Media, "HTMLMediaElement::setLoop(%s)", boolString(b)); 2251 WTF_LOG(Media, "HTMLMediaElement::setLoop(%s)", boolString(b));
2252 setBooleanAttribute(loopAttr, b); 2252 setBooleanAttribute(loopAttr, b);
2253 } 2253 }
2254 2254
2255 bool HTMLMediaElement::controls() const 2255 bool HTMLMediaElement::shouldShowControls() const
2256 { 2256 {
2257 LocalFrame* frame = document().frame(); 2257 LocalFrame* frame = document().frame();
2258 2258
2259 // always show controls when scripting is disabled 2259 // always show controls when scripting is disabled
2260 if (frame && !frame->script().canExecuteScripts(NotAboutToExecuteScript)) 2260 if (frame && !frame->script().canExecuteScripts(NotAboutToExecuteScript))
2261 return true; 2261 return true;
2262 2262
2263 // Always show controls when in full screen mode. 2263 // Always show controls when in full screen mode.
2264 if (isFullscreen()) 2264 if (isFullscreen())
2265 return true; 2265 return true;
2266 2266
2267 return fastHasAttribute(controlsAttr); 2267 return fastHasAttribute(controlsAttr);
2268 } 2268 }
2269 2269
2270 void HTMLMediaElement::setControls(bool b)
2271 {
2272 WTF_LOG(Media, "HTMLMediaElement::setControls(%s)", boolString(b));
2273 setBooleanAttribute(controlsAttr, b);
2274 }
2275
2276 double HTMLMediaElement::volume() const 2270 double HTMLMediaElement::volume() const
2277 { 2271 {
2278 return m_volume; 2272 return m_volume;
2279 } 2273 }
2280 2274
2281 void HTMLMediaElement::setVolume(double vol, ExceptionState& exceptionState) 2275 void HTMLMediaElement::setVolume(double vol, ExceptionState& exceptionState)
2282 { 2276 {
2283 WTF_LOG(Media, "HTMLMediaElement::setVolume(%f)", vol); 2277 WTF_LOG(Media, "HTMLMediaElement::setVolume(%f)", vol);
2284 2278
2285 if (m_volume == vol) 2279 if (m_volume == vol)
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after
3592 RefPtrWillBeRawPtr<MediaControls> mediaControls = MediaControls::create(*thi s); 3586 RefPtrWillBeRawPtr<MediaControls> mediaControls = MediaControls::create(*thi s);
3593 if (!mediaControls) 3587 if (!mediaControls)
3594 return false; 3588 return false;
3595 3589
3596 mediaControls->reset(); 3590 mediaControls->reset();
3597 if (isFullscreen()) 3591 if (isFullscreen())
3598 mediaControls->enteredFullscreen(); 3592 mediaControls->enteredFullscreen();
3599 3593
3600 ensureUserAgentShadowRoot().appendChild(mediaControls); 3594 ensureUserAgentShadowRoot().appendChild(mediaControls);
3601 3595
3602 if (!controls() || !inDocument()) 3596 if (!shouldShowControls() || !inDocument())
3603 mediaControls->hide(); 3597 mediaControls->hide();
3604 3598
3605 return true; 3599 return true;
3606 } 3600 }
3607 3601
3608 void HTMLMediaElement::configureMediaControls() 3602 void HTMLMediaElement::configureMediaControls()
3609 { 3603 {
3610 if (!controls() || !inDocument()) { 3604 if (!shouldShowControls() || !inDocument()) {
3611 if (hasMediaControls()) 3605 if (hasMediaControls())
3612 mediaControls()->hide(); 3606 mediaControls()->hide();
3613 return; 3607 return;
3614 } 3608 }
3615 3609
3616 if (!hasMediaControls() && !createMediaControls()) 3610 if (!hasMediaControls() && !createMediaControls())
3617 return; 3611 return;
3618 3612
3619 mediaControls()->reset(); 3613 mediaControls()->reset();
3620 mediaControls()->show(); 3614 mediaControls()->show();
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after
3958 3952
3959 #if ENABLE(WEB_AUDIO) 3953 #if ENABLE(WEB_AUDIO)
3960 void HTMLMediaElement::clearWeakMembers(Visitor* visitor) 3954 void HTMLMediaElement::clearWeakMembers(Visitor* visitor)
3961 { 3955 {
3962 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider()) 3956 if (!visitor->isAlive(m_audioSourceNode) && audioSourceProvider())
3963 audioSourceProvider()->setClient(0); 3957 audioSourceProvider()->setClient(0);
3964 } 3958 }
3965 #endif 3959 #endif
3966 3960
3967 } 3961 }
OLDNEW
« no previous file with comments | « Source/core/html/HTMLMediaElement.h ('k') | Source/core/html/HTMLMediaElement.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698