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

Unified Diff: Source/core/layout/svg/SVGTextMetrics.h

Issue 1160623002: Avoid resetting the metrics-list/character offset for each text box (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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
Index: Source/core/layout/svg/SVGTextMetrics.h
diff --git a/Source/core/layout/svg/SVGTextMetrics.h b/Source/core/layout/svg/SVGTextMetrics.h
index cbddde0a789de8d820c0126cb091b7911c6558d2..0fb8de219a2b9b74339ca9adb0dfcb1e4b994d30 100644
--- a/Source/core/layout/svg/SVGTextMetrics.h
+++ b/Source/core/layout/svg/SVGTextMetrics.h
@@ -21,6 +21,7 @@
#define SVGTextMetrics_h
#include "platform/text/TextDirection.h"
+#include "wtf/Vector.h"
namespace blink {
@@ -56,6 +57,34 @@ private:
unsigned m_length;
};
+class SVGTextMetricsIterator {
f(malita) 2015/05/27 01:53:49 nit: can this be a private nested class in SVGText
fs 2015/05/27 12:53:14 I have other possible uses in mind for this (SVGTe
+public:
+ SVGTextMetricsIterator() { reset(nullptr); }
+
+ void reset(const Vector<SVGTextMetrics>* metricsList)
pdr. 2015/05/27 03:11:18 I think this can be an internal detail of the iter
fs 2015/05/27 12:53:13 I wanted to keep the interface of the iterator fai
+ {
+ m_metricsList = metricsList;
+ m_characterOffset = 0;
+ m_metricsListOffset = 0;
+ }
+
+ void next()
+ {
+ m_characterOffset += metrics().length();
+ ++m_metricsListOffset;
+ }
+
+ const SVGTextMetrics& metrics() const { return metricsList()[m_metricsListOffset]; }
f(malita) 2015/05/27 01:53:49 nit: ASSERT(m_metricsList && m_metricsListOffset <
fs 2015/05/27 12:53:14 I've sort of been relying on the RELEASE_ASSERT in
+ const Vector<SVGTextMetrics>& metricsList() const { return *m_metricsList; }
+ unsigned metricsListOffset() const { return m_metricsListOffset; }
+ unsigned characterOffset() const { return m_characterOffset; }
+
+private:
+ const Vector<SVGTextMetrics>* m_metricsList;
+ unsigned m_metricsListOffset;
+ unsigned m_characterOffset;
+};
+
} // namespace blink
#endif

Powered by Google App Engine
This is Rietveld 408576698