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

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

Issue 2331783002: Fix tab is invisible when the next stop is close (Closed)
Patch Set: Cleanup Created 4 years, 3 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
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 098fc0f5160d0c73a5f15f8af122b67b985a75b5..9bcc953bb08f867501c89fce7e0f7bf38fb52dcf 100644
--- a/third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp
+++ b/third_party/WebKit/Source/platform/fonts/shaping/ShapeResult.cpp
@@ -362,4 +362,31 @@ void ShapeResult::insertRun(std::unique_ptr<ShapeResult::RunInfo> runToInsert,
m_runs.append(std::move(run));
}
+PassRefPtr<ShapeResult> ShapeResult::createForTabulationCharacters(const Font* font,
+ const TextRun& textRun, float positionOffset, unsigned count)
+{
+ const SimpleFontData* fontData = font->primaryFont();
+ std::unique_ptr<ShapeResult::RunInfo> run = wrapUnique(new ShapeResult::RunInfo(fontData,
+ // Tab characters are always LTR or RTL, not TTB, even when isVerticalAnyUpright().
+ textRun.rtl() ? HB_DIRECTION_RTL : HB_DIRECTION_LTR,
+ HB_SCRIPT_COMMON, 0, count, count));
+ float position = textRun.xPos() + positionOffset;
+ float startPosition = position;
+ for (unsigned i = 0; i < count; i++) {
+ float advance = font->tabWidth(*fontData, textRun.getTabSize(), position);
+ run->m_glyphData[i].characterIndex = i;
+ run->setGlyphAndPositions(i, fontData->spaceGlyph(), advance, 0, 0);
+ position += advance;
+ }
+ run->m_width = position - startPosition;
+
+ RefPtr<ShapeResult> result = ShapeResult::create(font, count, textRun.direction());
+ result->m_width = run->m_width;
+ result->m_numGlyphs = count;
+ DCHECK_EQ(result->m_numGlyphs, count); // no overflow
+ result->m_hasVerticalOffsets = fontData->platformData().isVerticalAnyUpright();
+ result->m_runs.append(std::move(run));
+ return result.release();
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/fonts/shaping/HarfBuzzShaper.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698