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

Unified Diff: third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h

Issue 1547263002: Fix SVGInlineTextMetricsIterator not to keep a pointer to LineLayoutItem (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix LineLayoutSVGInlineText* to LineLayoutSVGInlineText Created 5 years 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 | « no previous file | third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h
diff --git a/third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h b/third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h
index 02496d4ab935ff2495281dfb7d636f28ae06ace0..ca8d149d87d27565d5e7a4cbc8111996b227cb04 100644
--- a/third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h
+++ b/third_party/WebKit/Source/core/layout/api/LineLayoutSVGInlineText.h
@@ -63,12 +63,15 @@ private:
class SVGInlineTextMetricsIterator {
DISALLOW_NEW();
public:
- SVGInlineTextMetricsIterator() { reset(nullptr); }
+ SVGInlineTextMetricsIterator() { reset(LineLayoutSVGInlineText()); }
- void advanceToTextStart(LineLayoutSVGInlineText* textLineLayout, unsigned startCharacterOffset)
+ void advanceToTextStart(LineLayoutSVGInlineText textLineLayout, unsigned startCharacterOffset)
{
+#if ENABLE(ASSERT)
+ assertCharacterOffsetFromMetricsList();
+#endif
ASSERT(textLineLayout);
- if (m_textLineLayout != textLineLayout) {
+ if (!m_textLineLayout || !m_textLineLayout.isEqual(textLineLayout)) {
reset(textLineLayout);
ASSERT(!metricsList().isEmpty());
}
@@ -82,11 +85,14 @@ public:
while (m_characterOffset < startCharacterOffset)
next();
+ ASSERT(m_characterOffset == startCharacterOffset);
}
void next()
{
m_characterOffset += metrics().length();
+ ASSERT(m_characterOffset <= m_textLineLayout.length());
+ ASSERT(m_metricsListOffset < metricsList().size());
++m_metricsListOffset;
}
@@ -95,20 +101,38 @@ public:
ASSERT(m_textLineLayout && m_metricsListOffset < metricsList().size());
return metricsList()[m_metricsListOffset];
}
- const Vector<SVGTextMetrics>& metricsList() const { return m_textLineLayout->layoutAttributes()->textMetricsValues(); }
+ const Vector<SVGTextMetrics>& metricsList() const { return m_textLineLayout.layoutAttributes()->textMetricsValues(); }
unsigned metricsListOffset() const { return m_metricsListOffset; }
unsigned characterOffset() const { return m_characterOffset; }
bool isAtEnd() const { return m_metricsListOffset == metricsList().size(); }
private:
- void reset(LineLayoutSVGInlineText* textLineLayout)
+ void reset(LineLayoutSVGInlineText textLineLayout)
{
m_textLineLayout = textLineLayout;
m_characterOffset = 0;
m_metricsListOffset = 0;
}
- LineLayoutSVGInlineText* m_textLineLayout;
+#if ENABLE(ASSERT)
+ void assertCharacterOffsetFromMetricsList()
eae 2015/12/28 16:41:26 Is this really necessary? Wouldn't the length asse
+ {
+ if (!m_textLineLayout)
+ return;
+ const Vector<SVGTextMetrics>& metricsList = this->metricsList();
+ ASSERT(m_metricsListOffset <= metricsList.size());
+ unsigned characterOffset = 0, metricsListOffset = 0;
+ for (; metricsListOffset < m_metricsListOffset; ++metricsListOffset)
+ characterOffset += metricsList[metricsListOffset].length();
+ ASSERT(m_characterOffset == characterOffset);
+
+ for (; metricsListOffset < metricsList.size(); ++metricsListOffset)
+ characterOffset += metricsList[metricsListOffset].length();
+ ASSERT(characterOffset == m_textLineLayout.length());
+ }
+#endif
+
+ LineLayoutSVGInlineText m_textLineLayout;
unsigned m_metricsListOffset;
unsigned m_characterOffset;
};
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698