| 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 | 27 |
| 27 namespace blink { | 28 namespace blink { |
| 28 | 29 |
| 29 TreeScope& treeScopeForIdResolution(const SVGElement& element) | 30 TreeScope& treeScopeForIdResolution(const SVGElement& element) |
| 30 { | 31 { |
| 31 if (SVGElement* correspondingElement = element.correspondingElement()) | 32 if (SVGElement* correspondingElement = element.correspondingElement()) |
| 32 return correspondingElement->treeScope(); | 33 return correspondingElement->treeScope(); |
| 33 return element.treeScope(); | 34 return element.treeScope(); |
| 34 } | 35 } |
| 35 | 36 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 57 } | 58 } |
| 58 | 59 |
| 59 bool LayoutSVGTextPath::isChildAllowed(LayoutObject* child, const ComputedStyle&
) const | 60 bool LayoutSVGTextPath::isChildAllowed(LayoutObject* child, const ComputedStyle&
) const |
| 60 { | 61 { |
| 61 if (child->isText()) | 62 if (child->isText()) |
| 62 return SVGLayoutSupport::isLayoutableTextNode(child); | 63 return SVGLayoutSupport::isLayoutableTextNode(child); |
| 63 | 64 |
| 64 return child->isSVGInline() && !child->isSVGTextPath(); | 65 return child->isSVGInline() && !child->isSVGTextPath(); |
| 65 } | 66 } |
| 66 | 67 |
| 67 PassOwnPtr<PathPositionMapper> LayoutSVGTextPath::layoutPath() const | 68 std::unique_ptr<PathPositionMapper> LayoutSVGTextPath::layoutPath() const |
| 68 { | 69 { |
| 69 const SVGTextPathElement& textPathElement = toSVGTextPathElement(*node()); | 70 const SVGTextPathElement& textPathElement = toSVGTextPathElement(*node()); |
| 70 Element* targetElement = SVGURIReference::targetElementFromIRIString( | 71 Element* targetElement = SVGURIReference::targetElementFromIRIString( |
| 71 textPathElement.hrefString(), treeScopeForIdResolution(textPathElement))
; | 72 textPathElement.hrefString(), treeScopeForIdResolution(textPathElement))
; |
| 72 | 73 |
| 73 if (!isSVGPathElement(targetElement)) | 74 if (!isSVGPathElement(targetElement)) |
| 74 return nullptr; | 75 return nullptr; |
| 75 | 76 |
| 76 SVGPathElement& pathElement = toSVGPathElement(*targetElement); | 77 SVGPathElement& pathElement = toSVGPathElement(*targetElement); |
| 77 Path pathData = pathElement.asPath(); | 78 Path pathData = pathElement.asPath(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 92 { | 93 { |
| 93 const SVGLength& startOffset = *toSVGTextPathElement(node())->startOffset()-
>currentValue(); | 94 const SVGLength& startOffset = *toSVGTextPathElement(node())->startOffset()-
>currentValue(); |
| 94 float textPathStartOffset = startOffset.valueAsPercentage(); | 95 float textPathStartOffset = startOffset.valueAsPercentage(); |
| 95 if (startOffset.typeWithCalcResolved() == CSSPrimitiveValue::UnitType::Perce
ntage) | 96 if (startOffset.typeWithCalcResolved() == CSSPrimitiveValue::UnitType::Perce
ntage) |
| 96 textPathStartOffset *= pathLength; | 97 textPathStartOffset *= pathLength; |
| 97 | 98 |
| 98 return textPathStartOffset; | 99 return textPathStartOffset; |
| 99 } | 100 } |
| 100 | 101 |
| 101 } // namespace blink | 102 } // namespace blink |
| OLD | NEW |