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 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 { | 53 { |
54 if (child->isText()) | 54 if (child->isText()) |
55 return SVGLayoutSupport::isLayoutableTextNode(child); | 55 return SVGLayoutSupport::isLayoutableTextNode(child); |
56 | 56 |
57 return child->isSVGInline() && !child->isSVGTextPath(); | 57 return child->isSVGInline() && !child->isSVGTextPath(); |
58 } | 58 } |
59 | 59 |
60 PassOwnPtr<PathPositionMapper> LayoutSVGTextPath::layoutPath() const | 60 PassOwnPtr<PathPositionMapper> LayoutSVGTextPath::layoutPath() const |
61 { | 61 { |
62 const SVGTextPathElement& textPathElement = toSVGTextPathElement(*node()); | 62 const SVGTextPathElement& textPathElement = toSVGTextPathElement(*node()); |
63 Element* targetElement = SVGURIReference::targetElementFromIRIString( | 63 Element* targetElement; |
64 textPathElement.hrefString(), textPathElement.treeScope()); | 64 if (textPathElement.inUseShadowTree()) { |
fs
2016/03/14 12:54:10
I think we could simplify this a bit (and preferab
hyunjunekim2
2016/03/15 23:11:32
Done.
| |
65 SVGElement* correspondingElement = textPathElement.correspondingElement( ); | |
66 if (correspondingElement && isSVGTextPathElement(correspondingElement)) { | |
67 targetElement = SVGURIReference::targetElementFromIRIString( | |
68 textPathElement.hrefString(), correspondingElement->treeScope()) ; | |
69 } | |
70 } else { | |
71 targetElement = SVGURIReference::targetElementFromIRIString( | |
72 textPathElement.hrefString(), textPathElement.treeScope()); | |
73 } | |
65 if (!isSVGPathElement(targetElement)) | 74 if (!isSVGPathElement(targetElement)) |
66 return nullptr; | 75 return nullptr; |
67 | 76 |
68 SVGPathElement& pathElement = toSVGPathElement(*targetElement); | 77 SVGPathElement& pathElement = toSVGPathElement(*targetElement); |
69 Path pathData = pathElement.asPath(); | 78 Path pathData = pathElement.asPath(); |
70 if (pathData.isEmpty()) | 79 if (pathData.isEmpty()) |
71 return nullptr; | 80 return nullptr; |
72 | 81 |
73 // Spec: The transform attribute on the referenced 'path' element represent s a | 82 // Spec: The transform attribute on the referenced 'path' element represent s a |
74 // supplemental transformation relative to the current user coordinate syste m for | 83 // supplemental transformation relative to the current user coordinate syste m for |
75 // the current 'text' element, including any adjustments to the current user coordinate | 84 // the current 'text' element, including any adjustments to the current user coordinate |
76 // system due to a possible transform attribute on the current 'text' elemen t. | 85 // system due to a possible transform attribute on the current 'text' elemen t. |
77 // http://www.w3.org/TR/SVG/text.html#TextPathElement | 86 // http://www.w3.org/TR/SVG/text.html#TextPathElement |
78 pathData.transform(pathElement.calculateAnimatedLocalTransform()); | 87 pathData.transform(pathElement.calculateAnimatedLocalTransform()); |
79 | 88 |
80 return PathPositionMapper::create(pathData); | 89 return PathPositionMapper::create(pathData); |
81 } | 90 } |
82 | 91 |
83 float LayoutSVGTextPath::calculateStartOffset(float pathLength) const | 92 float LayoutSVGTextPath::calculateStartOffset(float pathLength) const |
84 { | 93 { |
85 const SVGLength& startOffset = *toSVGTextPathElement(node())->startOffset()- >currentValue(); | 94 const SVGLength& startOffset = *toSVGTextPathElement(node())->startOffset()- >currentValue(); |
86 float textPathStartOffset = startOffset.valueAsPercentage(); | 95 float textPathStartOffset = startOffset.valueAsPercentage(); |
87 if (startOffset.typeWithCalcResolved() == CSSPrimitiveValue::UnitType::Perce ntage) | 96 if (startOffset.typeWithCalcResolved() == CSSPrimitiveValue::UnitType::Perce ntage) |
88 textPathStartOffset *= pathLength; | 97 textPathStartOffset *= pathLength; |
89 | 98 |
90 return textPathStartOffset; | 99 return textPathStartOffset; |
91 } | 100 } |
92 | 101 |
93 } // namespace blink | 102 } // namespace blink |
OLD | NEW |