CSSImportRule.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (c) 2021, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/URL.h>
  7. #include <LibWeb/CSS/CSSImportRule.h>
  8. #include <LibWeb/CSS/CSSStyleSheet.h>
  9. namespace Web::CSS {
  10. CSSImportRule::CSSImportRule(AK::URL url)
  11. : m_url(move(url))
  12. {
  13. }
  14. CSSImportRule::~CSSImportRule()
  15. {
  16. }
  17. // https://www.w3.org/TR/cssom/#serialize-a-css-rule
  18. String CSSImportRule::serialized() const
  19. {
  20. StringBuilder builder;
  21. // The result of concatenating the following:
  22. // 1. The string "@import" followed by a single SPACE (U+0020).
  23. builder.append("@import "sv);
  24. // 2. The result of performing serialize a URL on the rule’s location.
  25. // FIXME: Look into the correctness of this serialization
  26. builder.append("url("sv);
  27. builder.append(m_url.to_string());
  28. builder.append(')');
  29. // FIXME: 3. If the rule’s associated media list is not empty, a single SPACE (U+0020) followed by the result of performing serialize a media query list on the media list.
  30. // 4. The string ";", i.e., SEMICOLON (U+003B).
  31. builder.append(';');
  32. return builder.to_string();
  33. }
  34. }