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

Side by Side Diff: third_party/WebKit/Source/core/style/StylePath.cpp

Issue 1640313002: Lazily create the Path in StylePath (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months 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
« no previous file with comments | « third_party/WebKit/Source/core/style/StylePath.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 11
11 namespace blink { 12 namespace blink {
12 13
13 StylePath::StylePath(PassRefPtr<SVGPathByteStream> pathByteStream) 14 StylePath::StylePath(PassRefPtr<SVGPathByteStream> pathByteStream)
14 : m_byteStream(pathByteStream) 15 : m_byteStream(pathByteStream)
15 { 16 {
16 ASSERT(m_byteStream); 17 ASSERT(m_byteStream);
17 buildPathFromByteStream(*m_byteStream, m_path);
18 } 18 }
19 19
20 StylePath::~StylePath() 20 StylePath::~StylePath()
21 { 21 {
22 } 22 }
23 23
24 PassRefPtr<StylePath> StylePath::create(PassRefPtr<SVGPathByteStream> pathByteSt ream) 24 PassRefPtr<StylePath> StylePath::create(PassRefPtr<SVGPathByteStream> pathByteSt ream)
25 { 25 {
26 return adoptRef(new StylePath(pathByteStream)); 26 return adoptRef(new StylePath(pathByteStream));
27 } 27 }
28 28
29 StylePath* StylePath::emptyPath() 29 StylePath* StylePath::emptyPath()
30 { 30 {
31 DEFINE_STATIC_REF(StylePath, emptyPath, StylePath::create(SVGPathByteStream: :create())); 31 DEFINE_STATIC_REF(StylePath, emptyPath, StylePath::create(SVGPathByteStream: :create()));
32 return emptyPath; 32 return emptyPath;
33 } 33 }
34 34
35 const Path& StylePath::path() const
36 {
37 if (!m_path) {
38 m_path = adoptPtr(new Path);
39 buildPathFromByteStream(*m_byteStream, *m_path);
40 }
41 return *m_path;
42 }
43
35 const SVGPathByteStream& StylePath::byteStream() const 44 const SVGPathByteStream& StylePath::byteStream() const
36 { 45 {
37 return *m_byteStream; 46 return *m_byteStream;
38 } 47 }
39 48
40 PassRefPtrWillBeRawPtr<CSSValue> StylePath::computedCSSValue() const 49 PassRefPtrWillBeRawPtr<CSSValue> StylePath::computedCSSValue() const
41 { 50 {
42 return CSSPathValue::create(m_byteStream, const_cast<StylePath*>(this)); 51 return CSSPathValue::create(m_byteStream, const_cast<StylePath*>(this));
43 } 52 }
44 53
45 bool StylePath::equals(const StylePath& other) const 54 bool StylePath::equals(const StylePath& other) const
46 { 55 {
47 return *m_byteStream == *other.m_byteStream; 56 return *m_byteStream == *other.m_byteStream;
48 } 57 }
49 58
50 } // namespace blink 59 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/StylePath.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698