OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef ShapingLineBreaker_h | 5 #ifndef ShapingLineBreaker_h |
6 #define ShapingLineBreaker_h | 6 #define ShapingLineBreaker_h |
7 | 7 |
8 #include "platform/LayoutUnit.h" | 8 #include "platform/LayoutUnit.h" |
9 #include "platform/PlatformExport.h" | 9 #include "platform/PlatformExport.h" |
10 #include "platform/wtf/text/AtomicString.h" | 10 #include "platform/wtf/text/AtomicString.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 class Font; | 14 class Font; |
15 class ShapeResult; | 15 class ShapeResult; |
16 class HarfBuzzShaper; | 16 class HarfBuzzShaper; |
| 17 class LazyLineBreakIterator; |
17 enum class LineBreakType; | 18 enum class LineBreakType; |
18 | 19 |
19 // Shapes a line of text by finding the ideal break position as indicated by the | 20 // Shapes a line of text by finding the ideal break position as indicated by the |
20 // available space and the shape results for the entire paragraph. Once an ideal | 21 // available space and the shape results for the entire paragraph. Once an ideal |
21 // break position has been found the text is scanned backwards until a valid and | 22 // break position has been found the text is scanned backwards until a valid and |
22 // and appropriate break opportunity is identified. Unless the break opportunity | 23 // and appropriate break opportunity is identified. Unless the break opportunity |
23 // is at a safe-to-break boundary (as identified by HarfBuzz) the beginning and/ | 24 // is at a safe-to-break boundary (as identified by HarfBuzz) the beginning and/ |
24 // or end of the line is reshaped to account for differences caused by breaking. | 25 // or end of the line is reshaped to account for differences caused by breaking. |
25 // | 26 // |
26 // This allows for significantly faster and more efficient line breaking by only | 27 // This allows for significantly faster and more efficient line breaking by only |
27 // reshaping when absolutely necessarily and by only evaluating likely candidate | 28 // reshaping when absolutely necessarily and by only evaluating likely candidate |
28 // break opportunities instead of measuring and evaluating all possible options. | 29 // break opportunities instead of measuring and evaluating all possible options. |
29 class PLATFORM_EXPORT ShapingLineBreaker final { | 30 class PLATFORM_EXPORT ShapingLineBreaker final { |
| 31 STACK_ALLOCATED(); |
| 32 |
30 public: | 33 public: |
31 ShapingLineBreaker(const HarfBuzzShaper*, | 34 ShapingLineBreaker(const HarfBuzzShaper*, |
32 const Font*, | 35 const Font*, |
33 const ShapeResult*, | 36 const ShapeResult*, |
34 const AtomicString, | 37 const LazyLineBreakIterator*); |
35 LineBreakType); | |
36 ~ShapingLineBreaker() {} | 38 ~ShapingLineBreaker() {} |
37 | 39 |
38 // Shapes a line of text by finding a valid and appropriate break opportunity | 40 // Shapes a line of text by finding a valid and appropriate break opportunity |
39 // based on the shaping results for the entire paragraph. | 41 // based on the shaping results for the entire paragraph. |
40 // The output parameter breakOffset indicates the resulting break offset. | 42 // The output parameter breakOffset indicates the resulting break offset. |
41 PassRefPtr<ShapeResult> ShapeLine(unsigned start_offset, | 43 PassRefPtr<ShapeResult> ShapeLine(unsigned start_offset, |
42 LayoutUnit available_space, | 44 LayoutUnit available_space, |
43 unsigned* break_offset); | 45 unsigned* break_offset); |
44 | 46 |
45 private: | 47 private: |
46 | 48 |
47 const HarfBuzzShaper* shaper_; | 49 const HarfBuzzShaper* shaper_; |
48 const Font* font_; | 50 const Font* font_; |
49 const ShapeResult* result_; | 51 const ShapeResult* result_; |
50 const AtomicString locale_; | 52 const LazyLineBreakIterator* break_iterator_; |
51 LineBreakType break_type_; | |
52 String text_; | 53 String text_; |
53 }; | 54 }; |
54 | 55 |
55 } // namespace blink | 56 } // namespace blink |
56 | 57 |
57 #endif // ShapingLineBreaker_h | 58 #endif // ShapingLineBreaker_h |
OLD | NEW |