enable_reset_aspect_ratio.patch 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Cheng Zhao <[email protected]>
  3. Date: Thu, 4 Oct 2018 14:57:02 -0700
  4. Subject: feat: enable setting aspect ratio to 0
  5. Make SetAspectRatio accept 0 as valid input, which would reset to null.
  6. diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
  7. index a1de50d6b0f699d0651c369cafafdd5bb542242d..65b9f5e5f81e8ef8b591ef2e027e095df11c0d7b 100644
  8. --- a/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
  9. +++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc
  10. @@ -530,7 +530,7 @@ void DesktopWindowTreeHostWin::SetOpacity(float opacity) {
  11. }
  12. void DesktopWindowTreeHostWin::SetAspectRatio(const gfx::SizeF& aspect_ratio) {
  13. - DCHECK(!aspect_ratio.IsEmpty());
  14. + DCHECK_NE(aspect_ratio.height(), 0);
  15. message_handler_->SetAspectRatio(aspect_ratio.width() /
  16. aspect_ratio.height());
  17. }
  18. diff --git a/ui/views/win/hwnd_message_handler.cc b/ui/views/win/hwnd_message_handler.cc
  19. index b14fa0f41166a904991ec920cec2f45c3b71c953..37bb1e9788a251b3f2c79b5272d4a44c22b707b3 100644
  20. --- a/ui/views/win/hwnd_message_handler.cc
  21. +++ b/ui/views/win/hwnd_message_handler.cc
  22. @@ -936,8 +936,11 @@ void HWNDMessageHandler::SetFullscreen(bool fullscreen) {
  23. }
  24. void HWNDMessageHandler::SetAspectRatio(float aspect_ratio) {
  25. - // If the aspect ratio is not in the valid range, do nothing.
  26. - DCHECK_GT(aspect_ratio, 0.0f);
  27. + // If the aspect ratio is 0, reset it to null.
  28. + if (aspect_ratio == 0.0f) {
  29. + aspect_ratio_.reset();
  30. + return;
  31. + }
  32. aspect_ratio_ = aspect_ratio;