Changeset 128075 in webkit
- Timestamp:
- Sep 10, 2012 10:15:41 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 7 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r128073 r128075 1 2012-09-10 Silvia Pfeiffer <silviapf@chromium.org> 2 3 [Chromium] Handle smaller sizes of media elements in media controls. 4 https://bugs.webkit.org/show_bug.cgi?id=89344 5 6 Reviewed by Eric Carlson. 7 8 The redesign of the Chrome video controls calls for successive removal of individual 9 elements in the Chrome video and audio controls as the element becomes smaller in width. 10 It also requires decreasing padding on the enclosure element of videos. 11 12 These platform-specific tests check if the correct interactive elements are shown for 13 different video and audio element widths and the correct padding is applied for videos. 14 15 * platform/chromium/TestExpectations: 16 Mark failing tests for later rebaseline. 17 * platform/chromium/media/controls-audio-sizes-expected.txt: Added. 18 * platform/chromium/media/controls-audio-sizes.html: Added. 19 Tests if the correct elements are shown for audio elements. 20 * platform/chromium/media/controls-video-sizes-expected.txt: Added. 21 * platform/chromium/media/controls-video-sizes.html: Added. 22 * platform/chromium-mac/platform/chromium/media/controls-video-sizes-expected.png: Added. 23 Tests if the correct elements are shown for video elements. 24 * platform/chromium/media/controls-video-sizes-padding-expected.txt: Added. 25 * platform/chromium/media/controls-video-sizes-padding.html: Added. 26 Tests if the correct padding is applied to the enclosure of the video controls. 27 1 28 2012-09-10 Tony Chang <tony@chromium.org> 2 29 -
trunk/LayoutTests/platform/chromium/TestExpectations
r128073 r128075 3322 3322 BUGWK94242 DEBUG : media/track/track-cues-sorted-before-dispatch.html = PASS TIMEOUT 3323 3323 3324 // Need rebaseline. 3325 BUGWK89344 : media/audio-controls-rendering.html = IMAGE+TEXT 3326 BUGWK89344 : media/audio-repaint.html = IMAGE+TEXT 3327 BUGWK89344 : media/controls-after-reload.html = IMAGE+TEXT 3328 BUGWK89344 : media/controls-layout-direction.html = IMAGE 3329 BUGWK89344 : media/controls-strict.html = IMAGE+TEXT 3330 BUGWK89344 : media/controls-styling-strict.html = IMAGE+TEXT 3331 BUGWK89344 : media/controls-styling.html = IMAGE+TEXT 3332 BUGWK89344 : media/controls-without-preload.html = IMAGE+TEXT 3333 BUGWK89344 : media/media-controls-clone.html = IMAGE+TEXT 3334 BUGWK89344 : media/media-document-audio-repaint.html = IMAGE+TEXT 3335 BUGWK89344 : media/track/track-cue-rendering-horizontal.html = IMAGE+TEXT 3336 BUGWK89344 : media/track/track-cue-rendering-vertical.html = IMAGE+TEXT 3337 BUGWK89344 : media/video-controls-rendering.html = IMAGE+TEXT 3338 BUGWK89344 : media/video-display-toggle.html = IMAGE+TEXT 3339 BUGWK89344 : media/video-empty-source.html = IMAGE+TEXT 3340 BUGWK89344 : media/video-no-audio.html = IMAGE+TEXT 3341 BUGWK89344 : media/video-playing-and-pause.html = IMAGE+TEXT 3342 BUGWK89344 : media/video-zoom-controls.html = IMAGE+TEXT 3343 BUGWK89344 : http/tests/media/video-buffered-range-contains-currentTime.html = IMAGE 3344 BUGWK89344 : fast/hidpi/video-controls-in-hidpi.html = IMAGE+TEXT 3345 BUGWK89344 : fast/layers/video-layer.html = IMAGE+TEXT 3346 BUGWK89344 : compositing/video/video-controls-layer-creation.html = IMAGE 3347 BUGWK89344 LINUX ANDROID WIN : platform/chromium/media/controls-video-sizes.html = IMAGE 3348 3324 3349 // Supposedly started failing between CR r140760 and CR r141216. The failures 3325 3350 // look like they involve antialiasing; the fact that the test clearly expects -
trunk/Source/WebCore/ChangeLog
r128074 r128075 1 2012-09-10 Silvia Pfeiffer <silviapf@chromium.org> 2 3 [Chromium] Handle smaller sizes of media elements in media controls. 4 https://bugs.webkit.org/show_bug.cgi?id=89344 5 6 Reviewed by Eric Carlson. 7 8 The redesign of the Chrome video controls calls for successive removal of individual 9 elements in the Chrome video and audio controls as the element becomes smaller in width. 10 It also requires decreasing padding on the enclosure element of videos. 11 12 This patch introduces a layout() function into the MediaControlRootElementChromium to 13 react to any changes of the media controls width and appropriately hide/show the 14 interactive elements and apply the correct padding on video elements. 15 16 Tests: platform/chromium/media/controls-audio-sizes.html 17 platform/chromium/media/controls-video-sizes-padding.html 18 platform/chromium/media/controls-video-sizes.html 19 20 * html/shadow/MediaControlRootElementChromium.cpp: 21 (WebCore): 22 (RenderMediaControlPanelEnclosureElement): 23 Introduce a renderer for the MediaControlPanelEnclosureElement in which to deal with the layout changes. 24 Following the pattern in MediaControlElements.cpp . 25 (WebCore::RenderMediaControlPanelEnclosureElement::RenderMediaControlPanelEnclosureElement): 26 Definition of the new RenderMediaControlPanelEnclosureElement class. 27 (WebCore::RenderMediaControlPanelEnclosureElement::layout): 28 Definition of the layout() function for the renderer. This does most of the actual work. 29 (WebCore::MediaControlPanelEnclosureElement::createRenderer): 30 Create the renderer for the MediaControlPanelEnclosureElement. 31 (WebCore::MediaControlPanelEnclosureElement::updatePadding): 32 Update padding as part of the MediaControlPanelEnclosureElement functions. 33 (WebCore::MediaControlRootElementChromium::MediaControlRootElementChromium): 34 Add a class property to store whether the duration and current time display are hidden. 35 (WebCore::MediaControlRootElementChromium::reset): 36 Include the hiding/showing of the timeline into the updateTimeDisplay() function to reduce code duplication. 37 (WebCore::MediaControlRootElementChromium::playbackStarted): 38 Include the hiding/showing of the timeline and time display into the updateTimeDisplay() function 39 to reduce code duplication. 40 (WebCore::MediaControlRootElementChromium::playbackProgressed): 41 Include the hiding/showing of the timeline into the updateTimeDisplay() function to reduce code duplication. 42 (WebCore::MediaControlRootElementChromium::playbackStopped): 43 Include the hiding/showing of the timeline into the updateTimeDisplay() function to reduce code duplication. 44 (WebCore::MediaControlRootElementChromium::updateTimeDisplay): 45 Only show time display if not hidden. Add timeline update here to reduce code duplication/ 46 (WebCore::MediaControlRootElementChromium::hideVolumeSlider): 47 New function to allow layout() function to hide the volume slider. 48 (WebCore::MediaControlRootElementChromium::showTimeDisplay): 49 New function to allow layout() function to show the time display. 50 (WebCore::MediaControlRootElementChromium::hideTimeDisplay): 51 New function to allow layout() function to hide the time display. 52 (WebCore::MediaControlRootElementChromium::showMuteButton): 53 New function to allow layout() function to show the mute button. 54 (WebCore::MediaControlRootElementChromium::hideMuteButton): 55 New function to allow layout() function to hide the mute button. 56 (WebCore::MediaControlRootElementChromium::showFullscreenButton): 57 New function to allow layout() function to show the fullscreen button. 58 (WebCore::MediaControlRootElementChromium::hideFullscreenButton): 59 New function to allow layout() function to hide the fullscreen button. 60 (WebCore::MediaControlRootElementChromium::showTimeline): 61 New function to allow layout() function to show the timeline. 62 (WebCore::MediaControlRootElementChromium::hideTimeline): 63 New function to allow layout() function to hide the timeline. 64 65 * html/shadow/MediaControlRootElementChromium.h: 66 (MediaControlPanelEnclosureElement): 67 Add a createRender() and a updatePadding() function to the MediaControlPanelEnclosureElement class. 68 (MediaControlRootElementChromium): 69 Add hide/show functions for volume slider, time display, mute button, fullscreen button and timeline. 70 Add a class property to store whether the duration and current time display are hidden. 71 1 72 2012-09-10 Joanmarie Diggs <jdiggs@igalia.com> 2 73 -
trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.cpp
r127035 r128075 30 30 #include "MediaControlRootElementChromium.h" 31 31 32 #include "CSSValueKeywords.h" 32 33 #include "HTMLDivElement.h" 33 34 #include "HTMLMediaElement.h" … … 36 37 #include "MouseEvent.h" 37 38 #include "Page.h" 39 #include "RenderMedia.h" 38 40 #include "RenderTheme.h" 41 #include "RenderView.h" 42 #include "StyleResolver.h" 39 43 #include "Text.h" 40 44 … … 60 64 } 61 65 66 67 class RenderMediaControlPanelEnclosureElement : public RenderBlock { 68 public: 69 RenderMediaControlPanelEnclosureElement(Node*); 70 71 private: 72 virtual void layout() OVERRIDE; 73 }; 74 75 RenderMediaControlPanelEnclosureElement::RenderMediaControlPanelEnclosureElement(Node* node) 76 : RenderBlock(node) 77 { 78 } 79 80 static const int hideTimeDisplayWidth = 350; 81 static const int hideVolumeDisplayWidth = 275; 82 static const int hideMuteButtonWidth = 210; 83 static const int hideFullscreenButtonWidth = 150; 84 static const int hideTimelineWidth = 100; 85 86 void RenderMediaControlPanelEnclosureElement::layout() 87 { 88 HTMLMediaElement* mediaElement = toParentMediaElement(this); 89 if (!mediaElement || !mediaElement->renderer()) 90 return; 91 92 float mediaWidthFloat = toRenderMedia(mediaElement->renderer())->contentBoxRect().width().toFloat(); 93 int mediaWidth = round(adjustFloatForAbsoluteZoom(mediaWidthFloat, style())); 94 95 MediaControlRootElementChromium* elementShadow = (MediaControlRootElementChromium *) mediaElement->mediaControls(); 96 97 if (mediaWidth < hideTimeDisplayWidth) 98 elementShadow->hideTimeDisplay(); 99 else 100 elementShadow->showTimeDisplay(); 101 102 if (mediaWidth < hideVolumeDisplayWidth) 103 elementShadow->hideVolumeSlider(); 104 else 105 elementShadow->showVolumeSlider(); 106 107 if (mediaWidth < hideMuteButtonWidth) 108 elementShadow->hideMuteButton(); 109 else 110 elementShadow->showMuteButton(); 111 112 if (mediaWidth < hideFullscreenButtonWidth) 113 elementShadow->hideFullscreenButton(); 114 else 115 elementShadow->showFullscreenButton(); 116 117 if (mediaWidth < hideTimelineWidth) 118 elementShadow->hideTimeline(); 119 else 120 elementShadow->showTimeline(); 121 122 if (mediaElement->renderer()->isVideo()) 123 // Update padding according to video width. 124 static_cast<MediaControlPanelEnclosureElement*>(node())->updatePadding(mediaWidth); 125 126 RenderBlock::layout(); 127 } 128 62 129 MediaControlPanelEnclosureElement::MediaControlPanelEnclosureElement(Document* document) 63 130 : MediaControlChromiumEnclosureElement(document) … … 70 137 } 71 138 139 RenderObject* MediaControlPanelEnclosureElement::createRenderer(RenderArena* arena, RenderStyle*) 140 { 141 return new (arena) RenderMediaControlPanelEnclosureElement(this); 142 } 143 72 144 const AtomicString& MediaControlPanelEnclosureElement::shadowPseudoId() const 73 145 { 74 146 DEFINE_STATIC_LOCAL(AtomicString, id, ("-webkit-media-controls-enclosure")); 75 147 return id; 148 } 149 150 // Make sure to keep these values in sync with the ones in mediaControlsChromium.css. 151 static const int videoControlsHeight = 30; 152 static const int maxPadding = 5; 153 static const int minPadding = 0; 154 static const int minPaddingAtWidth = 160; 155 static const int decreaseStep = 60; 156 157 void MediaControlPanelEnclosureElement::updatePadding(int mediaWidth) 158 { 159 // Scale padding linearly between minPadding and maxPadding depending on mediaWidth. 160 float padding = round((mediaWidth - minPaddingAtWidth) / decreaseStep); 161 if (padding < minPadding) 162 padding = minPadding; 163 else if (padding > maxPadding) 164 padding = maxPadding; 165 166 setInlineStyleProperty(CSSPropertyPaddingRight, padding, CSSPrimitiveValue::CSS_PX); 167 setInlineStyleProperty(CSSPropertyPaddingBottom, padding, CSSPrimitiveValue::CSS_PX); 168 setInlineStyleProperty(CSSPropertyPaddingLeft, padding, CSSPrimitiveValue::CSS_PX); 169 setInlineStyleProperty(CSSPropertyHeight, padding + videoControlsHeight, CSSPrimitiveValue::CSS_PX); 76 170 } 77 171 … … 95 189 , m_isMouseOverControls(false) 96 190 , m_isFullscreen(false) 191 , m_hiddenTimeDisplay(false) 97 192 { 98 193 } … … 258 353 float duration = m_mediaController->duration(); 259 354 m_timeline->setDuration(duration); 260 m_timeline->show();261 355 262 356 m_durationDisplay->setInnerText(page->theme()->formatMediaControlsTime(duration), ASSERT_NO_EXCEPTION); 263 357 m_durationDisplay->setCurrentValue(duration); 264 358 265 m_timeline->setPosition(m_mediaController->currentTime());266 359 updateTimeDisplay(); 267 268 m_panelMuteButton->show();269 360 270 361 if (m_volumeSlider) { … … 284 375 } 285 376 286 if (m_mediaController->supportsFullscreen() && m_mediaController->hasVideo()) 287 m_fullscreenButton->show(); 288 else 289 m_fullscreenButton->hide(); 377 showFullscreenButton(); 378 290 379 makeOpaque(); 291 380 } … … 294 383 { 295 384 m_playButton->updateDisplayType(); 296 m_timeline->setPosition(m_mediaController->currentTime());297 m_currentTimeDisplay->show();298 m_durationDisplay->hide();299 385 updateTimeDisplay(); 300 386 … … 305 391 void MediaControlRootElementChromium::playbackProgressed() 306 392 { 307 m_timeline->setPosition(m_mediaController->currentTime());308 393 updateTimeDisplay(); 309 394 … … 315 400 { 316 401 m_playButton->updateDisplayType(); 317 m_timeline->setPosition(m_mediaController->currentTime());318 402 updateTimeDisplay(); 319 403 makeOpaque(); … … 331 415 return; 332 416 333 // After seek , hide duration display and show current time.334 if ( now > 0) {417 // After seek or playback start, hide duration display and show current time. 418 if (!m_hiddenTimeDisplay && now > 0) { 335 419 m_currentTimeDisplay->show(); 336 420 m_durationDisplay->hide(); … … 341 425 m_currentTimeDisplay->setInnerText(page->theme()->formatMediaControlsCurrentTime(now, duration), ec); 342 426 m_currentTimeDisplay->setCurrentValue(now); 427 428 m_timeline->setPosition(m_mediaController->currentTime()); 343 429 } 344 430 … … 479 565 } 480 566 567 void MediaControlRootElementChromium::hideVolumeSlider() 568 { 569 m_volumeSlider->hide(); 570 } 571 572 void MediaControlRootElementChromium::showTimeDisplay() 573 { 574 m_hiddenTimeDisplay = false; 575 m_durationDisplay->show(); 576 updateTimeDisplay(); 577 } 578 579 void MediaControlRootElementChromium::hideTimeDisplay() 580 { 581 m_hiddenTimeDisplay = true; 582 m_durationDisplay->hide(); 583 m_currentTimeDisplay->hide(); 584 } 585 586 void MediaControlRootElementChromium::showMuteButton() 587 { 588 if (!m_mediaController->hasAudio()) 589 return; 590 591 m_panelMuteButton->show(); 592 } 593 594 void MediaControlRootElementChromium::hideMuteButton() 595 { 596 m_panelMuteButton->hide(); 597 } 598 599 void MediaControlRootElementChromium::showFullscreenButton() 600 { 601 if (!m_mediaController->supportsFullscreen() || !m_mediaController->hasVideo()) 602 return; 603 604 m_fullscreenButton->show(); 605 } 606 607 void MediaControlRootElementChromium::hideFullscreenButton() 608 { 609 m_fullscreenButton->hide(); 610 } 611 612 void MediaControlRootElementChromium::showTimeline() 613 { 614 m_timeline->show(); 615 } 616 617 void MediaControlRootElementChromium::hideTimeline() 618 { 619 m_timeline->hide(); 620 } 621 481 622 #if ENABLE(VIDEO_TRACK) 482 623 void MediaControlRootElementChromium::createTextTrackDisplay() -
trunk/Source/WebCore/html/shadow/MediaControlRootElementChromium.h
r127035 r128075 75 75 public: 76 76 static PassRefPtr<MediaControlPanelEnclosureElement> create(Document*); 77 virtual RenderObject* createRenderer(RenderArena*, RenderStyle*) OVERRIDE; 78 void updatePadding(int mediaWidth); 77 79 78 80 private: … … 110 112 111 113 void showVolumeSlider(); 114 void hideVolumeSlider(); 115 void showTimeDisplay(); 116 void hideTimeDisplay(); 117 void showMuteButton(); 118 void hideMuteButton(); 119 void showFullscreenButton(); 120 void hideFullscreenButton(); 121 void showTimeline(); 122 void hideTimeline(); 123 112 124 void updateTimeDisplay(); 113 125 void updateStatusDisplay(); … … 160 172 bool m_isMouseOverControls; 161 173 bool m_isFullscreen; 174 bool m_hiddenTimeDisplay; 162 175 }; 163 176
Note: See TracChangeset
for help on using the changeset viewer.