Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2011, 2012 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2011, 2012 Google Inc. All rights reserved. | 3 * Copyright (C) 2011, 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 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/html/shadow/MediaControls.h" | 28 #include "core/html/shadow/MediaControls.h" |
| 29 | 29 |
| 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 30 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 31 #include "core/dom/ClientRect.h" | 31 #include "core/dom/ClientRect.h" |
| 32 #include "core/events/MouseEvent.h" | 32 #include "core/events/MouseEvent.h" |
| 33 #include "core/frame/Settings.h" | 33 #include "core/frame/Settings.h" |
| 34 #include "core/html/HTMLMediaElement.h" | 34 #include "core/html/HTMLMediaElement.h" |
| 35 #include "core/html/MediaController.h" | 35 #include "core/html/MediaController.h" |
| 36 #include "core/layout/LayoutTheme.h" | 36 #include "core/layout/LayoutTheme.h" |
| 37 #include "core/page/EventHandler.h" | |
| 37 | 38 |
| 38 namespace blink { | 39 namespace blink { |
| 39 | 40 |
| 40 // If you change this value, then also update the corresponding value in | 41 // If you change this value, then also update the corresponding value in |
| 41 // LayoutTests/media/media-controls.js. | 42 // LayoutTests/media/media-controls.js. |
| 42 static const double timeWithoutMouseMovementBeforeHidingMediaControls = 3; | 43 static const double timeWithoutMouseMovementBeforeHidingMediaControls = 3; |
| 43 | 44 |
| 44 static bool fullscreenIsSupported(const Document& document) | 45 static bool fullscreenIsSupported(const Document& document) |
| 45 { | 46 { |
| 46 return !document.settings() || document.settings()->fullscreenSupported(); | 47 return !document.settings() || document.settings()->fullscreenSupported(); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 61 , m_toggleClosedCaptionsButton(nullptr) | 62 , m_toggleClosedCaptionsButton(nullptr) |
| 62 , m_fullScreenButton(nullptr) | 63 , m_fullScreenButton(nullptr) |
| 63 , m_castButton(nullptr) | 64 , m_castButton(nullptr) |
| 64 , m_overlayCastButton(nullptr) | 65 , m_overlayCastButton(nullptr) |
| 65 , m_durationDisplay(nullptr) | 66 , m_durationDisplay(nullptr) |
| 66 , m_enclosure(nullptr) | 67 , m_enclosure(nullptr) |
| 67 , m_hideMediaControlsTimer(this, &MediaControls::hideMediaControlsTimerFired ) | 68 , m_hideMediaControlsTimer(this, &MediaControls::hideMediaControlsTimerFired ) |
| 68 , m_isMouseOverControls(false) | 69 , m_isMouseOverControls(false) |
| 69 , m_isPausedForScrubbing(false) | 70 , m_isPausedForScrubbing(false) |
| 70 , m_wasLastEventTouch(false) | 71 , m_wasLastEventTouch(false) |
| 72 , m_behaviorFlags(0) | |
| 71 { | 73 { |
| 72 } | 74 } |
| 73 | 75 |
| 74 PassRefPtrWillBeRawPtr<MediaControls> MediaControls::create(HTMLMediaElement& me diaElement) | 76 PassRefPtrWillBeRawPtr<MediaControls> MediaControls::create(HTMLMediaElement& me diaElement) |
| 75 { | 77 { |
| 76 RefPtrWillBeRawPtr<MediaControls> controls = adoptRefWillBeNoop(new MediaCon trols(mediaElement)); | 78 RefPtrWillBeRawPtr<MediaControls> controls = adoptRefWillBeNoop(new MediaCon trols(mediaElement)); |
| 77 controls->setShadowPseudoId(AtomicString("-webkit-media-controls", AtomicStr ing::ConstructFromLiteral)); | 79 controls->setShadowPseudoId(AtomicString("-webkit-media-controls", AtomicStr ing::ConstructFromLiteral)); |
| 78 controls->initializeControls(); | 80 controls->initializeControls(); |
| 79 return controls.release(); | 81 return controls.release(); |
| 80 } | 82 } |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 m_castButton->setIsPlayingRemotely(false); | 436 m_castButton->setIsPlayingRemotely(false); |
| 435 m_overlayCastButton->setIsPlayingRemotely(false); | 437 m_overlayCastButton->setIsPlayingRemotely(false); |
| 436 } | 438 } |
| 437 | 439 |
| 438 void MediaControls::defaultEventHandler(Event* event) | 440 void MediaControls::defaultEventHandler(Event* event) |
| 439 { | 441 { |
| 440 HTMLDivElement::defaultEventHandler(event); | 442 HTMLDivElement::defaultEventHandler(event); |
| 441 m_wasLastEventTouch = event->isTouchEvent() || event->isGestureEvent() | 443 m_wasLastEventTouch = event->isTouchEvent() || event->isGestureEvent() |
| 442 || (event->isMouseEvent() && toMouseEvent(event)->fromTouch()); | 444 || (event->isMouseEvent() && toMouseEvent(event)->fromTouch()); |
| 443 | 445 |
| 446 if (m_wasLastEventTouch) { | |
| 447 m_behaviorFlags |= IgnoreControlsHover; | |
|
fs
2015/02/06 10:32:36
I think I'd prefer if we could factor this slightl
| |
| 448 } | |
| 449 | |
| 444 if (event->type() == EventTypeNames::mouseover) { | 450 if (event->type() == EventTypeNames::mouseover) { |
| 445 if (!containsRelatedTarget(event)) { | 451 if (!containsRelatedTarget(event)) { |
| 446 m_isMouseOverControls = true; | 452 m_isMouseOverControls = true; |
| 447 if (!mediaElement().togglePlayStateWillPlay()) { | 453 if (!mediaElement().togglePlayStateWillPlay()) { |
| 448 makeOpaque(); | 454 makeOpaque(); |
| 449 if (shouldHideMediaControls()) | 455 if (shouldHideMediaControls()) |
| 450 startHideMediaControlsTimer(); | 456 startHideMediaControlsTimer(); |
| 451 } | 457 } |
| 452 } | 458 } |
| 453 return; | 459 return; |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 470 startHideMediaControlsTimer(); | 476 startHideMediaControlsTimer(); |
| 471 return; | 477 return; |
| 472 } | 478 } |
| 473 } | 479 } |
| 474 | 480 |
| 475 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) | 481 void MediaControls::hideMediaControlsTimerFired(Timer<MediaControls>*) |
| 476 { | 482 { |
| 477 if (mediaElement().togglePlayStateWillPlay()) | 483 if (mediaElement().togglePlayStateWillPlay()) |
| 478 return; | 484 return; |
| 479 | 485 |
| 480 unsigned behaviorFlags = IgnoreFocus | IgnoreVideoHover; | 486 m_behaviorFlags = m_behaviorFlags | IgnoreFocus | IgnoreVideoHover; |
| 481 if (m_wasLastEventTouch) { | 487 if (!shouldHideMediaControls(m_behaviorFlags)) |
| 482 behaviorFlags |= IgnoreControlsHover; | |
| 483 } | |
| 484 if (!shouldHideMediaControls(behaviorFlags)) | |
| 485 return; | 488 return; |
| 486 | 489 |
| 487 makeTransparent(); | 490 makeTransparent(); |
| 488 m_overlayCastButton->hide(); | 491 m_overlayCastButton->hide(); |
| 492 m_behaviorFlags = 0; | |
| 489 } | 493 } |
| 490 | 494 |
| 491 void MediaControls::startHideMediaControlsTimer() | 495 void MediaControls::startHideMediaControlsTimer() |
| 492 { | 496 { |
| 493 m_hideMediaControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHidingMe diaControls, FROM_HERE); | 497 m_hideMediaControlsTimer.startOneShot(timeWithoutMouseMovementBeforeHidingMe diaControls, FROM_HERE); |
| 494 } | 498 } |
| 495 | 499 |
| 496 void MediaControls::stopHideMediaControlsTimer() | 500 void MediaControls::stopHideMediaControlsTimer() |
| 497 { | 501 { |
| 498 m_hideMediaControlsTimer.stop(); | 502 m_hideMediaControlsTimer.stop(); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 565 visitor->trace(m_toggleClosedCaptionsButton); | 569 visitor->trace(m_toggleClosedCaptionsButton); |
| 566 visitor->trace(m_fullScreenButton); | 570 visitor->trace(m_fullScreenButton); |
| 567 visitor->trace(m_durationDisplay); | 571 visitor->trace(m_durationDisplay); |
| 568 visitor->trace(m_enclosure); | 572 visitor->trace(m_enclosure); |
| 569 visitor->trace(m_castButton); | 573 visitor->trace(m_castButton); |
| 570 visitor->trace(m_overlayCastButton); | 574 visitor->trace(m_overlayCastButton); |
| 571 HTMLDivElement::trace(visitor); | 575 HTMLDivElement::trace(visitor); |
| 572 } | 576 } |
| 573 | 577 |
| 574 } | 578 } |
| OLD | NEW |