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

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: Rebase only. 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..1f36deda8ff88a3764466c3e50f16481c07d59b6 100644
--- a/third_party/WebKit/Source/core/html/shadow/MediaRemotingInterstitial.cpp
+++ b/third_party/WebKit/Source/core/html/shadow/MediaRemotingInterstitial.cpp
@@ -4,15 +4,29 @@
#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()),
+ is_shown_(false),
+ 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 +46,45 @@ MediaRemotingInterstitial::MediaRemotingInterstitial(
}
void MediaRemotingInterstitial::Show() {
+ if (is_shown_ && toggle_insterstitial_timer_.IsActive())
mlamouri (slow - plz ping) 2017/04/19 16:17:19 Why do you check if the timer is active? Actually,
xjz 2017/04/19 17:11:19 Done. Yes, the timer could be active. For example,
+ return;
+ if (toggle_insterstitial_timer_.IsActive())
+ toggle_insterstitial_timer_.Stop();
+ is_shown_ = true;
RemoveInlineStyleProperty(CSSPropertyDisplay);
- exit_button_->OnShown();
+ toggle_insterstitial_timer_.StartOneShot(kStyleChangeTransSeconds,
+ BLINK_FROM_HERE);
}
void MediaRemotingInterstitial::Hide() {
- SetInlineStyleProperty(CSSPropertyDisplay, CSSValueNone);
+ if (!is_shown_ && toggle_insterstitial_timer_.IsActive())
+ return;
+ if (toggle_insterstitial_timer_.IsActive())
+ toggle_insterstitial_timer_.Stop();
+ is_shown_ = false;
exit_button_->OnHidden();
+ SetInlineStyleProperty(CSSPropertyOpacity, 0,
+ CSSPrimitiveValue::UnitType::kNumber);
+ toggle_insterstitial_timer_.StartOneShot(kHiddenAnimationSeconds,
+ BLINK_FROM_HERE);
+}
+
+void MediaRemotingInterstitial::ToggleInterstitialTimerFired(TimerBase*) {
+ toggle_insterstitial_timer_.Stop();
+ if (is_shown_) {
+ SetInlineStyleProperty(CSSPropertyOpacity, 1,
+ CSSPrimitiveValue::UnitType::kNumber);
+ exit_button_->OnShown();
mlamouri (slow - plz ping) 2017/04/19 16:17:19 Why are we not being consistent with onShown and o
xjz 2017/04/19 17:11:19 The initial thought was call onHidden() first to s
+ } 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