chromium/third_party/blink/renderer/core/css/white_space.h

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_WHITE_SPACE_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_WHITE_SPACE_H_

#include <bit>
#include <cstdint>

#include "third_party/blink/renderer/core/style/computed_style_base_constants.h"

namespace blink {

//
// This file contains definitions of the `white-space` shorthand property and
// its longhands.
// https://w3c.github.io/csswg-drafts/css-text-4/#propdef-white-space
//

//
// The `white-space-collapse` property.
// https://w3c.github.io/csswg-drafts/css-text-4/#white-space-collapsing
//
enum class WhiteSpaceCollapse : uint8_t {};

// Ensure this is in sync with `css_properties.json5`.
static constexpr int kWhiteSpaceCollapseBits =;
static constexpr uint8_t kWhiteSpaceCollapseMask =;

inline bool IsWhiteSpaceCollapseAny(WhiteSpaceCollapse value,
                                    WhiteSpaceCollapse flags) {}

// Whether to collapse or preserve all whitespaces: spaces (U+0020), tabs
// (U+0009), and segment breaks.
// https://w3c.github.io/csswg-drafts/css-text-4/#white-space
inline bool ShouldPreserveWhiteSpaces(WhiteSpaceCollapse collapse) {}
inline bool ShouldCollapseWhiteSpaces(WhiteSpaceCollapse collapse) {}
// Whether to collapse or preserve segment breaks.
// https://w3c.github.io/csswg-drafts/css-text-4/#segment-break
inline bool ShouldPreserveBreaks(WhiteSpaceCollapse collapse) {}
inline bool ShouldCollapseBreaks(WhiteSpaceCollapse collapse) {}
inline bool ShouldBreakSpaces(WhiteSpaceCollapse collapse) {}

//
// The `text-wrap-mode` property.
// https://drafts.csswg.org/css-text-4/#propdef-text-wrap-mode
//
inline constexpr unsigned kTextWrapModeBits =;

// Returns `true` if lines should wrap.
inline bool ShouldWrapLine(TextWrapMode mode) {}

//
// The `text-wrap-style` property.
// https://drafts.csswg.org/css-text-4/#propdef-text-wrap-style
//

// Returns `true` if the greedy line breaker should be used.
inline bool ShouldWrapLineGreedy(TextWrapStyle style) {}

//
// The `white-space` property.
// https://w3c.github.io/csswg-drafts/css-text-4/#propdef-white-space
//
// `EWhiteSpace` is represented by bit-flags of combinations of all possible
// longhand values. Thus `ToWhiteSpace()` may return values that are not defined
// as the `EWhiteSpace` value. `IsValidWhiteSpace()` can check if a value is one
// of pre-defined keywords.
//
constexpr uint8_t ToWhiteSpaceValue(WhiteSpaceCollapse collapse,
                                    TextWrapMode wrap) {}

enum class EWhiteSpace : uint8_t {};

static_assert;

// Convert longhands of `white-space` to `EWhiteSpace`. The return value may not
// be one of the defined enum values. Please see the comment above.
inline EWhiteSpace ToWhiteSpace(WhiteSpaceCollapse collapse,
                                TextWrapMode wrap) {}

inline bool IsValidWhiteSpace(EWhiteSpace whitespace) {}

// Convert `EWhiteSpace` to longhands.
inline WhiteSpaceCollapse ToWhiteSpaceCollapse(EWhiteSpace whitespace) {}
inline TextWrapMode ToTextWrapMode(EWhiteSpace whitespace) {}

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_WHITE_SPACE_H_