scoped_animation_disabler.cc 848 B

123456789101112131415161718192021222324252627
  1. // Copyright 2018 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/scoped_animation_disabler.h"
  5. #include "ui/aura/client/aura_constants.h"
  6. #include "ui/base/class_property.h"
  7. namespace ash {
  8. ScopedAnimationDisabler::ScopedAnimationDisabler(aura::Window* window)
  9. : window_(window) {
  10. DCHECK(window_);
  11. needs_disable_ = !window_->GetProperty(aura::client::kAnimationsDisabledKey);
  12. if (needs_disable_)
  13. window_->SetProperty(aura::client::kAnimationsDisabledKey, true);
  14. }
  15. ScopedAnimationDisabler::~ScopedAnimationDisabler() {
  16. if (needs_disable_) {
  17. DCHECK_EQ(window_->GetProperty(aura::client::kAnimationsDisabledKey), true);
  18. window_->ClearProperty(aura::client::kAnimationsDisabledKey);
  19. }
  20. }
  21. } // namespace ash