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

Unified Diff: third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp

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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp b/third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp
index dd602a40f4a6290c19184e40dffadac77987a50b..ce2a8c34b8394afc9e57a017610c624edf6b7860 100644
--- a/third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp
+++ b/third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp
@@ -308,8 +308,10 @@ void ShapeResult::FallbackFonts(
}
}
-void ShapeResult::ApplySpacing(ShapeResultSpacing& spacing,
- const TextRun& text_run) {
+template <typename TextContainerType>
+void ShapeResult::ApplySpacing(ShapeResultSpacing<TextContainerType>& spacing,
+ const TextContainerType& text,
+ bool is_rtl) {
float offset_x, offset_y;
float& offset = spacing.IsVerticalOffset() ? offset_y : offset_x;
float total_space = 0;
@@ -325,7 +327,7 @@ void ShapeResult::ApplySpacing(ShapeResultSpacing& spacing,
glyph_data.character_index ==
run->glyph_data_[i + 1].character_index) {
// In RTL, marks need the same letter-spacing offset as the base.
- if (text_run.Rtl() && spacing.LetterSpacing()) {
+ if (is_rtl && spacing.LetterSpacing()) {
offset_x = offset_y = 0;
offset = spacing.LetterSpacing();
glyph_data.offset.Expand(offset_x, offset_y);
@@ -333,10 +335,10 @@ void ShapeResult::ApplySpacing(ShapeResultSpacing& spacing,
} else {
offset_x = offset_y = 0;
float space = spacing.ComputeSpacing(
- text_run, run->start_index_ + glyph_data.character_index, offset);
+ text, run->start_index_ + glyph_data.character_index, offset);
glyph_data.advance += space;
total_space_for_run += space;
- if (text_run.Rtl()) {
+ if (is_rtl) {
// In RTL, spacing should be added to left side of glyphs.
offset += space;
}
@@ -354,11 +356,17 @@ void ShapeResult::ApplySpacing(ShapeResultSpacing& spacing,
glyph_bounding_box_.SetWidth(glyph_bounding_box_.Width() + total_space);
}
+void ShapeResult::ApplySpacing(ShapeResultSpacing<StringView>& spacing,
+ const StringView& text,
+ TextDirection direction) {
+ ApplySpacing(spacing, text, direction == TextDirection::kRtl);
+}
+
PassRefPtr<ShapeResult> ShapeResult::ApplySpacingToCopy(
- ShapeResultSpacing& spacing,
+ ShapeResultSpacing<TextRun>& spacing,
const TextRun& run) const {
RefPtr<ShapeResult> result = ShapeResult::Create(*this);
- result->ApplySpacing(spacing, run);
+ result->ApplySpacing(spacing, run, run.Rtl());
return result.Release();
}

Powered by Google App Engine
This is Rietveld 408576698