CalculatedOr.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) 2023, Sam Atkins <atkinssj@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include "CalculatedOr.h"
  7. namespace Web::CSS {
  8. Angle AngleOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
  9. {
  10. return calculated->resolve_angle().value();
  11. }
  12. Flex FlexOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
  13. {
  14. return calculated->resolve_flex().value();
  15. }
  16. Frequency FrequencyOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
  17. {
  18. return calculated->resolve_frequency().value();
  19. }
  20. i64 IntegerOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
  21. {
  22. return calculated->resolve_integer().value();
  23. }
  24. Length LengthOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const& layout_node) const
  25. {
  26. return calculated->resolve_length(layout_node).value();
  27. }
  28. Length LengthOrCalculated::resolved(Length::ResolutionContext const& context) const
  29. {
  30. if (is_calculated())
  31. return calculated()->resolve_length(context).value();
  32. return value();
  33. }
  34. double NumberOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
  35. {
  36. return calculated->resolve_number().value();
  37. }
  38. Percentage PercentageOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
  39. {
  40. return calculated->resolve_percentage().value();
  41. }
  42. Resolution ResolutionOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
  43. {
  44. return calculated->resolve_resolution().value();
  45. }
  46. Time TimeOrCalculated::resolve_calculated(NonnullRefPtr<CalculatedStyleValue> const& calculated, Layout::Node const&) const
  47. {
  48. return calculated->resolve_time().value();
  49. }
  50. }