// Copyright 2020 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_LAYOUT_TABLE_TABLE_BORDERS_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_TABLE_TABLE_BORDERS_H_ #include <optional> #include "base/check_op.h" #include "base/dcheck_is_on.h" #include "base/memory/scoped_refptr.h" #include "base/notreached.h" #include "third_party/blink/renderer/core/style/computed_style.h" #include "third_party/blink/renderer/core/style/computed_style_constants.h" #include "third_party/blink/renderer/platform/geometry/layout_unit.h" #include "third_party/blink/renderer/platform/text/text_direction.h" #include "third_party/blink/renderer/platform/text/writing_mode.h" #include "third_party/blink/renderer/platform/wtf/vector.h" namespace blink { class BlockNode; class ComputedStyle; struct BoxStrut; // When table has collapsed borders, computing borders for table parts is // complex, and costly. // TableBorders precomputes collapsed borders. It exposes the API for // border access. If borders are not collapsed, the API returns regular // borders. // // TableBorders methods often take rowspan/colspan arguments. // Rowspan must never be taller than the section. // Colspan must never be wider than the table. // To enforce this, TableBorders keeps track of section dimensions, // and table's last column. // // Collapsed borders are stored as edges. // Edges are stored in a 1D array. The array does not grow if borders are // not set. // Each edge represents a cell border. // Mapping between edges and cells is best understood like this: // - each cell stores only two edges, left edge, and a top edge. // - cell's right edge is the left edge of the next cell. // - cell's bottom edge is the top edge of the cell in the next row. // // To store all last row/col edges, an extra imaginary cell is used. // // A grid with R rows and C columns has |2 * (R+1) * (C+1)| edges. // Example; R=1, C=3, 2*(1+1)*(3+1) = 16 edges. // Edges 7, 9, 11, 13, 14, 15 are unused. // // 1 3 5 7 // ------------------ <= edges for 3 cols X 1 row // |0 |2 |4 |6 // | | | | // ------------------ // | 8 | 10| 12 | 14 // | | | | // |9 |11 |13 |15 class TableBorders : public GarbageCollected<TableBorders> { … }; } // namespace blink WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(…) WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(…) #endif // THIRD_PARTY_BLINK_RENDERER_CORE_LAYOUT_TABLE_TABLE_BORDERS_H_