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

Side by Side Diff: third_party/WebKit/Source/core/layout/svg/LayoutSVGTextPath.cpp

Issue 1580293008: Fix incorrect handling of small non-percentage value for 'startOffset' on <textPath> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 50
51 // Spec: The transform attribute on the referenced 'path' element represent s a 51 // Spec: The transform attribute on the referenced 'path' element represent s a
52 // supplemental transformation relative to the current user coordinate syste m for 52 // supplemental transformation relative to the current user coordinate syste m for
53 // the current 'text' element, including any adjustments to the current user coordinate 53 // the current 'text' element, including any adjustments to the current user coordinate
54 // system due to a possible transform attribute on the current 'text' elemen t. 54 // system due to a possible transform attribute on the current 'text' elemen t.
55 // http://www.w3.org/TR/SVG/text.html#TextPathElement 55 // http://www.w3.org/TR/SVG/text.html#TextPathElement
56 pathData.transform(pathElement.calculateAnimatedLocalTransform()); 56 pathData.transform(pathElement.calculateAnimatedLocalTransform());
57 return pathData; 57 return pathData;
58 } 58 }
59 59
60 float LayoutSVGTextPath::startOffset() const 60 static inline bool isPercentageForStartOffset(const LayoutObject* layoutObject)
61 { 61 {
62 return toSVGTextPathElement(node())->startOffset()->currentValue()->valueAsP ercentage(); 62 return toSVGTextPathElement(layoutObject->node())->startOffset()->currentVal ue()->typeWithCalcResolved() == CSSPrimitiveValue::UnitType::Percentage;
63 }
64
65 float LayoutSVGTextPath::calculateStartOffset(float length) const
66 {
67 float textPathStartOffset = toSVGTextPathElement(node())->startOffset()->cur rentValue()->valueAsPercentage();
68 if (isPercentageForStartOffset(this)) {
fs 2016/01/28 15:20:34 This is unnecessarily complicated, just do: const
69 textPathStartOffset *= length;
70 }
71 return textPathStartOffset;
63 } 72 }
64 73
65 } // namespace blink 74 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698