1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
// 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_CSSOM_UTILS_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSSOM_UTILS_H_
#include "third_party/blink/renderer/core/style/grid_area.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
namespace blink {
class CSSValue;
class CSSValueList;
namespace cssvalue {
class CSSGridTemplateAreasValue;
}
class CSSOMUtils {
STATIC_ONLY(CSSOMUtils);
public:
static bool IncludeDependentGridLineEndValue(const CSSValue* line_start,
const CSSValue* line_end);
static bool IsAutoValue(const CSSValue* value);
static bool IsNoneValue(const CSSValue* value);
static bool IsEmptyValueList(const CSSValue* value);
static bool HasGridRepeatValue(const CSSValueList* value_list);
static bool IsMasonryColumnDirectionValue(
const CSSValue* masonry_direction_values);
// Returns the name of a grid area based on the position (`row`, `column`).
// e.g. with the following grid definition:
// grid-template-areas: "a a a"
// "b b b";
// grid-template-rows: [header-top] auto [header-bottom main-top] 1fr
// [main-bottom]; grid-template-columns: auto 1fr auto;
//
// NamedGridAreaTextForPosition(grid_area_map, 0, 0) will return "a"
// NamedGridAreaTextForPosition(grid_area_map, 1, 0) will return "b"
//
// Unlike the CSS indices, these are 0-based indices.
// Out-of-range or not-found indices return ".", per spec.
static String NamedGridAreaTextForPosition(
const NamedGridAreaMap& grid_area_map,
wtf_size_t row,
wtf_size_t column);
// Helper to serialize a single row or column of grid area names into a
// space-separated string. If `is_row` is true, serialize a row (iterate
// columns for a fixed row). If `is_row` is false, serialize a column (iterate
// rows for a fixed column).
static String SerializeGridAreaText(
const cssvalue::CSSGridTemplateAreasValue* template_areas,
wtf_size_t fixed_index,
bool is_row);
// Returns a `CSSValueList` containing the computed value for the
// `grid-template` shorthand, based on provided `grid-template-rows`,
// `grid-template-columns`, and `grid-template-areas`.
static CSSValueList* ComputedValueForGridTemplateShorthand(
const CSSValue* template_row_values,
const CSSValue* template_column_values,
const CSSValue* template_area_values);
// Returns a `CSSValueList` containing the computed value for
// the `masonry` shorthand, based on provided `masonry-template-tracks`,
// `grid-template-areas`, `masonry-direction`, and `masonry-fill`.
static CSSValueList* ComputedValueForMasonryShorthand(
const CSSValue* masonry_template_tracks_values,
const CSSValue* template_area_values,
const CSSValue* masonry_direction_values,
const CSSValue* masonry_fill_values);
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_CSSOM_UTILS_H_
|