HTMLObjectElement.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. WEB_PLATFORM_OBJECT(HTMLObjectElement, BrowsingContextContainer)
  19. FORM_ASSOCIATED_ELEMENT(BrowsingContextContainer, HTMLObjectElement)
  20. enum class Representation {
  21. Unknown,
  22. Image,
  23. NestedBrowsingContext,
  24. Children,
  25. };
  26. public:
  27. virtual ~HTMLObjectElement() override;
  28. virtual void parse_attribute(FlyString const& name, String const& value) override;
  29. String data() const;
  30. void set_data(String const& data) { set_attribute(HTML::AttributeNames::data, data); }
  31. String type() const { return attribute(HTML::AttributeNames::type); }
  32. // ^FormAssociatedElement
  33. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  34. virtual bool is_listed() const override { return true; }
  35. private:
  36. HTMLObjectElement(DOM::Document&, DOM::QualifiedName);
  37. virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
  38. bool has_ancestor_media_element_or_object_element_not_showing_fallback_content() const;
  39. void queue_element_task_to_run_object_representation_steps();
  40. void run_object_representation_handler_steps(Optional<String> resource_type);
  41. void run_object_representation_completed_steps(Representation);
  42. void run_object_representation_fallback_steps();
  43. void convert_resource_to_image();
  44. void update_layout_and_child_objects(Representation);
  45. // ^ResourceClient
  46. virtual void resource_did_load() override;
  47. virtual void resource_did_fail() override;
  48. Representation m_representation { Representation::Unknown };
  49. Optional<ImageLoader> m_image_loader;
  50. };
  51. }
  52. WRAPPER_HACK(HTMLObjectElement, Web::HTML)