PositionStyleValue.cpp 973 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2021, Tobias Christiansen <tobyase@serenityos.org>
  4. * Copyright (c) 2021-2023, Sam Atkins <atkinssj@serenityos.org>
  5. * Copyright (c) 2022-2023, MacDue <macdue@dueutil.tech>
  6. *
  7. * SPDX-License-Identifier: BSD-2-Clause
  8. */
  9. #include "PositionStyleValue.h"
  10. namespace Web::CSS {
  11. ErrorOr<String> PositionStyleValue::to_string() const
  12. {
  13. auto to_string = [](PositionEdge edge) {
  14. switch (edge) {
  15. case PositionEdge::Left:
  16. return "left";
  17. case PositionEdge::Right:
  18. return "right";
  19. case PositionEdge::Top:
  20. return "top";
  21. case PositionEdge::Bottom:
  22. return "bottom";
  23. }
  24. VERIFY_NOT_REACHED();
  25. };
  26. return String::formatted("{} {} {} {}", to_string(m_properties.edge_x), TRY(m_properties.offset_x.to_string()), to_string(m_properties.edge_y), TRY(m_properties.offset_y.to_string()));
  27. }
  28. }