<commit_before>// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/wm/visibility_controller.h"

#include "ash/wm/window_animations.h"
#include "ui/aura/window.h"

namespace ash {
namespace internal {
namespace {

// Property set on all windows whose child windows' visibility changes are
// animated. The type of the value is bool.
const char kChildWindowVisibilityChangesAnimated[] =
    "ash/wm/ChildWindowVisibilityChangesAnimated";

bool GetChildWindowVisibilityChangesAnimated(aura::Window* window) {
  if (!window)
    return false;
  return window->GetIntProperty(kChildWindowVisibilityChangesAnimated) != 0;
}

}  // namespace

VisibilityController::VisibilityController() {
}

VisibilityController::~VisibilityController() {
}

void VisibilityController::UpdateLayerVisibility(aura::Window* window,
                                                 bool visible) {
  bool animated = GetChildWindowVisibilityChangesAnimated(window->parent()) &&
                  window->type() != aura::client::WINDOW_TYPE_CONTROL &&
                  window->type() != aura::client::WINDOW_TYPE_UNKNOWN;
  animated = animated && AnimateOnChildWindowVisibilityChanged(window, visible);

  // When a window is made visible, we always make its layer visible
  // immediately. When a window is hidden, the layer must be left visible and
  // only made not visible once the animation is complete.
  if (!animated || visible)
    window->layer()->SetVisible(visible);
}

}  // namespace internal

void SetChildWindowVisibilityChangesAnimated(aura::Window* window) {
  window->SetIntProperty(internal::kChildWindowVisibilityChangesAnimated, 1);
}

}  // namespace ash<commit_msg>aura: Ignore hide animation request for a window that is already animating to hide.<commit_after>// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ash/wm/visibility_controller.h"

#include "ash/wm/window_animations.h"
#include "ui/aura/window.h"

namespace ash {
namespace internal {
namespace {

// Property set on all windows whose child windows' visibility changes are
// animated. The type of the value is bool.
const char kChildWindowVisibilityChangesAnimated[] =
    "ash/wm/ChildWindowVisibilityChangesAnimated";

bool GetChildWindowVisibilityChangesAnimated(aura::Window* window) {
  if (!window)
    return false;
  return window->GetIntProperty(kChildWindowVisibilityChangesAnimated) != 0;
}

}  // namespace

VisibilityController::VisibilityController() {
}

VisibilityController::~VisibilityController() {
}

void VisibilityController::UpdateLayerVisibility(aura::Window* window,
                                                 bool visible) {
  bool animated = GetChildWindowVisibilityChangesAnimated(window->parent()) &&
                  window->type() != aura::client::WINDOW_TYPE_CONTROL &&
                  window->type() != aura::client::WINDOW_TYPE_UNKNOWN;
  animated = animated && AnimateOnChildWindowVisibilityChanged(window, visible);

  if (!visible) {
    // For window hiding animation, we want to check if the window is already
    // animating, and not do SetVisible(false) if it is.
    // TODO(vollick): remove this.
    animated = animated || (window->layer()->GetAnimator()->
        IsAnimatingProperty(ui::LayerAnimationElement::OPACITY) &&
        window->layer()->GetTargetOpacity() == 0.0f);
  }

  // When a window is made visible, we always make its layer visible
  // immediately. When a window is hidden, the layer must be left visible and
  // only made not visible once the animation is complete.
  if (!animated || visible)
    window->layer()->SetVisible(visible);
}

}  // namespace internal

void SetChildWindowVisibilityChangesAnimated(aura::Window* window) {
  window->SetIntProperty(internal::kChildWindowVisibilityChangesAnimated, 1);
}

}  // namespace ash
{'fraction_non_alphanumeric': 0.10279910824869953, 'fraction_numerical': 0.0034679217240525142, 'mean_word_length': 3.9667896678966788, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6936091', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1035, 'n_words': 322}