OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "bindings/core/v8/ScriptSourceCode.h" | 5 #include "bindings/core/v8/ScriptSourceCode.h" |
6 | 6 |
7 namespace blink { | 7 namespace blink { |
8 | 8 |
9 ScriptSourceCode::ScriptSourceCode() | 9 ScriptSourceCode::ScriptSourceCode() |
10 : m_resource(0) | 10 : m_startPosition(TextPosition::minimumPosition()) |
11 , m_startPosition(TextPosition::minimumPosition()) | |
12 { | 11 { |
13 } | 12 } |
14 | 13 |
15 ScriptSourceCode::ScriptSourceCode(const String& source, const KURL& url, const
TextPosition& startPosition) | 14 ScriptSourceCode::ScriptSourceCode(const String& source, const KURL& url, const
TextPosition& startPosition) |
16 : ScriptSourceCode(CompressibleString(source.impl()), url, startPosition) | 15 : ScriptSourceCode(CompressibleString(source.impl()), url, startPosition) |
17 { | 16 { |
18 } | 17 } |
19 | 18 |
20 ScriptSourceCode::ScriptSourceCode(const CompressibleString& source, const KURL&
url, const TextPosition& startPosition) | 19 ScriptSourceCode::ScriptSourceCode(const CompressibleString& source, const KURL&
url, const TextPosition& startPosition) |
21 : m_source(source) | 20 : m_source(source) |
22 , m_resource(0) | |
23 , m_url(url) | 21 , m_url(url) |
24 , m_startPosition(startPosition) | 22 , m_startPosition(startPosition) |
25 { | 23 { |
26 treatNullSourceAsEmpty(); | 24 treatNullSourceAsEmpty(); |
27 if (!m_url.isEmpty()) | 25 if (!m_url.isEmpty()) |
28 m_url.removeFragmentIdentifier(); | 26 m_url.removeFragmentIdentifier(); |
29 } | 27 } |
30 | 28 |
31 ScriptSourceCode::ScriptSourceCode(ScriptResource* resource) | 29 ScriptSourceCode::ScriptSourceCode(ScriptResource* resource) |
32 : m_source(resource->script()) | 30 : m_source(resource->script()) |
(...skipping 11 matching lines...) Expand all Loading... |
44 { | 42 { |
45 treatNullSourceAsEmpty(); | 43 treatNullSourceAsEmpty(); |
46 } | 44 } |
47 | 45 |
48 ScriptSourceCode::~ScriptSourceCode() | 46 ScriptSourceCode::~ScriptSourceCode() |
49 { | 47 { |
50 } | 48 } |
51 | 49 |
52 DEFINE_TRACE(ScriptSourceCode) | 50 DEFINE_TRACE(ScriptSourceCode) |
53 { | 51 { |
| 52 visitor->trace(m_resource); |
54 visitor->trace(m_streamer); | 53 visitor->trace(m_streamer); |
55 } | 54 } |
56 | 55 |
57 const KURL& ScriptSourceCode::url() const | 56 const KURL& ScriptSourceCode::url() const |
58 { | 57 { |
59 if (m_url.isEmpty() && m_resource) { | 58 if (m_url.isEmpty() && m_resource) { |
60 m_url = m_resource->response().url(); | 59 m_url = m_resource->response().url(); |
61 if (!m_url.isEmpty()) | 60 if (!m_url.isEmpty()) |
62 m_url.removeFragmentIdentifier(); | 61 m_url.removeFragmentIdentifier(); |
63 } | 62 } |
(...skipping 20 matching lines...) Expand all Loading... |
84 // construct such a value. | 83 // construct such a value. |
85 // | 84 // |
86 // Should the other constructors be passed a null string, that is interprete
d as representing | 85 // Should the other constructors be passed a null string, that is interprete
d as representing |
87 // the empty script. Consequently, we need to disambiguate between such null
string occurrences. | 86 // the empty script. Consequently, we need to disambiguate between such null
string occurrences. |
88 // Do that by converting the latter case's null strings into empty ones. | 87 // Do that by converting the latter case's null strings into empty ones. |
89 if (m_source.isNull()) | 88 if (m_source.isNull()) |
90 m_source = CompressibleString(); | 89 m_source = CompressibleString(); |
91 } | 90 } |
92 | 91 |
93 } // namespace blink | 92 } // namespace blink |
OLD | NEW |