Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/ShapeResultSpacing.h

Issue 2924263003: [LayoutNG] Initial letter-spacing and word-spacing support (Closed)
Patch Set: Cleanup Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 ShapeResultSpacing_h 5 #ifndef ShapeResultSpacing_h
6 #define ShapeResultSpacing_h 6 #define ShapeResultSpacing_h
7 7
8 #include "platform/PlatformExport.h" 8 #include "platform/PlatformExport.h"
9 #include "platform/text/Character.h" 9 #include "platform/text/Character.h"
10 #include "platform/wtf/Allocator.h"
10 11
11 namespace blink { 12 namespace blink {
12 13
13 class FontDescription; 14 class FontDescription;
14 class TextRun;
15 15
16 // A context object to apply letter-spacing, word-spacing, and justification to
17 // ShapeResult.
18 template <typename TextContainerType>
16 class PLATFORM_EXPORT ShapeResultSpacing final { 19 class PLATFORM_EXPORT ShapeResultSpacing final {
20 STACK_ALLOCATED();
21
17 public: 22 public:
18 ShapeResultSpacing(const TextRun&, const FontDescription&); 23 ShapeResultSpacing(const TextContainerType&);
19 24
20 float LetterSpacing() const { return letter_spacing_; } 25 float LetterSpacing() const { return letter_spacing_; }
21 bool HasSpacing() const { return has_spacing_; } 26 bool HasSpacing() const { return has_spacing_; }
22 bool IsVerticalOffset() const { return is_vertical_offset_; } 27 bool IsVerticalOffset() const { return is_vertical_offset_; }
23 28
24 float ComputeSpacing(const TextRun&, size_t, float& offset); 29 // Set letter-spacing and word-spacing.
30 bool SetSpacing(const FontDescription&);
31
32 // Set letter-spacing, word-spacing, and justification.
33 // Available only for TextRun.
34 void SetSpacingAndExpansion(const FontDescription&);
35
36 // Compute the sum of all spacings for the specified index.
37 // For justification, this function must be called incrementally since it
38 // keeps states and counts consumed justification opportunities.
39 float ComputeSpacing(const TextContainerType&, size_t, float& offset);
25 40
26 private: 41 private:
27 bool HasExpansion() const { return expansion_opportunity_count_; } 42 bool HasExpansion() const { return expansion_opportunity_count_; }
28 bool IsAfterExpansion() const { return is_after_expansion_; } 43 bool IsAfterExpansion() const { return is_after_expansion_; }
29 bool IsFirstRun(const TextRun&) const; 44 bool IsFirstRun(const TextContainerType&) const;
45
46 void ComputeExpansion(bool allows_leading_expansion,
47 bool allows_trailing_expansion,
48 TextJustify);
30 49
31 float NextExpansion(); 50 float NextExpansion();
32 51
33 const TextRun& text_run_; 52 const TextContainerType& text_;
34 float letter_spacing_; 53 float letter_spacing_;
35 float word_spacing_; 54 float word_spacing_;
36 float expansion_; 55 float expansion_;
37 float expansion_per_opportunity_; 56 float expansion_per_opportunity_;
38 unsigned expansion_opportunity_count_; 57 unsigned expansion_opportunity_count_;
39 TextJustify text_justify_; 58 TextJustify text_justify_;
40 bool has_spacing_; 59 bool has_spacing_;
41 bool normalize_space_; 60 bool normalize_space_;
42 bool allow_tabs_; 61 bool allow_tabs_;
43 bool is_after_expansion_; 62 bool is_after_expansion_;
44 bool is_vertical_offset_; 63 bool is_vertical_offset_;
45 }; 64 };
46 65
47 } // namespace blink 66 } // namespace blink
48 67
49 #endif 68 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698