Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(452)

Unified Diff: third_party/WebKit/Source/core/html/shadow/MediaRemotingInterstitial.cpp

Issue 2825493005: Enable smooth transition when show/hide media remoting interstitial. (Closed)
Patch Set: Fix nits. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/html/shadow/MediaRemotingInterstitial.cpp
diff --git a/third_party/WebKit/Source/core/html/shadow/MediaRemotingInterstitial.cpp b/third_party/WebKit/Source/core/html/shadow/MediaRemotingInterstitial.cpp
index e183d8e59310f7094da408fae10d9a88b3cb8dd3..f38296b13caa2f55ef6c9b2a6b8d504657ccf12d 100644
--- a/third_party/WebKit/Source/core/html/shadow/MediaRemotingInterstitial.cpp
+++ b/third_party/WebKit/Source/core/html/shadow/MediaRemotingInterstitial.cpp
@@ -4,15 +4,28 @@
#include "core/html/shadow/MediaRemotingInterstitial.h"
+#include "core/dom/TaskRunnerHelper.h"
#include "core/html/HTMLImageElement.h"
#include "core/html/HTMLVideoElement.h"
#include "core/html/shadow/MediaRemotingElements.h"
+namespace {
+
+constexpr double kStyleChangeTransSeconds = 0.2;
+constexpr double kHiddenAnimationSeconds = 0.3;
+
+} // namespace
+
namespace blink {
MediaRemotingInterstitial::MediaRemotingInterstitial(
HTMLVideoElement& videoElement)
: HTMLDivElement(videoElement.GetDocument()),
+ toggle_insterstitial_timer_(
+ TaskRunnerHelper::Get(TaskType::kUnthrottled,
+ &videoElement.GetDocument()),
+ this,
+ &MediaRemotingInterstitial::ToggleInterstitialTimerFired),
video_element_(&videoElement) {
SetShadowPseudoId(AtomicString("-internal-media-remoting-interstitial"));
background_image_ = HTMLImageElement::Create(videoElement.GetDocument());
@@ -32,13 +45,43 @@ MediaRemotingInterstitial::MediaRemotingInterstitial(
}
void MediaRemotingInterstitial::Show() {
+ DCHECK(!should_be_visible_);
+ if (toggle_insterstitial_timer_.IsActive())
+ toggle_insterstitial_timer_.Stop();
+ should_be_visible_ = true;
RemoveInlineStyleProperty(CSSPropertyDisplay);
exit_button_->OnShown();
+ toggle_insterstitial_timer_.StartOneShot(kStyleChangeTransSeconds,
+ BLINK_FROM_HERE);
}
void MediaRemotingInterstitial::Hide() {
- SetInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
+ DCHECK(should_be_visible_);
+ if (toggle_insterstitial_timer_.IsActive())
+ toggle_insterstitial_timer_.Stop();
+ should_be_visible_ = false;
+ SetInlineStyleProperty(CSSPropertyOpacity, 0,
+ CSSPrimitiveValue::UnitType::kNumber);
exit_button_->OnHidden();
+ toggle_insterstitial_timer_.StartOneShot(kHiddenAnimationSeconds,
+ BLINK_FROM_HERE);
+}
+
+void MediaRemotingInterstitial::ToggleInterstitialTimerFired(TimerBase*) {
+ toggle_insterstitial_timer_.Stop();
+ if (should_be_visible_) {
+ SetInlineStyleProperty(CSSPropertyOpacity, 1,
+ CSSPrimitiveValue::UnitType::kNumber);
+ } else {
+ SetInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
+ }
+}
+
+void MediaRemotingInterstitial::DidMoveToNewDocument(Document& old_document) {
+ toggle_insterstitial_timer_.MoveToNewTaskRunner(
+ TaskRunnerHelper::Get(TaskType::kUnthrottled, &GetDocument()));
+
+ HTMLDivElement::DidMoveToNewDocument(old_document);
}
void MediaRemotingInterstitial::OnPosterImageChanged() {

Powered by Google App Engine
This is Rietveld 408576698