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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.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 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 28 matching lines...) Expand all
39 #include "platform/wtf/HashSet.h" 39 #include "platform/wtf/HashSet.h"
40 #include "platform/wtf/Noncopyable.h" 40 #include "platform/wtf/Noncopyable.h"
41 #include "platform/wtf/RefCounted.h" 41 #include "platform/wtf/RefCounted.h"
42 #include "platform/wtf/Vector.h" 42 #include "platform/wtf/Vector.h"
43 43
44 struct hb_buffer_t; 44 struct hb_buffer_t;
45 45
46 namespace blink { 46 namespace blink {
47 47
48 class Font; 48 class Font;
49 template <typename TextContainerType>
49 class ShapeResultSpacing; 50 class ShapeResultSpacing;
50 class SimpleFontData; 51 class SimpleFontData;
51 class TextRun; 52 class TextRun;
52 53
53 class PLATFORM_EXPORT ShapeResult : public RefCounted<ShapeResult> { 54 class PLATFORM_EXPORT ShapeResult : public RefCounted<ShapeResult> {
54 public: 55 public:
55 static PassRefPtr<ShapeResult> Create(const Font* font, 56 static PassRefPtr<ShapeResult> Create(const Font* font,
56 unsigned num_characters, 57 unsigned num_characters,
57 TextDirection direction) { 58 TextDirection direction) {
58 return AdoptRef(new ShapeResult(font, num_characters, direction)); 59 return AdoptRef(new ShapeResult(font, num_characters, direction));
(...skipping 24 matching lines...) Expand all
83 84
84 unsigned OffsetForPosition(float target_x, bool include_partial_glyphs) const; 85 unsigned OffsetForPosition(float target_x, bool include_partial_glyphs) const;
85 float PositionForOffset(unsigned offset) const; 86 float PositionForOffset(unsigned offset) const;
86 LayoutUnit SnappedStartPositionForOffset(unsigned offset) const { 87 LayoutUnit SnappedStartPositionForOffset(unsigned offset) const {
87 return LayoutUnit::FromFloatFloor(PositionForOffset(offset)); 88 return LayoutUnit::FromFloatFloor(PositionForOffset(offset));
88 } 89 }
89 LayoutUnit SnappedEndPositionForOffset(unsigned offset) const { 90 LayoutUnit SnappedEndPositionForOffset(unsigned offset) const {
90 return LayoutUnit::FromFloatCeil(PositionForOffset(offset)); 91 return LayoutUnit::FromFloatCeil(PositionForOffset(offset));
91 } 92 }
92 93
93 PassRefPtr<ShapeResult> ApplySpacingToCopy(ShapeResultSpacing&, 94 void ApplySpacing(ShapeResultSpacing<StringView>&,
95 const StringView&,
96 TextDirection);
97 PassRefPtr<ShapeResult> ApplySpacingToCopy(ShapeResultSpacing<TextRun>&,
94 const TextRun&) const; 98 const TextRun&) const;
95 99
96 void CopyRange(unsigned start, unsigned end, ShapeResult*) const; 100 void CopyRange(unsigned start, unsigned end, ShapeResult*) const;
97 101
98 protected: 102 protected:
99 struct RunInfo; 103 struct RunInfo;
100 104
101 ShapeResult(const Font*, unsigned num_characters, TextDirection); 105 ShapeResult(const Font*, unsigned num_characters, TextDirection);
102 ShapeResult(const ShapeResult&); 106 ShapeResult(const ShapeResult&);
103 107
104 static PassRefPtr<ShapeResult> Create(const ShapeResult& other) { 108 static PassRefPtr<ShapeResult> Create(const ShapeResult& other) {
105 return AdoptRef(new ShapeResult(other)); 109 return AdoptRef(new ShapeResult(other));
106 } 110 }
107 111
108 void ApplySpacing(ShapeResultSpacing&, const TextRun&); 112 template <typename TextContainerType>
113 void ApplySpacing(ShapeResultSpacing<TextContainerType>&,
114 const TextContainerType&,
115 bool is_rtl);
109 void InsertRun(std::unique_ptr<ShapeResult::RunInfo>, 116 void InsertRun(std::unique_ptr<ShapeResult::RunInfo>,
110 unsigned start_glyph, 117 unsigned start_glyph,
111 unsigned num_glyphs, 118 unsigned num_glyphs,
112 hb_buffer_t*); 119 hb_buffer_t*);
113 120
114 float width_; 121 float width_;
115 FloatRect glyph_bounding_box_; 122 FloatRect glyph_bounding_box_;
116 Vector<std::unique_ptr<RunInfo>> runs_; 123 Vector<std::unique_ptr<RunInfo>> runs_;
117 RefPtr<SimpleFontData> primary_font_; 124 RefPtr<SimpleFontData> primary_font_;
118 125
119 unsigned num_characters_; 126 unsigned num_characters_;
120 unsigned num_glyphs_ : 30; 127 unsigned num_glyphs_ : 30;
121 128
122 // Overall direction for the TextRun, dictates which order each individual 129 // Overall direction for the TextRun, dictates which order each individual
123 // sub run (represented by RunInfo structs in the m_runs vector) can have a 130 // sub run (represented by RunInfo structs in the m_runs vector) can have a
124 // different text direction. 131 // different text direction.
125 unsigned direction_ : 1; 132 unsigned direction_ : 1;
126 133
127 // Tracks whether any runs contain glyphs with a y-offset != 0. 134 // Tracks whether any runs contain glyphs with a y-offset != 0.
128 unsigned has_vertical_offsets_ : 1; 135 unsigned has_vertical_offsets_ : 1;
129 136
130 friend class HarfBuzzShaper; 137 friend class HarfBuzzShaper;
131 friend class ShapeResultBuffer; 138 friend class ShapeResultBuffer;
132 friend class ShapeResultBloberizer; 139 friend class ShapeResultBloberizer;
133 }; 140 };
134 141
135 } // namespace blink 142 } // namespace blink
136 143
137 #endif // ShapeResult_h 144 #endif // ShapeResult_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698