// Copyright 2018 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifdef UNSAFE_BUFFERS_BUILD // TODO(crbug.com/351564777): Remove this and convert code to safer constructs. #pragma allow_unsafe_buffers #endif #ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_SHAPING_SHAPE_RESULT_VIEW_H_ #define THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_SHAPING_SHAPE_RESULT_VIEW_H_ #include "base/containers/span.h" #include "third_party/blink/renderer/platform/fonts/shaping/glyph_data.h" #include "third_party/blink/renderer/platform/fonts/shaping/shape_result.h" #include "third_party/blink/renderer/platform/fonts/simple_font_data.h" #include "third_party/blink/renderer/platform/geometry/layout_unit.h" #include "third_party/blink/renderer/platform/heap/collection_support/heap_hash_set.h" #include "third_party/blink/renderer/platform/platform_export.h" #include "third_party/blink/renderer/platform/text/text_direction.h" #include "third_party/blink/renderer/platform/wtf/forward.h" #include "third_party/blink/renderer/platform/wtf/vector.h" namespace blink { class ShapeResult; // Class representing a read-only composite of views into one or more existing // shape results. // Implemented as a list of ref counted RunInfo instances and a start/end // offset for each, represented using the internal RunInfoPart struct. // This allows lines to be reference sections of the overall paragraph shape // results without the memory or computational overhead of a copy. // // The example below shows the shape result and the individual lines as // ShapeResultView instances pointing to the original paragraph results for // the string "Pack my box with five dozen liquor jugs.": // ╔═════════════════════════════════════════════════════╗ // ║ Paragraph with single run, no re-shaping for lines. ║ // ╟─────────────────────────────────────────────────────╢ // ║ runs_ ╭───────────────────────────────────────────╮ ║ // ║ 1: │ Pack my box with five dozen liquor jugs. │ ║ // ║ ╰───────────────────────────────────────────╯ ║ // ║ lines ╭───────────────────────────────────────────╮ ║ // ║ 1: │ Pack my box with -> view, run 1: 0-16 │ ║ // ║ 2: │ five dozen liquor -> view, run 1: 17-34 │ ║ // ║ 3: │ jugs. -> view, run 1: 35-40 │ ║ // ║ ╰───────────────────────────────────────────╯ ║ // ╚═════════════════════════════════════════════════════╝ // // In cases where a portion of the line needs re-shaping the new results are // added as separate runs at the beginning and/or end of the runs_ vector with a // reference to zero or more sub-runs in the middle representing the original // content that could be reused. // // In the example below the end of the first line "Jack!" needs to be re-shaped: // ╔═════════════════════════════════════════════════════╗ // ║ Paragraph with single run, requiring re-shape. ║ // ╟─────────────────────────────────────────────────────╢ // ║ runs_ ╭───────────────────────────────────────────╮ ║ // ║ 1: │ "Now fax quiz Jack!" my brave ghost pled. │ ║ // ║ ╰───────────────────────────────────────────╯ ║ // ║ lines ╭───────────────────────────────────────────╮ ║ // ║ 1: │ "Now fax quiz -> view, run 1: 0-14 │ ║ // ║ 1: │ Jack! -> new result/run │ ║ // ║ 2: │ my brave ghost -> view, run 1: 21-35 │ ║ // ║ 3: │ pled. -> view, run 1: 41-36 │ ║ // ║ ╰───────────────────────────────────────────╯ ║ // ╚═════════════════════════════════════════════════════╝ // // In this case the beginning of the first line would be represented as a part // referencing a range in the original ShapeResult while the last word // would be a separate result owned by the ShapeResultView instance. The second // and third lines would again be represented as parts. class PLATFORM_EXPORT ShapeResultView final : public GarbageCollected<ShapeResultView> { … }; } // namespace blink WTF_ALLOW_CLEAR_UNUSED_SLOTS_WITH_MEM_FUNCTIONS(…) #endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_FONTS_SHAPING_SHAPE_RESULT_VIEW_H_