| 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 20 matching lines...) Expand all Loading... |
| 31 #include "core/html/shadow/MediaControlElements.h" | 31 #include "core/html/shadow/MediaControlElements.h" |
| 32 | 32 |
| 33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 33 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 34 #include "core/InputTypeNames.h" | 34 #include "core/InputTypeNames.h" |
| 35 #include "core/dom/ClientRect.h" | 35 #include "core/dom/ClientRect.h" |
| 36 #include "core/dom/DOMTokenList.h" | 36 #include "core/dom/DOMTokenList.h" |
| 37 #include "core/dom/shadow/ShadowRoot.h" | 37 #include "core/dom/shadow/ShadowRoot.h" |
| 38 #include "core/events/MouseEvent.h" | 38 #include "core/events/MouseEvent.h" |
| 39 #include "core/frame/LocalFrame.h" | 39 #include "core/frame/LocalFrame.h" |
| 40 #include "core/html/HTMLVideoElement.h" | 40 #include "core/html/HTMLVideoElement.h" |
| 41 #include "core/html/MediaController.h" | |
| 42 #include "core/html/TimeRanges.h" | 41 #include "core/html/TimeRanges.h" |
| 43 #include "core/html/shadow/MediaControls.h" | 42 #include "core/html/shadow/MediaControls.h" |
| 44 #include "core/input/EventHandler.h" | 43 #include "core/input/EventHandler.h" |
| 45 #include "core/layout/LayoutSlider.h" | 44 #include "core/layout/LayoutSlider.h" |
| 46 #include "core/layout/LayoutTheme.h" | 45 #include "core/layout/LayoutTheme.h" |
| 47 #include "core/layout/LayoutVideo.h" | 46 #include "core/layout/LayoutVideo.h" |
| 48 #include "platform/RuntimeEnabledFeatures.h" | 47 #include "platform/RuntimeEnabledFeatures.h" |
| 49 #include "public/platform/Platform.h" | 48 #include "public/platform/Platform.h" |
| 50 | 49 |
| 51 namespace blink { | 50 namespace blink { |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 if (event->type() == EventTypeNames::click) { | 288 if (event->type() == EventTypeNames::click) { |
| 290 mediaElement().togglePlayState(); | 289 mediaElement().togglePlayState(); |
| 291 updateDisplayType(); | 290 updateDisplayType(); |
| 292 event->setDefaultHandled(); | 291 event->setDefaultHandled(); |
| 293 } | 292 } |
| 294 HTMLInputElement::defaultEventHandler(event); | 293 HTMLInputElement::defaultEventHandler(event); |
| 295 } | 294 } |
| 296 | 295 |
| 297 void MediaControlPlayButtonElement::updateDisplayType() | 296 void MediaControlPlayButtonElement::updateDisplayType() |
| 298 { | 297 { |
| 299 setDisplayType(mediaElement().togglePlayStateWillPlay() ? MediaPlayButton :
MediaPauseButton); | 298 setDisplayType(mediaElement().paused() ? MediaPlayButton : MediaPauseButton)
; |
| 300 } | 299 } |
| 301 | 300 |
| 302 // ---------------------------- | 301 // ---------------------------- |
| 303 | 302 |
| 304 MediaControlOverlayPlayButtonElement::MediaControlOverlayPlayButtonElement(Media
Controls& mediaControls) | 303 MediaControlOverlayPlayButtonElement::MediaControlOverlayPlayButtonElement(Media
Controls& mediaControls) |
| 305 : MediaControlInputElement(mediaControls, MediaOverlayPlayButton) | 304 : MediaControlInputElement(mediaControls, MediaOverlayPlayButton) |
| 306 { | 305 { |
| 307 } | 306 } |
| 308 | 307 |
| 309 PassRefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> MediaControlOverlay
PlayButtonElement::create(MediaControls& mediaControls) | 308 PassRefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> MediaControlOverlay
PlayButtonElement::create(MediaControls& mediaControls) |
| 310 { | 309 { |
| 311 RefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> button = adoptRefWi
llBeNoop(new MediaControlOverlayPlayButtonElement(mediaControls)); | 310 RefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> button = adoptRefWi
llBeNoop(new MediaControlOverlayPlayButtonElement(mediaControls)); |
| 312 button->ensureUserAgentShadowRoot(); | 311 button->ensureUserAgentShadowRoot(); |
| 313 button->setType(InputTypeNames::button); | 312 button->setType(InputTypeNames::button); |
| 314 button->setShadowPseudoId(AtomicString("-webkit-media-controls-overlay-play-
button", AtomicString::ConstructFromLiteral)); | 313 button->setShadowPseudoId(AtomicString("-webkit-media-controls-overlay-play-
button", AtomicString::ConstructFromLiteral)); |
| 315 return button.release(); | 314 return button.release(); |
| 316 } | 315 } |
| 317 | 316 |
| 318 void MediaControlOverlayPlayButtonElement::defaultEventHandler(Event* event) | 317 void MediaControlOverlayPlayButtonElement::defaultEventHandler(Event* event) |
| 319 { | 318 { |
| 320 if (event->type() == EventTypeNames::click && mediaElement().togglePlayState
WillPlay()) { | 319 if (event->type() == EventTypeNames::click && mediaElement().paused()) { |
| 321 mediaElement().togglePlayState(); | 320 mediaElement().play(); |
| 322 updateDisplayType(); | 321 updateDisplayType(); |
| 323 event->setDefaultHandled(); | 322 event->setDefaultHandled(); |
| 324 } | 323 } |
| 325 } | 324 } |
| 326 | 325 |
| 327 void MediaControlOverlayPlayButtonElement::updateDisplayType() | 326 void MediaControlOverlayPlayButtonElement::updateDisplayType() |
| 328 { | 327 { |
| 329 setIsWanted(mediaElement().shouldShowControls() && mediaElement().togglePlay
StateWillPlay()); | 328 setIsWanted(mediaElement().shouldShowControls() && mediaElement().paused()); |
| 330 } | 329 } |
| 331 | 330 |
| 332 bool MediaControlOverlayPlayButtonElement::keepEventInNode(Event* event) | 331 bool MediaControlOverlayPlayButtonElement::keepEventInNode(Event* event) |
| 333 { | 332 { |
| 334 return isUserInteractionEvent(event); | 333 return isUserInteractionEvent(event); |
| 335 } | 334 } |
| 336 | 335 |
| 337 | 336 |
| 338 // ---------------------------- | 337 // ---------------------------- |
| 339 | 338 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 | 403 |
| 405 MediaControlInputElement::defaultEventHandler(event); | 404 MediaControlInputElement::defaultEventHandler(event); |
| 406 | 405 |
| 407 if (event->type() == EventTypeNames::mouseover || event->type() == EventType
Names::mouseout || event->type() == EventTypeNames::mousemove) | 406 if (event->type() == EventTypeNames::mouseover || event->type() == EventType
Names::mouseout || event->type() == EventTypeNames::mousemove) |
| 408 return; | 407 return; |
| 409 | 408 |
| 410 double time = value().toDouble(); | 409 double time = value().toDouble(); |
| 411 if (event->type() == EventTypeNames::input) { | 410 if (event->type() == EventTypeNames::input) { |
| 412 // FIXME: This will need to take the timeline offset into consideration | 411 // FIXME: This will need to take the timeline offset into consideration |
| 413 // once that concept is supported, see https://crbug.com/312699 | 412 // once that concept is supported, see https://crbug.com/312699 |
| 414 if (mediaElement().controller()) { | 413 if (mediaElement().seekable()->contain(time)) |
| 415 if (mediaElement().controller()->seekable()->contain(time)) | 414 mediaElement().setCurrentTime(time); |
| 416 mediaElement().controller()->setCurrentTime(time); | |
| 417 } else if (mediaElement().seekable()->contain(time)) { | |
| 418 mediaElement().setCurrentTime(time, IGNORE_EXCEPTION); | |
| 419 } | |
| 420 } | 415 } |
| 421 | 416 |
| 422 LayoutSlider* slider = toLayoutSlider(layoutObject()); | 417 LayoutSlider* slider = toLayoutSlider(layoutObject()); |
| 423 if (slider && slider->inDragMode()) | 418 if (slider && slider->inDragMode()) |
| 424 mediaControls().updateCurrentTimeDisplay(); | 419 mediaControls().updateCurrentTimeDisplay(); |
| 425 } | 420 } |
| 426 | 421 |
| 427 bool MediaControlTimelineElement::willRespondToMouseClickEvents() | 422 bool MediaControlTimelineElement::willRespondToMouseClickEvents() |
| 428 { | 423 { |
| 429 return inDocument() && document().isActive(); | 424 return inDocument() && document().isActive(); |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 } | 650 } |
| 656 | 651 |
| 657 PassRefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> MediaControlCurren
tTimeDisplayElement::create(MediaControls& mediaControls) | 652 PassRefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> MediaControlCurren
tTimeDisplayElement::create(MediaControls& mediaControls) |
| 658 { | 653 { |
| 659 RefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> element = adoptRef
WillBeNoop(new MediaControlCurrentTimeDisplayElement(mediaControls)); | 654 RefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> element = adoptRef
WillBeNoop(new MediaControlCurrentTimeDisplayElement(mediaControls)); |
| 660 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time
-display", AtomicString::ConstructFromLiteral)); | 655 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time
-display", AtomicString::ConstructFromLiteral)); |
| 661 return element.release(); | 656 return element.release(); |
| 662 } | 657 } |
| 663 | 658 |
| 664 } // namespace blink | 659 } // namespace blink |
| OLD | NEW |