decorated_text.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // Copyright 2016 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef UI_GFX_DECORATED_TEXT_H_
  5. #define UI_GFX_DECORATED_TEXT_H_
  6. #include <string>
  7. #include <vector>
  8. #include "ui/gfx/font.h"
  9. #include "ui/gfx/gfx_export.h"
  10. #include "ui/gfx/range/range.h"
  11. namespace gfx {
  12. // Encapsulates styling information for some given text.
  13. struct GFX_EXPORT DecoratedText {
  14. // Describes the various text decoration attributes applicable to a given
  15. // range of text.
  16. struct GFX_EXPORT RangedAttribute {
  17. // Disallow default construction of Font, since that's slow.
  18. RangedAttribute() = delete;
  19. RangedAttribute(const Range& range, const Font& font);
  20. // The range in |text|, this RangedAttribute corresponds to. Should not be
  21. // reversed and should lie within the bounds of |text|.
  22. Range range;
  23. Font font;
  24. bool strike;
  25. };
  26. DecoratedText();
  27. ~DecoratedText();
  28. std::u16string text;
  29. // Vector of RangedAttribute describing styling of non-overlapping ranges
  30. // in |text|.
  31. std::vector<RangedAttribute> attributes;
  32. };
  33. } // namespace gfx
  34. #endif // UI_GFX_DECORATED_TEXT_H_