| 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 "sky/engine/core/script/dom_dart_state.h" | 5 #include "sky/engine/core/script/dom_dart_state.h" |
| 6 | 6 |
| 7 #include "sky/engine/core/dom/Document.h" | 7 #include "sky/engine/core/dom/Document.h" |
| 8 #include "sky/engine/tonic/dart_builtin.h" | 8 #include "sky/engine/tonic/dart_builtin.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 DOMDartState::DOMDartState(Document* document, const String& url) | 12 DOMDartState::DOMDartState(Document* document, const String& url) |
| 13 : document_(document), url_(url) { | 13 : document_(document), url_(url) { |
| 14 } | 14 } |
| 15 | 15 |
| 16 DOMDartState::~DOMDartState() { | 16 DOMDartState::~DOMDartState() { |
| 17 // We've already destroyed the isolate. Revoke any weak ptrs held by | 17 // We've already destroyed the isolate. Revoke any weak ptrs held by |
| 18 // DartPersistentValues so they don't try to enter the destroyed isolate to | 18 // DartPersistentValues so they don't try to enter the destroyed isolate to |
| 19 // clean themselves up. | 19 // clean themselves up. |
| 20 weak_factory_.InvalidateWeakPtrs(); | 20 weak_factory_.InvalidateWeakPtrs(); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void DOMDartState::DidSetIsolate() { | 23 void DOMDartState::DidSetIsolate() { |
| 24 Scope dart_scope(this); | 24 Scope dart_scope(this); |
| 25 x_handle_.Set(this, ToDart("x")); | 25 x_handle_.Set(this, ToDart("x")); |
| 26 y_handle_.Set(this, ToDart("y")); | 26 y_handle_.Set(this, ToDart("y")); |
| 27 dx_handle_.Set(this, ToDart("_dx")); |
| 28 dy_handle_.Set(this, ToDart("_dy")); |
| 27 value_handle_.Set(this, ToDart("_value")); | 29 value_handle_.Set(this, ToDart("_value")); |
| 28 | 30 |
| 29 Dart_Handle sky_library = DartBuiltin::LookupLibrary("dart:sky"); | 31 Dart_Handle sky_library = DartBuiltin::LookupLibrary("dart:sky"); |
| 30 color_class_.Set(this, Dart_GetType(sky_library, ToDart("Color"), 0, 0)); | 32 color_class_.Set(this, Dart_GetType(sky_library, ToDart("Color"), 0, 0)); |
| 31 } | 33 } |
| 32 | 34 |
| 33 DOMDartState* DOMDartState::Current() { | 35 DOMDartState* DOMDartState::Current() { |
| 34 return static_cast<DOMDartState*>(DartState::Current()); | 36 return static_cast<DOMDartState*>(DartState::Current()); |
| 35 } | 37 } |
| 36 | 38 |
| 37 Document* DOMDartState::CurrentDocument() { | 39 Document* DOMDartState::CurrentDocument() { |
| 38 return Current()->document_.get(); | 40 return Current()->document_.get(); |
| 39 } | 41 } |
| 40 | 42 |
| 41 LocalFrame* DOMDartState::CurrentFrame() { | 43 LocalFrame* DOMDartState::CurrentFrame() { |
| 42 DCHECK(Current()->document_); | 44 DCHECK(Current()->document_); |
| 43 return Current()->document_->frame(); | 45 return Current()->document_->frame(); |
| 44 } | 46 } |
| 45 | 47 |
| 46 LocalDOMWindow* DOMDartState::CurrentWindow() { | 48 LocalDOMWindow* DOMDartState::CurrentWindow() { |
| 47 DCHECK(Current()->document_); | 49 DCHECK(Current()->document_); |
| 48 return Current()->document_->domWindow(); | 50 return Current()->document_->domWindow(); |
| 49 } | 51 } |
| 50 | 52 |
| 51 } // namespace blink | 53 } // namespace blink |
| OLD | NEW |