Index: third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.h |
diff --git a/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.h b/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.h |
index 7db9bcb48b7cbc1dc2b0b971e8baaa44cdd47ecb..aa331429b9ef084d253306975c2fd6c545e4f3cb 100644 |
--- a/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.h |
+++ b/third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.h |
@@ -31,54 +31,77 @@ |
#ifndef HarfBuzzShaper_h |
#define HarfBuzzShaper_h |
+#include <hb.h> |
+#include <unicode/uscript.h> |
+#include <memory> |
+#include "platform/fonts/shaping/RunSegmenter.h" |
#include "platform/fonts/shaping/ShapeResult.h" |
#include "platform/text/TextRun.h" |
#include "wtf/Allocator.h" |
#include "wtf/Deque.h" |
#include "wtf/Vector.h" |
-#include <hb.h> |
-#include <memory> |
-#include <unicode/uscript.h> |
namespace blink { |
class Font; |
class SimpleFontData; |
class HarfBuzzShaper; |
+struct HolesQueueItem; |
class PLATFORM_EXPORT HarfBuzzShaper final { |
public: |
- HarfBuzzShaper(const UChar*, unsigned length, TextDirection); |
- PassRefPtr<ShapeResult> shapeResult(const Font*) const; |
- ~HarfBuzzShaper() {} |
+ HarfBuzzShaper(const UChar*, unsigned length); |
+ |
+ // Shape a range, defined by the start and end parameters, of the string |
+ // supplied to the constructor. |
+ // The start and end positions should represent boundaries where a break may |
+ // occur, such as at the beginning or end of lines or at element boundaries. |
+ // If given arbitrary positions the results are not guaranteed to be correct. |
+ // May be called multiple times; font and direction may vary between calls. |
+ PassRefPtr<ShapeResult> shape(const Font*, |
+ TextDirection, |
+ unsigned start, |
+ unsigned end) const; |
- enum HolesQueueItemAction { HolesQueueNextFont, HolesQueueRange }; |
+ // Shape the entire string with a single font and direction. |
+ // Equivalent to calling the range version with a start offset of zero and an |
+ // end offset equal to the length. |
+ PassRefPtr<ShapeResult> shape(const Font*, TextDirection) const; |
- struct HolesQueueItem { |
- DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
- HolesQueueItemAction m_action; |
- unsigned m_startIndex; |
- unsigned m_numCharacters; |
- HolesQueueItem(HolesQueueItemAction action, unsigned start, unsigned num) |
- : m_action(action), m_startIndex(start), m_numCharacters(num){}; |
- }; |
+ ~HarfBuzzShaper() {} |
private: |
+ using FeaturesVector = Vector<hb_feature_t, 6>; |
+ |
+ // Shapes a single seqment, as identified by the RunSegmenterRange parameter, |
+ // one or more times taking font fallback into account. The start and end |
+ // parameters are for the entire text run, not the segment, and are used to |
+ // determine pre- and post-context for shaping. |
+ void shapeSegment(ShapeResult*, |
+ Deque<HolesQueueItem>*, |
+ hb_buffer_t*, |
+ const Font*, |
+ TextDirection, |
+ FeaturesVector*, |
+ RunSegmenter::RunSegmenterRange, |
+ unsigned start, |
+ unsigned end) const; |
+ |
bool extractShapeResults(hb_buffer_t*, |
ShapeResult*, |
bool& fontCycleQueued, |
Deque<HolesQueueItem>*, |
const HolesQueueItem&, |
const Font*, |
+ TextDirection, |
const SimpleFontData*, |
UScriptCode, |
bool isLastResort) const; |
- bool collectFallbackHintChars(const Deque<HolesQueueItem>&, |
+ bool collectFallbackHintChars(const Deque<HolesQueueItem>*, |
Vector<UChar32>& hint) const; |
- const UChar* m_normalizedBuffer; |
- unsigned m_normalizedBufferLength; |
- TextDirection m_textDirection; |
+ const UChar* m_text; |
+ unsigned m_textLength; |
}; |
} // namespace blink |