Index: Source/core/rendering/InlineTextBox.cpp |
diff --git a/Source/core/rendering/InlineTextBox.cpp b/Source/core/rendering/InlineTextBox.cpp |
index 2e3d986fc8a34b7a0f0a8890f28a5e6fc999cfb5..191dd49f68c94ab6466b9a1603de285919602b31 100644 |
--- a/Source/core/rendering/InlineTextBox.cpp |
+++ b/Source/core/rendering/InlineTextBox.cpp |
@@ -35,6 +35,7 @@ |
#include "core/platform/graphics/DrawLooper.h" |
#include "core/platform/graphics/FontCache.h" |
#include "core/platform/graphics/GraphicsContextStateSaver.h" |
+#include "core/platform/graphics/WidthIterator.h" |
#include "core/rendering/EllipsisBox.h" |
#include "core/rendering/HitTestResult.h" |
#include "core/rendering/PaintInfo.h" |
@@ -1485,6 +1486,30 @@ bool InlineTextBox::containsCaretOffset(int offset) const |
return true; |
} |
+void InlineTextBox::characterWidths(Vector<float>& widths) const |
eseidel
2013/09/10 22:22:23
This function seems OK to me. I'm surprised it's
|
+{ |
+ FontCachePurgePreventer fontCachePurgePreventer; |
+ |
+ RenderText* textObj = textRenderer(); |
+ RenderStyle* styleToUse = textObj->style(isFirstLineStyle()); |
+ const Font& font = styleToUse->font(); |
+ |
+ StringBuilder charactersWithHyphen; |
+ TextRun textRun = constructTextRun(styleToUse, font, hasHyphen() ? &charactersWithHyphen : 0); |
+ |
+ GlyphBuffer glyphBuffer; |
+ WidthIterator it(&font, textRun); |
+ float lastWidth = 0; |
+ widths.resize(m_len); |
+ for (unsigned i = 0; i < m_len; i++) { |
+ it.advance(i + 1, &glyphBuffer); |
+ widths[i] = it.m_runWidthSoFar - lastWidth; |
+ if (textRun.rtl()) |
+ widths[i] *= -1; |
+ lastWidth = it.m_runWidthSoFar; |
+ } |
+} |
+ |
TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, StringBuilder* charactersWithHyphen) const |
{ |
ASSERT(style); |