| OLD | NEW |
| 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 |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 * Library General Public License for more details. | 12 * Library General Public License for more details. |
| 13 * | 13 * |
| 14 * You should have received a copy of the GNU Library General Public License | 14 * You should have received a copy of the GNU Library General Public License |
| 15 * along with this library; see the file COPYING.LIB. If not, write to | 15 * along with this library; see the file COPYING.LIB. If not, write to |
| 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 * Boston, MA 02110-1301, USA. | 17 * Boston, MA 02110-1301, USA. |
| 18 */ | 18 */ |
| 19 | 19 |
| 20 #include "core/layout/svg/LayoutSVGTextPath.h" | 20 #include "core/layout/svg/LayoutSVGTextPath.h" |
| 21 | 21 |
| 22 #include "core/layout/svg/SVGLayoutSupport.h" | 22 #include "core/layout/svg/SVGLayoutSupport.h" |
| 23 #include "core/svg/SVGPathElement.h" | 23 #include "core/svg/SVGPathElement.h" |
| 24 #include "core/svg/SVGTextPathElement.h" | 24 #include "core/svg/SVGTextPathElement.h" |
| 25 #include "platform/graphics/Path.h" | 25 #include "platform/graphics/Path.h" |
| 26 #include <memory> | 26 #include <memory> |
| 27 | 27 |
| 28 namespace blink { | 28 namespace blink { |
| 29 | 29 |
| 30 TreeScope& treeScopeForIdResolution(const SVGElement& element) { | |
| 31 if (SVGElement* correspondingElement = element.correspondingElement()) | |
| 32 return correspondingElement->treeScope(); | |
| 33 return element.treeScope(); | |
| 34 } | |
| 35 | |
| 36 PathPositionMapper::PathPositionMapper(const Path& path) | 30 PathPositionMapper::PathPositionMapper(const Path& path) |
| 37 : m_positionCalculator(path), m_pathLength(path.length()) {} | 31 : m_positionCalculator(path), m_pathLength(path.length()) {} |
| 38 | 32 |
| 39 PathPositionMapper::PositionType PathPositionMapper::pointAndNormalAtLength( | 33 PathPositionMapper::PositionType PathPositionMapper::pointAndNormalAtLength( |
| 40 float length, | 34 float length, |
| 41 FloatPoint& point, | 35 FloatPoint& point, |
| 42 float& angle) { | 36 float& angle) { |
| 43 if (length < 0) | 37 if (length < 0) |
| 44 return BeforePath; | 38 return BeforePath; |
| 45 if (length > m_pathLength) | 39 if (length > m_pathLength) |
| (...skipping 10 matching lines...) Expand all Loading... |
| 56 const ComputedStyle&) const { | 50 const ComputedStyle&) const { |
| 57 if (child->isText()) | 51 if (child->isText()) |
| 58 return SVGLayoutSupport::isLayoutableTextNode(child); | 52 return SVGLayoutSupport::isLayoutableTextNode(child); |
| 59 | 53 |
| 60 return child->isSVGInline() && !child->isSVGTextPath(); | 54 return child->isSVGInline() && !child->isSVGTextPath(); |
| 61 } | 55 } |
| 62 | 56 |
| 63 std::unique_ptr<PathPositionMapper> LayoutSVGTextPath::layoutPath() const { | 57 std::unique_ptr<PathPositionMapper> LayoutSVGTextPath::layoutPath() const { |
| 64 const SVGTextPathElement& textPathElement = toSVGTextPathElement(*node()); | 58 const SVGTextPathElement& textPathElement = toSVGTextPathElement(*node()); |
| 65 Element* targetElement = SVGURIReference::targetElementFromIRIString( | 59 Element* targetElement = SVGURIReference::targetElementFromIRIString( |
| 66 textPathElement.hrefString(), treeScopeForIdResolution(textPathElement)); | 60 textPathElement.hrefString(), textPathElement.treeScopeForIdResolution()); |
| 67 | 61 |
| 68 if (!isSVGPathElement(targetElement)) | 62 if (!isSVGPathElement(targetElement)) |
| 69 return nullptr; | 63 return nullptr; |
| 70 | 64 |
| 71 SVGPathElement& pathElement = toSVGPathElement(*targetElement); | 65 SVGPathElement& pathElement = toSVGPathElement(*targetElement); |
| 72 Path pathData = pathElement.asPath(); | 66 Path pathData = pathElement.asPath(); |
| 73 if (pathData.isEmpty()) | 67 if (pathData.isEmpty()) |
| 74 return nullptr; | 68 return nullptr; |
| 75 | 69 |
| 76 // Spec: The transform attribute on the referenced 'path' element represents | 70 // Spec: The transform attribute on the referenced 'path' element represents |
| (...skipping 12 matching lines...) Expand all Loading... |
| 89 *toSVGTextPathElement(node())->startOffset()->currentValue(); | 83 *toSVGTextPathElement(node())->startOffset()->currentValue(); |
| 90 float textPathStartOffset = startOffset.valueAsPercentage(); | 84 float textPathStartOffset = startOffset.valueAsPercentage(); |
| 91 if (startOffset.typeWithCalcResolved() == | 85 if (startOffset.typeWithCalcResolved() == |
| 92 CSSPrimitiveValue::UnitType::Percentage) | 86 CSSPrimitiveValue::UnitType::Percentage) |
| 93 textPathStartOffset *= pathLength; | 87 textPathStartOffset *= pathLength; |
| 94 | 88 |
| 95 return textPathStartOffset; | 89 return textPathStartOffset; |
| 96 } | 90 } |
| 97 | 91 |
| 98 } // namespace blink | 92 } // namespace blink |
| OLD | NEW |