| OLD | NEW |
| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 const AtomicString& type = event->type(); | 58 const AtomicString& type = event->type(); |
| 59 return type == EventTypeNames::mousedown | 59 return type == EventTypeNames::mousedown |
| 60 || type == EventTypeNames::mouseup | 60 || type == EventTypeNames::mouseup |
| 61 || type == EventTypeNames::click | 61 || type == EventTypeNames::click |
| 62 || type == EventTypeNames::dblclick | 62 || type == EventTypeNames::dblclick |
| 63 || event->isKeyboardEvent() | 63 || event->isKeyboardEvent() |
| 64 || event->isTouchEvent(); | 64 || event->isTouchEvent(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 // Sliders (the volume control and timeline) need to capture some additional eve
nts used when dragging the thumb. | 67 // Sliders (the volume control and timeline) need to capture some additional eve
nts used when dragging the thumb. |
| 68 static bool isUserInteractionEventForSlider(Event* event) | 68 static bool isUserInteractionEventForSlider(Event* event, LayoutObject* layoutOb
ject) |
| 69 { | 69 { |
| 70 // It is unclear if this can be converted to isUserInteractionEvent(), since |
| 71 // mouse* events seem to be eaten during a drag anyway. crbug.com/516416 . |
| 72 if (isUserInteractionEvent(event)) |
| 73 return true; |
| 74 |
| 75 // Some events are only captured during a slider drag. |
| 76 LayoutSlider* slider = toLayoutSlider(layoutObject); |
| 77 if (slider && !slider->inDragMode()) |
| 78 return false; |
| 79 |
| 70 const AtomicString& type = event->type(); | 80 const AtomicString& type = event->type(); |
| 71 return type == EventTypeNames::mousedown | 81 return type == EventTypeNames::mouseover |
| 72 || type == EventTypeNames::mouseup | |
| 73 || type == EventTypeNames::click | |
| 74 || type == EventTypeNames::dblclick | |
| 75 || type == EventTypeNames::mouseover | |
| 76 || type == EventTypeNames::mouseout | 82 || type == EventTypeNames::mouseout |
| 77 || type == EventTypeNames::mousemove | 83 || type == EventTypeNames::mousemove; |
| 78 || event->isKeyboardEvent() | |
| 79 || event->isTouchEvent(); | |
| 80 } | 84 } |
| 81 | 85 |
| 82 | 86 |
| 83 MediaControlPanelElement::MediaControlPanelElement(MediaControls& mediaControls) | 87 MediaControlPanelElement::MediaControlPanelElement(MediaControls& mediaControls) |
| 84 : MediaControlDivElement(mediaControls, MediaControlsPanel) | 88 : MediaControlDivElement(mediaControls, MediaControlsPanel) |
| 85 , m_isDisplayed(false) | 89 , m_isDisplayed(false) |
| 86 , m_opaque(true) | 90 , m_opaque(true) |
| 87 , m_transitionTimer(this, &MediaControlPanelElement::transitionTimerFired) | 91 , m_transitionTimer(this, &MediaControlPanelElement::transitionTimerFired) |
| 88 { | 92 { |
| 89 } | 93 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 119 | 123 |
| 120 void MediaControlPanelElement::stopTimer() | 124 void MediaControlPanelElement::stopTimer() |
| 121 { | 125 { |
| 122 if (m_transitionTimer.isActive()) | 126 if (m_transitionTimer.isActive()) |
| 123 m_transitionTimer.stop(); | 127 m_transitionTimer.stop(); |
| 124 } | 128 } |
| 125 | 129 |
| 126 void MediaControlPanelElement::transitionTimerFired(Timer<MediaControlPanelEleme
nt>*) | 130 void MediaControlPanelElement::transitionTimerFired(Timer<MediaControlPanelEleme
nt>*) |
| 127 { | 131 { |
| 128 if (!m_opaque) | 132 if (!m_opaque) |
| 129 hide(); | 133 setIsWanted(false); |
| 130 | 134 |
| 131 stopTimer(); | 135 stopTimer(); |
| 132 } | 136 } |
| 133 | 137 |
| 134 void MediaControlPanelElement::didBecomeVisible() | 138 void MediaControlPanelElement::didBecomeVisible() |
| 135 { | 139 { |
| 136 ASSERT(m_isDisplayed && m_opaque); | 140 ASSERT(m_isDisplayed && m_opaque); |
| 137 mediaElement().mediaControlsDidBecomeVisible(); | 141 mediaElement().mediaControlsDidBecomeVisible(); |
| 138 } | 142 } |
| 139 | 143 |
| 140 void MediaControlPanelElement::makeOpaque() | 144 void MediaControlPanelElement::makeOpaque() |
| 141 { | 145 { |
| 142 if (m_opaque) | 146 if (m_opaque) |
| 143 return; | 147 return; |
| 144 | 148 |
| 145 setInlineStyleProperty(CSSPropertyOpacity, 1.0, CSSPrimitiveValue::UnitType:
:Number); | 149 setInlineStyleProperty(CSSPropertyOpacity, 1.0, CSSPrimitiveValue::UnitType:
:Number); |
| 146 m_opaque = true; | 150 m_opaque = true; |
| 147 | 151 |
| 148 if (m_isDisplayed) { | 152 if (m_isDisplayed) { |
| 149 show(); | 153 setIsWanted(true); |
| 150 didBecomeVisible(); | 154 didBecomeVisible(); |
| 151 } | 155 } |
| 152 } | 156 } |
| 153 | 157 |
| 154 void MediaControlPanelElement::makeTransparent() | 158 void MediaControlPanelElement::makeTransparent() |
| 155 { | 159 { |
| 156 if (!m_opaque) | 160 if (!m_opaque) |
| 157 return; | 161 return; |
| 158 | 162 |
| 159 setInlineStyleProperty(CSSPropertyOpacity, 0.0, CSSPrimitiveValue::UnitType:
:Number); | 163 setInlineStyleProperty(CSSPropertyOpacity, 0.0, CSSPrimitiveValue::UnitType:
:Number); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 { | 305 { |
| 302 if (event->type() == EventTypeNames::click && mediaElement().togglePlayState
WillPlay()) { | 306 if (event->type() == EventTypeNames::click && mediaElement().togglePlayState
WillPlay()) { |
| 303 mediaElement().togglePlayState(); | 307 mediaElement().togglePlayState(); |
| 304 updateDisplayType(); | 308 updateDisplayType(); |
| 305 event->setDefaultHandled(); | 309 event->setDefaultHandled(); |
| 306 } | 310 } |
| 307 } | 311 } |
| 308 | 312 |
| 309 void MediaControlOverlayPlayButtonElement::updateDisplayType() | 313 void MediaControlOverlayPlayButtonElement::updateDisplayType() |
| 310 { | 314 { |
| 311 if (mediaElement().shouldShowControls() && mediaElement().togglePlayStateWil
lPlay()) | 315 setIsWanted(mediaElement().shouldShowControls() && mediaElement().togglePlay
StateWillPlay()); |
| 312 show(); | |
| 313 else | |
| 314 hide(); | |
| 315 } | 316 } |
| 316 | 317 |
| 317 bool MediaControlOverlayPlayButtonElement::keepEventInNode(Event* event) | 318 bool MediaControlOverlayPlayButtonElement::keepEventInNode(Event* event) |
| 318 { | 319 { |
| 319 return isUserInteractionEvent(event); | 320 return isUserInteractionEvent(event); |
| 320 } | 321 } |
| 321 | 322 |
| 322 | 323 |
| 323 // ---------------------------- | 324 // ---------------------------- |
| 324 | 325 |
| 325 MediaControlToggleClosedCaptionsButtonElement::MediaControlToggleClosedCaptionsB
uttonElement(MediaControls& mediaControls) | 326 MediaControlToggleClosedCaptionsButtonElement::MediaControlToggleClosedCaptionsB
uttonElement(MediaControls& mediaControls) |
| 326 : MediaControlInputElement(mediaControls, MediaShowClosedCaptionsButton) | 327 : MediaControlInputElement(mediaControls, MediaShowClosedCaptionsButton) |
| 327 { | 328 { |
| 328 } | 329 } |
| 329 | 330 |
| 330 PassRefPtrWillBeRawPtr<MediaControlToggleClosedCaptionsButtonElement> MediaContr
olToggleClosedCaptionsButtonElement::create(MediaControls& mediaControls) | 331 PassRefPtrWillBeRawPtr<MediaControlToggleClosedCaptionsButtonElement> MediaContr
olToggleClosedCaptionsButtonElement::create(MediaControls& mediaControls) |
| 331 { | 332 { |
| 332 RefPtrWillBeRawPtr<MediaControlToggleClosedCaptionsButtonElement> button = a
doptRefWillBeNoop(new MediaControlToggleClosedCaptionsButtonElement(mediaControl
s)); | 333 RefPtrWillBeRawPtr<MediaControlToggleClosedCaptionsButtonElement> button = a
doptRefWillBeNoop(new MediaControlToggleClosedCaptionsButtonElement(mediaControl
s)); |
| 333 button->ensureUserAgentShadowRoot(); | 334 button->ensureUserAgentShadowRoot(); |
| 334 button->setType(InputTypeNames::button); | 335 button->setType(InputTypeNames::button); |
| 335 button->setShadowPseudoId(AtomicString("-webkit-media-controls-toggle-closed
-captions-button", AtomicString::ConstructFromLiteral)); | 336 button->setShadowPseudoId(AtomicString("-webkit-media-controls-toggle-closed
-captions-button", AtomicString::ConstructFromLiteral)); |
| 336 button->hide(); | 337 button->setIsWanted(false); |
| 337 return button.release(); | 338 return button.release(); |
| 338 } | 339 } |
| 339 | 340 |
| 340 void MediaControlToggleClosedCaptionsButtonElement::updateDisplayType() | 341 void MediaControlToggleClosedCaptionsButtonElement::updateDisplayType() |
| 341 { | 342 { |
| 342 bool captionsVisible = mediaElement().closedCaptionsVisible(); | 343 bool captionsVisible = mediaElement().closedCaptionsVisible(); |
| 343 setDisplayType(captionsVisible ? MediaHideClosedCaptionsButton : MediaShowCl
osedCaptionsButton); | 344 setDisplayType(captionsVisible ? MediaHideClosedCaptionsButton : MediaShowCl
osedCaptionsButton); |
| 344 setChecked(captionsVisible); | 345 setChecked(captionsVisible); |
| 345 } | 346 } |
| 346 | 347 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 void MediaControlTimelineElement::setDuration(double duration) | 426 void MediaControlTimelineElement::setDuration(double duration) |
| 426 { | 427 { |
| 427 setFloatingPointAttribute(maxAttr, std::isfinite(duration) ? duration : 0); | 428 setFloatingPointAttribute(maxAttr, std::isfinite(duration) ? duration : 0); |
| 428 | 429 |
| 429 if (LayoutObject* layoutObject = this->layoutObject()) | 430 if (LayoutObject* layoutObject = this->layoutObject()) |
| 430 layoutObject->setShouldDoFullPaintInvalidation(); | 431 layoutObject->setShouldDoFullPaintInvalidation(); |
| 431 } | 432 } |
| 432 | 433 |
| 433 bool MediaControlTimelineElement::keepEventInNode(Event* event) | 434 bool MediaControlTimelineElement::keepEventInNode(Event* event) |
| 434 { | 435 { |
| 435 return isUserInteractionEventForSlider(event); | 436 return isUserInteractionEventForSlider(event, layoutObject()); |
| 436 } | 437 } |
| 437 | 438 |
| 438 // ---------------------------- | 439 // ---------------------------- |
| 439 | 440 |
| 440 MediaControlVolumeSliderElement::MediaControlVolumeSliderElement(MediaControls&
mediaControls) | 441 MediaControlVolumeSliderElement::MediaControlVolumeSliderElement(MediaControls&
mediaControls) |
| 441 : MediaControlInputElement(mediaControls, MediaVolumeSlider) | 442 : MediaControlInputElement(mediaControls, MediaVolumeSlider) |
| 442 { | 443 { |
| 443 } | 444 } |
| 444 | 445 |
| 445 PassRefPtrWillBeRawPtr<MediaControlVolumeSliderElement> MediaControlVolumeSlider
Element::create(MediaControls& mediaControls) | 446 PassRefPtrWillBeRawPtr<MediaControlVolumeSliderElement> MediaControlVolumeSlider
Element::create(MediaControls& mediaControls) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 } | 489 } |
| 489 | 490 |
| 490 void MediaControlVolumeSliderElement::setVolume(double volume) | 491 void MediaControlVolumeSliderElement::setVolume(double volume) |
| 491 { | 492 { |
| 492 if (value().toDouble() != volume) | 493 if (value().toDouble() != volume) |
| 493 setValue(String::number(volume)); | 494 setValue(String::number(volume)); |
| 494 } | 495 } |
| 495 | 496 |
| 496 bool MediaControlVolumeSliderElement::keepEventInNode(Event* event) | 497 bool MediaControlVolumeSliderElement::keepEventInNode(Event* event) |
| 497 { | 498 { |
| 498 return isUserInteractionEventForSlider(event); | 499 return isUserInteractionEventForSlider(event, layoutObject()); |
| 499 } | 500 } |
| 500 | 501 |
| 501 // ---------------------------- | 502 // ---------------------------- |
| 502 | 503 |
| 503 MediaControlFullscreenButtonElement::MediaControlFullscreenButtonElement(MediaCo
ntrols& mediaControls) | 504 MediaControlFullscreenButtonElement::MediaControlFullscreenButtonElement(MediaCo
ntrols& mediaControls) |
| 504 : MediaControlInputElement(mediaControls, MediaEnterFullscreenButton) | 505 : MediaControlInputElement(mediaControls, MediaEnterFullscreenButton) |
| 505 { | 506 { |
| 506 } | 507 } |
| 507 | 508 |
| 508 PassRefPtrWillBeRawPtr<MediaControlFullscreenButtonElement> MediaControlFullscre
enButtonElement::create(MediaControls& mediaControls) | 509 PassRefPtrWillBeRawPtr<MediaControlFullscreenButtonElement> MediaControlFullscre
enButtonElement::create(MediaControls& mediaControls) |
| 509 { | 510 { |
| 510 RefPtrWillBeRawPtr<MediaControlFullscreenButtonElement> button = adoptRefWil
lBeNoop(new MediaControlFullscreenButtonElement(mediaControls)); | 511 RefPtrWillBeRawPtr<MediaControlFullscreenButtonElement> button = adoptRefWil
lBeNoop(new MediaControlFullscreenButtonElement(mediaControls)); |
| 511 button->ensureUserAgentShadowRoot(); | 512 button->ensureUserAgentShadowRoot(); |
| 512 button->setType(InputTypeNames::button); | 513 button->setType(InputTypeNames::button); |
| 513 button->setShadowPseudoId(AtomicString("-webkit-media-controls-fullscreen-bu
tton", AtomicString::ConstructFromLiteral)); | 514 button->setShadowPseudoId(AtomicString("-webkit-media-controls-fullscreen-bu
tton", AtomicString::ConstructFromLiteral)); |
| 514 button->hide(); | 515 button->setIsWanted(false); |
| 515 return button.release(); | 516 return button.release(); |
| 516 } | 517 } |
| 517 | 518 |
| 518 void MediaControlFullscreenButtonElement::defaultEventHandler(Event* event) | 519 void MediaControlFullscreenButtonElement::defaultEventHandler(Event* event) |
| 519 { | 520 { |
| 520 if (event->type() == EventTypeNames::click) { | 521 if (event->type() == EventTypeNames::click) { |
| 521 if (mediaElement().isFullscreen()) | 522 if (mediaElement().isFullscreen()) |
| 522 mediaElement().exitFullscreen(); | 523 mediaElement().exitFullscreen(); |
| 523 else | 524 else |
| 524 mediaElement().enterFullscreen(); | 525 mediaElement().enterFullscreen(); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 } | 612 } |
| 612 | 613 |
| 613 PassRefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> MediaControlCurren
tTimeDisplayElement::create(MediaControls& mediaControls) | 614 PassRefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> MediaControlCurren
tTimeDisplayElement::create(MediaControls& mediaControls) |
| 614 { | 615 { |
| 615 RefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> element = adoptRef
WillBeNoop(new MediaControlCurrentTimeDisplayElement(mediaControls)); | 616 RefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> element = adoptRef
WillBeNoop(new MediaControlCurrentTimeDisplayElement(mediaControls)); |
| 616 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time
-display", AtomicString::ConstructFromLiteral)); | 617 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time
-display", AtomicString::ConstructFromLiteral)); |
| 617 return element.release(); | 618 return element.release(); |
| 618 } | 619 } |
| 619 | 620 |
| 620 } // namespace blink | 621 } // namespace blink |
| OLD | NEW |