// Copyright 2024 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_TRY_TACTIC_TRANSFORM_H_ #define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_TRY_TACTIC_TRANSFORM_H_ #include "third_party/blink/renderer/core/core_export.h" #include "third_party/blink/renderer/core/style/position_try_fallbacks.h" #include "third_party/blink/renderer/platform/text/writing_direction_mode.h" #include "third_party/blink/renderer/platform/text/writing_mode_utils.h" namespace blink { // Represents a transform via <try-tactic>. // // Considering an element at some initial position (0), there are only seven // different possible transformations represented by <try-tactic> flips: // // // 4 5 // // ┌───────────────────┐ // │. │ // 0 │ . │ 2 // │ . │ // │ . │ // │ . │ // │ . │ // │ . │ // │ . │ // 1 │ . │ 3 // │ .│ // └───────────────────┘ // // 6 7 // // // Note that the dotted line represents the start-start to end-end diagonal // that we mirror across for flip-start. // // In many cases, there are multiple ways to compose flips together to reach // a certain point. For example, first flipping block, then flipping inline // both end up at (3). A less obvious example is block-start-inline being // equivalent to just start (4). // // Although the specified order of flips within the <try-tactic> matters, any // tactic can be converted to another corresponding tactic with a *fixed* order. // This class represents the "canonical" tactic, with the following fixed // flipping order: block, inline, then start. // // The following table shows the canonical tactics (N) vs. the diagram above, // and also shows how non-canonical are transformed into canonical ones (=>N)). // // block (1) // inline (2) // block inline (3) // start (4) // block start (5) // inline start (6) // block inline start (7) // // inline block (=>3) // block start inline (=>4) // inline start block (=>4) // start inline (=>5) // start block (=>6) // inline block start (=>7) // start block inline (=>7) // start inline block (=>7) // class CORE_EXPORT TryTacticTransform { … }; } // namespace blink #endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_TRY_TACTIC_TRANSFORM_H_