| 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 19 matching lines...) Expand all Loading... |
| 30 #include "config.h" | 30 #include "config.h" |
| 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/DOMTokenList.h" | 35 #include "core/dom/DOMTokenList.h" |
| 36 #include "core/dom/shadow/ShadowRoot.h" | 36 #include "core/dom/shadow/ShadowRoot.h" |
| 37 #include "core/events/MouseEvent.h" | 37 #include "core/events/MouseEvent.h" |
| 38 #include "core/frame/LocalFrame.h" | 38 #include "core/frame/LocalFrame.h" |
| 39 #include "core/html/HTMLVideoElement.h" | 39 #include "core/html/HTMLVideoElement.h" |
| 40 #include "core/html/MediaController.h" | |
| 41 #include "core/html/TimeRanges.h" | 40 #include "core/html/TimeRanges.h" |
| 42 #include "core/html/shadow/MediaControls.h" | 41 #include "core/html/shadow/MediaControls.h" |
| 43 #include "core/input/EventHandler.h" | 42 #include "core/input/EventHandler.h" |
| 44 #include "core/layout/LayoutSlider.h" | 43 #include "core/layout/LayoutSlider.h" |
| 45 #include "core/layout/LayoutTheme.h" | 44 #include "core/layout/LayoutTheme.h" |
| 46 #include "core/layout/LayoutVideo.h" | 45 #include "core/layout/LayoutVideo.h" |
| 47 #include "platform/RuntimeEnabledFeatures.h" | 46 #include "platform/RuntimeEnabledFeatures.h" |
| 48 | 47 |
| 49 namespace blink { | 48 namespace blink { |
| 50 | 49 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 if (event->type() == EventTypeNames::click) { | 274 if (event->type() == EventTypeNames::click) { |
| 276 mediaElement().togglePlayState(); | 275 mediaElement().togglePlayState(); |
| 277 updateDisplayType(); | 276 updateDisplayType(); |
| 278 event->setDefaultHandled(); | 277 event->setDefaultHandled(); |
| 279 } | 278 } |
| 280 HTMLInputElement::defaultEventHandler(event); | 279 HTMLInputElement::defaultEventHandler(event); |
| 281 } | 280 } |
| 282 | 281 |
| 283 void MediaControlPlayButtonElement::updateDisplayType() | 282 void MediaControlPlayButtonElement::updateDisplayType() |
| 284 { | 283 { |
| 285 setDisplayType(mediaElement().togglePlayStateWillPlay() ? MediaPlayButton :
MediaPauseButton); | 284 setDisplayType(mediaElement().paused() ? MediaPlayButton : MediaPauseButton)
; |
| 286 } | 285 } |
| 287 | 286 |
| 288 // ---------------------------- | 287 // ---------------------------- |
| 289 | 288 |
| 290 MediaControlOverlayPlayButtonElement::MediaControlOverlayPlayButtonElement(Media
Controls& mediaControls) | 289 MediaControlOverlayPlayButtonElement::MediaControlOverlayPlayButtonElement(Media
Controls& mediaControls) |
| 291 : MediaControlInputElement(mediaControls, MediaOverlayPlayButton) | 290 : MediaControlInputElement(mediaControls, MediaOverlayPlayButton) |
| 292 { | 291 { |
| 293 } | 292 } |
| 294 | 293 |
| 295 PassRefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> MediaControlOverlay
PlayButtonElement::create(MediaControls& mediaControls) | 294 PassRefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> MediaControlOverlay
PlayButtonElement::create(MediaControls& mediaControls) |
| 296 { | 295 { |
| 297 RefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> button = adoptRefWi
llBeNoop(new MediaControlOverlayPlayButtonElement(mediaControls)); | 296 RefPtrWillBeRawPtr<MediaControlOverlayPlayButtonElement> button = adoptRefWi
llBeNoop(new MediaControlOverlayPlayButtonElement(mediaControls)); |
| 298 button->ensureUserAgentShadowRoot(); | 297 button->ensureUserAgentShadowRoot(); |
| 299 button->setType(InputTypeNames::button); | 298 button->setType(InputTypeNames::button); |
| 300 button->setShadowPseudoId(AtomicString("-webkit-media-controls-overlay-play-
button", AtomicString::ConstructFromLiteral)); | 299 button->setShadowPseudoId(AtomicString("-webkit-media-controls-overlay-play-
button", AtomicString::ConstructFromLiteral)); |
| 301 return button.release(); | 300 return button.release(); |
| 302 } | 301 } |
| 303 | 302 |
| 304 void MediaControlOverlayPlayButtonElement::defaultEventHandler(Event* event) | 303 void MediaControlOverlayPlayButtonElement::defaultEventHandler(Event* event) |
| 305 { | 304 { |
| 306 if (event->type() == EventTypeNames::click && mediaElement().togglePlayState
WillPlay()) { | 305 if (event->type() == EventTypeNames::click && mediaElement().paused()) { |
| 307 mediaElement().togglePlayState(); | 306 mediaElement().play(); |
| 308 updateDisplayType(); | 307 updateDisplayType(); |
| 309 event->setDefaultHandled(); | 308 event->setDefaultHandled(); |
| 310 } | 309 } |
| 311 } | 310 } |
| 312 | 311 |
| 313 void MediaControlOverlayPlayButtonElement::updateDisplayType() | 312 void MediaControlOverlayPlayButtonElement::updateDisplayType() |
| 314 { | 313 { |
| 315 setIsWanted(mediaElement().shouldShowControls() && mediaElement().togglePlay
StateWillPlay()); | 314 setIsWanted(mediaElement().shouldShowControls() && mediaElement().paused()); |
| 316 } | 315 } |
| 317 | 316 |
| 318 bool MediaControlOverlayPlayButtonElement::keepEventInNode(Event* event) | 317 bool MediaControlOverlayPlayButtonElement::keepEventInNode(Event* event) |
| 319 { | 318 { |
| 320 return isUserInteractionEvent(event); | 319 return isUserInteractionEvent(event); |
| 321 } | 320 } |
| 322 | 321 |
| 323 | 322 |
| 324 // ---------------------------- | 323 // ---------------------------- |
| 325 | 324 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 | 389 |
| 391 MediaControlInputElement::defaultEventHandler(event); | 390 MediaControlInputElement::defaultEventHandler(event); |
| 392 | 391 |
| 393 if (event->type() == EventTypeNames::mouseover || event->type() == EventType
Names::mouseout || event->type() == EventTypeNames::mousemove) | 392 if (event->type() == EventTypeNames::mouseover || event->type() == EventType
Names::mouseout || event->type() == EventTypeNames::mousemove) |
| 394 return; | 393 return; |
| 395 | 394 |
| 396 double time = value().toDouble(); | 395 double time = value().toDouble(); |
| 397 if (event->type() == EventTypeNames::input) { | 396 if (event->type() == EventTypeNames::input) { |
| 398 // FIXME: This will need to take the timeline offset into consideration | 397 // FIXME: This will need to take the timeline offset into consideration |
| 399 // once that concept is supported, see https://crbug.com/312699 | 398 // once that concept is supported, see https://crbug.com/312699 |
| 400 if (mediaElement().controller()) { | 399 if (mediaElement().seekable()->contain(time)) |
| 401 if (mediaElement().controller()->seekable()->contain(time)) | 400 mediaElement().setCurrentTime(time); |
| 402 mediaElement().controller()->setCurrentTime(time); | |
| 403 } else if (mediaElement().seekable()->contain(time)) { | |
| 404 mediaElement().setCurrentTime(time, IGNORE_EXCEPTION); | |
| 405 } | |
| 406 } | 401 } |
| 407 | 402 |
| 408 LayoutSlider* slider = toLayoutSlider(layoutObject()); | 403 LayoutSlider* slider = toLayoutSlider(layoutObject()); |
| 409 if (slider && slider->inDragMode()) | 404 if (slider && slider->inDragMode()) |
| 410 mediaControls().updateCurrentTimeDisplay(); | 405 mediaControls().updateCurrentTimeDisplay(); |
| 411 } | 406 } |
| 412 | 407 |
| 413 bool MediaControlTimelineElement::willRespondToMouseClickEvents() | 408 bool MediaControlTimelineElement::willRespondToMouseClickEvents() |
| 414 { | 409 { |
| 415 return inDocument() && document().isActive(); | 410 return inDocument() && document().isActive(); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 } | 607 } |
| 613 | 608 |
| 614 PassRefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> MediaControlCurren
tTimeDisplayElement::create(MediaControls& mediaControls) | 609 PassRefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> MediaControlCurren
tTimeDisplayElement::create(MediaControls& mediaControls) |
| 615 { | 610 { |
| 616 RefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> element = adoptRef
WillBeNoop(new MediaControlCurrentTimeDisplayElement(mediaControls)); | 611 RefPtrWillBeRawPtr<MediaControlCurrentTimeDisplayElement> element = adoptRef
WillBeNoop(new MediaControlCurrentTimeDisplayElement(mediaControls)); |
| 617 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time
-display", AtomicString::ConstructFromLiteral)); | 612 element->setShadowPseudoId(AtomicString("-webkit-media-controls-current-time
-display", AtomicString::ConstructFromLiteral)); |
| 618 return element.release(); | 613 return element.release(); |
| 619 } | 614 } |
| 620 | 615 |
| 621 } // namespace blink | 616 } // namespace blink |
| OLD | NEW |