FrameBox.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/DOM/Document.h>
  7. #include <LibWeb/Layout/FrameBox.h>
  8. #include <LibWeb/Layout/Viewport.h>
  9. #include <LibWeb/Painting/NestedBrowsingContextPaintable.h>
  10. namespace Web::Layout {
  11. FrameBox::FrameBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr<CSS::StyleProperties> style)
  12. : ReplacedBox(document, element, move(style))
  13. {
  14. }
  15. FrameBox::~FrameBox() = default;
  16. void FrameBox::prepare_for_replaced_layout()
  17. {
  18. // FIXME: Do proper error checking, etc.
  19. set_natural_width(dom_node().get_attribute_value(HTML::AttributeNames::width).to_number<int>().value_or(300));
  20. set_natural_height(dom_node().get_attribute_value(HTML::AttributeNames::height).to_number<int>().value_or(150));
  21. }
  22. void FrameBox::did_set_content_size()
  23. {
  24. ReplacedBox::did_set_content_size();
  25. if (dom_node().content_navigable())
  26. dom_node().content_navigable()->set_size(paintable_box()->content_size());
  27. }
  28. JS::GCPtr<Painting::Paintable> FrameBox::create_paintable() const
  29. {
  30. return Painting::NestedBrowsingContextPaintable::create(*this);
  31. }
  32. }