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

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

Issue 2740083002: Add support for shaper-driven line breaking to HarfBuzzShaper (Closed)
Patch Set: Try to fix test failures Created 3 years, 8 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 13 matching lines...) Expand all
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #ifndef ShapeResult_h 31 #ifndef ShapeResult_h
32 #define ShapeResult_h 32 #define ShapeResult_h
33 33
34 #include <memory>
35 #include "platform/LayoutUnit.h"
34 #include "platform/PlatformExport.h" 36 #include "platform/PlatformExport.h"
35 #include "platform/geometry/FloatRect.h" 37 #include "platform/geometry/FloatRect.h"
36 #include "platform/text/TextDirection.h" 38 #include "platform/text/TextDirection.h"
37 #include "wtf/HashSet.h" 39 #include "wtf/HashSet.h"
38 #include "wtf/Noncopyable.h" 40 #include "wtf/Noncopyable.h"
39 #include "wtf/RefCounted.h" 41 #include "wtf/RefCounted.h"
40 #include "wtf/Vector.h" 42 #include "wtf/Vector.h"
41 #include <memory>
42 43
43 struct hb_buffer_t; 44 struct hb_buffer_t;
44 45
45 namespace blink { 46 namespace blink {
46 47
47 class Font; 48 class Font;
48 class ShapeResultSpacing; 49 class ShapeResultSpacing;
49 class SimpleFontData; 50 class SimpleFontData;
50 class TextRun; 51 class TextRun;
51 52
52 class PLATFORM_EXPORT ShapeResult : public RefCounted<ShapeResult> { 53 class PLATFORM_EXPORT ShapeResult : public RefCounted<ShapeResult> {
53 public: 54 public:
54 static PassRefPtr<ShapeResult> create(const Font* font, 55 static PassRefPtr<ShapeResult> create(const Font* font,
55 unsigned numCharacters, 56 unsigned numCharacters,
56 TextDirection direction) { 57 TextDirection direction) {
57 return adoptRef(new ShapeResult(font, numCharacters, direction)); 58 return adoptRef(new ShapeResult(font, numCharacters, direction));
58 } 59 }
59 static PassRefPtr<ShapeResult> createForTabulationCharacters( 60 static PassRefPtr<ShapeResult> createForTabulationCharacters(
60 const Font*, 61 const Font*,
61 const TextRun&, 62 const TextRun&,
62 float positionOffset, 63 float positionOffset,
63 unsigned count); 64 unsigned count);
64 ~ShapeResult(); 65 ~ShapeResult();
65 66
66 float width() const { return m_width; } 67 float width() const { return m_width; }
68 LayoutUnit snappedWidth() const { return LayoutUnit::fromFloatCeil(m_width); }
67 const FloatRect& bounds() const { return m_glyphBoundingBox; } 69 const FloatRect& bounds() const { return m_glyphBoundingBox; }
68 unsigned numCharacters() const { return m_numCharacters; } 70 unsigned numCharacters() const { return m_numCharacters; }
69 void fallbackFonts(HashSet<const SimpleFontData*>*) const; 71 void fallbackFonts(HashSet<const SimpleFontData*>*) const;
70 bool rtl() const { 72 TextDirection direction() const {
71 return static_cast<TextDirection>(m_direction) == TextDirection::kRtl; 73 return static_cast<TextDirection>(m_direction);
72 } 74 }
75 bool rtl() const { return direction() == TextDirection::kRtl; }
73 bool hasVerticalOffsets() const { return m_hasVerticalOffsets; } 76 bool hasVerticalOffsets() const { return m_hasVerticalOffsets; }
74 77
75 // For memory reporting. 78 // For memory reporting.
76 size_t byteSize() const; 79 size_t byteSize() const;
77 80
78 unsigned offsetForPosition(float targetX, bool includePartialGlyphs) const; 81 unsigned offsetForPosition(float targetX, bool includePartialGlyphs) const;
79 float positionForOffset(unsigned offset) const; 82 float positionForOffset(unsigned offset) const;
83 LayoutUnit snappedStartPositionForOffset(unsigned offset) const {
84 return LayoutUnit::fromFloatFloor(positionForOffset(offset));
85 }
86 LayoutUnit snappedEndPositionForOffset(unsigned offset) const {
87 return LayoutUnit::fromFloatCeil(positionForOffset(offset));
88 }
80 89
81 PassRefPtr<ShapeResult> applySpacingToCopy(ShapeResultSpacing&, 90 PassRefPtr<ShapeResult> applySpacingToCopy(ShapeResultSpacing&,
82 const TextRun&) const; 91 const TextRun&) const;
83 92
93 void copyRange(unsigned start, unsigned end, ShapeResult*) const;
94
84 protected: 95 protected:
85 struct RunInfo; 96 struct RunInfo;
86 97
87 ShapeResult(const Font*, unsigned numCharacters, TextDirection); 98 ShapeResult(const Font*, unsigned numCharacters, TextDirection);
88 ShapeResult(const ShapeResult&); 99 ShapeResult(const ShapeResult&);
89 100
90 static PassRefPtr<ShapeResult> create(const ShapeResult& other) { 101 static PassRefPtr<ShapeResult> create(const ShapeResult& other) {
91 return adoptRef(new ShapeResult(other)); 102 return adoptRef(new ShapeResult(other));
92 } 103 }
93 104
(...skipping 19 matching lines...) Expand all
113 // Tracks whether any runs contain glyphs with a y-offset != 0. 124 // Tracks whether any runs contain glyphs with a y-offset != 0.
114 unsigned m_hasVerticalOffsets : 1; 125 unsigned m_hasVerticalOffsets : 1;
115 126
116 friend class HarfBuzzShaper; 127 friend class HarfBuzzShaper;
117 friend class ShapeResultBuffer; 128 friend class ShapeResultBuffer;
118 }; 129 };
119 130
120 } // namespace blink 131 } // namespace blink
121 132
122 #endif // ShapeResult_h 133 #endif // ShapeResult_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698