HTMLObjectElement.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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/FormAssociatedElement.h>
  10. #include <LibWeb/HTML/HTMLElement.h>
  11. #include <LibWeb/HTML/NavigableContainer.h>
  12. #include <LibWeb/Layout/ImageProvider.h>
  13. #include <LibWeb/Loader/ImageLoader.h>
  14. namespace Web::HTML {
  15. class HTMLObjectElement final
  16. : public NavigableContainer
  17. , public FormAssociatedElement
  18. , public ResourceClient
  19. , public Layout::ImageProvider {
  20. WEB_PLATFORM_OBJECT(HTMLObjectElement, NavigableContainer)
  21. FORM_ASSOCIATED_ELEMENT(NavigableContainer, HTMLObjectElement)
  22. enum class Representation {
  23. Unknown,
  24. Image,
  25. NestedBrowsingContext,
  26. Children,
  27. };
  28. public:
  29. virtual ~HTMLObjectElement() override;
  30. virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override;
  31. DeprecatedString data() const;
  32. void set_data(DeprecatedString const& data) { MUST(set_attribute(HTML::AttributeNames::data, data)); }
  33. DeprecatedString type() const { return attribute(HTML::AttributeNames::type); }
  34. // ^FormAssociatedElement
  35. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  36. virtual bool is_listed() const override { return true; }
  37. private:
  38. HTMLObjectElement(DOM::Document&, DOM::QualifiedName);
  39. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  40. virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
  41. bool has_ancestor_media_element_or_object_element_not_showing_fallback_content() const;
  42. void queue_element_task_to_run_object_representation_steps();
  43. void run_object_representation_handler_steps(Optional<DeprecatedString> resource_type);
  44. void run_object_representation_completed_steps(Representation);
  45. void run_object_representation_fallback_steps();
  46. void convert_resource_to_image();
  47. void update_layout_and_child_objects(Representation);
  48. // ^ResourceClient
  49. virtual void resource_did_load() override;
  50. virtual void resource_did_fail() override;
  51. // ^DOM::Element
  52. virtual i32 default_tab_index_value() const override;
  53. // ^Layout::ImageProvider
  54. virtual RefPtr<Gfx::Bitmap const> current_image_bitmap() const override;
  55. virtual void set_visible_in_viewport(bool) override;
  56. Representation m_representation { Representation::Unknown };
  57. Optional<ImageLoader> m_image_loader;
  58. };
  59. }