| 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 : start_position_(TextPosition::MinimumPosition()) {} | 10 : start_position_(TextPosition::MinimumPosition()) {} |
| 11 | 11 |
| 12 ScriptSourceCode::ScriptSourceCode(const String& source, | 12 ScriptSourceCode::ScriptSourceCode(const String& source, |
| 13 const KURL& url, | 13 const KURL& url, |
| 14 const TextPosition& start_position) | 14 const TextPosition& start_position) |
| 15 : source_(source), url_(url), start_position_(start_position) { | 15 : source_(source), url_(url), start_position_(start_position) { |
| 16 TreatNullSourceAsEmpty(); | 16 TreatNullSourceAsEmpty(); |
| 17 if (!url_.IsEmpty()) | 17 if (!url_.IsEmpty()) |
| 18 url_.RemoveFragmentIdentifier(); | 18 url_.RemoveFragmentIdentifier(); |
| 19 } | 19 } |
| 20 | 20 |
| 21 ScriptSourceCode::ScriptSourceCode(ScriptResource* resource) | 21 ScriptSourceCode::ScriptSourceCode(ScriptResource* resource) |
| 22 : source_(resource->Script()), | 22 : source_(resource->SourceText()), |
| 23 resource_(resource), | 23 resource_(resource), |
| 24 start_position_(TextPosition::MinimumPosition()) { | 24 start_position_(TextPosition::MinimumPosition()) { |
| 25 TreatNullSourceAsEmpty(); | 25 TreatNullSourceAsEmpty(); |
| 26 } | 26 } |
| 27 | 27 |
| 28 ScriptSourceCode::ScriptSourceCode(ScriptStreamer* streamer, | 28 ScriptSourceCode::ScriptSourceCode(ScriptStreamer* streamer, |
| 29 ScriptResource* resource) | 29 ScriptResource* resource) |
| 30 : source_(resource->Script()), | 30 : source_(resource->SourceText()), |
| 31 resource_(resource), | 31 resource_(resource), |
| 32 streamer_(streamer), | 32 streamer_(streamer), |
| 33 start_position_(TextPosition::MinimumPosition()) { | 33 start_position_(TextPosition::MinimumPosition()) { |
| 34 TreatNullSourceAsEmpty(); | 34 TreatNullSourceAsEmpty(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 ScriptSourceCode::~ScriptSourceCode() {} | 37 ScriptSourceCode::~ScriptSourceCode() {} |
| 38 | 38 |
| 39 void ScriptSourceCode::Dispose() { | 39 void ScriptSourceCode::Dispose() { |
| 40 source_ = String(); | 40 source_ = String(); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // | 76 // |
| 77 // Should the other constructors be passed a null string, that is interpreted | 77 // Should the other constructors be passed a null string, that is interpreted |
| 78 // as representing the empty script. Consequently, we need to disambiguate | 78 // as representing the empty script. Consequently, we need to disambiguate |
| 79 // between such null string occurrences. Do that by converting the latter | 79 // between such null string occurrences. Do that by converting the latter |
| 80 // case's null strings into empty ones. | 80 // case's null strings into empty ones. |
| 81 if (source_.IsNull()) | 81 if (source_.IsNull()) |
| 82 source_ = ""; | 82 source_ = ""; |
| 83 } | 83 } |
| 84 | 84 |
| 85 } // namespace blink | 85 } // namespace blink |
| OLD | NEW |