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

Side by Side Diff: Source/core/html/shadow/MediaControlElements.cpp

Issue 196143005: Stop using toParentMediaElement internally in MediaControlElements (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 587
588 void MediaControlFullscreenButtonElement::defaultEventHandler(Event* event) 588 void MediaControlFullscreenButtonElement::defaultEventHandler(Event* event)
589 { 589 {
590 if (event->type() == EventTypeNames::click) { 590 if (event->type() == EventTypeNames::click) {
591 // Only use the new full screen API if the fullScreenEnabled setting has 591 // Only use the new full screen API if the fullScreenEnabled setting has
592 // been explicitly enabled. Otherwise, use the old fullscreen API. This 592 // been explicitly enabled. Otherwise, use the old fullscreen API. This
593 // allows apps which embed a WebView to retain the existing full screen 593 // allows apps which embed a WebView to retain the existing full screen
594 // video implementation without requiring them to implement their own fu ll 594 // video implementation without requiring them to implement their own fu ll
595 // screen behavior. 595 // screen behavior.
596 if (document().settings() && document().settings()->fullScreenEnabled()) { 596 if (document().settings() && document().settings()->fullScreenEnabled()) {
597 if (FullscreenElementStack::isActiveFullScreenElement(toParentMediaE lement(this))) 597 if (FullscreenElementStack::isActiveFullScreenElement(&mediaElement( )))
598 FullscreenElementStack::from(document()).webkitCancelFullScreen( ); 598 FullscreenElementStack::from(document()).webkitCancelFullScreen( );
599 else 599 else
600 FullscreenElementStack::from(document()).requestFullScreenForEle ment(toParentMediaElement(this), 0, FullscreenElementStack::ExemptIFrameAllowFul lScreenRequirement); 600 FullscreenElementStack::from(document()).requestFullScreenForEle ment(&mediaElement(), 0, FullscreenElementStack::ExemptIFrameAllowFullScreenRequ irement);
601 } else { 601 } else {
602 mediaControllerInterface().enterFullscreen(); 602 mediaControllerInterface().enterFullscreen();
603 } 603 }
604 event->setDefaultHandled(); 604 event->setDefaultHandled();
605 } 605 }
606 HTMLInputElement::defaultEventHandler(event); 606 HTMLInputElement::defaultEventHandler(event);
607 } 607 }
608 608
609 const AtomicString& MediaControlFullscreenButtonElement::shadowPseudoId() const 609 const AtomicString& MediaControlFullscreenButtonElement::shadowPseudoId() const
610 { 610 {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 return textTrackContainerElementShadowPseudoId(); 694 return textTrackContainerElementShadowPseudoId();
695 } 695 }
696 696
697 void MediaControlTextTrackContainerElement::updateDisplay() 697 void MediaControlTextTrackContainerElement::updateDisplay()
698 { 698 {
699 if (!mediaControllerInterface().closedCaptionsVisible()) { 699 if (!mediaControllerInterface().closedCaptionsVisible()) {
700 removeChildren(); 700 removeChildren();
701 return; 701 return;
702 } 702 }
703 703
704 HTMLMediaElement* mediaElement = toParentMediaElement(this);
705 // 1. If the media element is an audio element, or is another playback 704 // 1. If the media element is an audio element, or is another playback
706 // mechanism with no rendering area, abort these steps. There is nothing to 705 // mechanism with no rendering area, abort these steps. There is nothing to
707 // render. 706 // render.
708 if (!mediaElement || !mediaElement->isVideo()) 707 if (!mediaElement().isVideo())
709 return; 708 return;
710 709
711 // 2. Let video be the media element or other playback mechanism. 710 // 2. Let video be the media element or other playback mechanism.
712 HTMLVideoElement* video = toHTMLVideoElement(mediaElement); 711 HTMLVideoElement& video = toHTMLVideoElement(mediaElement());
713 712
714 // 3. Let output be an empty list of absolutely positioned CSS block boxes. 713 // 3. Let output be an empty list of absolutely positioned CSS block boxes.
715 Vector<RefPtr<HTMLDivElement> > output; 714 Vector<RefPtr<HTMLDivElement> > output;
716 715
717 // 4. If the user agent is exposing a user interface for video, add to 716 // 4. If the user agent is exposing a user interface for video, add to
718 // output one or more completely transparent positioned CSS block boxes that 717 // output one or more completely transparent positioned CSS block boxes that
719 // cover the same region as the user interface. 718 // cover the same region as the user interface.
720 719
721 // 5. If the last time these rules were run, the user agent was not exposing 720 // 5. If the last time these rules were run, the user agent was not exposing
722 // a user interface for video, but now it is, let reset be true. Otherwise, 721 // a user interface for video, but now it is, let reset be true. Otherwise,
723 // let reset be false. 722 // let reset be false.
724 723
725 // There is nothing to be done explicitly for 4th and 5th steps, as 724 // There is nothing to be done explicitly for 4th and 5th steps, as
726 // everything is handled through CSS. The caption box is on top of the 725 // everything is handled through CSS. The caption box is on top of the
727 // controls box, in a container set with the -webkit-box display property. 726 // controls box, in a container set with the -webkit-box display property.
728 727
729 // 6. Let tracks be the subset of video's list of text tracks that have as 728 // 6. Let tracks be the subset of video's list of text tracks that have as
730 // their rules for updating the text track rendering these rules for 729 // their rules for updating the text track rendering these rules for
731 // updating the display of WebVTT text tracks, and whose text track mode is 730 // updating the display of WebVTT text tracks, and whose text track mode is
732 // showing or showing by default. 731 // showing or showing by default.
733 // 7. Let cues be an empty list of text track cues. 732 // 7. Let cues be an empty list of text track cues.
734 // 8. For each track track in tracks, append to cues all the cues from 733 // 8. For each track track in tracks, append to cues all the cues from
735 // track's list of cues that have their text track cue active flag set. 734 // track's list of cues that have their text track cue active flag set.
736 CueList activeCues = video->currentlyActiveCues(); 735 CueList activeCues = video.currentlyActiveCues();
737 736
738 // 9. If reset is false, then, for each text track cue cue in cues: if cue's 737 // 9. If reset is false, then, for each text track cue cue in cues: if cue's
739 // text track cue display state has a set of CSS boxes, then add those boxes 738 // text track cue display state has a set of CSS boxes, then add those boxes
740 // to output, and remove cue from cues. 739 // to output, and remove cue from cues.
741 740
742 // There is nothing explicitly to be done here, as all the caching occurs 741 // There is nothing explicitly to be done here, as all the caching occurs
743 // within the TextTrackCue instance itself. If parameters of the cue change, 742 // within the TextTrackCue instance itself. If parameters of the cue change,
744 // the display tree is cleared. 743 // the display tree is cleared.
745 744
746 // 10. For each text track cue cue in cues that has not yet had 745 // 10. For each text track cue cue in cues that has not yet had
(...skipping 11 matching lines...) Expand all
758 757
759 // 11. Return output. 758 // 11. Return output.
760 if (hasChildren()) 759 if (hasChildren())
761 show(); 760 show();
762 else 761 else
763 hide(); 762 hide();
764 } 763 }
765 764
766 void MediaControlTextTrackContainerElement::updateSizes() 765 void MediaControlTextTrackContainerElement::updateSizes()
767 { 766 {
768 HTMLMediaElement* mediaElement = toParentMediaElement(this);
769 if (!mediaElement)
770 return;
771
772 if (!document().isActive()) 767 if (!document().isActive())
773 return; 768 return;
774 769
775 IntRect videoBox; 770 IntRect videoBox;
776 771
777 if (!mediaElement->renderer() || !mediaElement->renderer()->isVideo()) 772 if (!mediaElement().renderer() || !mediaElement().renderer()->isVideo())
778 return; 773 return;
779 videoBox = toRenderVideo(mediaElement->renderer())->videoBox(); 774 videoBox = toRenderVideo(mediaElement().renderer())->videoBox();
780 775
781 if (m_videoDisplaySize == videoBox) 776 if (m_videoDisplaySize == videoBox)
782 return; 777 return;
783 m_videoDisplaySize = videoBox; 778 m_videoDisplaySize = videoBox;
784 779
785 float smallestDimension = std::min(m_videoDisplaySize.size().height(), m_vid eoDisplaySize.size().width()); 780 float smallestDimension = std::min(m_videoDisplaySize.size().height(), m_vid eoDisplaySize.size().width());
786 781
787 float fontSize = smallestDimension * 0.05f; 782 float fontSize = smallestDimension * 0.05f;
788 if (fontSize != m_fontSize) { 783 if (fontSize != m_fontSize) {
789 m_fontSize = fontSize; 784 m_fontSize = fontSize;
790 setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue: :CSS_PX); 785 setInlineStyleProperty(CSSPropertyFontSize, fontSize, CSSPrimitiveValue: :CSS_PX);
791 } 786 }
792 } 787 }
793 788
794 // ---------------------------- 789 // ----------------------------
795 790
796 } // namespace WebCore 791 } // namespace WebCore
OLDNEW
« 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