Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions services/sky/document_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ void DocumentView::OnEmbed(
services_provided_by_embedder_ = services_provided_by_embedder.Pass();

Load(response_.Pass());

UpdateRootSizeAndViewportMetrics(root_->bounds());
root_->AddObserver(this);
}

Expand All @@ -141,7 +143,6 @@ void DocumentView::LoadFromSnapshotStream(
String name, mojo::ScopedDataPipeConsumerHandle snapshot) {
if (sky_view_) {
sky_view_->RunFromSnapshot(name, snapshot.Pass());
UpdateRootSizeAndViewportMetrics(root_->bounds());
}
}

Expand All @@ -153,6 +154,7 @@ void DocumentView::Load(mojo::URLResponsePtr response) {
layer_host_->SetRootLayer(root_layer_);

String name = String::fromUTF8(response->url);
sky_view_->CreateView(name);
if (name.endsWith(".skyx")) {
AssetUnpackerJob* unpacker = new AssetUnpackerJob(
mojo::GetProxy(&root_bundle_),
Expand All @@ -167,7 +169,6 @@ void DocumentView::Load(mojo::URLResponsePtr response) {
network_service_.get(),
CreatePrefetchedLibraryIfNeeded(name, response.Pass())));
sky_view_->RunFromLibrary(name, library_provider_.get());
UpdateRootSizeAndViewportMetrics(root_->bounds());
}

scoped_ptr<Rasterizer> DocumentView::CreateRasterizer() {
Expand Down
40 changes: 20 additions & 20 deletions sky/engine/public/sky/sky_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,33 @@ void SkyView::SetDisplayMetrics(const SkyDisplayMetrics& metrics) {
view_->setDisplayMetrics(display_metrics_);
}

void SkyView::CreateView(const String& name) {
DCHECK(!view_);
DCHECK(!dart_controller_);

view_ = View::create(
base::Bind(&SkyView::ScheduleFrame, weak_factory_.GetWeakPtr()));
view_->setDisplayMetrics(display_metrics_);

dart_controller_ = adoptPtr(new DartController);
dart_controller_->CreateIsolateFor(adoptPtr(new DOMDartState(name)));
dart_controller_->InstallView(view_.get());

Dart_Isolate isolate = dart_controller_->dart_state()->isolate();
DartIsolateScope scope(isolate);
DartApiScope api_scope;
client_->DidCreateIsolate(isolate);
}

void SkyView::RunFromLibrary(const WebString& name,
DartLibraryProvider* library_provider) {
CreateView(name);
DCHECK(view_);
dart_controller_->RunFromLibrary(name, library_provider);
}

void SkyView::RunFromSnapshot(const WebString& name,
mojo::ScopedDataPipeConsumerHandle snapshot) {
CreateView(name);
DCHECK(view_);
dart_controller_->RunFromSnapshot(snapshot.Pass());
}

Expand Down Expand Up @@ -81,24 +99,6 @@ void SkyView::HandleInputEvent(const WebInputEvent& inputEvent) {

}

void SkyView::CreateView(const String& name) {
DCHECK(!view_);
DCHECK(!dart_controller_);

view_ = View::create(
base::Bind(&SkyView::ScheduleFrame, weak_factory_.GetWeakPtr()));
view_->setDisplayMetrics(display_metrics_);

dart_controller_ = adoptPtr(new DartController);
dart_controller_->CreateIsolateFor(adoptPtr(new DOMDartState(name)));
dart_controller_->InstallView(view_.get());

Dart_Isolate isolate = dart_controller_->dart_state()->isolate();
DartIsolateScope scope(isolate);
DartApiScope api_scope;
client_->DidCreateIsolate(isolate);
}

void SkyView::ScheduleFrame() {
client_->ScheduleFrame();
}
Expand Down
3 changes: 2 additions & 1 deletion sky/engine/public/sky/sky_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class SkyView {
void SetDisplayMetrics(const SkyDisplayMetrics& metrics);
void BeginFrame(base::TimeTicks frame_time);

void CreateView(const String& name);

void RunFromLibrary(const WebString& name,
DartLibraryProvider* library_provider);
void RunFromSnapshot(const WebString& name,
Expand All @@ -49,7 +51,6 @@ class SkyView {
private:
explicit SkyView(SkyViewClient* client);

void CreateView(const String& name);
void ScheduleFrame();

SkyViewClient* client_;
Expand Down
2 changes: 2 additions & 0 deletions sky/shell/ui/engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ void Engine::OnInputEvent(InputEventPtr event) {

void Engine::RunFromLibrary(const std::string& name) {
sky_view_ = blink::SkyView::Create(this);
sky_view_->CreateView(blink::WebString::fromUTF8(name));
sky_view_->RunFromLibrary(blink::WebString::fromUTF8(name),
dart_library_provider_.get());
sky_view_->SetDisplayMetrics(display_metrics_);
Expand All @@ -175,6 +176,7 @@ void Engine::RunFromSnapshotStream(
const std::string& name,
mojo::ScopedDataPipeConsumerHandle snapshot) {
sky_view_ = blink::SkyView::Create(this);
sky_view_->CreateView(blink::WebString::fromUTF8(name));
sky_view_->RunFromSnapshot(blink::WebString::fromUTF8(name), snapshot.Pass());
sky_view_->SetDisplayMetrics(display_metrics_);
}
Expand Down