#include "ui/views/controls/styled_label.h"
#include <stddef.h>
#include <algorithm>
#include <limits>
#include <optional>
#include <utility>
#include "base/i18n/rtl.h"
#include "base/memory/raw_ptr.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "third_party/abseil-cpp/absl/types/variant.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/color/color_id.h"
#include "ui/color/color_provider.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/text_constants.h"
#include "ui/gfx/text_elider.h"
#include "ui/gfx/text_utils.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/link.h"
#include "ui/views/controls/link_fragment.h"
#include "ui/views/style/typography.h"
#include "ui/views/style/typography_provider.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/view_utils.h"
namespace views {
DEFINE_UI_CLASS_PROPERTY_KEY(…)
StyledLabel::RangeStyleInfo::RangeStyleInfo() = default;
StyledLabel::RangeStyleInfo::RangeStyleInfo(const RangeStyleInfo&) = default;
StyledLabel::RangeStyleInfo& StyledLabel::RangeStyleInfo::operator=(
const RangeStyleInfo&) = default;
StyledLabel::RangeStyleInfo::~RangeStyleInfo() = default;
StyledLabel::RangeStyleInfo StyledLabel::RangeStyleInfo::CreateForLink(
base::RepeatingClosure callback) { … }
StyledLabel::RangeStyleInfo StyledLabel::RangeStyleInfo::CreateForLink(
Link::ClickedCallback callback) { … }
StyledLabel::LayoutSizeInfo::LayoutSizeInfo(int max_valid_width)
: … { … }
StyledLabel::LayoutSizeInfo::LayoutSizeInfo(const LayoutSizeInfo&) = default;
StyledLabel::LayoutSizeInfo& StyledLabel::LayoutSizeInfo::operator=(
const LayoutSizeInfo&) = default;
StyledLabel::LayoutSizeInfo::~LayoutSizeInfo() = default;
bool StyledLabel::StyleRange::operator<(
const StyledLabel::StyleRange& other) const { … }
struct StyledLabel::LayoutViews { … };
StyledLabel::StyledLabel() { … }
StyledLabel::~StyledLabel() = default;
const std::u16string& StyledLabel::GetText() const { … }
void StyledLabel::SetText(std::u16string text) { … }
gfx::FontList StyledLabel::GetFontList(const RangeStyleInfo& style_info) const { … }
void StyledLabel::AddStyleRange(const gfx::Range& range,
const RangeStyleInfo& style_info) { … }
void StyledLabel::AddCustomView(std::unique_ptr<View> custom_view) { … }
int StyledLabel::GetTextContext() const { … }
void StyledLabel::SetTextContext(int text_context) { … }
int StyledLabel::GetDefaultTextStyle() const { … }
void StyledLabel::SetDefaultTextStyle(int text_style) { … }
std::optional<ui::ColorId> StyledLabel::GetDefaultEnabledColorId() const { … }
void StyledLabel::SetDefaultEnabledColorId(
std::optional<ui::ColorId> enabled_color_id) { … }
int StyledLabel::GetLineHeight() const { … }
void StyledLabel::SetLineHeight(int line_height) { … }
StyledLabel::ColorVariant StyledLabel::GetDisplayedOnBackgroundColor() const { … }
void StyledLabel::SetDisplayedOnBackgroundColor(ColorVariant color) { … }
bool StyledLabel::GetAutoColorReadabilityEnabled() const { … }
void StyledLabel::SetAutoColorReadabilityEnabled(bool auto_color_readability) { … }
bool StyledLabel::GetSubpixelRenderingEnabled() const { … }
void StyledLabel::SetSubpixelRenderingEnabled(bool subpixel_rendering_enabled) { … }
const StyledLabel::LayoutSizeInfo& StyledLabel::GetLayoutSizeInfoForWidth(
int w) const { … }
void StyledLabel::SizeToFit(int fixed_width) { … }
base::CallbackListSubscription StyledLabel::AddTextChangedCallback(
views::PropertyChangedCallback callback) { … }
gfx::Size StyledLabel::GetMinimumSize() const { … }
gfx::Size StyledLabel::CalculatePreferredSize(
const SizeBounds& available_size) const { … }
void StyledLabel::OnBoundsChanged(const gfx::Rect& previous_bounds) { … }
void StyledLabel::Layout(PassKey) { … }
void StyledLabel::PreferredSizeChanged() { … }
void StyledLabel::SetHorizontalAlignment(gfx::HorizontalAlignment alignment) { … }
void StyledLabel::ClearStyleRanges() { … }
void StyledLabel::ClickFirstLinkForTesting() { … }
views::Link* StyledLabel::GetFirstLinkForTesting() { … }
int StyledLabel::StartX(int excess_space) const { … }
void StyledLabel::CalculateLayout(int width) const { … }
std::unique_ptr<Label> StyledLabel::CreateLabel(
const std::u16string& text,
const RangeStyleInfo& style_info,
const gfx::Range& range,
LinkFragment** previous_link_fragment) const { … }
void StyledLabel::UpdateLabelBackgroundColor() { … }
void StyledLabel::RemoveOrDeleteAllChildViews() { … }
void StyledLabel::RecreateChildViews() { … }
BEGIN_METADATA(…)
}