HTMLParagraphElement.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * Copyright (c) 2020, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/Intrinsics.h>
  7. #include <LibWeb/HTML/HTMLParagraphElement.h>
  8. namespace Web::HTML {
  9. HTMLParagraphElement::HTMLParagraphElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  10. : HTMLElement(document, move(qualified_name))
  11. {
  12. set_prototype(&Bindings::cached_web_prototype(realm(), "HTMLParagraphElement"));
  13. }
  14. HTMLParagraphElement::~HTMLParagraphElement() = default;
  15. // https://html.spec.whatwg.org/multipage/rendering.html#tables-2
  16. void HTMLParagraphElement::apply_presentational_hints(CSS::StyleProperties& style) const
  17. {
  18. HTMLElement::apply_presentational_hints(style);
  19. for_each_attribute([&](auto& name, auto& value) {
  20. if (name.equals_ignoring_case("align"sv)) {
  21. if (value == "left"sv)
  22. style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Left));
  23. else if (value == "right"sv)
  24. style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Right));
  25. else if (value == "center"sv)
  26. style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Center));
  27. else if (value == "justify"sv)
  28. style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify));
  29. }
  30. });
  31. }
  32. }