Index: Source/core/rendering/InlineTextBox.cpp |
diff --git a/Source/core/rendering/InlineTextBox.cpp b/Source/core/rendering/InlineTextBox.cpp |
index 38f5c8f21ef51720071f1835ac5d6e9f438e013d..20e4204be347b2a5cf6518b17f720fcfa71c567b 100644 |
--- a/Source/core/rendering/InlineTextBox.cpp |
+++ b/Source/core/rendering/InlineTextBox.cpp |
@@ -35,6 +35,8 @@ |
#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/AbstractInlineTextBox.h" |
#include "core/rendering/EllipsisBox.h" |
#include "core/rendering/HitTestResult.h" |
#include "core/rendering/PaintInfo.h" |
@@ -69,6 +71,8 @@ static const int misspellingLineThickness = 3; |
void InlineTextBox::destroy() |
{ |
+ AbstractInlineTextBox::willDestroy(this); |
+ |
if (!knownToHaveNoOverflow() && gTextBoxesWithOverflow) |
gTextBoxesWithOverflow->remove(this); |
InlineBox::destroy(); |
@@ -1474,6 +1478,27 @@ bool InlineTextBox::containsCaretOffset(int offset) const |
return true; |
} |
+void InlineTextBox::characterWidths(Vector<float>& widths) const |
+{ |
+ FontCachePurgePreventer fontCachePurgePreventer; |
+ |
+ RenderText* textObj = textRenderer(); |
+ RenderStyle* styleToUse = textObj->style(isFirstLineStyle()); |
+ const Font& font = styleToUse->font(); |
+ |
+ TextRun textRun = constructTextRun(styleToUse, font); |
+ |
+ 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; |
+ lastWidth = it.m_runWidthSoFar; |
+ } |
+} |
+ |
TextRun InlineTextBox::constructTextRun(RenderStyle* style, const Font& font, StringBuilder* charactersWithHyphen) const |
{ |
ASSERT(style); |