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