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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 2739113002: Simplify calls for scale factor (Closed)
Patch Set: nit Created 3 years, 9 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 #include "ui/aura/window.h" 75 #include "ui/aura/window.h"
76 #include "ui/aura/window_event_dispatcher.h" 76 #include "ui/aura/window_event_dispatcher.h"
77 #include "ui/aura/window_observer.h" 77 #include "ui/aura/window_observer.h"
78 #include "ui/aura/window_tree_host.h" 78 #include "ui/aura/window_tree_host.h"
79 #include "ui/base/clipboard/scoped_clipboard_writer.h" 79 #include "ui/base/clipboard/scoped_clipboard_writer.h"
80 #include "ui/base/hit_test.h" 80 #include "ui/base/hit_test.h"
81 #include "ui/base/ime/input_method.h" 81 #include "ui/base/ime/input_method.h"
82 #include "ui/base/ui_base_types.h" 82 #include "ui/base/ui_base_types.h"
83 #include "ui/compositor/compositor_vsync_manager.h" 83 #include "ui/compositor/compositor_vsync_manager.h"
84 #include "ui/compositor/dip_util.h" 84 #include "ui/compositor/dip_util.h"
85 #include "ui/display/display.h"
86 #include "ui/display/screen.h" 85 #include "ui/display/screen.h"
87 #include "ui/events/blink/blink_event_util.h" 86 #include "ui/events/blink/blink_event_util.h"
88 #include "ui/events/blink/web_input_event.h" 87 #include "ui/events/blink/web_input_event.h"
89 #include "ui/events/event.h" 88 #include "ui/events/event.h"
90 #include "ui/events/event_utils.h" 89 #include "ui/events/event_utils.h"
91 #include "ui/events/gesture_detection/gesture_configuration.h" 90 #include "ui/events/gesture_detection/gesture_configuration.h"
92 #include "ui/events/gestures/gesture_recognizer.h" 91 #include "ui/events/gestures/gesture_recognizer.h"
93 #include "ui/gfx/canvas.h" 92 #include "ui/gfx/canvas.h"
94 #include "ui/gfx/geometry/dip_util.h" 93 #include "ui/gfx/geometry/dip_util.h"
95 #include "ui/gfx/geometry/rect_conversions.h" 94 #include "ui/gfx/geometry/rect_conversions.h"
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 431
433 void RenderWidgetHostViewAura::InitAsChild( 432 void RenderWidgetHostViewAura::InitAsChild(
434 gfx::NativeView parent_view) { 433 gfx::NativeView parent_view) {
435 CreateDelegatedFrameHostClient(); 434 CreateDelegatedFrameHostClient();
436 435
437 CreateAuraWindow(ui::wm::WINDOW_TYPE_CONTROL); 436 CreateAuraWindow(ui::wm::WINDOW_TYPE_CONTROL);
438 437
439 if (parent_view) 438 if (parent_view)
440 parent_view->AddChild(GetNativeView()); 439 parent_view->AddChild(GetNativeView());
441 440
442 const display::Display display = 441 device_scale_factor_ = ui::GetScaleFactorForNativeView(window_);
443 display::Screen::GetScreen()->GetDisplayNearestWindow(window_);
444 device_scale_factor_ = display.device_scale_factor();
445 } 442 }
446 443
447 void RenderWidgetHostViewAura::InitAsPopup( 444 void RenderWidgetHostViewAura::InitAsPopup(
448 RenderWidgetHostView* parent_host_view, 445 RenderWidgetHostView* parent_host_view,
449 const gfx::Rect& bounds_in_screen) { 446 const gfx::Rect& bounds_in_screen) {
450 CreateDelegatedFrameHostClient(); 447 CreateDelegatedFrameHostClient();
451 448
452 popup_parent_host_view_ = 449 popup_parent_host_view_ =
453 static_cast<RenderWidgetHostViewAura*>(parent_host_view); 450 static_cast<RenderWidgetHostViewAura*>(parent_host_view);
454 451
(...skipping 28 matching lines...) Expand all
483 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow(); 480 aura::Window* root = popup_parent_host_view_->window_->GetRootWindow();
484 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen); 481 aura::client::ParentWindowWithContext(window_, root, bounds_in_screen);
485 482
486 SetBounds(bounds_in_screen); 483 SetBounds(bounds_in_screen);
487 Show(); 484 Show();
488 if (NeedsMouseCapture()) 485 if (NeedsMouseCapture())
489 window_->SetCapture(); 486 window_->SetCapture();
490 487
491 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); 488 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this));
492 489
493 const display::Display display = 490 device_scale_factor_ = ui::GetScaleFactorForNativeView(window_);
494 display::Screen::GetScreen()->GetDisplayNearestWindow(window_);
495 device_scale_factor_ = display.device_scale_factor();
496 } 491 }
497 492
498 void RenderWidgetHostViewAura::InitAsFullscreen( 493 void RenderWidgetHostViewAura::InitAsFullscreen(
499 RenderWidgetHostView* reference_host_view) { 494 RenderWidgetHostView* reference_host_view) {
500 is_fullscreen_ = true; 495 is_fullscreen_ = true;
501 CreateDelegatedFrameHostClient(); 496 CreateDelegatedFrameHostClient();
502 CreateAuraWindow(ui::wm::WINDOW_TYPE_NORMAL); 497 CreateAuraWindow(ui::wm::WINDOW_TYPE_NORMAL);
503 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN); 498 window_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_FULLSCREEN);
504 499
505 aura::Window* parent = NULL; 500 aura::Window* parent = NULL;
506 gfx::Rect bounds; 501 gfx::Rect bounds;
507 if (reference_host_view) { 502 if (reference_host_view) {
508 aura::Window* reference_window = 503 aura::Window* reference_window =
509 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_; 504 static_cast<RenderWidgetHostViewAura*>(reference_host_view)->window_;
510 event_handler_->TrackHost(reference_window); 505 event_handler_->TrackHost(reference_window);
511 display::Display display = 506 display::Display display =
512 display::Screen::GetScreen()->GetDisplayNearestWindow(reference_window); 507 display::Screen::GetScreen()->GetDisplayNearestWindow(reference_window);
513 parent = reference_window->GetRootWindow(); 508 parent = reference_window->GetRootWindow();
514 bounds = display.bounds(); 509 bounds = display.bounds();
515 } 510 }
516 aura::client::ParentWindowWithContext(window_, parent, bounds); 511 aura::client::ParentWindowWithContext(window_, parent, bounds);
517 Show(); 512 Show();
518 Focus(); 513 Focus();
519 514
520 const display::Display display = 515 device_scale_factor_ = ui::GetScaleFactorForNativeView(window_);
521 display::Screen::GetScreen()->GetDisplayNearestWindow(window_);
522 device_scale_factor_ = display.device_scale_factor();
523 } 516 }
524 517
525 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const { 518 RenderWidgetHost* RenderWidgetHostViewAura::GetRenderWidgetHost() const {
526 return host_; 519 return host_;
527 } 520 }
528 521
529 void RenderWidgetHostViewAura::Show() { 522 void RenderWidgetHostViewAura::Show() {
530 window_->Show(); 523 window_->Show();
531 524
532 if (!host_->is_hidden()) 525 if (!host_->is_hidden())
(...skipping 1843 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 2369
2377 void RenderWidgetHostViewAura::SetPopupChild( 2370 void RenderWidgetHostViewAura::SetPopupChild(
2378 RenderWidgetHostViewAura* popup_child_host_view) { 2371 RenderWidgetHostViewAura* popup_child_host_view) {
2379 popup_child_host_view_ = popup_child_host_view; 2372 popup_child_host_view_ = popup_child_host_view;
2380 event_handler_->SetPopupChild( 2373 event_handler_->SetPopupChild(
2381 popup_child_host_view, 2374 popup_child_host_view,
2382 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr); 2375 popup_child_host_view ? popup_child_host_view->event_handler() : nullptr);
2383 } 2376 }
2384 2377
2385 } // namespace content 2378 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698