| 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 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 m_timeline->setDuration(duration); | 253 m_timeline->setDuration(duration); |
| 254 m_timeline->setPosition(mediaElement().currentTime()); | 254 m_timeline->setPosition(mediaElement().currentTime()); |
| 255 | 255 |
| 256 updateVolume(); | 256 updateVolume(); |
| 257 | 257 |
| 258 refreshClosedCaptionsButtonVisibility(); | 258 refreshClosedCaptionsButtonVisibility(); |
| 259 | 259 |
| 260 m_fullScreenButton->setIsWanted(shouldShowFullscreenButton(mediaElement())); | 260 m_fullScreenButton->setIsWanted(shouldShowFullscreenButton(mediaElement())); |
| 261 | 261 |
| 262 refreshCastButtonVisibilityWithoutUpdate(); | 262 refreshCastButtonVisibilityWithoutUpdate(); |
| 263 | |
| 264 // Set the panel width here, and force a layout, before the controls update. | |
| 265 // This would be harmless for the !useNewUi case too, but it causes | |
| 266 // compositing/geometry/video-fixed-scrolling.html to fail with two extra | |
| 267 // 0 height nodes in the render tree. | |
| 268 if (useNewUi) | |
| 269 m_panelWidth = m_panel->clientWidth(); | |
| 270 } | 263 } |
| 271 | 264 |
| 272 LayoutObject* MediaControls::layoutObjectForTextTrackLayout() | 265 LayoutObject* MediaControls::layoutObjectForTextTrackLayout() |
| 273 { | 266 { |
| 274 return m_panel->layoutObject(); | 267 return m_panel->layoutObject(); |
| 275 } | 268 } |
| 276 | 269 |
| 277 void MediaControls::show() | 270 void MediaControls::show() |
| 278 { | 271 { |
| 279 makeOpaque(); | 272 makeOpaque(); |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 | 638 |
| 646 void MediaControls::computeWhichControlsFit() | 639 void MediaControls::computeWhichControlsFit() |
| 647 { | 640 { |
| 648 // Hide all controls that don't fit, and show the ones that do. | 641 // Hide all controls that don't fit, and show the ones that do. |
| 649 // This might be better suited for a layout, but since JS media controls | 642 // This might be better suited for a layout, but since JS media controls |
| 650 // won't benefit from that anwyay, we just do it here like JS will. | 643 // won't benefit from that anwyay, we just do it here like JS will. |
| 651 | 644 |
| 652 if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) | 645 if (!RuntimeEnabledFeatures::newMediaPlaybackUiEnabled()) |
| 653 return; | 646 return; |
| 654 | 647 |
| 655 if (!m_panelWidth) | |
| 656 return; | |
| 657 | |
| 658 // Controls that we'll hide / show, in order of decreasing priority. | 648 // Controls that we'll hide / show, in order of decreasing priority. |
| 659 MediaControlElement* elements[] = { | 649 MediaControlElement* elements[] = { |
| 660 m_playButton.get(), | 650 m_playButton.get(), |
| 661 m_toggleClosedCaptionsButton.get(), | 651 m_toggleClosedCaptionsButton.get(), |
| 662 m_fullScreenButton.get(), | 652 m_fullScreenButton.get(), |
| 663 m_timeline.get(), | 653 m_timeline.get(), |
| 664 m_currentTimeDisplay.get(), | 654 m_currentTimeDisplay.get(), |
| 665 m_volumeSlider.get(), | 655 m_volumeSlider.get(), |
| 666 m_castButton.get(), | 656 m_castButton.get(), |
| 667 m_muteButton.get(), | 657 m_muteButton.get(), |
| 668 m_durationDisplay.get(), | 658 m_durationDisplay.get(), |
| 669 }; | 659 }; |
| 670 | 660 |
| 661 if (!m_panelWidth) { |
| 662 // No layout yet -- hide everything, then make them show up later. |
| 663 // This prevents the wrong controls from being shown briefly |
| 664 // immediately after the first layout and paint, but before we have |
| 665 // a chance to revise them. |
| 666 for (MediaControlElement* element : elements) { |
| 667 if (element) |
| 668 element->setDoesFit(false); |
| 669 } |
| 670 return; |
| 671 } |
| 672 |
| 671 int usedWidth = 0; | 673 int usedWidth = 0; |
| 672 bool droppedCastButton = false; | 674 bool droppedCastButton = false; |
| 673 // Assume that all controls require 48px. Ideally, we could get this | 675 // Assume that all controls require 48px. Ideally, we could get this |
| 674 // the computed style, but that requires the controls to be shown. | 676 // the computed style, but that requires the controls to be shown. |
| 675 const int minimumWidth = 48; | 677 const int minimumWidth = 48; |
| 676 for (MediaControlElement* element : elements) { | 678 for (MediaControlElement* element : elements) { |
| 677 if (!element) | 679 if (!element) |
| 678 continue; | 680 continue; |
| 679 | 681 |
| 680 if (element->isWanted()) { | 682 if (element->isWanted()) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 visitor->trace(m_toggleClosedCaptionsButton); | 741 visitor->trace(m_toggleClosedCaptionsButton); |
| 740 visitor->trace(m_fullScreenButton); | 742 visitor->trace(m_fullScreenButton); |
| 741 visitor->trace(m_durationDisplay); | 743 visitor->trace(m_durationDisplay); |
| 742 visitor->trace(m_enclosure); | 744 visitor->trace(m_enclosure); |
| 743 visitor->trace(m_castButton); | 745 visitor->trace(m_castButton); |
| 744 visitor->trace(m_overlayCastButton); | 746 visitor->trace(m_overlayCastButton); |
| 745 HTMLDivElement::trace(visitor); | 747 HTMLDivElement::trace(visitor); |
| 746 } | 748 } |
| 747 | 749 |
| 748 } | 750 } |
| OLD | NEW |