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

Unified Diff: third_party/WebKit/Source/platform/fonts/GlyphBuffer.h

Issue 2502413004: WTF/std normalization: replace WTF::Vector::last with ::back (Closed)
Patch Set: rebase Created 4 years, 1 month 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/GlyphBuffer.h
diff --git a/third_party/WebKit/Source/platform/fonts/GlyphBuffer.h b/third_party/WebKit/Source/platform/fonts/GlyphBuffer.h
index 879f8f43afb46e417bb0f87a7e41f617ef3997ee..f05a0d5ad37ac87f4aa576a7161b1a416c8aaee5 100644
--- a/third_party/WebKit/Source/platform/fonts/GlyphBuffer.h
+++ b/third_party/WebKit/Source/platform/fonts/GlyphBuffer.h
@@ -111,6 +111,36 @@ class GlyphBuffer {
m_offsets.append(offset.y());
}
+ void reverseForSimpleRTL(float afterOffset, float totalWidth) {
+ ASSERT(!hasVerticalOffsets());
+
+ if (isEmpty())
+ return;
+
+ m_fontData.reverse();
+ m_glyphs.reverse();
+
+ // | .. [X0 X1 .. Xn] .. |
+ // ^ ^ ^
+ // 0 afterOffset totalWidth
+ //
+ // The input buffer is shaped using RTL advances, but since the right edge
+ // is unknown at that time, offsets are computed as if the advances were
+ // LTR. This method performs the required adjustments by reconstructing
+ // advances and positioning offsets in an RTL progression.
+
+ // FIXME: we should get rid of this (idea: store negative offsets while
+ // shaping, and adjust the initial advance accordingly -> should
+ // yield correctly positioned RTL glyphs without any post-shape
+ // munging).
+ SECURITY_DCHECK(!m_offsets.isEmpty());
+ for (unsigned i = 0; i + 1 < m_offsets.size(); ++i)
+ m_offsets[i] = totalWidth - m_offsets[i + 1];
+ m_offsets.back() = totalWidth - afterOffset;
+
+ m_offsets.reverse();
+ }
+
protected:
Vector<const SimpleFontData*, 2048> m_fontData;
Vector<Glyph, 2048> m_glyphs;
« no previous file with comments | « third_party/WebKit/Source/platform/blob/BlobData.cpp ('k') | third_party/WebKit/Source/platform/geometry/Region.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698