HTMLObjectElement.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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(DeprecatedFlyString const& name, DeprecatedString const& value) override;
  29. DeprecatedString data() const;
  30. void set_data(DeprecatedString const& data) { MUST(set_attribute(HTML::AttributeNames::data, data)); }
  31. DeprecatedString 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 JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  38. virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
  39. bool has_ancestor_media_element_or_object_element_not_showing_fallback_content() const;
  40. void queue_element_task_to_run_object_representation_steps();
  41. void run_object_representation_handler_steps(Optional<DeprecatedString> resource_type);
  42. void run_object_representation_completed_steps(Representation);
  43. void run_object_representation_fallback_steps();
  44. void convert_resource_to_image();
  45. void update_layout_and_child_objects(Representation);
  46. // ^ResourceClient
  47. virtual void resource_did_load() override;
  48. virtual void resource_did_fail() override;
  49. // ^DOM::Element
  50. virtual i32 default_tab_index_value() const override;
  51. Representation m_representation { Representation::Unknown };
  52. Optional<ImageLoader> m_image_loader;
  53. };
  54. }