frame_layout_manager.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2020 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. #ifndef FUCHSIA_WEB_WEBENGINE_BROWSER_FRAME_LAYOUT_MANAGER_H_
  5. #define FUCHSIA_WEB_WEBENGINE_BROWSER_FRAME_LAYOUT_MANAGER_H_
  6. #include "ui/aura/layout_manager.h"
  7. #include "ui/aura/window.h"
  8. // Layout manager used for the root window that hosts the WebContents window.
  9. // The main WebContents window is stretched to occupy the whole parent. Note
  10. // that the root window may host other windows (particularly menus for drop-down
  11. // boxes). These windows get the location and size they request. The main
  12. // window for the web content is identified by window.type() ==
  13. // WINDOW_TYPE_CONTROL (set in WebContentsViewAura).
  14. class FrameLayoutManager : public aura::LayoutManager {
  15. public:
  16. FrameLayoutManager();
  17. ~FrameLayoutManager() override;
  18. FrameLayoutManager(const FrameLayoutManager&) = delete;
  19. FrameLayoutManager& operator=(const FrameLayoutManager&) = delete;
  20. // Renders web content within a virtual window of a given |size|, which is
  21. // proportionately scaled to fit within the View.
  22. void ForceContentDimensions(gfx::Size size);
  23. private:
  24. // Sizes the main window to fit inside its container.
  25. // Sets the window's internal resolution to |render_size_override_|, if set,
  26. // and adjusts its scaling factor so that it fits inside the container without
  27. // clipping.
  28. void UpdateContentBounds();
  29. // aura::LayoutManager implementation.
  30. void OnWindowResized() override;
  31. void OnWindowAddedToLayout(aura::Window* child) override;
  32. void OnWillRemoveWindowFromLayout(aura::Window* child) override;
  33. void OnWindowRemovedFromLayout(aura::Window* child) override;
  34. void OnChildWindowVisibilityChanged(aura::Window* child,
  35. bool visible) override;
  36. void SetChildBounds(aura::Window* child,
  37. const gfx::Rect& requested_bounds) override;
  38. // The main window used for the WebContents.
  39. aura::Window* main_child_ = nullptr;
  40. gfx::Size render_size_override_;
  41. };
  42. #endif // FUCHSIA_WEB_WEBENGINE_BROWSER_FRAME_LAYOUT_MANAGER_H_