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

Side by Side Diff: content/browser/devtools/protocol/page_handler.cc

Issue 2122023002: Cross-process frames should be notified of device scale factor changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Version of patch without second test. Created 4 years, 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/devtools/protocol/page_handler.h" 5 #include "content/browser/devtools/protocol/page_handler.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/base64.h" 9 #include "base/base64.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/single_thread_task_runner.h" 12 #include "base/single_thread_task_runner.h"
13 #include "base/strings/string16.h" 13 #include "base/strings/string16.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "base/threading/worker_pool.h" 16 #include "base/threading/worker_pool.h"
17 #include "content/browser/devtools/page_navigation_throttle.h" 17 #include "content/browser/devtools/page_navigation_throttle.h"
18 #include "content/browser/devtools/protocol/color_picker.h" 18 #include "content/browser/devtools/protocol/color_picker.h"
19 #include "content/browser/renderer_host/render_widget_host_impl.h" 19 #include "content/browser/renderer_host/render_widget_host_impl.h"
20 #include "content/browser/renderer_host/render_widget_host_view_base.h" 20 #include "content/browser/renderer_host/render_widget_host_view_base.h"
21 #include "content/browser/web_contents/web_contents_impl.h" 21 #include "content/browser/web_contents/web_contents_impl.h"
22 #include "content/browser/web_contents/web_contents_view.h"
22 #include "content/common/view_messages.h" 23 #include "content/common/view_messages.h"
23 #include "content/public/browser/browser_thread.h" 24 #include "content/public/browser/browser_thread.h"
24 #include "content/public/browser/javascript_dialog_manager.h" 25 #include "content/public/browser/javascript_dialog_manager.h"
25 #include "content/public/browser/navigation_controller.h" 26 #include "content/public/browser/navigation_controller.h"
26 #include "content/public/browser/navigation_entry.h" 27 #include "content/public/browser/navigation_entry.h"
27 #include "content/public/browser/navigation_handle.h" 28 #include "content/public/browser/navigation_handle.h"
28 #include "content/public/browser/notification_service.h" 29 #include "content/public/browser/notification_service.h"
29 #include "content/public/browser/notification_types.h" 30 #include "content/public/browser/notification_types.h"
30 #include "content/public/browser/storage_partition.h" 31 #include "content/public/browser/storage_partition.h"
31 #include "content/public/browser/web_contents_delegate.h" 32 #include "content/public/browser/web_contents_delegate.h"
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 // TODO(vkuzkokov): do not use previous frame metadata. 465 // TODO(vkuzkokov): do not use previous frame metadata.
465 cc::CompositorFrameMetadata& metadata = last_compositor_frame_metadata_; 466 cc::CompositorFrameMetadata& metadata = last_compositor_frame_metadata_;
466 467
467 gfx::SizeF viewport_size_dip = gfx::ScaleSize( 468 gfx::SizeF viewport_size_dip = gfx::ScaleSize(
468 metadata.scrollable_viewport_size, metadata.page_scale_factor); 469 metadata.scrollable_viewport_size, metadata.page_scale_factor);
469 gfx::SizeF screen_size_dip = 470 gfx::SizeF screen_size_dip =
470 gfx::ScaleSize(gfx::SizeF(view->GetPhysicalBackingSize()), 471 gfx::ScaleSize(gfx::SizeF(view->GetPhysicalBackingSize()),
471 1 / metadata.device_scale_factor); 472 1 / metadata.device_scale_factor);
472 473
473 blink::WebScreenInfo screen_info; 474 blink::WebScreenInfo screen_info;
474 view->GetScreenInfo(&screen_info); 475 GetWebContents()->GetView()->GetScreenInfo(&screen_info);
475 double device_scale_factor = screen_info.deviceScaleFactor; 476 double device_scale_factor = screen_info.deviceScaleFactor;
476 double scale = 1; 477 double scale = 1;
477 478
478 if (screencast_max_width_ > 0) { 479 if (screencast_max_width_ > 0) {
479 double max_width_dip = screencast_max_width_ / device_scale_factor; 480 double max_width_dip = screencast_max_width_ / device_scale_factor;
480 scale = std::min(scale, max_width_dip / screen_size_dip.width()); 481 scale = std::min(scale, max_width_dip / screen_size_dip.width());
481 } 482 }
482 if (screencast_max_height_ > 0) { 483 if (screencast_max_height_ > 0) {
483 double max_height_dip = screencast_max_height_ / device_scale_factor; 484 double max_height_dip = screencast_max_height_ / device_scale_factor;
484 scale = std::min(scale, max_height_dip / screen_size_dip.height()); 485 scale = std::min(scale, max_height_dip / screen_size_dip.height());
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 580
580 void PageHandler::OnColorPicked(int r, int g, int b, int a) { 581 void PageHandler::OnColorPicked(int r, int g, int b, int a) {
581 scoped_refptr<dom::RGBA> color = 582 scoped_refptr<dom::RGBA> color =
582 dom::RGBA::Create()->set_r(r)->set_g(g)->set_b(b)->set_a(a); 583 dom::RGBA::Create()->set_r(r)->set_g(g)->set_b(b)->set_a(a);
583 client_->ColorPicked(ColorPickedParams::Create()->set_color(color)); 584 client_->ColorPicked(ColorPickedParams::Create()->set_color(color));
584 } 585 }
585 586
586 } // namespace page 587 } // namespace page
587 } // namespace devtools 588 } // namespace devtools
588 } // namespace content 589 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/devtools/protocol/color_picker.cc ('k') | content/browser/frame_host/cross_process_frame_connector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698