HTMLObjectElement.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibCore/Forward.h>
  8. #include <LibGfx/Forward.h>
  9. #include <LibWeb/HTML/BrowsingContextContainer.h>
  10. #include <LibWeb/HTML/FormAssociatedElement.h>
  11. #include <LibWeb/HTML/HTMLElement.h>
  12. #include <LibWeb/Loader/ImageLoader.h>
  13. namespace Web::HTML {
  14. class HTMLObjectElement final
  15. : public BrowsingContextContainer
  16. , public FormAssociatedElement
  17. , public ResourceClient {
  18. FORM_ASSOCIATED_ELEMENT(BrowsingContextContainer, HTMLObjectElement)
  19. enum class Representation {
  20. Unknown,
  21. Image,
  22. NestedBrowsingContext,
  23. Children,
  24. };
  25. public:
  26. using WrapperType = Bindings::HTMLObjectElementWrapper;
  27. HTMLObjectElement(DOM::Document&, DOM::QualifiedName);
  28. virtual ~HTMLObjectElement() override;
  29. virtual void parse_attribute(const FlyString& name, const String& value) override;
  30. String data() const;
  31. void set_data(String const& data) { set_attribute(HTML::AttributeNames::data, data); }
  32. String type() const { return attribute(HTML::AttributeNames::type); }
  33. // ^FormAssociatedElement
  34. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  35. virtual bool is_listed() const override { return true; }
  36. private:
  37. virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
  38. void queue_element_task_to_run_object_representation_steps();
  39. void run_object_representation_handler_steps(StringView resource_type);
  40. void run_object_representation_completed_steps();
  41. void run_object_representation_fallback_steps();
  42. void convert_resource_to_image();
  43. void update_layout_and_child_objects();
  44. // ^ResourceClient
  45. virtual void resource_did_load() override;
  46. virtual void resource_did_fail() override;
  47. Representation m_representation { Representation::Unknown };
  48. Optional<ImageLoader> m_image_loader;
  49. };
  50. }