OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "core/style/StylePath.h" | 5 #include "core/style/StylePath.h" |
6 | 6 |
7 #include "core/css/CSSPathValue.h" | 7 #include "core/css/CSSPathValue.h" |
8 #include "core/svg/SVGPathByteStream.h" | 8 #include "core/svg/SVGPathByteStream.h" |
9 #include "core/svg/SVGPathUtilities.h" | 9 #include "core/svg/SVGPathUtilities.h" |
10 #include "platform/graphics/Path.h" | 10 #include "platform/graphics/Path.h" |
| 11 #include "wtf/PtrUtil.h" |
| 12 #include <memory> |
11 | 13 |
12 namespace blink { | 14 namespace blink { |
13 | 15 |
14 StylePath::StylePath(PassOwnPtr<SVGPathByteStream> pathByteStream) | 16 StylePath::StylePath(std::unique_ptr<SVGPathByteStream> pathByteStream) |
15 : m_byteStream(std::move(pathByteStream)) | 17 : m_byteStream(std::move(pathByteStream)) |
16 , m_pathLength(std::numeric_limits<float>::quiet_NaN()) | 18 , m_pathLength(std::numeric_limits<float>::quiet_NaN()) |
17 { | 19 { |
18 ASSERT(m_byteStream); | 20 ASSERT(m_byteStream); |
19 } | 21 } |
20 | 22 |
21 StylePath::~StylePath() | 23 StylePath::~StylePath() |
22 { | 24 { |
23 } | 25 } |
24 | 26 |
25 PassRefPtr<StylePath> StylePath::create(PassOwnPtr<SVGPathByteStream> pathByteSt
ream) | 27 PassRefPtr<StylePath> StylePath::create(std::unique_ptr<SVGPathByteStream> pathB
yteStream) |
26 { | 28 { |
27 return adoptRef(new StylePath(std::move(pathByteStream))); | 29 return adoptRef(new StylePath(std::move(pathByteStream))); |
28 } | 30 } |
29 | 31 |
30 StylePath* StylePath::emptyPath() | 32 StylePath* StylePath::emptyPath() |
31 { | 33 { |
32 DEFINE_STATIC_REF(StylePath, emptyPath, StylePath::create(SVGPathByteStream:
:create())); | 34 DEFINE_STATIC_REF(StylePath, emptyPath, StylePath::create(SVGPathByteStream:
:create())); |
33 return emptyPath; | 35 return emptyPath; |
34 } | 36 } |
35 | 37 |
36 const Path& StylePath::path() const | 38 const Path& StylePath::path() const |
37 { | 39 { |
38 if (!m_path) { | 40 if (!m_path) { |
39 m_path = adoptPtr(new Path); | 41 m_path = wrapUnique(new Path); |
40 buildPathFromByteStream(*m_byteStream, *m_path); | 42 buildPathFromByteStream(*m_byteStream, *m_path); |
41 } | 43 } |
42 return *m_path; | 44 return *m_path; |
43 } | 45 } |
44 | 46 |
45 float StylePath::length() const | 47 float StylePath::length() const |
46 { | 48 { |
47 if (std::isnan(m_pathLength)) | 49 if (std::isnan(m_pathLength)) |
48 m_pathLength = path().length(); | 50 m_pathLength = path().length(); |
49 return m_pathLength; | 51 return m_pathLength; |
50 } | 52 } |
51 | 53 |
52 bool StylePath::isClosed() const | 54 bool StylePath::isClosed() const |
53 { | 55 { |
54 return path().isClosed(); | 56 return path().isClosed(); |
55 } | 57 } |
56 | 58 |
57 CSSValue* StylePath::computedCSSValue() const | 59 CSSValue* StylePath::computedCSSValue() const |
58 { | 60 { |
59 return CSSPathValue::create(const_cast<StylePath*>(this)); | 61 return CSSPathValue::create(const_cast<StylePath*>(this)); |
60 } | 62 } |
61 | 63 |
62 bool StylePath::operator==(const StylePath& other) const | 64 bool StylePath::operator==(const StylePath& other) const |
63 { | 65 { |
64 return *m_byteStream == *other.m_byteStream; | 66 return *m_byteStream == *other.m_byteStream; |
65 } | 67 } |
66 | 68 |
67 } // namespace blink | 69 } // namespace blink |
OLD | NEW |