| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2011, 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 // Insert an overflow menu. However, if we see that the overflow menu | 767 // Insert an overflow menu. However, if we see that the overflow menu |
| 768 // doesn't end up containing at least two elements, we will not display it | 768 // doesn't end up containing at least two elements, we will not display it |
| 769 // but instead make place for the first element that was dropped. | 769 // but instead make place for the first element that was dropped. |
| 770 m_overflowMenu->setDoesFit(true); | 770 m_overflowMenu->setDoesFit(true); |
| 771 m_overflowMenu->setIsWanted(true); | 771 m_overflowMenu->setIsWanted(true); |
| 772 usedWidth = minimumWidth; | 772 usedWidth = minimumWidth; |
| 773 | 773 |
| 774 std::list<MediaControlElement*> overflowElements; | 774 std::list<MediaControlElement*> overflowElements; |
| 775 MediaControlElement* firstDisplacedElement = nullptr; | 775 MediaControlElement* firstDisplacedElement = nullptr; |
| 776 // For each control that fits, enable it in order of decreasing priority. | 776 // For each control that fits, enable it in order of decreasing priority. |
| 777 bool droppedCastButton = false; | |
| 778 for (MediaControlElement* element : elements) { | 777 for (MediaControlElement* element : elements) { |
| 779 if (!element) | 778 if (!element) |
| 780 continue; | 779 continue; |
| 781 int width = minimumWidth; | 780 int width = minimumWidth; |
| 782 if ((element == m_timeline.get()) || (element == m_volumeSlider.get())) | 781 if ((element == m_timeline.get()) || (element == m_volumeSlider.get())) |
| 783 width += sliderMargin; | 782 width += sliderMargin; |
| 784 element->shouldShowButtonInOverflowMenu(false); | 783 element->shouldShowButtonInOverflowMenu(false); |
| 785 if (element->isWanted()) { | 784 if (element->isWanted()) { |
| 786 if (usedWidth + width <= m_panelWidth) { | 785 if (usedWidth + width <= m_panelWidth) { |
| 787 element->setDoesFit(true); | 786 element->setDoesFit(true); |
| 788 usedWidth += width; | 787 usedWidth += width; |
| 789 } else { | 788 } else { |
| 790 element->setDoesFit(false); | 789 element->setDoesFit(false); |
| 791 // TODO(mlamouri): we should probably no longer mark the cast | |
| 792 // button as dropped, it should appear in the overflow menu. | |
| 793 if (element == m_castButton.get()) | |
| 794 droppedCastButton = true; | |
| 795 element->shouldShowButtonInOverflowMenu(true); | 790 element->shouldShowButtonInOverflowMenu(true); |
| 796 if (element->hasOverflowButton()) | 791 if (element->hasOverflowButton()) |
| 797 overflowElements.push_front(element); | 792 overflowElements.push_front(element); |
| 798 // We want a way to access the first media element that was | 793 // We want a way to access the first media element that was |
| 799 // removed. If we don't end up needing an overflow menu, we can | 794 // removed. If we don't end up needing an overflow menu, we can |
| 800 // use the space the overflow menu would have taken up to | 795 // use the space the overflow menu would have taken up to |
| 801 // instead display that media element. | 796 // instead display that media element. |
| 802 if (!element->hasOverflowButton() && !firstDisplacedElement) | 797 if (!element->hasOverflowButton() && !firstDisplacedElement) |
| 803 firstDisplacedElement = element; | 798 firstDisplacedElement = element; |
| 804 } | 799 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 815 if ((firstDisplacedElement == m_timeline.get()) || | 810 if ((firstDisplacedElement == m_timeline.get()) || |
| 816 (firstDisplacedElement == m_volumeSlider.get())) | 811 (firstDisplacedElement == m_volumeSlider.get())) |
| 817 width += sliderMargin; | 812 width += sliderMargin; |
| 818 if (usedWidth + width <= m_panelWidth) | 813 if (usedWidth + width <= m_panelWidth) |
| 819 firstDisplacedElement->setDoesFit(true); | 814 firstDisplacedElement->setDoesFit(true); |
| 820 } | 815 } |
| 821 } else if (overflowElements.size() == 1) { | 816 } else if (overflowElements.size() == 1) { |
| 822 m_overflowMenu->setIsWanted(false); | 817 m_overflowMenu->setIsWanted(false); |
| 823 overflowElements.front()->setDoesFit(true); | 818 overflowElements.front()->setDoesFit(true); |
| 824 } | 819 } |
| 825 | |
| 826 // Special case for cast: if we want a cast button but dropped it, then | |
| 827 // show the overlay cast button instead. | |
| 828 if (m_castButton->isWanted()) { | |
| 829 if (droppedCastButton) | |
| 830 m_overlayCastButton->tryShowOverlay(); | |
| 831 else | |
| 832 m_overlayCastButton->setIsWanted(false); | |
| 833 } | |
| 834 } | 820 } |
| 835 | 821 |
| 836 void MediaControls::setAllowHiddenVolumeControls(bool allow) { | 822 void MediaControls::setAllowHiddenVolumeControls(bool allow) { |
| 837 m_allowHiddenVolumeControls = allow; | 823 m_allowHiddenVolumeControls = allow; |
| 838 // Update the controls visibility. | 824 // Update the controls visibility. |
| 839 updateVolume(); | 825 updateVolume(); |
| 840 } | 826 } |
| 841 | 827 |
| 842 void MediaControls::invalidate(Element* element) { | 828 void MediaControls::invalidate(Element* element) { |
| 843 if (!element) | 829 if (!element) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 visitor->trace(m_enclosure); | 870 visitor->trace(m_enclosure); |
| 885 visitor->trace(m_textTrackList); | 871 visitor->trace(m_textTrackList); |
| 886 visitor->trace(m_overflowMenu); | 872 visitor->trace(m_overflowMenu); |
| 887 visitor->trace(m_overflowList); | 873 visitor->trace(m_overflowList); |
| 888 visitor->trace(m_castButton); | 874 visitor->trace(m_castButton); |
| 889 visitor->trace(m_overlayCastButton); | 875 visitor->trace(m_overlayCastButton); |
| 890 HTMLDivElement::trace(visitor); | 876 HTMLDivElement::trace(visitor); |
| 891 } | 877 } |
| 892 | 878 |
| 893 } // namespace blink | 879 } // namespace blink |
| OLD | NEW |