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

Unified Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGTextPath.h

Issue 1683903004: Factor out the <textPath> positioning mapping code into a helper class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 10 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: third_party/WebKit/Source/core/layout/svg/LayoutSVGTextPath.h
diff --git a/third_party/WebKit/Source/core/layout/svg/LayoutSVGTextPath.h b/third_party/WebKit/Source/core/layout/svg/LayoutSVGTextPath.h
index 1d875856e532555d749daaeb112c6e9aa2ff30dc..1fd09f0713ebe455cbb408ee2e753981c0fce746 100644
--- a/third_party/WebKit/Source/core/layout/svg/LayoutSVGTextPath.h
+++ b/third_party/WebKit/Source/core/layout/svg/LayoutSVGTextPath.h
@@ -25,11 +25,37 @@
namespace blink {
+// This class maps a 1D location in the "path space"; [0, path length] to a
+// (2D) point on the path and provides the normal (angle from the x-axis) for
+// said point.
+class PathPositionMapper {
+ USING_FAST_MALLOC(PathPositionMapper);
+public:
+ static PassOwnPtr<PathPositionMapper> create(const Path& path)
+ {
+ return adoptPtr(new PathPositionMapper(path));
+ }
+
+ enum PositionType {
+ OnPath,
+ BeforePath,
+ AfterPath,
+ };
+ PositionType pointAndNormalAtLength(float length, FloatPoint&, float& angle);
+ float length() const { return m_pathLength; }
+
+private:
+ explicit PathPositionMapper(const Path&);
+
+ Path::PositionCalculator m_positionCalculator;
+ float m_pathLength;
+};
+
class LayoutSVGTextPath final : public LayoutSVGInline {
public:
explicit LayoutSVGTextPath(Element*);
- Path layoutPath() const;
+ PassOwnPtr<PathPositionMapper> layoutPath() const;
float calculateStartOffset(float) const;
bool isChildAllowed(LayoutObject*, const ComputedStyle&) const override;

Powered by Google App Engine
This is Rietveld 408576698