Repository: electron/electron
File: shell/browser/api/electron_api_view.cc (C++)

Code before:
  bool animate = false;
  int duration = 250;
  std::string easing = "linear";

  gin_helper::Dictionary options;
  if (args->GetNext(&options)) {
    options.Get("animate", &animate);
    options.Get("duration", &duration);
    options.Get("easing", &easing);
  }

  if (duration < 0)
    duration = 0;

  if (!view_)
    return;

  if (!animate) {
    view_->SetBoundsRect(bounds);

    return;
  }

  gfx::Tween::Type tween_type = gfx::Tween::LINEAR;

  if (easing == "ease-in") {
    tween_type = gfx::Tween::EASE_IN;
  } else if (easing == "ease-out") {
    tween_type = gfx::Tween::EASE_OUT;
  } else if (easing == "ease-in-out") {
    tween_type = gfx::Tween::EASE_IN_OUT;
  }

  gfx::Rect current_bounds = view_->bounds();
  gfx::Rect target_size = gfx::Rect(0, 0, bounds.width(), bounds.height());
  gfx::Rect max_size =
      gfx::Rect(current_bounds.x(), current_bounds.y(),
                std::max(current_bounds.width(), bounds.width()),
                std::max(current_bounds.height(), bounds.height()));

  view_->SetPaintToLayer(ui::LAYER_NOT_DRAWN);

  // if the view's size is smaller than the target size, we need to set the
  // view's bounds immediatley to the new size (not position) and set the
  // layer's clip rect to animate from there.
  if (view_->width() < bounds.width() || view_->height() < bounds.height()) {
    view_->SetBoundsRect(max_size);

    ui::Layer* layer = view_->layer();
    if (layer) {
      layer->SetClipRect(

Review comment (suggestion):
this would be replaced above with something like:

```
template <>
struct Converter<gfx::Tween::Type> {
  static bool FromV8(v8::Isolate* isolate,
                     v8::Local<v8::Value> val,
                     gfx::Tween::Type* out) {
    std::string easing = base::ToLowerASCII(gin::V8ToString(isolate, val));
    if (orientation == "linear") {
      *out = gfx::Tween::LINEAR;
    } else if (orientation == "ease-in") {
      *out = gfx::Tween::EASE_IN;
    } else if (orientation == "ease-out") {
      *out = gfx::Tween::EASE_OUT;
    } else if (orientation == "ease-in-out") {
      *out = gfx::Tween::EASE_IN_OUT;
    } else {
      return false;
    }
    return true;
  }
};
```

Code after:
    return;

  const auto it =
      std::ranges::find_if(child_views_, [&](const ChildPair& child_view) {
        return child_view.first == child->view();
      });
  if (it != child_views_.end()) {
#if BUILDFLAG(IS_MAC)
    ScopedCAActionDisabler disable_animations;
#endif
    // Remove from child_views first so that OnChildViewRemoved doesn't try to
    // remove it again
    child_views_.erase(it);
    // It's possible for the child's view to be invalid here
    // if the child's webContents was closed or destroyed.
    if (child->view())
      view_->RemoveChildView(child->view());
  }
}

ui::Layer* View::GetLayer() {
  if (!view_)
    return nullptr;

  if (view_->layer())
    return view_->layer();

  view_->SetPaintToLayer();

  ui::Layer* layer = view_->layer();

  layer->SetFillsBoundsOpaquely(false);

  return layer;
}

void View::SetBounds(const gfx::Rect& bounds, gin::Arguments* const args) {
  bool animate = false;
  int duration = 250;
  gfx::Tween::Type easing = gfx::Tween::LINEAR;

  gin_helper::Dictionary dict;
  if (args->GetNext(&dict)) {
    v8::Local<v8::Value> animate_value;

    if (dict.Get("animate", &animate_value)) {
      if (animate_value->IsBoolean()) {
        animate = animate_value->BooleanValue(isolate());
      } else {
        animate = true;