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

Side by Side Diff: sky/shell/ui/engine.cc

Issue 953933004: Fix display of fonts in SkyShell (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: One patch, not two Created 5 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 | « sky/shell/ui/engine.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 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/shell/ui/engine.h" 5 #include "sky/shell/ui/engine.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "sky/engine/public/platform/WebInputEvent.h" 8 #include "sky/engine/public/platform/WebInputEvent.h"
9 #include "sky/engine/public/web/Sky.h" 9 #include "sky/engine/public/web/Sky.h"
10 #include "sky/engine/public/web/WebLocalFrame.h" 10 #include "sky/engine/public/web/WebLocalFrame.h"
11 #include "sky/engine/public/web/WebSettings.h"
11 #include "sky/engine/public/web/WebView.h" 12 #include "sky/engine/public/web/WebView.h"
12 #include "sky/shell/ui/animator.h" 13 #include "sky/shell/ui/animator.h"
13 #include "sky/shell/ui/input_event_converter.h" 14 #include "sky/shell/ui/input_event_converter.h"
14 #include "sky/shell/ui/platform_impl.h" 15 #include "sky/shell/ui/platform_impl.h"
15 #include "third_party/skia/include/core/SkCanvas.h" 16 #include "third_party/skia/include/core/SkCanvas.h"
16 #include "third_party/skia/include/core/SkPictureRecorder.h" 17 #include "third_party/skia/include/core/SkPictureRecorder.h"
17 18
18 namespace sky { 19 namespace sky {
19 namespace shell { 20 namespace shell {
20 21
22 namespace {
23
24 void ConfigureSettings(blink::WebSettings* settings) {
25 settings->setDefaultFixedFontSize(13);
26 settings->setDefaultFontSize(16);
27 settings->setLoadsImagesAutomatically(true);
28 }
29
30 }
31
21 Engine::Engine(const Config& config) 32 Engine::Engine(const Config& config)
22 : animator_(new Animator(config, this)), 33 : animator_(new Animator(config, this)),
23 web_view_(nullptr), 34 web_view_(nullptr),
24 device_pixel_ratio_(1.0f), 35 device_pixel_ratio_(1.0f),
25 viewport_observer_binding_(this), 36 viewport_observer_binding_(this),
26 weak_factory_(this) { 37 weak_factory_(this) {
27 } 38 }
28 39
29 Engine::~Engine() { 40 Engine::~Engine() {
30 if (web_view_) 41 if (web_view_)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 void Engine::UpdateWebViewSize() 89 void Engine::UpdateWebViewSize()
79 { 90 {
80 CHECK(web_view_); 91 CHECK(web_view_);
81 web_view_->setDeviceScaleFactor(device_pixel_ratio_); 92 web_view_->setDeviceScaleFactor(device_pixel_ratio_);
82 gfx::SizeF size = gfx::ScaleSize(physical_size_, 1 / device_pixel_ratio_); 93 gfx::SizeF size = gfx::ScaleSize(physical_size_, 1 / device_pixel_ratio_);
83 // FIXME: We should be able to set the size of the WebView in floating point 94 // FIXME: We should be able to set the size of the WebView in floating point
84 // because its in logical pixels. 95 // because its in logical pixels.
85 web_view_->resize(blink::WebSize(size.width(), size.height())); 96 web_view_->resize(blink::WebSize(size.width(), size.height()));
86 } 97 }
87 98
99 // TODO(eseidel): This is likely not needed anymore.
100 blink::WebScreenInfo Engine::screenInfo() {
101 blink::WebScreenInfo screen;
102 screen.rect = blink::WebRect(gfx::Rect(physical_size_));
103 screen.availableRect = screen.rect;
104 screen.deviceScaleFactor = device_pixel_ratio_;
105 return screen;
106 }
107
88 void Engine::OnInputEvent(InputEventPtr event) { 108 void Engine::OnInputEvent(InputEventPtr event) {
89 scoped_ptr<blink::WebInputEvent> web_event = 109 scoped_ptr<blink::WebInputEvent> web_event =
90 ConvertEvent(event, device_pixel_ratio_); 110 ConvertEvent(event, device_pixel_ratio_);
91 if (!web_event) 111 if (!web_event)
92 return; 112 return;
93 web_view_->handleInputEvent(*web_event); 113 web_view_->handleInputEvent(*web_event);
94 } 114 }
95 115
96 void Engine::LoadURL(const mojo::String& url) { 116 void Engine::LoadURL(const mojo::String& url) {
97 web_view_ = blink::WebView::create(this); 117 web_view_ = blink::WebView::create(this);
118 ConfigureSettings(web_view_->settings());
98 web_view_->setMainFrame(blink::WebLocalFrame::create(this)); 119 web_view_->setMainFrame(blink::WebLocalFrame::create(this));
99 UpdateWebViewSize(); 120 UpdateWebViewSize();
100 web_view_->mainFrame()->load(GURL(url)); 121 web_view_->mainFrame()->load(GURL(url));
101 } 122 }
102 123
103 void Engine::initializeLayerTreeView() { 124 void Engine::initializeLayerTreeView() {
104 } 125 }
105 126
106 void Engine::scheduleVisualUpdate() { 127 void Engine::scheduleVisualUpdate() {
107 animator_->RequestFrame(); 128 animator_->RequestFrame();
108 } 129 }
109 130
110 } // namespace shell 131 } // namespace shell
111 } // namespace sky 132 } // namespace sky
OLDNEW
« no previous file with comments | « sky/shell/ui/engine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698