Commit fa83647c authored by sky's avatar sky Committed by Commit bot

Wires through scale factor and bounds in html_viewer

R=jamesr@chromium.org

Review URL: https://codereview.chromium.org/1018543002

Cr-Commit-Position: refs/heads/master@{#320998}
parent 5f80e74c
...@@ -98,6 +98,7 @@ source_set("lib") { ...@@ -98,6 +98,7 @@ source_set("lib") {
"//third_party/mojo_services/src/input_events/public/interfaces", "//third_party/mojo_services/src/input_events/public/interfaces",
"//third_party/mojo_services/src/navigation/public/interfaces", "//third_party/mojo_services/src/navigation/public/interfaces",
"//third_party/mojo_services/src/surfaces/public/interfaces", "//third_party/mojo_services/src/surfaces/public/interfaces",
"//ui/gfx/geometry",
"//ui/native_theme", "//ui/native_theme",
"//url", "//url",
] ]
......
...@@ -14,5 +14,6 @@ include_rules = [ ...@@ -14,5 +14,6 @@ include_rules = [
"+third_party/skia/include", "+third_party/skia/include",
"+ui/base", "+ui/base",
"+ui/events", "+ui/events",
"+ui/gfx/geometry",
"+ui/native_theme", "+ui/native_theme",
] ]
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "third_party/skia/include/core/SkCanvas.h" #include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkDevice.h" #include "third_party/skia/include/core/SkDevice.h"
#include "ui/gfx/geometry/dip_util.h"
using mojo::AxProvider; using mojo::AxProvider;
using mojo::Rect; using mojo::Rect;
...@@ -135,10 +136,7 @@ void HTMLDocument::OnEmbed( ...@@ -135,10 +136,7 @@ void HTMLDocument::OnEmbed(
root_ = root; root_ = root;
embedder_service_provider_ = exposed_services.Pass(); embedder_service_provider_ = exposed_services.Pass();
navigator_host_.set_service_provider(embedder_service_provider_.get()); navigator_host_.set_service_provider(embedder_service_provider_.get());
UpdateWebviewSizeFromViewSize();
blink::WebSize root_size(root_->bounds().width, root_->bounds().height);
web_view_->resize(root_size);
web_layer_tree_view_impl_->setViewportSize(root_size);
web_layer_tree_view_impl_->set_view(root_); web_layer_tree_view_impl_->set_view(root_);
root_->AddObserver(this); root_->AddObserver(this);
} }
...@@ -174,6 +172,16 @@ void HTMLDocument::Load(URLResponsePtr response) { ...@@ -174,6 +172,16 @@ void HTMLDocument::Load(URLResponsePtr response) {
web_view_->mainFrame()->loadRequest(web_request); web_view_->mainFrame()->loadRequest(web_request);
} }
void HTMLDocument::UpdateWebviewSizeFromViewSize() {
web_view_->setDeviceScaleFactor(root_->viewport_metrics().device_pixel_ratio);
const gfx::Size size_in_pixels(root_->bounds().width, root_->bounds().height);
const gfx::Size size_in_dips = gfx::ConvertSizeToDIP(
root_->viewport_metrics().device_pixel_ratio, size_in_pixels);
web_view_->resize(
blink::WebSize(size_in_dips.width(), size_in_dips.height()));
web_layer_tree_view_impl_->setViewportSize(size_in_pixels);
}
blink::WebStorageNamespace* HTMLDocument::createSessionStorageNamespace() { blink::WebStorageNamespace* HTMLDocument::createSessionStorageNamespace() {
return new WebStorageNamespaceImpl(); return new WebStorageNamespaceImpl();
} }
...@@ -303,8 +311,7 @@ void HTMLDocument::OnViewBoundsChanged(View* view, ...@@ -303,8 +311,7 @@ void HTMLDocument::OnViewBoundsChanged(View* view,
const Rect& old_bounds, const Rect& old_bounds,
const Rect& new_bounds) { const Rect& new_bounds) {
DCHECK_EQ(view, root_); DCHECK_EQ(view, root_);
web_view_->resize( UpdateWebviewSizeFromViewSize();
blink::WebSize(view->bounds().width, view->bounds().height));
} }
void HTMLDocument::OnViewDestroyed(View* view) { void HTMLDocument::OnViewDestroyed(View* view) {
......
...@@ -69,6 +69,10 @@ class HTMLDocument : public blink::WebViewClient, ...@@ -69,6 +69,10 @@ class HTMLDocument : public blink::WebViewClient,
virtual ~HTMLDocument(); virtual ~HTMLDocument();
private: private:
// Updates the size and scale factor of the webview and related classes from
// |root_|.
void UpdateWebviewSizeFromViewSize();
// WebViewClient methods: // WebViewClient methods:
virtual blink::WebStorageNamespace* createSessionStorageNamespace(); virtual blink::WebStorageNamespace* createSessionStorageNamespace();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment