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

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

Issue 16048003: Fix race between DPI and window size (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove semicolon Created 7 years, 6 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 | Annotate | Revision Log
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_impl.h" 5 #include "content/browser/renderer_host/render_widget_host_impl.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 delegate_(delegate), 140 delegate_(delegate),
141 process_(process), 141 process_(process),
142 routing_id_(routing_id), 142 routing_id_(routing_id),
143 surface_id_(0), 143 surface_id_(0),
144 is_loading_(false), 144 is_loading_(false),
145 is_hidden_(false), 145 is_hidden_(false),
146 is_fullscreen_(false), 146 is_fullscreen_(false),
147 is_accelerated_compositing_active_(false), 147 is_accelerated_compositing_active_(false),
148 repaint_ack_pending_(false), 148 repaint_ack_pending_(false),
149 resize_ack_pending_(false), 149 resize_ack_pending_(false),
150 screen_info_out_of_date_(false),
150 overdraw_bottom_height_(0.f), 151 overdraw_bottom_height_(0.f),
151 should_auto_resize_(false), 152 should_auto_resize_(false),
152 waiting_for_screen_rects_ack_(false), 153 waiting_for_screen_rects_ack_(false),
153 mouse_move_pending_(false), 154 mouse_move_pending_(false),
154 mouse_wheel_pending_(false), 155 mouse_wheel_pending_(false),
155 accessibility_mode_(AccessibilityModeOff), 156 accessibility_mode_(AccessibilityModeOff),
156 select_range_pending_(false), 157 select_range_pending_(false),
157 move_caret_pending_(false), 158 move_caret_pending_(false),
158 needs_repainting_on_restore_(false), 159 needs_repainting_on_restore_(false),
159 is_unresponsive_(false), 160 is_unresponsive_(false),
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 520
520 gfx::Size old_physical_backing_size = physical_backing_size_; 521 gfx::Size old_physical_backing_size = physical_backing_size_;
521 physical_backing_size_ = view_->GetPhysicalBackingSize(); 522 physical_backing_size_ = view_->GetPhysicalBackingSize();
522 bool was_fullscreen = is_fullscreen_; 523 bool was_fullscreen = is_fullscreen_;
523 is_fullscreen_ = IsFullscreen(); 524 is_fullscreen_ = IsFullscreen();
524 float old_overdraw_bottom_height = overdraw_bottom_height_; 525 float old_overdraw_bottom_height = overdraw_bottom_height_;
525 overdraw_bottom_height_ = view_->GetOverdrawBottomHeight(); 526 overdraw_bottom_height_ = view_->GetOverdrawBottomHeight();
526 527
527 bool size_changed = new_size != current_size_; 528 bool size_changed = new_size != current_size_;
528 bool side_payload_changed = 529 bool side_payload_changed =
530 screen_info_out_of_date_ ||
529 old_physical_backing_size != physical_backing_size_ || 531 old_physical_backing_size != physical_backing_size_ ||
530 was_fullscreen != is_fullscreen_ || 532 was_fullscreen != is_fullscreen_ ||
531 old_overdraw_bottom_height != overdraw_bottom_height_; 533 old_overdraw_bottom_height != overdraw_bottom_height_;
532 534
533 if (!size_changed && !side_payload_changed) 535 if (!size_changed && !side_payload_changed)
534 return; 536 return;
535 537
536 if (in_flight_size_ != gfx::Size() && new_size == in_flight_size_ && 538 if (in_flight_size_ != gfx::Size() && new_size == in_flight_size_ &&
537 !side_payload_changed) 539 !side_payload_changed)
538 return; 540 return;
539 541
542 if (!screen_info_) {
543 screen_info_.reset(new WebKit::WebScreenInfo);
544 GetWebScreenInfo(screen_info_.get());
545 }
546
540 // We don't expect to receive an ACK when the requested size or the physical 547 // We don't expect to receive an ACK when the requested size or the physical
541 // backing size is empty, or when the main viewport size didn't change. 548 // backing size is empty, or when the main viewport size didn't change.
542 if (!new_size.IsEmpty() && !physical_backing_size_.IsEmpty() && size_changed) 549 if (!new_size.IsEmpty() && !physical_backing_size_.IsEmpty() && size_changed)
543 resize_ack_pending_ = true; 550 resize_ack_pending_ = true;
544 551
545 if (!Send(new ViewMsg_Resize(routing_id_, new_size, physical_backing_size_, 552 ViewMsg_Resize_Params params;
546 overdraw_bottom_height_, 553 params.screen_info = *screen_info_;
547 GetRootWindowResizerRect(), is_fullscreen_))) { 554 params.new_size = new_size;
555 params.physical_backing_size = physical_backing_size_;
556 params.overdraw_bottom_height = overdraw_bottom_height_;
557 params.resizer_rect = GetRootWindowResizerRect();
558 params.is_fullscreen = is_fullscreen_;
559 if (!Send(new ViewMsg_Resize(routing_id_, params))) {
548 resize_ack_pending_ = false; 560 resize_ack_pending_ = false;
549 } else { 561 } else {
550 in_flight_size_ = new_size; 562 in_flight_size_ = new_size;
551 } 563 }
552 } 564 }
553 565
554 void RenderWidgetHostImpl::ResizeRectChanged(const gfx::Rect& new_rect) { 566 void RenderWidgetHostImpl::ResizeRectChanged(const gfx::Rect& new_rect) {
555 Send(new ViewMsg_ChangeResizeRect(routing_id_, new_rect)); 567 Send(new ViewMsg_ChangeResizeRect(routing_id_, new_rect));
556 } 568 }
557 569
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 } 1338 }
1327 1339
1328 const NativeWebKeyboardEvent* 1340 const NativeWebKeyboardEvent*
1329 RenderWidgetHostImpl::GetLastKeyboardEvent() const { 1341 RenderWidgetHostImpl::GetLastKeyboardEvent() const {
1330 if (key_queue_.empty()) 1342 if (key_queue_.empty())
1331 return NULL; 1343 return NULL;
1332 return &key_queue_.front(); 1344 return &key_queue_.front();
1333 } 1345 }
1334 1346
1335 void RenderWidgetHostImpl::NotifyScreenInfoChanged() { 1347 void RenderWidgetHostImpl::NotifyScreenInfoChanged() {
1336 WebKit::WebScreenInfo screen_info; 1348 // The resize message (which may not happen immediately) will carry with it
1337 GetWebScreenInfo(&screen_info); 1349 // the screen info as well as the new size (if the screen has changed scale
1338 Send(new ViewMsg_ScreenInfoChanged(GetRoutingID(), screen_info)); 1350 // factor).
1351 screen_info_.reset();
1352 screen_info_out_of_date_ = true;
1353 WasResized();
1339 } 1354 }
1340 1355
1341 void RenderWidgetHostImpl::GetSnapshotFromRenderer( 1356 void RenderWidgetHostImpl::GetSnapshotFromRenderer(
1342 const gfx::Rect& src_subrect, 1357 const gfx::Rect& src_subrect,
1343 const base::Callback<void(bool, const SkBitmap&)>& callback) { 1358 const base::Callback<void(bool, const SkBitmap&)>& callback) {
1344 TRACE_EVENT0("browser", "RenderWidgetHostImpl::GetSnapshotFromRenderer"); 1359 TRACE_EVENT0("browser", "RenderWidgetHostImpl::GetSnapshotFromRenderer");
1345 pending_snapshots_.push(callback); 1360 pending_snapshots_.push(callback);
1346 1361
1347 gfx::Rect copy_rect = src_subrect.IsEmpty() ? 1362 gfx::Rect copy_rect = src_subrect.IsEmpty() ?
1348 gfx::Rect(view_->GetViewBounds().size()) : src_subrect; 1363 gfx::Rect(view_->GetViewBounds().size()) : src_subrect;
(...skipping 1133 matching lines...) Expand 10 before | Expand all | Expand 10 after
2482 } 2497 }
2483 2498
2484 void RenderWidgetHostImpl::DetachDelegate() { 2499 void RenderWidgetHostImpl::DetachDelegate() {
2485 delegate_ = NULL; 2500 delegate_ = NULL;
2486 } 2501 }
2487 2502
2488 void RenderWidgetHostImpl::FrameSwapped(const cc::LatencyInfo& latency_info) { 2503 void RenderWidgetHostImpl::FrameSwapped(const cc::LatencyInfo& latency_info) {
2489 } 2504 }
2490 2505
2491 } // namespace content 2506 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698