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