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

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

Issue 2525233002: Move pathLength attribute from SVGPathElement to SVGGeometryElement. (Closed)
Patch Set: Created 4 years 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) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org> 2 * Copyright (C) 2004, 2005, 2006, 2008 Nikolas Zimmermann <zimmermann@kde.org>
3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org> 3 * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 12 matching lines...) Expand all
23 #include "core/css/CSSIdentifierValue.h" 23 #include "core/css/CSSIdentifierValue.h"
24 #include "core/dom/StyleChangeReason.h" 24 #include "core/dom/StyleChangeReason.h"
25 #include "core/layout/svg/LayoutSVGPath.h" 25 #include "core/layout/svg/LayoutSVGPath.h"
26 #include "core/svg/SVGMPathElement.h" 26 #include "core/svg/SVGMPathElement.h"
27 #include "core/svg/SVGPathQuery.h" 27 #include "core/svg/SVGPathQuery.h"
28 #include "core/svg/SVGPathUtilities.h" 28 #include "core/svg/SVGPathUtilities.h"
29 #include "core/svg/SVGPointTearOff.h" 29 #include "core/svg/SVGPointTearOff.h"
30 30
31 namespace blink { 31 namespace blink {
32 32
33 class SVGAnimatedPathLength final : public SVGAnimatedNumber {
34 public:
35 static SVGAnimatedPathLength* create(SVGPathElement* contextElement) {
36 return new SVGAnimatedPathLength(contextElement);
37 }
38
39 SVGParsingError setBaseValueAsString(const String& value) override {
40 SVGParsingError parseStatus =
41 SVGAnimatedNumber::setBaseValueAsString(value);
42 if (parseStatus == SVGParseStatus::NoError && baseValue()->value() < 0)
43 parseStatus = SVGParseStatus::NegativeValue;
44 return parseStatus;
45 }
46
47 private:
48 explicit SVGAnimatedPathLength(SVGPathElement* contextElement)
49 : SVGAnimatedNumber(contextElement,
50 SVGNames::pathLengthAttr,
51 SVGNumber::create()) {}
52 };
53
54 inline SVGPathElement::SVGPathElement(Document& document) 33 inline SVGPathElement::SVGPathElement(Document& document)
55 : SVGGeometryElement(SVGNames::pathTag, document), 34 : SVGGeometryElement(SVGNames::pathTag, document),
56 m_pathLength(SVGAnimatedPathLength::create(this)),
57 m_path(SVGAnimatedPath::create(this, SVGNames::dAttr, CSSPropertyD)) { 35 m_path(SVGAnimatedPath::create(this, SVGNames::dAttr, CSSPropertyD)) {
58 addToPropertyMap(m_pathLength);
59 addToPropertyMap(m_path); 36 addToPropertyMap(m_path);
60 } 37 }
61 38
62 DEFINE_TRACE(SVGPathElement) { 39 DEFINE_TRACE(SVGPathElement) {
63 visitor->trace(m_pathLength);
64 visitor->trace(m_path); 40 visitor->trace(m_path);
65 SVGGeometryElement::trace(visitor); 41 SVGGeometryElement::trace(visitor);
66 } 42 }
67 43
68 DEFINE_NODE_FACTORY(SVGPathElement) 44 DEFINE_NODE_FACTORY(SVGPathElement)
69 45
70 Path SVGPathElement::attributePath() const { 46 Path SVGPathElement::attributePath() const {
71 return m_path->currentValue()->stylePath()->path(); 47 return m_path->currentValue()->stylePath()->path();
72 } 48 }
73 49
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 } 168 }
193 169
194 FloatRect SVGPathElement::getBBox() { 170 FloatRect SVGPathElement::getBBox() {
195 document().updateStyleAndLayoutIgnorePendingStylesheets(); 171 document().updateStyleAndLayoutIgnorePendingStylesheets();
196 172
197 // We want the exact bounds. 173 // We want the exact bounds.
198 return SVGPathElement::asPath().boundingRect(Path::BoundsType::Exact); 174 return SVGPathElement::asPath().boundingRect(Path::BoundsType::Exact);
199 } 175 }
200 176
201 } // namespace blink 177 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698